babylon.module.d.ts 6.7 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962139963139964139965139966139967139968139969139970139971139972139973139974139975139976139977139978139979139980139981139982139983139984139985139986139987139988139989139990139991139992139993139994139995139996139997139998139999140000140001140002140003140004140005140006140007140008140009140010140011140012140013140014140015140016140017140018140019140020140021140022140023140024140025140026140027140028140029140030140031140032140033140034140035140036140037140038140039140040140041140042140043140044140045140046140047140048140049140050140051140052140053140054140055140056140057140058140059140060140061140062140063140064140065140066140067140068140069140070140071140072140073140074140075140076140077140078140079140080140081140082140083140084140085140086140087140088140089140090140091140092140093140094140095140096140097140098140099140100140101140102140103140104140105140106140107140108140109140110140111140112140113140114140115140116140117140118140119140120140121140122140123140124140125140126140127140128140129140130140131140132140133140134140135140136140137140138140139140140140141140142140143140144140145140146140147140148140149140150140151140152140153140154140155140156140157140158140159140160140161140162140163140164140165140166140167140168140169140170140171140172140173140174140175140176140177140178140179140180140181140182140183140184140185140186140187140188140189140190140191140192140193140194140195140196140197140198140199140200140201140202140203140204140205140206140207140208140209140210140211140212140213140214140215140216140217140218140219140220140221140222140223140224140225140226140227140228140229140230140231140232140233140234140235140236140237140238140239140240140241140242140243140244140245140246140247140248140249140250140251140252140253140254140255140256140257140258140259140260140261140262140263140264140265140266140267140268140269140270140271140272140273140274140275140276140277140278140279140280140281140282140283140284140285140286140287140288140289140290140291140292140293140294140295140296140297140298140299140300140301140302140303140304140305140306140307140308140309140310140311140312140313140314140315140316140317140318140319140320140321140322140323140324140325140326140327140328140329140330140331140332140333140334140335140336140337140338140339140340140341140342140343140344140345140346140347140348140349140350140351140352140353140354140355140356140357140358140359140360140361140362140363140364140365140366140367140368140369140370140371140372140373140374140375140376140377140378140379140380140381140382140383140384140385140386140387140388140389140390140391140392140393140394140395140396140397140398140399140400140401140402140403140404140405140406140407140408140409140410140411140412140413140414140415140416140417140418140419140420140421140422140423140424140425140426140427140428140429140430140431140432140433140434140435140436140437140438140439140440140441140442140443140444140445140446140447140448140449140450140451140452140453140454140455140456140457140458140459140460140461140462140463140464140465140466140467140468140469140470140471140472140473140474140475140476140477140478140479140480140481140482140483140484140485140486140487140488140489140490140491140492140493140494140495140496140497140498140499140500140501140502140503140504140505140506140507140508140509140510140511140512140513140514140515140516140517140518140519140520140521140522140523140524140525140526140527140528140529140530140531140532140533140534140535140536140537140538140539140540140541140542140543140544140545140546140547140548140549140550140551140552140553140554140555140556140557140558140559140560140561140562140563140564140565140566140567140568140569140570140571140572140573140574140575140576140577140578140579140580140581140582140583140584140585140586140587140588140589140590140591140592140593140594140595140596140597140598140599140600140601140602140603140604140605140606140607140608140609140610140611140612140613140614140615140616140617140618140619140620140621140622140623140624140625140626140627140628140629140630140631140632140633140634140635140636140637140638140639140640140641140642140643140644140645140646140647140648140649140650140651140652140653140654140655140656140657140658140659140660140661140662140663140664140665140666140667140668140669140670140671140672140673140674140675140676140677140678140679140680140681140682140683140684140685140686140687140688140689140690140691140692140693140694140695140696140697140698140699140700140701140702140703140704140705140706140707140708140709140710140711140712140713140714140715140716140717140718140719140720140721140722140723140724140725140726140727140728140729140730140731140732140733140734140735140736140737140738140739140740140741140742140743140744140745140746140747140748140749140750140751140752140753140754140755140756140757140758140759140760140761140762140763140764140765140766140767140768140769140770140771140772140773140774140775140776140777140778140779140780140781140782140783140784140785140786140787140788140789140790140791140792140793140794140795140796140797140798140799140800140801140802140803140804140805140806140807140808140809140810140811140812140813140814140815140816140817140818140819140820140821140822140823140824140825140826140827140828140829140830140831140832140833140834140835140836140837140838140839140840140841140842140843140844140845140846140847140848140849140850140851140852140853140854140855140856140857140858140859140860140861140862140863140864140865140866140867140868140869140870140871140872140873140874140875140876140877140878140879140880140881140882140883140884140885140886140887140888140889140890140891140892140893140894140895140896140897140898140899140900140901140902140903140904140905140906140907140908140909140910140911140912140913140914140915140916140917140918140919140920140921140922140923140924140925140926140927140928140929140930140931140932140933140934140935140936140937140938140939140940140941140942140943140944140945140946140947140948140949140950140951140952140953140954140955140956140957140958140959140960140961140962140963140964140965140966140967140968140969140970140971140972140973140974140975140976140977140978140979140980140981140982140983140984140985140986140987140988140989140990140991140992140993140994140995140996140997140998140999141000141001141002141003141004141005141006141007141008141009141010141011141012141013141014141015141016141017141018141019141020141021141022141023141024141025141026141027141028141029141030141031141032141033141034141035141036141037141038141039141040141041141042141043141044141045141046141047141048141049141050141051141052141053141054141055141056141057141058141059141060141061141062141063141064141065141066141067141068141069141070141071141072141073141074141075141076141077141078141079141080141081141082141083141084141085141086141087141088141089141090141091141092141093141094141095141096141097141098141099141100141101141102141103141104141105141106141107141108141109141110141111141112141113141114141115141116141117141118141119141120141121141122141123141124141125141126141127141128141129141130141131141132141133141134141135141136141137141138141139141140141141141142141143141144141145141146141147141148141149141150141151141152141153141154141155141156141157141158141159141160141161141162141163141164141165141166141167141168141169141170141171141172141173141174141175141176141177141178141179141180141181141182141183141184141185141186141187141188141189141190141191141192141193141194141195141196141197141198141199141200141201141202141203141204141205141206141207141208141209141210141211141212141213141214141215141216141217141218141219141220141221141222141223141224141225141226141227141228141229141230141231141232141233141234141235141236141237141238141239141240141241141242141243141244141245141246141247141248141249141250141251141252141253141254141255141256141257141258141259141260141261141262141263141264141265141266141267141268141269141270141271141272141273141274141275141276141277141278141279141280141281141282141283141284141285141286141287141288141289141290141291141292141293141294141295141296141297141298141299141300141301141302141303141304141305141306141307141308141309141310141311141312141313141314141315141316141317141318141319141320141321141322141323141324141325141326141327141328141329141330141331141332141333141334141335141336141337141338141339141340141341141342141343141344141345141346141347141348141349141350141351141352141353141354141355141356141357141358141359141360141361141362141363141364141365141366141367141368141369141370141371141372141373141374141375141376141377141378141379141380141381141382141383141384141385141386141387141388141389141390141391141392141393141394141395141396141397141398141399141400141401141402141403141404141405141406141407141408141409141410141411141412141413141414141415141416141417141418141419141420141421141422141423141424141425141426141427141428141429141430141431141432141433141434141435141436141437141438141439141440141441141442141443141444141445141446141447141448141449141450141451141452141453141454141455141456141457141458141459141460141461141462141463141464141465141466141467141468141469141470141471141472141473141474141475141476141477141478141479141480141481141482141483141484141485141486141487141488141489141490141491141492141493141494141495141496141497141498141499141500141501141502141503141504141505141506141507141508141509141510141511141512141513141514141515141516141517141518141519141520141521141522141523141524141525141526141527141528141529141530141531141532141533141534141535141536141537141538141539141540141541141542141543141544141545141546141547141548141549141550141551141552141553141554141555141556141557141558141559141560141561141562141563141564141565141566141567141568141569141570141571141572141573141574141575141576141577141578141579141580141581141582141583141584141585141586141587141588141589141590141591141592141593141594141595141596141597141598141599141600141601141602141603141604141605141606141607141608141609141610141611141612141613141614141615141616141617141618141619141620141621141622141623141624141625141626141627141628141629141630141631141632141633141634141635141636141637141638141639141640141641141642141643141644141645141646141647141648141649141650141651141652141653141654141655141656141657141658141659141660141661141662141663141664141665141666141667141668141669141670141671141672141673141674141675141676141677141678141679141680141681141682141683141684141685141686141687141688141689141690141691141692141693141694141695141696141697141698141699141700141701141702141703141704141705141706141707141708141709141710141711141712141713141714141715141716141717141718141719141720141721141722141723141724141725141726141727141728141729141730141731141732141733141734141735141736141737141738141739141740141741141742141743141744141745141746141747141748141749141750141751141752141753141754141755141756141757141758141759141760141761141762141763141764141765141766141767141768141769141770141771141772141773141774141775141776141777141778141779141780141781141782141783141784141785141786141787141788141789141790141791141792141793141794141795141796141797141798141799141800141801141802141803141804141805141806141807141808141809141810141811141812141813141814141815141816141817141818141819141820141821141822141823141824141825141826141827141828141829141830141831141832141833141834141835141836141837141838141839141840141841141842141843141844141845141846141847141848141849141850141851141852141853141854141855141856141857141858141859141860141861141862141863141864141865141866141867141868141869141870141871141872141873141874141875141876141877141878141879141880141881141882141883141884141885141886141887141888141889141890141891141892141893141894141895141896141897141898141899141900141901141902141903141904141905141906141907141908141909141910141911141912141913141914141915141916141917141918141919141920141921141922141923141924141925141926141927141928141929141930141931141932141933141934141935141936141937141938141939141940141941141942141943141944141945141946141947141948141949141950141951141952141953141954141955141956141957141958141959141960141961141962141963141964141965141966141967141968141969141970141971141972141973141974141975141976141977141978141979141980141981141982141983141984141985141986141987141988141989141990141991141992141993141994141995141996141997141998141999142000142001142002142003142004142005142006142007142008142009142010142011142012142013142014142015142016142017142018142019142020142021142022142023142024142025142026142027142028142029142030142031142032142033142034142035142036142037142038142039142040142041142042142043142044142045142046142047142048142049142050142051142052142053142054142055142056142057142058142059142060142061142062142063142064142065142066142067142068142069142070142071142072142073142074142075142076142077142078142079142080142081142082142083142084142085142086142087142088142089142090142091142092142093142094142095142096142097142098142099142100142101142102142103142104142105142106142107142108142109142110142111142112142113142114142115142116142117142118142119142120142121142122142123142124142125142126142127142128142129142130142131142132142133142134142135142136142137142138142139142140142141142142142143142144142145142146142147142148142149142150142151142152142153142154142155142156142157142158142159142160142161142162142163142164142165142166142167142168142169142170142171142172142173142174142175142176142177142178142179142180142181142182142183142184142185142186142187142188142189142190142191142192142193142194142195142196142197142198142199142200142201142202142203142204142205142206142207142208142209142210142211142212142213142214142215142216142217142218142219142220142221142222142223142224142225142226142227142228142229142230142231142232142233142234142235142236142237142238142239142240142241142242142243142244142245142246142247142248142249142250142251142252142253142254142255142256142257142258142259142260142261142262142263142264142265142266142267142268142269142270142271142272142273142274142275142276142277142278142279142280142281142282142283142284142285142286142287142288142289142290142291142292142293142294142295142296142297142298142299142300142301142302142303142304142305142306142307142308142309142310142311142312142313142314142315142316142317142318142319142320142321142322142323142324142325142326142327142328142329142330142331142332142333142334142335142336142337142338142339142340142341142342142343142344142345142346142347142348142349142350142351142352142353142354142355142356142357142358142359142360142361142362142363142364142365142366142367142368142369142370142371142372142373142374142375142376142377142378142379142380142381142382142383142384142385142386142387142388142389142390142391142392142393142394142395142396142397142398142399142400142401142402142403142404142405142406142407142408142409142410142411142412142413142414142415142416142417142418142419142420142421142422142423142424142425142426142427142428142429142430142431142432142433142434142435142436142437142438142439142440142441142442142443142444142445142446142447142448142449142450142451142452142453142454142455142456142457142458142459142460142461142462142463142464142465142466142467142468142469142470142471142472142473142474142475142476142477142478142479142480142481142482142483142484142485142486142487142488142489142490142491142492142493142494142495142496142497142498142499142500142501142502142503142504142505142506142507142508142509142510142511142512142513142514142515142516142517142518142519142520142521142522142523142524142525142526142527142528142529142530142531142532142533142534142535142536142537142538142539142540142541142542142543142544142545142546142547142548142549142550142551142552142553142554142555142556142557142558142559142560142561142562142563142564142565142566142567142568142569142570142571142572142573142574142575142576142577142578142579142580142581142582142583142584142585142586142587142588142589142590142591142592142593142594142595142596142597142598142599142600142601142602142603142604142605142606142607142608142609142610142611142612142613142614142615142616142617142618142619142620142621142622142623142624142625142626142627142628142629142630142631142632142633142634142635142636142637142638142639142640142641142642142643142644142645142646142647142648142649142650142651142652142653142654142655142656142657142658142659142660142661142662142663142664142665142666142667142668142669142670142671142672142673142674142675142676142677142678142679142680142681142682142683142684142685142686142687142688142689142690142691142692142693142694142695142696142697142698142699142700142701142702142703142704142705142706142707142708142709142710142711142712142713142714142715142716142717142718142719142720142721142722142723142724142725142726142727142728142729142730142731142732142733142734142735142736142737142738142739142740142741142742142743142744142745142746142747142748142749142750142751142752142753142754142755142756142757142758142759142760142761142762142763142764142765142766142767142768142769142770142771142772142773142774142775142776142777142778142779142780142781142782142783142784142785142786142787142788142789142790142791142792142793142794142795142796142797142798142799142800142801142802142803142804142805142806142807142808142809142810142811142812142813142814142815142816142817142818142819142820142821142822142823142824142825142826142827142828142829142830142831142832142833142834142835142836142837142838142839142840142841142842142843142844142845142846142847142848142849142850142851142852142853142854142855142856142857142858142859142860142861142862142863142864142865142866142867142868142869142870142871142872142873142874142875142876142877142878142879142880142881142882142883142884142885142886142887142888142889142890142891142892142893142894142895142896142897142898142899142900142901142902142903142904142905142906142907142908142909142910142911142912142913142914142915142916142917142918142919142920142921142922142923142924142925142926142927142928142929142930142931142932142933142934142935142936142937142938142939142940142941142942142943142944142945142946142947142948142949142950142951142952142953142954142955142956142957142958142959142960142961142962142963142964142965142966142967142968142969142970142971142972142973142974142975142976142977142978142979142980142981142982142983142984142985142986142987142988142989142990142991142992142993142994142995142996142997142998142999143000143001143002143003143004143005143006143007143008143009143010143011143012143013143014143015143016143017143018143019143020143021143022143023143024143025143026143027143028143029143030143031143032143033143034143035143036143037143038143039143040143041143042143043143044143045143046143047143048143049143050143051143052143053143054143055143056143057143058143059143060143061143062143063143064143065143066143067143068143069143070143071143072143073143074143075143076143077143078143079143080143081143082143083143084143085143086143087143088143089143090143091143092143093143094143095143096143097143098143099143100143101143102143103143104143105143106143107143108143109143110143111143112143113143114143115143116143117143118143119143120143121143122143123143124143125143126143127143128143129143130143131143132143133143134143135143136143137143138143139143140143141143142143143143144143145143146143147143148143149143150143151143152143153143154143155143156143157143158143159143160143161143162143163143164143165143166143167143168143169143170143171143172143173143174143175143176143177143178143179143180143181143182143183143184143185143186143187143188143189143190143191143192143193143194143195143196143197143198143199143200143201143202143203143204143205143206143207143208143209143210143211143212143213143214143215143216143217143218143219143220143221143222143223143224143225143226143227143228143229143230143231143232143233143234143235143236143237143238143239143240143241143242143243143244143245143246143247143248143249143250143251143252143253143254143255143256143257143258143259143260143261143262143263143264143265143266143267143268143269143270143271143272143273143274143275143276143277143278143279143280143281143282143283143284143285143286143287143288143289143290143291143292143293143294143295143296143297143298143299143300143301143302143303143304143305143306143307143308143309143310143311143312143313143314143315143316143317143318143319143320143321143322143323143324143325143326143327143328143329143330143331143332143333143334143335143336143337143338143339143340143341143342143343143344143345143346143347143348143349143350143351143352143353143354143355143356143357143358143359143360143361143362143363143364143365143366143367143368143369143370143371143372143373143374143375143376143377143378143379143380143381143382143383143384143385143386143387143388143389143390143391143392143393143394143395143396143397143398143399143400143401143402143403143404143405143406143407143408143409143410143411143412143413143414143415143416143417143418143419143420143421143422143423143424143425143426143427143428143429143430143431143432143433143434143435143436143437143438143439143440143441143442143443143444143445143446143447143448143449143450143451143452143453143454143455143456143457143458143459143460143461143462143463143464143465143466143467143468143469143470143471143472143473143474143475143476143477143478143479143480143481143482143483143484143485143486143487143488143489143490143491143492143493143494143495143496143497143498143499143500143501143502143503143504143505143506143507143508143509143510143511143512143513143514143515143516143517143518143519143520143521143522143523143524143525143526143527143528143529143530143531143532143533143534143535143536143537143538143539143540143541143542143543143544143545143546143547143548143549143550143551143552143553143554143555143556143557143558143559143560143561143562143563143564143565143566143567143568143569143570143571143572143573143574143575143576143577143578143579143580143581143582143583143584143585143586143587143588143589143590143591143592143593143594143595143596143597143598143599143600143601143602143603143604143605143606143607143608143609143610143611143612143613143614143615143616143617143618143619143620143621143622143623143624143625143626143627143628143629143630143631143632143633143634143635143636143637143638143639143640143641143642143643143644143645143646143647143648143649143650143651143652143653143654143655143656143657143658143659143660143661143662143663143664143665143666143667143668143669143670143671143672143673143674143675143676143677143678143679143680143681143682143683143684143685143686143687143688143689143690143691143692143693143694143695143696143697143698143699143700143701143702143703143704143705143706143707143708143709143710143711143712143713143714143715143716143717143718143719143720143721143722143723143724143725143726143727143728143729143730143731143732143733143734143735143736143737143738143739143740143741143742143743143744143745143746143747143748143749143750143751143752143753143754143755143756143757143758143759143760143761143762143763143764143765143766143767143768143769143770143771143772143773143774143775143776143777143778143779143780143781143782143783143784143785143786143787143788143789143790143791143792143793143794143795143796143797143798143799143800143801143802143803143804143805143806143807143808143809143810143811143812143813143814143815143816143817143818143819143820143821143822143823143824143825143826143827143828143829143830143831143832143833143834143835143836143837143838143839143840143841143842143843143844143845143846143847143848143849143850143851143852143853143854143855143856143857143858143859143860143861143862143863143864143865143866143867143868143869143870143871143872143873143874143875143876143877143878143879143880143881143882143883143884143885143886143887143888143889143890143891143892143893143894143895143896143897143898143899143900143901143902143903143904143905143906143907143908143909143910143911143912143913143914143915143916143917143918143919143920143921143922143923143924143925143926143927143928143929143930143931143932143933143934143935143936143937143938143939143940143941143942143943143944143945143946143947143948143949143950143951143952143953143954143955143956143957143958143959143960143961143962143963143964143965143966143967143968143969143970143971143972143973143974143975143976143977143978143979143980143981143982143983143984143985143986143987143988143989143990143991143992143993143994143995143996143997143998143999144000144001144002144003144004144005144006144007144008144009144010144011144012144013144014144015144016144017144018144019144020144021144022144023144024144025144026144027144028144029144030144031144032144033144034144035144036144037144038144039144040144041144042144043144044144045144046144047144048144049144050144051144052144053144054144055144056144057144058144059144060144061144062144063144064144065144066144067144068144069144070144071144072144073144074144075144076144077144078144079144080144081144082144083144084144085144086144087144088144089144090144091144092144093144094144095144096144097144098144099144100144101144102144103144104144105144106144107144108144109144110144111144112144113144114144115144116144117144118144119144120144121144122144123144124144125144126144127144128144129144130144131144132144133144134144135144136144137144138144139144140144141144142144143144144144145144146144147144148144149144150144151144152144153144154144155144156144157144158144159144160144161144162144163144164144165144166144167144168144169144170144171144172144173144174144175144176144177144178144179144180144181144182144183144184144185144186144187144188144189144190144191144192144193144194144195144196144197144198144199144200144201144202144203144204144205144206144207144208144209144210144211144212144213144214144215144216144217144218144219144220144221144222144223144224144225144226144227144228144229144230144231144232144233144234144235144236144237144238144239144240144241144242144243144244144245144246144247144248144249144250144251144252144253144254144255144256144257144258144259144260144261144262144263144264144265144266144267144268144269144270144271144272144273144274144275144276144277144278144279144280144281144282144283144284144285144286144287144288144289144290144291144292144293144294144295144296144297144298144299144300144301144302144303144304144305144306144307144308144309144310144311144312144313144314144315144316144317144318144319144320144321144322144323144324144325144326144327144328144329144330144331144332144333144334144335144336144337144338144339144340144341144342144343144344144345144346144347144348144349144350144351144352144353144354144355144356144357144358144359144360144361144362144363144364144365144366144367144368144369144370144371144372144373144374144375144376144377144378144379144380144381144382144383144384144385144386144387144388144389144390144391144392144393144394144395144396144397144398144399144400144401144402144403144404144405144406144407144408144409144410144411144412144413144414144415144416144417144418144419144420144421144422144423144424144425144426144427144428144429144430144431144432144433144434144435144436144437144438144439144440144441144442144443144444144445144446144447144448144449144450144451144452144453144454144455144456144457144458144459144460144461144462144463144464144465144466144467144468144469144470144471144472144473144474144475144476144477144478144479144480144481144482144483144484144485144486144487144488144489144490144491144492144493144494144495144496144497144498144499144500144501144502144503144504144505144506144507144508144509144510144511144512144513144514144515144516144517144518144519144520144521144522144523144524144525144526144527144528144529144530144531144532144533144534144535144536144537144538144539144540144541144542144543144544144545144546144547144548144549144550144551144552144553144554144555144556144557144558144559144560144561144562144563144564144565144566144567144568144569144570144571144572144573144574144575144576144577144578144579144580144581144582144583144584144585144586144587144588144589144590144591144592144593144594144595144596144597144598144599144600144601144602144603144604144605144606144607144608144609144610144611144612144613144614144615144616144617144618144619144620144621144622144623144624144625144626144627144628144629144630144631144632144633144634144635144636144637144638144639144640144641144642144643144644144645144646144647144648144649144650144651144652144653144654144655144656144657144658144659144660144661144662144663144664144665144666144667144668144669144670144671144672144673144674144675144676144677144678144679144680144681144682144683144684144685144686144687144688144689144690144691144692144693144694144695144696144697144698144699144700144701144702144703144704144705144706144707144708144709144710144711144712144713144714144715144716144717144718144719144720144721144722144723144724144725144726144727144728144729144730144731144732144733144734144735144736144737144738144739144740144741144742144743144744144745144746144747144748144749144750144751144752144753144754144755144756144757144758144759144760144761144762144763144764144765144766144767144768144769144770144771144772144773144774144775144776144777144778144779144780144781144782144783144784144785144786144787144788144789144790144791144792144793144794144795144796144797144798144799144800144801144802144803144804144805144806144807144808144809144810144811144812144813144814144815144816144817144818144819144820144821144822144823144824144825144826144827144828144829144830144831144832144833144834144835144836144837144838144839144840144841144842144843144844144845144846144847144848144849144850144851144852144853144854144855144856144857144858144859144860144861144862144863144864144865144866144867144868144869144870144871144872144873144874144875144876144877144878144879144880144881144882144883144884144885144886144887144888144889144890144891144892144893144894144895144896144897144898144899144900144901144902144903144904144905144906144907144908144909144910144911144912144913144914144915144916144917144918144919144920144921144922144923144924144925144926144927144928144929144930144931144932144933144934144935144936144937144938144939144940144941144942144943144944144945144946144947144948144949144950144951144952144953144954144955144956144957144958144959144960144961144962144963144964144965144966144967144968144969144970144971144972144973144974144975144976144977144978144979144980144981144982144983144984144985144986144987144988144989144990144991144992144993144994144995144996144997144998144999145000145001145002145003145004145005145006145007145008145009145010145011145012145013145014145015145016145017145018145019145020145021145022145023145024145025145026145027145028145029145030145031145032145033145034145035145036145037145038145039145040145041145042145043145044145045145046145047145048145049145050145051145052145053145054145055145056145057145058145059145060145061145062145063145064145065145066145067145068145069145070145071145072145073145074145075145076145077145078145079145080145081145082145083145084145085145086145087145088145089145090145091145092145093145094145095145096145097145098145099145100145101145102145103145104145105145106145107145108145109145110145111145112145113145114145115145116145117145118145119145120145121145122145123145124145125145126145127145128145129145130145131145132145133145134145135145136145137145138145139145140145141145142145143145144145145145146145147145148145149145150145151145152145153145154145155145156145157145158145159145160145161145162145163145164145165145166145167145168145169145170145171145172145173145174145175145176145177145178145179145180145181145182145183145184145185145186145187145188145189145190145191145192145193145194145195145196145197145198145199145200145201145202145203145204145205145206145207145208145209145210145211145212145213145214145215145216145217145218145219145220145221145222145223145224145225145226145227145228145229145230145231145232145233145234145235145236145237145238145239145240145241145242145243145244145245145246145247145248145249145250145251145252145253145254145255145256145257145258145259145260145261145262145263145264145265145266145267145268145269145270145271145272145273145274145275145276145277145278145279145280145281145282145283145284145285145286145287145288145289145290145291145292145293145294145295145296145297145298145299145300145301145302145303145304145305145306145307145308145309145310145311145312145313145314145315145316145317145318145319145320145321145322145323145324145325145326145327145328145329145330145331145332145333145334145335145336145337145338145339145340145341145342145343145344145345145346145347145348145349145350145351145352145353145354145355145356145357145358145359145360145361145362145363145364145365145366145367145368145369145370145371145372145373145374145375145376145377145378145379145380145381145382145383145384145385145386145387145388145389145390145391145392145393145394145395145396145397145398145399145400145401145402145403145404145405145406145407145408145409145410145411145412145413145414145415145416145417145418145419145420145421145422145423145424145425145426145427145428145429145430145431145432145433145434145435145436145437145438145439145440145441145442145443145444145445145446145447145448145449145450145451145452145453145454145455145456145457145458145459145460145461145462145463145464145465145466145467145468145469145470145471145472145473145474145475145476145477145478145479145480145481145482145483145484145485145486145487145488145489145490145491145492145493145494145495145496145497145498145499145500145501145502145503145504145505145506145507145508145509145510145511145512145513145514145515145516145517145518145519145520145521145522145523145524145525145526145527145528145529145530145531145532145533145534145535145536145537145538145539145540145541145542145543145544145545145546145547145548145549145550145551145552145553145554145555145556145557145558145559145560145561145562145563145564145565145566145567145568145569145570145571145572145573145574145575145576145577145578145579145580145581145582145583145584145585145586145587145588145589145590145591145592145593145594145595145596145597145598145599145600145601145602145603145604145605145606145607145608145609145610145611145612145613145614145615145616145617145618145619145620145621145622145623145624145625145626145627145628145629145630145631145632145633145634145635145636145637145638145639145640145641145642145643145644145645145646145647145648145649145650145651145652145653145654145655145656145657145658145659145660145661145662145663145664145665145666145667145668145669145670145671145672145673145674145675145676145677145678145679145680145681145682145683145684145685145686145687145688145689145690145691145692145693145694145695145696145697145698145699145700145701145702145703145704145705145706145707145708145709145710145711145712145713145714145715145716145717145718145719145720145721145722145723145724145725145726145727145728145729145730145731145732145733145734145735145736145737145738145739145740145741145742145743145744145745145746145747145748145749145750145751145752145753145754145755145756145757145758145759145760145761145762145763145764145765145766145767145768145769145770145771145772145773145774145775145776145777145778145779145780145781145782145783145784145785145786145787145788145789145790145791145792145793145794145795145796145797145798145799145800145801145802145803145804145805145806145807145808145809145810145811145812145813145814145815145816145817145818145819145820145821145822145823145824145825145826145827145828145829145830145831145832145833145834145835145836145837145838145839145840145841145842145843145844145845145846145847145848145849145850145851145852145853145854145855145856145857145858145859145860145861145862145863145864145865145866145867145868145869145870145871145872145873145874145875145876145877145878145879145880145881145882145883145884145885145886145887145888145889145890145891145892145893145894145895145896145897145898145899145900145901145902145903145904145905145906145907145908145909145910145911145912145913145914145915145916145917145918145919145920145921145922145923145924145925145926145927145928145929145930145931145932145933145934145935145936145937145938145939145940145941145942145943145944145945145946145947145948145949145950145951145952145953145954145955145956145957145958145959145960145961145962145963145964145965145966145967145968145969145970145971145972145973145974145975145976145977145978145979145980145981145982145983145984145985145986145987145988145989145990145991145992145993145994145995145996145997145998145999146000146001146002146003146004146005146006146007146008146009146010146011146012146013146014146015146016146017146018146019146020146021146022146023146024146025146026146027146028146029146030146031146032146033146034146035146036146037146038146039146040146041146042146043146044146045146046146047146048146049146050146051146052146053146054146055146056146057146058146059146060146061146062146063146064146065146066146067146068146069146070146071146072146073146074146075146076146077146078146079146080146081146082146083146084146085146086146087146088146089146090146091146092146093146094146095146096146097146098146099146100146101146102146103146104146105146106146107146108146109146110146111146112146113146114146115146116146117146118146119146120146121146122146123146124146125146126146127146128146129146130146131146132146133146134146135146136146137146138146139146140146141146142146143146144146145146146146147146148146149146150146151146152146153146154146155146156146157146158146159146160146161146162146163146164146165146166146167146168146169146170146171146172146173146174146175146176146177146178146179146180146181146182146183146184146185146186146187146188146189146190146191146192146193146194146195146196146197146198146199146200146201146202146203146204146205146206146207146208146209146210146211146212146213146214146215146216146217146218146219146220146221146222146223146224146225146226146227146228146229146230146231146232146233146234146235146236146237146238146239146240146241146242146243146244146245146246146247146248146249146250146251146252146253146254146255146256146257146258146259146260146261146262146263146264146265146266146267146268146269146270146271146272146273146274146275146276146277146278146279146280146281146282146283146284146285146286146287146288146289146290146291146292146293146294146295146296146297146298146299146300146301146302146303146304146305146306146307146308146309146310146311146312146313146314146315146316146317146318146319146320146321146322146323146324146325146326146327146328146329146330146331146332146333146334146335146336146337146338146339146340146341146342146343146344146345146346146347146348146349146350146351146352146353146354146355146356146357146358146359146360146361146362146363146364146365146366146367146368146369146370146371146372146373146374146375146376146377146378146379146380146381146382146383146384146385146386146387146388146389146390146391146392146393146394146395146396146397146398146399146400146401146402146403146404146405146406146407146408146409146410146411146412146413146414146415146416146417146418146419146420146421146422146423146424146425146426146427146428146429146430146431146432146433146434146435146436146437146438146439146440146441146442146443146444146445146446146447146448146449146450146451146452146453146454146455146456146457146458146459146460146461146462146463146464146465146466146467146468146469146470146471146472146473146474146475146476146477146478146479146480146481146482146483146484146485146486146487146488146489146490146491146492146493146494146495146496146497146498146499146500146501146502146503146504146505146506146507146508146509146510146511146512146513146514146515146516146517146518146519146520146521146522146523146524146525146526146527146528146529146530146531146532146533146534146535146536146537146538146539146540146541146542146543146544146545146546146547146548146549146550146551146552146553146554146555146556146557146558146559146560146561146562146563146564146565146566146567146568146569146570146571146572146573146574146575146576146577146578146579146580146581146582146583146584146585146586146587146588146589146590146591146592146593146594146595146596146597146598146599146600146601146602146603146604146605146606146607146608146609146610146611146612146613146614146615146616146617146618146619146620146621146622146623146624146625146626146627146628146629146630146631146632146633146634146635146636146637146638146639146640146641146642146643146644146645146646146647146648146649146650146651146652146653146654146655146656146657146658146659146660146661146662146663146664146665146666146667146668146669146670146671146672146673146674146675146676146677146678146679146680146681146682146683146684146685146686146687146688146689146690146691146692146693146694146695146696146697146698146699146700146701146702146703146704146705146706146707146708146709146710146711146712146713146714146715146716146717146718146719146720146721146722146723146724146725146726146727146728146729146730146731146732146733146734146735146736146737146738146739146740146741146742146743146744146745146746146747146748146749146750146751146752146753146754146755146756146757146758146759146760146761146762146763146764146765146766146767146768146769146770146771146772146773146774146775146776146777146778146779146780146781146782146783146784146785146786146787146788146789146790146791146792146793146794146795146796146797146798146799146800146801146802146803146804146805146806146807146808146809146810146811146812146813146814146815146816146817146818146819146820146821146822146823146824146825146826146827146828146829146830146831146832146833146834146835146836146837146838146839146840146841146842146843146844146845146846146847146848146849146850146851146852146853146854146855146856146857146858146859146860146861146862146863146864146865146866146867146868146869146870146871146872146873146874146875146876146877146878146879146880146881146882146883146884146885146886146887146888146889146890146891146892146893146894146895146896146897146898146899146900146901146902146903146904146905146906146907146908146909146910146911146912146913146914146915146916146917146918146919146920146921146922146923146924146925146926146927146928146929146930146931146932146933146934146935146936146937146938146939146940146941146942146943146944146945146946146947146948146949146950146951146952146953146954146955146956146957146958146959146960146961146962146963146964146965146966146967146968146969146970146971146972146973146974146975146976146977146978146979146980146981146982146983146984146985146986146987146988146989146990146991146992146993146994146995146996146997146998146999147000147001147002147003147004147005147006147007147008147009147010147011147012147013147014147015147016147017147018147019147020147021147022147023147024147025147026147027147028147029147030147031147032147033147034147035147036147037147038147039147040147041147042147043147044147045147046147047147048147049147050147051147052147053147054147055147056147057147058147059147060147061147062147063147064147065147066147067147068147069147070147071147072147073147074147075147076147077147078147079147080147081147082147083147084147085147086147087147088147089147090147091147092147093147094147095147096147097147098147099147100147101147102147103147104147105147106147107147108147109147110147111147112147113147114147115147116147117147118147119147120147121147122147123147124147125147126147127147128147129147130147131147132147133147134147135147136147137147138147139147140147141147142147143147144147145147146147147147148147149147150147151147152147153147154147155147156147157147158147159147160147161147162147163147164147165147166147167147168147169147170147171147172147173147174147175147176147177147178147179147180147181147182147183147184147185147186147187147188147189147190147191147192147193147194147195147196147197147198147199147200147201147202147203147204147205147206147207147208147209147210147211147212147213147214147215147216147217147218147219147220147221147222147223147224147225147226147227147228147229147230147231147232147233147234147235147236147237147238147239147240147241147242147243147244147245147246147247147248147249147250147251147252147253147254147255147256147257147258147259147260147261147262147263147264147265147266147267147268147269147270147271147272147273147274147275147276147277147278147279147280147281147282147283147284147285147286147287147288147289147290147291147292147293147294147295147296147297147298147299147300147301147302147303147304147305147306147307147308147309147310147311147312147313147314147315147316147317147318147319147320147321147322147323147324147325147326147327147328147329147330147331147332147333147334147335147336147337147338147339147340147341147342147343147344147345147346147347147348147349147350147351147352147353147354147355147356147357147358147359147360147361147362147363147364147365147366147367147368147369147370147371147372147373147374147375147376147377147378147379147380147381147382147383147384147385147386147387147388147389147390147391147392147393147394147395147396147397147398147399147400147401147402147403147404147405147406147407147408147409147410147411147412147413147414147415147416147417147418147419147420147421147422147423147424147425147426147427147428147429147430147431147432147433147434147435147436147437147438147439147440147441147442147443147444147445147446147447147448147449147450147451147452147453147454147455147456147457147458147459147460147461147462147463147464147465147466147467147468147469147470147471147472147473147474147475147476147477147478147479147480147481147482147483147484147485147486147487147488147489147490147491147492147493147494147495147496147497147498147499147500147501147502147503147504147505147506147507147508147509147510147511147512147513147514147515147516147517147518147519147520147521147522147523147524147525147526147527147528147529147530147531147532147533147534147535147536147537147538147539147540147541147542147543147544147545147546147547147548147549147550147551147552147553147554147555147556147557147558147559147560147561147562147563147564147565147566147567147568147569147570147571147572147573147574147575147576147577147578147579147580147581147582147583147584147585147586147587147588147589147590147591147592147593147594147595147596147597147598147599147600147601147602147603147604147605147606147607147608147609147610147611147612147613147614147615147616147617147618147619147620147621147622147623147624147625147626147627147628147629147630147631147632147633147634147635147636147637147638147639147640147641147642147643147644147645147646147647147648147649147650147651147652147653147654147655147656147657147658147659147660147661147662147663147664147665147666147667147668147669147670147671147672147673147674147675147676147677147678147679147680147681147682147683147684147685147686147687147688147689147690147691147692147693147694147695147696147697147698147699147700147701147702147703147704147705147706147707147708147709147710147711147712147713147714147715147716147717147718147719147720147721147722147723147724147725147726147727147728147729147730147731147732147733147734147735147736147737147738147739147740147741147742147743147744147745147746147747147748147749147750147751147752147753147754147755147756147757147758147759147760147761147762147763147764147765147766147767147768147769147770147771147772147773147774147775147776147777147778147779147780147781147782147783147784147785147786147787147788147789147790147791147792147793147794147795147796147797147798147799147800147801147802147803147804147805147806147807147808147809147810147811147812147813147814147815147816147817147818147819147820147821147822147823147824147825147826147827147828147829147830147831147832147833147834147835147836147837147838147839147840147841147842147843147844147845147846147847147848147849147850147851147852147853147854147855147856147857147858147859147860147861147862147863147864147865147866147867147868147869147870147871147872147873147874147875147876147877147878147879147880147881147882147883147884147885147886147887147888147889147890147891147892147893147894147895147896147897147898147899147900147901147902147903147904147905147906147907147908147909147910147911147912147913147914147915147916147917147918147919147920147921147922147923147924147925147926147927147928147929147930147931147932147933147934147935147936147937147938147939147940147941147942147943147944147945147946147947147948147949147950147951147952147953147954147955147956147957147958147959147960147961147962147963147964147965147966147967147968147969147970147971147972147973147974147975147976147977147978147979147980147981147982147983147984147985147986147987147988147989147990147991147992147993147994147995147996147997147998147999148000148001148002148003148004148005148006148007148008148009148010148011148012148013148014148015148016148017148018148019148020148021148022148023148024148025148026148027148028148029148030148031148032148033148034148035148036148037148038148039148040148041148042148043148044148045148046148047148048148049148050148051148052148053148054148055148056148057148058148059148060148061148062148063148064148065148066148067148068148069148070148071148072148073148074148075148076148077148078148079148080148081148082148083148084148085148086148087148088148089148090148091148092148093148094148095148096148097148098148099148100148101148102148103148104148105148106148107148108148109148110148111148112148113148114148115148116148117148118148119148120148121148122148123148124148125148126148127148128148129148130148131148132148133148134148135148136148137148138148139148140148141148142148143148144148145148146148147148148148149148150148151148152148153148154148155148156148157148158148159148160148161148162148163148164148165148166148167148168148169148170148171148172148173148174148175148176148177148178148179148180148181148182148183148184148185148186148187148188148189148190148191148192148193148194148195148196148197148198148199148200148201148202148203148204148205148206148207148208148209148210148211148212148213148214148215148216148217148218148219148220148221148222148223148224148225148226148227148228148229148230148231148232148233148234148235148236148237148238148239148240148241148242148243148244148245148246148247148248148249148250148251148252148253148254148255148256148257148258148259148260148261148262148263148264148265148266148267148268148269148270148271148272148273148274148275148276148277148278148279148280148281148282148283148284148285148286148287148288148289148290148291148292148293148294148295148296148297148298148299148300148301148302148303148304148305148306148307148308148309148310148311148312148313148314148315148316148317148318148319148320148321148322148323148324148325148326148327148328148329148330148331148332148333148334148335148336148337148338148339148340148341148342148343148344148345148346148347148348148349148350148351148352148353148354148355148356148357148358148359148360148361148362148363148364148365148366148367148368148369148370148371148372148373148374148375148376148377148378148379148380148381148382148383148384148385148386148387148388148389148390148391148392148393148394148395148396148397148398148399148400148401148402148403148404148405148406148407148408148409148410148411148412148413148414148415148416148417148418148419148420148421148422148423148424148425148426148427148428148429148430148431148432148433148434148435148436148437148438148439148440148441148442148443148444148445148446148447148448148449148450148451148452148453148454148455148456148457148458148459148460148461148462148463148464148465148466148467148468148469148470148471148472148473148474148475148476148477148478148479148480148481148482148483148484148485148486148487148488148489148490148491148492148493148494148495148496148497148498148499148500148501148502148503148504148505148506148507148508148509148510148511148512148513148514148515148516148517148518148519148520148521148522148523148524148525148526148527148528148529148530148531148532148533148534148535148536148537148538148539148540148541148542148543148544148545148546148547148548148549148550148551148552148553148554148555148556148557148558148559148560148561148562148563148564148565148566148567148568148569148570148571148572148573148574148575148576148577148578148579148580148581148582148583148584148585148586148587148588148589148590148591148592148593148594148595148596148597148598148599148600148601148602148603148604148605148606148607148608148609148610148611148612148613148614148615148616148617148618148619148620148621148622148623148624148625148626148627148628148629148630148631148632148633148634148635148636148637148638148639148640148641148642148643148644148645148646148647148648148649148650148651148652148653148654148655148656148657148658148659148660148661148662148663148664148665148666148667148668148669148670148671148672148673148674148675148676148677148678148679148680148681148682148683148684148685148686148687148688148689148690148691148692148693148694148695148696148697148698148699148700148701148702148703148704148705148706148707148708148709148710148711148712148713148714148715148716148717148718148719148720148721148722148723148724148725148726148727148728148729148730148731148732148733148734148735148736148737148738148739148740148741148742148743148744148745148746148747148748148749148750148751148752148753148754148755148756148757148758148759148760148761148762148763148764148765148766148767148768148769148770148771148772148773148774148775148776148777148778148779148780148781148782148783148784148785148786148787148788148789148790148791148792148793148794148795148796148797148798148799148800148801148802148803148804148805148806148807148808148809148810148811148812148813148814148815148816148817148818148819148820148821148822148823148824148825148826148827148828148829148830148831148832148833148834148835148836148837148838148839148840148841148842148843148844148845148846148847148848148849148850148851148852148853148854148855148856148857148858148859148860148861148862148863148864148865148866148867148868148869148870148871148872148873148874148875148876148877148878148879148880148881148882148883148884148885148886148887148888148889148890148891148892148893148894148895148896148897148898148899148900148901148902148903148904148905148906148907148908148909148910148911148912148913148914148915148916148917148918148919148920148921148922148923148924148925148926148927148928148929148930148931148932148933148934148935148936148937148938148939148940148941148942148943148944148945148946148947148948148949148950148951148952148953148954148955148956148957148958148959148960148961148962148963148964148965148966148967148968148969148970148971148972148973148974148975148976148977148978148979148980148981148982148983148984148985148986148987148988148989148990148991148992148993148994148995148996148997148998148999149000149001149002149003149004149005149006149007149008149009149010149011149012149013149014149015149016149017149018149019149020149021149022149023149024149025149026149027149028149029149030149031149032149033149034149035149036149037149038149039149040149041149042149043149044149045149046149047149048149049149050149051149052149053149054149055149056149057149058149059149060149061149062149063149064149065149066149067149068149069149070149071149072149073149074149075149076149077149078149079149080149081149082149083149084149085149086149087149088149089149090149091149092149093149094149095149096149097149098149099149100149101149102149103149104149105149106149107149108149109149110149111149112149113149114149115149116149117149118149119149120149121149122149123149124149125149126149127149128149129149130149131149132149133149134149135149136149137149138149139149140149141149142149143149144149145149146149147149148149149149150149151149152149153149154149155149156149157149158149159149160149161149162149163149164149165149166149167149168149169149170149171149172149173149174149175149176149177149178149179149180149181149182149183149184149185149186149187149188149189149190149191149192149193149194149195149196149197149198149199149200149201149202149203149204149205149206149207149208149209149210149211149212149213149214149215149216149217149218149219149220149221149222149223149224149225149226149227149228149229149230149231149232149233149234149235149236149237149238149239149240149241149242149243149244149245149246149247149248149249149250149251149252149253149254149255149256149257149258149259149260149261149262149263149264149265149266149267149268149269149270149271149272149273149274149275149276149277149278149279149280149281149282149283149284149285149286149287149288149289149290149291149292149293149294149295149296149297149298149299149300149301149302149303149304149305149306149307149308149309149310149311149312149313149314149315149316149317149318149319149320149321149322149323149324149325149326149327149328149329149330149331149332149333149334149335149336149337149338149339149340149341149342149343149344149345149346149347149348149349149350149351149352149353149354149355149356149357149358149359149360149361149362149363149364149365149366149367149368149369149370149371149372149373149374149375149376149377149378149379149380149381149382149383149384149385149386149387149388149389149390149391149392149393149394149395149396149397149398149399149400149401149402149403149404149405149406149407149408149409149410149411149412149413149414149415149416149417149418149419149420149421149422149423149424149425149426149427149428149429149430149431149432149433149434149435149436149437149438149439149440149441149442149443149444149445149446149447149448149449149450149451149452149453149454149455149456149457149458149459149460149461149462149463149464149465149466149467149468149469149470149471149472149473149474149475149476149477149478149479149480149481149482149483149484149485149486149487149488149489149490149491149492149493149494149495149496149497149498149499149500149501149502149503149504149505149506149507149508149509149510149511149512149513149514149515149516149517149518149519149520149521149522149523149524149525149526149527149528149529149530149531149532149533149534149535149536149537149538149539149540149541149542149543149544149545149546149547149548149549149550149551149552149553149554149555149556149557149558149559149560149561149562149563149564149565149566149567149568149569149570149571149572149573149574149575149576149577149578149579149580149581149582149583149584149585149586149587149588149589149590149591149592149593149594149595149596149597149598149599149600149601149602149603149604149605149606149607149608149609149610149611149612149613149614149615149616149617149618149619149620149621149622149623149624149625149626149627149628149629149630149631149632149633149634149635149636149637149638149639149640149641149642149643149644149645149646149647149648149649149650149651149652149653149654149655149656149657149658149659149660149661149662149663149664149665149666149667149668149669149670149671149672149673149674149675149676149677149678149679149680149681149682149683149684149685149686149687149688149689149690149691149692149693149694149695149696149697149698149699149700149701149702149703149704149705149706149707149708149709149710149711149712149713149714149715149716149717149718149719149720149721149722149723149724149725149726149727149728149729149730149731149732149733149734149735149736149737149738149739149740149741149742149743149744149745149746149747149748149749149750149751149752149753149754149755149756149757149758149759149760149761149762149763149764149765149766149767149768149769149770149771149772149773149774149775149776149777149778149779149780149781149782149783149784149785149786149787149788149789149790149791149792149793149794149795149796149797149798149799149800149801149802149803149804149805149806149807149808149809149810149811149812149813149814149815149816149817149818149819149820149821149822149823149824149825149826149827149828149829149830149831149832149833149834149835149836149837149838149839149840149841149842149843149844149845149846149847149848149849149850149851149852149853149854149855149856149857149858149859149860149861149862149863149864149865149866149867149868149869149870149871149872149873149874149875149876149877149878149879149880149881149882149883149884149885149886149887149888149889149890149891149892149893149894149895149896149897149898149899149900149901149902149903149904149905149906149907149908149909149910149911149912149913149914149915149916149917149918149919149920149921149922149923149924149925149926149927149928149929149930149931149932149933149934149935149936149937149938149939149940149941149942149943149944149945149946149947149948149949149950149951149952149953149954149955149956149957149958149959149960149961149962149963149964149965149966149967149968149969149970149971149972149973149974149975149976149977149978149979149980149981149982149983149984149985149986149987149988149989149990149991149992149993149994149995149996149997149998149999150000150001150002150003150004150005150006150007150008150009150010150011150012150013150014150015150016150017150018150019150020150021150022150023150024150025150026150027150028150029150030150031150032150033150034150035150036150037150038150039150040150041150042150043150044150045150046150047150048150049150050150051150052150053150054150055150056150057150058150059150060150061150062150063150064150065150066150067150068150069150070150071150072150073150074150075150076150077150078150079150080150081150082150083150084150085150086150087150088150089150090150091150092150093150094150095150096150097150098150099150100150101150102150103150104150105150106150107150108150109150110150111150112150113150114150115150116150117150118150119150120150121150122150123150124150125150126150127150128150129150130150131150132150133150134150135150136150137150138150139150140150141150142150143150144150145150146150147150148150149150150150151150152150153150154150155150156150157150158150159150160150161150162150163150164150165150166150167150168150169150170150171150172150173150174150175150176150177150178150179150180150181150182150183150184150185150186150187150188150189150190150191150192150193150194150195150196150197150198150199150200150201150202150203150204150205150206150207150208150209150210150211150212150213150214150215150216150217150218150219150220150221150222150223150224150225150226150227150228150229150230150231150232150233150234150235150236150237150238150239150240150241150242150243150244150245150246150247150248150249150250150251150252150253150254150255150256150257150258150259150260150261150262150263150264150265150266150267150268150269150270150271150272150273150274150275150276150277150278150279150280150281150282150283150284150285150286150287150288150289150290150291150292150293150294150295150296150297150298150299150300150301150302150303150304150305150306150307150308150309150310150311150312150313150314150315150316150317150318150319150320150321150322150323150324150325150326150327150328150329150330150331150332150333150334150335150336150337150338150339150340150341150342150343150344150345150346150347150348150349150350150351150352150353150354150355150356150357150358150359150360150361150362150363150364150365150366150367150368150369150370150371150372150373150374150375150376150377150378150379150380150381150382150383150384150385150386150387150388150389150390150391150392150393150394150395150396150397150398150399150400150401150402150403150404150405150406150407150408150409150410150411150412150413150414150415150416150417150418150419150420150421150422150423150424150425150426150427150428150429150430150431150432150433150434150435150436150437150438150439150440150441150442150443150444150445150446150447150448150449150450150451150452150453150454150455150456150457150458150459150460150461150462150463150464150465150466150467150468150469150470150471150472150473150474150475150476150477150478150479150480150481150482150483150484150485150486150487150488150489150490150491150492150493150494150495150496150497150498150499150500150501150502150503150504150505150506150507150508150509150510150511150512150513150514150515150516150517150518150519150520150521150522150523150524150525150526150527150528150529150530150531150532150533150534150535150536150537150538150539150540150541150542150543150544150545150546150547150548150549150550150551150552150553150554150555150556150557150558150559150560150561150562150563150564150565150566150567150568150569150570150571150572150573150574150575150576150577150578150579150580150581150582150583150584150585150586150587150588150589150590150591150592150593150594150595150596150597150598150599150600150601150602150603150604150605150606150607150608150609150610150611150612150613150614150615150616150617150618150619150620150621150622150623150624150625150626150627150628150629150630150631150632150633150634150635150636150637150638150639150640150641150642150643150644150645150646150647150648150649150650150651150652150653150654150655150656150657150658150659150660150661150662150663150664150665150666150667150668150669150670150671150672150673150674150675150676150677150678150679150680150681150682150683150684150685150686150687150688150689150690150691150692150693150694150695150696150697150698150699150700150701150702150703150704150705150706150707150708150709150710150711150712150713150714150715150716150717150718150719150720150721150722150723150724150725150726150727150728150729150730150731150732150733150734150735150736150737150738150739150740150741150742150743150744150745150746150747150748150749150750150751150752150753150754150755150756150757150758150759150760150761150762150763150764150765150766150767150768150769150770150771150772150773150774150775150776150777150778150779150780150781150782150783150784150785150786150787150788150789150790150791150792150793150794150795150796150797150798150799150800150801150802150803150804150805150806150807150808150809150810150811150812150813150814150815150816150817150818150819150820150821150822150823150824150825150826150827150828150829150830150831150832150833150834150835150836150837150838150839150840150841150842150843150844150845150846150847150848150849150850150851150852150853150854150855150856150857150858150859150860150861150862150863150864150865150866150867150868150869150870150871150872150873150874150875150876150877150878150879150880150881150882150883150884150885150886150887150888150889150890150891150892150893150894150895150896150897150898150899150900150901150902150903150904150905150906150907150908150909150910150911150912150913150914150915150916150917150918150919150920150921150922150923150924150925150926150927150928150929150930150931150932150933150934150935150936150937150938150939150940150941150942150943150944150945150946150947150948150949150950150951150952150953150954150955150956150957150958150959150960150961150962150963150964150965150966150967150968150969150970150971150972150973150974150975150976150977150978150979150980150981150982150983150984150985150986150987150988150989150990150991150992150993150994150995150996150997150998150999151000151001151002151003151004151005151006151007151008151009151010151011151012151013151014151015151016151017151018151019151020151021151022151023151024151025151026151027151028151029151030151031151032151033151034151035151036151037151038151039151040151041151042151043151044151045151046151047151048151049151050151051151052151053151054151055151056151057151058151059151060151061151062151063151064151065151066151067151068151069151070151071151072151073151074151075151076151077151078151079151080151081151082151083151084151085151086151087151088151089151090151091151092151093151094151095151096151097151098151099151100151101151102151103151104151105151106151107151108151109151110151111151112151113151114151115151116151117151118151119151120151121151122151123151124151125151126151127151128151129151130151131151132151133151134151135151136151137151138151139151140151141151142151143151144151145151146151147151148151149151150151151151152151153151154151155151156151157151158151159151160151161151162151163151164151165151166151167151168151169151170151171151172151173151174151175151176151177151178151179151180151181151182151183151184151185151186151187151188151189151190151191151192151193151194151195151196151197151198151199151200151201151202151203151204151205151206151207151208151209151210151211151212151213151214151215151216151217151218151219151220151221151222151223151224151225151226151227151228151229151230151231151232151233151234151235151236151237151238151239151240151241151242151243151244151245151246151247151248151249151250151251151252151253151254151255151256151257151258151259151260151261151262151263151264151265151266151267151268151269151270151271151272151273151274151275151276151277151278151279151280151281151282151283151284151285151286151287151288151289151290151291151292151293151294151295151296151297151298151299151300151301151302151303151304151305151306151307151308151309151310151311151312151313151314151315151316151317151318151319151320151321151322151323151324151325151326151327151328151329151330151331151332151333151334151335151336151337151338151339151340151341151342151343151344151345151346151347151348151349151350151351151352151353151354151355151356151357151358151359151360151361151362151363151364151365151366151367151368151369151370151371151372151373151374151375151376151377151378151379151380151381151382151383151384151385151386151387151388151389151390151391151392151393151394151395151396151397151398151399151400151401151402151403151404151405151406151407151408151409151410151411151412151413151414151415151416151417151418151419151420151421151422151423151424151425151426151427151428151429151430151431151432151433151434151435151436151437151438151439151440151441151442151443151444151445151446151447151448151449151450151451151452151453151454151455151456151457151458151459151460151461151462151463151464151465151466151467151468151469151470151471151472151473151474151475151476151477151478151479151480151481151482151483151484151485151486151487151488151489151490151491151492151493151494151495151496151497151498151499151500151501151502151503151504151505151506151507151508151509151510151511151512151513151514151515151516151517151518151519151520151521151522151523151524151525151526151527151528151529151530151531151532151533151534151535151536151537151538151539151540151541151542151543151544151545151546151547151548151549151550151551151552151553151554151555151556151557151558151559151560151561151562151563151564151565151566151567151568151569151570151571151572151573151574151575151576151577151578151579151580151581151582151583151584151585151586151587151588151589151590151591151592151593151594151595151596151597151598151599151600151601151602151603151604151605151606151607151608151609151610151611151612151613151614151615151616151617151618151619151620151621151622151623151624151625151626151627151628151629151630151631151632151633151634151635151636151637151638151639151640151641151642151643151644151645151646151647151648151649151650151651151652151653151654151655151656151657151658151659151660151661151662151663151664151665151666151667151668151669151670151671151672151673151674151675151676151677151678151679151680151681151682151683151684151685151686151687151688151689151690151691151692151693151694151695151696151697151698151699151700151701151702151703151704151705151706151707151708151709151710151711151712151713151714151715151716151717151718151719151720151721151722151723151724151725151726151727151728151729151730151731151732151733151734151735151736151737151738151739151740151741151742151743151744151745151746151747151748151749151750151751151752151753151754151755151756151757151758151759151760151761151762151763151764151765151766151767151768151769151770151771151772151773151774151775151776151777151778151779151780151781151782151783151784151785151786151787151788151789151790151791151792151793151794151795151796151797151798151799151800151801151802151803151804151805151806151807151808151809151810151811151812151813151814151815151816151817151818151819151820151821151822151823151824151825151826151827151828151829151830151831151832151833151834151835151836151837151838151839151840151841151842151843151844151845151846151847151848151849151850151851151852151853151854151855151856151857151858151859151860151861151862151863151864151865151866151867151868151869151870151871151872151873151874151875151876151877151878151879151880151881151882151883151884151885151886151887151888151889151890151891151892151893151894151895151896151897151898151899151900151901151902151903151904151905151906151907151908151909151910151911151912151913151914151915151916151917151918151919151920151921151922151923151924151925151926151927151928151929151930151931151932151933151934151935151936151937151938151939151940151941151942151943151944151945151946151947151948151949151950151951151952151953151954151955151956151957151958151959151960151961151962151963151964151965151966151967151968151969151970151971151972151973151974151975151976151977151978151979151980151981151982151983151984151985151986151987151988151989151990151991151992151993151994151995151996151997151998151999152000152001152002152003152004152005152006152007152008152009152010152011152012152013152014152015152016152017152018152019152020152021152022152023152024152025152026152027152028152029152030152031152032152033152034152035152036152037152038152039152040152041152042152043152044152045152046152047152048152049152050152051152052152053152054152055152056152057152058152059152060152061152062152063152064152065152066152067152068152069152070152071152072152073152074152075152076152077152078152079152080152081152082152083152084152085152086152087152088152089152090152091152092152093152094152095152096152097152098152099152100152101152102152103152104152105152106152107152108152109152110152111152112152113152114152115152116152117152118152119152120152121152122152123152124152125152126152127152128152129152130152131152132152133152134152135152136152137152138152139152140152141152142152143152144152145152146152147152148152149152150152151152152152153152154152155152156152157152158152159152160152161152162152163152164152165152166152167152168152169152170152171152172152173152174152175152176152177152178152179152180152181152182152183152184152185152186152187152188152189152190152191152192152193152194152195152196152197152198152199152200152201152202152203152204152205152206152207152208152209152210152211152212152213152214152215152216152217152218152219152220152221152222152223152224152225152226152227152228152229152230152231152232152233152234152235152236152237152238152239152240152241152242152243152244152245152246152247152248152249152250152251152252152253152254152255152256152257152258152259152260152261152262152263152264152265152266152267152268152269152270152271152272152273152274152275152276152277152278152279152280152281152282152283152284152285152286152287152288152289152290152291152292152293152294152295152296152297152298152299152300152301152302152303152304152305152306152307152308152309152310152311152312152313152314152315152316152317152318152319152320152321152322152323152324152325152326152327152328152329152330152331152332152333152334152335152336152337152338152339152340152341152342152343152344152345152346152347152348152349152350152351152352152353152354152355152356152357152358152359152360152361152362152363152364152365152366152367152368152369152370152371152372152373152374152375152376152377152378152379152380152381152382152383152384152385152386152387152388152389152390152391152392152393152394152395152396152397152398152399152400152401152402152403152404152405152406152407152408152409152410152411152412152413152414152415152416152417152418152419152420152421152422152423152424152425152426152427152428152429152430152431152432152433152434152435152436152437152438152439152440152441152442152443152444152445152446152447152448152449152450152451152452152453152454152455152456152457152458152459152460152461152462152463152464152465152466152467152468152469152470152471152472152473152474152475152476152477152478152479152480152481152482152483152484152485152486152487152488152489152490152491152492152493152494152495152496152497152498152499152500152501152502152503152504152505152506152507152508152509152510152511152512152513152514152515152516152517152518152519152520152521152522152523152524152525152526152527152528152529152530152531152532152533152534152535152536152537152538152539152540152541152542152543152544152545152546152547152548152549152550152551152552152553152554152555152556152557152558152559152560152561152562152563152564152565152566152567152568152569152570152571152572152573152574152575152576152577152578152579152580152581152582152583152584152585152586152587152588152589152590152591152592152593152594152595152596152597152598152599152600152601152602152603152604152605152606152607152608152609152610152611152612152613152614152615152616152617152618152619152620152621152622152623152624152625152626152627152628152629152630152631152632152633152634152635152636152637152638152639152640152641152642152643152644152645152646152647152648152649152650152651152652152653152654152655152656152657152658152659152660152661152662152663152664152665152666152667152668152669152670152671152672152673152674152675152676152677152678152679152680152681152682152683152684152685152686152687152688152689152690152691152692152693152694152695152696152697152698152699152700152701152702152703152704152705152706152707152708152709152710152711152712152713152714152715152716152717152718152719152720152721152722152723152724152725152726152727152728152729152730152731152732152733152734152735152736152737152738152739152740152741152742152743152744152745152746152747152748152749152750152751152752152753152754152755152756152757152758152759152760152761152762152763152764152765152766152767152768152769152770152771152772152773152774152775152776152777152778152779152780152781152782152783152784152785152786152787152788152789152790152791152792152793152794152795152796152797152798152799152800152801152802152803152804152805152806152807152808152809152810152811152812152813152814152815152816152817152818152819152820152821152822152823152824152825152826152827152828152829152830152831152832152833152834152835152836152837152838152839152840152841152842152843152844152845152846152847152848152849152850152851152852152853152854152855152856152857152858152859152860152861152862152863152864152865152866152867152868152869152870152871152872152873152874152875152876152877152878152879152880152881152882152883152884152885152886152887152888152889152890152891152892152893152894152895152896152897152898152899152900152901152902152903152904152905152906152907152908152909152910152911152912152913152914152915152916152917152918152919152920152921152922152923152924152925152926152927152928152929152930152931152932152933152934152935152936152937152938152939152940152941152942152943152944152945152946152947152948152949152950152951152952152953152954152955152956152957152958152959152960152961152962152963152964152965152966152967152968152969152970152971152972152973152974152975152976152977152978152979152980152981152982152983152984152985152986152987152988152989152990152991152992152993152994152995152996152997152998152999153000153001153002153003153004153005153006153007153008153009153010153011153012153013153014153015153016153017153018153019153020153021153022153023153024153025153026153027153028153029153030153031153032153033153034153035153036153037153038153039153040153041153042153043153044153045153046153047153048153049153050153051153052153053153054153055153056153057153058153059153060153061153062153063153064153065153066153067153068153069153070153071153072153073153074153075153076153077153078153079153080153081153082153083153084153085153086153087153088153089153090153091153092153093153094153095153096153097153098153099153100153101153102153103153104153105153106153107153108153109153110153111153112153113153114153115153116153117153118153119153120153121153122153123153124153125153126153127153128153129153130153131153132153133153134153135153136153137153138153139153140153141153142153143153144153145153146153147153148153149153150153151153152153153153154153155153156153157153158153159153160153161153162153163153164153165153166153167153168153169153170153171153172153173153174153175153176153177153178153179153180153181153182153183153184153185153186153187153188153189153190153191153192153193153194153195153196153197153198153199153200153201153202153203153204153205153206153207153208153209153210153211153212153213153214153215153216153217153218153219153220153221153222153223153224153225153226153227153228153229153230153231153232153233153234153235153236153237153238153239153240153241153242153243153244153245153246153247153248153249153250153251153252153253153254153255153256153257153258153259153260153261153262153263153264153265153266153267153268153269153270153271153272153273153274153275153276153277153278153279153280153281153282153283153284153285153286153287153288153289153290153291153292153293153294153295153296153297153298153299153300153301153302153303153304153305153306153307153308153309153310153311153312153313153314153315153316153317153318153319153320153321153322153323153324153325153326153327153328153329153330153331153332153333153334153335153336153337153338153339153340153341153342153343153344153345153346153347153348153349153350153351153352153353153354153355153356153357153358153359153360153361153362153363153364153365153366153367153368153369153370153371153372153373153374153375153376153377153378153379153380153381153382153383153384153385153386153387153388153389153390153391153392153393153394153395153396153397153398153399153400153401153402153403153404153405153406153407153408153409153410153411153412153413153414153415153416153417153418153419153420153421153422153423153424153425153426153427153428153429153430153431153432153433153434153435153436153437153438153439153440153441153442153443153444153445153446153447153448153449153450153451153452153453153454153455153456153457153458153459153460153461153462153463153464153465153466153467153468153469153470153471153472153473153474153475153476153477153478153479153480153481153482153483153484153485153486153487153488153489153490153491153492153493153494153495153496153497153498153499153500153501153502153503153504153505153506153507153508153509153510153511153512153513153514153515153516153517153518153519153520153521153522153523153524153525153526153527153528153529153530153531153532153533153534153535153536153537153538153539153540153541153542153543153544153545153546153547153548153549153550153551153552153553153554153555153556153557153558153559153560153561153562153563153564153565153566153567153568153569153570153571153572153573153574153575153576153577153578153579153580153581153582153583153584153585153586153587153588153589153590153591153592153593153594153595153596153597153598153599153600153601153602153603153604153605153606153607153608153609153610153611153612153613153614153615153616153617153618153619153620153621153622153623153624153625153626153627153628153629153630153631153632153633153634153635153636153637153638153639153640153641153642153643153644153645153646153647153648153649153650153651153652153653153654153655153656153657153658153659153660153661153662153663153664153665153666153667153668153669153670153671153672153673153674153675153676153677153678153679153680153681153682153683153684153685153686153687153688153689153690153691153692153693153694153695153696153697153698153699153700153701153702153703153704153705153706153707153708153709153710153711153712153713153714153715153716153717153718153719153720153721153722153723153724153725153726153727153728153729153730153731153732153733153734153735153736153737153738153739153740153741153742153743153744153745153746153747153748153749153750153751153752153753153754153755153756153757153758153759153760153761153762153763153764153765153766153767153768153769153770153771153772153773153774153775153776153777153778153779153780153781153782153783153784153785153786153787153788153789153790153791153792153793153794153795153796153797153798153799153800153801153802153803153804153805153806153807153808153809153810153811153812153813153814153815153816153817153818153819153820153821153822153823153824153825153826153827153828153829153830153831153832153833153834153835153836153837153838153839153840153841153842153843153844153845153846153847153848153849153850153851153852153853153854153855153856153857153858153859153860153861153862153863153864153865153866153867153868153869153870153871153872153873153874153875153876153877153878153879153880153881153882153883153884153885153886153887153888153889153890153891153892153893153894153895153896153897153898153899153900153901153902153903153904153905153906153907153908153909153910153911153912153913153914153915153916153917153918153919153920153921153922153923153924153925153926153927153928153929153930153931153932153933153934153935153936153937153938153939153940153941153942153943153944153945153946153947153948153949153950153951153952153953153954153955153956153957153958153959153960153961153962153963153964153965153966153967153968153969153970153971153972153973153974153975153976153977153978153979153980153981153982153983153984153985153986153987153988153989153990153991153992153993153994153995153996153997153998153999154000154001154002154003154004154005154006154007154008154009154010154011154012154013154014154015154016154017154018154019154020154021154022154023154024154025154026154027154028154029154030154031154032154033154034154035154036154037154038154039154040154041154042154043154044154045154046154047154048154049154050154051154052154053154054154055154056154057154058154059154060154061154062154063154064154065154066154067154068154069154070154071154072154073154074154075154076154077154078154079154080154081154082154083154084154085154086154087154088154089154090154091154092154093154094154095154096154097154098154099154100154101154102154103154104154105154106154107154108154109154110154111154112154113154114154115154116154117154118154119154120154121154122154123154124154125154126154127154128154129154130154131154132154133154134154135154136154137154138154139154140154141154142154143154144154145154146154147154148154149154150154151154152154153154154154155154156154157154158154159154160154161154162154163154164154165154166154167154168154169154170154171154172154173154174154175154176154177154178154179154180154181154182154183154184154185154186154187154188154189154190154191154192154193154194154195154196154197154198154199154200154201154202154203154204154205154206154207154208154209154210154211154212154213154214154215154216154217154218154219154220154221154222154223154224154225154226154227154228154229154230154231154232154233154234154235154236154237154238154239154240154241154242154243154244154245154246154247154248154249154250154251154252154253154254154255154256154257154258154259154260154261154262154263154264154265154266154267154268154269154270154271154272154273154274154275154276154277154278154279154280154281154282154283154284154285154286154287154288154289154290154291154292154293154294154295154296154297154298154299154300154301154302154303154304154305154306154307154308154309154310154311154312154313154314154315154316154317154318154319154320154321154322154323154324154325154326154327154328154329154330154331154332154333154334154335154336154337154338154339154340154341154342154343154344154345154346154347154348154349154350154351154352154353154354154355154356154357154358154359154360154361154362154363154364154365154366154367154368154369154370154371154372154373154374154375154376154377154378154379154380154381154382154383154384154385154386154387154388154389154390154391154392154393154394154395154396154397154398154399154400154401154402154403154404154405154406154407154408154409154410154411154412154413154414154415154416154417154418154419154420154421154422154423154424154425154426154427154428154429154430154431154432154433154434154435154436154437154438154439154440154441154442154443154444154445154446154447154448154449154450154451154452154453154454154455154456154457154458154459154460154461154462154463154464154465154466154467154468154469154470154471154472154473154474154475154476154477154478154479154480154481154482154483154484154485154486154487154488154489154490154491154492154493154494154495154496154497154498154499154500154501154502154503154504154505154506154507154508154509154510154511154512154513154514154515154516154517154518154519154520154521154522154523154524154525154526154527154528154529154530154531154532154533154534154535154536154537154538154539154540154541154542154543154544154545154546154547154548154549154550154551154552154553154554154555154556154557154558154559154560154561154562154563154564154565154566154567154568154569154570154571154572154573154574154575154576154577154578154579154580154581154582154583154584154585154586154587154588154589154590154591154592154593154594154595154596154597154598154599154600154601154602154603154604154605154606154607154608154609154610154611154612154613154614154615154616154617154618154619154620154621154622154623154624154625154626154627154628154629154630154631154632154633154634154635154636154637154638154639154640154641154642154643154644154645154646154647154648154649154650154651154652154653154654154655154656154657154658154659154660154661154662154663154664154665154666154667154668154669154670154671154672154673154674154675154676154677154678154679154680154681154682154683154684154685154686154687154688154689154690154691154692154693154694154695154696154697154698154699154700154701154702154703154704154705154706154707154708154709154710154711154712154713154714154715154716154717154718154719154720154721154722154723154724154725154726154727154728154729154730154731154732154733154734154735154736154737154738154739154740154741154742154743154744154745154746154747154748154749154750154751154752154753154754154755154756154757154758154759154760154761154762154763154764154765154766154767154768154769154770154771154772154773154774154775154776154777154778154779154780154781154782154783154784154785154786154787154788154789154790154791154792154793154794154795154796154797154798154799154800154801154802154803154804154805154806154807154808154809154810154811154812154813154814154815154816154817154818154819154820154821154822154823154824154825154826154827154828154829154830154831154832154833154834154835154836154837154838154839154840154841154842154843154844154845154846154847154848154849154850154851154852154853154854154855154856154857154858154859154860154861154862154863154864154865154866154867154868154869154870154871154872154873154874154875154876154877154878154879154880154881154882154883154884154885154886154887154888154889154890154891154892154893154894154895154896154897154898154899154900154901154902154903154904154905154906154907154908154909154910154911154912154913154914154915154916154917154918154919154920154921154922154923154924154925154926154927154928154929154930154931154932154933154934154935154936154937154938154939154940154941154942154943154944154945154946154947154948154949154950154951154952154953154954154955154956154957154958154959154960154961154962154963154964154965154966154967154968154969154970154971154972154973154974154975154976154977154978154979154980154981154982154983154984154985154986154987154988154989154990154991154992154993154994154995154996154997154998154999155000155001155002155003155004155005155006155007155008155009155010155011155012155013155014155015155016155017155018155019155020155021155022155023155024155025155026155027155028155029155030155031155032155033155034155035155036155037155038155039155040155041155042155043155044155045155046155047155048155049155050155051155052155053155054155055155056155057155058155059155060155061155062155063155064155065155066155067155068155069155070155071155072155073155074155075155076155077155078155079155080155081155082155083155084155085155086155087155088155089155090155091155092155093155094155095155096155097155098155099155100155101155102155103155104155105155106155107155108155109155110155111155112155113155114155115155116155117155118155119155120155121155122155123155124155125155126155127155128155129155130155131155132155133155134155135155136155137155138155139155140155141155142155143155144155145155146155147155148155149155150155151155152155153155154155155155156155157155158155159155160155161155162155163155164155165155166155167155168155169155170155171155172155173155174155175155176155177155178155179155180155181155182155183155184155185155186155187155188155189155190155191155192155193155194155195155196155197155198155199155200155201155202155203155204155205155206155207155208155209155210155211155212155213155214155215155216155217155218155219155220155221155222155223155224155225155226155227155228155229155230155231155232155233155234155235155236155237155238155239155240155241155242155243155244155245155246155247155248155249155250155251155252155253155254155255155256155257155258155259155260155261155262155263155264155265155266155267155268155269155270155271155272155273155274155275155276155277155278155279155280155281155282155283155284155285155286155287155288155289155290155291155292155293155294155295155296155297155298155299155300155301155302155303155304155305155306155307155308155309155310155311155312155313155314155315155316155317155318155319155320155321155322155323155324155325155326155327155328155329155330155331155332155333155334155335155336155337155338155339155340155341155342155343155344155345155346155347155348155349155350155351155352155353155354155355155356155357155358155359155360155361155362155363155364155365155366155367155368155369155370155371155372155373155374155375155376155377155378155379155380155381155382155383155384155385155386155387155388155389155390155391155392155393155394155395155396155397155398155399155400155401155402155403155404155405155406155407155408155409155410155411155412155413155414155415155416155417155418155419155420155421155422155423155424155425155426155427155428155429155430155431155432155433155434155435155436155437155438155439155440155441155442155443155444155445155446155447155448155449155450155451155452155453155454155455155456155457155458155459155460155461155462155463155464155465155466155467155468155469155470155471155472155473155474155475155476155477155478155479155480155481155482155483155484155485155486155487155488155489155490155491155492155493155494155495155496155497155498155499155500155501155502155503155504155505155506155507155508155509155510155511155512155513155514155515155516155517155518155519155520155521155522155523155524155525155526155527155528155529155530155531155532155533155534155535155536155537155538155539155540155541155542155543155544155545155546155547155548155549155550155551155552155553155554155555155556155557155558155559155560155561155562155563155564155565155566155567155568155569155570155571155572155573155574155575155576155577155578155579155580155581155582155583155584155585155586155587155588155589155590155591155592155593155594155595155596155597155598155599155600155601155602155603155604155605155606155607155608155609155610155611155612155613155614155615155616155617155618155619155620155621155622155623155624155625155626155627155628155629155630155631155632155633155634155635155636155637155638155639155640155641155642155643155644155645155646155647155648155649155650155651155652155653155654155655155656155657155658155659155660155661155662155663155664155665155666155667155668155669155670155671155672155673155674155675155676155677155678155679155680155681155682155683155684155685155686155687155688155689155690155691155692155693155694155695155696155697155698155699155700155701155702155703155704155705155706155707155708155709155710155711155712155713155714155715155716155717155718155719155720155721155722155723155724155725155726155727155728155729155730155731155732155733155734155735155736155737155738155739155740155741155742155743155744155745155746155747155748155749155750155751155752155753155754155755155756155757155758155759155760155761155762155763155764155765155766155767155768155769155770155771155772155773155774155775155776155777155778155779155780155781155782155783155784155785155786155787155788155789155790155791155792155793155794155795155796155797155798155799155800155801155802155803155804155805155806155807155808155809155810155811155812155813155814155815155816155817155818155819155820155821155822155823155824155825155826155827155828155829155830155831155832155833155834155835155836155837155838155839155840155841155842155843155844155845155846155847155848155849155850155851155852155853155854155855155856155857155858155859155860155861155862155863155864155865155866155867155868155869155870155871155872155873155874155875155876155877155878155879155880155881155882155883155884155885155886155887155888155889155890155891155892155893155894155895155896155897155898155899155900155901155902155903155904155905155906155907155908155909155910155911155912155913155914155915155916155917155918155919155920155921155922155923155924155925155926155927155928155929155930155931155932155933155934155935155936155937155938155939155940155941155942155943155944155945155946155947155948155949155950155951155952155953155954155955155956155957155958155959155960155961155962155963155964155965155966155967155968155969155970155971155972155973155974155975155976155977155978155979155980155981155982155983155984155985155986155987155988155989155990155991155992155993155994155995155996155997155998155999156000156001156002156003156004156005156006156007156008156009156010156011156012156013156014156015156016156017156018156019156020156021156022156023156024156025156026156027156028156029156030156031156032156033156034156035156036156037156038156039156040156041156042156043156044156045156046156047156048156049156050156051156052156053156054156055156056156057156058156059156060156061156062156063156064156065156066156067156068156069156070156071156072156073156074156075156076156077156078156079156080156081156082156083156084156085156086156087156088156089156090156091156092156093156094156095156096156097156098156099156100156101156102156103156104156105156106156107156108156109156110156111156112156113156114156115156116156117156118156119156120156121156122156123156124156125156126156127156128156129156130156131156132156133156134156135156136156137156138156139156140156141156142156143156144156145156146156147156148156149156150156151156152156153156154156155156156156157156158156159156160156161156162156163156164156165156166156167156168156169156170156171156172156173156174156175156176156177156178156179156180156181156182156183156184156185156186156187156188156189156190156191156192156193156194156195156196156197156198156199156200156201156202156203156204156205156206156207156208156209156210156211156212156213156214156215156216156217156218156219156220156221156222156223156224156225156226156227156228156229156230156231156232156233156234156235156236156237156238156239156240156241156242156243156244156245156246156247156248156249156250156251156252156253156254156255156256156257156258156259156260156261156262156263156264156265156266156267156268156269156270156271156272156273156274156275156276156277156278156279156280156281156282156283156284156285156286156287156288156289156290156291156292156293156294156295156296156297156298156299156300156301156302156303156304156305156306156307156308156309156310156311156312156313156314156315156316156317156318156319156320156321156322156323156324156325156326156327156328156329156330156331156332156333156334156335156336156337156338156339156340156341156342156343156344156345156346156347156348156349156350156351156352156353156354156355156356156357156358156359156360156361156362156363156364156365156366156367156368156369156370156371156372156373156374156375156376156377156378156379156380156381156382156383156384156385156386156387156388156389156390156391156392156393156394156395156396156397156398156399156400156401156402156403156404156405156406156407156408156409156410156411156412156413156414156415156416156417156418156419156420156421156422156423156424156425156426156427156428156429156430156431156432156433156434156435156436156437156438156439156440156441156442156443156444156445156446156447156448156449156450156451156452156453156454156455156456156457156458156459156460156461156462156463156464156465156466156467156468156469156470156471156472156473156474156475156476156477156478156479156480156481156482156483156484156485156486156487156488156489156490156491156492156493156494156495156496156497156498156499156500156501156502156503156504156505156506156507156508156509156510156511156512156513156514156515156516156517156518156519156520156521156522156523156524156525156526156527156528156529156530156531156532156533156534156535156536156537156538156539156540156541156542156543156544156545156546156547156548156549156550156551156552156553156554156555156556156557156558156559156560156561156562156563156564156565156566156567156568156569156570156571156572156573156574156575156576156577156578156579156580156581156582156583156584156585156586156587156588156589156590156591156592156593156594156595156596156597156598156599156600156601156602156603156604156605156606156607156608156609156610156611156612156613156614156615156616156617156618156619156620156621156622156623156624156625156626156627156628156629156630156631156632156633156634156635156636156637156638156639156640156641156642156643156644156645156646156647156648156649156650156651156652156653156654156655156656156657156658156659156660156661156662156663156664156665156666156667156668156669156670156671156672156673156674156675156676156677156678156679156680156681156682156683156684156685156686156687156688156689156690156691156692156693156694156695156696156697156698156699156700156701156702156703156704156705156706156707156708156709156710156711156712156713156714156715156716156717156718156719156720156721156722156723156724156725156726156727156728156729156730156731156732156733156734156735156736156737156738156739156740156741156742156743156744156745156746156747156748156749156750156751156752156753156754156755156756156757156758156759156760156761156762156763156764156765156766156767156768156769156770156771156772156773156774156775156776156777156778156779156780156781156782156783156784156785156786156787156788156789156790156791156792156793156794156795156796156797156798156799156800156801156802156803156804156805156806156807156808156809156810156811156812156813156814156815156816156817156818156819156820156821156822156823156824156825156826156827156828156829156830156831156832156833156834156835156836156837156838156839156840156841156842156843156844156845156846156847156848156849156850156851156852156853156854156855156856156857156858156859156860156861156862156863156864156865156866156867156868156869156870156871156872156873156874156875156876156877156878156879156880156881156882156883156884156885156886156887156888156889156890156891156892156893156894156895156896156897156898156899156900156901156902156903156904156905156906156907156908156909156910156911156912156913156914156915156916156917156918156919156920156921156922156923156924156925156926156927156928156929156930156931156932156933156934156935156936156937156938156939156940156941156942156943156944156945156946156947156948156949156950156951156952156953156954156955156956156957156958156959156960156961156962156963156964156965156966156967156968156969156970156971156972156973156974156975156976156977156978156979156980156981156982156983156984156985156986156987156988156989156990156991156992156993156994156995156996156997156998156999157000157001157002157003157004157005157006157007157008157009157010157011157012157013157014157015157016157017157018157019157020157021157022157023157024157025157026157027157028157029157030157031157032157033157034157035157036157037157038157039157040157041157042157043157044157045157046157047157048157049157050157051157052157053157054157055157056157057157058157059157060157061157062157063157064157065157066157067157068157069157070157071157072157073157074157075157076157077157078157079157080157081157082157083157084157085157086157087157088157089157090157091157092157093157094157095157096157097157098157099157100157101157102157103157104157105157106157107157108157109157110157111157112157113157114157115157116157117157118157119157120157121157122157123157124157125157126157127157128157129157130157131157132157133157134157135157136157137157138157139157140157141157142157143157144157145157146157147157148157149157150157151157152157153157154157155157156157157157158157159157160157161157162157163157164157165157166157167157168157169157170157171157172157173157174157175157176157177157178157179157180157181157182157183157184157185157186157187157188157189157190157191157192157193157194157195157196157197157198157199157200157201157202157203157204157205157206157207157208157209157210157211157212157213157214157215157216157217157218157219157220157221157222157223157224157225157226157227157228157229157230157231157232157233157234157235157236157237157238157239157240157241157242157243157244157245157246157247157248157249157250157251157252157253157254157255157256157257157258157259157260157261157262157263157264157265157266157267157268157269157270157271157272157273157274157275157276157277157278157279157280157281157282157283157284157285157286157287157288157289157290157291157292157293157294157295157296157297157298157299157300157301157302157303157304157305157306157307157308157309157310157311157312157313157314157315157316157317157318157319157320157321157322157323157324157325157326157327157328157329157330157331157332157333157334157335157336157337157338157339157340157341157342157343157344157345157346157347157348157349157350157351157352157353157354157355157356157357157358157359157360157361157362157363157364157365157366157367157368157369157370157371157372157373157374157375157376157377157378157379157380157381157382157383157384
  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 dirty prepass flag value
  862. */
  863. static readonly MATERIAL_PrePassDirtyFlag: number;
  864. /**
  865. * The all dirty flag value
  866. */
  867. static readonly MATERIAL_AllDirtyFlag: number;
  868. /**
  869. * Returns the triangle fill mode
  870. */
  871. static readonly MATERIAL_TriangleFillMode: number;
  872. /**
  873. * Returns the wireframe mode
  874. */
  875. static readonly MATERIAL_WireFrameFillMode: number;
  876. /**
  877. * Returns the point fill mode
  878. */
  879. static readonly MATERIAL_PointFillMode: number;
  880. /**
  881. * Returns the point list draw mode
  882. */
  883. static readonly MATERIAL_PointListDrawMode: number;
  884. /**
  885. * Returns the line list draw mode
  886. */
  887. static readonly MATERIAL_LineListDrawMode: number;
  888. /**
  889. * Returns the line loop draw mode
  890. */
  891. static readonly MATERIAL_LineLoopDrawMode: number;
  892. /**
  893. * Returns the line strip draw mode
  894. */
  895. static readonly MATERIAL_LineStripDrawMode: number;
  896. /**
  897. * Returns the triangle strip draw mode
  898. */
  899. static readonly MATERIAL_TriangleStripDrawMode: number;
  900. /**
  901. * Returns the triangle fan draw mode
  902. */
  903. static readonly MATERIAL_TriangleFanDrawMode: number;
  904. /**
  905. * Stores the clock-wise side orientation
  906. */
  907. static readonly MATERIAL_ClockWiseSideOrientation: number;
  908. /**
  909. * Stores the counter clock-wise side orientation
  910. */
  911. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  912. /**
  913. * Nothing
  914. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  915. */
  916. static readonly ACTION_NothingTrigger: number;
  917. /**
  918. * On pick
  919. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  920. */
  921. static readonly ACTION_OnPickTrigger: number;
  922. /**
  923. * On left pick
  924. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  925. */
  926. static readonly ACTION_OnLeftPickTrigger: number;
  927. /**
  928. * On right pick
  929. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  930. */
  931. static readonly ACTION_OnRightPickTrigger: number;
  932. /**
  933. * On center pick
  934. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  935. */
  936. static readonly ACTION_OnCenterPickTrigger: number;
  937. /**
  938. * On pick down
  939. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  940. */
  941. static readonly ACTION_OnPickDownTrigger: number;
  942. /**
  943. * On double pick
  944. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  945. */
  946. static readonly ACTION_OnDoublePickTrigger: number;
  947. /**
  948. * On pick up
  949. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  950. */
  951. static readonly ACTION_OnPickUpTrigger: number;
  952. /**
  953. * On pick out.
  954. * This trigger will only be raised if you also declared a OnPickDown
  955. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  956. */
  957. static readonly ACTION_OnPickOutTrigger: number;
  958. /**
  959. * On long press
  960. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  961. */
  962. static readonly ACTION_OnLongPressTrigger: number;
  963. /**
  964. * On pointer over
  965. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  966. */
  967. static readonly ACTION_OnPointerOverTrigger: number;
  968. /**
  969. * On pointer out
  970. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  971. */
  972. static readonly ACTION_OnPointerOutTrigger: number;
  973. /**
  974. * On every frame
  975. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  976. */
  977. static readonly ACTION_OnEveryFrameTrigger: number;
  978. /**
  979. * On intersection enter
  980. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  981. */
  982. static readonly ACTION_OnIntersectionEnterTrigger: number;
  983. /**
  984. * On intersection exit
  985. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  986. */
  987. static readonly ACTION_OnIntersectionExitTrigger: number;
  988. /**
  989. * On key down
  990. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  991. */
  992. static readonly ACTION_OnKeyDownTrigger: number;
  993. /**
  994. * On key up
  995. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  996. */
  997. static readonly ACTION_OnKeyUpTrigger: number;
  998. /**
  999. * Billboard mode will only apply to Y axis
  1000. */
  1001. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  1002. /**
  1003. * Billboard mode will apply to all axes
  1004. */
  1005. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  1006. /**
  1007. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  1008. */
  1009. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  1010. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  1011. * Test order :
  1012. * Is the bounding sphere outside the frustum ?
  1013. * If not, are the bounding box vertices outside the frustum ?
  1014. * It not, then the cullable object is in the frustum.
  1015. */
  1016. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  1017. /** Culling strategy : Bounding Sphere Only.
  1018. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  1019. * It's also less accurate than the standard because some not visible objects can still be selected.
  1020. * Test : is the bounding sphere outside the frustum ?
  1021. * If not, then the cullable object is in the frustum.
  1022. */
  1023. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  1024. /** Culling strategy : Optimistic Inclusion.
  1025. * This in an inclusion test first, then the standard exclusion test.
  1026. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  1027. * 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.
  1028. * Anyway, it's as accurate as the standard strategy.
  1029. * Test :
  1030. * Is the cullable object bounding sphere center in the frustum ?
  1031. * If not, apply the default culling strategy.
  1032. */
  1033. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  1034. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  1035. * This in an inclusion test first, then the bounding sphere only exclusion test.
  1036. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  1037. * 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.
  1038. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  1039. * Test :
  1040. * Is the cullable object bounding sphere center in the frustum ?
  1041. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  1042. */
  1043. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  1044. /**
  1045. * No logging while loading
  1046. */
  1047. static readonly SCENELOADER_NO_LOGGING: number;
  1048. /**
  1049. * Minimal logging while loading
  1050. */
  1051. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  1052. /**
  1053. * Summary logging while loading
  1054. */
  1055. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  1056. /**
  1057. * Detailled logging while loading
  1058. */
  1059. static readonly SCENELOADER_DETAILED_LOGGING: number;
  1060. /**
  1061. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  1062. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  1063. */
  1064. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  1065. /**
  1066. * Constant used to retrieve the position texture index in the textures array in the prepass
  1067. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  1068. */
  1069. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  1070. /**
  1071. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  1072. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  1073. */
  1074. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  1075. /**
  1076. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  1077. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  1078. */
  1079. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  1080. /**
  1081. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  1082. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  1083. */
  1084. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  1085. /**
  1086. * Constant used to retrieve depth + normal index in the textures array in the prepass
  1087. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  1088. */
  1089. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  1090. /**
  1091. * Constant used to retrieve albedo index in the textures array in the prepass
  1092. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  1093. */
  1094. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  1095. }
  1096. }
  1097. declare module "babylonjs/Materials/Textures/internalTextureLoader" {
  1098. import { Nullable } from "babylonjs/types";
  1099. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  1100. /**
  1101. * This represents the required contract to create a new type of texture loader.
  1102. */
  1103. export interface IInternalTextureLoader {
  1104. /**
  1105. * Defines wether the loader supports cascade loading the different faces.
  1106. */
  1107. supportCascades: boolean;
  1108. /**
  1109. * This returns if the loader support the current file information.
  1110. * @param extension defines the file extension of the file being loaded
  1111. * @param mimeType defines the optional mime type of the file being loaded
  1112. * @returns true if the loader can load the specified file
  1113. */
  1114. canLoad(extension: string, mimeType?: string): boolean;
  1115. /**
  1116. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  1117. * @param data contains the texture data
  1118. * @param texture defines the BabylonJS internal texture
  1119. * @param createPolynomials will be true if polynomials have been requested
  1120. * @param onLoad defines the callback to trigger once the texture is ready
  1121. * @param onError defines the callback to trigger in case of error
  1122. */
  1123. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  1124. /**
  1125. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  1126. * @param data contains the texture data
  1127. * @param texture defines the BabylonJS internal texture
  1128. * @param callback defines the method to call once ready to upload
  1129. */
  1130. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  1131. }
  1132. }
  1133. declare module "babylonjs/Engines/IPipelineContext" {
  1134. /**
  1135. * Class used to store and describe the pipeline context associated with an effect
  1136. */
  1137. export interface IPipelineContext {
  1138. /**
  1139. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  1140. */
  1141. isAsync: boolean;
  1142. /**
  1143. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  1144. */
  1145. isReady: boolean;
  1146. /** @hidden */
  1147. _getVertexShaderCode(): string | null;
  1148. /** @hidden */
  1149. _getFragmentShaderCode(): string | null;
  1150. /** @hidden */
  1151. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  1152. }
  1153. }
  1154. declare module "babylonjs/Meshes/dataBuffer" {
  1155. /**
  1156. * Class used to store gfx data (like WebGLBuffer)
  1157. */
  1158. export class DataBuffer {
  1159. /**
  1160. * Gets or sets the number of objects referencing this buffer
  1161. */
  1162. references: number;
  1163. /** Gets or sets the size of the underlying buffer */
  1164. capacity: number;
  1165. /**
  1166. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  1167. */
  1168. is32Bits: boolean;
  1169. /**
  1170. * Gets the underlying buffer
  1171. */
  1172. get underlyingResource(): any;
  1173. }
  1174. }
  1175. declare module "babylonjs/Engines/Processors/iShaderProcessor" {
  1176. /** @hidden */
  1177. export interface IShaderProcessor {
  1178. attributeProcessor?: (attribute: string) => string;
  1179. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  1180. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  1181. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  1182. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  1183. lineProcessor?: (line: string, isFragment: boolean) => string;
  1184. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1185. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  1186. }
  1187. }
  1188. declare module "babylonjs/Engines/Processors/shaderProcessingOptions" {
  1189. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  1190. /** @hidden */
  1191. export interface ProcessingOptions {
  1192. defines: string[];
  1193. indexParameters: any;
  1194. isFragment: boolean;
  1195. shouldUseHighPrecisionShader: boolean;
  1196. supportsUniformBuffers: boolean;
  1197. shadersRepository: string;
  1198. includesShadersStore: {
  1199. [key: string]: string;
  1200. };
  1201. processor?: IShaderProcessor;
  1202. version: string;
  1203. platformName: string;
  1204. lookForClosingBracketForUniformBuffer?: boolean;
  1205. }
  1206. }
  1207. declare module "babylonjs/Engines/Processors/shaderCodeNode" {
  1208. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1209. /** @hidden */
  1210. export class ShaderCodeNode {
  1211. line: string;
  1212. children: ShaderCodeNode[];
  1213. additionalDefineKey?: string;
  1214. additionalDefineValue?: string;
  1215. isValid(preprocessors: {
  1216. [key: string]: string;
  1217. }): boolean;
  1218. process(preprocessors: {
  1219. [key: string]: string;
  1220. }, options: ProcessingOptions): string;
  1221. }
  1222. }
  1223. declare module "babylonjs/Engines/Processors/shaderCodeCursor" {
  1224. /** @hidden */
  1225. export class ShaderCodeCursor {
  1226. private _lines;
  1227. lineIndex: number;
  1228. get currentLine(): string;
  1229. get canRead(): boolean;
  1230. set lines(value: string[]);
  1231. }
  1232. }
  1233. declare module "babylonjs/Engines/Processors/shaderCodeConditionNode" {
  1234. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1235. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1236. /** @hidden */
  1237. export class ShaderCodeConditionNode extends ShaderCodeNode {
  1238. process(preprocessors: {
  1239. [key: string]: string;
  1240. }, options: ProcessingOptions): string;
  1241. }
  1242. }
  1243. declare module "babylonjs/Engines/Processors/Expressions/shaderDefineExpression" {
  1244. /** @hidden */
  1245. export class ShaderDefineExpression {
  1246. isTrue(preprocessors: {
  1247. [key: string]: string;
  1248. }): boolean;
  1249. private static _OperatorPriority;
  1250. private static _Stack;
  1251. static postfixToInfix(postfix: string[]): string;
  1252. static infixToPostfix(infix: string): string[];
  1253. }
  1254. }
  1255. declare module "babylonjs/Engines/Processors/shaderCodeTestNode" {
  1256. import { ShaderCodeNode } from "babylonjs/Engines/Processors/shaderCodeNode";
  1257. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1258. /** @hidden */
  1259. export class ShaderCodeTestNode extends ShaderCodeNode {
  1260. testExpression: ShaderDefineExpression;
  1261. isValid(preprocessors: {
  1262. [key: string]: string;
  1263. }): boolean;
  1264. }
  1265. }
  1266. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator" {
  1267. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1268. /** @hidden */
  1269. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  1270. define: string;
  1271. not: boolean;
  1272. constructor(define: string, not?: boolean);
  1273. isTrue(preprocessors: {
  1274. [key: string]: string;
  1275. }): boolean;
  1276. }
  1277. }
  1278. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator" {
  1279. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1280. /** @hidden */
  1281. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  1282. leftOperand: ShaderDefineExpression;
  1283. rightOperand: ShaderDefineExpression;
  1284. isTrue(preprocessors: {
  1285. [key: string]: string;
  1286. }): boolean;
  1287. }
  1288. }
  1289. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator" {
  1290. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1291. /** @hidden */
  1292. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  1293. leftOperand: ShaderDefineExpression;
  1294. rightOperand: ShaderDefineExpression;
  1295. isTrue(preprocessors: {
  1296. [key: string]: string;
  1297. }): boolean;
  1298. }
  1299. }
  1300. declare module "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator" {
  1301. import { ShaderDefineExpression } from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  1302. /** @hidden */
  1303. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  1304. define: string;
  1305. operand: string;
  1306. testValue: string;
  1307. constructor(define: string, operand: string, testValue: string);
  1308. isTrue(preprocessors: {
  1309. [key: string]: string;
  1310. }): boolean;
  1311. }
  1312. }
  1313. declare module "babylonjs/Offline/IOfflineProvider" {
  1314. /**
  1315. * Class used to enable access to offline support
  1316. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  1317. */
  1318. export interface IOfflineProvider {
  1319. /**
  1320. * Gets a boolean indicating if scene must be saved in the database
  1321. */
  1322. enableSceneOffline: boolean;
  1323. /**
  1324. * Gets a boolean indicating if textures must be saved in the database
  1325. */
  1326. enableTexturesOffline: boolean;
  1327. /**
  1328. * Open the offline support and make it available
  1329. * @param successCallback defines the callback to call on success
  1330. * @param errorCallback defines the callback to call on error
  1331. */
  1332. open(successCallback: () => void, errorCallback: () => void): void;
  1333. /**
  1334. * Loads an image from the offline support
  1335. * @param url defines the url to load from
  1336. * @param image defines the target DOM image
  1337. */
  1338. loadImage(url: string, image: HTMLImageElement): void;
  1339. /**
  1340. * Loads a file from offline support
  1341. * @param url defines the URL to load from
  1342. * @param sceneLoaded defines a callback to call on success
  1343. * @param progressCallBack defines a callback to call when progress changed
  1344. * @param errorCallback defines a callback to call on error
  1345. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  1346. */
  1347. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  1348. }
  1349. }
  1350. declare module "babylonjs/Misc/filesInputStore" {
  1351. /**
  1352. * Class used to help managing file picking and drag'n'drop
  1353. * File Storage
  1354. */
  1355. export class FilesInputStore {
  1356. /**
  1357. * List of files ready to be loaded
  1358. */
  1359. static FilesToLoad: {
  1360. [key: string]: File;
  1361. };
  1362. }
  1363. }
  1364. declare module "babylonjs/Misc/retryStrategy" {
  1365. import { WebRequest } from "babylonjs/Misc/webRequest";
  1366. /**
  1367. * Class used to define a retry strategy when error happens while loading assets
  1368. */
  1369. export class RetryStrategy {
  1370. /**
  1371. * Function used to defines an exponential back off strategy
  1372. * @param maxRetries defines the maximum number of retries (3 by default)
  1373. * @param baseInterval defines the interval between retries
  1374. * @returns the strategy function to use
  1375. */
  1376. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  1377. }
  1378. }
  1379. declare module "babylonjs/Misc/baseError" {
  1380. /**
  1381. * @ignore
  1382. * Application error to support additional information when loading a file
  1383. */
  1384. export abstract class BaseError extends Error {
  1385. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  1386. }
  1387. }
  1388. declare module "babylonjs/Misc/fileTools" {
  1389. import { WebRequest } from "babylonjs/Misc/webRequest";
  1390. import { Nullable } from "babylonjs/types";
  1391. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1392. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1393. import { BaseError } from "babylonjs/Misc/baseError";
  1394. /** @ignore */
  1395. export class LoadFileError extends BaseError {
  1396. request?: WebRequest;
  1397. file?: File;
  1398. /**
  1399. * Creates a new LoadFileError
  1400. * @param message defines the message of the error
  1401. * @param request defines the optional web request
  1402. * @param file defines the optional file
  1403. */
  1404. constructor(message: string, object?: WebRequest | File);
  1405. }
  1406. /** @ignore */
  1407. export class RequestFileError extends BaseError {
  1408. request: WebRequest;
  1409. /**
  1410. * Creates a new LoadFileError
  1411. * @param message defines the message of the error
  1412. * @param request defines the optional web request
  1413. */
  1414. constructor(message: string, request: WebRequest);
  1415. }
  1416. /** @ignore */
  1417. export class ReadFileError extends BaseError {
  1418. file: File;
  1419. /**
  1420. * Creates a new ReadFileError
  1421. * @param message defines the message of the error
  1422. * @param file defines the optional file
  1423. */
  1424. constructor(message: string, file: File);
  1425. }
  1426. /**
  1427. * @hidden
  1428. */
  1429. export class FileTools {
  1430. /**
  1431. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  1432. */
  1433. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  1434. /**
  1435. * Gets or sets the base URL to use to load assets
  1436. */
  1437. static BaseUrl: string;
  1438. /**
  1439. * Default behaviour for cors in the application.
  1440. * It can be a string if the expected behavior is identical in the entire app.
  1441. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  1442. */
  1443. static CorsBehavior: string | ((url: string | string[]) => string);
  1444. /**
  1445. * Gets or sets a function used to pre-process url before using them to load assets
  1446. */
  1447. static PreprocessUrl: (url: string) => string;
  1448. /**
  1449. * Removes unwanted characters from an url
  1450. * @param url defines the url to clean
  1451. * @returns the cleaned url
  1452. */
  1453. private static _CleanUrl;
  1454. /**
  1455. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  1456. * @param url define the url we are trying
  1457. * @param element define the dom element where to configure the cors policy
  1458. */
  1459. static SetCorsBehavior(url: string | string[], element: {
  1460. crossOrigin: string | null;
  1461. }): void;
  1462. /**
  1463. * Loads an image as an HTMLImageElement.
  1464. * @param input url string, ArrayBuffer, or Blob to load
  1465. * @param onLoad callback called when the image successfully loads
  1466. * @param onError callback called when the image fails to load
  1467. * @param offlineProvider offline provider for caching
  1468. * @param mimeType optional mime type
  1469. * @returns the HTMLImageElement of the loaded image
  1470. */
  1471. 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>;
  1472. /**
  1473. * Reads a file from a File object
  1474. * @param file defines the file to load
  1475. * @param onSuccess defines the callback to call when data is loaded
  1476. * @param onProgress defines the callback to call during loading process
  1477. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  1478. * @param onError defines the callback to call when an error occurs
  1479. * @returns a file request object
  1480. */
  1481. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  1482. /**
  1483. * Loads a file from a url
  1484. * @param url url to load
  1485. * @param onSuccess callback called when the file successfully loads
  1486. * @param onProgress callback called while file is loading (if the server supports this mode)
  1487. * @param offlineProvider defines the offline provider for caching
  1488. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1489. * @param onError callback called when the file fails to load
  1490. * @returns a file request object
  1491. */
  1492. 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;
  1493. /**
  1494. * Loads a file
  1495. * @param url url to load
  1496. * @param onSuccess callback called when the file successfully loads
  1497. * @param onProgress callback called while file is loading (if the server supports this mode)
  1498. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1499. * @param onError callback called when the file fails to load
  1500. * @param onOpened callback called when the web request is opened
  1501. * @returns a file request object
  1502. */
  1503. 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;
  1504. /**
  1505. * Checks if the loaded document was accessed via `file:`-Protocol.
  1506. * @returns boolean
  1507. */
  1508. static IsFileURL(): boolean;
  1509. }
  1510. }
  1511. declare module "babylonjs/Engines/Processors/shaderProcessor" {
  1512. import { ProcessingOptions } from "babylonjs/Engines/Processors/shaderProcessingOptions";
  1513. import { WebRequest } from "babylonjs/Misc/webRequest";
  1514. import { LoadFileError } from "babylonjs/Misc/fileTools";
  1515. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  1516. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  1517. /** @hidden */
  1518. export class ShaderProcessor {
  1519. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  1520. private static _ProcessPrecision;
  1521. private static _ExtractOperation;
  1522. private static _BuildSubExpression;
  1523. private static _BuildExpression;
  1524. private static _MoveCursorWithinIf;
  1525. private static _MoveCursor;
  1526. private static _EvaluatePreProcessors;
  1527. private static _PreparePreProcessors;
  1528. private static _ProcessShaderConversion;
  1529. private static _ProcessIncludes;
  1530. /**
  1531. * Loads a file from a url
  1532. * @param url url to load
  1533. * @param onSuccess callback called when the file successfully loads
  1534. * @param onProgress callback called while file is loading (if the server supports this mode)
  1535. * @param offlineProvider defines the offline provider for caching
  1536. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  1537. * @param onError callback called when the file fails to load
  1538. * @returns a file request object
  1539. * @hidden
  1540. */
  1541. 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;
  1542. }
  1543. }
  1544. declare module "babylonjs/Maths/math.like" {
  1545. import { float, int, DeepImmutable } from "babylonjs/types";
  1546. /**
  1547. * @hidden
  1548. */
  1549. export interface IColor4Like {
  1550. r: float;
  1551. g: float;
  1552. b: float;
  1553. a: float;
  1554. }
  1555. /**
  1556. * @hidden
  1557. */
  1558. export interface IColor3Like {
  1559. r: float;
  1560. g: float;
  1561. b: float;
  1562. }
  1563. /**
  1564. * @hidden
  1565. */
  1566. export interface IVector4Like {
  1567. x: float;
  1568. y: float;
  1569. z: float;
  1570. w: float;
  1571. }
  1572. /**
  1573. * @hidden
  1574. */
  1575. export interface IVector3Like {
  1576. x: float;
  1577. y: float;
  1578. z: float;
  1579. }
  1580. /**
  1581. * @hidden
  1582. */
  1583. export interface IVector2Like {
  1584. x: float;
  1585. y: float;
  1586. }
  1587. /**
  1588. * @hidden
  1589. */
  1590. export interface IMatrixLike {
  1591. toArray(): DeepImmutable<Float32Array | Array<number>>;
  1592. updateFlag: int;
  1593. }
  1594. /**
  1595. * @hidden
  1596. */
  1597. export interface IViewportLike {
  1598. x: float;
  1599. y: float;
  1600. width: float;
  1601. height: float;
  1602. }
  1603. /**
  1604. * @hidden
  1605. */
  1606. export interface IPlaneLike {
  1607. normal: IVector3Like;
  1608. d: float;
  1609. normalize(): void;
  1610. }
  1611. }
  1612. declare module "babylonjs/Materials/iEffectFallbacks" {
  1613. import { Effect } from "babylonjs/Materials/effect";
  1614. /**
  1615. * Interface used to define common properties for effect fallbacks
  1616. */
  1617. export interface IEffectFallbacks {
  1618. /**
  1619. * Removes the defines that should be removed when falling back.
  1620. * @param currentDefines defines the current define statements for the shader.
  1621. * @param effect defines the current effect we try to compile
  1622. * @returns The resulting defines with defines of the current rank removed.
  1623. */
  1624. reduce(currentDefines: string, effect: Effect): string;
  1625. /**
  1626. * Removes the fallback from the bound mesh.
  1627. */
  1628. unBindMesh(): void;
  1629. /**
  1630. * Checks to see if more fallbacks are still availible.
  1631. */
  1632. hasMoreFallbacks: boolean;
  1633. }
  1634. }
  1635. declare module "babylonjs/Misc/andOrNotEvaluator" {
  1636. /**
  1637. * Class used to evalaute queries containing `and` and `or` operators
  1638. */
  1639. export class AndOrNotEvaluator {
  1640. /**
  1641. * Evaluate a query
  1642. * @param query defines the query to evaluate
  1643. * @param evaluateCallback defines the callback used to filter result
  1644. * @returns true if the query matches
  1645. */
  1646. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  1647. private static _HandleParenthesisContent;
  1648. private static _SimplifyNegation;
  1649. }
  1650. }
  1651. declare module "babylonjs/Misc/tags" {
  1652. /**
  1653. * Class used to store custom tags
  1654. */
  1655. export class Tags {
  1656. /**
  1657. * Adds support for tags on the given object
  1658. * @param obj defines the object to use
  1659. */
  1660. static EnableFor(obj: any): void;
  1661. /**
  1662. * Removes tags support
  1663. * @param obj defines the object to use
  1664. */
  1665. static DisableFor(obj: any): void;
  1666. /**
  1667. * Gets a boolean indicating if the given object has tags
  1668. * @param obj defines the object to use
  1669. * @returns a boolean
  1670. */
  1671. static HasTags(obj: any): boolean;
  1672. /**
  1673. * Gets the tags available on a given object
  1674. * @param obj defines the object to use
  1675. * @param asString defines if the tags must be returned as a string instead of an array of strings
  1676. * @returns the tags
  1677. */
  1678. static GetTags(obj: any, asString?: boolean): any;
  1679. /**
  1680. * Adds tags to an object
  1681. * @param obj defines the object to use
  1682. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  1683. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  1684. */
  1685. static AddTagsTo(obj: any, tagsString: string): void;
  1686. /**
  1687. * @hidden
  1688. */
  1689. static _AddTagTo(obj: any, tag: string): void;
  1690. /**
  1691. * Removes specific tags from a specific object
  1692. * @param obj defines the object to use
  1693. * @param tagsString defines the tags to remove
  1694. */
  1695. static RemoveTagsFrom(obj: any, tagsString: string): void;
  1696. /**
  1697. * @hidden
  1698. */
  1699. static _RemoveTagFrom(obj: any, tag: string): void;
  1700. /**
  1701. * Defines if tags hosted on an object match a given query
  1702. * @param obj defines the object to use
  1703. * @param tagsQuery defines the tag query
  1704. * @returns a boolean
  1705. */
  1706. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  1707. }
  1708. }
  1709. declare module "babylonjs/Maths/math.scalar" {
  1710. /**
  1711. * Scalar computation library
  1712. */
  1713. export class Scalar {
  1714. /**
  1715. * Two pi constants convenient for computation.
  1716. */
  1717. static TwoPi: number;
  1718. /**
  1719. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1720. * @param a number
  1721. * @param b number
  1722. * @param epsilon (default = 1.401298E-45)
  1723. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  1724. */
  1725. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  1726. /**
  1727. * Returns a string : the upper case translation of the number i to hexadecimal.
  1728. * @param i number
  1729. * @returns the upper case translation of the number i to hexadecimal.
  1730. */
  1731. static ToHex(i: number): string;
  1732. /**
  1733. * Returns -1 if value is negative and +1 is value is positive.
  1734. * @param value the value
  1735. * @returns the value itself if it's equal to zero.
  1736. */
  1737. static Sign(value: number): number;
  1738. /**
  1739. * Returns the value itself if it's between min and max.
  1740. * Returns min if the value is lower than min.
  1741. * Returns max if the value is greater than max.
  1742. * @param value the value to clmap
  1743. * @param min the min value to clamp to (default: 0)
  1744. * @param max the max value to clamp to (default: 1)
  1745. * @returns the clamped value
  1746. */
  1747. static Clamp(value: number, min?: number, max?: number): number;
  1748. /**
  1749. * the log2 of value.
  1750. * @param value the value to compute log2 of
  1751. * @returns the log2 of value.
  1752. */
  1753. static Log2(value: number): number;
  1754. /**
  1755. * Loops the value, so that it is never larger than length and never smaller than 0.
  1756. *
  1757. * This is similar to the modulo operator but it works with floating point numbers.
  1758. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  1759. * With t = 5 and length = 2.5, the result would be 0.0.
  1760. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  1761. * @param value the value
  1762. * @param length the length
  1763. * @returns the looped value
  1764. */
  1765. static Repeat(value: number, length: number): number;
  1766. /**
  1767. * Normalize the value between 0.0 and 1.0 using min and max values
  1768. * @param value value to normalize
  1769. * @param min max to normalize between
  1770. * @param max min to normalize between
  1771. * @returns the normalized value
  1772. */
  1773. static Normalize(value: number, min: number, max: number): number;
  1774. /**
  1775. * Denormalize the value from 0.0 and 1.0 using min and max values
  1776. * @param normalized value to denormalize
  1777. * @param min max to denormalize between
  1778. * @param max min to denormalize between
  1779. * @returns the denormalized value
  1780. */
  1781. static Denormalize(normalized: number, min: number, max: number): number;
  1782. /**
  1783. * Calculates the shortest difference between two given angles given in degrees.
  1784. * @param current current angle in degrees
  1785. * @param target target angle in degrees
  1786. * @returns the delta
  1787. */
  1788. static DeltaAngle(current: number, target: number): number;
  1789. /**
  1790. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  1791. * @param tx value
  1792. * @param length length
  1793. * @returns The returned value will move back and forth between 0 and length
  1794. */
  1795. static PingPong(tx: number, length: number): number;
  1796. /**
  1797. * Interpolates between min and max with smoothing at the limits.
  1798. *
  1799. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  1800. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  1801. * @param from from
  1802. * @param to to
  1803. * @param tx value
  1804. * @returns the smooth stepped value
  1805. */
  1806. static SmoothStep(from: number, to: number, tx: number): number;
  1807. /**
  1808. * Moves a value current towards target.
  1809. *
  1810. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  1811. * Negative values of maxDelta pushes the value away from target.
  1812. * @param current current value
  1813. * @param target target value
  1814. * @param maxDelta max distance to move
  1815. * @returns resulting value
  1816. */
  1817. static MoveTowards(current: number, target: number, maxDelta: number): number;
  1818. /**
  1819. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1820. *
  1821. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  1822. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  1823. * @param current current value
  1824. * @param target target value
  1825. * @param maxDelta max distance to move
  1826. * @returns resulting angle
  1827. */
  1828. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  1829. /**
  1830. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  1831. * @param start start value
  1832. * @param end target value
  1833. * @param amount amount to lerp between
  1834. * @returns the lerped value
  1835. */
  1836. static Lerp(start: number, end: number, amount: number): number;
  1837. /**
  1838. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  1839. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  1840. * @param start start value
  1841. * @param end target value
  1842. * @param amount amount to lerp between
  1843. * @returns the lerped value
  1844. */
  1845. static LerpAngle(start: number, end: number, amount: number): number;
  1846. /**
  1847. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  1848. * @param a start value
  1849. * @param b target value
  1850. * @param value value between a and b
  1851. * @returns the inverseLerp value
  1852. */
  1853. static InverseLerp(a: number, b: number, value: number): number;
  1854. /**
  1855. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  1856. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  1857. * @param value1 spline value
  1858. * @param tangent1 spline value
  1859. * @param value2 spline value
  1860. * @param tangent2 spline value
  1861. * @param amount input value
  1862. * @returns hermite result
  1863. */
  1864. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  1865. /**
  1866. * Returns a random float number between and min and max values
  1867. * @param min min value of random
  1868. * @param max max value of random
  1869. * @returns random value
  1870. */
  1871. static RandomRange(min: number, max: number): number;
  1872. /**
  1873. * This function returns percentage of a number in a given range.
  1874. *
  1875. * RangeToPercent(40,20,60) will return 0.5 (50%)
  1876. * RangeToPercent(34,0,100) will return 0.34 (34%)
  1877. * @param number to convert to percentage
  1878. * @param min min range
  1879. * @param max max range
  1880. * @returns the percentage
  1881. */
  1882. static RangeToPercent(number: number, min: number, max: number): number;
  1883. /**
  1884. * This function returns number that corresponds to the percentage in a given range.
  1885. *
  1886. * PercentToRange(0.34,0,100) will return 34.
  1887. * @param percent to convert to number
  1888. * @param min min range
  1889. * @param max max range
  1890. * @returns the number
  1891. */
  1892. static PercentToRange(percent: number, min: number, max: number): number;
  1893. /**
  1894. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  1895. * @param angle The angle to normalize in radian.
  1896. * @return The converted angle.
  1897. */
  1898. static NormalizeRadians(angle: number): number;
  1899. }
  1900. }
  1901. declare module "babylonjs/Maths/math.constants" {
  1902. /**
  1903. * Constant used to convert a value to gamma space
  1904. * @ignorenaming
  1905. */
  1906. export const ToGammaSpace: number;
  1907. /**
  1908. * Constant used to convert a value to linear space
  1909. * @ignorenaming
  1910. */
  1911. export const ToLinearSpace = 2.2;
  1912. /**
  1913. * Constant used to define the minimal number value in Babylon.js
  1914. * @ignorenaming
  1915. */
  1916. let Epsilon: number;
  1917. export { Epsilon };
  1918. }
  1919. declare module "babylonjs/Maths/math.viewport" {
  1920. /**
  1921. * Class used to represent a viewport on screen
  1922. */
  1923. export class Viewport {
  1924. /** viewport left coordinate */
  1925. x: number;
  1926. /** viewport top coordinate */
  1927. y: number;
  1928. /**viewport width */
  1929. width: number;
  1930. /** viewport height */
  1931. height: number;
  1932. /**
  1933. * Creates a Viewport object located at (x, y) and sized (width, height)
  1934. * @param x defines viewport left coordinate
  1935. * @param y defines viewport top coordinate
  1936. * @param width defines the viewport width
  1937. * @param height defines the viewport height
  1938. */
  1939. constructor(
  1940. /** viewport left coordinate */
  1941. x: number,
  1942. /** viewport top coordinate */
  1943. y: number,
  1944. /**viewport width */
  1945. width: number,
  1946. /** viewport height */
  1947. height: number);
  1948. /**
  1949. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  1950. * @param renderWidth defines the rendering width
  1951. * @param renderHeight defines the rendering height
  1952. * @returns a new Viewport
  1953. */
  1954. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  1955. /**
  1956. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  1957. * @param renderWidth defines the rendering width
  1958. * @param renderHeight defines the rendering height
  1959. * @param ref defines the target viewport
  1960. * @returns the current viewport
  1961. */
  1962. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  1963. /**
  1964. * Returns a new Viewport copied from the current one
  1965. * @returns a new Viewport
  1966. */
  1967. clone(): Viewport;
  1968. }
  1969. }
  1970. declare module "babylonjs/Misc/arrayTools" {
  1971. /**
  1972. * Class containing a set of static utilities functions for arrays.
  1973. */
  1974. export class ArrayTools {
  1975. /**
  1976. * Returns an array of the given size filled with element built from the given constructor and the paramters
  1977. * @param size the number of element to construct and put in the array
  1978. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  1979. * @returns a new array filled with new objects
  1980. */
  1981. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  1982. }
  1983. }
  1984. declare module "babylonjs/Maths/math.plane" {
  1985. import { DeepImmutable } from "babylonjs/types";
  1986. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  1987. /**
  1988. * Represents a plane by the equation ax + by + cz + d = 0
  1989. */
  1990. export class Plane {
  1991. private static _TmpMatrix;
  1992. /**
  1993. * Normal of the plane (a,b,c)
  1994. */
  1995. normal: Vector3;
  1996. /**
  1997. * d component of the plane
  1998. */
  1999. d: number;
  2000. /**
  2001. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  2002. * @param a a component of the plane
  2003. * @param b b component of the plane
  2004. * @param c c component of the plane
  2005. * @param d d component of the plane
  2006. */
  2007. constructor(a: number, b: number, c: number, d: number);
  2008. /**
  2009. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  2010. */
  2011. asArray(): number[];
  2012. /**
  2013. * @returns a new plane copied from the current Plane.
  2014. */
  2015. clone(): Plane;
  2016. /**
  2017. * @returns the string "Plane".
  2018. */
  2019. getClassName(): string;
  2020. /**
  2021. * @returns the Plane hash code.
  2022. */
  2023. getHashCode(): number;
  2024. /**
  2025. * Normalize the current Plane in place.
  2026. * @returns the updated Plane.
  2027. */
  2028. normalize(): Plane;
  2029. /**
  2030. * Applies a transformation the plane and returns the result
  2031. * @param transformation the transformation matrix to be applied to the plane
  2032. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  2033. */
  2034. transform(transformation: DeepImmutable<Matrix>): Plane;
  2035. /**
  2036. * Compute the dot product between the point and the plane normal
  2037. * @param point point to calculate the dot product with
  2038. * @returns the dot product (float) of the point coordinates and the plane normal.
  2039. */
  2040. dotCoordinate(point: DeepImmutable<Vector3>): number;
  2041. /**
  2042. * Updates the current Plane from the plane defined by the three given points.
  2043. * @param point1 one of the points used to contruct the plane
  2044. * @param point2 one of the points used to contruct the plane
  2045. * @param point3 one of the points used to contruct the plane
  2046. * @returns the updated Plane.
  2047. */
  2048. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2049. /**
  2050. * Checks if the plane is facing a given direction
  2051. * @param direction the direction to check if the plane is facing
  2052. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  2053. * @returns True is the vector "direction" is the same side than the plane normal.
  2054. */
  2055. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  2056. /**
  2057. * Calculates the distance to a point
  2058. * @param point point to calculate distance to
  2059. * @returns the signed distance (float) from the given point to the Plane.
  2060. */
  2061. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  2062. /**
  2063. * Creates a plane from an array
  2064. * @param array the array to create a plane from
  2065. * @returns a new Plane from the given array.
  2066. */
  2067. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  2068. /**
  2069. * Creates a plane from three points
  2070. * @param point1 point used to create the plane
  2071. * @param point2 point used to create the plane
  2072. * @param point3 point used to create the plane
  2073. * @returns a new Plane defined by the three given points.
  2074. */
  2075. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  2076. /**
  2077. * Creates a plane from an origin point and a normal
  2078. * @param origin origin of the plane to be constructed
  2079. * @param normal normal of the plane to be constructed
  2080. * @returns a new Plane the normal vector to this plane at the given origin point.
  2081. * Note : the vector "normal" is updated because normalized.
  2082. */
  2083. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  2084. /**
  2085. * Calculates the distance from a plane and a point
  2086. * @param origin origin of the plane to be constructed
  2087. * @param normal normal of the plane to be constructed
  2088. * @param point point to calculate distance to
  2089. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  2090. */
  2091. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  2092. }
  2093. }
  2094. declare module "babylonjs/Engines/performanceConfigurator" {
  2095. /** @hidden */
  2096. export class PerformanceConfigurator {
  2097. /** @hidden */
  2098. static MatrixUse64Bits: boolean;
  2099. /** @hidden */
  2100. static MatrixTrackPrecisionChange: boolean;
  2101. /** @hidden */
  2102. static MatrixCurrentType: any;
  2103. /** @hidden */
  2104. static MatrixTrackedMatrices: Array<any> | null;
  2105. /** @hidden */
  2106. static SetMatrixPrecision(use64bits: boolean): void;
  2107. }
  2108. }
  2109. declare module "babylonjs/Maths/math.vector" {
  2110. import { Viewport } from "babylonjs/Maths/math.viewport";
  2111. import { DeepImmutable, Nullable, FloatArray, float } from "babylonjs/types";
  2112. import { IPlaneLike } from "babylonjs/Maths/math.like";
  2113. import { Plane } from "babylonjs/Maths/math.plane";
  2114. /**
  2115. * Class representing a vector containing 2 coordinates
  2116. */
  2117. export class Vector2 {
  2118. /** defines the first coordinate */
  2119. x: number;
  2120. /** defines the second coordinate */
  2121. y: number;
  2122. /**
  2123. * Creates a new Vector2 from the given x and y coordinates
  2124. * @param x defines the first coordinate
  2125. * @param y defines the second coordinate
  2126. */
  2127. constructor(
  2128. /** defines the first coordinate */
  2129. x?: number,
  2130. /** defines the second coordinate */
  2131. y?: number);
  2132. /**
  2133. * Gets a string with the Vector2 coordinates
  2134. * @returns a string with the Vector2 coordinates
  2135. */
  2136. toString(): string;
  2137. /**
  2138. * Gets class name
  2139. * @returns the string "Vector2"
  2140. */
  2141. getClassName(): string;
  2142. /**
  2143. * Gets current vector hash code
  2144. * @returns the Vector2 hash code as a number
  2145. */
  2146. getHashCode(): number;
  2147. /**
  2148. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  2149. * @param array defines the source array
  2150. * @param index defines the offset in source array
  2151. * @returns the current Vector2
  2152. */
  2153. toArray(array: FloatArray, index?: number): Vector2;
  2154. /**
  2155. * Update the current vector from an array
  2156. * @param array defines the destination array
  2157. * @param index defines the offset in the destination array
  2158. * @returns the current Vector3
  2159. */
  2160. fromArray(array: FloatArray, index?: number): Vector2;
  2161. /**
  2162. * Copy the current vector to an array
  2163. * @returns a new array with 2 elements: the Vector2 coordinates.
  2164. */
  2165. asArray(): number[];
  2166. /**
  2167. * Sets the Vector2 coordinates with the given Vector2 coordinates
  2168. * @param source defines the source Vector2
  2169. * @returns the current updated Vector2
  2170. */
  2171. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  2172. /**
  2173. * Sets the Vector2 coordinates with the given floats
  2174. * @param x defines the first coordinate
  2175. * @param y defines the second coordinate
  2176. * @returns the current updated Vector2
  2177. */
  2178. copyFromFloats(x: number, y: number): Vector2;
  2179. /**
  2180. * Sets the Vector2 coordinates with the given floats
  2181. * @param x defines the first coordinate
  2182. * @param y defines the second coordinate
  2183. * @returns the current updated Vector2
  2184. */
  2185. set(x: number, y: number): Vector2;
  2186. /**
  2187. * Add another vector with the current one
  2188. * @param otherVector defines the other vector
  2189. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  2190. */
  2191. add(otherVector: DeepImmutable<Vector2>): Vector2;
  2192. /**
  2193. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  2194. * @param otherVector defines the other vector
  2195. * @param result defines the target vector
  2196. * @returns the unmodified current Vector2
  2197. */
  2198. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2199. /**
  2200. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  2201. * @param otherVector defines the other vector
  2202. * @returns the current updated Vector2
  2203. */
  2204. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2205. /**
  2206. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  2207. * @param otherVector defines the other vector
  2208. * @returns a new Vector2
  2209. */
  2210. addVector3(otherVector: Vector3): Vector2;
  2211. /**
  2212. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  2213. * @param otherVector defines the other vector
  2214. * @returns a new Vector2
  2215. */
  2216. subtract(otherVector: Vector2): Vector2;
  2217. /**
  2218. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  2219. * @param otherVector defines the other vector
  2220. * @param result defines the target vector
  2221. * @returns the unmodified current Vector2
  2222. */
  2223. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2224. /**
  2225. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  2226. * @param otherVector defines the other vector
  2227. * @returns the current updated Vector2
  2228. */
  2229. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2230. /**
  2231. * Multiplies in place the current Vector2 coordinates by the given ones
  2232. * @param otherVector defines the other vector
  2233. * @returns the current updated Vector2
  2234. */
  2235. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2236. /**
  2237. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  2238. * @param otherVector defines the other vector
  2239. * @returns a new Vector2
  2240. */
  2241. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  2242. /**
  2243. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  2244. * @param otherVector defines the other vector
  2245. * @param result defines the target vector
  2246. * @returns the unmodified current Vector2
  2247. */
  2248. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2249. /**
  2250. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  2251. * @param x defines the first coordinate
  2252. * @param y defines the second coordinate
  2253. * @returns a new Vector2
  2254. */
  2255. multiplyByFloats(x: number, y: number): Vector2;
  2256. /**
  2257. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  2258. * @param otherVector defines the other vector
  2259. * @returns a new Vector2
  2260. */
  2261. divide(otherVector: Vector2): Vector2;
  2262. /**
  2263. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  2264. * @param otherVector defines the other vector
  2265. * @param result defines the target vector
  2266. * @returns the unmodified current Vector2
  2267. */
  2268. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  2269. /**
  2270. * Divides the current Vector2 coordinates by the given ones
  2271. * @param otherVector defines the other vector
  2272. * @returns the current updated Vector2
  2273. */
  2274. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  2275. /**
  2276. * Gets a new Vector2 with current Vector2 negated coordinates
  2277. * @returns a new Vector2
  2278. */
  2279. negate(): Vector2;
  2280. /**
  2281. * Negate this vector in place
  2282. * @returns this
  2283. */
  2284. negateInPlace(): Vector2;
  2285. /**
  2286. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  2287. * @param result defines the Vector3 object where to store the result
  2288. * @returns the current Vector2
  2289. */
  2290. negateToRef(result: Vector2): Vector2;
  2291. /**
  2292. * Multiply the Vector2 coordinates by scale
  2293. * @param scale defines the scaling factor
  2294. * @returns the current updated Vector2
  2295. */
  2296. scaleInPlace(scale: number): Vector2;
  2297. /**
  2298. * Returns a new Vector2 scaled by "scale" from the current Vector2
  2299. * @param scale defines the scaling factor
  2300. * @returns a new Vector2
  2301. */
  2302. scale(scale: number): Vector2;
  2303. /**
  2304. * Scale the current Vector2 values by a factor to a given Vector2
  2305. * @param scale defines the scale factor
  2306. * @param result defines the Vector2 object where to store the result
  2307. * @returns the unmodified current Vector2
  2308. */
  2309. scaleToRef(scale: number, result: Vector2): Vector2;
  2310. /**
  2311. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  2312. * @param scale defines the scale factor
  2313. * @param result defines the Vector2 object where to store the result
  2314. * @returns the unmodified current Vector2
  2315. */
  2316. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  2317. /**
  2318. * Gets a boolean if two vectors are equals
  2319. * @param otherVector defines the other vector
  2320. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  2321. */
  2322. equals(otherVector: DeepImmutable<Vector2>): boolean;
  2323. /**
  2324. * Gets a boolean if two vectors are equals (using an epsilon value)
  2325. * @param otherVector defines the other vector
  2326. * @param epsilon defines the minimal distance to consider equality
  2327. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  2328. */
  2329. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  2330. /**
  2331. * Gets a new Vector2 from current Vector2 floored values
  2332. * @returns a new Vector2
  2333. */
  2334. floor(): Vector2;
  2335. /**
  2336. * Gets a new Vector2 from current Vector2 floored values
  2337. * @returns a new Vector2
  2338. */
  2339. fract(): Vector2;
  2340. /**
  2341. * Gets the length of the vector
  2342. * @returns the vector length (float)
  2343. */
  2344. length(): number;
  2345. /**
  2346. * Gets the vector squared length
  2347. * @returns the vector squared length (float)
  2348. */
  2349. lengthSquared(): number;
  2350. /**
  2351. * Normalize the vector
  2352. * @returns the current updated Vector2
  2353. */
  2354. normalize(): Vector2;
  2355. /**
  2356. * Gets a new Vector2 copied from the Vector2
  2357. * @returns a new Vector2
  2358. */
  2359. clone(): Vector2;
  2360. /**
  2361. * Gets a new Vector2(0, 0)
  2362. * @returns a new Vector2
  2363. */
  2364. static Zero(): Vector2;
  2365. /**
  2366. * Gets a new Vector2(1, 1)
  2367. * @returns a new Vector2
  2368. */
  2369. static One(): Vector2;
  2370. /**
  2371. * Gets a new Vector2 set from the given index element of the given array
  2372. * @param array defines the data source
  2373. * @param offset defines the offset in the data source
  2374. * @returns a new Vector2
  2375. */
  2376. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  2377. /**
  2378. * Sets "result" from the given index element of the given array
  2379. * @param array defines the data source
  2380. * @param offset defines the offset in the data source
  2381. * @param result defines the target vector
  2382. */
  2383. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  2384. /**
  2385. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  2386. * @param value1 defines 1st point of control
  2387. * @param value2 defines 2nd point of control
  2388. * @param value3 defines 3rd point of control
  2389. * @param value4 defines 4th point of control
  2390. * @param amount defines the interpolation factor
  2391. * @returns a new Vector2
  2392. */
  2393. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  2394. /**
  2395. * 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".
  2396. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  2397. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  2398. * @param value defines the value to clamp
  2399. * @param min defines the lower limit
  2400. * @param max defines the upper limit
  2401. * @returns a new Vector2
  2402. */
  2403. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  2404. /**
  2405. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  2406. * @param value1 defines the 1st control point
  2407. * @param tangent1 defines the outgoing tangent
  2408. * @param value2 defines the 2nd control point
  2409. * @param tangent2 defines the incoming tangent
  2410. * @param amount defines the interpolation factor
  2411. * @returns a new Vector2
  2412. */
  2413. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  2414. /**
  2415. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  2416. * @param start defines the start vector
  2417. * @param end defines the end vector
  2418. * @param amount defines the interpolation factor
  2419. * @returns a new Vector2
  2420. */
  2421. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  2422. /**
  2423. * Gets the dot product of the vector "left" and the vector "right"
  2424. * @param left defines first vector
  2425. * @param right defines second vector
  2426. * @returns the dot product (float)
  2427. */
  2428. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  2429. /**
  2430. * Returns a new Vector2 equal to the normalized given vector
  2431. * @param vector defines the vector to normalize
  2432. * @returns a new Vector2
  2433. */
  2434. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  2435. /**
  2436. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  2437. * @param left defines 1st vector
  2438. * @param right defines 2nd vector
  2439. * @returns a new Vector2
  2440. */
  2441. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2442. /**
  2443. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  2444. * @param left defines 1st vector
  2445. * @param right defines 2nd vector
  2446. * @returns a new Vector2
  2447. */
  2448. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  2449. /**
  2450. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  2451. * @param vector defines the vector to transform
  2452. * @param transformation defines the matrix to apply
  2453. * @returns a new Vector2
  2454. */
  2455. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  2456. /**
  2457. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  2458. * @param vector defines the vector to transform
  2459. * @param transformation defines the matrix to apply
  2460. * @param result defines the target vector
  2461. */
  2462. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  2463. /**
  2464. * Determines if a given vector is included in a triangle
  2465. * @param p defines the vector to test
  2466. * @param p0 defines 1st triangle point
  2467. * @param p1 defines 2nd triangle point
  2468. * @param p2 defines 3rd triangle point
  2469. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  2470. */
  2471. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  2472. /**
  2473. * Gets the distance between the vectors "value1" and "value2"
  2474. * @param value1 defines first vector
  2475. * @param value2 defines second vector
  2476. * @returns the distance between vectors
  2477. */
  2478. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2479. /**
  2480. * Returns the squared distance between the vectors "value1" and "value2"
  2481. * @param value1 defines first vector
  2482. * @param value2 defines second vector
  2483. * @returns the squared distance between vectors
  2484. */
  2485. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  2486. /**
  2487. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  2488. * @param value1 defines first vector
  2489. * @param value2 defines second vector
  2490. * @returns a new Vector2
  2491. */
  2492. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  2493. /**
  2494. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  2495. * @param p defines the middle point
  2496. * @param segA defines one point of the segment
  2497. * @param segB defines the other point of the segment
  2498. * @returns the shortest distance
  2499. */
  2500. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  2501. }
  2502. /**
  2503. * Class used to store (x,y,z) vector representation
  2504. * A Vector3 is the main object used in 3D geometry
  2505. * It can represent etiher the coordinates of a point the space, either a direction
  2506. * Reminder: js uses a left handed forward facing system
  2507. */
  2508. export class Vector3 {
  2509. private static _UpReadOnly;
  2510. private static _ZeroReadOnly;
  2511. /** @hidden */
  2512. _x: number;
  2513. /** @hidden */
  2514. _y: number;
  2515. /** @hidden */
  2516. _z: number;
  2517. /** @hidden */
  2518. _isDirty: boolean;
  2519. /** Gets or sets the x coordinate */
  2520. get x(): number;
  2521. set x(value: number);
  2522. /** Gets or sets the y coordinate */
  2523. get y(): number;
  2524. set y(value: number);
  2525. /** Gets or sets the z coordinate */
  2526. get z(): number;
  2527. set z(value: number);
  2528. /**
  2529. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  2530. * @param x defines the first coordinates (on X axis)
  2531. * @param y defines the second coordinates (on Y axis)
  2532. * @param z defines the third coordinates (on Z axis)
  2533. */
  2534. constructor(x?: number, y?: number, z?: number);
  2535. /**
  2536. * Creates a string representation of the Vector3
  2537. * @returns a string with the Vector3 coordinates.
  2538. */
  2539. toString(): string;
  2540. /**
  2541. * Gets the class name
  2542. * @returns the string "Vector3"
  2543. */
  2544. getClassName(): string;
  2545. /**
  2546. * Creates the Vector3 hash code
  2547. * @returns a number which tends to be unique between Vector3 instances
  2548. */
  2549. getHashCode(): number;
  2550. /**
  2551. * Creates an array containing three elements : the coordinates of the Vector3
  2552. * @returns a new array of numbers
  2553. */
  2554. asArray(): number[];
  2555. /**
  2556. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  2557. * @param array defines the destination array
  2558. * @param index defines the offset in the destination array
  2559. * @returns the current Vector3
  2560. */
  2561. toArray(array: FloatArray, index?: number): Vector3;
  2562. /**
  2563. * Update the current vector from an array
  2564. * @param array defines the destination array
  2565. * @param index defines the offset in the destination array
  2566. * @returns the current Vector3
  2567. */
  2568. fromArray(array: FloatArray, index?: number): Vector3;
  2569. /**
  2570. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  2571. * @returns a new Quaternion object, computed from the Vector3 coordinates
  2572. */
  2573. toQuaternion(): Quaternion;
  2574. /**
  2575. * Adds the given vector to the current Vector3
  2576. * @param otherVector defines the second operand
  2577. * @returns the current updated Vector3
  2578. */
  2579. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2580. /**
  2581. * Adds the given coordinates to the current Vector3
  2582. * @param x defines the x coordinate of the operand
  2583. * @param y defines the y coordinate of the operand
  2584. * @param z defines the z coordinate of the operand
  2585. * @returns the current updated Vector3
  2586. */
  2587. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2588. /**
  2589. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  2590. * @param otherVector defines the second operand
  2591. * @returns the resulting Vector3
  2592. */
  2593. add(otherVector: DeepImmutable<Vector3>): Vector3;
  2594. /**
  2595. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  2596. * @param otherVector defines the second operand
  2597. * @param result defines the Vector3 object where to store the result
  2598. * @returns the current Vector3
  2599. */
  2600. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2601. /**
  2602. * Subtract the given vector from the current Vector3
  2603. * @param otherVector defines the second operand
  2604. * @returns the current updated Vector3
  2605. */
  2606. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2607. /**
  2608. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  2609. * @param otherVector defines the second operand
  2610. * @returns the resulting Vector3
  2611. */
  2612. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  2613. /**
  2614. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  2615. * @param otherVector defines the second operand
  2616. * @param result defines the Vector3 object where to store the result
  2617. * @returns the current Vector3
  2618. */
  2619. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2620. /**
  2621. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  2622. * @param x defines the x coordinate of the operand
  2623. * @param y defines the y coordinate of the operand
  2624. * @param z defines the z coordinate of the operand
  2625. * @returns the resulting Vector3
  2626. */
  2627. subtractFromFloats(x: number, y: number, z: number): Vector3;
  2628. /**
  2629. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  2630. * @param x defines the x coordinate of the operand
  2631. * @param y defines the y coordinate of the operand
  2632. * @param z defines the z coordinate of the operand
  2633. * @param result defines the Vector3 object where to store the result
  2634. * @returns the current Vector3
  2635. */
  2636. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  2637. /**
  2638. * Gets a new Vector3 set with the current Vector3 negated coordinates
  2639. * @returns a new Vector3
  2640. */
  2641. negate(): Vector3;
  2642. /**
  2643. * Negate this vector in place
  2644. * @returns this
  2645. */
  2646. negateInPlace(): Vector3;
  2647. /**
  2648. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  2649. * @param result defines the Vector3 object where to store the result
  2650. * @returns the current Vector3
  2651. */
  2652. negateToRef(result: Vector3): Vector3;
  2653. /**
  2654. * Multiplies the Vector3 coordinates by the float "scale"
  2655. * @param scale defines the multiplier factor
  2656. * @returns the current updated Vector3
  2657. */
  2658. scaleInPlace(scale: number): Vector3;
  2659. /**
  2660. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  2661. * @param scale defines the multiplier factor
  2662. * @returns a new Vector3
  2663. */
  2664. scale(scale: number): Vector3;
  2665. /**
  2666. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  2667. * @param scale defines the multiplier factor
  2668. * @param result defines the Vector3 object where to store the result
  2669. * @returns the current Vector3
  2670. */
  2671. scaleToRef(scale: number, result: Vector3): Vector3;
  2672. /**
  2673. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  2674. * @param scale defines the scale factor
  2675. * @param result defines the Vector3 object where to store the result
  2676. * @returns the unmodified current Vector3
  2677. */
  2678. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  2679. /**
  2680. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2681. * @param origin defines the origin of the projection ray
  2682. * @param plane defines the plane to project to
  2683. * @returns the projected vector3
  2684. */
  2685. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  2686. /**
  2687. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  2688. * @param origin defines the origin of the projection ray
  2689. * @param plane defines the plane to project to
  2690. * @param result defines the Vector3 where to store the result
  2691. */
  2692. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  2693. /**
  2694. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  2695. * @param otherVector defines the second operand
  2696. * @returns true if both vectors are equals
  2697. */
  2698. equals(otherVector: DeepImmutable<Vector3>): boolean;
  2699. /**
  2700. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  2701. * @param otherVector defines the second operand
  2702. * @param epsilon defines the minimal distance to define values as equals
  2703. * @returns true if both vectors are distant less than epsilon
  2704. */
  2705. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  2706. /**
  2707. * Returns true if the current Vector3 coordinates equals the given floats
  2708. * @param x defines the x coordinate of the operand
  2709. * @param y defines the y coordinate of the operand
  2710. * @param z defines the z coordinate of the operand
  2711. * @returns true if both vectors are equals
  2712. */
  2713. equalsToFloats(x: number, y: number, z: number): boolean;
  2714. /**
  2715. * Multiplies the current Vector3 coordinates by the given ones
  2716. * @param otherVector defines the second operand
  2717. * @returns the current updated Vector3
  2718. */
  2719. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  2720. /**
  2721. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  2722. * @param otherVector defines the second operand
  2723. * @returns the new Vector3
  2724. */
  2725. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  2726. /**
  2727. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  2728. * @param otherVector defines the second operand
  2729. * @param result defines the Vector3 object where to store the result
  2730. * @returns the current Vector3
  2731. */
  2732. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2733. /**
  2734. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  2735. * @param x defines the x coordinate of the operand
  2736. * @param y defines the y coordinate of the operand
  2737. * @param z defines the z coordinate of the operand
  2738. * @returns the new Vector3
  2739. */
  2740. multiplyByFloats(x: number, y: number, z: number): Vector3;
  2741. /**
  2742. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  2743. * @param otherVector defines the second operand
  2744. * @returns the new Vector3
  2745. */
  2746. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  2747. /**
  2748. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  2749. * @param otherVector defines the second operand
  2750. * @param result defines the Vector3 object where to store the result
  2751. * @returns the current Vector3
  2752. */
  2753. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  2754. /**
  2755. * Divides the current Vector3 coordinates by the given ones.
  2756. * @param otherVector defines the second operand
  2757. * @returns the current updated Vector3
  2758. */
  2759. divideInPlace(otherVector: Vector3): Vector3;
  2760. /**
  2761. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  2762. * @param other defines the second operand
  2763. * @returns the current updated Vector3
  2764. */
  2765. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2766. /**
  2767. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  2768. * @param other defines the second operand
  2769. * @returns the current updated Vector3
  2770. */
  2771. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  2772. /**
  2773. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  2774. * @param x defines the x coordinate of the operand
  2775. * @param y defines the y coordinate of the operand
  2776. * @param z defines the z coordinate of the operand
  2777. * @returns the current updated Vector3
  2778. */
  2779. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2780. /**
  2781. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  2782. * @param x defines the x coordinate of the operand
  2783. * @param y defines the y coordinate of the operand
  2784. * @param z defines the z coordinate of the operand
  2785. * @returns the current updated Vector3
  2786. */
  2787. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  2788. /**
  2789. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  2790. * Check if is non uniform within a certain amount of decimal places to account for this
  2791. * @param epsilon the amount the values can differ
  2792. * @returns if the the vector is non uniform to a certain number of decimal places
  2793. */
  2794. isNonUniformWithinEpsilon(epsilon: number): boolean;
  2795. /**
  2796. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  2797. */
  2798. get isNonUniform(): boolean;
  2799. /**
  2800. * Gets a new Vector3 from current Vector3 floored values
  2801. * @returns a new Vector3
  2802. */
  2803. floor(): Vector3;
  2804. /**
  2805. * Gets a new Vector3 from current Vector3 floored values
  2806. * @returns a new Vector3
  2807. */
  2808. fract(): Vector3;
  2809. /**
  2810. * Gets the length of the Vector3
  2811. * @returns the length of the Vector3
  2812. */
  2813. length(): number;
  2814. /**
  2815. * Gets the squared length of the Vector3
  2816. * @returns squared length of the Vector3
  2817. */
  2818. lengthSquared(): number;
  2819. /**
  2820. * Normalize the current Vector3.
  2821. * Please note that this is an in place operation.
  2822. * @returns the current updated Vector3
  2823. */
  2824. normalize(): Vector3;
  2825. /**
  2826. * Reorders the x y z properties of the vector in place
  2827. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  2828. * @returns the current updated vector
  2829. */
  2830. reorderInPlace(order: string): this;
  2831. /**
  2832. * Rotates the vector around 0,0,0 by a quaternion
  2833. * @param quaternion the rotation quaternion
  2834. * @param result vector to store the result
  2835. * @returns the resulting vector
  2836. */
  2837. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  2838. /**
  2839. * Rotates a vector around a given point
  2840. * @param quaternion the rotation quaternion
  2841. * @param point the point to rotate around
  2842. * @param result vector to store the result
  2843. * @returns the resulting vector
  2844. */
  2845. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  2846. /**
  2847. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  2848. * The cross product is then orthogonal to both current and "other"
  2849. * @param other defines the right operand
  2850. * @returns the cross product
  2851. */
  2852. cross(other: Vector3): Vector3;
  2853. /**
  2854. * Normalize the current Vector3 with the given input length.
  2855. * Please note that this is an in place operation.
  2856. * @param len the length of the vector
  2857. * @returns the current updated Vector3
  2858. */
  2859. normalizeFromLength(len: number): Vector3;
  2860. /**
  2861. * Normalize the current Vector3 to a new vector
  2862. * @returns the new Vector3
  2863. */
  2864. normalizeToNew(): Vector3;
  2865. /**
  2866. * Normalize the current Vector3 to the reference
  2867. * @param reference define the Vector3 to update
  2868. * @returns the updated Vector3
  2869. */
  2870. normalizeToRef(reference: Vector3): Vector3;
  2871. /**
  2872. * Creates a new Vector3 copied from the current Vector3
  2873. * @returns the new Vector3
  2874. */
  2875. clone(): Vector3;
  2876. /**
  2877. * Copies the given vector coordinates to the current Vector3 ones
  2878. * @param source defines the source Vector3
  2879. * @returns the current updated Vector3
  2880. */
  2881. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  2882. /**
  2883. * Copies the given floats to the current Vector3 coordinates
  2884. * @param x defines the x coordinate of the operand
  2885. * @param y defines the y coordinate of the operand
  2886. * @param z defines the z coordinate of the operand
  2887. * @returns the current updated Vector3
  2888. */
  2889. copyFromFloats(x: number, y: number, z: number): Vector3;
  2890. /**
  2891. * Copies the given floats to the current Vector3 coordinates
  2892. * @param x defines the x coordinate of the operand
  2893. * @param y defines the y coordinate of the operand
  2894. * @param z defines the z coordinate of the operand
  2895. * @returns the current updated Vector3
  2896. */
  2897. set(x: number, y: number, z: number): Vector3;
  2898. /**
  2899. * Copies the given float to the current Vector3 coordinates
  2900. * @param v defines the x, y and z coordinates of the operand
  2901. * @returns the current updated Vector3
  2902. */
  2903. setAll(v: number): Vector3;
  2904. /**
  2905. * Get the clip factor between two vectors
  2906. * @param vector0 defines the first operand
  2907. * @param vector1 defines the second operand
  2908. * @param axis defines the axis to use
  2909. * @param size defines the size along the axis
  2910. * @returns the clip factor
  2911. */
  2912. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  2913. /**
  2914. * Get angle between two vectors
  2915. * @param vector0 angle between vector0 and vector1
  2916. * @param vector1 angle between vector0 and vector1
  2917. * @param normal direction of the normal
  2918. * @return the angle between vector0 and vector1
  2919. */
  2920. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  2921. /**
  2922. * Returns a new Vector3 set from the index "offset" of the given array
  2923. * @param array defines the source array
  2924. * @param offset defines the offset in the source array
  2925. * @returns the new Vector3
  2926. */
  2927. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  2928. /**
  2929. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  2930. * @param array defines the source array
  2931. * @param offset defines the offset in the source array
  2932. * @returns the new Vector3
  2933. * @deprecated Please use FromArray instead.
  2934. */
  2935. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  2936. /**
  2937. * Sets the given vector "result" with the element values from the index "offset" of the given array
  2938. * @param array defines the source array
  2939. * @param offset defines the offset in the source array
  2940. * @param result defines the Vector3 where to store the result
  2941. */
  2942. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  2943. /**
  2944. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  2945. * @param array defines the source array
  2946. * @param offset defines the offset in the source array
  2947. * @param result defines the Vector3 where to store the result
  2948. * @deprecated Please use FromArrayToRef instead.
  2949. */
  2950. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  2951. /**
  2952. * Sets the given vector "result" with the given floats.
  2953. * @param x defines the x coordinate of the source
  2954. * @param y defines the y coordinate of the source
  2955. * @param z defines the z coordinate of the source
  2956. * @param result defines the Vector3 where to store the result
  2957. */
  2958. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  2959. /**
  2960. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  2961. * @returns a new empty Vector3
  2962. */
  2963. static Zero(): Vector3;
  2964. /**
  2965. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  2966. * @returns a new unit Vector3
  2967. */
  2968. static One(): Vector3;
  2969. /**
  2970. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  2971. * @returns a new up Vector3
  2972. */
  2973. static Up(): Vector3;
  2974. /**
  2975. * Gets a up Vector3 that must not be updated
  2976. */
  2977. static get UpReadOnly(): DeepImmutable<Vector3>;
  2978. /**
  2979. * Gets a zero Vector3 that must not be updated
  2980. */
  2981. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  2982. /**
  2983. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  2984. * @returns a new down Vector3
  2985. */
  2986. static Down(): Vector3;
  2987. /**
  2988. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  2989. * @param rightHandedSystem is the scene right-handed (negative z)
  2990. * @returns a new forward Vector3
  2991. */
  2992. static Forward(rightHandedSystem?: boolean): Vector3;
  2993. /**
  2994. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  2995. * @param rightHandedSystem is the scene right-handed (negative-z)
  2996. * @returns a new forward Vector3
  2997. */
  2998. static Backward(rightHandedSystem?: boolean): Vector3;
  2999. /**
  3000. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  3001. * @returns a new right Vector3
  3002. */
  3003. static Right(): Vector3;
  3004. /**
  3005. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  3006. * @returns a new left Vector3
  3007. */
  3008. static Left(): Vector3;
  3009. /**
  3010. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  3011. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3012. * @param vector defines the Vector3 to transform
  3013. * @param transformation defines the transformation matrix
  3014. * @returns the transformed Vector3
  3015. */
  3016. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3017. /**
  3018. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  3019. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  3020. * @param vector defines the Vector3 to transform
  3021. * @param transformation defines the transformation matrix
  3022. * @param result defines the Vector3 where to store the result
  3023. */
  3024. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3025. /**
  3026. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  3027. * This method computes tranformed coordinates only, not transformed direction vectors
  3028. * @param x define the x coordinate of the source vector
  3029. * @param y define the y coordinate of the source vector
  3030. * @param z define the z coordinate of the source vector
  3031. * @param transformation defines the transformation matrix
  3032. * @param result defines the Vector3 where to store the result
  3033. */
  3034. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3035. /**
  3036. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  3037. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3038. * @param vector defines the Vector3 to transform
  3039. * @param transformation defines the transformation matrix
  3040. * @returns the new Vector3
  3041. */
  3042. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  3043. /**
  3044. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  3045. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3046. * @param vector defines the Vector3 to transform
  3047. * @param transformation defines the transformation matrix
  3048. * @param result defines the Vector3 where to store the result
  3049. */
  3050. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3051. /**
  3052. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  3053. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  3054. * @param x define the x coordinate of the source vector
  3055. * @param y define the y coordinate of the source vector
  3056. * @param z define the z coordinate of the source vector
  3057. * @param transformation defines the transformation matrix
  3058. * @param result defines the Vector3 where to store the result
  3059. */
  3060. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  3061. /**
  3062. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  3063. * @param value1 defines the first control point
  3064. * @param value2 defines the second control point
  3065. * @param value3 defines the third control point
  3066. * @param value4 defines the fourth control point
  3067. * @param amount defines the amount on the spline to use
  3068. * @returns the new Vector3
  3069. */
  3070. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  3071. /**
  3072. * 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"
  3073. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3074. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3075. * @param value defines the current value
  3076. * @param min defines the lower range value
  3077. * @param max defines the upper range value
  3078. * @returns the new Vector3
  3079. */
  3080. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  3081. /**
  3082. * 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"
  3083. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  3084. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  3085. * @param value defines the current value
  3086. * @param min defines the lower range value
  3087. * @param max defines the upper range value
  3088. * @param result defines the Vector3 where to store the result
  3089. */
  3090. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  3091. /**
  3092. * Checks if a given vector is inside a specific range
  3093. * @param v defines the vector to test
  3094. * @param min defines the minimum range
  3095. * @param max defines the maximum range
  3096. */
  3097. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  3098. /**
  3099. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  3100. * @param value1 defines the first control point
  3101. * @param tangent1 defines the first tangent vector
  3102. * @param value2 defines the second control point
  3103. * @param tangent2 defines the second tangent vector
  3104. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  3105. * @returns the new Vector3
  3106. */
  3107. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  3108. /**
  3109. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  3110. * @param start defines the start value
  3111. * @param end defines the end value
  3112. * @param amount max defines amount between both (between 0 and 1)
  3113. * @returns the new Vector3
  3114. */
  3115. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  3116. /**
  3117. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  3118. * @param start defines the start value
  3119. * @param end defines the end value
  3120. * @param amount max defines amount between both (between 0 and 1)
  3121. * @param result defines the Vector3 where to store the result
  3122. */
  3123. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  3124. /**
  3125. * Returns the dot product (float) between the vectors "left" and "right"
  3126. * @param left defines the left operand
  3127. * @param right defines the right operand
  3128. * @returns the dot product
  3129. */
  3130. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  3131. /**
  3132. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  3133. * The cross product is then orthogonal to both "left" and "right"
  3134. * @param left defines the left operand
  3135. * @param right defines the right operand
  3136. * @returns the cross product
  3137. */
  3138. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3139. /**
  3140. * Sets the given vector "result" with the cross product of "left" and "right"
  3141. * The cross product is then orthogonal to both "left" and "right"
  3142. * @param left defines the left operand
  3143. * @param right defines the right operand
  3144. * @param result defines the Vector3 where to store the result
  3145. */
  3146. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  3147. /**
  3148. * Returns a new Vector3 as the normalization of the given vector
  3149. * @param vector defines the Vector3 to normalize
  3150. * @returns the new Vector3
  3151. */
  3152. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  3153. /**
  3154. * Sets the given vector "result" with the normalization of the given first vector
  3155. * @param vector defines the Vector3 to normalize
  3156. * @param result defines the Vector3 where to store the result
  3157. */
  3158. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  3159. /**
  3160. * Project a Vector3 onto screen space
  3161. * @param vector defines the Vector3 to project
  3162. * @param world defines the world matrix to use
  3163. * @param transform defines the transform (view x projection) matrix to use
  3164. * @param viewport defines the screen viewport to use
  3165. * @returns the new Vector3
  3166. */
  3167. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  3168. /** @hidden */
  3169. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  3170. /**
  3171. * Unproject from screen space to object space
  3172. * @param source defines the screen space Vector3 to use
  3173. * @param viewportWidth defines the current width of the viewport
  3174. * @param viewportHeight defines the current height of the viewport
  3175. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3176. * @param transform defines the transform (view x projection) matrix to use
  3177. * @returns the new Vector3
  3178. */
  3179. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  3180. /**
  3181. * Unproject from screen space to object space
  3182. * @param source defines the screen space Vector3 to use
  3183. * @param viewportWidth defines the current width of the viewport
  3184. * @param viewportHeight defines the current height of the viewport
  3185. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3186. * @param view defines the view matrix to use
  3187. * @param projection defines the projection matrix to use
  3188. * @returns the new Vector3
  3189. */
  3190. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  3191. /**
  3192. * Unproject from screen space to object space
  3193. * @param source defines the screen space Vector3 to use
  3194. * @param viewportWidth defines the current width of the viewport
  3195. * @param viewportHeight defines the current height of the viewport
  3196. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3197. * @param view defines the view matrix to use
  3198. * @param projection defines the projection matrix to use
  3199. * @param result defines the Vector3 where to store the result
  3200. */
  3201. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3202. /**
  3203. * Unproject from screen space to object space
  3204. * @param sourceX defines the screen space x coordinate to use
  3205. * @param sourceY defines the screen space y coordinate to use
  3206. * @param sourceZ defines the screen space z coordinate to use
  3207. * @param viewportWidth defines the current width of the viewport
  3208. * @param viewportHeight defines the current height of the viewport
  3209. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  3210. * @param view defines the view matrix to use
  3211. * @param projection defines the projection matrix to use
  3212. * @param result defines the Vector3 where to store the result
  3213. */
  3214. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  3215. /**
  3216. * Gets the minimal coordinate values between two Vector3
  3217. * @param left defines the first operand
  3218. * @param right defines the second operand
  3219. * @returns the new Vector3
  3220. */
  3221. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3222. /**
  3223. * Gets the maximal coordinate values between two Vector3
  3224. * @param left defines the first operand
  3225. * @param right defines the second operand
  3226. * @returns the new Vector3
  3227. */
  3228. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  3229. /**
  3230. * Returns the distance between the vectors "value1" and "value2"
  3231. * @param value1 defines the first operand
  3232. * @param value2 defines the second operand
  3233. * @returns the distance
  3234. */
  3235. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3236. /**
  3237. * Returns the squared distance between the vectors "value1" and "value2"
  3238. * @param value1 defines the first operand
  3239. * @param value2 defines the second operand
  3240. * @returns the squared distance
  3241. */
  3242. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  3243. /**
  3244. * Returns a new Vector3 located at the center between "value1" and "value2"
  3245. * @param value1 defines the first operand
  3246. * @param value2 defines the second operand
  3247. * @returns the new Vector3
  3248. */
  3249. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  3250. /**
  3251. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  3252. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  3253. * to something in order to rotate it from its local system to the given target system
  3254. * Note: axis1, axis2 and axis3 are normalized during this operation
  3255. * @param axis1 defines the first axis
  3256. * @param axis2 defines the second axis
  3257. * @param axis3 defines the third axis
  3258. * @returns a new Vector3
  3259. */
  3260. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  3261. /**
  3262. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  3263. * @param axis1 defines the first axis
  3264. * @param axis2 defines the second axis
  3265. * @param axis3 defines the third axis
  3266. * @param ref defines the Vector3 where to store the result
  3267. */
  3268. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  3269. }
  3270. /**
  3271. * Vector4 class created for EulerAngle class conversion to Quaternion
  3272. */
  3273. export class Vector4 {
  3274. /** x value of the vector */
  3275. x: number;
  3276. /** y value of the vector */
  3277. y: number;
  3278. /** z value of the vector */
  3279. z: number;
  3280. /** w value of the vector */
  3281. w: number;
  3282. /**
  3283. * Creates a Vector4 object from the given floats.
  3284. * @param x x value of the vector
  3285. * @param y y value of the vector
  3286. * @param z z value of the vector
  3287. * @param w w value of the vector
  3288. */
  3289. constructor(
  3290. /** x value of the vector */
  3291. x: number,
  3292. /** y value of the vector */
  3293. y: number,
  3294. /** z value of the vector */
  3295. z: number,
  3296. /** w value of the vector */
  3297. w: number);
  3298. /**
  3299. * Returns the string with the Vector4 coordinates.
  3300. * @returns a string containing all the vector values
  3301. */
  3302. toString(): string;
  3303. /**
  3304. * Returns the string "Vector4".
  3305. * @returns "Vector4"
  3306. */
  3307. getClassName(): string;
  3308. /**
  3309. * Returns the Vector4 hash code.
  3310. * @returns a unique hash code
  3311. */
  3312. getHashCode(): number;
  3313. /**
  3314. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  3315. * @returns the resulting array
  3316. */
  3317. asArray(): number[];
  3318. /**
  3319. * Populates the given array from the given index with the Vector4 coordinates.
  3320. * @param array array to populate
  3321. * @param index index of the array to start at (default: 0)
  3322. * @returns the Vector4.
  3323. */
  3324. toArray(array: FloatArray, index?: number): Vector4;
  3325. /**
  3326. * Update the current vector from an array
  3327. * @param array defines the destination array
  3328. * @param index defines the offset in the destination array
  3329. * @returns the current Vector3
  3330. */
  3331. fromArray(array: FloatArray, index?: number): Vector4;
  3332. /**
  3333. * Adds the given vector to the current Vector4.
  3334. * @param otherVector the vector to add
  3335. * @returns the updated Vector4.
  3336. */
  3337. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3338. /**
  3339. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  3340. * @param otherVector the vector to add
  3341. * @returns the resulting vector
  3342. */
  3343. add(otherVector: DeepImmutable<Vector4>): Vector4;
  3344. /**
  3345. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  3346. * @param otherVector the vector to add
  3347. * @param result the vector to store the result
  3348. * @returns the current Vector4.
  3349. */
  3350. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3351. /**
  3352. * Subtract in place the given vector from the current Vector4.
  3353. * @param otherVector the vector to subtract
  3354. * @returns the updated Vector4.
  3355. */
  3356. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3357. /**
  3358. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  3359. * @param otherVector the vector to add
  3360. * @returns the new vector with the result
  3361. */
  3362. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  3363. /**
  3364. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  3365. * @param otherVector the vector to subtract
  3366. * @param result the vector to store the result
  3367. * @returns the current Vector4.
  3368. */
  3369. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3370. /**
  3371. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3372. */
  3373. /**
  3374. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3375. * @param x value to subtract
  3376. * @param y value to subtract
  3377. * @param z value to subtract
  3378. * @param w value to subtract
  3379. * @returns new vector containing the result
  3380. */
  3381. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3382. /**
  3383. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  3384. * @param x value to subtract
  3385. * @param y value to subtract
  3386. * @param z value to subtract
  3387. * @param w value to subtract
  3388. * @param result the vector to store the result in
  3389. * @returns the current Vector4.
  3390. */
  3391. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  3392. /**
  3393. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  3394. * @returns a new vector with the negated values
  3395. */
  3396. negate(): Vector4;
  3397. /**
  3398. * Negate this vector in place
  3399. * @returns this
  3400. */
  3401. negateInPlace(): Vector4;
  3402. /**
  3403. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  3404. * @param result defines the Vector3 object where to store the result
  3405. * @returns the current Vector4
  3406. */
  3407. negateToRef(result: Vector4): Vector4;
  3408. /**
  3409. * Multiplies the current Vector4 coordinates by scale (float).
  3410. * @param scale the number to scale with
  3411. * @returns the updated Vector4.
  3412. */
  3413. scaleInPlace(scale: number): Vector4;
  3414. /**
  3415. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  3416. * @param scale the number to scale with
  3417. * @returns a new vector with the result
  3418. */
  3419. scale(scale: number): Vector4;
  3420. /**
  3421. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  3422. * @param scale the number to scale with
  3423. * @param result a vector to store the result in
  3424. * @returns the current Vector4.
  3425. */
  3426. scaleToRef(scale: number, result: Vector4): Vector4;
  3427. /**
  3428. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  3429. * @param scale defines the scale factor
  3430. * @param result defines the Vector4 object where to store the result
  3431. * @returns the unmodified current Vector4
  3432. */
  3433. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  3434. /**
  3435. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  3436. * @param otherVector the vector to compare against
  3437. * @returns true if they are equal
  3438. */
  3439. equals(otherVector: DeepImmutable<Vector4>): boolean;
  3440. /**
  3441. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  3442. * @param otherVector vector to compare against
  3443. * @param epsilon (Default: very small number)
  3444. * @returns true if they are equal
  3445. */
  3446. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  3447. /**
  3448. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  3449. * @param x x value to compare against
  3450. * @param y y value to compare against
  3451. * @param z z value to compare against
  3452. * @param w w value to compare against
  3453. * @returns true if equal
  3454. */
  3455. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  3456. /**
  3457. * Multiplies in place the current Vector4 by the given one.
  3458. * @param otherVector vector to multiple with
  3459. * @returns the updated Vector4.
  3460. */
  3461. multiplyInPlace(otherVector: Vector4): Vector4;
  3462. /**
  3463. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  3464. * @param otherVector vector to multiple with
  3465. * @returns resulting new vector
  3466. */
  3467. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  3468. /**
  3469. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  3470. * @param otherVector vector to multiple with
  3471. * @param result vector to store the result
  3472. * @returns the current Vector4.
  3473. */
  3474. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3475. /**
  3476. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  3477. * @param x x value multiply with
  3478. * @param y y value multiply with
  3479. * @param z z value multiply with
  3480. * @param w w value multiply with
  3481. * @returns resulting new vector
  3482. */
  3483. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  3484. /**
  3485. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  3486. * @param otherVector vector to devide with
  3487. * @returns resulting new vector
  3488. */
  3489. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  3490. /**
  3491. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  3492. * @param otherVector vector to devide with
  3493. * @param result vector to store the result
  3494. * @returns the current Vector4.
  3495. */
  3496. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  3497. /**
  3498. * Divides the current Vector3 coordinates by the given ones.
  3499. * @param otherVector vector to devide with
  3500. * @returns the updated Vector3.
  3501. */
  3502. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  3503. /**
  3504. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  3505. * @param other defines the second operand
  3506. * @returns the current updated Vector4
  3507. */
  3508. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3509. /**
  3510. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  3511. * @param other defines the second operand
  3512. * @returns the current updated Vector4
  3513. */
  3514. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  3515. /**
  3516. * Gets a new Vector4 from current Vector4 floored values
  3517. * @returns a new Vector4
  3518. */
  3519. floor(): Vector4;
  3520. /**
  3521. * Gets a new Vector4 from current Vector3 floored values
  3522. * @returns a new Vector4
  3523. */
  3524. fract(): Vector4;
  3525. /**
  3526. * Returns the Vector4 length (float).
  3527. * @returns the length
  3528. */
  3529. length(): number;
  3530. /**
  3531. * Returns the Vector4 squared length (float).
  3532. * @returns the length squared
  3533. */
  3534. lengthSquared(): number;
  3535. /**
  3536. * Normalizes in place the Vector4.
  3537. * @returns the updated Vector4.
  3538. */
  3539. normalize(): Vector4;
  3540. /**
  3541. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  3542. * @returns this converted to a new vector3
  3543. */
  3544. toVector3(): Vector3;
  3545. /**
  3546. * Returns a new Vector4 copied from the current one.
  3547. * @returns the new cloned vector
  3548. */
  3549. clone(): Vector4;
  3550. /**
  3551. * Updates the current Vector4 with the given one coordinates.
  3552. * @param source the source vector to copy from
  3553. * @returns the updated Vector4.
  3554. */
  3555. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  3556. /**
  3557. * Updates the current Vector4 coordinates with the given floats.
  3558. * @param x float to copy from
  3559. * @param y float to copy from
  3560. * @param z float to copy from
  3561. * @param w float to copy from
  3562. * @returns the updated Vector4.
  3563. */
  3564. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  3565. /**
  3566. * Updates the current Vector4 coordinates with the given floats.
  3567. * @param x float to set from
  3568. * @param y float to set from
  3569. * @param z float to set from
  3570. * @param w float to set from
  3571. * @returns the updated Vector4.
  3572. */
  3573. set(x: number, y: number, z: number, w: number): Vector4;
  3574. /**
  3575. * Copies the given float to the current Vector3 coordinates
  3576. * @param v defines the x, y, z and w coordinates of the operand
  3577. * @returns the current updated Vector3
  3578. */
  3579. setAll(v: number): Vector4;
  3580. /**
  3581. * Returns a new Vector4 set from the starting index of the given array.
  3582. * @param array the array to pull values from
  3583. * @param offset the offset into the array to start at
  3584. * @returns the new vector
  3585. */
  3586. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  3587. /**
  3588. * Updates the given vector "result" from the starting index of the given array.
  3589. * @param array the array to pull values from
  3590. * @param offset the offset into the array to start at
  3591. * @param result the vector to store the result in
  3592. */
  3593. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  3594. /**
  3595. * Updates the given vector "result" from the starting index of the given Float32Array.
  3596. * @param array the array to pull values from
  3597. * @param offset the offset into the array to start at
  3598. * @param result the vector to store the result in
  3599. */
  3600. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  3601. /**
  3602. * Updates the given vector "result" coordinates from the given floats.
  3603. * @param x float to set from
  3604. * @param y float to set from
  3605. * @param z float to set from
  3606. * @param w float to set from
  3607. * @param result the vector to the floats in
  3608. */
  3609. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  3610. /**
  3611. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  3612. * @returns the new vector
  3613. */
  3614. static Zero(): Vector4;
  3615. /**
  3616. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  3617. * @returns the new vector
  3618. */
  3619. static One(): Vector4;
  3620. /**
  3621. * Returns a new normalized Vector4 from the given one.
  3622. * @param vector the vector to normalize
  3623. * @returns the vector
  3624. */
  3625. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  3626. /**
  3627. * Updates the given vector "result" from the normalization of the given one.
  3628. * @param vector the vector to normalize
  3629. * @param result the vector to store the result in
  3630. */
  3631. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  3632. /**
  3633. * Returns a vector with the minimum values from the left and right vectors
  3634. * @param left left vector to minimize
  3635. * @param right right vector to minimize
  3636. * @returns a new vector with the minimum of the left and right vector values
  3637. */
  3638. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3639. /**
  3640. * Returns a vector with the maximum values from the left and right vectors
  3641. * @param left left vector to maximize
  3642. * @param right right vector to maximize
  3643. * @returns a new vector with the maximum of the left and right vector values
  3644. */
  3645. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  3646. /**
  3647. * Returns the distance (float) between the vectors "value1" and "value2".
  3648. * @param value1 value to calulate the distance between
  3649. * @param value2 value to calulate the distance between
  3650. * @return the distance between the two vectors
  3651. */
  3652. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3653. /**
  3654. * Returns the squared distance (float) between the vectors "value1" and "value2".
  3655. * @param value1 value to calulate the distance between
  3656. * @param value2 value to calulate the distance between
  3657. * @return the distance between the two vectors squared
  3658. */
  3659. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  3660. /**
  3661. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  3662. * @param value1 value to calulate the center between
  3663. * @param value2 value to calulate the center between
  3664. * @return the center between the two vectors
  3665. */
  3666. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  3667. /**
  3668. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  3669. * This methods computes transformed normalized direction vectors only.
  3670. * @param vector the vector to transform
  3671. * @param transformation the transformation matrix to apply
  3672. * @returns the new vector
  3673. */
  3674. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  3675. /**
  3676. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  3677. * This methods computes transformed normalized direction vectors only.
  3678. * @param vector the vector to transform
  3679. * @param transformation the transformation matrix to apply
  3680. * @param result the vector to store the result in
  3681. */
  3682. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3683. /**
  3684. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  3685. * This methods computes transformed normalized direction vectors only.
  3686. * @param x value to transform
  3687. * @param y value to transform
  3688. * @param z value to transform
  3689. * @param w value to transform
  3690. * @param transformation the transformation matrix to apply
  3691. * @param result the vector to store the results in
  3692. */
  3693. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  3694. /**
  3695. * Creates a new Vector4 from a Vector3
  3696. * @param source defines the source data
  3697. * @param w defines the 4th component (default is 0)
  3698. * @returns a new Vector4
  3699. */
  3700. static FromVector3(source: Vector3, w?: number): Vector4;
  3701. }
  3702. /**
  3703. * Class used to store quaternion data
  3704. * @see https://en.wikipedia.org/wiki/Quaternion
  3705. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  3706. */
  3707. export class Quaternion {
  3708. /** @hidden */
  3709. _x: number;
  3710. /** @hidden */
  3711. _y: number;
  3712. /** @hidden */
  3713. _z: number;
  3714. /** @hidden */
  3715. _w: number;
  3716. /** @hidden */
  3717. _isDirty: boolean;
  3718. /** Gets or sets the x coordinate */
  3719. get x(): number;
  3720. set x(value: number);
  3721. /** Gets or sets the y coordinate */
  3722. get y(): number;
  3723. set y(value: number);
  3724. /** Gets or sets the z coordinate */
  3725. get z(): number;
  3726. set z(value: number);
  3727. /** Gets or sets the w coordinate */
  3728. get w(): number;
  3729. set w(value: number);
  3730. /**
  3731. * Creates a new Quaternion from the given floats
  3732. * @param x defines the first component (0 by default)
  3733. * @param y defines the second component (0 by default)
  3734. * @param z defines the third component (0 by default)
  3735. * @param w defines the fourth component (1.0 by default)
  3736. */
  3737. constructor(x?: number, y?: number, z?: number, w?: number);
  3738. /**
  3739. * Gets a string representation for the current quaternion
  3740. * @returns a string with the Quaternion coordinates
  3741. */
  3742. toString(): string;
  3743. /**
  3744. * Gets the class name of the quaternion
  3745. * @returns the string "Quaternion"
  3746. */
  3747. getClassName(): string;
  3748. /**
  3749. * Gets a hash code for this quaternion
  3750. * @returns the quaternion hash code
  3751. */
  3752. getHashCode(): number;
  3753. /**
  3754. * Copy the quaternion to an array
  3755. * @returns a new array populated with 4 elements from the quaternion coordinates
  3756. */
  3757. asArray(): number[];
  3758. /**
  3759. * Check if two quaternions are equals
  3760. * @param otherQuaternion defines the second operand
  3761. * @return true if the current quaternion and the given one coordinates are strictly equals
  3762. */
  3763. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  3764. /**
  3765. * Gets a boolean if two quaternions are equals (using an epsilon value)
  3766. * @param otherQuaternion defines the other quaternion
  3767. * @param epsilon defines the minimal distance to consider equality
  3768. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  3769. */
  3770. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  3771. /**
  3772. * Clone the current quaternion
  3773. * @returns a new quaternion copied from the current one
  3774. */
  3775. clone(): Quaternion;
  3776. /**
  3777. * Copy a quaternion to the current one
  3778. * @param other defines the other quaternion
  3779. * @returns the updated current quaternion
  3780. */
  3781. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  3782. /**
  3783. * Updates the current quaternion with the given float coordinates
  3784. * @param x defines the x coordinate
  3785. * @param y defines the y coordinate
  3786. * @param z defines the z coordinate
  3787. * @param w defines the w coordinate
  3788. * @returns the updated current quaternion
  3789. */
  3790. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  3791. /**
  3792. * Updates the current quaternion from the given float coordinates
  3793. * @param x defines the x coordinate
  3794. * @param y defines the y coordinate
  3795. * @param z defines the z coordinate
  3796. * @param w defines the w coordinate
  3797. * @returns the updated current quaternion
  3798. */
  3799. set(x: number, y: number, z: number, w: number): Quaternion;
  3800. /**
  3801. * Adds two quaternions
  3802. * @param other defines the second operand
  3803. * @returns a new quaternion as the addition result of the given one and the current quaternion
  3804. */
  3805. add(other: DeepImmutable<Quaternion>): Quaternion;
  3806. /**
  3807. * Add a quaternion to the current one
  3808. * @param other defines the quaternion to add
  3809. * @returns the current quaternion
  3810. */
  3811. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  3812. /**
  3813. * Subtract two quaternions
  3814. * @param other defines the second operand
  3815. * @returns a new quaternion as the subtraction result of the given one from the current one
  3816. */
  3817. subtract(other: Quaternion): Quaternion;
  3818. /**
  3819. * Multiplies the current quaternion by a scale factor
  3820. * @param value defines the scale factor
  3821. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  3822. */
  3823. scale(value: number): Quaternion;
  3824. /**
  3825. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  3826. * @param scale defines the scale factor
  3827. * @param result defines the Quaternion object where to store the result
  3828. * @returns the unmodified current quaternion
  3829. */
  3830. scaleToRef(scale: number, result: Quaternion): Quaternion;
  3831. /**
  3832. * Multiplies in place the current quaternion by a scale factor
  3833. * @param value defines the scale factor
  3834. * @returns the current modified quaternion
  3835. */
  3836. scaleInPlace(value: number): Quaternion;
  3837. /**
  3838. * Scale the current quaternion values by a factor and add the result to a given quaternion
  3839. * @param scale defines the scale factor
  3840. * @param result defines the Quaternion object where to store the result
  3841. * @returns the unmodified current quaternion
  3842. */
  3843. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  3844. /**
  3845. * Multiplies two quaternions
  3846. * @param q1 defines the second operand
  3847. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  3848. */
  3849. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  3850. /**
  3851. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  3852. * @param q1 defines the second operand
  3853. * @param result defines the target quaternion
  3854. * @returns the current quaternion
  3855. */
  3856. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  3857. /**
  3858. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  3859. * @param q1 defines the second operand
  3860. * @returns the currentupdated quaternion
  3861. */
  3862. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  3863. /**
  3864. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  3865. * @param ref defines the target quaternion
  3866. * @returns the current quaternion
  3867. */
  3868. conjugateToRef(ref: Quaternion): Quaternion;
  3869. /**
  3870. * Conjugates in place (1-q) the current quaternion
  3871. * @returns the current updated quaternion
  3872. */
  3873. conjugateInPlace(): Quaternion;
  3874. /**
  3875. * Conjugates in place (1-q) the current quaternion
  3876. * @returns a new quaternion
  3877. */
  3878. conjugate(): Quaternion;
  3879. /**
  3880. * Gets length of current quaternion
  3881. * @returns the quaternion length (float)
  3882. */
  3883. length(): number;
  3884. /**
  3885. * Normalize in place the current quaternion
  3886. * @returns the current updated quaternion
  3887. */
  3888. normalize(): Quaternion;
  3889. /**
  3890. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  3891. * @param order is a reserved parameter and is ignored for now
  3892. * @returns a new Vector3 containing the Euler angles
  3893. */
  3894. toEulerAngles(order?: string): Vector3;
  3895. /**
  3896. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  3897. * @param result defines the vector which will be filled with the Euler angles
  3898. * @returns the current unchanged quaternion
  3899. */
  3900. toEulerAnglesToRef(result: Vector3): Quaternion;
  3901. /**
  3902. * Updates the given rotation matrix with the current quaternion values
  3903. * @param result defines the target matrix
  3904. * @returns the current unchanged quaternion
  3905. */
  3906. toRotationMatrix(result: Matrix): Quaternion;
  3907. /**
  3908. * Updates the current quaternion from the given rotation matrix values
  3909. * @param matrix defines the source matrix
  3910. * @returns the current updated quaternion
  3911. */
  3912. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3913. /**
  3914. * Creates a new quaternion from a rotation matrix
  3915. * @param matrix defines the source matrix
  3916. * @returns a new quaternion created from the given rotation matrix values
  3917. */
  3918. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  3919. /**
  3920. * Updates the given quaternion with the given rotation matrix values
  3921. * @param matrix defines the source matrix
  3922. * @param result defines the target quaternion
  3923. */
  3924. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  3925. /**
  3926. * Returns the dot product (float) between the quaternions "left" and "right"
  3927. * @param left defines the left operand
  3928. * @param right defines the right operand
  3929. * @returns the dot product
  3930. */
  3931. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  3932. /**
  3933. * Checks if the two quaternions are close to each other
  3934. * @param quat0 defines the first quaternion to check
  3935. * @param quat1 defines the second quaternion to check
  3936. * @returns true if the two quaternions are close to each other
  3937. */
  3938. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  3939. /**
  3940. * Creates an empty quaternion
  3941. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  3942. */
  3943. static Zero(): Quaternion;
  3944. /**
  3945. * Inverse a given quaternion
  3946. * @param q defines the source quaternion
  3947. * @returns a new quaternion as the inverted current quaternion
  3948. */
  3949. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  3950. /**
  3951. * Inverse a given quaternion
  3952. * @param q defines the source quaternion
  3953. * @param result the quaternion the result will be stored in
  3954. * @returns the result quaternion
  3955. */
  3956. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  3957. /**
  3958. * Creates an identity quaternion
  3959. * @returns the identity quaternion
  3960. */
  3961. static Identity(): Quaternion;
  3962. /**
  3963. * Gets a boolean indicating if the given quaternion is identity
  3964. * @param quaternion defines the quaternion to check
  3965. * @returns true if the quaternion is identity
  3966. */
  3967. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  3968. /**
  3969. * Creates a quaternion from a rotation around an axis
  3970. * @param axis defines the axis to use
  3971. * @param angle defines the angle to use
  3972. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  3973. */
  3974. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  3975. /**
  3976. * Creates a rotation around an axis and stores it into the given quaternion
  3977. * @param axis defines the axis to use
  3978. * @param angle defines the angle to use
  3979. * @param result defines the target quaternion
  3980. * @returns the target quaternion
  3981. */
  3982. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  3983. /**
  3984. * Creates a new quaternion from data stored into an array
  3985. * @param array defines the data source
  3986. * @param offset defines the offset in the source array where the data starts
  3987. * @returns a new quaternion
  3988. */
  3989. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  3990. /**
  3991. * Updates the given quaternion "result" from the starting index of the given array.
  3992. * @param array the array to pull values from
  3993. * @param offset the offset into the array to start at
  3994. * @param result the quaternion to store the result in
  3995. */
  3996. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  3997. /**
  3998. * Create a quaternion from Euler rotation angles
  3999. * @param x Pitch
  4000. * @param y Yaw
  4001. * @param z Roll
  4002. * @returns the new Quaternion
  4003. */
  4004. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  4005. /**
  4006. * Updates a quaternion from Euler rotation angles
  4007. * @param x Pitch
  4008. * @param y Yaw
  4009. * @param z Roll
  4010. * @param result the quaternion to store the result
  4011. * @returns the updated quaternion
  4012. */
  4013. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  4014. /**
  4015. * Create a quaternion from Euler rotation vector
  4016. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4017. * @returns the new Quaternion
  4018. */
  4019. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  4020. /**
  4021. * Updates a quaternion from Euler rotation vector
  4022. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  4023. * @param result the quaternion to store the result
  4024. * @returns the updated quaternion
  4025. */
  4026. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  4027. /**
  4028. * Creates a new quaternion from the given Euler float angles (y, x, z)
  4029. * @param yaw defines the rotation around Y axis
  4030. * @param pitch defines the rotation around X axis
  4031. * @param roll defines the rotation around Z axis
  4032. * @returns the new quaternion
  4033. */
  4034. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  4035. /**
  4036. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  4037. * @param yaw defines the rotation around Y axis
  4038. * @param pitch defines the rotation around X axis
  4039. * @param roll defines the rotation around Z axis
  4040. * @param result defines the target quaternion
  4041. */
  4042. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  4043. /**
  4044. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  4045. * @param alpha defines the rotation around first axis
  4046. * @param beta defines the rotation around second axis
  4047. * @param gamma defines the rotation around third axis
  4048. * @returns the new quaternion
  4049. */
  4050. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  4051. /**
  4052. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  4053. * @param alpha defines the rotation around first axis
  4054. * @param beta defines the rotation around second axis
  4055. * @param gamma defines the rotation around third axis
  4056. * @param result defines the target quaternion
  4057. */
  4058. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  4059. /**
  4060. * 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)
  4061. * @param axis1 defines the first axis
  4062. * @param axis2 defines the second axis
  4063. * @param axis3 defines the third axis
  4064. * @returns the new quaternion
  4065. */
  4066. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  4067. /**
  4068. * 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
  4069. * @param axis1 defines the first axis
  4070. * @param axis2 defines the second axis
  4071. * @param axis3 defines the third axis
  4072. * @param ref defines the target quaternion
  4073. */
  4074. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  4075. /**
  4076. * Interpolates between two quaternions
  4077. * @param left defines first quaternion
  4078. * @param right defines second quaternion
  4079. * @param amount defines the gradient to use
  4080. * @returns the new interpolated quaternion
  4081. */
  4082. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4083. /**
  4084. * Interpolates between two quaternions and stores it into a target quaternion
  4085. * @param left defines first quaternion
  4086. * @param right defines second quaternion
  4087. * @param amount defines the gradient to use
  4088. * @param result defines the target quaternion
  4089. */
  4090. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  4091. /**
  4092. * Interpolate between two quaternions using Hermite interpolation
  4093. * @param value1 defines first quaternion
  4094. * @param tangent1 defines the incoming tangent
  4095. * @param value2 defines second quaternion
  4096. * @param tangent2 defines the outgoing tangent
  4097. * @param amount defines the target quaternion
  4098. * @returns the new interpolated quaternion
  4099. */
  4100. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  4101. }
  4102. /**
  4103. * Class used to store matrix data (4x4)
  4104. */
  4105. export class Matrix {
  4106. /**
  4107. * Gets the precision of matrix computations
  4108. */
  4109. static get Use64Bits(): boolean;
  4110. private static _updateFlagSeed;
  4111. private static _identityReadOnly;
  4112. private _isIdentity;
  4113. private _isIdentityDirty;
  4114. private _isIdentity3x2;
  4115. private _isIdentity3x2Dirty;
  4116. /**
  4117. * Gets the update flag of the matrix which is an unique number for the matrix.
  4118. * It will be incremented every time the matrix data change.
  4119. * You can use it to speed the comparison between two versions of the same matrix.
  4120. */
  4121. updateFlag: number;
  4122. private readonly _m;
  4123. /**
  4124. * Gets the internal data of the matrix
  4125. */
  4126. get m(): DeepImmutable<Float32Array | Array<number>>;
  4127. /** @hidden */
  4128. _markAsUpdated(): void;
  4129. /** @hidden */
  4130. private _updateIdentityStatus;
  4131. /**
  4132. * Creates an empty matrix (filled with zeros)
  4133. */
  4134. constructor();
  4135. /**
  4136. * Check if the current matrix is identity
  4137. * @returns true is the matrix is the identity matrix
  4138. */
  4139. isIdentity(): boolean;
  4140. /**
  4141. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  4142. * @returns true is the matrix is the identity matrix
  4143. */
  4144. isIdentityAs3x2(): boolean;
  4145. /**
  4146. * Gets the determinant of the matrix
  4147. * @returns the matrix determinant
  4148. */
  4149. determinant(): number;
  4150. /**
  4151. * Returns the matrix as a Float32Array or Array<number>
  4152. * @returns the matrix underlying array
  4153. */
  4154. toArray(): DeepImmutable<Float32Array | Array<number>>;
  4155. /**
  4156. * Returns the matrix as a Float32Array or Array<number>
  4157. * @returns the matrix underlying array.
  4158. */
  4159. asArray(): DeepImmutable<Float32Array | Array<number>>;
  4160. /**
  4161. * Inverts the current matrix in place
  4162. * @returns the current inverted matrix
  4163. */
  4164. invert(): Matrix;
  4165. /**
  4166. * Sets all the matrix elements to zero
  4167. * @returns the current matrix
  4168. */
  4169. reset(): Matrix;
  4170. /**
  4171. * Adds the current matrix with a second one
  4172. * @param other defines the matrix to add
  4173. * @returns a new matrix as the addition of the current matrix and the given one
  4174. */
  4175. add(other: DeepImmutable<Matrix>): Matrix;
  4176. /**
  4177. * Sets the given matrix "result" to the addition of the current matrix and the given one
  4178. * @param other defines the matrix to add
  4179. * @param result defines the target matrix
  4180. * @returns the current matrix
  4181. */
  4182. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4183. /**
  4184. * Adds in place the given matrix to the current matrix
  4185. * @param other defines the second operand
  4186. * @returns the current updated matrix
  4187. */
  4188. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  4189. /**
  4190. * Sets the given matrix to the current inverted Matrix
  4191. * @param other defines the target matrix
  4192. * @returns the unmodified current matrix
  4193. */
  4194. invertToRef(other: Matrix): Matrix;
  4195. /**
  4196. * add a value at the specified position in the current Matrix
  4197. * @param index the index of the value within the matrix. between 0 and 15.
  4198. * @param value the value to be added
  4199. * @returns the current updated matrix
  4200. */
  4201. addAtIndex(index: number, value: number): Matrix;
  4202. /**
  4203. * mutiply the specified position in the current Matrix by a value
  4204. * @param index the index of the value within the matrix. between 0 and 15.
  4205. * @param value the value to be added
  4206. * @returns the current updated matrix
  4207. */
  4208. multiplyAtIndex(index: number, value: number): Matrix;
  4209. /**
  4210. * Inserts the translation vector (using 3 floats) in the current matrix
  4211. * @param x defines the 1st component of the translation
  4212. * @param y defines the 2nd component of the translation
  4213. * @param z defines the 3rd component of the translation
  4214. * @returns the current updated matrix
  4215. */
  4216. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4217. /**
  4218. * Adds the translation vector (using 3 floats) in the current matrix
  4219. * @param x defines the 1st component of the translation
  4220. * @param y defines the 2nd component of the translation
  4221. * @param z defines the 3rd component of the translation
  4222. * @returns the current updated matrix
  4223. */
  4224. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  4225. /**
  4226. * Inserts the translation vector in the current matrix
  4227. * @param vector3 defines the translation to insert
  4228. * @returns the current updated matrix
  4229. */
  4230. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  4231. /**
  4232. * Gets the translation value of the current matrix
  4233. * @returns a new Vector3 as the extracted translation from the matrix
  4234. */
  4235. getTranslation(): Vector3;
  4236. /**
  4237. * Fill a Vector3 with the extracted translation from the matrix
  4238. * @param result defines the Vector3 where to store the translation
  4239. * @returns the current matrix
  4240. */
  4241. getTranslationToRef(result: Vector3): Matrix;
  4242. /**
  4243. * Remove rotation and scaling part from the matrix
  4244. * @returns the updated matrix
  4245. */
  4246. removeRotationAndScaling(): Matrix;
  4247. /**
  4248. * Multiply two matrices
  4249. * @param other defines the second operand
  4250. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  4251. */
  4252. multiply(other: DeepImmutable<Matrix>): Matrix;
  4253. /**
  4254. * Copy the current matrix from the given one
  4255. * @param other defines the source matrix
  4256. * @returns the current updated matrix
  4257. */
  4258. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  4259. /**
  4260. * Populates the given array from the starting index with the current matrix values
  4261. * @param array defines the target array
  4262. * @param offset defines the offset in the target array where to start storing values
  4263. * @returns the current matrix
  4264. */
  4265. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  4266. /**
  4267. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  4268. * @param other defines the second operand
  4269. * @param result defines the matrix where to store the multiplication
  4270. * @returns the current matrix
  4271. */
  4272. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  4273. /**
  4274. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  4275. * @param other defines the second operand
  4276. * @param result defines the array where to store the multiplication
  4277. * @param offset defines the offset in the target array where to start storing values
  4278. * @returns the current matrix
  4279. */
  4280. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  4281. /**
  4282. * Check equality between this matrix and a second one
  4283. * @param value defines the second matrix to compare
  4284. * @returns true is the current matrix and the given one values are strictly equal
  4285. */
  4286. equals(value: DeepImmutable<Matrix>): boolean;
  4287. /**
  4288. * Clone the current matrix
  4289. * @returns a new matrix from the current matrix
  4290. */
  4291. clone(): Matrix;
  4292. /**
  4293. * Returns the name of the current matrix class
  4294. * @returns the string "Matrix"
  4295. */
  4296. getClassName(): string;
  4297. /**
  4298. * Gets the hash code of the current matrix
  4299. * @returns the hash code
  4300. */
  4301. getHashCode(): number;
  4302. /**
  4303. * Decomposes the current Matrix into a translation, rotation and scaling components
  4304. * @param scale defines the scale vector3 given as a reference to update
  4305. * @param rotation defines the rotation quaternion given as a reference to update
  4306. * @param translation defines the translation vector3 given as a reference to update
  4307. * @returns true if operation was successful
  4308. */
  4309. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  4310. /**
  4311. * Gets specific row of the matrix
  4312. * @param index defines the number of the row to get
  4313. * @returns the index-th row of the current matrix as a new Vector4
  4314. */
  4315. getRow(index: number): Nullable<Vector4>;
  4316. /**
  4317. * Sets the index-th row of the current matrix to the vector4 values
  4318. * @param index defines the number of the row to set
  4319. * @param row defines the target vector4
  4320. * @returns the updated current matrix
  4321. */
  4322. setRow(index: number, row: Vector4): Matrix;
  4323. /**
  4324. * Compute the transpose of the matrix
  4325. * @returns the new transposed matrix
  4326. */
  4327. transpose(): Matrix;
  4328. /**
  4329. * Compute the transpose of the matrix and store it in a given matrix
  4330. * @param result defines the target matrix
  4331. * @returns the current matrix
  4332. */
  4333. transposeToRef(result: Matrix): Matrix;
  4334. /**
  4335. * Sets the index-th row of the current matrix with the given 4 x float values
  4336. * @param index defines the row index
  4337. * @param x defines the x component to set
  4338. * @param y defines the y component to set
  4339. * @param z defines the z component to set
  4340. * @param w defines the w component to set
  4341. * @returns the updated current matrix
  4342. */
  4343. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  4344. /**
  4345. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  4346. * @param scale defines the scale factor
  4347. * @returns a new matrix
  4348. */
  4349. scale(scale: number): Matrix;
  4350. /**
  4351. * Scale the current matrix values by a factor to a given result matrix
  4352. * @param scale defines the scale factor
  4353. * @param result defines the matrix to store the result
  4354. * @returns the current matrix
  4355. */
  4356. scaleToRef(scale: number, result: Matrix): Matrix;
  4357. /**
  4358. * Scale the current matrix values by a factor and add the result to a given matrix
  4359. * @param scale defines the scale factor
  4360. * @param result defines the Matrix to store the result
  4361. * @returns the current matrix
  4362. */
  4363. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  4364. /**
  4365. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  4366. * @param ref matrix to store the result
  4367. */
  4368. toNormalMatrix(ref: Matrix): void;
  4369. /**
  4370. * Gets only rotation part of the current matrix
  4371. * @returns a new matrix sets to the extracted rotation matrix from the current one
  4372. */
  4373. getRotationMatrix(): Matrix;
  4374. /**
  4375. * Extracts the rotation matrix from the current one and sets it as the given "result"
  4376. * @param result defines the target matrix to store data to
  4377. * @returns the current matrix
  4378. */
  4379. getRotationMatrixToRef(result: Matrix): Matrix;
  4380. /**
  4381. * Toggles model matrix from being right handed to left handed in place and vice versa
  4382. */
  4383. toggleModelMatrixHandInPlace(): void;
  4384. /**
  4385. * Toggles projection matrix from being right handed to left handed in place and vice versa
  4386. */
  4387. toggleProjectionMatrixHandInPlace(): void;
  4388. /**
  4389. * Creates a matrix from an array
  4390. * @param array defines the source array
  4391. * @param offset defines an offset in the source array
  4392. * @returns a new Matrix set from the starting index of the given array
  4393. */
  4394. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  4395. /**
  4396. * Copy the content of an array into a given matrix
  4397. * @param array defines the source array
  4398. * @param offset defines an offset in the source array
  4399. * @param result defines the target matrix
  4400. */
  4401. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  4402. /**
  4403. * Stores an array into a matrix after having multiplied each component by a given factor
  4404. * @param array defines the source array
  4405. * @param offset defines the offset in the source array
  4406. * @param scale defines the scaling factor
  4407. * @param result defines the target matrix
  4408. */
  4409. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  4410. /**
  4411. * Gets an identity matrix that must not be updated
  4412. */
  4413. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  4414. /**
  4415. * Stores a list of values (16) inside a given matrix
  4416. * @param initialM11 defines 1st value of 1st row
  4417. * @param initialM12 defines 2nd value of 1st row
  4418. * @param initialM13 defines 3rd value of 1st row
  4419. * @param initialM14 defines 4th value of 1st row
  4420. * @param initialM21 defines 1st value of 2nd row
  4421. * @param initialM22 defines 2nd value of 2nd row
  4422. * @param initialM23 defines 3rd value of 2nd row
  4423. * @param initialM24 defines 4th value of 2nd row
  4424. * @param initialM31 defines 1st value of 3rd row
  4425. * @param initialM32 defines 2nd value of 3rd row
  4426. * @param initialM33 defines 3rd value of 3rd row
  4427. * @param initialM34 defines 4th value of 3rd row
  4428. * @param initialM41 defines 1st value of 4th row
  4429. * @param initialM42 defines 2nd value of 4th row
  4430. * @param initialM43 defines 3rd value of 4th row
  4431. * @param initialM44 defines 4th value of 4th row
  4432. * @param result defines the target matrix
  4433. */
  4434. 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;
  4435. /**
  4436. * Creates new matrix from a list of values (16)
  4437. * @param initialM11 defines 1st value of 1st row
  4438. * @param initialM12 defines 2nd value of 1st row
  4439. * @param initialM13 defines 3rd value of 1st row
  4440. * @param initialM14 defines 4th value of 1st row
  4441. * @param initialM21 defines 1st value of 2nd row
  4442. * @param initialM22 defines 2nd value of 2nd row
  4443. * @param initialM23 defines 3rd value of 2nd row
  4444. * @param initialM24 defines 4th value of 2nd row
  4445. * @param initialM31 defines 1st value of 3rd row
  4446. * @param initialM32 defines 2nd value of 3rd row
  4447. * @param initialM33 defines 3rd value of 3rd row
  4448. * @param initialM34 defines 4th value of 3rd row
  4449. * @param initialM41 defines 1st value of 4th row
  4450. * @param initialM42 defines 2nd value of 4th row
  4451. * @param initialM43 defines 3rd value of 4th row
  4452. * @param initialM44 defines 4th value of 4th row
  4453. * @returns the new matrix
  4454. */
  4455. 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;
  4456. /**
  4457. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4458. * @param scale defines the scale vector3
  4459. * @param rotation defines the rotation quaternion
  4460. * @param translation defines the translation vector3
  4461. * @returns a new matrix
  4462. */
  4463. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  4464. /**
  4465. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  4466. * @param scale defines the scale vector3
  4467. * @param rotation defines the rotation quaternion
  4468. * @param translation defines the translation vector3
  4469. * @param result defines the target matrix
  4470. */
  4471. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  4472. /**
  4473. * Creates a new identity matrix
  4474. * @returns a new identity matrix
  4475. */
  4476. static Identity(): Matrix;
  4477. /**
  4478. * Creates a new identity matrix and stores the result in a given matrix
  4479. * @param result defines the target matrix
  4480. */
  4481. static IdentityToRef(result: Matrix): void;
  4482. /**
  4483. * Creates a new zero matrix
  4484. * @returns a new zero matrix
  4485. */
  4486. static Zero(): Matrix;
  4487. /**
  4488. * Creates a new rotation matrix for "angle" radians around the X axis
  4489. * @param angle defines the angle (in radians) to use
  4490. * @return the new matrix
  4491. */
  4492. static RotationX(angle: number): Matrix;
  4493. /**
  4494. * Creates a new matrix as the invert of a given matrix
  4495. * @param source defines the source matrix
  4496. * @returns the new matrix
  4497. */
  4498. static Invert(source: DeepImmutable<Matrix>): Matrix;
  4499. /**
  4500. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  4501. * @param angle defines the angle (in radians) to use
  4502. * @param result defines the target matrix
  4503. */
  4504. static RotationXToRef(angle: number, result: Matrix): void;
  4505. /**
  4506. * Creates a new rotation matrix for "angle" radians around the Y axis
  4507. * @param angle defines the angle (in radians) to use
  4508. * @return the new matrix
  4509. */
  4510. static RotationY(angle: number): Matrix;
  4511. /**
  4512. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  4513. * @param angle defines the angle (in radians) to use
  4514. * @param result defines the target matrix
  4515. */
  4516. static RotationYToRef(angle: number, result: Matrix): void;
  4517. /**
  4518. * Creates a new rotation matrix for "angle" radians around the Z axis
  4519. * @param angle defines the angle (in radians) to use
  4520. * @return the new matrix
  4521. */
  4522. static RotationZ(angle: number): Matrix;
  4523. /**
  4524. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  4525. * @param angle defines the angle (in radians) to use
  4526. * @param result defines the target matrix
  4527. */
  4528. static RotationZToRef(angle: number, result: Matrix): void;
  4529. /**
  4530. * Creates a new rotation matrix for "angle" radians around the given axis
  4531. * @param axis defines the axis to use
  4532. * @param angle defines the angle (in radians) to use
  4533. * @return the new matrix
  4534. */
  4535. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  4536. /**
  4537. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  4538. * @param axis defines the axis to use
  4539. * @param angle defines the angle (in radians) to use
  4540. * @param result defines the target matrix
  4541. */
  4542. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  4543. /**
  4544. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  4545. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  4546. * @param from defines the vector to align
  4547. * @param to defines the vector to align to
  4548. * @param result defines the target matrix
  4549. */
  4550. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  4551. /**
  4552. * Creates a rotation matrix
  4553. * @param yaw defines the yaw angle in radians (Y axis)
  4554. * @param pitch defines the pitch angle in radians (X axis)
  4555. * @param roll defines the roll angle in radians (Z axis)
  4556. * @returns the new rotation matrix
  4557. */
  4558. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  4559. /**
  4560. * Creates a rotation matrix and stores it in a given matrix
  4561. * @param yaw defines the yaw angle in radians (Y axis)
  4562. * @param pitch defines the pitch angle in radians (X axis)
  4563. * @param roll defines the roll angle in radians (Z axis)
  4564. * @param result defines the target matrix
  4565. */
  4566. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  4567. /**
  4568. * Creates a scaling matrix
  4569. * @param x defines the scale factor on X axis
  4570. * @param y defines the scale factor on Y axis
  4571. * @param z defines the scale factor on Z axis
  4572. * @returns the new matrix
  4573. */
  4574. static Scaling(x: number, y: number, z: number): Matrix;
  4575. /**
  4576. * Creates a scaling matrix and stores it in a given matrix
  4577. * @param x defines the scale factor on X axis
  4578. * @param y defines the scale factor on Y axis
  4579. * @param z defines the scale factor on Z axis
  4580. * @param result defines the target matrix
  4581. */
  4582. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  4583. /**
  4584. * Creates a translation matrix
  4585. * @param x defines the translation on X axis
  4586. * @param y defines the translation on Y axis
  4587. * @param z defines the translationon Z axis
  4588. * @returns the new matrix
  4589. */
  4590. static Translation(x: number, y: number, z: number): Matrix;
  4591. /**
  4592. * Creates a translation matrix and stores it in a given matrix
  4593. * @param x defines the translation on X axis
  4594. * @param y defines the translation on Y axis
  4595. * @param z defines the translationon Z axis
  4596. * @param result defines the target matrix
  4597. */
  4598. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  4599. /**
  4600. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4601. * @param startValue defines the start value
  4602. * @param endValue defines the end value
  4603. * @param gradient defines the gradient factor
  4604. * @returns the new matrix
  4605. */
  4606. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4607. /**
  4608. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  4609. * @param startValue defines the start value
  4610. * @param endValue defines the end value
  4611. * @param gradient defines the gradient factor
  4612. * @param result defines the Matrix object where to store data
  4613. */
  4614. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4615. /**
  4616. * Builds a new matrix whose values are computed by:
  4617. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4618. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4619. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4620. * @param startValue defines the first matrix
  4621. * @param endValue defines the second matrix
  4622. * @param gradient defines the gradient between the two matrices
  4623. * @returns the new matrix
  4624. */
  4625. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  4626. /**
  4627. * Update a matrix to values which are computed by:
  4628. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  4629. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  4630. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  4631. * @param startValue defines the first matrix
  4632. * @param endValue defines the second matrix
  4633. * @param gradient defines the gradient between the two matrices
  4634. * @param result defines the target matrix
  4635. */
  4636. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  4637. /**
  4638. * 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"
  4639. * This function works in left handed mode
  4640. * @param eye defines the final position of the entity
  4641. * @param target defines where the entity should look at
  4642. * @param up defines the up vector for the entity
  4643. * @returns the new matrix
  4644. */
  4645. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4646. /**
  4647. * 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".
  4648. * This function works in left handed mode
  4649. * @param eye defines the final position of the entity
  4650. * @param target defines where the entity should look at
  4651. * @param up defines the up vector for the entity
  4652. * @param result defines the target matrix
  4653. */
  4654. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4655. /**
  4656. * 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"
  4657. * This function works in right handed mode
  4658. * @param eye defines the final position of the entity
  4659. * @param target defines where the entity should look at
  4660. * @param up defines the up vector for the entity
  4661. * @returns the new matrix
  4662. */
  4663. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  4664. /**
  4665. * 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".
  4666. * This function works in right handed mode
  4667. * @param eye defines the final position of the entity
  4668. * @param target defines where the entity should look at
  4669. * @param up defines the up vector for the entity
  4670. * @param result defines the target matrix
  4671. */
  4672. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  4673. /**
  4674. * Create a left-handed orthographic projection matrix
  4675. * @param width defines the viewport width
  4676. * @param height defines the viewport height
  4677. * @param znear defines the near clip plane
  4678. * @param zfar defines the far clip plane
  4679. * @returns a new matrix as a left-handed orthographic projection matrix
  4680. */
  4681. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4682. /**
  4683. * Store a left-handed orthographic projection to a given matrix
  4684. * @param width defines the viewport width
  4685. * @param height defines the viewport height
  4686. * @param znear defines the near clip plane
  4687. * @param zfar defines the far clip plane
  4688. * @param result defines the target matrix
  4689. */
  4690. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  4691. /**
  4692. * Create a left-handed orthographic projection matrix
  4693. * @param left defines the viewport left coordinate
  4694. * @param right defines the viewport right coordinate
  4695. * @param bottom defines the viewport bottom coordinate
  4696. * @param top defines the viewport top coordinate
  4697. * @param znear defines the near clip plane
  4698. * @param zfar defines the far clip plane
  4699. * @returns a new matrix as a left-handed orthographic projection matrix
  4700. */
  4701. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4702. /**
  4703. * Stores a left-handed orthographic projection into a given matrix
  4704. * @param left defines the viewport left coordinate
  4705. * @param right defines the viewport right coordinate
  4706. * @param bottom defines the viewport bottom coordinate
  4707. * @param top defines the viewport top coordinate
  4708. * @param znear defines the near clip plane
  4709. * @param zfar defines the far clip plane
  4710. * @param result defines the target matrix
  4711. */
  4712. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4713. /**
  4714. * Creates a right-handed orthographic projection matrix
  4715. * @param left defines the viewport left coordinate
  4716. * @param right defines the viewport right coordinate
  4717. * @param bottom defines the viewport bottom coordinate
  4718. * @param top defines the viewport top coordinate
  4719. * @param znear defines the near clip plane
  4720. * @param zfar defines the far clip plane
  4721. * @returns a new matrix as a right-handed orthographic projection matrix
  4722. */
  4723. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  4724. /**
  4725. * Stores a right-handed orthographic projection into a given matrix
  4726. * @param left defines the viewport left coordinate
  4727. * @param right defines the viewport right coordinate
  4728. * @param bottom defines the viewport bottom coordinate
  4729. * @param top defines the viewport top coordinate
  4730. * @param znear defines the near clip plane
  4731. * @param zfar defines the far clip plane
  4732. * @param result defines the target matrix
  4733. */
  4734. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  4735. /**
  4736. * Creates a left-handed perspective projection matrix
  4737. * @param width defines the viewport width
  4738. * @param height defines the viewport height
  4739. * @param znear defines the near clip plane
  4740. * @param zfar defines the far clip plane
  4741. * @returns a new matrix as a left-handed perspective projection matrix
  4742. */
  4743. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  4744. /**
  4745. * Creates a left-handed perspective projection matrix
  4746. * @param fov defines the horizontal field of view
  4747. * @param aspect defines the aspect ratio
  4748. * @param znear defines the near clip plane
  4749. * @param zfar defines the far clip plane
  4750. * @returns a new matrix as a left-handed perspective projection matrix
  4751. */
  4752. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4753. /**
  4754. * Stores a left-handed perspective projection into a given matrix
  4755. * @param fov defines the horizontal field of view
  4756. * @param aspect defines the aspect ratio
  4757. * @param znear defines the near clip plane
  4758. * @param zfar defines the far clip plane
  4759. * @param result defines the target matrix
  4760. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4761. */
  4762. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4763. /**
  4764. * Stores a left-handed perspective projection into a given matrix with depth reversed
  4765. * @param fov defines the horizontal field of view
  4766. * @param aspect defines the aspect ratio
  4767. * @param znear defines the near clip plane
  4768. * @param zfar not used as infinity is used as far clip
  4769. * @param result defines the target matrix
  4770. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4771. */
  4772. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4773. /**
  4774. * Creates a right-handed perspective projection matrix
  4775. * @param fov defines the horizontal field of view
  4776. * @param aspect defines the aspect ratio
  4777. * @param znear defines the near clip plane
  4778. * @param zfar defines the far clip plane
  4779. * @returns a new matrix as a right-handed perspective projection matrix
  4780. */
  4781. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  4782. /**
  4783. * Stores a right-handed perspective projection into a given matrix
  4784. * @param fov defines the horizontal field of view
  4785. * @param aspect defines the aspect ratio
  4786. * @param znear defines the near clip plane
  4787. * @param zfar defines the far clip plane
  4788. * @param result defines the target matrix
  4789. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4790. */
  4791. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4792. /**
  4793. * Stores a right-handed perspective projection into a given matrix
  4794. * @param fov defines the horizontal field of view
  4795. * @param aspect defines the aspect ratio
  4796. * @param znear defines the near clip plane
  4797. * @param zfar not used as infinity is used as far clip
  4798. * @param result defines the target matrix
  4799. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  4800. */
  4801. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  4802. /**
  4803. * Stores a perspective projection for WebVR info a given matrix
  4804. * @param fov defines the field of view
  4805. * @param znear defines the near clip plane
  4806. * @param zfar defines the far clip plane
  4807. * @param result defines the target matrix
  4808. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  4809. */
  4810. static PerspectiveFovWebVRToRef(fov: {
  4811. upDegrees: number;
  4812. downDegrees: number;
  4813. leftDegrees: number;
  4814. rightDegrees: number;
  4815. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  4816. /**
  4817. * Computes a complete transformation matrix
  4818. * @param viewport defines the viewport to use
  4819. * @param world defines the world matrix
  4820. * @param view defines the view matrix
  4821. * @param projection defines the projection matrix
  4822. * @param zmin defines the near clip plane
  4823. * @param zmax defines the far clip plane
  4824. * @returns the transformation matrix
  4825. */
  4826. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  4827. /**
  4828. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  4829. * @param matrix defines the matrix to use
  4830. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  4831. */
  4832. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4833. /**
  4834. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  4835. * @param matrix defines the matrix to use
  4836. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  4837. */
  4838. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  4839. /**
  4840. * Compute the transpose of a given matrix
  4841. * @param matrix defines the matrix to transpose
  4842. * @returns the new matrix
  4843. */
  4844. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  4845. /**
  4846. * Compute the transpose of a matrix and store it in a target matrix
  4847. * @param matrix defines the matrix to transpose
  4848. * @param result defines the target matrix
  4849. */
  4850. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  4851. /**
  4852. * Computes a reflection matrix from a plane
  4853. * @param plane defines the reflection plane
  4854. * @returns a new matrix
  4855. */
  4856. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  4857. /**
  4858. * Computes a reflection matrix from a plane
  4859. * @param plane defines the reflection plane
  4860. * @param result defines the target matrix
  4861. */
  4862. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  4863. /**
  4864. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  4865. * @param xaxis defines the value of the 1st axis
  4866. * @param yaxis defines the value of the 2nd axis
  4867. * @param zaxis defines the value of the 3rd axis
  4868. * @param result defines the target matrix
  4869. */
  4870. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  4871. /**
  4872. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  4873. * @param quat defines the quaternion to use
  4874. * @param result defines the target matrix
  4875. */
  4876. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  4877. }
  4878. /**
  4879. * @hidden
  4880. */
  4881. export class TmpVectors {
  4882. static Vector2: Vector2[];
  4883. static Vector3: Vector3[];
  4884. static Vector4: Vector4[];
  4885. static Quaternion: Quaternion[];
  4886. static Matrix: Matrix[];
  4887. }
  4888. }
  4889. declare module "babylonjs/Maths/math.path" {
  4890. import { DeepImmutable, Nullable } from "babylonjs/types";
  4891. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  4892. /**
  4893. * Defines potential orientation for back face culling
  4894. */
  4895. export enum Orientation {
  4896. /**
  4897. * Clockwise
  4898. */
  4899. CW = 0,
  4900. /** Counter clockwise */
  4901. CCW = 1
  4902. }
  4903. /** Class used to represent a Bezier curve */
  4904. export class BezierCurve {
  4905. /**
  4906. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  4907. * @param t defines the time
  4908. * @param x1 defines the left coordinate on X axis
  4909. * @param y1 defines the left coordinate on Y axis
  4910. * @param x2 defines the right coordinate on X axis
  4911. * @param y2 defines the right coordinate on Y axis
  4912. * @returns the interpolated value
  4913. */
  4914. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  4915. }
  4916. /**
  4917. * Defines angle representation
  4918. */
  4919. export class Angle {
  4920. private _radians;
  4921. /**
  4922. * Creates an Angle object of "radians" radians (float).
  4923. * @param radians the angle in radians
  4924. */
  4925. constructor(radians: number);
  4926. /**
  4927. * Get value in degrees
  4928. * @returns the Angle value in degrees (float)
  4929. */
  4930. degrees(): number;
  4931. /**
  4932. * Get value in radians
  4933. * @returns the Angle value in radians (float)
  4934. */
  4935. radians(): number;
  4936. /**
  4937. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  4938. * @param a defines first point as the origin
  4939. * @param b defines point
  4940. * @returns a new Angle
  4941. */
  4942. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  4943. /**
  4944. * Gets a new Angle object from the given float in radians
  4945. * @param radians defines the angle value in radians
  4946. * @returns a new Angle
  4947. */
  4948. static FromRadians(radians: number): Angle;
  4949. /**
  4950. * Gets a new Angle object from the given float in degrees
  4951. * @param degrees defines the angle value in degrees
  4952. * @returns a new Angle
  4953. */
  4954. static FromDegrees(degrees: number): Angle;
  4955. }
  4956. /**
  4957. * This represents an arc in a 2d space.
  4958. */
  4959. export class Arc2 {
  4960. /** Defines the start point of the arc */
  4961. startPoint: Vector2;
  4962. /** Defines the mid point of the arc */
  4963. midPoint: Vector2;
  4964. /** Defines the end point of the arc */
  4965. endPoint: Vector2;
  4966. /**
  4967. * Defines the center point of the arc.
  4968. */
  4969. centerPoint: Vector2;
  4970. /**
  4971. * Defines the radius of the arc.
  4972. */
  4973. radius: number;
  4974. /**
  4975. * Defines the angle of the arc (from mid point to end point).
  4976. */
  4977. angle: Angle;
  4978. /**
  4979. * Defines the start angle of the arc (from start point to middle point).
  4980. */
  4981. startAngle: Angle;
  4982. /**
  4983. * Defines the orientation of the arc (clock wise/counter clock wise).
  4984. */
  4985. orientation: Orientation;
  4986. /**
  4987. * Creates an Arc object from the three given points : start, middle and end.
  4988. * @param startPoint Defines the start point of the arc
  4989. * @param midPoint Defines the midlle point of the arc
  4990. * @param endPoint Defines the end point of the arc
  4991. */
  4992. constructor(
  4993. /** Defines the start point of the arc */
  4994. startPoint: Vector2,
  4995. /** Defines the mid point of the arc */
  4996. midPoint: Vector2,
  4997. /** Defines the end point of the arc */
  4998. endPoint: Vector2);
  4999. }
  5000. /**
  5001. * Represents a 2D path made up of multiple 2D points
  5002. */
  5003. export class Path2 {
  5004. private _points;
  5005. private _length;
  5006. /**
  5007. * If the path start and end point are the same
  5008. */
  5009. closed: boolean;
  5010. /**
  5011. * Creates a Path2 object from the starting 2D coordinates x and y.
  5012. * @param x the starting points x value
  5013. * @param y the starting points y value
  5014. */
  5015. constructor(x: number, y: number);
  5016. /**
  5017. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  5018. * @param x the added points x value
  5019. * @param y the added points y value
  5020. * @returns the updated Path2.
  5021. */
  5022. addLineTo(x: number, y: number): Path2;
  5023. /**
  5024. * 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.
  5025. * @param midX middle point x value
  5026. * @param midY middle point y value
  5027. * @param endX end point x value
  5028. * @param endY end point y value
  5029. * @param numberOfSegments (default: 36)
  5030. * @returns the updated Path2.
  5031. */
  5032. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  5033. /**
  5034. * Closes the Path2.
  5035. * @returns the Path2.
  5036. */
  5037. close(): Path2;
  5038. /**
  5039. * Gets the sum of the distance between each sequential point in the path
  5040. * @returns the Path2 total length (float).
  5041. */
  5042. length(): number;
  5043. /**
  5044. * Gets the points which construct the path
  5045. * @returns the Path2 internal array of points.
  5046. */
  5047. getPoints(): Vector2[];
  5048. /**
  5049. * Retreives the point at the distance aways from the starting point
  5050. * @param normalizedLengthPosition the length along the path to retreive the point from
  5051. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  5052. */
  5053. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  5054. /**
  5055. * Creates a new path starting from an x and y position
  5056. * @param x starting x value
  5057. * @param y starting y value
  5058. * @returns a new Path2 starting at the coordinates (x, y).
  5059. */
  5060. static StartingAt(x: number, y: number): Path2;
  5061. }
  5062. /**
  5063. * Represents a 3D path made up of multiple 3D points
  5064. */
  5065. export class Path3D {
  5066. /**
  5067. * an array of Vector3, the curve axis of the Path3D
  5068. */
  5069. path: Vector3[];
  5070. private _curve;
  5071. private _distances;
  5072. private _tangents;
  5073. private _normals;
  5074. private _binormals;
  5075. private _raw;
  5076. private _alignTangentsWithPath;
  5077. private readonly _pointAtData;
  5078. /**
  5079. * new Path3D(path, normal, raw)
  5080. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  5081. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  5082. * @param path an array of Vector3, the curve axis of the Path3D
  5083. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  5084. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  5085. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  5086. */
  5087. constructor(
  5088. /**
  5089. * an array of Vector3, the curve axis of the Path3D
  5090. */
  5091. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  5092. /**
  5093. * Returns the Path3D array of successive Vector3 designing its curve.
  5094. * @returns the Path3D array of successive Vector3 designing its curve.
  5095. */
  5096. getCurve(): Vector3[];
  5097. /**
  5098. * Returns the Path3D array of successive Vector3 designing its curve.
  5099. * @returns the Path3D array of successive Vector3 designing its curve.
  5100. */
  5101. getPoints(): Vector3[];
  5102. /**
  5103. * @returns the computed length (float) of the path.
  5104. */
  5105. length(): number;
  5106. /**
  5107. * Returns an array populated with tangent vectors on each Path3D curve point.
  5108. * @returns an array populated with tangent vectors on each Path3D curve point.
  5109. */
  5110. getTangents(): Vector3[];
  5111. /**
  5112. * Returns an array populated with normal vectors on each Path3D curve point.
  5113. * @returns an array populated with normal vectors on each Path3D curve point.
  5114. */
  5115. getNormals(): Vector3[];
  5116. /**
  5117. * Returns an array populated with binormal vectors on each Path3D curve point.
  5118. * @returns an array populated with binormal vectors on each Path3D curve point.
  5119. */
  5120. getBinormals(): Vector3[];
  5121. /**
  5122. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  5123. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  5124. */
  5125. getDistances(): number[];
  5126. /**
  5127. * Returns an interpolated point along this path
  5128. * @param position the position of the point along this path, from 0.0 to 1.0
  5129. * @returns a new Vector3 as the point
  5130. */
  5131. getPointAt(position: number): Vector3;
  5132. /**
  5133. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5134. * @param position the position of the point along this path, from 0.0 to 1.0
  5135. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  5136. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  5137. */
  5138. getTangentAt(position: number, interpolated?: boolean): Vector3;
  5139. /**
  5140. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  5141. * @param position the position of the point along this path, from 0.0 to 1.0
  5142. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  5143. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  5144. */
  5145. getNormalAt(position: number, interpolated?: boolean): Vector3;
  5146. /**
  5147. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  5148. * @param position the position of the point along this path, from 0.0 to 1.0
  5149. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  5150. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  5151. */
  5152. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  5153. /**
  5154. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  5155. * @param position the position of the point along this path, from 0.0 to 1.0
  5156. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  5157. */
  5158. getDistanceAt(position: number): number;
  5159. /**
  5160. * Returns the array index of the previous point of an interpolated point along this path
  5161. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5162. * @returns the array index
  5163. */
  5164. getPreviousPointIndexAt(position: number): number;
  5165. /**
  5166. * 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)
  5167. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  5168. * @returns the sub position
  5169. */
  5170. getSubPositionAt(position: number): number;
  5171. /**
  5172. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  5173. * @param target the vector of which to get the closest position to
  5174. * @returns the position of the closest virtual point on this path to the target vector
  5175. */
  5176. getClosestPositionTo(target: Vector3): number;
  5177. /**
  5178. * Returns a sub path (slice) of this path
  5179. * @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
  5180. * @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
  5181. * @returns a sub path (slice) of this path
  5182. */
  5183. slice(start?: number, end?: number): Path3D;
  5184. /**
  5185. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  5186. * @param path path which all values are copied into the curves points
  5187. * @param firstNormal which should be projected onto the curve
  5188. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  5189. * @returns the same object updated.
  5190. */
  5191. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  5192. private _compute;
  5193. private _getFirstNonNullVector;
  5194. private _getLastNonNullVector;
  5195. private _normalVector;
  5196. /**
  5197. * Updates the point at data for an interpolated point along this curve
  5198. * @param position the position of the point along this curve, from 0.0 to 1.0
  5199. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  5200. * @returns the (updated) point at data
  5201. */
  5202. private _updatePointAtData;
  5203. /**
  5204. * Updates the point at data from the specified parameters
  5205. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  5206. * @param point the interpolated point
  5207. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  5208. */
  5209. private _setPointAtData;
  5210. /**
  5211. * Updates the point at interpolation matrix for the tangents, normals and binormals
  5212. */
  5213. private _updateInterpolationMatrix;
  5214. }
  5215. /**
  5216. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5217. * A Curve3 is designed from a series of successive Vector3.
  5218. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  5219. */
  5220. export class Curve3 {
  5221. private _points;
  5222. private _length;
  5223. /**
  5224. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  5225. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  5226. * @param v1 (Vector3) the control point
  5227. * @param v2 (Vector3) the end point of the Quadratic Bezier
  5228. * @param nbPoints (integer) the wanted number of points in the curve
  5229. * @returns the created Curve3
  5230. */
  5231. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5232. /**
  5233. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  5234. * @param v0 (Vector3) the origin point of the Cubic Bezier
  5235. * @param v1 (Vector3) the first control point
  5236. * @param v2 (Vector3) the second control point
  5237. * @param v3 (Vector3) the end point of the Cubic Bezier
  5238. * @param nbPoints (integer) the wanted number of points in the curve
  5239. * @returns the created Curve3
  5240. */
  5241. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5242. /**
  5243. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  5244. * @param p1 (Vector3) the origin point of the Hermite Spline
  5245. * @param t1 (Vector3) the tangent vector at the origin point
  5246. * @param p2 (Vector3) the end point of the Hermite Spline
  5247. * @param t2 (Vector3) the tangent vector at the end point
  5248. * @param nbPoints (integer) the wanted number of points in the curve
  5249. * @returns the created Curve3
  5250. */
  5251. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  5252. /**
  5253. * Returns a Curve3 object along a CatmullRom Spline curve :
  5254. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  5255. * @param nbPoints (integer) the wanted number of points between each curve control points
  5256. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  5257. * @returns the created Curve3
  5258. */
  5259. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  5260. /**
  5261. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  5262. * A Curve3 is designed from a series of successive Vector3.
  5263. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  5264. * @param points points which make up the curve
  5265. */
  5266. constructor(points: Vector3[]);
  5267. /**
  5268. * @returns the Curve3 stored array of successive Vector3
  5269. */
  5270. getPoints(): Vector3[];
  5271. /**
  5272. * @returns the computed length (float) of the curve.
  5273. */
  5274. length(): number;
  5275. /**
  5276. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  5277. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  5278. * curveA and curveB keep unchanged.
  5279. * @param curve the curve to continue from this curve
  5280. * @returns the newly constructed curve
  5281. */
  5282. continue(curve: DeepImmutable<Curve3>): Curve3;
  5283. private _computeLength;
  5284. }
  5285. }
  5286. declare module "babylonjs/Animations/easing" {
  5287. /**
  5288. * This represents the main contract an easing function should follow.
  5289. * Easing functions are used throughout the animation system.
  5290. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5291. */
  5292. export interface IEasingFunction {
  5293. /**
  5294. * Given an input gradient between 0 and 1, this returns the corrseponding value
  5295. * of the easing function.
  5296. * The link below provides some of the most common examples of easing functions.
  5297. * @see https://easings.net/
  5298. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5299. * @returns the corresponding value on the curve defined by the easing function
  5300. */
  5301. ease(gradient: number): number;
  5302. }
  5303. /**
  5304. * Base class used for every default easing function.
  5305. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5306. */
  5307. export class EasingFunction implements IEasingFunction {
  5308. /**
  5309. * Interpolation follows the mathematical formula associated with the easing function.
  5310. */
  5311. static readonly EASINGMODE_EASEIN: number;
  5312. /**
  5313. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  5314. */
  5315. static readonly EASINGMODE_EASEOUT: number;
  5316. /**
  5317. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  5318. */
  5319. static readonly EASINGMODE_EASEINOUT: number;
  5320. private _easingMode;
  5321. /**
  5322. * Sets the easing mode of the current function.
  5323. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  5324. */
  5325. setEasingMode(easingMode: number): void;
  5326. /**
  5327. * Gets the current easing mode.
  5328. * @returns the easing mode
  5329. */
  5330. getEasingMode(): number;
  5331. /**
  5332. * @hidden
  5333. */
  5334. easeInCore(gradient: number): number;
  5335. /**
  5336. * Given an input gradient between 0 and 1, this returns the corresponding value
  5337. * of the easing function.
  5338. * @param gradient Defines the value between 0 and 1 we want the easing value for
  5339. * @returns the corresponding value on the curve defined by the easing function
  5340. */
  5341. ease(gradient: number): number;
  5342. }
  5343. /**
  5344. * Easing function with a circle shape (see link below).
  5345. * @see https://easings.net/#easeInCirc
  5346. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5347. */
  5348. export class CircleEase extends EasingFunction implements IEasingFunction {
  5349. /** @hidden */
  5350. easeInCore(gradient: number): number;
  5351. }
  5352. /**
  5353. * Easing function with a ease back shape (see link below).
  5354. * @see https://easings.net/#easeInBack
  5355. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5356. */
  5357. export class BackEase extends EasingFunction implements IEasingFunction {
  5358. /** Defines the amplitude of the function */
  5359. amplitude: number;
  5360. /**
  5361. * Instantiates a back ease easing
  5362. * @see https://easings.net/#easeInBack
  5363. * @param amplitude Defines the amplitude of the function
  5364. */
  5365. constructor(
  5366. /** Defines the amplitude of the function */
  5367. amplitude?: number);
  5368. /** @hidden */
  5369. easeInCore(gradient: number): number;
  5370. }
  5371. /**
  5372. * Easing function with a bouncing shape (see link below).
  5373. * @see https://easings.net/#easeInBounce
  5374. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5375. */
  5376. export class BounceEase extends EasingFunction implements IEasingFunction {
  5377. /** Defines the number of bounces */
  5378. bounces: number;
  5379. /** Defines the amplitude of the bounce */
  5380. bounciness: number;
  5381. /**
  5382. * Instantiates a bounce easing
  5383. * @see https://easings.net/#easeInBounce
  5384. * @param bounces Defines the number of bounces
  5385. * @param bounciness Defines the amplitude of the bounce
  5386. */
  5387. constructor(
  5388. /** Defines the number of bounces */
  5389. bounces?: number,
  5390. /** Defines the amplitude of the bounce */
  5391. bounciness?: number);
  5392. /** @hidden */
  5393. easeInCore(gradient: number): number;
  5394. }
  5395. /**
  5396. * Easing function with a power of 3 shape (see link below).
  5397. * @see https://easings.net/#easeInCubic
  5398. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5399. */
  5400. export class CubicEase extends EasingFunction implements IEasingFunction {
  5401. /** @hidden */
  5402. easeInCore(gradient: number): number;
  5403. }
  5404. /**
  5405. * Easing function with an elastic shape (see link below).
  5406. * @see https://easings.net/#easeInElastic
  5407. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5408. */
  5409. export class ElasticEase extends EasingFunction implements IEasingFunction {
  5410. /** Defines the number of oscillations*/
  5411. oscillations: number;
  5412. /** Defines the amplitude of the oscillations*/
  5413. springiness: number;
  5414. /**
  5415. * Instantiates an elastic easing function
  5416. * @see https://easings.net/#easeInElastic
  5417. * @param oscillations Defines the number of oscillations
  5418. * @param springiness Defines the amplitude of the oscillations
  5419. */
  5420. constructor(
  5421. /** Defines the number of oscillations*/
  5422. oscillations?: number,
  5423. /** Defines the amplitude of the oscillations*/
  5424. springiness?: number);
  5425. /** @hidden */
  5426. easeInCore(gradient: number): number;
  5427. }
  5428. /**
  5429. * Easing function with an exponential shape (see link below).
  5430. * @see https://easings.net/#easeInExpo
  5431. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5432. */
  5433. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  5434. /** Defines the exponent of the function */
  5435. exponent: number;
  5436. /**
  5437. * Instantiates an exponential easing function
  5438. * @see https://easings.net/#easeInExpo
  5439. * @param exponent Defines the exponent of the function
  5440. */
  5441. constructor(
  5442. /** Defines the exponent of the function */
  5443. exponent?: number);
  5444. /** @hidden */
  5445. easeInCore(gradient: number): number;
  5446. }
  5447. /**
  5448. * Easing function with a power shape (see link below).
  5449. * @see https://easings.net/#easeInQuad
  5450. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5451. */
  5452. export class PowerEase extends EasingFunction implements IEasingFunction {
  5453. /** Defines the power of the function */
  5454. power: number;
  5455. /**
  5456. * Instantiates an power base easing function
  5457. * @see https://easings.net/#easeInQuad
  5458. * @param power Defines the power of the function
  5459. */
  5460. constructor(
  5461. /** Defines the power of the function */
  5462. power?: number);
  5463. /** @hidden */
  5464. easeInCore(gradient: number): number;
  5465. }
  5466. /**
  5467. * Easing function with a power of 2 shape (see link below).
  5468. * @see https://easings.net/#easeInQuad
  5469. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5470. */
  5471. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  5472. /** @hidden */
  5473. easeInCore(gradient: number): number;
  5474. }
  5475. /**
  5476. * Easing function with a power of 4 shape (see link below).
  5477. * @see https://easings.net/#easeInQuart
  5478. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5479. */
  5480. export class QuarticEase extends EasingFunction implements IEasingFunction {
  5481. /** @hidden */
  5482. easeInCore(gradient: number): number;
  5483. }
  5484. /**
  5485. * Easing function with a power of 5 shape (see link below).
  5486. * @see https://easings.net/#easeInQuint
  5487. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5488. */
  5489. export class QuinticEase extends EasingFunction implements IEasingFunction {
  5490. /** @hidden */
  5491. easeInCore(gradient: number): number;
  5492. }
  5493. /**
  5494. * Easing function with a sin shape (see link below).
  5495. * @see https://easings.net/#easeInSine
  5496. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5497. */
  5498. export class SineEase extends EasingFunction implements IEasingFunction {
  5499. /** @hidden */
  5500. easeInCore(gradient: number): number;
  5501. }
  5502. /**
  5503. * Easing function with a bezier shape (see link below).
  5504. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5505. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  5506. */
  5507. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  5508. /** Defines the x component of the start tangent in the bezier curve */
  5509. x1: number;
  5510. /** Defines the y component of the start tangent in the bezier curve */
  5511. y1: number;
  5512. /** Defines the x component of the end tangent in the bezier curve */
  5513. x2: number;
  5514. /** Defines the y component of the end tangent in the bezier curve */
  5515. y2: number;
  5516. /**
  5517. * Instantiates a bezier function
  5518. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  5519. * @param x1 Defines the x component of the start tangent in the bezier curve
  5520. * @param y1 Defines the y component of the start tangent in the bezier curve
  5521. * @param x2 Defines the x component of the end tangent in the bezier curve
  5522. * @param y2 Defines the y component of the end tangent in the bezier curve
  5523. */
  5524. constructor(
  5525. /** Defines the x component of the start tangent in the bezier curve */
  5526. x1?: number,
  5527. /** Defines the y component of the start tangent in the bezier curve */
  5528. y1?: number,
  5529. /** Defines the x component of the end tangent in the bezier curve */
  5530. x2?: number,
  5531. /** Defines the y component of the end tangent in the bezier curve */
  5532. y2?: number);
  5533. /** @hidden */
  5534. easeInCore(gradient: number): number;
  5535. }
  5536. }
  5537. declare module "babylonjs/Maths/math.color" {
  5538. import { DeepImmutable, FloatArray } from "babylonjs/types";
  5539. /**
  5540. * Class used to hold a RBG color
  5541. */
  5542. export class Color3 {
  5543. /**
  5544. * Defines the red component (between 0 and 1, default is 0)
  5545. */
  5546. r: number;
  5547. /**
  5548. * Defines the green component (between 0 and 1, default is 0)
  5549. */
  5550. g: number;
  5551. /**
  5552. * Defines the blue component (between 0 and 1, default is 0)
  5553. */
  5554. b: number;
  5555. /**
  5556. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  5557. * @param r defines the red component (between 0 and 1, default is 0)
  5558. * @param g defines the green component (between 0 and 1, default is 0)
  5559. * @param b defines the blue component (between 0 and 1, default is 0)
  5560. */
  5561. constructor(
  5562. /**
  5563. * Defines the red component (between 0 and 1, default is 0)
  5564. */
  5565. r?: number,
  5566. /**
  5567. * Defines the green component (between 0 and 1, default is 0)
  5568. */
  5569. g?: number,
  5570. /**
  5571. * Defines the blue component (between 0 and 1, default is 0)
  5572. */
  5573. b?: number);
  5574. /**
  5575. * Creates a string with the Color3 current values
  5576. * @returns the string representation of the Color3 object
  5577. */
  5578. toString(): string;
  5579. /**
  5580. * Returns the string "Color3"
  5581. * @returns "Color3"
  5582. */
  5583. getClassName(): string;
  5584. /**
  5585. * Compute the Color3 hash code
  5586. * @returns an unique number that can be used to hash Color3 objects
  5587. */
  5588. getHashCode(): number;
  5589. /**
  5590. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  5591. * @param array defines the array where to store the r,g,b components
  5592. * @param index defines an optional index in the target array to define where to start storing values
  5593. * @returns the current Color3 object
  5594. */
  5595. toArray(array: FloatArray, index?: number): Color3;
  5596. /**
  5597. * Update the current color with values stored in an array from the starting index of the given array
  5598. * @param array defines the source array
  5599. * @param offset defines an offset in the source array
  5600. * @returns the current Color3 object
  5601. */
  5602. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5603. /**
  5604. * Returns a new Color4 object from the current Color3 and the given alpha
  5605. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  5606. * @returns a new Color4 object
  5607. */
  5608. toColor4(alpha?: number): Color4;
  5609. /**
  5610. * Returns a new array populated with 3 numeric elements : red, green and blue values
  5611. * @returns the new array
  5612. */
  5613. asArray(): number[];
  5614. /**
  5615. * Returns the luminance value
  5616. * @returns a float value
  5617. */
  5618. toLuminance(): number;
  5619. /**
  5620. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  5621. * @param otherColor defines the second operand
  5622. * @returns the new Color3 object
  5623. */
  5624. multiply(otherColor: DeepImmutable<Color3>): Color3;
  5625. /**
  5626. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  5627. * @param otherColor defines the second operand
  5628. * @param result defines the Color3 object where to store the result
  5629. * @returns the current Color3
  5630. */
  5631. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5632. /**
  5633. * Determines equality between Color3 objects
  5634. * @param otherColor defines the second operand
  5635. * @returns true if the rgb values are equal to the given ones
  5636. */
  5637. equals(otherColor: DeepImmutable<Color3>): boolean;
  5638. /**
  5639. * Determines equality between the current Color3 object and a set of r,b,g values
  5640. * @param r defines the red component to check
  5641. * @param g defines the green component to check
  5642. * @param b defines the blue component to check
  5643. * @returns true if the rgb values are equal to the given ones
  5644. */
  5645. equalsFloats(r: number, g: number, b: number): boolean;
  5646. /**
  5647. * Multiplies in place each rgb value by scale
  5648. * @param scale defines the scaling factor
  5649. * @returns the updated Color3
  5650. */
  5651. scale(scale: number): Color3;
  5652. /**
  5653. * Multiplies the rgb values by scale and stores the result into "result"
  5654. * @param scale defines the scaling factor
  5655. * @param result defines the Color3 object where to store the result
  5656. * @returns the unmodified current Color3
  5657. */
  5658. scaleToRef(scale: number, result: Color3): Color3;
  5659. /**
  5660. * Scale the current Color3 values by a factor and add the result to a given Color3
  5661. * @param scale defines the scale factor
  5662. * @param result defines color to store the result into
  5663. * @returns the unmodified current Color3
  5664. */
  5665. scaleAndAddToRef(scale: number, result: Color3): Color3;
  5666. /**
  5667. * Clamps the rgb values by the min and max values and stores the result into "result"
  5668. * @param min defines minimum clamping value (default is 0)
  5669. * @param max defines maximum clamping value (default is 1)
  5670. * @param result defines color to store the result into
  5671. * @returns the original Color3
  5672. */
  5673. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  5674. /**
  5675. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  5676. * @param otherColor defines the second operand
  5677. * @returns the new Color3
  5678. */
  5679. add(otherColor: DeepImmutable<Color3>): Color3;
  5680. /**
  5681. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  5682. * @param otherColor defines the second operand
  5683. * @param result defines Color3 object to store the result into
  5684. * @returns the unmodified current Color3
  5685. */
  5686. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5687. /**
  5688. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  5689. * @param otherColor defines the second operand
  5690. * @returns the new Color3
  5691. */
  5692. subtract(otherColor: DeepImmutable<Color3>): Color3;
  5693. /**
  5694. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  5695. * @param otherColor defines the second operand
  5696. * @param result defines Color3 object to store the result into
  5697. * @returns the unmodified current Color3
  5698. */
  5699. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  5700. /**
  5701. * Copy the current object
  5702. * @returns a new Color3 copied the current one
  5703. */
  5704. clone(): Color3;
  5705. /**
  5706. * Copies the rgb values from the source in the current Color3
  5707. * @param source defines the source Color3 object
  5708. * @returns the updated Color3 object
  5709. */
  5710. copyFrom(source: DeepImmutable<Color3>): Color3;
  5711. /**
  5712. * Updates the Color3 rgb values from the given floats
  5713. * @param r defines the red component to read from
  5714. * @param g defines the green component to read from
  5715. * @param b defines the blue component to read from
  5716. * @returns the current Color3 object
  5717. */
  5718. copyFromFloats(r: number, g: number, b: number): Color3;
  5719. /**
  5720. * Updates the Color3 rgb values from the given floats
  5721. * @param r defines the red component to read from
  5722. * @param g defines the green component to read from
  5723. * @param b defines the blue component to read from
  5724. * @returns the current Color3 object
  5725. */
  5726. set(r: number, g: number, b: number): Color3;
  5727. /**
  5728. * Compute the Color3 hexadecimal code as a string
  5729. * @returns a string containing the hexadecimal representation of the Color3 object
  5730. */
  5731. toHexString(): string;
  5732. /**
  5733. * Computes a new Color3 converted from the current one to linear space
  5734. * @returns a new Color3 object
  5735. */
  5736. toLinearSpace(): Color3;
  5737. /**
  5738. * Converts current color in rgb space to HSV values
  5739. * @returns a new color3 representing the HSV values
  5740. */
  5741. toHSV(): Color3;
  5742. /**
  5743. * Converts current color in rgb space to HSV values
  5744. * @param result defines the Color3 where to store the HSV values
  5745. */
  5746. toHSVToRef(result: Color3): void;
  5747. /**
  5748. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  5749. * @param convertedColor defines the Color3 object where to store the linear space version
  5750. * @returns the unmodified Color3
  5751. */
  5752. toLinearSpaceToRef(convertedColor: Color3): Color3;
  5753. /**
  5754. * Computes a new Color3 converted from the current one to gamma space
  5755. * @returns a new Color3 object
  5756. */
  5757. toGammaSpace(): Color3;
  5758. /**
  5759. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  5760. * @param convertedColor defines the Color3 object where to store the gamma space version
  5761. * @returns the unmodified Color3
  5762. */
  5763. toGammaSpaceToRef(convertedColor: Color3): Color3;
  5764. private static _BlackReadOnly;
  5765. /**
  5766. * Convert Hue, saturation and value to a Color3 (RGB)
  5767. * @param hue defines the hue
  5768. * @param saturation defines the saturation
  5769. * @param value defines the value
  5770. * @param result defines the Color3 where to store the RGB values
  5771. */
  5772. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  5773. /**
  5774. * Creates a new Color3 from the string containing valid hexadecimal values
  5775. * @param hex defines a string containing valid hexadecimal values
  5776. * @returns a new Color3 object
  5777. */
  5778. static FromHexString(hex: string): Color3;
  5779. /**
  5780. * Creates a new Color3 from the starting index of the given array
  5781. * @param array defines the source array
  5782. * @param offset defines an offset in the source array
  5783. * @returns a new Color3 object
  5784. */
  5785. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  5786. /**
  5787. * Creates a new Color3 from the starting index element of the given array
  5788. * @param array defines the source array to read from
  5789. * @param offset defines the offset in the source array
  5790. * @param result defines the target Color3 object
  5791. */
  5792. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  5793. /**
  5794. * Creates a new Color3 from integer values (< 256)
  5795. * @param r defines the red component to read from (value between 0 and 255)
  5796. * @param g defines the green component to read from (value between 0 and 255)
  5797. * @param b defines the blue component to read from (value between 0 and 255)
  5798. * @returns a new Color3 object
  5799. */
  5800. static FromInts(r: number, g: number, b: number): Color3;
  5801. /**
  5802. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5803. * @param start defines the start Color3 value
  5804. * @param end defines the end Color3 value
  5805. * @param amount defines the gradient value between start and end
  5806. * @returns a new Color3 object
  5807. */
  5808. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  5809. /**
  5810. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  5811. * @param left defines the start value
  5812. * @param right defines the end value
  5813. * @param amount defines the gradient factor
  5814. * @param result defines the Color3 object where to store the result
  5815. */
  5816. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  5817. /**
  5818. * Returns a Color3 value containing a red color
  5819. * @returns a new Color3 object
  5820. */
  5821. static Red(): Color3;
  5822. /**
  5823. * Returns a Color3 value containing a green color
  5824. * @returns a new Color3 object
  5825. */
  5826. static Green(): Color3;
  5827. /**
  5828. * Returns a Color3 value containing a blue color
  5829. * @returns a new Color3 object
  5830. */
  5831. static Blue(): Color3;
  5832. /**
  5833. * Returns a Color3 value containing a black color
  5834. * @returns a new Color3 object
  5835. */
  5836. static Black(): Color3;
  5837. /**
  5838. * Gets a Color3 value containing a black color that must not be updated
  5839. */
  5840. static get BlackReadOnly(): DeepImmutable<Color3>;
  5841. /**
  5842. * Returns a Color3 value containing a white color
  5843. * @returns a new Color3 object
  5844. */
  5845. static White(): Color3;
  5846. /**
  5847. * Returns a Color3 value containing a purple color
  5848. * @returns a new Color3 object
  5849. */
  5850. static Purple(): Color3;
  5851. /**
  5852. * Returns a Color3 value containing a magenta color
  5853. * @returns a new Color3 object
  5854. */
  5855. static Magenta(): Color3;
  5856. /**
  5857. * Returns a Color3 value containing a yellow color
  5858. * @returns a new Color3 object
  5859. */
  5860. static Yellow(): Color3;
  5861. /**
  5862. * Returns a Color3 value containing a gray color
  5863. * @returns a new Color3 object
  5864. */
  5865. static Gray(): Color3;
  5866. /**
  5867. * Returns a Color3 value containing a teal color
  5868. * @returns a new Color3 object
  5869. */
  5870. static Teal(): Color3;
  5871. /**
  5872. * Returns a Color3 value containing a random color
  5873. * @returns a new Color3 object
  5874. */
  5875. static Random(): Color3;
  5876. }
  5877. /**
  5878. * Class used to hold a RBGA color
  5879. */
  5880. export class Color4 {
  5881. /**
  5882. * Defines the red component (between 0 and 1, default is 0)
  5883. */
  5884. r: number;
  5885. /**
  5886. * Defines the green component (between 0 and 1, default is 0)
  5887. */
  5888. g: number;
  5889. /**
  5890. * Defines the blue component (between 0 and 1, default is 0)
  5891. */
  5892. b: number;
  5893. /**
  5894. * Defines the alpha component (between 0 and 1, default is 1)
  5895. */
  5896. a: number;
  5897. /**
  5898. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  5899. * @param r defines the red component (between 0 and 1, default is 0)
  5900. * @param g defines the green component (between 0 and 1, default is 0)
  5901. * @param b defines the blue component (between 0 and 1, default is 0)
  5902. * @param a defines the alpha component (between 0 and 1, default is 1)
  5903. */
  5904. constructor(
  5905. /**
  5906. * Defines the red component (between 0 and 1, default is 0)
  5907. */
  5908. r?: number,
  5909. /**
  5910. * Defines the green component (between 0 and 1, default is 0)
  5911. */
  5912. g?: number,
  5913. /**
  5914. * Defines the blue component (between 0 and 1, default is 0)
  5915. */
  5916. b?: number,
  5917. /**
  5918. * Defines the alpha component (between 0 and 1, default is 1)
  5919. */
  5920. a?: number);
  5921. /**
  5922. * Adds in place the given Color4 values to the current Color4 object
  5923. * @param right defines the second operand
  5924. * @returns the current updated Color4 object
  5925. */
  5926. addInPlace(right: DeepImmutable<Color4>): Color4;
  5927. /**
  5928. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  5929. * @returns the new array
  5930. */
  5931. asArray(): number[];
  5932. /**
  5933. * Stores from the starting index in the given array the Color4 successive values
  5934. * @param array defines the array where to store the r,g,b components
  5935. * @param index defines an optional index in the target array to define where to start storing values
  5936. * @returns the current Color4 object
  5937. */
  5938. toArray(array: number[], index?: number): Color4;
  5939. /**
  5940. * Update the current color with values stored in an array from the starting index of the given array
  5941. * @param array defines the source array
  5942. * @param offset defines an offset in the source array
  5943. * @returns the current Color4 object
  5944. */
  5945. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  5946. /**
  5947. * Determines equality between Color4 objects
  5948. * @param otherColor defines the second operand
  5949. * @returns true if the rgba values are equal to the given ones
  5950. */
  5951. equals(otherColor: DeepImmutable<Color4>): boolean;
  5952. /**
  5953. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  5954. * @param right defines the second operand
  5955. * @returns a new Color4 object
  5956. */
  5957. add(right: DeepImmutable<Color4>): Color4;
  5958. /**
  5959. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  5960. * @param right defines the second operand
  5961. * @returns a new Color4 object
  5962. */
  5963. subtract(right: DeepImmutable<Color4>): Color4;
  5964. /**
  5965. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  5966. * @param right defines the second operand
  5967. * @param result defines the Color4 object where to store the result
  5968. * @returns the current Color4 object
  5969. */
  5970. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  5971. /**
  5972. * Creates a new Color4 with the current Color4 values multiplied by scale
  5973. * @param scale defines the scaling factor to apply
  5974. * @returns a new Color4 object
  5975. */
  5976. scale(scale: number): Color4;
  5977. /**
  5978. * Multiplies the current Color4 values by scale and stores the result in "result"
  5979. * @param scale defines the scaling factor to apply
  5980. * @param result defines the Color4 object where to store the result
  5981. * @returns the current unmodified Color4
  5982. */
  5983. scaleToRef(scale: number, result: Color4): Color4;
  5984. /**
  5985. * Scale the current Color4 values by a factor and add the result to a given Color4
  5986. * @param scale defines the scale factor
  5987. * @param result defines the Color4 object where to store the result
  5988. * @returns the unmodified current Color4
  5989. */
  5990. scaleAndAddToRef(scale: number, result: Color4): Color4;
  5991. /**
  5992. * Clamps the rgb values by the min and max values and stores the result into "result"
  5993. * @param min defines minimum clamping value (default is 0)
  5994. * @param max defines maximum clamping value (default is 1)
  5995. * @param result defines color to store the result into.
  5996. * @returns the cuurent Color4
  5997. */
  5998. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  5999. /**
  6000. * Multipy an Color4 value by another and return a new Color4 object
  6001. * @param color defines the Color4 value to multiply by
  6002. * @returns a new Color4 object
  6003. */
  6004. multiply(color: Color4): Color4;
  6005. /**
  6006. * Multipy a Color4 value by another and push the result in a reference value
  6007. * @param color defines the Color4 value to multiply by
  6008. * @param result defines the Color4 to fill the result in
  6009. * @returns the result Color4
  6010. */
  6011. multiplyToRef(color: Color4, result: Color4): Color4;
  6012. /**
  6013. * Creates a string with the Color4 current values
  6014. * @returns the string representation of the Color4 object
  6015. */
  6016. toString(): string;
  6017. /**
  6018. * Returns the string "Color4"
  6019. * @returns "Color4"
  6020. */
  6021. getClassName(): string;
  6022. /**
  6023. * Compute the Color4 hash code
  6024. * @returns an unique number that can be used to hash Color4 objects
  6025. */
  6026. getHashCode(): number;
  6027. /**
  6028. * Creates a new Color4 copied from the current one
  6029. * @returns a new Color4 object
  6030. */
  6031. clone(): Color4;
  6032. /**
  6033. * Copies the given Color4 values into the current one
  6034. * @param source defines the source Color4 object
  6035. * @returns the current updated Color4 object
  6036. */
  6037. copyFrom(source: Color4): Color4;
  6038. /**
  6039. * Copies the given float values into the current one
  6040. * @param r defines the red component to read from
  6041. * @param g defines the green component to read from
  6042. * @param b defines the blue component to read from
  6043. * @param a defines the alpha component to read from
  6044. * @returns the current updated Color4 object
  6045. */
  6046. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  6047. /**
  6048. * Copies the given float values into the current one
  6049. * @param r defines the red component to read from
  6050. * @param g defines the green component to read from
  6051. * @param b defines the blue component to read from
  6052. * @param a defines the alpha component to read from
  6053. * @returns the current updated Color4 object
  6054. */
  6055. set(r: number, g: number, b: number, a: number): Color4;
  6056. /**
  6057. * Compute the Color4 hexadecimal code as a string
  6058. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  6059. * @returns a string containing the hexadecimal representation of the Color4 object
  6060. */
  6061. toHexString(returnAsColor3?: boolean): string;
  6062. /**
  6063. * Computes a new Color4 converted from the current one to linear space
  6064. * @returns a new Color4 object
  6065. */
  6066. toLinearSpace(): Color4;
  6067. /**
  6068. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  6069. * @param convertedColor defines the Color4 object where to store the linear space version
  6070. * @returns the unmodified Color4
  6071. */
  6072. toLinearSpaceToRef(convertedColor: Color4): Color4;
  6073. /**
  6074. * Computes a new Color4 converted from the current one to gamma space
  6075. * @returns a new Color4 object
  6076. */
  6077. toGammaSpace(): Color4;
  6078. /**
  6079. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  6080. * @param convertedColor defines the Color4 object where to store the gamma space version
  6081. * @returns the unmodified Color4
  6082. */
  6083. toGammaSpaceToRef(convertedColor: Color4): Color4;
  6084. /**
  6085. * Creates a new Color4 from the string containing valid hexadecimal values
  6086. * @param hex defines a string containing valid hexadecimal values
  6087. * @returns a new Color4 object
  6088. */
  6089. static FromHexString(hex: string): Color4;
  6090. /**
  6091. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6092. * @param left defines the start value
  6093. * @param right defines the end value
  6094. * @param amount defines the gradient factor
  6095. * @returns a new Color4 object
  6096. */
  6097. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  6098. /**
  6099. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  6100. * @param left defines the start value
  6101. * @param right defines the end value
  6102. * @param amount defines the gradient factor
  6103. * @param result defines the Color4 object where to store data
  6104. */
  6105. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  6106. /**
  6107. * Creates a new Color4 from a Color3 and an alpha value
  6108. * @param color3 defines the source Color3 to read from
  6109. * @param alpha defines the alpha component (1.0 by default)
  6110. * @returns a new Color4 object
  6111. */
  6112. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  6113. /**
  6114. * Creates a new Color4 from the starting index element of the given array
  6115. * @param array defines the source array to read from
  6116. * @param offset defines the offset in the source array
  6117. * @returns a new Color4 object
  6118. */
  6119. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  6120. /**
  6121. * Creates a new Color4 from the starting index element of the given array
  6122. * @param array defines the source array to read from
  6123. * @param offset defines the offset in the source array
  6124. * @param result defines the target Color4 object
  6125. */
  6126. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  6127. /**
  6128. * Creates a new Color3 from integer values (< 256)
  6129. * @param r defines the red component to read from (value between 0 and 255)
  6130. * @param g defines the green component to read from (value between 0 and 255)
  6131. * @param b defines the blue component to read from (value between 0 and 255)
  6132. * @param a defines the alpha component to read from (value between 0 and 255)
  6133. * @returns a new Color3 object
  6134. */
  6135. static FromInts(r: number, g: number, b: number, a: number): Color4;
  6136. /**
  6137. * Check the content of a given array and convert it to an array containing RGBA data
  6138. * If the original array was already containing count * 4 values then it is returned directly
  6139. * @param colors defines the array to check
  6140. * @param count defines the number of RGBA data to expect
  6141. * @returns an array containing count * 4 values (RGBA)
  6142. */
  6143. static CheckColors4(colors: number[], count: number): number[];
  6144. }
  6145. /**
  6146. * @hidden
  6147. */
  6148. export class TmpColors {
  6149. static Color3: Color3[];
  6150. static Color4: Color4[];
  6151. }
  6152. }
  6153. declare module "babylonjs/Animations/animationKey" {
  6154. /**
  6155. * Defines an interface which represents an animation key frame
  6156. */
  6157. export interface IAnimationKey {
  6158. /**
  6159. * Frame of the key frame
  6160. */
  6161. frame: number;
  6162. /**
  6163. * Value at the specifies key frame
  6164. */
  6165. value: any;
  6166. /**
  6167. * The input tangent for the cubic hermite spline
  6168. */
  6169. inTangent?: any;
  6170. /**
  6171. * The output tangent for the cubic hermite spline
  6172. */
  6173. outTangent?: any;
  6174. /**
  6175. * The animation interpolation type
  6176. */
  6177. interpolation?: AnimationKeyInterpolation;
  6178. }
  6179. /**
  6180. * Enum for the animation key frame interpolation type
  6181. */
  6182. export enum AnimationKeyInterpolation {
  6183. /**
  6184. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  6185. */
  6186. STEP = 1
  6187. }
  6188. }
  6189. declare module "babylonjs/Animations/animationRange" {
  6190. /**
  6191. * Represents the range of an animation
  6192. */
  6193. export class AnimationRange {
  6194. /**The name of the animation range**/
  6195. name: string;
  6196. /**The starting frame of the animation */
  6197. from: number;
  6198. /**The ending frame of the animation*/
  6199. to: number;
  6200. /**
  6201. * Initializes the range of an animation
  6202. * @param name The name of the animation range
  6203. * @param from The starting frame of the animation
  6204. * @param to The ending frame of the animation
  6205. */
  6206. constructor(
  6207. /**The name of the animation range**/
  6208. name: string,
  6209. /**The starting frame of the animation */
  6210. from: number,
  6211. /**The ending frame of the animation*/
  6212. to: number);
  6213. /**
  6214. * Makes a copy of the animation range
  6215. * @returns A copy of the animation range
  6216. */
  6217. clone(): AnimationRange;
  6218. }
  6219. }
  6220. declare module "babylonjs/Animations/animationEvent" {
  6221. /**
  6222. * Composed of a frame, and an action function
  6223. */
  6224. export class AnimationEvent {
  6225. /** The frame for which the event is triggered **/
  6226. frame: number;
  6227. /** The event to perform when triggered **/
  6228. action: (currentFrame: number) => void;
  6229. /** Specifies if the event should be triggered only once**/
  6230. onlyOnce?: boolean | undefined;
  6231. /**
  6232. * Specifies if the animation event is done
  6233. */
  6234. isDone: boolean;
  6235. /**
  6236. * Initializes the animation event
  6237. * @param frame The frame for which the event is triggered
  6238. * @param action The event to perform when triggered
  6239. * @param onlyOnce Specifies if the event should be triggered only once
  6240. */
  6241. constructor(
  6242. /** The frame for which the event is triggered **/
  6243. frame: number,
  6244. /** The event to perform when triggered **/
  6245. action: (currentFrame: number) => void,
  6246. /** Specifies if the event should be triggered only once**/
  6247. onlyOnce?: boolean | undefined);
  6248. /** @hidden */
  6249. _clone(): AnimationEvent;
  6250. }
  6251. }
  6252. declare module "babylonjs/Behaviors/behavior" {
  6253. import { Nullable } from "babylonjs/types";
  6254. /**
  6255. * Interface used to define a behavior
  6256. */
  6257. export interface Behavior<T> {
  6258. /** gets or sets behavior's name */
  6259. name: string;
  6260. /**
  6261. * Function called when the behavior needs to be initialized (after attaching it to a target)
  6262. */
  6263. init(): void;
  6264. /**
  6265. * Called when the behavior is attached to a target
  6266. * @param target defines the target where the behavior is attached to
  6267. */
  6268. attach(target: T): void;
  6269. /**
  6270. * Called when the behavior is detached from its target
  6271. */
  6272. detach(): void;
  6273. }
  6274. /**
  6275. * Interface implemented by classes supporting behaviors
  6276. */
  6277. export interface IBehaviorAware<T> {
  6278. /**
  6279. * Attach a behavior
  6280. * @param behavior defines the behavior to attach
  6281. * @returns the current host
  6282. */
  6283. addBehavior(behavior: Behavior<T>): T;
  6284. /**
  6285. * Remove a behavior from the current object
  6286. * @param behavior defines the behavior to detach
  6287. * @returns the current host
  6288. */
  6289. removeBehavior(behavior: Behavior<T>): T;
  6290. /**
  6291. * Gets a behavior using its name to search
  6292. * @param name defines the name to search
  6293. * @returns the behavior or null if not found
  6294. */
  6295. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  6296. }
  6297. }
  6298. declare module "babylonjs/Misc/smartArray" {
  6299. /**
  6300. * Defines an array and its length.
  6301. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  6302. */
  6303. export interface ISmartArrayLike<T> {
  6304. /**
  6305. * The data of the array.
  6306. */
  6307. data: Array<T>;
  6308. /**
  6309. * The active length of the array.
  6310. */
  6311. length: number;
  6312. }
  6313. /**
  6314. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6315. */
  6316. export class SmartArray<T> implements ISmartArrayLike<T> {
  6317. /**
  6318. * The full set of data from the array.
  6319. */
  6320. data: Array<T>;
  6321. /**
  6322. * The active length of the array.
  6323. */
  6324. length: number;
  6325. protected _id: number;
  6326. /**
  6327. * Instantiates a Smart Array.
  6328. * @param capacity defines the default capacity of the array.
  6329. */
  6330. constructor(capacity: number);
  6331. /**
  6332. * Pushes a value at the end of the active data.
  6333. * @param value defines the object to push in the array.
  6334. */
  6335. push(value: T): void;
  6336. /**
  6337. * Iterates over the active data and apply the lambda to them.
  6338. * @param func defines the action to apply on each value.
  6339. */
  6340. forEach(func: (content: T) => void): void;
  6341. /**
  6342. * Sorts the full sets of data.
  6343. * @param compareFn defines the comparison function to apply.
  6344. */
  6345. sort(compareFn: (a: T, b: T) => number): void;
  6346. /**
  6347. * Resets the active data to an empty array.
  6348. */
  6349. reset(): void;
  6350. /**
  6351. * Releases all the data from the array as well as the array.
  6352. */
  6353. dispose(): void;
  6354. /**
  6355. * Concats the active data with a given array.
  6356. * @param array defines the data to concatenate with.
  6357. */
  6358. concat(array: any): void;
  6359. /**
  6360. * Returns the position of a value in the active data.
  6361. * @param value defines the value to find the index for
  6362. * @returns the index if found in the active data otherwise -1
  6363. */
  6364. indexOf(value: T): number;
  6365. /**
  6366. * Returns whether an element is part of the active data.
  6367. * @param value defines the value to look for
  6368. * @returns true if found in the active data otherwise false
  6369. */
  6370. contains(value: T): boolean;
  6371. private static _GlobalId;
  6372. }
  6373. /**
  6374. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  6375. * The data in this array can only be present once
  6376. */
  6377. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  6378. private _duplicateId;
  6379. /**
  6380. * Pushes a value at the end of the active data.
  6381. * THIS DOES NOT PREVENT DUPPLICATE DATA
  6382. * @param value defines the object to push in the array.
  6383. */
  6384. push(value: T): void;
  6385. /**
  6386. * Pushes a value at the end of the active data.
  6387. * If the data is already present, it won t be added again
  6388. * @param value defines the object to push in the array.
  6389. * @returns true if added false if it was already present
  6390. */
  6391. pushNoDuplicate(value: T): boolean;
  6392. /**
  6393. * Resets the active data to an empty array.
  6394. */
  6395. reset(): void;
  6396. /**
  6397. * Concats the active data with a given array.
  6398. * This ensures no dupplicate will be present in the result.
  6399. * @param array defines the data to concatenate with.
  6400. */
  6401. concatWithNoDuplicate(array: any): void;
  6402. }
  6403. }
  6404. declare module "babylonjs/Cameras/cameraInputsManager" {
  6405. import { Nullable } from "babylonjs/types";
  6406. import { Camera } from "babylonjs/Cameras/camera";
  6407. /**
  6408. * @ignore
  6409. * This is a list of all the different input types that are available in the application.
  6410. * Fo instance: ArcRotateCameraGamepadInput...
  6411. */
  6412. export var CameraInputTypes: {};
  6413. /**
  6414. * This is the contract to implement in order to create a new input class.
  6415. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  6416. */
  6417. export interface ICameraInput<TCamera extends Camera> {
  6418. /**
  6419. * Defines the camera the input is attached to.
  6420. */
  6421. camera: Nullable<TCamera>;
  6422. /**
  6423. * Gets the class name of the current intput.
  6424. * @returns the class name
  6425. */
  6426. getClassName(): string;
  6427. /**
  6428. * Get the friendly name associated with the input class.
  6429. * @returns the input friendly name
  6430. */
  6431. getSimpleName(): string;
  6432. /**
  6433. * Attach the input controls to a specific dom element to get the input from.
  6434. * @param element Defines the element the controls should be listened from
  6435. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6436. */
  6437. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  6438. /**
  6439. * Detach the current controls from the specified dom element.
  6440. * @param element Defines the element to stop listening the inputs from
  6441. */
  6442. detachControl(element: Nullable<HTMLElement>): void;
  6443. /**
  6444. * Update the current camera state depending on the inputs that have been used this frame.
  6445. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6446. */
  6447. checkInputs?: () => void;
  6448. }
  6449. /**
  6450. * Represents a map of input types to input instance or input index to input instance.
  6451. */
  6452. export interface CameraInputsMap<TCamera extends Camera> {
  6453. /**
  6454. * Accessor to the input by input type.
  6455. */
  6456. [name: string]: ICameraInput<TCamera>;
  6457. /**
  6458. * Accessor to the input by input index.
  6459. */
  6460. [idx: number]: ICameraInput<TCamera>;
  6461. }
  6462. /**
  6463. * This represents the input manager used within a camera.
  6464. * It helps dealing with all the different kind of input attached to a camera.
  6465. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6466. */
  6467. export class CameraInputsManager<TCamera extends Camera> {
  6468. /**
  6469. * Defines the list of inputs attahed to the camera.
  6470. */
  6471. attached: CameraInputsMap<TCamera>;
  6472. /**
  6473. * Defines the dom element the camera is collecting inputs from.
  6474. * This is null if the controls have not been attached.
  6475. */
  6476. attachedElement: Nullable<HTMLElement>;
  6477. /**
  6478. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6479. */
  6480. noPreventDefault: boolean;
  6481. /**
  6482. * Defined the camera the input manager belongs to.
  6483. */
  6484. camera: TCamera;
  6485. /**
  6486. * Update the current camera state depending on the inputs that have been used this frame.
  6487. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  6488. */
  6489. checkInputs: () => void;
  6490. /**
  6491. * Instantiate a new Camera Input Manager.
  6492. * @param camera Defines the camera the input manager blongs to
  6493. */
  6494. constructor(camera: TCamera);
  6495. /**
  6496. * Add an input method to a camera
  6497. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  6498. * @param input camera input method
  6499. */
  6500. add(input: ICameraInput<TCamera>): void;
  6501. /**
  6502. * Remove a specific input method from a camera
  6503. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  6504. * @param inputToRemove camera input method
  6505. */
  6506. remove(inputToRemove: ICameraInput<TCamera>): void;
  6507. /**
  6508. * Remove a specific input type from a camera
  6509. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  6510. * @param inputType the type of the input to remove
  6511. */
  6512. removeByType(inputType: string): void;
  6513. private _addCheckInputs;
  6514. /**
  6515. * Attach the input controls to the currently attached dom element to listen the events from.
  6516. * @param input Defines the input to attach
  6517. */
  6518. attachInput(input: ICameraInput<TCamera>): void;
  6519. /**
  6520. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  6521. * @param element Defines the dom element to collect the events from
  6522. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  6523. */
  6524. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  6525. /**
  6526. * Detach the current manager inputs controls from a specific dom element.
  6527. * @param element Defines the dom element to collect the events from
  6528. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  6529. */
  6530. detachElement(element: HTMLElement, disconnect?: boolean): void;
  6531. /**
  6532. * Rebuild the dynamic inputCheck function from the current list of
  6533. * defined inputs in the manager.
  6534. */
  6535. rebuildInputCheck(): void;
  6536. /**
  6537. * Remove all attached input methods from a camera
  6538. */
  6539. clear(): void;
  6540. /**
  6541. * Serialize the current input manager attached to a camera.
  6542. * This ensures than once parsed,
  6543. * the input associated to the camera will be identical to the current ones
  6544. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  6545. */
  6546. serialize(serializedCamera: any): void;
  6547. /**
  6548. * Parses an input manager serialized JSON to restore the previous list of inputs
  6549. * and states associated to a camera.
  6550. * @param parsedCamera Defines the JSON to parse
  6551. */
  6552. parse(parsedCamera: any): void;
  6553. }
  6554. }
  6555. declare module "babylonjs/Meshes/buffer" {
  6556. import { Nullable, DataArray } from "babylonjs/types";
  6557. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  6558. /**
  6559. * Class used to store data that will be store in GPU memory
  6560. */
  6561. export class Buffer {
  6562. private _engine;
  6563. private _buffer;
  6564. /** @hidden */
  6565. _data: Nullable<DataArray>;
  6566. private _updatable;
  6567. private _instanced;
  6568. private _divisor;
  6569. /**
  6570. * Gets the byte stride.
  6571. */
  6572. readonly byteStride: number;
  6573. /**
  6574. * Constructor
  6575. * @param engine the engine
  6576. * @param data the data to use for this buffer
  6577. * @param updatable whether the data is updatable
  6578. * @param stride the stride (optional)
  6579. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6580. * @param instanced whether the buffer is instanced (optional)
  6581. * @param useBytes set to true if the stride in in bytes (optional)
  6582. * @param divisor sets an optional divisor for instances (1 by default)
  6583. */
  6584. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  6585. /**
  6586. * Create a new VertexBuffer based on the current buffer
  6587. * @param kind defines the vertex buffer kind (position, normal, etc.)
  6588. * @param offset defines offset in the buffer (0 by default)
  6589. * @param size defines the size in floats of attributes (position is 3 for instance)
  6590. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  6591. * @param instanced defines if the vertex buffer contains indexed data
  6592. * @param useBytes defines if the offset and stride are in bytes *
  6593. * @param divisor sets an optional divisor for instances (1 by default)
  6594. * @returns the new vertex buffer
  6595. */
  6596. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  6597. /**
  6598. * Gets a boolean indicating if the Buffer is updatable?
  6599. * @returns true if the buffer is updatable
  6600. */
  6601. isUpdatable(): boolean;
  6602. /**
  6603. * Gets current buffer's data
  6604. * @returns a DataArray or null
  6605. */
  6606. getData(): Nullable<DataArray>;
  6607. /**
  6608. * Gets underlying native buffer
  6609. * @returns underlying native buffer
  6610. */
  6611. getBuffer(): Nullable<DataBuffer>;
  6612. /**
  6613. * Gets the stride in float32 units (i.e. byte stride / 4).
  6614. * May not be an integer if the byte stride is not divisible by 4.
  6615. * @returns the stride in float32 units
  6616. * @deprecated Please use byteStride instead.
  6617. */
  6618. getStrideSize(): number;
  6619. /**
  6620. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6621. * @param data defines the data to store
  6622. */
  6623. create(data?: Nullable<DataArray>): void;
  6624. /** @hidden */
  6625. _rebuild(): void;
  6626. /**
  6627. * Update current buffer data
  6628. * @param data defines the data to store
  6629. */
  6630. update(data: DataArray): void;
  6631. /**
  6632. * Updates the data directly.
  6633. * @param data the new data
  6634. * @param offset the new offset
  6635. * @param vertexCount the vertex count (optional)
  6636. * @param useBytes set to true if the offset is in bytes
  6637. */
  6638. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  6639. /**
  6640. * Release all resources
  6641. */
  6642. dispose(): void;
  6643. }
  6644. /**
  6645. * Specialized buffer used to store vertex data
  6646. */
  6647. export class VertexBuffer {
  6648. /** @hidden */
  6649. _buffer: Buffer;
  6650. private _kind;
  6651. private _size;
  6652. private _ownsBuffer;
  6653. private _instanced;
  6654. private _instanceDivisor;
  6655. /**
  6656. * The byte type.
  6657. */
  6658. static readonly BYTE: number;
  6659. /**
  6660. * The unsigned byte type.
  6661. */
  6662. static readonly UNSIGNED_BYTE: number;
  6663. /**
  6664. * The short type.
  6665. */
  6666. static readonly SHORT: number;
  6667. /**
  6668. * The unsigned short type.
  6669. */
  6670. static readonly UNSIGNED_SHORT: number;
  6671. /**
  6672. * The integer type.
  6673. */
  6674. static readonly INT: number;
  6675. /**
  6676. * The unsigned integer type.
  6677. */
  6678. static readonly UNSIGNED_INT: number;
  6679. /**
  6680. * The float type.
  6681. */
  6682. static readonly FLOAT: number;
  6683. /**
  6684. * Gets or sets the instance divisor when in instanced mode
  6685. */
  6686. get instanceDivisor(): number;
  6687. set instanceDivisor(value: number);
  6688. /**
  6689. * Gets the byte stride.
  6690. */
  6691. readonly byteStride: number;
  6692. /**
  6693. * Gets the byte offset.
  6694. */
  6695. readonly byteOffset: number;
  6696. /**
  6697. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  6698. */
  6699. readonly normalized: boolean;
  6700. /**
  6701. * Gets the data type of each component in the array.
  6702. */
  6703. readonly type: number;
  6704. /**
  6705. * Constructor
  6706. * @param engine the engine
  6707. * @param data the data to use for this vertex buffer
  6708. * @param kind the vertex buffer kind
  6709. * @param updatable whether the data is updatable
  6710. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  6711. * @param stride the stride (optional)
  6712. * @param instanced whether the buffer is instanced (optional)
  6713. * @param offset the offset of the data (optional)
  6714. * @param size the number of components (optional)
  6715. * @param type the type of the component (optional)
  6716. * @param normalized whether the data contains normalized data (optional)
  6717. * @param useBytes set to true if stride and offset are in bytes (optional)
  6718. * @param divisor defines the instance divisor to use (1 by default)
  6719. */
  6720. 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);
  6721. /** @hidden */
  6722. _rebuild(): void;
  6723. /**
  6724. * Returns the kind of the VertexBuffer (string)
  6725. * @returns a string
  6726. */
  6727. getKind(): string;
  6728. /**
  6729. * Gets a boolean indicating if the VertexBuffer is updatable?
  6730. * @returns true if the buffer is updatable
  6731. */
  6732. isUpdatable(): boolean;
  6733. /**
  6734. * Gets current buffer's data
  6735. * @returns a DataArray or null
  6736. */
  6737. getData(): Nullable<DataArray>;
  6738. /**
  6739. * Gets underlying native buffer
  6740. * @returns underlying native buffer
  6741. */
  6742. getBuffer(): Nullable<DataBuffer>;
  6743. /**
  6744. * Gets the stride in float32 units (i.e. byte stride / 4).
  6745. * May not be an integer if the byte stride is not divisible by 4.
  6746. * @returns the stride in float32 units
  6747. * @deprecated Please use byteStride instead.
  6748. */
  6749. getStrideSize(): number;
  6750. /**
  6751. * Returns the offset as a multiple of the type byte length.
  6752. * @returns the offset in bytes
  6753. * @deprecated Please use byteOffset instead.
  6754. */
  6755. getOffset(): number;
  6756. /**
  6757. * Returns the number of components per vertex attribute (integer)
  6758. * @returns the size in float
  6759. */
  6760. getSize(): number;
  6761. /**
  6762. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  6763. * @returns true if this buffer is instanced
  6764. */
  6765. getIsInstanced(): boolean;
  6766. /**
  6767. * Returns the instancing divisor, zero for non-instanced (integer).
  6768. * @returns a number
  6769. */
  6770. getInstanceDivisor(): number;
  6771. /**
  6772. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  6773. * @param data defines the data to store
  6774. */
  6775. create(data?: DataArray): void;
  6776. /**
  6777. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  6778. * This function will create a new buffer if the current one is not updatable
  6779. * @param data defines the data to store
  6780. */
  6781. update(data: DataArray): void;
  6782. /**
  6783. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  6784. * Returns the directly updated WebGLBuffer.
  6785. * @param data the new data
  6786. * @param offset the new offset
  6787. * @param useBytes set to true if the offset is in bytes
  6788. */
  6789. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  6790. /**
  6791. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  6792. */
  6793. dispose(): void;
  6794. /**
  6795. * Enumerates each value of this vertex buffer as numbers.
  6796. * @param count the number of values to enumerate
  6797. * @param callback the callback function called for each value
  6798. */
  6799. forEach(count: number, callback: (value: number, index: number) => void): void;
  6800. /**
  6801. * Positions
  6802. */
  6803. static readonly PositionKind: string;
  6804. /**
  6805. * Normals
  6806. */
  6807. static readonly NormalKind: string;
  6808. /**
  6809. * Tangents
  6810. */
  6811. static readonly TangentKind: string;
  6812. /**
  6813. * Texture coordinates
  6814. */
  6815. static readonly UVKind: string;
  6816. /**
  6817. * Texture coordinates 2
  6818. */
  6819. static readonly UV2Kind: string;
  6820. /**
  6821. * Texture coordinates 3
  6822. */
  6823. static readonly UV3Kind: string;
  6824. /**
  6825. * Texture coordinates 4
  6826. */
  6827. static readonly UV4Kind: string;
  6828. /**
  6829. * Texture coordinates 5
  6830. */
  6831. static readonly UV5Kind: string;
  6832. /**
  6833. * Texture coordinates 6
  6834. */
  6835. static readonly UV6Kind: string;
  6836. /**
  6837. * Colors
  6838. */
  6839. static readonly ColorKind: string;
  6840. /**
  6841. * Matrix indices (for bones)
  6842. */
  6843. static readonly MatricesIndicesKind: string;
  6844. /**
  6845. * Matrix weights (for bones)
  6846. */
  6847. static readonly MatricesWeightsKind: string;
  6848. /**
  6849. * Additional matrix indices (for bones)
  6850. */
  6851. static readonly MatricesIndicesExtraKind: string;
  6852. /**
  6853. * Additional matrix weights (for bones)
  6854. */
  6855. static readonly MatricesWeightsExtraKind: string;
  6856. /**
  6857. * Deduces the stride given a kind.
  6858. * @param kind The kind string to deduce
  6859. * @returns The deduced stride
  6860. */
  6861. static DeduceStride(kind: string): number;
  6862. /**
  6863. * Gets the byte length of the given type.
  6864. * @param type the type
  6865. * @returns the number of bytes
  6866. */
  6867. static GetTypeByteLength(type: number): number;
  6868. /**
  6869. * Enumerates each value of the given parameters as numbers.
  6870. * @param data the data to enumerate
  6871. * @param byteOffset the byte offset of the data
  6872. * @param byteStride the byte stride of the data
  6873. * @param componentCount the number of components per element
  6874. * @param componentType the type of the component
  6875. * @param count the number of values to enumerate
  6876. * @param normalized whether the data is normalized
  6877. * @param callback the callback function called for each value
  6878. */
  6879. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  6880. private static _GetFloatValue;
  6881. }
  6882. }
  6883. declare module "babylonjs/Meshes/Builders/capsuleBuilder" {
  6884. import { Vector3 } from "babylonjs/Maths/math.vector";
  6885. import { Mesh } from "babylonjs/Meshes/mesh";
  6886. /**
  6887. * The options Interface for creating a Capsule Mesh
  6888. */
  6889. export interface ICreateCapsuleOptions {
  6890. /** The Orientation of the capsule. Default : Vector3.Up() */
  6891. orientation?: Vector3;
  6892. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  6893. subdivisions: number;
  6894. /** Number of cylindrical segments on the capsule. */
  6895. tessellation: number;
  6896. /** Height or Length of the capsule. */
  6897. height: number;
  6898. /** Radius of the capsule. */
  6899. radius: number;
  6900. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  6901. capSubdivisions: number;
  6902. /** Overwrite for the top radius. */
  6903. radiusTop?: number;
  6904. /** Overwrite for the bottom radius. */
  6905. radiusBottom?: number;
  6906. /** Overwrite for the top capSubdivisions. */
  6907. topCapSubdivisions?: number;
  6908. /** Overwrite for the bottom capSubdivisions. */
  6909. bottomCapSubdivisions?: number;
  6910. }
  6911. /**
  6912. * Class containing static functions to help procedurally build meshes
  6913. */
  6914. export class CapsuleBuilder {
  6915. /**
  6916. * Creates a capsule or a pill mesh
  6917. * @param name defines the name of the mesh
  6918. * @param options The constructors options.
  6919. * @param scene The scene the mesh is scoped to.
  6920. * @returns Capsule Mesh
  6921. */
  6922. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  6923. }
  6924. }
  6925. declare module "babylonjs/Collisions/intersectionInfo" {
  6926. import { Nullable } from "babylonjs/types";
  6927. /**
  6928. * @hidden
  6929. */
  6930. export class IntersectionInfo {
  6931. bu: Nullable<number>;
  6932. bv: Nullable<number>;
  6933. distance: number;
  6934. faceId: number;
  6935. subMeshId: number;
  6936. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  6937. }
  6938. }
  6939. declare module "babylonjs/Culling/boundingSphere" {
  6940. import { DeepImmutable } from "babylonjs/types";
  6941. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  6942. import { Plane } from "babylonjs/Maths/math.plane";
  6943. /**
  6944. * Class used to store bounding sphere information
  6945. */
  6946. export class BoundingSphere {
  6947. /**
  6948. * Gets the center of the bounding sphere in local space
  6949. */
  6950. readonly center: Vector3;
  6951. /**
  6952. * Radius of the bounding sphere in local space
  6953. */
  6954. radius: number;
  6955. /**
  6956. * Gets the center of the bounding sphere in world space
  6957. */
  6958. readonly centerWorld: Vector3;
  6959. /**
  6960. * Radius of the bounding sphere in world space
  6961. */
  6962. radiusWorld: number;
  6963. /**
  6964. * Gets the minimum vector in local space
  6965. */
  6966. readonly minimum: Vector3;
  6967. /**
  6968. * Gets the maximum vector in local space
  6969. */
  6970. readonly maximum: Vector3;
  6971. private _worldMatrix;
  6972. private static readonly TmpVector3;
  6973. /**
  6974. * Creates a new bounding sphere
  6975. * @param min defines the minimum vector (in local space)
  6976. * @param max defines the maximum vector (in local space)
  6977. * @param worldMatrix defines the new world matrix
  6978. */
  6979. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  6980. /**
  6981. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  6982. * @param min defines the new minimum vector (in local space)
  6983. * @param max defines the new maximum vector (in local space)
  6984. * @param worldMatrix defines the new world matrix
  6985. */
  6986. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  6987. /**
  6988. * Scale the current bounding sphere by applying a scale factor
  6989. * @param factor defines the scale factor to apply
  6990. * @returns the current bounding box
  6991. */
  6992. scale(factor: number): BoundingSphere;
  6993. /**
  6994. * Gets the world matrix of the bounding box
  6995. * @returns a matrix
  6996. */
  6997. getWorldMatrix(): DeepImmutable<Matrix>;
  6998. /** @hidden */
  6999. _update(worldMatrix: DeepImmutable<Matrix>): void;
  7000. /**
  7001. * Tests if the bounding sphere is intersecting the frustum planes
  7002. * @param frustumPlanes defines the frustum planes to test
  7003. * @returns true if there is an intersection
  7004. */
  7005. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7006. /**
  7007. * Tests if the bounding sphere center is in between the frustum planes.
  7008. * Used for optimistic fast inclusion.
  7009. * @param frustumPlanes defines the frustum planes to test
  7010. * @returns true if the sphere center is in between the frustum planes
  7011. */
  7012. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7013. /**
  7014. * Tests if a point is inside the bounding sphere
  7015. * @param point defines the point to test
  7016. * @returns true if the point is inside the bounding sphere
  7017. */
  7018. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7019. /**
  7020. * Checks if two sphere intersct
  7021. * @param sphere0 sphere 0
  7022. * @param sphere1 sphere 1
  7023. * @returns true if the speres intersect
  7024. */
  7025. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  7026. }
  7027. }
  7028. declare module "babylonjs/Culling/boundingBox" {
  7029. import { DeepImmutable } from "babylonjs/types";
  7030. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7031. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7032. import { ICullable } from "babylonjs/Culling/boundingInfo";
  7033. import { Plane } from "babylonjs/Maths/math.plane";
  7034. /**
  7035. * Class used to store bounding box information
  7036. */
  7037. export class BoundingBox implements ICullable {
  7038. /**
  7039. * Gets the 8 vectors representing the bounding box in local space
  7040. */
  7041. readonly vectors: Vector3[];
  7042. /**
  7043. * Gets the center of the bounding box in local space
  7044. */
  7045. readonly center: Vector3;
  7046. /**
  7047. * Gets the center of the bounding box in world space
  7048. */
  7049. readonly centerWorld: Vector3;
  7050. /**
  7051. * Gets the extend size in local space
  7052. */
  7053. readonly extendSize: Vector3;
  7054. /**
  7055. * Gets the extend size in world space
  7056. */
  7057. readonly extendSizeWorld: Vector3;
  7058. /**
  7059. * Gets the OBB (object bounding box) directions
  7060. */
  7061. readonly directions: Vector3[];
  7062. /**
  7063. * Gets the 8 vectors representing the bounding box in world space
  7064. */
  7065. readonly vectorsWorld: Vector3[];
  7066. /**
  7067. * Gets the minimum vector in world space
  7068. */
  7069. readonly minimumWorld: Vector3;
  7070. /**
  7071. * Gets the maximum vector in world space
  7072. */
  7073. readonly maximumWorld: Vector3;
  7074. /**
  7075. * Gets the minimum vector in local space
  7076. */
  7077. readonly minimum: Vector3;
  7078. /**
  7079. * Gets the maximum vector in local space
  7080. */
  7081. readonly maximum: Vector3;
  7082. private _worldMatrix;
  7083. private static readonly TmpVector3;
  7084. /**
  7085. * @hidden
  7086. */
  7087. _tag: number;
  7088. /**
  7089. * Creates a new bounding box
  7090. * @param min defines the minimum vector (in local space)
  7091. * @param max defines the maximum vector (in local space)
  7092. * @param worldMatrix defines the new world matrix
  7093. */
  7094. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7095. /**
  7096. * Recreates the entire bounding box from scratch as if we call the constructor in place
  7097. * @param min defines the new minimum vector (in local space)
  7098. * @param max defines the new maximum vector (in local space)
  7099. * @param worldMatrix defines the new world matrix
  7100. */
  7101. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7102. /**
  7103. * Scale the current bounding box by applying a scale factor
  7104. * @param factor defines the scale factor to apply
  7105. * @returns the current bounding box
  7106. */
  7107. scale(factor: number): BoundingBox;
  7108. /**
  7109. * Gets the world matrix of the bounding box
  7110. * @returns a matrix
  7111. */
  7112. getWorldMatrix(): DeepImmutable<Matrix>;
  7113. /** @hidden */
  7114. _update(world: DeepImmutable<Matrix>): void;
  7115. /**
  7116. * Tests if the bounding box is intersecting the frustum planes
  7117. * @param frustumPlanes defines the frustum planes to test
  7118. * @returns true if there is an intersection
  7119. */
  7120. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7121. /**
  7122. * Tests if the bounding box is entirely inside the frustum planes
  7123. * @param frustumPlanes defines the frustum planes to test
  7124. * @returns true if there is an inclusion
  7125. */
  7126. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7127. /**
  7128. * Tests if a point is inside the bounding box
  7129. * @param point defines the point to test
  7130. * @returns true if the point is inside the bounding box
  7131. */
  7132. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7133. /**
  7134. * Tests if the bounding box intersects with a bounding sphere
  7135. * @param sphere defines the sphere to test
  7136. * @returns true if there is an intersection
  7137. */
  7138. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  7139. /**
  7140. * Tests if the bounding box intersects with a box defined by a min and max vectors
  7141. * @param min defines the min vector to use
  7142. * @param max defines the max vector to use
  7143. * @returns true if there is an intersection
  7144. */
  7145. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  7146. /**
  7147. * Tests if two bounding boxes are intersections
  7148. * @param box0 defines the first box to test
  7149. * @param box1 defines the second box to test
  7150. * @returns true if there is an intersection
  7151. */
  7152. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  7153. /**
  7154. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  7155. * @param minPoint defines the minimum vector of the bounding box
  7156. * @param maxPoint defines the maximum vector of the bounding box
  7157. * @param sphereCenter defines the sphere center
  7158. * @param sphereRadius defines the sphere radius
  7159. * @returns true if there is an intersection
  7160. */
  7161. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  7162. /**
  7163. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  7164. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7165. * @param frustumPlanes defines the frustum planes to test
  7166. * @return true if there is an inclusion
  7167. */
  7168. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7169. /**
  7170. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  7171. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  7172. * @param frustumPlanes defines the frustum planes to test
  7173. * @return true if there is an intersection
  7174. */
  7175. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7176. }
  7177. }
  7178. declare module "babylonjs/Collisions/collider" {
  7179. import { Nullable, IndicesArray } from "babylonjs/types";
  7180. import { Vector3 } from "babylonjs/Maths/math.vector";
  7181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  7182. import { Plane } from "babylonjs/Maths/math.plane";
  7183. /** @hidden */
  7184. export class Collider {
  7185. /** Define if a collision was found */
  7186. collisionFound: boolean;
  7187. /**
  7188. * Define last intersection point in local space
  7189. */
  7190. intersectionPoint: Vector3;
  7191. /**
  7192. * Define last collided mesh
  7193. */
  7194. collidedMesh: Nullable<AbstractMesh>;
  7195. private _collisionPoint;
  7196. private _planeIntersectionPoint;
  7197. private _tempVector;
  7198. private _tempVector2;
  7199. private _tempVector3;
  7200. private _tempVector4;
  7201. private _edge;
  7202. private _baseToVertex;
  7203. private _destinationPoint;
  7204. private _slidePlaneNormal;
  7205. private _displacementVector;
  7206. /** @hidden */
  7207. _radius: Vector3;
  7208. /** @hidden */
  7209. _retry: number;
  7210. private _velocity;
  7211. private _basePoint;
  7212. private _epsilon;
  7213. /** @hidden */
  7214. _velocityWorldLength: number;
  7215. /** @hidden */
  7216. _basePointWorld: Vector3;
  7217. private _velocityWorld;
  7218. private _normalizedVelocity;
  7219. /** @hidden */
  7220. _initialVelocity: Vector3;
  7221. /** @hidden */
  7222. _initialPosition: Vector3;
  7223. private _nearestDistance;
  7224. private _collisionMask;
  7225. get collisionMask(): number;
  7226. set collisionMask(mask: number);
  7227. /**
  7228. * Gets the plane normal used to compute the sliding response (in local space)
  7229. */
  7230. get slidePlaneNormal(): Vector3;
  7231. /** @hidden */
  7232. _initialize(source: Vector3, dir: Vector3, e: number): void;
  7233. /** @hidden */
  7234. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  7235. /** @hidden */
  7236. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  7237. /** @hidden */
  7238. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7239. /** @hidden */
  7240. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  7241. /** @hidden */
  7242. _getResponse(pos: Vector3, vel: Vector3): void;
  7243. }
  7244. }
  7245. declare module "babylonjs/Culling/boundingInfo" {
  7246. import { DeepImmutable } from "babylonjs/types";
  7247. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7248. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  7249. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  7250. import { Plane } from "babylonjs/Maths/math.plane";
  7251. import { Collider } from "babylonjs/Collisions/collider";
  7252. /**
  7253. * Interface for cullable objects
  7254. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  7255. */
  7256. export interface ICullable {
  7257. /**
  7258. * Checks if the object or part of the object is in the frustum
  7259. * @param frustumPlanes Camera near/planes
  7260. * @returns true if the object is in frustum otherwise false
  7261. */
  7262. isInFrustum(frustumPlanes: Plane[]): boolean;
  7263. /**
  7264. * Checks if a cullable object (mesh...) is in the camera frustum
  7265. * Unlike isInFrustum this cheks the full bounding box
  7266. * @param frustumPlanes Camera near/planes
  7267. * @returns true if the object is in frustum otherwise false
  7268. */
  7269. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  7270. }
  7271. /**
  7272. * Info for a bounding data of a mesh
  7273. */
  7274. export class BoundingInfo implements ICullable {
  7275. /**
  7276. * Bounding box for the mesh
  7277. */
  7278. readonly boundingBox: BoundingBox;
  7279. /**
  7280. * Bounding sphere for the mesh
  7281. */
  7282. readonly boundingSphere: BoundingSphere;
  7283. private _isLocked;
  7284. private static readonly TmpVector3;
  7285. /**
  7286. * Constructs bounding info
  7287. * @param minimum min vector of the bounding box/sphere
  7288. * @param maximum max vector of the bounding box/sphere
  7289. * @param worldMatrix defines the new world matrix
  7290. */
  7291. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  7292. /**
  7293. * Recreates the entire bounding info from scratch as if we call the constructor in place
  7294. * @param min defines the new minimum vector (in local space)
  7295. * @param max defines the new maximum vector (in local space)
  7296. * @param worldMatrix defines the new world matrix
  7297. */
  7298. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  7299. /**
  7300. * min vector of the bounding box/sphere
  7301. */
  7302. get minimum(): Vector3;
  7303. /**
  7304. * max vector of the bounding box/sphere
  7305. */
  7306. get maximum(): Vector3;
  7307. /**
  7308. * If the info is locked and won't be updated to avoid perf overhead
  7309. */
  7310. get isLocked(): boolean;
  7311. set isLocked(value: boolean);
  7312. /**
  7313. * Updates the bounding sphere and box
  7314. * @param world world matrix to be used to update
  7315. */
  7316. update(world: DeepImmutable<Matrix>): void;
  7317. /**
  7318. * Recreate the bounding info to be centered around a specific point given a specific extend.
  7319. * @param center New center of the bounding info
  7320. * @param extend New extend of the bounding info
  7321. * @returns the current bounding info
  7322. */
  7323. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  7324. /**
  7325. * Scale the current bounding info by applying a scale factor
  7326. * @param factor defines the scale factor to apply
  7327. * @returns the current bounding info
  7328. */
  7329. scale(factor: number): BoundingInfo;
  7330. /**
  7331. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  7332. * @param frustumPlanes defines the frustum to test
  7333. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  7334. * @returns true if the bounding info is in the frustum planes
  7335. */
  7336. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  7337. /**
  7338. * Gets the world distance between the min and max points of the bounding box
  7339. */
  7340. get diagonalLength(): number;
  7341. /**
  7342. * Checks if a cullable object (mesh...) is in the camera frustum
  7343. * Unlike isInFrustum this cheks the full bounding box
  7344. * @param frustumPlanes Camera near/planes
  7345. * @returns true if the object is in frustum otherwise false
  7346. */
  7347. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  7348. /** @hidden */
  7349. _checkCollision(collider: Collider): boolean;
  7350. /**
  7351. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  7352. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7353. * @param point the point to check intersection with
  7354. * @returns if the point intersects
  7355. */
  7356. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  7357. /**
  7358. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  7359. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  7360. * @param boundingInfo the bounding info to check intersection with
  7361. * @param precise if the intersection should be done using OBB
  7362. * @returns if the bounding info intersects
  7363. */
  7364. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  7365. }
  7366. }
  7367. declare module "babylonjs/Maths/math.functions" {
  7368. import { FloatArray, Nullable, IndicesArray } from "babylonjs/types";
  7369. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  7370. /**
  7371. * Extracts minimum and maximum values from a list of indexed positions
  7372. * @param positions defines the positions to use
  7373. * @param indices defines the indices to the positions
  7374. * @param indexStart defines the start index
  7375. * @param indexCount defines the end index
  7376. * @param bias defines bias value to add to the result
  7377. * @return minimum and maximum values
  7378. */
  7379. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  7380. minimum: Vector3;
  7381. maximum: Vector3;
  7382. };
  7383. /**
  7384. * Extracts minimum and maximum values from a list of positions
  7385. * @param positions defines the positions to use
  7386. * @param start defines the start index in the positions array
  7387. * @param count defines the number of positions to handle
  7388. * @param bias defines bias value to add to the result
  7389. * @param stride defines the stride size to use (distance between two positions in the positions array)
  7390. * @return minimum and maximum values
  7391. */
  7392. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  7393. minimum: Vector3;
  7394. maximum: Vector3;
  7395. };
  7396. }
  7397. declare module "babylonjs/Meshes/WebGL/webGLDataBuffer" {
  7398. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7399. /** @hidden */
  7400. export class WebGLDataBuffer extends DataBuffer {
  7401. private _buffer;
  7402. constructor(resource: WebGLBuffer);
  7403. get underlyingResource(): any;
  7404. }
  7405. }
  7406. declare module "babylonjs/Engines/WebGL/webGLPipelineContext" {
  7407. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7408. import { Nullable } from "babylonjs/types";
  7409. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7410. /** @hidden */
  7411. export class WebGLPipelineContext implements IPipelineContext {
  7412. engine: ThinEngine;
  7413. program: Nullable<WebGLProgram>;
  7414. context?: WebGLRenderingContext;
  7415. vertexShader?: WebGLShader;
  7416. fragmentShader?: WebGLShader;
  7417. isParallelCompiled: boolean;
  7418. onCompiled?: () => void;
  7419. transformFeedback?: WebGLTransformFeedback | null;
  7420. vertexCompilationError: Nullable<string>;
  7421. fragmentCompilationError: Nullable<string>;
  7422. programLinkError: Nullable<string>;
  7423. programValidationError: Nullable<string>;
  7424. get isAsync(): boolean;
  7425. get isReady(): boolean;
  7426. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  7427. _getVertexShaderCode(): string | null;
  7428. _getFragmentShaderCode(): string | null;
  7429. }
  7430. }
  7431. declare module "babylonjs/Engines/Extensions/engine.uniformBuffer" {
  7432. import { FloatArray, Nullable } from "babylonjs/types";
  7433. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7434. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  7435. module "babylonjs/Engines/thinEngine" {
  7436. interface ThinEngine {
  7437. /**
  7438. * Create an uniform buffer
  7439. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7440. * @param elements defines the content of the uniform buffer
  7441. * @returns the webGL uniform buffer
  7442. */
  7443. createUniformBuffer(elements: FloatArray): DataBuffer;
  7444. /**
  7445. * Create a dynamic uniform buffer
  7446. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7447. * @param elements defines the content of the uniform buffer
  7448. * @returns the webGL uniform buffer
  7449. */
  7450. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  7451. /**
  7452. * Update an existing uniform buffer
  7453. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  7454. * @param uniformBuffer defines the target uniform buffer
  7455. * @param elements defines the content to update
  7456. * @param offset defines the offset in the uniform buffer where update should start
  7457. * @param count defines the size of the data to update
  7458. */
  7459. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  7460. /**
  7461. * Bind an uniform buffer to the current webGL context
  7462. * @param buffer defines the buffer to bind
  7463. */
  7464. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  7465. /**
  7466. * Bind a buffer to the current webGL context at a given location
  7467. * @param buffer defines the buffer to bind
  7468. * @param location defines the index where to bind the buffer
  7469. */
  7470. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  7471. /**
  7472. * Bind a specific block at a given index in a specific shader program
  7473. * @param pipelineContext defines the pipeline context to use
  7474. * @param blockName defines the block name
  7475. * @param index defines the index where to bind the block
  7476. */
  7477. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  7478. }
  7479. }
  7480. }
  7481. declare module "babylonjs/Materials/uniformBuffer" {
  7482. import { Nullable, FloatArray } from "babylonjs/types";
  7483. import { Matrix, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  7484. import { Engine } from "babylonjs/Engines/engine";
  7485. import { Effect } from "babylonjs/Materials/effect";
  7486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7487. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  7488. import { Color3 } from "babylonjs/Maths/math.color";
  7489. import "babylonjs/Engines/Extensions/engine.uniformBuffer";
  7490. /**
  7491. * Uniform buffer objects.
  7492. *
  7493. * Handles blocks of uniform on the GPU.
  7494. *
  7495. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7496. *
  7497. * For more information, please refer to :
  7498. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7499. */
  7500. export class UniformBuffer {
  7501. private _engine;
  7502. private _buffer;
  7503. private _data;
  7504. private _bufferData;
  7505. private _dynamic?;
  7506. private _uniformLocations;
  7507. private _uniformSizes;
  7508. private _uniformLocationPointer;
  7509. private _needSync;
  7510. private _noUBO;
  7511. private _currentEffect;
  7512. /** @hidden */
  7513. _alreadyBound: boolean;
  7514. private static _MAX_UNIFORM_SIZE;
  7515. private static _tempBuffer;
  7516. /**
  7517. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  7518. * This is dynamic to allow compat with webgl 1 and 2.
  7519. * You will need to pass the name of the uniform as well as the value.
  7520. */
  7521. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  7522. /**
  7523. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  7524. * This is dynamic to allow compat with webgl 1 and 2.
  7525. * You will need to pass the name of the uniform as well as the value.
  7526. */
  7527. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  7528. /**
  7529. * Lambda to Update a single float in a uniform buffer.
  7530. * This is dynamic to allow compat with webgl 1 and 2.
  7531. * You will need to pass the name of the uniform as well as the value.
  7532. */
  7533. updateFloat: (name: string, x: number) => void;
  7534. /**
  7535. * Lambda to Update a vec2 of float in a uniform buffer.
  7536. * This is dynamic to allow compat with webgl 1 and 2.
  7537. * You will need to pass the name of the uniform as well as the value.
  7538. */
  7539. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  7540. /**
  7541. * Lambda to Update a vec3 of float in a uniform buffer.
  7542. * This is dynamic to allow compat with webgl 1 and 2.
  7543. * You will need to pass the name of the uniform as well as the value.
  7544. */
  7545. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  7546. /**
  7547. * Lambda to Update a vec4 of float in a uniform buffer.
  7548. * This is dynamic to allow compat with webgl 1 and 2.
  7549. * You will need to pass the name of the uniform as well as the value.
  7550. */
  7551. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  7552. /**
  7553. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  7554. * This is dynamic to allow compat with webgl 1 and 2.
  7555. * You will need to pass the name of the uniform as well as the value.
  7556. */
  7557. updateMatrix: (name: string, mat: Matrix) => void;
  7558. /**
  7559. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  7560. * This is dynamic to allow compat with webgl 1 and 2.
  7561. * You will need to pass the name of the uniform as well as the value.
  7562. */
  7563. updateVector3: (name: string, vector: Vector3) => void;
  7564. /**
  7565. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  7566. * This is dynamic to allow compat with webgl 1 and 2.
  7567. * You will need to pass the name of the uniform as well as the value.
  7568. */
  7569. updateVector4: (name: string, vector: Vector4) => void;
  7570. /**
  7571. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  7572. * This is dynamic to allow compat with webgl 1 and 2.
  7573. * You will need to pass the name of the uniform as well as the value.
  7574. */
  7575. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  7576. /**
  7577. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  7578. * This is dynamic to allow compat with webgl 1 and 2.
  7579. * You will need to pass the name of the uniform as well as the value.
  7580. */
  7581. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  7582. /**
  7583. * Instantiates a new Uniform buffer objects.
  7584. *
  7585. * Handles blocks of uniform on the GPU.
  7586. *
  7587. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  7588. *
  7589. * For more information, please refer to :
  7590. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  7591. * @param engine Define the engine the buffer is associated with
  7592. * @param data Define the data contained in the buffer
  7593. * @param dynamic Define if the buffer is updatable
  7594. */
  7595. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  7596. /**
  7597. * Indicates if the buffer is using the WebGL2 UBO implementation,
  7598. * or just falling back on setUniformXXX calls.
  7599. */
  7600. get useUbo(): boolean;
  7601. /**
  7602. * Indicates if the WebGL underlying uniform buffer is in sync
  7603. * with the javascript cache data.
  7604. */
  7605. get isSync(): boolean;
  7606. /**
  7607. * Indicates if the WebGL underlying uniform buffer is dynamic.
  7608. * Also, a dynamic UniformBuffer will disable cache verification and always
  7609. * update the underlying WebGL uniform buffer to the GPU.
  7610. * @returns if Dynamic, otherwise false
  7611. */
  7612. isDynamic(): boolean;
  7613. /**
  7614. * The data cache on JS side.
  7615. * @returns the underlying data as a float array
  7616. */
  7617. getData(): Float32Array;
  7618. /**
  7619. * The underlying WebGL Uniform buffer.
  7620. * @returns the webgl buffer
  7621. */
  7622. getBuffer(): Nullable<DataBuffer>;
  7623. /**
  7624. * std140 layout specifies how to align data within an UBO structure.
  7625. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  7626. * for specs.
  7627. */
  7628. private _fillAlignment;
  7629. /**
  7630. * Adds an uniform in the buffer.
  7631. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  7632. * for the layout to be correct !
  7633. * @param name Name of the uniform, as used in the uniform block in the shader.
  7634. * @param size Data size, or data directly.
  7635. */
  7636. addUniform(name: string, size: number | number[]): void;
  7637. /**
  7638. * Adds a Matrix 4x4 to the uniform buffer.
  7639. * @param name Name of the uniform, as used in the uniform block in the shader.
  7640. * @param mat A 4x4 matrix.
  7641. */
  7642. addMatrix(name: string, mat: Matrix): void;
  7643. /**
  7644. * Adds a vec2 to the uniform buffer.
  7645. * @param name Name of the uniform, as used in the uniform block in the shader.
  7646. * @param x Define the x component value of the vec2
  7647. * @param y Define the y component value of the vec2
  7648. */
  7649. addFloat2(name: string, x: number, y: number): void;
  7650. /**
  7651. * Adds a vec3 to the uniform buffer.
  7652. * @param name Name of the uniform, as used in the uniform block in the shader.
  7653. * @param x Define the x component value of the vec3
  7654. * @param y Define the y component value of the vec3
  7655. * @param z Define the z component value of the vec3
  7656. */
  7657. addFloat3(name: string, x: number, y: number, z: number): void;
  7658. /**
  7659. * Adds a vec3 to the uniform buffer.
  7660. * @param name Name of the uniform, as used in the uniform block in the shader.
  7661. * @param color Define the vec3 from a Color
  7662. */
  7663. addColor3(name: string, color: Color3): void;
  7664. /**
  7665. * Adds a vec4 to the uniform buffer.
  7666. * @param name Name of the uniform, as used in the uniform block in the shader.
  7667. * @param color Define the rgb components from a Color
  7668. * @param alpha Define the a component of the vec4
  7669. */
  7670. addColor4(name: string, color: Color3, alpha: number): void;
  7671. /**
  7672. * Adds a vec3 to the uniform buffer.
  7673. * @param name Name of the uniform, as used in the uniform block in the shader.
  7674. * @param vector Define the vec3 components from a Vector
  7675. */
  7676. addVector3(name: string, vector: Vector3): void;
  7677. /**
  7678. * Adds a Matrix 3x3 to the uniform buffer.
  7679. * @param name Name of the uniform, as used in the uniform block in the shader.
  7680. */
  7681. addMatrix3x3(name: string): void;
  7682. /**
  7683. * Adds a Matrix 2x2 to the uniform buffer.
  7684. * @param name Name of the uniform, as used in the uniform block in the shader.
  7685. */
  7686. addMatrix2x2(name: string): void;
  7687. /**
  7688. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  7689. */
  7690. create(): void;
  7691. /** @hidden */
  7692. _rebuild(): void;
  7693. /**
  7694. * Updates the WebGL Uniform Buffer on the GPU.
  7695. * If the `dynamic` flag is set to true, no cache comparison is done.
  7696. * Otherwise, the buffer will be updated only if the cache differs.
  7697. */
  7698. update(): void;
  7699. /**
  7700. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  7701. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7702. * @param data Define the flattened data
  7703. * @param size Define the size of the data.
  7704. */
  7705. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  7706. private _valueCache;
  7707. private _cacheMatrix;
  7708. private _updateMatrix3x3ForUniform;
  7709. private _updateMatrix3x3ForEffect;
  7710. private _updateMatrix2x2ForEffect;
  7711. private _updateMatrix2x2ForUniform;
  7712. private _updateFloatForEffect;
  7713. private _updateFloatForUniform;
  7714. private _updateFloat2ForEffect;
  7715. private _updateFloat2ForUniform;
  7716. private _updateFloat3ForEffect;
  7717. private _updateFloat3ForUniform;
  7718. private _updateFloat4ForEffect;
  7719. private _updateFloat4ForUniform;
  7720. private _updateMatrixForEffect;
  7721. private _updateMatrixForUniform;
  7722. private _updateVector3ForEffect;
  7723. private _updateVector3ForUniform;
  7724. private _updateVector4ForEffect;
  7725. private _updateVector4ForUniform;
  7726. private _updateColor3ForEffect;
  7727. private _updateColor3ForUniform;
  7728. private _updateColor4ForEffect;
  7729. private _updateColor4ForUniform;
  7730. /**
  7731. * Sets a sampler uniform on the effect.
  7732. * @param name Define the name of the sampler.
  7733. * @param texture Define the texture to set in the sampler
  7734. */
  7735. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  7736. /**
  7737. * Directly updates the value of the uniform in the cache AND on the GPU.
  7738. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  7739. * @param data Define the flattened data
  7740. */
  7741. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  7742. /**
  7743. * Binds this uniform buffer to an effect.
  7744. * @param effect Define the effect to bind the buffer to
  7745. * @param name Name of the uniform block in the shader.
  7746. */
  7747. bindToEffect(effect: Effect, name: string): void;
  7748. /**
  7749. * Disposes the uniform buffer.
  7750. */
  7751. dispose(): void;
  7752. }
  7753. }
  7754. declare module "babylonjs/Misc/iInspectable" {
  7755. /**
  7756. * Enum that determines the text-wrapping mode to use.
  7757. */
  7758. export enum InspectableType {
  7759. /**
  7760. * Checkbox for booleans
  7761. */
  7762. Checkbox = 0,
  7763. /**
  7764. * Sliders for numbers
  7765. */
  7766. Slider = 1,
  7767. /**
  7768. * Vector3
  7769. */
  7770. Vector3 = 2,
  7771. /**
  7772. * Quaternions
  7773. */
  7774. Quaternion = 3,
  7775. /**
  7776. * Color3
  7777. */
  7778. Color3 = 4,
  7779. /**
  7780. * String
  7781. */
  7782. String = 5
  7783. }
  7784. /**
  7785. * Interface used to define custom inspectable properties.
  7786. * This interface is used by the inspector to display custom property grids
  7787. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  7788. */
  7789. export interface IInspectable {
  7790. /**
  7791. * Gets the label to display
  7792. */
  7793. label: string;
  7794. /**
  7795. * Gets the name of the property to edit
  7796. */
  7797. propertyName: string;
  7798. /**
  7799. * Gets the type of the editor to use
  7800. */
  7801. type: InspectableType;
  7802. /**
  7803. * Gets the minimum value of the property when using in "slider" mode
  7804. */
  7805. min?: number;
  7806. /**
  7807. * Gets the maximum value of the property when using in "slider" mode
  7808. */
  7809. max?: number;
  7810. /**
  7811. * Gets the setp to use when using in "slider" mode
  7812. */
  7813. step?: number;
  7814. }
  7815. }
  7816. declare module "babylonjs/Misc/timingTools" {
  7817. /**
  7818. * Class used to provide helper for timing
  7819. */
  7820. export class TimingTools {
  7821. /**
  7822. * Polyfill for setImmediate
  7823. * @param action defines the action to execute after the current execution block
  7824. */
  7825. static SetImmediate(action: () => void): void;
  7826. }
  7827. }
  7828. declare module "babylonjs/Misc/instantiationTools" {
  7829. /**
  7830. * Class used to enable instatition of objects by class name
  7831. */
  7832. export class InstantiationTools {
  7833. /**
  7834. * Use this object to register external classes like custom textures or material
  7835. * to allow the laoders to instantiate them
  7836. */
  7837. static RegisteredExternalClasses: {
  7838. [key: string]: Object;
  7839. };
  7840. /**
  7841. * Tries to instantiate a new object from a given class name
  7842. * @param className defines the class name to instantiate
  7843. * @returns the new object or null if the system was not able to do the instantiation
  7844. */
  7845. static Instantiate(className: string): any;
  7846. }
  7847. }
  7848. declare module "babylonjs/Engines/depthTextureCreationOptions" {
  7849. /**
  7850. * Define options used to create a depth texture
  7851. */
  7852. export class DepthTextureCreationOptions {
  7853. /** Specifies whether or not a stencil should be allocated in the texture */
  7854. generateStencil?: boolean;
  7855. /** Specifies whether or not bilinear filtering is enable on the texture */
  7856. bilinearFiltering?: boolean;
  7857. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  7858. comparisonFunction?: number;
  7859. /** Specifies if the created texture is a cube texture */
  7860. isCube?: boolean;
  7861. }
  7862. }
  7863. declare module "babylonjs/Engines/Extensions/engine.cubeTexture" {
  7864. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  7865. import { Nullable } from "babylonjs/types";
  7866. import { Scene } from "babylonjs/scene";
  7867. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  7868. module "babylonjs/Engines/thinEngine" {
  7869. interface ThinEngine {
  7870. /**
  7871. * Creates a depth stencil cube texture.
  7872. * This is only available in WebGL 2.
  7873. * @param size The size of face edge in the cube texture.
  7874. * @param options The options defining the cube texture.
  7875. * @returns The cube texture
  7876. */
  7877. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  7878. /**
  7879. * Creates a cube texture
  7880. * @param rootUrl defines the url where the files to load is located
  7881. * @param scene defines the current scene
  7882. * @param files defines the list of files to load (1 per face)
  7883. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7884. * @param onLoad defines an optional callback raised when the texture is loaded
  7885. * @param onError defines an optional callback raised if there is an issue to load the texture
  7886. * @param format defines the format of the data
  7887. * @param forcedExtension defines the extension to use to pick the right loader
  7888. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7889. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7890. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7891. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  7892. * @returns the cube texture as an InternalTexture
  7893. */
  7894. 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;
  7895. /**
  7896. * Creates a cube texture
  7897. * @param rootUrl defines the url where the files to load is located
  7898. * @param scene defines the current scene
  7899. * @param files defines the list of files to load (1 per face)
  7900. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7901. * @param onLoad defines an optional callback raised when the texture is loaded
  7902. * @param onError defines an optional callback raised if there is an issue to load the texture
  7903. * @param format defines the format of the data
  7904. * @param forcedExtension defines the extension to use to pick the right loader
  7905. * @returns the cube texture as an InternalTexture
  7906. */
  7907. 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;
  7908. /**
  7909. * Creates a cube texture
  7910. * @param rootUrl defines the url where the files to load is located
  7911. * @param scene defines the current scene
  7912. * @param files defines the list of files to load (1 per face)
  7913. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  7914. * @param onLoad defines an optional callback raised when the texture is loaded
  7915. * @param onError defines an optional callback raised if there is an issue to load the texture
  7916. * @param format defines the format of the data
  7917. * @param forcedExtension defines the extension to use to pick the right loader
  7918. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  7919. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  7920. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  7921. * @returns the cube texture as an InternalTexture
  7922. */
  7923. 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;
  7924. /** @hidden */
  7925. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  7926. /** @hidden */
  7927. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  7928. /** @hidden */
  7929. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7930. /** @hidden */
  7931. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  7932. /**
  7933. * @hidden
  7934. */
  7935. _setCubeMapTextureParams(loadMipmap: boolean): void;
  7936. }
  7937. }
  7938. }
  7939. declare module "babylonjs/Materials/Textures/cubeTexture" {
  7940. import { Nullable } from "babylonjs/types";
  7941. import { Scene } from "babylonjs/scene";
  7942. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  7943. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  7944. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  7945. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  7946. import { Observable } from "babylonjs/Misc/observable";
  7947. /**
  7948. * Class for creating a cube texture
  7949. */
  7950. export class CubeTexture extends BaseTexture {
  7951. private _delayedOnLoad;
  7952. /**
  7953. * Observable triggered once the texture has been loaded.
  7954. */
  7955. onLoadObservable: Observable<CubeTexture>;
  7956. /**
  7957. * The url of the texture
  7958. */
  7959. url: string;
  7960. /**
  7961. * Gets or sets the center of the bounding box associated with the cube texture.
  7962. * It must define where the camera used to render the texture was set
  7963. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7964. */
  7965. boundingBoxPosition: Vector3;
  7966. private _boundingBoxSize;
  7967. /**
  7968. * Gets or sets the size of the bounding box associated with the cube texture
  7969. * When defined, the cubemap will switch to local mode
  7970. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  7971. * @example https://www.babylonjs-playground.com/#RNASML
  7972. */
  7973. set boundingBoxSize(value: Vector3);
  7974. /**
  7975. * Returns the bounding box size
  7976. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  7977. */
  7978. get boundingBoxSize(): Vector3;
  7979. protected _rotationY: number;
  7980. /**
  7981. * Sets texture matrix rotation angle around Y axis in radians.
  7982. */
  7983. set rotationY(value: number);
  7984. /**
  7985. * Gets texture matrix rotation angle around Y axis radians.
  7986. */
  7987. get rotationY(): number;
  7988. /**
  7989. * Are mip maps generated for this texture or not.
  7990. */
  7991. get noMipmap(): boolean;
  7992. private _noMipmap;
  7993. private _files;
  7994. protected _forcedExtension: Nullable<string>;
  7995. private _extensions;
  7996. private _textureMatrix;
  7997. private _format;
  7998. private _createPolynomials;
  7999. /**
  8000. * Creates a cube texture from an array of image urls
  8001. * @param files defines an array of image urls
  8002. * @param scene defines the hosting scene
  8003. * @param noMipmap specifies if mip maps are not used
  8004. * @returns a cube texture
  8005. */
  8006. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  8007. /**
  8008. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  8009. * @param url defines the url of the prefiltered texture
  8010. * @param scene defines the scene the texture is attached to
  8011. * @param forcedExtension defines the extension of the file if different from the url
  8012. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8013. * @return the prefiltered texture
  8014. */
  8015. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  8016. /**
  8017. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  8018. * as prefiltered data.
  8019. * @param rootUrl defines the url of the texture or the root name of the six images
  8020. * @param null defines the scene or engine the texture is attached to
  8021. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  8022. * @param noMipmap defines if mipmaps should be created or not
  8023. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  8024. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  8025. * @param onError defines a callback triggered in case of error during load
  8026. * @param format defines the internal format to use for the texture once loaded
  8027. * @param prefiltered defines whether or not the texture is created from prefiltered data
  8028. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  8029. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  8030. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  8031. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  8032. * @return the cube texture
  8033. */
  8034. 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);
  8035. /**
  8036. * Get the current class name of the texture useful for serialization or dynamic coding.
  8037. * @returns "CubeTexture"
  8038. */
  8039. getClassName(): string;
  8040. /**
  8041. * Update the url (and optional buffer) of this texture if url was null during construction.
  8042. * @param url the url of the texture
  8043. * @param forcedExtension defines the extension to use
  8044. * @param onLoad callback called when the texture is loaded (defaults to null)
  8045. * @param prefiltered Defines whether the updated texture is prefiltered or not
  8046. */
  8047. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  8048. /**
  8049. * Delays loading of the cube texture
  8050. * @param forcedExtension defines the extension to use
  8051. */
  8052. delayLoad(forcedExtension?: string): void;
  8053. /**
  8054. * Returns the reflection texture matrix
  8055. * @returns the reflection texture matrix
  8056. */
  8057. getReflectionTextureMatrix(): Matrix;
  8058. /**
  8059. * Sets the reflection texture matrix
  8060. * @param value Reflection texture matrix
  8061. */
  8062. setReflectionTextureMatrix(value: Matrix): void;
  8063. /**
  8064. * Parses text to create a cube texture
  8065. * @param parsedTexture define the serialized text to read from
  8066. * @param scene defines the hosting scene
  8067. * @param rootUrl defines the root url of the cube texture
  8068. * @returns a cube texture
  8069. */
  8070. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  8071. /**
  8072. * Makes a clone, or deep copy, of the cube texture
  8073. * @returns a new cube texture
  8074. */
  8075. clone(): CubeTexture;
  8076. }
  8077. }
  8078. declare module "babylonjs/Materials/materialDefines" {
  8079. /**
  8080. * Manages the defines for the Material
  8081. */
  8082. export class MaterialDefines {
  8083. /** @hidden */
  8084. protected _keys: string[];
  8085. private _isDirty;
  8086. /** @hidden */
  8087. _renderId: number;
  8088. /** @hidden */
  8089. _areLightsDirty: boolean;
  8090. /** @hidden */
  8091. _areLightsDisposed: boolean;
  8092. /** @hidden */
  8093. _areAttributesDirty: boolean;
  8094. /** @hidden */
  8095. _areTexturesDirty: boolean;
  8096. /** @hidden */
  8097. _areFresnelDirty: boolean;
  8098. /** @hidden */
  8099. _areMiscDirty: boolean;
  8100. /** @hidden */
  8101. _arePrePassDirty: boolean;
  8102. /** @hidden */
  8103. _areImageProcessingDirty: boolean;
  8104. /** @hidden */
  8105. _normals: boolean;
  8106. /** @hidden */
  8107. _uvs: boolean;
  8108. /** @hidden */
  8109. _needNormals: boolean;
  8110. /** @hidden */
  8111. _needUVs: boolean;
  8112. [id: string]: any;
  8113. /**
  8114. * Specifies if the material needs to be re-calculated
  8115. */
  8116. get isDirty(): boolean;
  8117. /**
  8118. * Marks the material to indicate that it has been re-calculated
  8119. */
  8120. markAsProcessed(): void;
  8121. /**
  8122. * Marks the material to indicate that it needs to be re-calculated
  8123. */
  8124. markAsUnprocessed(): void;
  8125. /**
  8126. * Marks the material to indicate all of its defines need to be re-calculated
  8127. */
  8128. markAllAsDirty(): void;
  8129. /**
  8130. * Marks the material to indicate that image processing needs to be re-calculated
  8131. */
  8132. markAsImageProcessingDirty(): void;
  8133. /**
  8134. * Marks the material to indicate the lights need to be re-calculated
  8135. * @param disposed Defines whether the light is dirty due to dispose or not
  8136. */
  8137. markAsLightDirty(disposed?: boolean): void;
  8138. /**
  8139. * Marks the attribute state as changed
  8140. */
  8141. markAsAttributesDirty(): void;
  8142. /**
  8143. * Marks the texture state as changed
  8144. */
  8145. markAsTexturesDirty(): void;
  8146. /**
  8147. * Marks the fresnel state as changed
  8148. */
  8149. markAsFresnelDirty(): void;
  8150. /**
  8151. * Marks the misc state as changed
  8152. */
  8153. markAsMiscDirty(): void;
  8154. /**
  8155. * Marks the prepass state as changed
  8156. */
  8157. markAsPrePassDirty(): void;
  8158. /**
  8159. * Rebuilds the material defines
  8160. */
  8161. rebuild(): void;
  8162. /**
  8163. * Specifies if two material defines are equal
  8164. * @param other - A material define instance to compare to
  8165. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  8166. */
  8167. isEqual(other: MaterialDefines): boolean;
  8168. /**
  8169. * Clones this instance's defines to another instance
  8170. * @param other - material defines to clone values to
  8171. */
  8172. cloneTo(other: MaterialDefines): void;
  8173. /**
  8174. * Resets the material define values
  8175. */
  8176. reset(): void;
  8177. /**
  8178. * Converts the material define values to a string
  8179. * @returns - String of material define information
  8180. */
  8181. toString(): string;
  8182. }
  8183. }
  8184. declare module "babylonjs/Materials/colorCurves" {
  8185. import { Effect } from "babylonjs/Materials/effect";
  8186. /**
  8187. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  8188. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  8189. * 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;
  8190. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  8191. */
  8192. export class ColorCurves {
  8193. private _dirty;
  8194. private _tempColor;
  8195. private _globalCurve;
  8196. private _highlightsCurve;
  8197. private _midtonesCurve;
  8198. private _shadowsCurve;
  8199. private _positiveCurve;
  8200. private _negativeCurve;
  8201. private _globalHue;
  8202. private _globalDensity;
  8203. private _globalSaturation;
  8204. private _globalExposure;
  8205. /**
  8206. * Gets the global Hue value.
  8207. * 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).
  8208. */
  8209. get globalHue(): number;
  8210. /**
  8211. * Sets the global Hue value.
  8212. * 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).
  8213. */
  8214. set globalHue(value: number);
  8215. /**
  8216. * Gets the global Density value.
  8217. * 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.
  8218. * Values less than zero provide a filter of opposite hue.
  8219. */
  8220. get globalDensity(): number;
  8221. /**
  8222. * Sets the global Density value.
  8223. * 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.
  8224. * Values less than zero provide a filter of opposite hue.
  8225. */
  8226. set globalDensity(value: number);
  8227. /**
  8228. * Gets the global Saturation value.
  8229. * 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.
  8230. */
  8231. get globalSaturation(): number;
  8232. /**
  8233. * Sets the global Saturation value.
  8234. * 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.
  8235. */
  8236. set globalSaturation(value: number);
  8237. /**
  8238. * Gets the global Exposure value.
  8239. * 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.
  8240. */
  8241. get globalExposure(): number;
  8242. /**
  8243. * Sets the global Exposure value.
  8244. * 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.
  8245. */
  8246. set globalExposure(value: number);
  8247. private _highlightsHue;
  8248. private _highlightsDensity;
  8249. private _highlightsSaturation;
  8250. private _highlightsExposure;
  8251. /**
  8252. * Gets the highlights Hue value.
  8253. * 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).
  8254. */
  8255. get highlightsHue(): number;
  8256. /**
  8257. * Sets the highlights Hue value.
  8258. * 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).
  8259. */
  8260. set highlightsHue(value: number);
  8261. /**
  8262. * Gets the highlights Density value.
  8263. * 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.
  8264. * Values less than zero provide a filter of opposite hue.
  8265. */
  8266. get highlightsDensity(): number;
  8267. /**
  8268. * Sets the highlights Density value.
  8269. * 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.
  8270. * Values less than zero provide a filter of opposite hue.
  8271. */
  8272. set highlightsDensity(value: number);
  8273. /**
  8274. * Gets the highlights Saturation value.
  8275. * 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.
  8276. */
  8277. get highlightsSaturation(): number;
  8278. /**
  8279. * Sets the highlights Saturation value.
  8280. * 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.
  8281. */
  8282. set highlightsSaturation(value: number);
  8283. /**
  8284. * Gets the highlights Exposure value.
  8285. * 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.
  8286. */
  8287. get highlightsExposure(): number;
  8288. /**
  8289. * Sets the highlights Exposure value.
  8290. * 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.
  8291. */
  8292. set highlightsExposure(value: number);
  8293. private _midtonesHue;
  8294. private _midtonesDensity;
  8295. private _midtonesSaturation;
  8296. private _midtonesExposure;
  8297. /**
  8298. * Gets the midtones Hue value.
  8299. * 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).
  8300. */
  8301. get midtonesHue(): number;
  8302. /**
  8303. * Sets the midtones Hue value.
  8304. * 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).
  8305. */
  8306. set midtonesHue(value: number);
  8307. /**
  8308. * Gets the midtones Density value.
  8309. * 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.
  8310. * Values less than zero provide a filter of opposite hue.
  8311. */
  8312. get midtonesDensity(): number;
  8313. /**
  8314. * Sets the midtones Density value.
  8315. * 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.
  8316. * Values less than zero provide a filter of opposite hue.
  8317. */
  8318. set midtonesDensity(value: number);
  8319. /**
  8320. * Gets the midtones Saturation value.
  8321. * 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.
  8322. */
  8323. get midtonesSaturation(): number;
  8324. /**
  8325. * Sets the midtones Saturation value.
  8326. * 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.
  8327. */
  8328. set midtonesSaturation(value: number);
  8329. /**
  8330. * Gets the midtones Exposure value.
  8331. * 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.
  8332. */
  8333. get midtonesExposure(): number;
  8334. /**
  8335. * Sets the midtones Exposure value.
  8336. * 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.
  8337. */
  8338. set midtonesExposure(value: number);
  8339. private _shadowsHue;
  8340. private _shadowsDensity;
  8341. private _shadowsSaturation;
  8342. private _shadowsExposure;
  8343. /**
  8344. * Gets the shadows Hue value.
  8345. * 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).
  8346. */
  8347. get shadowsHue(): number;
  8348. /**
  8349. * Sets the shadows Hue value.
  8350. * 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).
  8351. */
  8352. set shadowsHue(value: number);
  8353. /**
  8354. * Gets the shadows Density value.
  8355. * 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.
  8356. * Values less than zero provide a filter of opposite hue.
  8357. */
  8358. get shadowsDensity(): number;
  8359. /**
  8360. * Sets the shadows Density value.
  8361. * 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.
  8362. * Values less than zero provide a filter of opposite hue.
  8363. */
  8364. set shadowsDensity(value: number);
  8365. /**
  8366. * Gets the shadows Saturation value.
  8367. * 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.
  8368. */
  8369. get shadowsSaturation(): number;
  8370. /**
  8371. * Sets the shadows Saturation value.
  8372. * 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.
  8373. */
  8374. set shadowsSaturation(value: number);
  8375. /**
  8376. * Gets the shadows Exposure value.
  8377. * 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.
  8378. */
  8379. get shadowsExposure(): number;
  8380. /**
  8381. * Sets the shadows Exposure value.
  8382. * 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.
  8383. */
  8384. set shadowsExposure(value: number);
  8385. /**
  8386. * Returns the class name
  8387. * @returns The class name
  8388. */
  8389. getClassName(): string;
  8390. /**
  8391. * Binds the color curves to the shader.
  8392. * @param colorCurves The color curve to bind
  8393. * @param effect The effect to bind to
  8394. * @param positiveUniform The positive uniform shader parameter
  8395. * @param neutralUniform The neutral uniform shader parameter
  8396. * @param negativeUniform The negative uniform shader parameter
  8397. */
  8398. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  8399. /**
  8400. * Prepare the list of uniforms associated with the ColorCurves effects.
  8401. * @param uniformsList The list of uniforms used in the effect
  8402. */
  8403. static PrepareUniforms(uniformsList: string[]): void;
  8404. /**
  8405. * Returns color grading data based on a hue, density, saturation and exposure value.
  8406. * @param filterHue The hue of the color filter.
  8407. * @param filterDensity The density of the color filter.
  8408. * @param saturation The saturation.
  8409. * @param exposure The exposure.
  8410. * @param result The result data container.
  8411. */
  8412. private getColorGradingDataToRef;
  8413. /**
  8414. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  8415. * @param value The input slider value in range [-100,100].
  8416. * @returns Adjusted value.
  8417. */
  8418. private static applyColorGradingSliderNonlinear;
  8419. /**
  8420. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  8421. * @param hue The hue (H) input.
  8422. * @param saturation The saturation (S) input.
  8423. * @param brightness The brightness (B) input.
  8424. * @result An RGBA color represented as Vector4.
  8425. */
  8426. private static fromHSBToRef;
  8427. /**
  8428. * Returns a value clamped between min and max
  8429. * @param value The value to clamp
  8430. * @param min The minimum of value
  8431. * @param max The maximum of value
  8432. * @returns The clamped value.
  8433. */
  8434. private static clamp;
  8435. /**
  8436. * Clones the current color curve instance.
  8437. * @return The cloned curves
  8438. */
  8439. clone(): ColorCurves;
  8440. /**
  8441. * Serializes the current color curve instance to a json representation.
  8442. * @return a JSON representation
  8443. */
  8444. serialize(): any;
  8445. /**
  8446. * Parses the color curve from a json representation.
  8447. * @param source the JSON source to parse
  8448. * @return The parsed curves
  8449. */
  8450. static Parse(source: any): ColorCurves;
  8451. }
  8452. }
  8453. declare module "babylonjs/Materials/imageProcessingConfiguration" {
  8454. import { Observable } from "babylonjs/Misc/observable";
  8455. import { Nullable } from "babylonjs/types";
  8456. import { Color4 } from "babylonjs/Maths/math.color";
  8457. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  8458. import { Effect } from "babylonjs/Materials/effect";
  8459. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  8460. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  8461. /**
  8462. * Interface to follow in your material defines to integrate easily the
  8463. * Image proccessing functions.
  8464. * @hidden
  8465. */
  8466. export interface IImageProcessingConfigurationDefines {
  8467. IMAGEPROCESSING: boolean;
  8468. VIGNETTE: boolean;
  8469. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8470. VIGNETTEBLENDMODEOPAQUE: boolean;
  8471. TONEMAPPING: boolean;
  8472. TONEMAPPING_ACES: boolean;
  8473. CONTRAST: boolean;
  8474. EXPOSURE: boolean;
  8475. COLORCURVES: boolean;
  8476. COLORGRADING: boolean;
  8477. COLORGRADING3D: boolean;
  8478. SAMPLER3DGREENDEPTH: boolean;
  8479. SAMPLER3DBGRMAP: boolean;
  8480. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8481. }
  8482. /**
  8483. * @hidden
  8484. */
  8485. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  8486. IMAGEPROCESSING: boolean;
  8487. VIGNETTE: boolean;
  8488. VIGNETTEBLENDMODEMULTIPLY: boolean;
  8489. VIGNETTEBLENDMODEOPAQUE: boolean;
  8490. TONEMAPPING: boolean;
  8491. TONEMAPPING_ACES: boolean;
  8492. CONTRAST: boolean;
  8493. COLORCURVES: boolean;
  8494. COLORGRADING: boolean;
  8495. COLORGRADING3D: boolean;
  8496. SAMPLER3DGREENDEPTH: boolean;
  8497. SAMPLER3DBGRMAP: boolean;
  8498. IMAGEPROCESSINGPOSTPROCESS: boolean;
  8499. EXPOSURE: boolean;
  8500. constructor();
  8501. }
  8502. /**
  8503. * This groups together the common properties used for image processing either in direct forward pass
  8504. * or through post processing effect depending on the use of the image processing pipeline in your scene
  8505. * or not.
  8506. */
  8507. export class ImageProcessingConfiguration {
  8508. /**
  8509. * Default tone mapping applied in BabylonJS.
  8510. */
  8511. static readonly TONEMAPPING_STANDARD: number;
  8512. /**
  8513. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  8514. * to other engines rendering to increase portability.
  8515. */
  8516. static readonly TONEMAPPING_ACES: number;
  8517. /**
  8518. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  8519. */
  8520. colorCurves: Nullable<ColorCurves>;
  8521. private _colorCurvesEnabled;
  8522. /**
  8523. * Gets wether the color curves effect is enabled.
  8524. */
  8525. get colorCurvesEnabled(): boolean;
  8526. /**
  8527. * Sets wether the color curves effect is enabled.
  8528. */
  8529. set colorCurvesEnabled(value: boolean);
  8530. private _colorGradingTexture;
  8531. /**
  8532. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8533. */
  8534. get colorGradingTexture(): Nullable<BaseTexture>;
  8535. /**
  8536. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  8537. */
  8538. set colorGradingTexture(value: Nullable<BaseTexture>);
  8539. private _colorGradingEnabled;
  8540. /**
  8541. * Gets wether the color grading effect is enabled.
  8542. */
  8543. get colorGradingEnabled(): boolean;
  8544. /**
  8545. * Sets wether the color grading effect is enabled.
  8546. */
  8547. set colorGradingEnabled(value: boolean);
  8548. private _colorGradingWithGreenDepth;
  8549. /**
  8550. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  8551. */
  8552. get colorGradingWithGreenDepth(): boolean;
  8553. /**
  8554. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  8555. */
  8556. set colorGradingWithGreenDepth(value: boolean);
  8557. private _colorGradingBGR;
  8558. /**
  8559. * Gets wether the color grading texture contains BGR values.
  8560. */
  8561. get colorGradingBGR(): boolean;
  8562. /**
  8563. * Sets wether the color grading texture contains BGR values.
  8564. */
  8565. set colorGradingBGR(value: boolean);
  8566. /** @hidden */
  8567. _exposure: number;
  8568. /**
  8569. * Gets the Exposure used in the effect.
  8570. */
  8571. get exposure(): number;
  8572. /**
  8573. * Sets the Exposure used in the effect.
  8574. */
  8575. set exposure(value: number);
  8576. private _toneMappingEnabled;
  8577. /**
  8578. * Gets wether the tone mapping effect is enabled.
  8579. */
  8580. get toneMappingEnabled(): boolean;
  8581. /**
  8582. * Sets wether the tone mapping effect is enabled.
  8583. */
  8584. set toneMappingEnabled(value: boolean);
  8585. private _toneMappingType;
  8586. /**
  8587. * Gets the type of tone mapping effect.
  8588. */
  8589. get toneMappingType(): number;
  8590. /**
  8591. * Sets the type of tone mapping effect used in BabylonJS.
  8592. */
  8593. set toneMappingType(value: number);
  8594. protected _contrast: number;
  8595. /**
  8596. * Gets the contrast used in the effect.
  8597. */
  8598. get contrast(): number;
  8599. /**
  8600. * Sets the contrast used in the effect.
  8601. */
  8602. set contrast(value: number);
  8603. /**
  8604. * Vignette stretch size.
  8605. */
  8606. vignetteStretch: number;
  8607. /**
  8608. * Vignette centre X Offset.
  8609. */
  8610. vignetteCentreX: number;
  8611. /**
  8612. * Vignette centre Y Offset.
  8613. */
  8614. vignetteCentreY: number;
  8615. /**
  8616. * Vignette weight or intensity of the vignette effect.
  8617. */
  8618. vignetteWeight: number;
  8619. /**
  8620. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  8621. * if vignetteEnabled is set to true.
  8622. */
  8623. vignetteColor: Color4;
  8624. /**
  8625. * Camera field of view used by the Vignette effect.
  8626. */
  8627. vignetteCameraFov: number;
  8628. private _vignetteBlendMode;
  8629. /**
  8630. * Gets the vignette blend mode allowing different kind of effect.
  8631. */
  8632. get vignetteBlendMode(): number;
  8633. /**
  8634. * Sets the vignette blend mode allowing different kind of effect.
  8635. */
  8636. set vignetteBlendMode(value: number);
  8637. private _vignetteEnabled;
  8638. /**
  8639. * Gets wether the vignette effect is enabled.
  8640. */
  8641. get vignetteEnabled(): boolean;
  8642. /**
  8643. * Sets wether the vignette effect is enabled.
  8644. */
  8645. set vignetteEnabled(value: boolean);
  8646. private _applyByPostProcess;
  8647. /**
  8648. * Gets wether the image processing is applied through a post process or not.
  8649. */
  8650. get applyByPostProcess(): boolean;
  8651. /**
  8652. * Sets wether the image processing is applied through a post process or not.
  8653. */
  8654. set applyByPostProcess(value: boolean);
  8655. private _isEnabled;
  8656. /**
  8657. * Gets wether the image processing is enabled or not.
  8658. */
  8659. get isEnabled(): boolean;
  8660. /**
  8661. * Sets wether the image processing is enabled or not.
  8662. */
  8663. set isEnabled(value: boolean);
  8664. /**
  8665. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  8666. */
  8667. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  8668. /**
  8669. * Method called each time the image processing information changes requires to recompile the effect.
  8670. */
  8671. protected _updateParameters(): void;
  8672. /**
  8673. * Gets the current class name.
  8674. * @return "ImageProcessingConfiguration"
  8675. */
  8676. getClassName(): string;
  8677. /**
  8678. * Prepare the list of uniforms associated with the Image Processing effects.
  8679. * @param uniforms The list of uniforms used in the effect
  8680. * @param defines the list of defines currently in use
  8681. */
  8682. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  8683. /**
  8684. * Prepare the list of samplers associated with the Image Processing effects.
  8685. * @param samplersList The list of uniforms used in the effect
  8686. * @param defines the list of defines currently in use
  8687. */
  8688. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  8689. /**
  8690. * Prepare the list of defines associated to the shader.
  8691. * @param defines the list of defines to complete
  8692. * @param forPostProcess Define if we are currently in post process mode or not
  8693. */
  8694. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  8695. /**
  8696. * Returns true if all the image processing information are ready.
  8697. * @returns True if ready, otherwise, false
  8698. */
  8699. isReady(): boolean;
  8700. /**
  8701. * Binds the image processing to the shader.
  8702. * @param effect The effect to bind to
  8703. * @param overrideAspectRatio Override the aspect ratio of the effect
  8704. */
  8705. bind(effect: Effect, overrideAspectRatio?: number): void;
  8706. /**
  8707. * Clones the current image processing instance.
  8708. * @return The cloned image processing
  8709. */
  8710. clone(): ImageProcessingConfiguration;
  8711. /**
  8712. * Serializes the current image processing instance to a json representation.
  8713. * @return a JSON representation
  8714. */
  8715. serialize(): any;
  8716. /**
  8717. * Parses the image processing from a json representation.
  8718. * @param source the JSON source to parse
  8719. * @return The parsed image processing
  8720. */
  8721. static Parse(source: any): ImageProcessingConfiguration;
  8722. private static _VIGNETTEMODE_MULTIPLY;
  8723. private static _VIGNETTEMODE_OPAQUE;
  8724. /**
  8725. * Used to apply the vignette as a mix with the pixel color.
  8726. */
  8727. static get VIGNETTEMODE_MULTIPLY(): number;
  8728. /**
  8729. * Used to apply the vignette as a replacement of the pixel color.
  8730. */
  8731. static get VIGNETTEMODE_OPAQUE(): number;
  8732. }
  8733. }
  8734. declare module "babylonjs/Shaders/postprocess.vertex" {
  8735. /** @hidden */
  8736. export var postprocessVertexShader: {
  8737. name: string;
  8738. shader: string;
  8739. };
  8740. }
  8741. declare module "babylonjs/Engines/Extensions/engine.renderTarget" {
  8742. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  8743. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  8744. import { DepthTextureCreationOptions } from "babylonjs/Engines/depthTextureCreationOptions";
  8745. /**
  8746. * Type used to define a render target texture size (either with a number or with a rect width and height)
  8747. */
  8748. export type RenderTargetTextureSize = number | {
  8749. width: number;
  8750. height: number;
  8751. layers?: number;
  8752. };
  8753. module "babylonjs/Engines/thinEngine" {
  8754. interface ThinEngine {
  8755. /**
  8756. * Creates a new render target texture
  8757. * @param size defines the size of the texture
  8758. * @param options defines the options used to create the texture
  8759. * @returns a new render target texture stored in an InternalTexture
  8760. */
  8761. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  8762. /**
  8763. * Creates a depth stencil texture.
  8764. * This is only available in WebGL 2 or with the depth texture extension available.
  8765. * @param size The size of face edge in the texture.
  8766. * @param options The options defining the texture.
  8767. * @returns The texture
  8768. */
  8769. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8770. /** @hidden */
  8771. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  8772. }
  8773. }
  8774. }
  8775. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes" {
  8776. /**
  8777. * Defines the kind of connection point for node based material
  8778. */
  8779. export enum NodeMaterialBlockConnectionPointTypes {
  8780. /** Float */
  8781. Float = 1,
  8782. /** Int */
  8783. Int = 2,
  8784. /** Vector2 */
  8785. Vector2 = 4,
  8786. /** Vector3 */
  8787. Vector3 = 8,
  8788. /** Vector4 */
  8789. Vector4 = 16,
  8790. /** Color3 */
  8791. Color3 = 32,
  8792. /** Color4 */
  8793. Color4 = 64,
  8794. /** Matrix */
  8795. Matrix = 128,
  8796. /** Custom object */
  8797. Object = 256,
  8798. /** Detect type based on connection */
  8799. AutoDetect = 1024,
  8800. /** Output type that will be defined by input type */
  8801. BasedOnInput = 2048
  8802. }
  8803. }
  8804. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets" {
  8805. /**
  8806. * Enum used to define the target of a block
  8807. */
  8808. export enum NodeMaterialBlockTargets {
  8809. /** Vertex shader */
  8810. Vertex = 1,
  8811. /** Fragment shader */
  8812. Fragment = 2,
  8813. /** Neutral */
  8814. Neutral = 4,
  8815. /** Vertex and Fragment */
  8816. VertexAndFragment = 3
  8817. }
  8818. }
  8819. declare module "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode" {
  8820. /**
  8821. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  8822. */
  8823. export enum NodeMaterialBlockConnectionPointMode {
  8824. /** Value is an uniform */
  8825. Uniform = 0,
  8826. /** Value is a mesh attribute */
  8827. Attribute = 1,
  8828. /** Value is a varying between vertex and fragment shaders */
  8829. Varying = 2,
  8830. /** Mode is undefined */
  8831. Undefined = 3
  8832. }
  8833. }
  8834. declare module "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues" {
  8835. /**
  8836. * Enum used to define system values e.g. values automatically provided by the system
  8837. */
  8838. export enum NodeMaterialSystemValues {
  8839. /** World */
  8840. World = 1,
  8841. /** View */
  8842. View = 2,
  8843. /** Projection */
  8844. Projection = 3,
  8845. /** ViewProjection */
  8846. ViewProjection = 4,
  8847. /** WorldView */
  8848. WorldView = 5,
  8849. /** WorldViewProjection */
  8850. WorldViewProjection = 6,
  8851. /** CameraPosition */
  8852. CameraPosition = 7,
  8853. /** Fog Color */
  8854. FogColor = 8,
  8855. /** Delta time */
  8856. DeltaTime = 9
  8857. }
  8858. }
  8859. declare module "babylonjs/Maths/math.axis" {
  8860. import { Vector3 } from "babylonjs/Maths/math.vector";
  8861. /** Defines supported spaces */
  8862. export enum Space {
  8863. /** Local (object) space */
  8864. LOCAL = 0,
  8865. /** World space */
  8866. WORLD = 1,
  8867. /** Bone space */
  8868. BONE = 2
  8869. }
  8870. /** Defines the 3 main axes */
  8871. export class Axis {
  8872. /** X axis */
  8873. static X: Vector3;
  8874. /** Y axis */
  8875. static Y: Vector3;
  8876. /** Z axis */
  8877. static Z: Vector3;
  8878. }
  8879. }
  8880. declare module "babylonjs/Maths/math.frustum" {
  8881. import { Matrix } from "babylonjs/Maths/math.vector";
  8882. import { DeepImmutable } from "babylonjs/types";
  8883. import { Plane } from "babylonjs/Maths/math.plane";
  8884. /**
  8885. * Represents a camera frustum
  8886. */
  8887. export class Frustum {
  8888. /**
  8889. * Gets the planes representing the frustum
  8890. * @param transform matrix to be applied to the returned planes
  8891. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  8892. */
  8893. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  8894. /**
  8895. * Gets the near frustum plane transformed by the transform matrix
  8896. * @param transform transformation matrix to be applied to the resulting frustum plane
  8897. * @param frustumPlane the resuling frustum plane
  8898. */
  8899. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8900. /**
  8901. * Gets the far frustum plane transformed by the transform matrix
  8902. * @param transform transformation matrix to be applied to the resulting frustum plane
  8903. * @param frustumPlane the resuling frustum plane
  8904. */
  8905. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8906. /**
  8907. * Gets the left frustum plane transformed by the transform matrix
  8908. * @param transform transformation matrix to be applied to the resulting frustum plane
  8909. * @param frustumPlane the resuling frustum plane
  8910. */
  8911. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8912. /**
  8913. * Gets the right frustum plane transformed by the transform matrix
  8914. * @param transform transformation matrix to be applied to the resulting frustum plane
  8915. * @param frustumPlane the resuling frustum plane
  8916. */
  8917. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8918. /**
  8919. * Gets the top frustum plane transformed by the transform matrix
  8920. * @param transform transformation matrix to be applied to the resulting frustum plane
  8921. * @param frustumPlane the resuling frustum plane
  8922. */
  8923. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8924. /**
  8925. * Gets the bottom frustum plane transformed by the transform matrix
  8926. * @param transform transformation matrix to be applied to the resulting frustum plane
  8927. * @param frustumPlane the resuling frustum plane
  8928. */
  8929. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  8930. /**
  8931. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  8932. * @param transform transformation matrix to be applied to the resulting frustum planes
  8933. * @param frustumPlanes the resuling frustum planes
  8934. */
  8935. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  8936. }
  8937. }
  8938. declare module "babylonjs/Maths/math.size" {
  8939. /**
  8940. * Interface for the size containing width and height
  8941. */
  8942. export interface ISize {
  8943. /**
  8944. * Width
  8945. */
  8946. width: number;
  8947. /**
  8948. * Heighht
  8949. */
  8950. height: number;
  8951. }
  8952. /**
  8953. * Size containing widht and height
  8954. */
  8955. export class Size implements ISize {
  8956. /**
  8957. * Width
  8958. */
  8959. width: number;
  8960. /**
  8961. * Height
  8962. */
  8963. height: number;
  8964. /**
  8965. * Creates a Size object from the given width and height (floats).
  8966. * @param width width of the new size
  8967. * @param height height of the new size
  8968. */
  8969. constructor(width: number, height: number);
  8970. /**
  8971. * Returns a string with the Size width and height
  8972. * @returns a string with the Size width and height
  8973. */
  8974. toString(): string;
  8975. /**
  8976. * "Size"
  8977. * @returns the string "Size"
  8978. */
  8979. getClassName(): string;
  8980. /**
  8981. * Returns the Size hash code.
  8982. * @returns a hash code for a unique width and height
  8983. */
  8984. getHashCode(): number;
  8985. /**
  8986. * Updates the current size from the given one.
  8987. * @param src the given size
  8988. */
  8989. copyFrom(src: Size): void;
  8990. /**
  8991. * Updates in place the current Size from the given floats.
  8992. * @param width width of the new size
  8993. * @param height height of the new size
  8994. * @returns the updated Size.
  8995. */
  8996. copyFromFloats(width: number, height: number): Size;
  8997. /**
  8998. * Updates in place the current Size from the given floats.
  8999. * @param width width to set
  9000. * @param height height to set
  9001. * @returns the updated Size.
  9002. */
  9003. set(width: number, height: number): Size;
  9004. /**
  9005. * Multiplies the width and height by numbers
  9006. * @param w factor to multiple the width by
  9007. * @param h factor to multiple the height by
  9008. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  9009. */
  9010. multiplyByFloats(w: number, h: number): Size;
  9011. /**
  9012. * Clones the size
  9013. * @returns a new Size copied from the given one.
  9014. */
  9015. clone(): Size;
  9016. /**
  9017. * True if the current Size and the given one width and height are strictly equal.
  9018. * @param other the other size to compare against
  9019. * @returns True if the current Size and the given one width and height are strictly equal.
  9020. */
  9021. equals(other: Size): boolean;
  9022. /**
  9023. * The surface of the Size : width * height (float).
  9024. */
  9025. get surface(): number;
  9026. /**
  9027. * Create a new size of zero
  9028. * @returns a new Size set to (0.0, 0.0)
  9029. */
  9030. static Zero(): Size;
  9031. /**
  9032. * Sums the width and height of two sizes
  9033. * @param otherSize size to add to this size
  9034. * @returns a new Size set as the addition result of the current Size and the given one.
  9035. */
  9036. add(otherSize: Size): Size;
  9037. /**
  9038. * Subtracts the width and height of two
  9039. * @param otherSize size to subtract to this size
  9040. * @returns a new Size set as the subtraction result of the given one from the current Size.
  9041. */
  9042. subtract(otherSize: Size): Size;
  9043. /**
  9044. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  9045. * @param start starting size to lerp between
  9046. * @param end end size to lerp between
  9047. * @param amount amount to lerp between the start and end values
  9048. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  9049. */
  9050. static Lerp(start: Size, end: Size, amount: number): Size;
  9051. }
  9052. }
  9053. declare module "babylonjs/Maths/math.vertexFormat" {
  9054. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  9055. /**
  9056. * Contains position and normal vectors for a vertex
  9057. */
  9058. export class PositionNormalVertex {
  9059. /** the position of the vertex (defaut: 0,0,0) */
  9060. position: Vector3;
  9061. /** the normal of the vertex (defaut: 0,1,0) */
  9062. normal: Vector3;
  9063. /**
  9064. * Creates a PositionNormalVertex
  9065. * @param position the position of the vertex (defaut: 0,0,0)
  9066. * @param normal the normal of the vertex (defaut: 0,1,0)
  9067. */
  9068. constructor(
  9069. /** the position of the vertex (defaut: 0,0,0) */
  9070. position?: Vector3,
  9071. /** the normal of the vertex (defaut: 0,1,0) */
  9072. normal?: Vector3);
  9073. /**
  9074. * Clones the PositionNormalVertex
  9075. * @returns the cloned PositionNormalVertex
  9076. */
  9077. clone(): PositionNormalVertex;
  9078. }
  9079. /**
  9080. * Contains position, normal and uv vectors for a vertex
  9081. */
  9082. export class PositionNormalTextureVertex {
  9083. /** the position of the vertex (defaut: 0,0,0) */
  9084. position: Vector3;
  9085. /** the normal of the vertex (defaut: 0,1,0) */
  9086. normal: Vector3;
  9087. /** the uv of the vertex (default: 0,0) */
  9088. uv: Vector2;
  9089. /**
  9090. * Creates a PositionNormalTextureVertex
  9091. * @param position the position of the vertex (defaut: 0,0,0)
  9092. * @param normal the normal of the vertex (defaut: 0,1,0)
  9093. * @param uv the uv of the vertex (default: 0,0)
  9094. */
  9095. constructor(
  9096. /** the position of the vertex (defaut: 0,0,0) */
  9097. position?: Vector3,
  9098. /** the normal of the vertex (defaut: 0,1,0) */
  9099. normal?: Vector3,
  9100. /** the uv of the vertex (default: 0,0) */
  9101. uv?: Vector2);
  9102. /**
  9103. * Clones the PositionNormalTextureVertex
  9104. * @returns the cloned PositionNormalTextureVertex
  9105. */
  9106. clone(): PositionNormalTextureVertex;
  9107. }
  9108. }
  9109. declare module "babylonjs/Maths/math" {
  9110. export * from "babylonjs/Maths/math.axis";
  9111. export * from "babylonjs/Maths/math.color";
  9112. export * from "babylonjs/Maths/math.constants";
  9113. export * from "babylonjs/Maths/math.frustum";
  9114. export * from "babylonjs/Maths/math.path";
  9115. export * from "babylonjs/Maths/math.plane";
  9116. export * from "babylonjs/Maths/math.size";
  9117. export * from "babylonjs/Maths/math.vector";
  9118. export * from "babylonjs/Maths/math.vertexFormat";
  9119. export * from "babylonjs/Maths/math.viewport";
  9120. }
  9121. declare module "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes" {
  9122. /**
  9123. * Enum defining the type of animations supported by InputBlock
  9124. */
  9125. export enum AnimatedInputBlockTypes {
  9126. /** No animation */
  9127. None = 0,
  9128. /** Time based animation. Will only work for floats */
  9129. Time = 1
  9130. }
  9131. }
  9132. declare module "babylonjs/Lights/shadowLight" {
  9133. import { Camera } from "babylonjs/Cameras/camera";
  9134. import { Scene } from "babylonjs/scene";
  9135. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  9136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9137. import { Light } from "babylonjs/Lights/light";
  9138. /**
  9139. * Interface describing all the common properties and methods a shadow light needs to implement.
  9140. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  9141. * as well as binding the different shadow properties to the effects.
  9142. */
  9143. export interface IShadowLight extends Light {
  9144. /**
  9145. * The light id in the scene (used in scene.findLighById for instance)
  9146. */
  9147. id: string;
  9148. /**
  9149. * The position the shdow will be casted from.
  9150. */
  9151. position: Vector3;
  9152. /**
  9153. * In 2d mode (needCube being false), the direction used to cast the shadow.
  9154. */
  9155. direction: Vector3;
  9156. /**
  9157. * The transformed position. Position of the light in world space taking parenting in account.
  9158. */
  9159. transformedPosition: Vector3;
  9160. /**
  9161. * The transformed direction. Direction of the light in world space taking parenting in account.
  9162. */
  9163. transformedDirection: Vector3;
  9164. /**
  9165. * The friendly name of the light in the scene.
  9166. */
  9167. name: string;
  9168. /**
  9169. * Defines the shadow projection clipping minimum z value.
  9170. */
  9171. shadowMinZ: number;
  9172. /**
  9173. * Defines the shadow projection clipping maximum z value.
  9174. */
  9175. shadowMaxZ: number;
  9176. /**
  9177. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9178. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9179. */
  9180. computeTransformedInformation(): boolean;
  9181. /**
  9182. * Gets the scene the light belongs to.
  9183. * @returns The scene
  9184. */
  9185. getScene(): Scene;
  9186. /**
  9187. * Callback defining a custom Projection Matrix Builder.
  9188. * This can be used to override the default projection matrix computation.
  9189. */
  9190. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9191. /**
  9192. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9193. * @param matrix The materix to updated with the projection information
  9194. * @param viewMatrix The transform matrix of the light
  9195. * @param renderList The list of mesh to render in the map
  9196. * @returns The current light
  9197. */
  9198. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9199. /**
  9200. * Gets the current depth scale used in ESM.
  9201. * @returns The scale
  9202. */
  9203. getDepthScale(): number;
  9204. /**
  9205. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9206. * @returns true if a cube texture needs to be use
  9207. */
  9208. needCube(): boolean;
  9209. /**
  9210. * Detects if the projection matrix requires to be recomputed this frame.
  9211. * @returns true if it requires to be recomputed otherwise, false.
  9212. */
  9213. needProjectionMatrixCompute(): boolean;
  9214. /**
  9215. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9216. */
  9217. forceProjectionMatrixCompute(): void;
  9218. /**
  9219. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9220. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9221. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9222. */
  9223. getShadowDirection(faceIndex?: number): Vector3;
  9224. /**
  9225. * Gets the minZ used for shadow according to both the scene and the light.
  9226. * @param activeCamera The camera we are returning the min for
  9227. * @returns the depth min z
  9228. */
  9229. getDepthMinZ(activeCamera: Camera): number;
  9230. /**
  9231. * Gets the maxZ used for shadow according to both the scene and the light.
  9232. * @param activeCamera The camera we are returning the max for
  9233. * @returns the depth max z
  9234. */
  9235. getDepthMaxZ(activeCamera: Camera): number;
  9236. }
  9237. /**
  9238. * Base implementation IShadowLight
  9239. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  9240. */
  9241. export abstract class ShadowLight extends Light implements IShadowLight {
  9242. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  9243. protected _position: Vector3;
  9244. protected _setPosition(value: Vector3): void;
  9245. /**
  9246. * Sets the position the shadow will be casted from. Also use as the light position for both
  9247. * point and spot lights.
  9248. */
  9249. get position(): Vector3;
  9250. /**
  9251. * Sets the position the shadow will be casted from. Also use as the light position for both
  9252. * point and spot lights.
  9253. */
  9254. set position(value: Vector3);
  9255. protected _direction: Vector3;
  9256. protected _setDirection(value: Vector3): void;
  9257. /**
  9258. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  9259. * Also use as the light direction on spot and directional lights.
  9260. */
  9261. get direction(): Vector3;
  9262. /**
  9263. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  9264. * Also use as the light direction on spot and directional lights.
  9265. */
  9266. set direction(value: Vector3);
  9267. protected _shadowMinZ: number;
  9268. /**
  9269. * Gets the shadow projection clipping minimum z value.
  9270. */
  9271. get shadowMinZ(): number;
  9272. /**
  9273. * Sets the shadow projection clipping minimum z value.
  9274. */
  9275. set shadowMinZ(value: number);
  9276. protected _shadowMaxZ: number;
  9277. /**
  9278. * Sets the shadow projection clipping maximum z value.
  9279. */
  9280. get shadowMaxZ(): number;
  9281. /**
  9282. * Gets the shadow projection clipping maximum z value.
  9283. */
  9284. set shadowMaxZ(value: number);
  9285. /**
  9286. * Callback defining a custom Projection Matrix Builder.
  9287. * This can be used to override the default projection matrix computation.
  9288. */
  9289. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  9290. /**
  9291. * The transformed position. Position of the light in world space taking parenting in account.
  9292. */
  9293. transformedPosition: Vector3;
  9294. /**
  9295. * The transformed direction. Direction of the light in world space taking parenting in account.
  9296. */
  9297. transformedDirection: Vector3;
  9298. private _needProjectionMatrixCompute;
  9299. /**
  9300. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  9301. * @returns true if the information has been computed, false if it does not need to (no parenting)
  9302. */
  9303. computeTransformedInformation(): boolean;
  9304. /**
  9305. * Return the depth scale used for the shadow map.
  9306. * @returns the depth scale.
  9307. */
  9308. getDepthScale(): number;
  9309. /**
  9310. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  9311. * @param faceIndex The index of the face we are computed the direction to generate shadow
  9312. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  9313. */
  9314. getShadowDirection(faceIndex?: number): Vector3;
  9315. /**
  9316. * Returns the ShadowLight absolute position in the World.
  9317. * @returns the position vector in world space
  9318. */
  9319. getAbsolutePosition(): Vector3;
  9320. /**
  9321. * Sets the ShadowLight direction toward the passed target.
  9322. * @param target The point to target in local space
  9323. * @returns the updated ShadowLight direction
  9324. */
  9325. setDirectionToTarget(target: Vector3): Vector3;
  9326. /**
  9327. * Returns the light rotation in euler definition.
  9328. * @returns the x y z rotation in local space.
  9329. */
  9330. getRotation(): Vector3;
  9331. /**
  9332. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  9333. * @returns true if a cube texture needs to be use
  9334. */
  9335. needCube(): boolean;
  9336. /**
  9337. * Detects if the projection matrix requires to be recomputed this frame.
  9338. * @returns true if it requires to be recomputed otherwise, false.
  9339. */
  9340. needProjectionMatrixCompute(): boolean;
  9341. /**
  9342. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  9343. */
  9344. forceProjectionMatrixCompute(): void;
  9345. /** @hidden */
  9346. _initCache(): void;
  9347. /** @hidden */
  9348. _isSynchronized(): boolean;
  9349. /**
  9350. * Computes the world matrix of the node
  9351. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  9352. * @returns the world matrix
  9353. */
  9354. computeWorldMatrix(force?: boolean): Matrix;
  9355. /**
  9356. * Gets the minZ used for shadow according to both the scene and the light.
  9357. * @param activeCamera The camera we are returning the min for
  9358. * @returns the depth min z
  9359. */
  9360. getDepthMinZ(activeCamera: Camera): number;
  9361. /**
  9362. * Gets the maxZ used for shadow according to both the scene and the light.
  9363. * @param activeCamera The camera we are returning the max for
  9364. * @returns the depth max z
  9365. */
  9366. getDepthMaxZ(activeCamera: Camera): number;
  9367. /**
  9368. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  9369. * @param matrix The materix to updated with the projection information
  9370. * @param viewMatrix The transform matrix of the light
  9371. * @param renderList The list of mesh to render in the map
  9372. * @returns The current light
  9373. */
  9374. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  9375. }
  9376. }
  9377. declare module "babylonjs/Shaders/ShadersInclude/packingFunctions" {
  9378. /** @hidden */
  9379. export var packingFunctions: {
  9380. name: string;
  9381. shader: string;
  9382. };
  9383. }
  9384. declare module "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions" {
  9385. /** @hidden */
  9386. export var bayerDitherFunctions: {
  9387. name: string;
  9388. shader: string;
  9389. };
  9390. }
  9391. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration" {
  9392. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  9393. import "babylonjs/Shaders/ShadersInclude/bayerDitherFunctions";
  9394. /** @hidden */
  9395. export var shadowMapFragmentDeclaration: {
  9396. name: string;
  9397. shader: string;
  9398. };
  9399. }
  9400. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration" {
  9401. /** @hidden */
  9402. export var clipPlaneFragmentDeclaration: {
  9403. name: string;
  9404. shader: string;
  9405. };
  9406. }
  9407. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragment" {
  9408. /** @hidden */
  9409. export var clipPlaneFragment: {
  9410. name: string;
  9411. shader: string;
  9412. };
  9413. }
  9414. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragment" {
  9415. /** @hidden */
  9416. export var shadowMapFragment: {
  9417. name: string;
  9418. shader: string;
  9419. };
  9420. }
  9421. declare module "babylonjs/Shaders/shadowMap.fragment" {
  9422. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentDeclaration";
  9423. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  9424. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  9425. import "babylonjs/Shaders/ShadersInclude/shadowMapFragment";
  9426. /** @hidden */
  9427. export var shadowMapPixelShader: {
  9428. name: string;
  9429. shader: string;
  9430. };
  9431. }
  9432. declare module "babylonjs/Shaders/ShadersInclude/bonesDeclaration" {
  9433. /** @hidden */
  9434. export var bonesDeclaration: {
  9435. name: string;
  9436. shader: string;
  9437. };
  9438. }
  9439. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration" {
  9440. /** @hidden */
  9441. export var morphTargetsVertexGlobalDeclaration: {
  9442. name: string;
  9443. shader: string;
  9444. };
  9445. }
  9446. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration" {
  9447. /** @hidden */
  9448. export var morphTargetsVertexDeclaration: {
  9449. name: string;
  9450. shader: string;
  9451. };
  9452. }
  9453. declare module "babylonjs/Shaders/ShadersInclude/instancesDeclaration" {
  9454. /** @hidden */
  9455. export var instancesDeclaration: {
  9456. name: string;
  9457. shader: string;
  9458. };
  9459. }
  9460. declare module "babylonjs/Shaders/ShadersInclude/helperFunctions" {
  9461. /** @hidden */
  9462. export var helperFunctions: {
  9463. name: string;
  9464. shader: string;
  9465. };
  9466. }
  9467. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration" {
  9468. /** @hidden */
  9469. export var shadowMapVertexDeclaration: {
  9470. name: string;
  9471. shader: string;
  9472. };
  9473. }
  9474. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration" {
  9475. /** @hidden */
  9476. export var clipPlaneVertexDeclaration: {
  9477. name: string;
  9478. shader: string;
  9479. };
  9480. }
  9481. declare module "babylonjs/Shaders/ShadersInclude/morphTargetsVertex" {
  9482. /** @hidden */
  9483. export var morphTargetsVertex: {
  9484. name: string;
  9485. shader: string;
  9486. };
  9487. }
  9488. declare module "babylonjs/Shaders/ShadersInclude/instancesVertex" {
  9489. /** @hidden */
  9490. export var instancesVertex: {
  9491. name: string;
  9492. shader: string;
  9493. };
  9494. }
  9495. declare module "babylonjs/Shaders/ShadersInclude/bonesVertex" {
  9496. /** @hidden */
  9497. export var bonesVertex: {
  9498. name: string;
  9499. shader: string;
  9500. };
  9501. }
  9502. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias" {
  9503. /** @hidden */
  9504. export var shadowMapVertexNormalBias: {
  9505. name: string;
  9506. shader: string;
  9507. };
  9508. }
  9509. declare module "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric" {
  9510. /** @hidden */
  9511. export var shadowMapVertexMetric: {
  9512. name: string;
  9513. shader: string;
  9514. };
  9515. }
  9516. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertex" {
  9517. /** @hidden */
  9518. export var clipPlaneVertex: {
  9519. name: string;
  9520. shader: string;
  9521. };
  9522. }
  9523. declare module "babylonjs/Shaders/shadowMap.vertex" {
  9524. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  9525. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  9526. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  9527. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  9528. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  9529. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexDeclaration";
  9530. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  9531. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  9532. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  9533. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  9534. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexNormalBias";
  9535. import "babylonjs/Shaders/ShadersInclude/shadowMapVertexMetric";
  9536. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  9537. /** @hidden */
  9538. export var shadowMapVertexShader: {
  9539. name: string;
  9540. shader: string;
  9541. };
  9542. }
  9543. declare module "babylonjs/Shaders/depthBoxBlur.fragment" {
  9544. /** @hidden */
  9545. export var depthBoxBlurPixelShader: {
  9546. name: string;
  9547. shader: string;
  9548. };
  9549. }
  9550. declare module "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow" {
  9551. /** @hidden */
  9552. export var shadowMapFragmentSoftTransparentShadow: {
  9553. name: string;
  9554. shader: string;
  9555. };
  9556. }
  9557. declare module "babylonjs/Materials/effectFallbacks" {
  9558. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  9559. import { Effect } from "babylonjs/Materials/effect";
  9560. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  9561. /**
  9562. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  9563. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  9564. */
  9565. export class EffectFallbacks implements IEffectFallbacks {
  9566. private _defines;
  9567. private _currentRank;
  9568. private _maxRank;
  9569. private _mesh;
  9570. /**
  9571. * Removes the fallback from the bound mesh.
  9572. */
  9573. unBindMesh(): void;
  9574. /**
  9575. * Adds a fallback on the specified property.
  9576. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9577. * @param define The name of the define in the shader
  9578. */
  9579. addFallback(rank: number, define: string): void;
  9580. /**
  9581. * Sets the mesh to use CPU skinning when needing to fallback.
  9582. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  9583. * @param mesh The mesh to use the fallbacks.
  9584. */
  9585. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  9586. /**
  9587. * Checks to see if more fallbacks are still availible.
  9588. */
  9589. get hasMoreFallbacks(): boolean;
  9590. /**
  9591. * Removes the defines that should be removed when falling back.
  9592. * @param currentDefines defines the current define statements for the shader.
  9593. * @param effect defines the current effect we try to compile
  9594. * @returns The resulting defines with defines of the current rank removed.
  9595. */
  9596. reduce(currentDefines: string, effect: Effect): string;
  9597. }
  9598. }
  9599. declare module "babylonjs/Actions/action" {
  9600. import { Observable } from "babylonjs/Misc/observable";
  9601. import { Condition } from "babylonjs/Actions/condition";
  9602. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  9603. import { Nullable } from "babylonjs/types";
  9604. import { Scene } from "babylonjs/scene";
  9605. import { ActionManager } from "babylonjs/Actions/actionManager";
  9606. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9607. import { Node } from "babylonjs/node";
  9608. /**
  9609. * Interface used to define Action
  9610. */
  9611. export interface IAction {
  9612. /**
  9613. * Trigger for the action
  9614. */
  9615. trigger: number;
  9616. /** Options of the trigger */
  9617. triggerOptions: any;
  9618. /**
  9619. * Gets the trigger parameters
  9620. * @returns the trigger parameters
  9621. */
  9622. getTriggerParameter(): any;
  9623. /**
  9624. * Internal only - executes current action event
  9625. * @hidden
  9626. */
  9627. _executeCurrent(evt?: ActionEvent): void;
  9628. /**
  9629. * Serialize placeholder for child classes
  9630. * @param parent of child
  9631. * @returns the serialized object
  9632. */
  9633. serialize(parent: any): any;
  9634. /**
  9635. * Internal only
  9636. * @hidden
  9637. */
  9638. _prepare(): void;
  9639. /**
  9640. * Internal only - manager for action
  9641. * @hidden
  9642. */
  9643. _actionManager: Nullable<AbstractActionManager>;
  9644. /**
  9645. * Adds action to chain of actions, may be a DoNothingAction
  9646. * @param action defines the next action to execute
  9647. * @returns The action passed in
  9648. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9649. */
  9650. then(action: IAction): IAction;
  9651. }
  9652. /**
  9653. * The action to be carried out following a trigger
  9654. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  9655. */
  9656. export class Action implements IAction {
  9657. /** the trigger, with or without parameters, for the action */
  9658. triggerOptions: any;
  9659. /**
  9660. * Trigger for the action
  9661. */
  9662. trigger: number;
  9663. /**
  9664. * Internal only - manager for action
  9665. * @hidden
  9666. */
  9667. _actionManager: ActionManager;
  9668. private _nextActiveAction;
  9669. private _child;
  9670. private _condition?;
  9671. private _triggerParameter;
  9672. /**
  9673. * An event triggered prior to action being executed.
  9674. */
  9675. onBeforeExecuteObservable: Observable<Action>;
  9676. /**
  9677. * Creates a new Action
  9678. * @param triggerOptions the trigger, with or without parameters, for the action
  9679. * @param condition an optional determinant of action
  9680. */
  9681. constructor(
  9682. /** the trigger, with or without parameters, for the action */
  9683. triggerOptions: any, condition?: Condition);
  9684. /**
  9685. * Internal only
  9686. * @hidden
  9687. */
  9688. _prepare(): void;
  9689. /**
  9690. * Gets the trigger parameters
  9691. * @returns the trigger parameters
  9692. */
  9693. getTriggerParameter(): any;
  9694. /**
  9695. * Internal only - executes current action event
  9696. * @hidden
  9697. */
  9698. _executeCurrent(evt?: ActionEvent): void;
  9699. /**
  9700. * Execute placeholder for child classes
  9701. * @param evt optional action event
  9702. */
  9703. execute(evt?: ActionEvent): void;
  9704. /**
  9705. * Skips to next active action
  9706. */
  9707. skipToNextActiveAction(): void;
  9708. /**
  9709. * Adds action to chain of actions, may be a DoNothingAction
  9710. * @param action defines the next action to execute
  9711. * @returns The action passed in
  9712. * @see https://www.babylonjs-playground.com/#1T30HR#0
  9713. */
  9714. then(action: Action): Action;
  9715. /**
  9716. * Internal only
  9717. * @hidden
  9718. */
  9719. _getProperty(propertyPath: string): string;
  9720. /**
  9721. * Internal only
  9722. * @hidden
  9723. */
  9724. _getEffectiveTarget(target: any, propertyPath: string): any;
  9725. /**
  9726. * Serialize placeholder for child classes
  9727. * @param parent of child
  9728. * @returns the serialized object
  9729. */
  9730. serialize(parent: any): any;
  9731. /**
  9732. * Internal only called by serialize
  9733. * @hidden
  9734. */
  9735. protected _serialize(serializedAction: any, parent?: any): any;
  9736. /**
  9737. * Internal only
  9738. * @hidden
  9739. */
  9740. static _SerializeValueAsString: (value: any) => string;
  9741. /**
  9742. * Internal only
  9743. * @hidden
  9744. */
  9745. static _GetTargetProperty: (target: Scene | Node) => {
  9746. name: string;
  9747. targetType: string;
  9748. value: string;
  9749. };
  9750. }
  9751. }
  9752. declare module "babylonjs/Actions/condition" {
  9753. import { ActionManager } from "babylonjs/Actions/actionManager";
  9754. /**
  9755. * A Condition applied to an Action
  9756. */
  9757. export class Condition {
  9758. /**
  9759. * Internal only - manager for action
  9760. * @hidden
  9761. */
  9762. _actionManager: ActionManager;
  9763. /**
  9764. * Internal only
  9765. * @hidden
  9766. */
  9767. _evaluationId: number;
  9768. /**
  9769. * Internal only
  9770. * @hidden
  9771. */
  9772. _currentResult: boolean;
  9773. /**
  9774. * Creates a new Condition
  9775. * @param actionManager the manager of the action the condition is applied to
  9776. */
  9777. constructor(actionManager: ActionManager);
  9778. /**
  9779. * Check if the current condition is valid
  9780. * @returns a boolean
  9781. */
  9782. isValid(): boolean;
  9783. /**
  9784. * Internal only
  9785. * @hidden
  9786. */
  9787. _getProperty(propertyPath: string): string;
  9788. /**
  9789. * Internal only
  9790. * @hidden
  9791. */
  9792. _getEffectiveTarget(target: any, propertyPath: string): any;
  9793. /**
  9794. * Serialize placeholder for child classes
  9795. * @returns the serialized object
  9796. */
  9797. serialize(): any;
  9798. /**
  9799. * Internal only
  9800. * @hidden
  9801. */
  9802. protected _serialize(serializedCondition: any): any;
  9803. }
  9804. /**
  9805. * Defines specific conditional operators as extensions of Condition
  9806. */
  9807. export class ValueCondition extends Condition {
  9808. /** path to specify the property of the target the conditional operator uses */
  9809. propertyPath: string;
  9810. /** the value compared by the conditional operator against the current value of the property */
  9811. value: any;
  9812. /** the conditional operator, default ValueCondition.IsEqual */
  9813. operator: number;
  9814. /**
  9815. * Internal only
  9816. * @hidden
  9817. */
  9818. private static _IsEqual;
  9819. /**
  9820. * Internal only
  9821. * @hidden
  9822. */
  9823. private static _IsDifferent;
  9824. /**
  9825. * Internal only
  9826. * @hidden
  9827. */
  9828. private static _IsGreater;
  9829. /**
  9830. * Internal only
  9831. * @hidden
  9832. */
  9833. private static _IsLesser;
  9834. /**
  9835. * returns the number for IsEqual
  9836. */
  9837. static get IsEqual(): number;
  9838. /**
  9839. * Returns the number for IsDifferent
  9840. */
  9841. static get IsDifferent(): number;
  9842. /**
  9843. * Returns the number for IsGreater
  9844. */
  9845. static get IsGreater(): number;
  9846. /**
  9847. * Returns the number for IsLesser
  9848. */
  9849. static get IsLesser(): number;
  9850. /**
  9851. * Internal only The action manager for the condition
  9852. * @hidden
  9853. */
  9854. _actionManager: ActionManager;
  9855. /**
  9856. * Internal only
  9857. * @hidden
  9858. */
  9859. private _target;
  9860. /**
  9861. * Internal only
  9862. * @hidden
  9863. */
  9864. private _effectiveTarget;
  9865. /**
  9866. * Internal only
  9867. * @hidden
  9868. */
  9869. private _property;
  9870. /**
  9871. * Creates a new ValueCondition
  9872. * @param actionManager manager for the action the condition applies to
  9873. * @param target for the action
  9874. * @param propertyPath path to specify the property of the target the conditional operator uses
  9875. * @param value the value compared by the conditional operator against the current value of the property
  9876. * @param operator the conditional operator, default ValueCondition.IsEqual
  9877. */
  9878. constructor(actionManager: ActionManager, target: any,
  9879. /** path to specify the property of the target the conditional operator uses */
  9880. propertyPath: string,
  9881. /** the value compared by the conditional operator against the current value of the property */
  9882. value: any,
  9883. /** the conditional operator, default ValueCondition.IsEqual */
  9884. operator?: number);
  9885. /**
  9886. * Compares the given value with the property value for the specified conditional operator
  9887. * @returns the result of the comparison
  9888. */
  9889. isValid(): boolean;
  9890. /**
  9891. * Serialize the ValueCondition into a JSON compatible object
  9892. * @returns serialization object
  9893. */
  9894. serialize(): any;
  9895. /**
  9896. * Gets the name of the conditional operator for the ValueCondition
  9897. * @param operator the conditional operator
  9898. * @returns the name
  9899. */
  9900. static GetOperatorName(operator: number): string;
  9901. }
  9902. /**
  9903. * Defines a predicate condition as an extension of Condition
  9904. */
  9905. export class PredicateCondition extends Condition {
  9906. /** defines the predicate function used to validate the condition */
  9907. predicate: () => boolean;
  9908. /**
  9909. * Internal only - manager for action
  9910. * @hidden
  9911. */
  9912. _actionManager: ActionManager;
  9913. /**
  9914. * Creates a new PredicateCondition
  9915. * @param actionManager manager for the action the condition applies to
  9916. * @param predicate defines the predicate function used to validate the condition
  9917. */
  9918. constructor(actionManager: ActionManager,
  9919. /** defines the predicate function used to validate the condition */
  9920. predicate: () => boolean);
  9921. /**
  9922. * @returns the validity of the predicate condition
  9923. */
  9924. isValid(): boolean;
  9925. }
  9926. /**
  9927. * Defines a state condition as an extension of Condition
  9928. */
  9929. export class StateCondition extends Condition {
  9930. /** Value to compare with target state */
  9931. value: string;
  9932. /**
  9933. * Internal only - manager for action
  9934. * @hidden
  9935. */
  9936. _actionManager: ActionManager;
  9937. /**
  9938. * Internal only
  9939. * @hidden
  9940. */
  9941. private _target;
  9942. /**
  9943. * Creates a new StateCondition
  9944. * @param actionManager manager for the action the condition applies to
  9945. * @param target of the condition
  9946. * @param value to compare with target state
  9947. */
  9948. constructor(actionManager: ActionManager, target: any,
  9949. /** Value to compare with target state */
  9950. value: string);
  9951. /**
  9952. * Gets a boolean indicating if the current condition is met
  9953. * @returns the validity of the state
  9954. */
  9955. isValid(): boolean;
  9956. /**
  9957. * Serialize the StateCondition into a JSON compatible object
  9958. * @returns serialization object
  9959. */
  9960. serialize(): any;
  9961. }
  9962. }
  9963. declare module "babylonjs/Actions/directActions" {
  9964. import { Action } from "babylonjs/Actions/action";
  9965. import { Condition } from "babylonjs/Actions/condition";
  9966. import { ActionEvent } from "babylonjs/Actions/actionEvent";
  9967. /**
  9968. * This defines an action responsible to toggle a boolean once triggered.
  9969. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  9970. */
  9971. export class SwitchBooleanAction extends Action {
  9972. /**
  9973. * The path to the boolean property in the target object
  9974. */
  9975. propertyPath: string;
  9976. private _target;
  9977. private _effectiveTarget;
  9978. private _property;
  9979. /**
  9980. * Instantiate the action
  9981. * @param triggerOptions defines the trigger options
  9982. * @param target defines the object containing the boolean
  9983. * @param propertyPath defines the path to the boolean property in the target object
  9984. * @param condition defines the trigger related conditions
  9985. */
  9986. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  9987. /** @hidden */
  9988. _prepare(): void;
  9989. /**
  9990. * Execute the action toggle the boolean value.
  9991. */
  9992. execute(): void;
  9993. /**
  9994. * Serializes the actions and its related information.
  9995. * @param parent defines the object to serialize in
  9996. * @returns the serialized object
  9997. */
  9998. serialize(parent: any): any;
  9999. }
  10000. /**
  10001. * This defines an action responsible to set a the state field of the target
  10002. * to a desired value once triggered.
  10003. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10004. */
  10005. export class SetStateAction extends Action {
  10006. /**
  10007. * The value to store in the state field.
  10008. */
  10009. value: string;
  10010. private _target;
  10011. /**
  10012. * Instantiate the action
  10013. * @param triggerOptions defines the trigger options
  10014. * @param target defines the object containing the state property
  10015. * @param value defines the value to store in the state field
  10016. * @param condition defines the trigger related conditions
  10017. */
  10018. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  10019. /**
  10020. * Execute the action and store the value on the target state property.
  10021. */
  10022. execute(): void;
  10023. /**
  10024. * Serializes the actions and its related information.
  10025. * @param parent defines the object to serialize in
  10026. * @returns the serialized object
  10027. */
  10028. serialize(parent: any): any;
  10029. }
  10030. /**
  10031. * This defines an action responsible to set a property of the target
  10032. * to a desired value once triggered.
  10033. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10034. */
  10035. export class SetValueAction extends Action {
  10036. /**
  10037. * The path of the property to set in the target.
  10038. */
  10039. propertyPath: string;
  10040. /**
  10041. * The value to set in the property
  10042. */
  10043. value: any;
  10044. private _target;
  10045. private _effectiveTarget;
  10046. private _property;
  10047. /**
  10048. * Instantiate the action
  10049. * @param triggerOptions defines the trigger options
  10050. * @param target defines the object containing the property
  10051. * @param propertyPath defines the path of the property to set in the target
  10052. * @param value defines the value to set in the property
  10053. * @param condition defines the trigger related conditions
  10054. */
  10055. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10056. /** @hidden */
  10057. _prepare(): void;
  10058. /**
  10059. * Execute the action and set the targetted property to the desired value.
  10060. */
  10061. execute(): void;
  10062. /**
  10063. * Serializes the actions and its related information.
  10064. * @param parent defines the object to serialize in
  10065. * @returns the serialized object
  10066. */
  10067. serialize(parent: any): any;
  10068. }
  10069. /**
  10070. * This defines an action responsible to increment the target value
  10071. * to a desired value once triggered.
  10072. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10073. */
  10074. export class IncrementValueAction extends Action {
  10075. /**
  10076. * The path of the property to increment in the target.
  10077. */
  10078. propertyPath: string;
  10079. /**
  10080. * The value we should increment the property by.
  10081. */
  10082. value: any;
  10083. private _target;
  10084. private _effectiveTarget;
  10085. private _property;
  10086. /**
  10087. * Instantiate the action
  10088. * @param triggerOptions defines the trigger options
  10089. * @param target defines the object containing the property
  10090. * @param propertyPath defines the path of the property to increment in the target
  10091. * @param value defines the value value we should increment the property by
  10092. * @param condition defines the trigger related conditions
  10093. */
  10094. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  10095. /** @hidden */
  10096. _prepare(): void;
  10097. /**
  10098. * Execute the action and increment the target of the value amount.
  10099. */
  10100. execute(): void;
  10101. /**
  10102. * Serializes the actions and its related information.
  10103. * @param parent defines the object to serialize in
  10104. * @returns the serialized object
  10105. */
  10106. serialize(parent: any): any;
  10107. }
  10108. /**
  10109. * This defines an action responsible to start an animation once triggered.
  10110. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10111. */
  10112. export class PlayAnimationAction extends Action {
  10113. /**
  10114. * Where the animation should start (animation frame)
  10115. */
  10116. from: number;
  10117. /**
  10118. * Where the animation should stop (animation frame)
  10119. */
  10120. to: number;
  10121. /**
  10122. * Define if the animation should loop or stop after the first play.
  10123. */
  10124. loop?: boolean;
  10125. private _target;
  10126. /**
  10127. * Instantiate the action
  10128. * @param triggerOptions defines the trigger options
  10129. * @param target defines the target animation or animation name
  10130. * @param from defines from where the animation should start (animation frame)
  10131. * @param end defines where the animation should stop (animation frame)
  10132. * @param loop defines if the animation should loop or stop after the first play
  10133. * @param condition defines the trigger related conditions
  10134. */
  10135. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  10136. /** @hidden */
  10137. _prepare(): void;
  10138. /**
  10139. * Execute the action and play the animation.
  10140. */
  10141. execute(): void;
  10142. /**
  10143. * Serializes the actions and its related information.
  10144. * @param parent defines the object to serialize in
  10145. * @returns the serialized object
  10146. */
  10147. serialize(parent: any): any;
  10148. }
  10149. /**
  10150. * This defines an action responsible to stop an animation once triggered.
  10151. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10152. */
  10153. export class StopAnimationAction extends Action {
  10154. private _target;
  10155. /**
  10156. * Instantiate the action
  10157. * @param triggerOptions defines the trigger options
  10158. * @param target defines the target animation or animation name
  10159. * @param condition defines the trigger related conditions
  10160. */
  10161. constructor(triggerOptions: any, target: any, condition?: Condition);
  10162. /** @hidden */
  10163. _prepare(): void;
  10164. /**
  10165. * Execute the action and stop the animation.
  10166. */
  10167. execute(): void;
  10168. /**
  10169. * Serializes the actions and its related information.
  10170. * @param parent defines the object to serialize in
  10171. * @returns the serialized object
  10172. */
  10173. serialize(parent: any): any;
  10174. }
  10175. /**
  10176. * This defines an action responsible that does nothing once triggered.
  10177. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10178. */
  10179. export class DoNothingAction extends Action {
  10180. /**
  10181. * Instantiate the action
  10182. * @param triggerOptions defines the trigger options
  10183. * @param condition defines the trigger related conditions
  10184. */
  10185. constructor(triggerOptions?: any, condition?: Condition);
  10186. /**
  10187. * Execute the action and do nothing.
  10188. */
  10189. execute(): void;
  10190. /**
  10191. * Serializes the actions and its related information.
  10192. * @param parent defines the object to serialize in
  10193. * @returns the serialized object
  10194. */
  10195. serialize(parent: any): any;
  10196. }
  10197. /**
  10198. * This defines an action responsible to trigger several actions once triggered.
  10199. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10200. */
  10201. export class CombineAction extends Action {
  10202. /**
  10203. * The list of aggregated animations to run.
  10204. */
  10205. children: Action[];
  10206. /**
  10207. * Instantiate the action
  10208. * @param triggerOptions defines the trigger options
  10209. * @param children defines the list of aggregated animations to run
  10210. * @param condition defines the trigger related conditions
  10211. */
  10212. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  10213. /** @hidden */
  10214. _prepare(): void;
  10215. /**
  10216. * Execute the action and executes all the aggregated actions.
  10217. */
  10218. execute(evt: ActionEvent): void;
  10219. /**
  10220. * Serializes the actions and its related information.
  10221. * @param parent defines the object to serialize in
  10222. * @returns the serialized object
  10223. */
  10224. serialize(parent: any): any;
  10225. }
  10226. /**
  10227. * This defines an action responsible to run code (external event) once triggered.
  10228. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10229. */
  10230. export class ExecuteCodeAction extends Action {
  10231. /**
  10232. * The callback function to run.
  10233. */
  10234. func: (evt: ActionEvent) => void;
  10235. /**
  10236. * Instantiate the action
  10237. * @param triggerOptions defines the trigger options
  10238. * @param func defines the callback function to run
  10239. * @param condition defines the trigger related conditions
  10240. */
  10241. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  10242. /**
  10243. * Execute the action and run the attached code.
  10244. */
  10245. execute(evt: ActionEvent): void;
  10246. }
  10247. /**
  10248. * This defines an action responsible to set the parent property of the target once triggered.
  10249. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10250. */
  10251. export class SetParentAction extends Action {
  10252. private _parent;
  10253. private _target;
  10254. /**
  10255. * Instantiate the action
  10256. * @param triggerOptions defines the trigger options
  10257. * @param target defines the target containing the parent property
  10258. * @param parent defines from where the animation should start (animation frame)
  10259. * @param condition defines the trigger related conditions
  10260. */
  10261. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  10262. /** @hidden */
  10263. _prepare(): void;
  10264. /**
  10265. * Execute the action and set the parent property.
  10266. */
  10267. execute(): void;
  10268. /**
  10269. * Serializes the actions and its related information.
  10270. * @param parent defines the object to serialize in
  10271. * @returns the serialized object
  10272. */
  10273. serialize(parent: any): any;
  10274. }
  10275. }
  10276. declare module "babylonjs/Actions/actionManager" {
  10277. import { Nullable } from "babylonjs/types";
  10278. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10279. import { Scene } from "babylonjs/scene";
  10280. import { IAction } from "babylonjs/Actions/action";
  10281. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  10282. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  10283. /**
  10284. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  10285. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  10286. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  10287. */
  10288. export class ActionManager extends AbstractActionManager {
  10289. /**
  10290. * Nothing
  10291. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10292. */
  10293. static readonly NothingTrigger: number;
  10294. /**
  10295. * On pick
  10296. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10297. */
  10298. static readonly OnPickTrigger: number;
  10299. /**
  10300. * On left pick
  10301. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10302. */
  10303. static readonly OnLeftPickTrigger: number;
  10304. /**
  10305. * On right pick
  10306. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10307. */
  10308. static readonly OnRightPickTrigger: number;
  10309. /**
  10310. * On center pick
  10311. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10312. */
  10313. static readonly OnCenterPickTrigger: number;
  10314. /**
  10315. * On pick down
  10316. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10317. */
  10318. static readonly OnPickDownTrigger: number;
  10319. /**
  10320. * On double pick
  10321. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10322. */
  10323. static readonly OnDoublePickTrigger: number;
  10324. /**
  10325. * On pick up
  10326. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10327. */
  10328. static readonly OnPickUpTrigger: number;
  10329. /**
  10330. * On pick out.
  10331. * This trigger will only be raised if you also declared a OnPickDown
  10332. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10333. */
  10334. static readonly OnPickOutTrigger: number;
  10335. /**
  10336. * On long press
  10337. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10338. */
  10339. static readonly OnLongPressTrigger: number;
  10340. /**
  10341. * On pointer over
  10342. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10343. */
  10344. static readonly OnPointerOverTrigger: number;
  10345. /**
  10346. * On pointer out
  10347. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10348. */
  10349. static readonly OnPointerOutTrigger: number;
  10350. /**
  10351. * On every frame
  10352. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10353. */
  10354. static readonly OnEveryFrameTrigger: number;
  10355. /**
  10356. * On intersection enter
  10357. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10358. */
  10359. static readonly OnIntersectionEnterTrigger: number;
  10360. /**
  10361. * On intersection exit
  10362. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10363. */
  10364. static readonly OnIntersectionExitTrigger: number;
  10365. /**
  10366. * On key down
  10367. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10368. */
  10369. static readonly OnKeyDownTrigger: number;
  10370. /**
  10371. * On key up
  10372. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  10373. */
  10374. static readonly OnKeyUpTrigger: number;
  10375. private _scene;
  10376. /**
  10377. * Creates a new action manager
  10378. * @param scene defines the hosting scene
  10379. */
  10380. constructor(scene: Scene);
  10381. /**
  10382. * Releases all associated resources
  10383. */
  10384. dispose(): void;
  10385. /**
  10386. * Gets hosting scene
  10387. * @returns the hosting scene
  10388. */
  10389. getScene(): Scene;
  10390. /**
  10391. * Does this action manager handles actions of any of the given triggers
  10392. * @param triggers defines the triggers to be tested
  10393. * @return a boolean indicating whether one (or more) of the triggers is handled
  10394. */
  10395. hasSpecificTriggers(triggers: number[]): boolean;
  10396. /**
  10397. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  10398. * speed.
  10399. * @param triggerA defines the trigger to be tested
  10400. * @param triggerB defines the trigger to be tested
  10401. * @return a boolean indicating whether one (or more) of the triggers is handled
  10402. */
  10403. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  10404. /**
  10405. * Does this action manager handles actions of a given trigger
  10406. * @param trigger defines the trigger to be tested
  10407. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  10408. * @return whether the trigger is handled
  10409. */
  10410. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  10411. /**
  10412. * Does this action manager has pointer triggers
  10413. */
  10414. get hasPointerTriggers(): boolean;
  10415. /**
  10416. * Does this action manager has pick triggers
  10417. */
  10418. get hasPickTriggers(): boolean;
  10419. /**
  10420. * Registers an action to this action manager
  10421. * @param action defines the action to be registered
  10422. * @return the action amended (prepared) after registration
  10423. */
  10424. registerAction(action: IAction): Nullable<IAction>;
  10425. /**
  10426. * Unregisters an action to this action manager
  10427. * @param action defines the action to be unregistered
  10428. * @return a boolean indicating whether the action has been unregistered
  10429. */
  10430. unregisterAction(action: IAction): Boolean;
  10431. /**
  10432. * Process a specific trigger
  10433. * @param trigger defines the trigger to process
  10434. * @param evt defines the event details to be processed
  10435. */
  10436. processTrigger(trigger: number, evt?: IActionEvent): void;
  10437. /** @hidden */
  10438. _getEffectiveTarget(target: any, propertyPath: string): any;
  10439. /** @hidden */
  10440. _getProperty(propertyPath: string): string;
  10441. /**
  10442. * Serialize this manager to a JSON object
  10443. * @param name defines the property name to store this manager
  10444. * @returns a JSON representation of this manager
  10445. */
  10446. serialize(name: string): any;
  10447. /**
  10448. * Creates a new ActionManager from a JSON data
  10449. * @param parsedActions defines the JSON data to read from
  10450. * @param object defines the hosting mesh
  10451. * @param scene defines the hosting scene
  10452. */
  10453. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  10454. /**
  10455. * Get a trigger name by index
  10456. * @param trigger defines the trigger index
  10457. * @returns a trigger name
  10458. */
  10459. static GetTriggerName(trigger: number): string;
  10460. }
  10461. }
  10462. declare module "babylonjs/Sprites/sprite" {
  10463. import { Vector3 } from "babylonjs/Maths/math.vector";
  10464. import { Nullable } from "babylonjs/types";
  10465. import { ActionManager } from "babylonjs/Actions/actionManager";
  10466. import { ISpriteManager, SpriteManager } from "babylonjs/Sprites/spriteManager";
  10467. import { Color4 } from "babylonjs/Maths/math.color";
  10468. import { Observable } from "babylonjs/Misc/observable";
  10469. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  10470. import { Animation } from "babylonjs/Animations/animation";
  10471. /**
  10472. * Class used to represent a sprite
  10473. * @see https://doc.babylonjs.com/babylon101/sprites
  10474. */
  10475. export class Sprite implements IAnimatable {
  10476. /** defines the name */
  10477. name: string;
  10478. /** Gets or sets the current world position */
  10479. position: Vector3;
  10480. /** Gets or sets the main color */
  10481. color: Color4;
  10482. /** Gets or sets the width */
  10483. width: number;
  10484. /** Gets or sets the height */
  10485. height: number;
  10486. /** Gets or sets rotation angle */
  10487. angle: number;
  10488. /** Gets or sets the cell index in the sprite sheet */
  10489. cellIndex: number;
  10490. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  10491. cellRef: string;
  10492. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  10493. invertU: boolean;
  10494. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  10495. invertV: boolean;
  10496. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  10497. disposeWhenFinishedAnimating: boolean;
  10498. /** Gets the list of attached animations */
  10499. animations: Nullable<Array<Animation>>;
  10500. /** Gets or sets a boolean indicating if the sprite can be picked */
  10501. isPickable: boolean;
  10502. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  10503. useAlphaForPicking: boolean;
  10504. /** @hidden */
  10505. _xOffset: number;
  10506. /** @hidden */
  10507. _yOffset: number;
  10508. /** @hidden */
  10509. _xSize: number;
  10510. /** @hidden */
  10511. _ySize: number;
  10512. /**
  10513. * Gets or sets the associated action manager
  10514. */
  10515. actionManager: Nullable<ActionManager>;
  10516. /**
  10517. * An event triggered when the control has been disposed
  10518. */
  10519. onDisposeObservable: Observable<Sprite>;
  10520. private _animationStarted;
  10521. private _loopAnimation;
  10522. private _fromIndex;
  10523. private _toIndex;
  10524. private _delay;
  10525. private _direction;
  10526. private _manager;
  10527. private _time;
  10528. private _onAnimationEnd;
  10529. /**
  10530. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  10531. */
  10532. isVisible: boolean;
  10533. /**
  10534. * Gets or sets the sprite size
  10535. */
  10536. get size(): number;
  10537. set size(value: number);
  10538. /**
  10539. * Returns a boolean indicating if the animation is started
  10540. */
  10541. get animationStarted(): boolean;
  10542. /**
  10543. * Gets or sets the unique id of the sprite
  10544. */
  10545. uniqueId: number;
  10546. /**
  10547. * Gets the manager of this sprite
  10548. */
  10549. get manager(): ISpriteManager;
  10550. /**
  10551. * Creates a new Sprite
  10552. * @param name defines the name
  10553. * @param manager defines the manager
  10554. */
  10555. constructor(
  10556. /** defines the name */
  10557. name: string, manager: ISpriteManager);
  10558. /**
  10559. * Returns the string "Sprite"
  10560. * @returns "Sprite"
  10561. */
  10562. getClassName(): string;
  10563. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  10564. get fromIndex(): number;
  10565. set fromIndex(value: number);
  10566. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  10567. get toIndex(): number;
  10568. set toIndex(value: number);
  10569. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  10570. get loopAnimation(): boolean;
  10571. set loopAnimation(value: boolean);
  10572. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  10573. get delay(): number;
  10574. set delay(value: number);
  10575. /**
  10576. * Starts an animation
  10577. * @param from defines the initial key
  10578. * @param to defines the end key
  10579. * @param loop defines if the animation must loop
  10580. * @param delay defines the start delay (in ms)
  10581. * @param onAnimationEnd defines a callback to call when animation ends
  10582. */
  10583. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  10584. /** Stops current animation (if any) */
  10585. stopAnimation(): void;
  10586. /** @hidden */
  10587. _animate(deltaTime: number): void;
  10588. /** Release associated resources */
  10589. dispose(): void;
  10590. /**
  10591. * Serializes the sprite to a JSON object
  10592. * @returns the JSON object
  10593. */
  10594. serialize(): any;
  10595. /**
  10596. * Parses a JSON object to create a new sprite
  10597. * @param parsedSprite The JSON object to parse
  10598. * @param manager defines the hosting manager
  10599. * @returns the new sprite
  10600. */
  10601. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  10602. }
  10603. }
  10604. declare module "babylonjs/Collisions/pickingInfo" {
  10605. import { Nullable } from "babylonjs/types";
  10606. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  10607. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10608. import { Sprite } from "babylonjs/Sprites/sprite";
  10609. import { Ray } from "babylonjs/Culling/ray";
  10610. /**
  10611. * Information about the result of picking within a scene
  10612. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  10613. */
  10614. export class PickingInfo {
  10615. /** @hidden */
  10616. _pickingUnavailable: boolean;
  10617. /**
  10618. * If the pick collided with an object
  10619. */
  10620. hit: boolean;
  10621. /**
  10622. * Distance away where the pick collided
  10623. */
  10624. distance: number;
  10625. /**
  10626. * The location of pick collision
  10627. */
  10628. pickedPoint: Nullable<Vector3>;
  10629. /**
  10630. * The mesh corresponding the the pick collision
  10631. */
  10632. pickedMesh: Nullable<AbstractMesh>;
  10633. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  10634. bu: number;
  10635. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  10636. bv: number;
  10637. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10638. faceId: number;
  10639. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  10640. subMeshFaceId: number;
  10641. /** Id of the the submesh that was picked */
  10642. subMeshId: number;
  10643. /** If a sprite was picked, this will be the sprite the pick collided with */
  10644. pickedSprite: Nullable<Sprite>;
  10645. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  10646. thinInstanceIndex: number;
  10647. /**
  10648. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  10649. */
  10650. originMesh: Nullable<AbstractMesh>;
  10651. /**
  10652. * The ray that was used to perform the picking.
  10653. */
  10654. ray: Nullable<Ray>;
  10655. /**
  10656. * Gets the normal correspodning to the face the pick collided with
  10657. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  10658. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  10659. * @returns The normal correspodning to the face the pick collided with
  10660. */
  10661. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  10662. /**
  10663. * Gets the texture coordinates of where the pick occured
  10664. * @returns the vector containing the coordnates of the texture
  10665. */
  10666. getTextureCoordinates(): Nullable<Vector2>;
  10667. }
  10668. }
  10669. declare module "babylonjs/Culling/ray" {
  10670. import { DeepImmutable, Nullable, float } from "babylonjs/types";
  10671. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  10672. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10673. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10674. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  10675. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  10676. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  10677. import { Plane } from "babylonjs/Maths/math.plane";
  10678. /**
  10679. * Class representing a ray with position and direction
  10680. */
  10681. export class Ray {
  10682. /** origin point */
  10683. origin: Vector3;
  10684. /** direction */
  10685. direction: Vector3;
  10686. /** length of the ray */
  10687. length: number;
  10688. private static readonly _TmpVector3;
  10689. private _tmpRay;
  10690. /**
  10691. * Creates a new ray
  10692. * @param origin origin point
  10693. * @param direction direction
  10694. * @param length length of the ray
  10695. */
  10696. constructor(
  10697. /** origin point */
  10698. origin: Vector3,
  10699. /** direction */
  10700. direction: Vector3,
  10701. /** length of the ray */
  10702. length?: number);
  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 minimum bound of the box
  10707. * @param maximum bound of the box
  10708. * @param intersectionTreshold extra extend to be added to the box in all direction
  10709. * @returns if the box was hit
  10710. */
  10711. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  10712. /**
  10713. * Checks if the ray intersects a box
  10714. * This does not account for the ray lenght by design to improve perfs.
  10715. * @param box the bounding box to check
  10716. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  10717. * @returns if the box was hit
  10718. */
  10719. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  10720. /**
  10721. * If the ray hits a sphere
  10722. * @param sphere the bounding sphere to check
  10723. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  10724. * @returns true if it hits the sphere
  10725. */
  10726. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  10727. /**
  10728. * If the ray hits a triange
  10729. * @param vertex0 triangle vertex
  10730. * @param vertex1 triangle vertex
  10731. * @param vertex2 triangle vertex
  10732. * @returns intersection information if hit
  10733. */
  10734. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  10735. /**
  10736. * Checks if ray intersects a plane
  10737. * @param plane the plane to check
  10738. * @returns the distance away it was hit
  10739. */
  10740. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  10741. /**
  10742. * Calculate the intercept of a ray on a given axis
  10743. * @param axis to check 'x' | 'y' | 'z'
  10744. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  10745. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  10746. */
  10747. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  10748. /**
  10749. * Checks if ray intersects a mesh
  10750. * @param mesh the mesh to check
  10751. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10752. * @returns picking info of the intersecton
  10753. */
  10754. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  10755. /**
  10756. * Checks if ray intersects a mesh
  10757. * @param meshes the meshes to check
  10758. * @param fastCheck defines if the first intersection will be used (and not the closest)
  10759. * @param results array to store result in
  10760. * @returns Array of picking infos
  10761. */
  10762. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  10763. private _comparePickingInfo;
  10764. private static smallnum;
  10765. private static rayl;
  10766. /**
  10767. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  10768. * @param sega the first point of the segment to test the intersection against
  10769. * @param segb the second point of the segment to test the intersection against
  10770. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  10771. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  10772. */
  10773. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  10774. /**
  10775. * Update the ray from viewport position
  10776. * @param x position
  10777. * @param y y position
  10778. * @param viewportWidth viewport width
  10779. * @param viewportHeight viewport height
  10780. * @param world world matrix
  10781. * @param view view matrix
  10782. * @param projection projection matrix
  10783. * @returns this ray updated
  10784. */
  10785. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10786. /**
  10787. * Creates a ray with origin and direction of 0,0,0
  10788. * @returns the new ray
  10789. */
  10790. static Zero(): Ray;
  10791. /**
  10792. * Creates a new ray from screen space and viewport
  10793. * @param x position
  10794. * @param y y position
  10795. * @param viewportWidth viewport width
  10796. * @param viewportHeight viewport height
  10797. * @param world world matrix
  10798. * @param view view matrix
  10799. * @param projection projection matrix
  10800. * @returns new ray
  10801. */
  10802. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  10803. /**
  10804. * 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
  10805. * transformed to the given world matrix.
  10806. * @param origin The origin point
  10807. * @param end The end point
  10808. * @param world a matrix to transform the ray to. Default is the identity matrix.
  10809. * @returns the new ray
  10810. */
  10811. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  10812. /**
  10813. * Transforms a ray by a matrix
  10814. * @param ray ray to transform
  10815. * @param matrix matrix to apply
  10816. * @returns the resulting new ray
  10817. */
  10818. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  10819. /**
  10820. * Transforms a ray by a matrix
  10821. * @param ray ray to transform
  10822. * @param matrix matrix to apply
  10823. * @param result ray to store result in
  10824. */
  10825. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  10826. /**
  10827. * Unproject a ray from screen space to object space
  10828. * @param sourceX defines the screen space x coordinate to use
  10829. * @param sourceY defines the screen space y coordinate to use
  10830. * @param viewportWidth defines the current width of the viewport
  10831. * @param viewportHeight defines the current height of the viewport
  10832. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  10833. * @param view defines the view matrix to use
  10834. * @param projection defines the projection matrix to use
  10835. */
  10836. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  10837. }
  10838. /**
  10839. * Type used to define predicate used to select faces when a mesh intersection is detected
  10840. */
  10841. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  10842. module "babylonjs/scene" {
  10843. interface Scene {
  10844. /** @hidden */
  10845. _tempPickingRay: Nullable<Ray>;
  10846. /** @hidden */
  10847. _cachedRayForTransform: Ray;
  10848. /** @hidden */
  10849. _pickWithRayInverseMatrix: Matrix;
  10850. /** @hidden */
  10851. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10852. /** @hidden */
  10853. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  10854. /** @hidden */
  10855. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  10856. }
  10857. }
  10858. }
  10859. declare module "babylonjs/sceneComponent" {
  10860. import { Scene } from "babylonjs/scene";
  10861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  10862. import { SubMesh } from "babylonjs/Meshes/subMesh";
  10863. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  10864. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  10865. import { Nullable } from "babylonjs/types";
  10866. import { Camera } from "babylonjs/Cameras/camera";
  10867. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  10868. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  10869. import { AbstractScene } from "babylonjs/abstractScene";
  10870. import { Mesh } from "babylonjs/Meshes/mesh";
  10871. /**
  10872. * Groups all the scene component constants in one place to ease maintenance.
  10873. * @hidden
  10874. */
  10875. export class SceneComponentConstants {
  10876. static readonly NAME_EFFECTLAYER: string;
  10877. static readonly NAME_LAYER: string;
  10878. static readonly NAME_LENSFLARESYSTEM: string;
  10879. static readonly NAME_BOUNDINGBOXRENDERER: string;
  10880. static readonly NAME_PARTICLESYSTEM: string;
  10881. static readonly NAME_GAMEPAD: string;
  10882. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  10883. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  10884. static readonly NAME_PREPASSRENDERER: string;
  10885. static readonly NAME_DEPTHRENDERER: string;
  10886. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  10887. static readonly NAME_SPRITE: string;
  10888. static readonly NAME_SUBSURFACE: string;
  10889. static readonly NAME_OUTLINERENDERER: string;
  10890. static readonly NAME_PROCEDURALTEXTURE: string;
  10891. static readonly NAME_SHADOWGENERATOR: string;
  10892. static readonly NAME_OCTREE: string;
  10893. static readonly NAME_PHYSICSENGINE: string;
  10894. static readonly NAME_AUDIO: string;
  10895. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  10896. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10897. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  10898. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  10899. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  10900. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  10901. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  10902. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  10903. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  10904. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  10905. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  10906. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  10907. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  10908. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  10909. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  10910. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  10911. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  10912. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  10913. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  10914. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  10915. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  10916. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  10917. static readonly STEP_AFTERRENDER_AUDIO: number;
  10918. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  10919. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  10920. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  10921. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  10922. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  10923. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  10924. static readonly STEP_POINTERMOVE_SPRITE: number;
  10925. static readonly STEP_POINTERDOWN_SPRITE: number;
  10926. static readonly STEP_POINTERUP_SPRITE: number;
  10927. }
  10928. /**
  10929. * This represents a scene component.
  10930. *
  10931. * This is used to decouple the dependency the scene is having on the different workloads like
  10932. * layers, post processes...
  10933. */
  10934. export interface ISceneComponent {
  10935. /**
  10936. * The name of the component. Each component must have a unique name.
  10937. */
  10938. name: string;
  10939. /**
  10940. * The scene the component belongs to.
  10941. */
  10942. scene: Scene;
  10943. /**
  10944. * Register the component to one instance of a scene.
  10945. */
  10946. register(): void;
  10947. /**
  10948. * Rebuilds the elements related to this component in case of
  10949. * context lost for instance.
  10950. */
  10951. rebuild(): void;
  10952. /**
  10953. * Disposes the component and the associated ressources.
  10954. */
  10955. dispose(): void;
  10956. }
  10957. /**
  10958. * This represents a SERIALIZABLE scene component.
  10959. *
  10960. * This extends Scene Component to add Serialization methods on top.
  10961. */
  10962. export interface ISceneSerializableComponent extends ISceneComponent {
  10963. /**
  10964. * Adds all the elements from the container to the scene
  10965. * @param container the container holding the elements
  10966. */
  10967. addFromContainer(container: AbstractScene): void;
  10968. /**
  10969. * Removes all the elements in the container from the scene
  10970. * @param container contains the elements to remove
  10971. * @param dispose if the removed element should be disposed (default: false)
  10972. */
  10973. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  10974. /**
  10975. * Serializes the component data to the specified json object
  10976. * @param serializationObject The object to serialize to
  10977. */
  10978. serialize(serializationObject: any): void;
  10979. }
  10980. /**
  10981. * Strong typing of a Mesh related stage step action
  10982. */
  10983. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  10984. /**
  10985. * Strong typing of a Evaluate Sub Mesh related stage step action
  10986. */
  10987. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  10988. /**
  10989. * Strong typing of a Active Mesh related stage step action
  10990. */
  10991. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  10992. /**
  10993. * Strong typing of a Camera related stage step action
  10994. */
  10995. export type CameraStageAction = (camera: Camera) => void;
  10996. /**
  10997. * Strong typing of a Camera Frame buffer related stage step action
  10998. */
  10999. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  11000. /**
  11001. * Strong typing of a Render Target related stage step action
  11002. */
  11003. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  11004. /**
  11005. * Strong typing of a RenderingGroup related stage step action
  11006. */
  11007. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  11008. /**
  11009. * Strong typing of a Mesh Render related stage step action
  11010. */
  11011. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  11012. /**
  11013. * Strong typing of a simple stage step action
  11014. */
  11015. export type SimpleStageAction = () => void;
  11016. /**
  11017. * Strong typing of a render target action.
  11018. */
  11019. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  11020. /**
  11021. * Strong typing of a pointer move action.
  11022. */
  11023. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  11024. /**
  11025. * Strong typing of a pointer up/down action.
  11026. */
  11027. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  11028. /**
  11029. * Representation of a stage in the scene (Basically a list of ordered steps)
  11030. * @hidden
  11031. */
  11032. export class Stage<T extends Function> extends Array<{
  11033. index: number;
  11034. component: ISceneComponent;
  11035. action: T;
  11036. }> {
  11037. /**
  11038. * Hide ctor from the rest of the world.
  11039. * @param items The items to add.
  11040. */
  11041. private constructor();
  11042. /**
  11043. * Creates a new Stage.
  11044. * @returns A new instance of a Stage
  11045. */
  11046. static Create<T extends Function>(): Stage<T>;
  11047. /**
  11048. * Registers a step in an ordered way in the targeted stage.
  11049. * @param index Defines the position to register the step in
  11050. * @param component Defines the component attached to the step
  11051. * @param action Defines the action to launch during the step
  11052. */
  11053. registerStep(index: number, component: ISceneComponent, action: T): void;
  11054. /**
  11055. * Clears all the steps from the stage.
  11056. */
  11057. clear(): void;
  11058. }
  11059. }
  11060. declare module "babylonjs/Sprites/spriteSceneComponent" {
  11061. import { Nullable } from "babylonjs/types";
  11062. import { Observable } from "babylonjs/Misc/observable";
  11063. import { Scene } from "babylonjs/scene";
  11064. import { Sprite } from "babylonjs/Sprites/sprite";
  11065. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  11066. import { Ray } from "babylonjs/Culling/ray";
  11067. import { Camera } from "babylonjs/Cameras/camera";
  11068. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11069. import { ISceneComponent } from "babylonjs/sceneComponent";
  11070. module "babylonjs/scene" {
  11071. interface Scene {
  11072. /** @hidden */
  11073. _pointerOverSprite: Nullable<Sprite>;
  11074. /** @hidden */
  11075. _pickedDownSprite: Nullable<Sprite>;
  11076. /** @hidden */
  11077. _tempSpritePickingRay: Nullable<Ray>;
  11078. /**
  11079. * All of the sprite managers added to this scene
  11080. * @see https://doc.babylonjs.com/babylon101/sprites
  11081. */
  11082. spriteManagers: Array<ISpriteManager>;
  11083. /**
  11084. * An event triggered when sprites rendering is about to start
  11085. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11086. */
  11087. onBeforeSpritesRenderingObservable: Observable<Scene>;
  11088. /**
  11089. * An event triggered when sprites rendering is done
  11090. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  11091. */
  11092. onAfterSpritesRenderingObservable: Observable<Scene>;
  11093. /** @hidden */
  11094. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11095. /** Launch a ray to try to pick a sprite in the scene
  11096. * @param x position on screen
  11097. * @param y position on screen
  11098. * @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
  11099. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11100. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11101. * @returns a PickingInfo
  11102. */
  11103. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11104. /** Use the given ray to pick a sprite in the scene
  11105. * @param ray The ray (in world space) to use to pick meshes
  11106. * @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
  11107. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11108. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11109. * @returns a PickingInfo
  11110. */
  11111. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  11112. /** @hidden */
  11113. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11114. /** Launch a ray to try to pick sprites in the scene
  11115. * @param x position on screen
  11116. * @param y position on screen
  11117. * @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
  11118. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  11119. * @returns a PickingInfo array
  11120. */
  11121. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11122. /** Use the given ray to pick sprites in the scene
  11123. * @param ray The ray (in world space) to use to pick meshes
  11124. * @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
  11125. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  11126. * @returns a PickingInfo array
  11127. */
  11128. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  11129. /**
  11130. * Force the sprite under the pointer
  11131. * @param sprite defines the sprite to use
  11132. */
  11133. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  11134. /**
  11135. * Gets the sprite under the pointer
  11136. * @returns a Sprite or null if no sprite is under the pointer
  11137. */
  11138. getPointerOverSprite(): Nullable<Sprite>;
  11139. }
  11140. }
  11141. /**
  11142. * Defines the sprite scene component responsible to manage sprites
  11143. * in a given scene.
  11144. */
  11145. export class SpriteSceneComponent implements ISceneComponent {
  11146. /**
  11147. * The component name helpfull to identify the component in the list of scene components.
  11148. */
  11149. readonly name: string;
  11150. /**
  11151. * The scene the component belongs to.
  11152. */
  11153. scene: Scene;
  11154. /** @hidden */
  11155. private _spritePredicate;
  11156. /**
  11157. * Creates a new instance of the component for the given scene
  11158. * @param scene Defines the scene to register the component in
  11159. */
  11160. constructor(scene: Scene);
  11161. /**
  11162. * Registers the component in a given scene
  11163. */
  11164. register(): void;
  11165. /**
  11166. * Rebuilds the elements related to this component in case of
  11167. * context lost for instance.
  11168. */
  11169. rebuild(): void;
  11170. /**
  11171. * Disposes the component and the associated ressources.
  11172. */
  11173. dispose(): void;
  11174. private _pickSpriteButKeepRay;
  11175. private _pointerMove;
  11176. private _pointerDown;
  11177. private _pointerUp;
  11178. }
  11179. }
  11180. declare module "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration" {
  11181. /** @hidden */
  11182. export var fogFragmentDeclaration: {
  11183. name: string;
  11184. shader: string;
  11185. };
  11186. }
  11187. declare module "babylonjs/Shaders/ShadersInclude/fogFragment" {
  11188. /** @hidden */
  11189. export var fogFragment: {
  11190. name: string;
  11191. shader: string;
  11192. };
  11193. }
  11194. declare module "babylonjs/Shaders/sprites.fragment" {
  11195. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  11196. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  11197. /** @hidden */
  11198. export var spritesPixelShader: {
  11199. name: string;
  11200. shader: string;
  11201. };
  11202. }
  11203. declare module "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration" {
  11204. /** @hidden */
  11205. export var fogVertexDeclaration: {
  11206. name: string;
  11207. shader: string;
  11208. };
  11209. }
  11210. declare module "babylonjs/Shaders/sprites.vertex" {
  11211. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  11212. /** @hidden */
  11213. export var spritesVertexShader: {
  11214. name: string;
  11215. shader: string;
  11216. };
  11217. }
  11218. declare module "babylonjs/Sprites/spriteManager" {
  11219. import { IDisposable, Scene } from "babylonjs/scene";
  11220. import { Nullable } from "babylonjs/types";
  11221. import { Observable } from "babylonjs/Misc/observable";
  11222. import { Sprite } from "babylonjs/Sprites/sprite";
  11223. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  11224. import { Camera } from "babylonjs/Cameras/camera";
  11225. import { Texture } from "babylonjs/Materials/Textures/texture";
  11226. import "babylonjs/Shaders/sprites.fragment";
  11227. import "babylonjs/Shaders/sprites.vertex";
  11228. import { Ray } from "babylonjs/Culling/ray";
  11229. /**
  11230. * Defines the minimum interface to fullfil in order to be a sprite manager.
  11231. */
  11232. export interface ISpriteManager extends IDisposable {
  11233. /**
  11234. * Gets manager's name
  11235. */
  11236. name: string;
  11237. /**
  11238. * Restricts the camera to viewing objects with the same layerMask.
  11239. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  11240. */
  11241. layerMask: number;
  11242. /**
  11243. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  11244. */
  11245. isPickable: boolean;
  11246. /**
  11247. * Gets the hosting scene
  11248. */
  11249. scene: Scene;
  11250. /**
  11251. * Specifies the rendering group id for this mesh (0 by default)
  11252. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  11253. */
  11254. renderingGroupId: number;
  11255. /**
  11256. * Defines the list of sprites managed by the manager.
  11257. */
  11258. sprites: Array<Sprite>;
  11259. /**
  11260. * Gets or sets the spritesheet texture
  11261. */
  11262. texture: Texture;
  11263. /** Defines the default width of a cell in the spritesheet */
  11264. cellWidth: number;
  11265. /** Defines the default height of a cell in the spritesheet */
  11266. cellHeight: number;
  11267. /**
  11268. * Tests the intersection of a sprite with a specific ray.
  11269. * @param ray The ray we are sending to test the collision
  11270. * @param camera The camera space we are sending rays in
  11271. * @param predicate A predicate allowing excluding sprites from the list of object to test
  11272. * @param fastCheck defines if the first intersection will be used (and not the closest)
  11273. * @returns picking info or null.
  11274. */
  11275. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11276. /**
  11277. * Intersects the sprites with a ray
  11278. * @param ray defines the ray to intersect with
  11279. * @param camera defines the current active camera
  11280. * @param predicate defines a predicate used to select candidate sprites
  11281. * @returns null if no hit or a PickingInfo array
  11282. */
  11283. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11284. /**
  11285. * Renders the list of sprites on screen.
  11286. */
  11287. render(): void;
  11288. }
  11289. /**
  11290. * Class used to manage multiple sprites on the same spritesheet
  11291. * @see https://doc.babylonjs.com/babylon101/sprites
  11292. */
  11293. export class SpriteManager implements ISpriteManager {
  11294. /** defines the manager's name */
  11295. name: string;
  11296. /** Define the Url to load snippets */
  11297. static SnippetUrl: string;
  11298. /** Snippet ID if the manager was created from the snippet server */
  11299. snippetId: string;
  11300. /** Gets the list of sprites */
  11301. sprites: Sprite[];
  11302. /** Gets or sets the rendering group id (0 by default) */
  11303. renderingGroupId: number;
  11304. /** Gets or sets camera layer mask */
  11305. layerMask: number;
  11306. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  11307. fogEnabled: boolean;
  11308. /** Gets or sets a boolean indicating if the sprites are pickable */
  11309. isPickable: boolean;
  11310. /** Defines the default width of a cell in the spritesheet */
  11311. cellWidth: number;
  11312. /** Defines the default height of a cell in the spritesheet */
  11313. cellHeight: number;
  11314. /** Associative array from JSON sprite data file */
  11315. private _cellData;
  11316. /** Array of sprite names from JSON sprite data file */
  11317. private _spriteMap;
  11318. /** True when packed cell data from JSON file is ready*/
  11319. private _packedAndReady;
  11320. private _textureContent;
  11321. private _useInstancing;
  11322. /**
  11323. * An event triggered when the manager is disposed.
  11324. */
  11325. onDisposeObservable: Observable<SpriteManager>;
  11326. private _onDisposeObserver;
  11327. /**
  11328. * Callback called when the manager is disposed
  11329. */
  11330. set onDispose(callback: () => void);
  11331. private _capacity;
  11332. private _fromPacked;
  11333. private _spriteTexture;
  11334. private _epsilon;
  11335. private _scene;
  11336. private _vertexData;
  11337. private _buffer;
  11338. private _vertexBuffers;
  11339. private _spriteBuffer;
  11340. private _indexBuffer;
  11341. private _effectBase;
  11342. private _effectFog;
  11343. private _vertexBufferSize;
  11344. /**
  11345. * Gets or sets the unique id of the sprite
  11346. */
  11347. uniqueId: number;
  11348. /**
  11349. * Gets the array of sprites
  11350. */
  11351. get children(): Sprite[];
  11352. /**
  11353. * Gets the hosting scene
  11354. */
  11355. get scene(): Scene;
  11356. /**
  11357. * Gets the capacity of the manager
  11358. */
  11359. get capacity(): number;
  11360. /**
  11361. * Gets or sets the spritesheet texture
  11362. */
  11363. get texture(): Texture;
  11364. set texture(value: Texture);
  11365. private _blendMode;
  11366. /**
  11367. * Blend mode use to render the particle, it can be any of
  11368. * the static Constants.ALPHA_x properties provided in this class.
  11369. * Default value is Constants.ALPHA_COMBINE
  11370. */
  11371. get blendMode(): number;
  11372. set blendMode(blendMode: number);
  11373. /** Disables writing to the depth buffer when rendering the sprites.
  11374. * It can be handy to disable depth writing when using textures without alpha channel
  11375. * and setting some specific blend modes.
  11376. */
  11377. disableDepthWrite: boolean;
  11378. /**
  11379. * Creates a new sprite manager
  11380. * @param name defines the manager's name
  11381. * @param imgUrl defines the sprite sheet url
  11382. * @param capacity defines the maximum allowed number of sprites
  11383. * @param cellSize defines the size of a sprite cell
  11384. * @param scene defines the hosting scene
  11385. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  11386. * @param samplingMode defines the smapling mode to use with spritesheet
  11387. * @param fromPacked set to false; do not alter
  11388. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  11389. */
  11390. constructor(
  11391. /** defines the manager's name */
  11392. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  11393. /**
  11394. * Returns the string "SpriteManager"
  11395. * @returns "SpriteManager"
  11396. */
  11397. getClassName(): string;
  11398. private _makePacked;
  11399. private _appendSpriteVertex;
  11400. private _checkTextureAlpha;
  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. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  11407. * @returns null if no hit or a PickingInfo
  11408. */
  11409. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  11410. /**
  11411. * Intersects the sprites with a ray
  11412. * @param ray defines the ray to intersect with
  11413. * @param camera defines the current active camera
  11414. * @param predicate defines a predicate used to select candidate sprites
  11415. * @returns null if no hit or a PickingInfo array
  11416. */
  11417. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  11418. /**
  11419. * Render all child sprites
  11420. */
  11421. render(): void;
  11422. /**
  11423. * Release associated resources
  11424. */
  11425. dispose(): void;
  11426. /**
  11427. * Serializes the sprite manager to a JSON object
  11428. * @param serializeTexture defines if the texture must be serialized as well
  11429. * @returns the JSON object
  11430. */
  11431. serialize(serializeTexture?: boolean): any;
  11432. /**
  11433. * Parses a JSON object to create a new sprite manager.
  11434. * @param parsedManager The JSON object to parse
  11435. * @param scene The scene to create the sprite managerin
  11436. * @param rootUrl The root url to use to load external dependencies like texture
  11437. * @returns the new sprite manager
  11438. */
  11439. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  11440. /**
  11441. * Creates a sprite manager from a snippet saved in a remote file
  11442. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  11443. * @param url defines the url to load from
  11444. * @param scene defines the hosting scene
  11445. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11446. * @returns a promise that will resolve to the new sprite manager
  11447. */
  11448. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11449. /**
  11450. * Creates a sprite manager from a snippet saved by the sprite editor
  11451. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  11452. * @param scene defines the hosting scene
  11453. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  11454. * @returns a promise that will resolve to the new sprite manager
  11455. */
  11456. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  11457. }
  11458. }
  11459. declare module "babylonjs/Misc/gradients" {
  11460. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  11461. /** Interface used by value gradients (color, factor, ...) */
  11462. export interface IValueGradient {
  11463. /**
  11464. * Gets or sets the gradient value (between 0 and 1)
  11465. */
  11466. gradient: number;
  11467. }
  11468. /** Class used to store color4 gradient */
  11469. export class ColorGradient implements IValueGradient {
  11470. /**
  11471. * Gets or sets the gradient value (between 0 and 1)
  11472. */
  11473. gradient: number;
  11474. /**
  11475. * Gets or sets first associated color
  11476. */
  11477. color1: Color4;
  11478. /**
  11479. * Gets or sets second associated color
  11480. */
  11481. color2?: Color4 | undefined;
  11482. /**
  11483. * Creates a new color4 gradient
  11484. * @param gradient gets or sets the gradient value (between 0 and 1)
  11485. * @param color1 gets or sets first associated color
  11486. * @param color2 gets or sets first second color
  11487. */
  11488. constructor(
  11489. /**
  11490. * Gets or sets the gradient value (between 0 and 1)
  11491. */
  11492. gradient: number,
  11493. /**
  11494. * Gets or sets first associated color
  11495. */
  11496. color1: Color4,
  11497. /**
  11498. * Gets or sets second associated color
  11499. */
  11500. color2?: Color4 | undefined);
  11501. /**
  11502. * Will get a color picked randomly between color1 and color2.
  11503. * If color2 is undefined then color1 will be used
  11504. * @param result defines the target Color4 to store the result in
  11505. */
  11506. getColorToRef(result: Color4): void;
  11507. }
  11508. /** Class used to store color 3 gradient */
  11509. export class Color3Gradient implements IValueGradient {
  11510. /**
  11511. * Gets or sets the gradient value (between 0 and 1)
  11512. */
  11513. gradient: number;
  11514. /**
  11515. * Gets or sets the associated color
  11516. */
  11517. color: Color3;
  11518. /**
  11519. * Creates a new color3 gradient
  11520. * @param gradient gets or sets the gradient value (between 0 and 1)
  11521. * @param color gets or sets associated color
  11522. */
  11523. constructor(
  11524. /**
  11525. * Gets or sets the gradient value (between 0 and 1)
  11526. */
  11527. gradient: number,
  11528. /**
  11529. * Gets or sets the associated color
  11530. */
  11531. color: Color3);
  11532. }
  11533. /** Class used to store factor gradient */
  11534. export class FactorGradient implements IValueGradient {
  11535. /**
  11536. * Gets or sets the gradient value (between 0 and 1)
  11537. */
  11538. gradient: number;
  11539. /**
  11540. * Gets or sets first associated factor
  11541. */
  11542. factor1: number;
  11543. /**
  11544. * Gets or sets second associated factor
  11545. */
  11546. factor2?: number | undefined;
  11547. /**
  11548. * Creates a new factor gradient
  11549. * @param gradient gets or sets the gradient value (between 0 and 1)
  11550. * @param factor1 gets or sets first associated factor
  11551. * @param factor2 gets or sets second associated factor
  11552. */
  11553. constructor(
  11554. /**
  11555. * Gets or sets the gradient value (between 0 and 1)
  11556. */
  11557. gradient: number,
  11558. /**
  11559. * Gets or sets first associated factor
  11560. */
  11561. factor1: number,
  11562. /**
  11563. * Gets or sets second associated factor
  11564. */
  11565. factor2?: number | undefined);
  11566. /**
  11567. * Will get a number picked randomly between factor1 and factor2.
  11568. * If factor2 is undefined then factor1 will be used
  11569. * @returns the picked number
  11570. */
  11571. getFactor(): number;
  11572. }
  11573. /**
  11574. * Helper used to simplify some generic gradient tasks
  11575. */
  11576. export class GradientHelper {
  11577. /**
  11578. * Gets the current gradient from an array of IValueGradient
  11579. * @param ratio defines the current ratio to get
  11580. * @param gradients defines the array of IValueGradient
  11581. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  11582. */
  11583. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  11584. }
  11585. }
  11586. declare module "babylonjs/Engines/Extensions/engine.rawTexture" {
  11587. import { Nullable } from "babylonjs/types";
  11588. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11589. import { Scene } from "babylonjs/scene";
  11590. module "babylonjs/Engines/thinEngine" {
  11591. interface ThinEngine {
  11592. /**
  11593. * Creates a raw texture
  11594. * @param data defines the data to store in the texture
  11595. * @param width defines the width of the texture
  11596. * @param height defines the height of the texture
  11597. * @param format defines the format of the data
  11598. * @param generateMipMaps defines if the engine should generate the mip levels
  11599. * @param invertY defines if data must be stored with Y axis inverted
  11600. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  11601. * @param compression defines the compression used (null by default)
  11602. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11603. * @returns the raw texture inside an InternalTexture
  11604. */
  11605. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  11606. /**
  11607. * Update a raw texture
  11608. * @param texture defines the texture to update
  11609. * @param data defines the data to store in the texture
  11610. * @param format defines the format of the data
  11611. * @param invertY defines if data must be stored with Y axis inverted
  11612. */
  11613. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11614. /**
  11615. * Update a raw texture
  11616. * @param texture defines the texture to update
  11617. * @param data defines the data to store in the texture
  11618. * @param format defines the format of the data
  11619. * @param invertY defines if data must be stored with Y axis inverted
  11620. * @param compression defines the compression used (null by default)
  11621. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11622. */
  11623. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  11624. /**
  11625. * Creates a new raw cube texture
  11626. * @param data defines the array of data to use to create each face
  11627. * @param size defines the size of the textures
  11628. * @param format defines the format of the data
  11629. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11630. * @param generateMipMaps defines if the engine should generate the mip levels
  11631. * @param invertY defines if data must be stored with Y axis inverted
  11632. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11633. * @param compression defines the compression used (null by default)
  11634. * @returns the cube texture as an InternalTexture
  11635. */
  11636. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  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. */
  11645. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  11646. /**
  11647. * Update a raw cube texture
  11648. * @param texture defines the texture to udpdate
  11649. * @param data defines the data to store
  11650. * @param format defines the data format
  11651. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11652. * @param invertY defines if data must be stored with Y axis inverted
  11653. * @param compression defines the compression used (null by default)
  11654. */
  11655. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  11656. /**
  11657. * Update a raw cube texture
  11658. * @param texture defines the texture to udpdate
  11659. * @param data defines the data to store
  11660. * @param format defines the data format
  11661. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  11662. * @param invertY defines if data must be stored with Y axis inverted
  11663. * @param compression defines the compression used (null by default)
  11664. * @param level defines which level of the texture to update
  11665. */
  11666. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  11667. /**
  11668. * Creates a new raw cube texture from a specified url
  11669. * @param url defines the url where the data is located
  11670. * @param scene defines the current scene
  11671. * @param size defines the size of the textures
  11672. * @param format defines the format of the data
  11673. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11674. * @param noMipmap defines if the engine should avoid generating the mip levels
  11675. * @param callback defines a callback used to extract texture data from loaded data
  11676. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11677. * @param onLoad defines a callback called when texture is loaded
  11678. * @param onError defines a callback called if there is an error
  11679. * @returns the cube texture as an InternalTexture
  11680. */
  11681. 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;
  11682. /**
  11683. * Creates a new raw cube texture from a specified url
  11684. * @param url defines the url where the data is located
  11685. * @param scene defines the current scene
  11686. * @param size defines the size of the textures
  11687. * @param format defines the format of the data
  11688. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  11689. * @param noMipmap defines if the engine should avoid generating the mip levels
  11690. * @param callback defines a callback used to extract texture data from loaded data
  11691. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  11692. * @param onLoad defines a callback called when texture is loaded
  11693. * @param onError defines a callback called if there is an error
  11694. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11695. * @param invertY defines if data must be stored with Y axis inverted
  11696. * @returns the cube texture as an InternalTexture
  11697. */
  11698. 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;
  11699. /**
  11700. * Creates a new raw 3D texture
  11701. * @param data defines the data used to create the texture
  11702. * @param width defines the width of the texture
  11703. * @param height defines the height of the texture
  11704. * @param depth defines the depth of the texture
  11705. * @param format defines the format of the texture
  11706. * @param generateMipMaps defines if the engine must generate mip levels
  11707. * @param invertY defines if data must be stored with Y axis inverted
  11708. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11709. * @param compression defines the compressed used (can be null)
  11710. * @param textureType defines the compressed used (can be null)
  11711. * @returns a new raw 3D texture (stored in an InternalTexture)
  11712. */
  11713. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11714. /**
  11715. * Update a raw 3D texture
  11716. * @param texture defines the texture to update
  11717. * @param data defines the data to store
  11718. * @param format defines the data format
  11719. * @param invertY defines if data must be stored with Y axis inverted
  11720. */
  11721. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11722. /**
  11723. * Update a raw 3D texture
  11724. * @param texture defines the texture to update
  11725. * @param data defines the data to store
  11726. * @param format defines the data format
  11727. * @param invertY defines if data must be stored with Y axis inverted
  11728. * @param compression defines the used compression (can be null)
  11729. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11730. */
  11731. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11732. /**
  11733. * Creates a new raw 2D array texture
  11734. * @param data defines the data used to create the texture
  11735. * @param width defines the width of the texture
  11736. * @param height defines the height of the texture
  11737. * @param depth defines the number of layers of the texture
  11738. * @param format defines the format of the texture
  11739. * @param generateMipMaps defines if the engine must generate mip levels
  11740. * @param invertY defines if data must be stored with Y axis inverted
  11741. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  11742. * @param compression defines the compressed used (can be null)
  11743. * @param textureType defines the compressed used (can be null)
  11744. * @returns a new raw 2D array texture (stored in an InternalTexture)
  11745. */
  11746. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  11747. /**
  11748. * Update a raw 2D array texture
  11749. * @param texture defines the texture to update
  11750. * @param data defines the data to store
  11751. * @param format defines the data format
  11752. * @param invertY defines if data must be stored with Y axis inverted
  11753. */
  11754. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  11755. /**
  11756. * Update a raw 2D array texture
  11757. * @param texture defines the texture to update
  11758. * @param data defines the data to store
  11759. * @param format defines the data format
  11760. * @param invertY defines if data must be stored with Y axis inverted
  11761. * @param compression defines the used compression (can be null)
  11762. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  11763. */
  11764. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  11765. }
  11766. }
  11767. }
  11768. declare module "babylonjs/Materials/Textures/rawTexture" {
  11769. import { Texture } from "babylonjs/Materials/Textures/texture";
  11770. import "babylonjs/Engines/Extensions/engine.rawTexture";
  11771. import { Nullable } from "babylonjs/types";
  11772. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  11773. import { Scene } from "babylonjs/scene";
  11774. /**
  11775. * Raw texture can help creating a texture directly from an array of data.
  11776. * This can be super useful if you either get the data from an uncompressed source or
  11777. * if you wish to create your texture pixel by pixel.
  11778. */
  11779. export class RawTexture extends Texture {
  11780. /**
  11781. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11782. */
  11783. format: number;
  11784. /**
  11785. * Instantiates a new RawTexture.
  11786. * Raw texture can help creating a texture directly from an array of data.
  11787. * This can be super useful if you either get the data from an uncompressed source or
  11788. * if you wish to create your texture pixel by pixel.
  11789. * @param data define the array of data to use to create the texture
  11790. * @param width define the width of the texture
  11791. * @param height define the height of the texture
  11792. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11793. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11794. * @param generateMipMaps define whether mip maps should be generated or not
  11795. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11796. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11797. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11798. */
  11799. constructor(data: ArrayBufferView, width: number, height: number,
  11800. /**
  11801. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  11802. */
  11803. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  11804. /**
  11805. * Updates the texture underlying data.
  11806. * @param data Define the new data of the texture
  11807. */
  11808. update(data: ArrayBufferView): void;
  11809. /**
  11810. * Creates a luminance texture from some data.
  11811. * @param data Define the texture data
  11812. * @param width Define the width of the texture
  11813. * @param height Define the height of the texture
  11814. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11815. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11816. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11817. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11818. * @returns the luminance texture
  11819. */
  11820. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11821. /**
  11822. * Creates a luminance alpha texture from some data.
  11823. * @param data Define the texture data
  11824. * @param width Define the width of the texture
  11825. * @param height Define the height of the texture
  11826. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11827. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11828. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11829. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11830. * @returns the luminance alpha texture
  11831. */
  11832. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11833. /**
  11834. * Creates an alpha texture from some data.
  11835. * @param data Define the texture data
  11836. * @param width Define the width of the texture
  11837. * @param height Define the height of the texture
  11838. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11839. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11840. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11841. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11842. * @returns the alpha texture
  11843. */
  11844. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  11845. /**
  11846. * Creates a RGB texture from some data.
  11847. * @param data Define the texture data
  11848. * @param width Define the width of the texture
  11849. * @param height Define the height of the texture
  11850. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11851. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11852. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11853. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11854. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11855. * @returns the RGB alpha texture
  11856. */
  11857. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11858. /**
  11859. * Creates a RGBA texture from some data.
  11860. * @param data Define the texture data
  11861. * @param width Define the width of the texture
  11862. * @param height Define the height of the texture
  11863. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11864. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11865. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11866. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11867. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11868. * @returns the RGBA texture
  11869. */
  11870. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11871. /**
  11872. * Creates a R texture from some data.
  11873. * @param data Define the texture data
  11874. * @param width Define the width of the texture
  11875. * @param height Define the height of the texture
  11876. * @param sceneOrEngine defines the scene or engine the texture will belong to
  11877. * @param generateMipMaps Define whether or not to create mip maps for the texture
  11878. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  11879. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  11880. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  11881. * @returns the R texture
  11882. */
  11883. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  11884. }
  11885. }
  11886. declare module "babylonjs/Engines/Extensions/engine.dynamicBuffer" {
  11887. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  11888. import { IndicesArray, DataArray } from "babylonjs/types";
  11889. module "babylonjs/Engines/thinEngine" {
  11890. interface ThinEngine {
  11891. /**
  11892. * Update a dynamic index buffer
  11893. * @param indexBuffer defines the target index buffer
  11894. * @param indices defines the data to update
  11895. * @param offset defines the offset in the target index buffer where update should start
  11896. */
  11897. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  11898. /**
  11899. * Updates a dynamic vertex buffer.
  11900. * @param vertexBuffer the vertex buffer to update
  11901. * @param data the data used to update the vertex buffer
  11902. * @param byteOffset the byte offset of the data
  11903. * @param byteLength the byte length of the data
  11904. */
  11905. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  11906. }
  11907. }
  11908. }
  11909. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent" {
  11910. import { Scene } from "babylonjs/scene";
  11911. import { ISceneComponent } from "babylonjs/sceneComponent";
  11912. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  11913. module "babylonjs/abstractScene" {
  11914. interface AbstractScene {
  11915. /**
  11916. * The list of procedural textures added to the scene
  11917. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11918. */
  11919. proceduralTextures: Array<ProceduralTexture>;
  11920. }
  11921. }
  11922. /**
  11923. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  11924. * in a given scene.
  11925. */
  11926. export class ProceduralTextureSceneComponent implements ISceneComponent {
  11927. /**
  11928. * The component name helpfull to identify the component in the list of scene components.
  11929. */
  11930. readonly name: string;
  11931. /**
  11932. * The scene the component belongs to.
  11933. */
  11934. scene: Scene;
  11935. /**
  11936. * Creates a new instance of the component for the given scene
  11937. * @param scene Defines the scene to register the component in
  11938. */
  11939. constructor(scene: Scene);
  11940. /**
  11941. * Registers the component in a given scene
  11942. */
  11943. register(): void;
  11944. /**
  11945. * Rebuilds the elements related to this component in case of
  11946. * context lost for instance.
  11947. */
  11948. rebuild(): void;
  11949. /**
  11950. * Disposes the component and the associated ressources.
  11951. */
  11952. dispose(): void;
  11953. private _beforeClear;
  11954. }
  11955. }
  11956. declare module "babylonjs/Engines/Extensions/engine.renderTargetCube" {
  11957. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  11958. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  11959. module "babylonjs/Engines/thinEngine" {
  11960. interface ThinEngine {
  11961. /**
  11962. * Creates a new render target cube texture
  11963. * @param size defines the size of the texture
  11964. * @param options defines the options used to create the texture
  11965. * @returns a new render target cube texture stored in an InternalTexture
  11966. */
  11967. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  11968. }
  11969. }
  11970. }
  11971. declare module "babylonjs/Shaders/procedural.vertex" {
  11972. /** @hidden */
  11973. export var proceduralVertexShader: {
  11974. name: string;
  11975. shader: string;
  11976. };
  11977. }
  11978. declare module "babylonjs/Materials/Textures/Procedurals/proceduralTexture" {
  11979. import { Observable } from "babylonjs/Misc/observable";
  11980. import { Nullable } from "babylonjs/types";
  11981. import { Scene } from "babylonjs/scene";
  11982. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  11983. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  11984. import { Effect } from "babylonjs/Materials/effect";
  11985. import { Texture } from "babylonjs/Materials/Textures/texture";
  11986. import "babylonjs/Engines/Extensions/engine.renderTarget";
  11987. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  11988. import "babylonjs/Shaders/procedural.vertex";
  11989. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  11990. import { RenderTargetTextureSize } from "babylonjs/Engines/Extensions/engine.renderTarget";
  11991. /**
  11992. * 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.
  11993. * This is the base class of any Procedural texture and contains most of the shareable code.
  11994. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  11995. */
  11996. export class ProceduralTexture extends Texture {
  11997. /**
  11998. * Define if the texture is enabled or not (disabled texture will not render)
  11999. */
  12000. isEnabled: boolean;
  12001. /**
  12002. * Define if the texture must be cleared before rendering (default is true)
  12003. */
  12004. autoClear: boolean;
  12005. /**
  12006. * Callback called when the texture is generated
  12007. */
  12008. onGenerated: () => void;
  12009. /**
  12010. * Event raised when the texture is generated
  12011. */
  12012. onGeneratedObservable: Observable<ProceduralTexture>;
  12013. /**
  12014. * Event raised before the texture is generated
  12015. */
  12016. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  12017. /**
  12018. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  12019. */
  12020. nodeMaterialSource: Nullable<NodeMaterial>;
  12021. /** @hidden */
  12022. _generateMipMaps: boolean;
  12023. /** @hidden **/
  12024. _effect: Effect;
  12025. /** @hidden */
  12026. _textures: {
  12027. [key: string]: Texture;
  12028. };
  12029. /** @hidden */
  12030. protected _fallbackTexture: Nullable<Texture>;
  12031. private _size;
  12032. private _currentRefreshId;
  12033. private _frameId;
  12034. private _refreshRate;
  12035. private _vertexBuffers;
  12036. private _indexBuffer;
  12037. private _uniforms;
  12038. private _samplers;
  12039. private _fragment;
  12040. private _floats;
  12041. private _ints;
  12042. private _floatsArrays;
  12043. private _colors3;
  12044. private _colors4;
  12045. private _vectors2;
  12046. private _vectors3;
  12047. private _matrices;
  12048. private _fallbackTextureUsed;
  12049. private _fullEngine;
  12050. private _cachedDefines;
  12051. private _contentUpdateId;
  12052. private _contentData;
  12053. /**
  12054. * Instantiates a new procedural texture.
  12055. * 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.
  12056. * This is the base class of any Procedural texture and contains most of the shareable code.
  12057. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  12058. * @param name Define the name of the texture
  12059. * @param size Define the size of the texture to create
  12060. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  12061. * @param scene Define the scene the texture belongs to
  12062. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  12063. * @param generateMipMaps Define if the texture should creates mip maps or not
  12064. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  12065. * @param textureType The FBO internal texture type
  12066. */
  12067. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  12068. /**
  12069. * The effect that is created when initializing the post process.
  12070. * @returns The created effect corresponding the the postprocess.
  12071. */
  12072. getEffect(): Effect;
  12073. /**
  12074. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  12075. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  12076. */
  12077. getContent(): Nullable<ArrayBufferView>;
  12078. private _createIndexBuffer;
  12079. /** @hidden */
  12080. _rebuild(): void;
  12081. /**
  12082. * Resets the texture in order to recreate its associated resources.
  12083. * This can be called in case of context loss
  12084. */
  12085. reset(): void;
  12086. protected _getDefines(): string;
  12087. /**
  12088. * Is the texture ready to be used ? (rendered at least once)
  12089. * @returns true if ready, otherwise, false.
  12090. */
  12091. isReady(): boolean;
  12092. /**
  12093. * Resets the refresh counter of the texture and start bak from scratch.
  12094. * Could be useful to regenerate the texture if it is setup to render only once.
  12095. */
  12096. resetRefreshCounter(): void;
  12097. /**
  12098. * Set the fragment shader to use in order to render the texture.
  12099. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  12100. */
  12101. setFragment(fragment: any): void;
  12102. /**
  12103. * Define the refresh rate of the texture or the rendering frequency.
  12104. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  12105. */
  12106. get refreshRate(): number;
  12107. set refreshRate(value: number);
  12108. /** @hidden */
  12109. _shouldRender(): boolean;
  12110. /**
  12111. * Get the size the texture is rendering at.
  12112. * @returns the size (on cube texture it is always squared)
  12113. */
  12114. getRenderSize(): RenderTargetTextureSize;
  12115. /**
  12116. * Resize the texture to new value.
  12117. * @param size Define the new size the texture should have
  12118. * @param generateMipMaps Define whether the new texture should create mip maps
  12119. */
  12120. resize(size: number, generateMipMaps: boolean): void;
  12121. private _checkUniform;
  12122. /**
  12123. * Set a texture in the shader program used to render.
  12124. * @param name Define the name of the uniform samplers as defined in the shader
  12125. * @param texture Define the texture to bind to this sampler
  12126. * @return the texture itself allowing "fluent" like uniform updates
  12127. */
  12128. setTexture(name: string, texture: Texture): ProceduralTexture;
  12129. /**
  12130. * Set a float in the shader.
  12131. * @param name Define the name of the uniform as defined in the shader
  12132. * @param value Define the value to give to the uniform
  12133. * @return the texture itself allowing "fluent" like uniform updates
  12134. */
  12135. setFloat(name: string, value: number): ProceduralTexture;
  12136. /**
  12137. * Set a int in the shader.
  12138. * @param name Define the name of the uniform as defined in the shader
  12139. * @param value Define the value to give to the uniform
  12140. * @return the texture itself allowing "fluent" like uniform updates
  12141. */
  12142. setInt(name: string, value: number): ProceduralTexture;
  12143. /**
  12144. * Set an array of floats in the shader.
  12145. * @param name Define the name of the uniform as defined in the shader
  12146. * @param value Define the value to give to the uniform
  12147. * @return the texture itself allowing "fluent" like uniform updates
  12148. */
  12149. setFloats(name: string, value: number[]): ProceduralTexture;
  12150. /**
  12151. * Set a vec3 in the shader from a Color3.
  12152. * @param name Define the name of the uniform as defined in the shader
  12153. * @param value Define the value to give to the uniform
  12154. * @return the texture itself allowing "fluent" like uniform updates
  12155. */
  12156. setColor3(name: string, value: Color3): ProceduralTexture;
  12157. /**
  12158. * Set a vec4 in the shader from a Color4.
  12159. * @param name Define the name of the uniform as defined in the shader
  12160. * @param value Define the value to give to the uniform
  12161. * @return the texture itself allowing "fluent" like uniform updates
  12162. */
  12163. setColor4(name: string, value: Color4): ProceduralTexture;
  12164. /**
  12165. * Set a vec2 in the shader from a Vector2.
  12166. * @param name Define the name of the uniform as defined in the shader
  12167. * @param value Define the value to give to the uniform
  12168. * @return the texture itself allowing "fluent" like uniform updates
  12169. */
  12170. setVector2(name: string, value: Vector2): ProceduralTexture;
  12171. /**
  12172. * Set a vec3 in the shader from a Vector3.
  12173. * @param name Define the name of the uniform as defined in the shader
  12174. * @param value Define the value to give to the uniform
  12175. * @return the texture itself allowing "fluent" like uniform updates
  12176. */
  12177. setVector3(name: string, value: Vector3): ProceduralTexture;
  12178. /**
  12179. * Set a mat4 in the shader from a MAtrix.
  12180. * @param name Define the name of the uniform as defined in the shader
  12181. * @param value Define the value to give to the uniform
  12182. * @return the texture itself allowing "fluent" like uniform updates
  12183. */
  12184. setMatrix(name: string, value: Matrix): ProceduralTexture;
  12185. /**
  12186. * Render the texture to its associated render target.
  12187. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  12188. */
  12189. render(useCameraPostProcess?: boolean): void;
  12190. /**
  12191. * Clone the texture.
  12192. * @returns the cloned texture
  12193. */
  12194. clone(): ProceduralTexture;
  12195. /**
  12196. * Dispose the texture and release its asoociated resources.
  12197. */
  12198. dispose(): void;
  12199. }
  12200. }
  12201. declare module "babylonjs/Particles/baseParticleSystem" {
  12202. import { Nullable } from "babylonjs/types";
  12203. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  12204. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  12205. import { ImageProcessingConfiguration, ImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  12206. import { ColorGradient, FactorGradient, Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  12207. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  12208. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  12209. import { Color4 } from "babylonjs/Maths/math.color";
  12210. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12211. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  12212. import { Animation } from "babylonjs/Animations/animation";
  12213. import { Scene } from "babylonjs/scene";
  12214. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  12215. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  12216. /**
  12217. * This represents the base class for particle system in Babylon.
  12218. * 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.
  12219. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12220. * @example https://doc.babylonjs.com/babylon101/particles
  12221. */
  12222. export class BaseParticleSystem {
  12223. /**
  12224. * Source color is added to the destination color without alpha affecting the result
  12225. */
  12226. static BLENDMODE_ONEONE: number;
  12227. /**
  12228. * Blend current color and particle color using particle’s alpha
  12229. */
  12230. static BLENDMODE_STANDARD: number;
  12231. /**
  12232. * Add current color and particle color multiplied by particle’s alpha
  12233. */
  12234. static BLENDMODE_ADD: number;
  12235. /**
  12236. * Multiply current color with particle color
  12237. */
  12238. static BLENDMODE_MULTIPLY: number;
  12239. /**
  12240. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  12241. */
  12242. static BLENDMODE_MULTIPLYADD: number;
  12243. /**
  12244. * List of animations used by the particle system.
  12245. */
  12246. animations: Animation[];
  12247. /**
  12248. * Gets or sets the unique id of the particle system
  12249. */
  12250. uniqueId: number;
  12251. /**
  12252. * The id of the Particle system.
  12253. */
  12254. id: string;
  12255. /**
  12256. * The friendly name of the Particle system.
  12257. */
  12258. name: string;
  12259. /**
  12260. * Snippet ID if the particle system was created from the snippet server
  12261. */
  12262. snippetId: string;
  12263. /**
  12264. * The rendering group used by the Particle system to chose when to render.
  12265. */
  12266. renderingGroupId: number;
  12267. /**
  12268. * The emitter represents the Mesh or position we are attaching the particle system to.
  12269. */
  12270. emitter: Nullable<AbstractMesh | Vector3>;
  12271. /**
  12272. * The maximum number of particles to emit per frame
  12273. */
  12274. emitRate: number;
  12275. /**
  12276. * If you want to launch only a few particles at once, that can be done, as well.
  12277. */
  12278. manualEmitCount: number;
  12279. /**
  12280. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  12281. */
  12282. updateSpeed: number;
  12283. /**
  12284. * The amount of time the particle system is running (depends of the overall update speed).
  12285. */
  12286. targetStopDuration: number;
  12287. /**
  12288. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  12289. */
  12290. disposeOnStop: boolean;
  12291. /**
  12292. * Minimum power of emitting particles.
  12293. */
  12294. minEmitPower: number;
  12295. /**
  12296. * Maximum power of emitting particles.
  12297. */
  12298. maxEmitPower: number;
  12299. /**
  12300. * Minimum life time of emitting particles.
  12301. */
  12302. minLifeTime: number;
  12303. /**
  12304. * Maximum life time of emitting particles.
  12305. */
  12306. maxLifeTime: number;
  12307. /**
  12308. * Minimum Size of emitting particles.
  12309. */
  12310. minSize: number;
  12311. /**
  12312. * Maximum Size of emitting particles.
  12313. */
  12314. maxSize: number;
  12315. /**
  12316. * Minimum scale of emitting particles on X axis.
  12317. */
  12318. minScaleX: number;
  12319. /**
  12320. * Maximum scale of emitting particles on X axis.
  12321. */
  12322. maxScaleX: number;
  12323. /**
  12324. * Minimum scale of emitting particles on Y axis.
  12325. */
  12326. minScaleY: number;
  12327. /**
  12328. * Maximum scale of emitting particles on Y axis.
  12329. */
  12330. maxScaleY: number;
  12331. /**
  12332. * Gets or sets the minimal initial rotation in radians.
  12333. */
  12334. minInitialRotation: number;
  12335. /**
  12336. * Gets or sets the maximal initial rotation in radians.
  12337. */
  12338. maxInitialRotation: number;
  12339. /**
  12340. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  12341. */
  12342. minAngularSpeed: number;
  12343. /**
  12344. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  12345. */
  12346. maxAngularSpeed: number;
  12347. /**
  12348. * The texture used to render each particle. (this can be a spritesheet)
  12349. */
  12350. particleTexture: Nullable<BaseTexture>;
  12351. /**
  12352. * The layer mask we are rendering the particles through.
  12353. */
  12354. layerMask: number;
  12355. /**
  12356. * This can help using your own shader to render the particle system.
  12357. * The according effect will be created
  12358. */
  12359. customShader: any;
  12360. /**
  12361. * By default particle system starts as soon as they are created. This prevents the
  12362. * automatic start to happen and let you decide when to start emitting particles.
  12363. */
  12364. preventAutoStart: boolean;
  12365. private _noiseTexture;
  12366. /**
  12367. * Gets or sets a texture used to add random noise to particle positions
  12368. */
  12369. get noiseTexture(): Nullable<ProceduralTexture>;
  12370. set noiseTexture(value: Nullable<ProceduralTexture>);
  12371. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  12372. noiseStrength: Vector3;
  12373. /**
  12374. * Callback triggered when the particle animation is ending.
  12375. */
  12376. onAnimationEnd: Nullable<() => void>;
  12377. /**
  12378. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  12379. */
  12380. blendMode: number;
  12381. /**
  12382. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  12383. * to override the particles.
  12384. */
  12385. forceDepthWrite: boolean;
  12386. /** 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 */
  12387. preWarmCycles: number;
  12388. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  12389. preWarmStepOffset: number;
  12390. /**
  12391. * 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)
  12392. */
  12393. spriteCellChangeSpeed: number;
  12394. /**
  12395. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  12396. */
  12397. startSpriteCellID: number;
  12398. /**
  12399. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  12400. */
  12401. endSpriteCellID: number;
  12402. /**
  12403. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  12404. */
  12405. spriteCellWidth: number;
  12406. /**
  12407. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  12408. */
  12409. spriteCellHeight: number;
  12410. /**
  12411. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  12412. */
  12413. spriteRandomStartCell: boolean;
  12414. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  12415. translationPivot: Vector2;
  12416. /** @hidden */
  12417. protected _isAnimationSheetEnabled: boolean;
  12418. /**
  12419. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  12420. */
  12421. beginAnimationOnStart: boolean;
  12422. /**
  12423. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  12424. */
  12425. beginAnimationFrom: number;
  12426. /**
  12427. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  12428. */
  12429. beginAnimationTo: number;
  12430. /**
  12431. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  12432. */
  12433. beginAnimationLoop: boolean;
  12434. /**
  12435. * Gets or sets a world offset applied to all particles
  12436. */
  12437. worldOffset: Vector3;
  12438. /**
  12439. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  12440. */
  12441. get isAnimationSheetEnabled(): boolean;
  12442. set isAnimationSheetEnabled(value: boolean);
  12443. /**
  12444. * Get hosting scene
  12445. * @returns the scene
  12446. */
  12447. getScene(): Nullable<Scene>;
  12448. /**
  12449. * You can use gravity if you want to give an orientation to your particles.
  12450. */
  12451. gravity: Vector3;
  12452. protected _colorGradients: Nullable<Array<ColorGradient>>;
  12453. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  12454. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  12455. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  12456. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  12457. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  12458. protected _dragGradients: Nullable<Array<FactorGradient>>;
  12459. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  12460. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  12461. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  12462. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  12463. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  12464. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  12465. /**
  12466. * Defines the delay in milliseconds before starting the system (0 by default)
  12467. */
  12468. startDelay: number;
  12469. /**
  12470. * Gets the current list of drag gradients.
  12471. * You must use addDragGradient and removeDragGradient to udpate this list
  12472. * @returns the list of drag gradients
  12473. */
  12474. getDragGradients(): Nullable<Array<FactorGradient>>;
  12475. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  12476. limitVelocityDamping: number;
  12477. /**
  12478. * Gets the current list of limit velocity gradients.
  12479. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  12480. * @returns the list of limit velocity gradients
  12481. */
  12482. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  12483. /**
  12484. * Gets the current list of color gradients.
  12485. * You must use addColorGradient and removeColorGradient to udpate this list
  12486. * @returns the list of color gradients
  12487. */
  12488. getColorGradients(): Nullable<Array<ColorGradient>>;
  12489. /**
  12490. * Gets the current list of size gradients.
  12491. * You must use addSizeGradient and removeSizeGradient to udpate this list
  12492. * @returns the list of size gradients
  12493. */
  12494. getSizeGradients(): Nullable<Array<FactorGradient>>;
  12495. /**
  12496. * Gets the current list of color remap gradients.
  12497. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  12498. * @returns the list of color remap gradients
  12499. */
  12500. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  12501. /**
  12502. * Gets the current list of alpha remap gradients.
  12503. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  12504. * @returns the list of alpha remap gradients
  12505. */
  12506. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  12507. /**
  12508. * Gets the current list of life time gradients.
  12509. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  12510. * @returns the list of life time gradients
  12511. */
  12512. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  12513. /**
  12514. * Gets the current list of angular speed gradients.
  12515. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  12516. * @returns the list of angular speed gradients
  12517. */
  12518. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  12519. /**
  12520. * Gets the current list of velocity gradients.
  12521. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  12522. * @returns the list of velocity gradients
  12523. */
  12524. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  12525. /**
  12526. * Gets the current list of start size gradients.
  12527. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  12528. * @returns the list of start size gradients
  12529. */
  12530. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  12531. /**
  12532. * Gets the current list of emit rate gradients.
  12533. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  12534. * @returns the list of emit rate gradients
  12535. */
  12536. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  12537. /**
  12538. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12539. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12540. */
  12541. get direction1(): Vector3;
  12542. set direction1(value: Vector3);
  12543. /**
  12544. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  12545. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12546. */
  12547. get direction2(): Vector3;
  12548. set direction2(value: Vector3);
  12549. /**
  12550. * 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.
  12551. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12552. */
  12553. get minEmitBox(): Vector3;
  12554. set minEmitBox(value: Vector3);
  12555. /**
  12556. * 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.
  12557. * This only works when particleEmitterTyps is a BoxParticleEmitter
  12558. */
  12559. get maxEmitBox(): Vector3;
  12560. set maxEmitBox(value: Vector3);
  12561. /**
  12562. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12563. */
  12564. color1: Color4;
  12565. /**
  12566. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  12567. */
  12568. color2: Color4;
  12569. /**
  12570. * Color the particle will have at the end of its lifetime
  12571. */
  12572. colorDead: Color4;
  12573. /**
  12574. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  12575. */
  12576. textureMask: Color4;
  12577. /**
  12578. * The particle emitter type defines the emitter used by the particle system.
  12579. * It can be for example box, sphere, or cone...
  12580. */
  12581. particleEmitterType: IParticleEmitterType;
  12582. /** @hidden */
  12583. _isSubEmitter: boolean;
  12584. /**
  12585. * Gets or sets the billboard mode to use when isBillboardBased = true.
  12586. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  12587. */
  12588. billboardMode: number;
  12589. protected _isBillboardBased: boolean;
  12590. /**
  12591. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  12592. */
  12593. get isBillboardBased(): boolean;
  12594. set isBillboardBased(value: boolean);
  12595. /**
  12596. * The scene the particle system belongs to.
  12597. */
  12598. protected _scene: Nullable<Scene>;
  12599. /**
  12600. * The engine the particle system belongs to.
  12601. */
  12602. protected _engine: ThinEngine;
  12603. /**
  12604. * Local cache of defines for image processing.
  12605. */
  12606. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  12607. /**
  12608. * Default configuration related to image processing available in the standard Material.
  12609. */
  12610. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  12611. /**
  12612. * Gets the image processing configuration used either in this material.
  12613. */
  12614. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  12615. /**
  12616. * Sets the Default image processing configuration used either in the this material.
  12617. *
  12618. * If sets to null, the scene one is in use.
  12619. */
  12620. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  12621. /**
  12622. * Attaches a new image processing configuration to the Standard Material.
  12623. * @param configuration
  12624. */
  12625. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  12626. /** @hidden */
  12627. protected _reset(): void;
  12628. /** @hidden */
  12629. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  12630. /**
  12631. * Instantiates a particle system.
  12632. * 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.
  12633. * @param name The name of the particle system
  12634. */
  12635. constructor(name: string);
  12636. /**
  12637. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  12638. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12639. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12640. * @returns the emitter
  12641. */
  12642. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  12643. /**
  12644. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  12645. * @param radius The radius of the hemisphere to emit from
  12646. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12647. * @returns the emitter
  12648. */
  12649. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  12650. /**
  12651. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  12652. * @param radius The radius of the sphere to emit from
  12653. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  12654. * @returns the emitter
  12655. */
  12656. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  12657. /**
  12658. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  12659. * @param radius The radius of the sphere to emit from
  12660. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  12661. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  12662. * @returns the emitter
  12663. */
  12664. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  12665. /**
  12666. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  12667. * @param radius The radius of the emission cylinder
  12668. * @param height The height of the emission cylinder
  12669. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  12670. * @param directionRandomizer How much to randomize the particle direction [0-1]
  12671. * @returns the emitter
  12672. */
  12673. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  12674. /**
  12675. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  12676. * @param radius The radius of the cylinder to emit from
  12677. * @param height The height of the emission cylinder
  12678. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  12679. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  12680. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  12681. * @returns the emitter
  12682. */
  12683. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  12684. /**
  12685. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  12686. * @param radius The radius of the cone to emit from
  12687. * @param angle The base angle of the cone
  12688. * @returns the emitter
  12689. */
  12690. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  12691. /**
  12692. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  12693. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  12694. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  12695. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12696. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  12697. * @returns the emitter
  12698. */
  12699. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  12700. }
  12701. }
  12702. declare module "babylonjs/Particles/subEmitter" {
  12703. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12704. import { Scene } from "babylonjs/scene";
  12705. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  12706. /**
  12707. * Type of sub emitter
  12708. */
  12709. export enum SubEmitterType {
  12710. /**
  12711. * Attached to the particle over it's lifetime
  12712. */
  12713. ATTACHED = 0,
  12714. /**
  12715. * Created when the particle dies
  12716. */
  12717. END = 1
  12718. }
  12719. /**
  12720. * Sub emitter class used to emit particles from an existing particle
  12721. */
  12722. export class SubEmitter {
  12723. /**
  12724. * the particle system to be used by the sub emitter
  12725. */
  12726. particleSystem: ParticleSystem;
  12727. /**
  12728. * Type of the submitter (Default: END)
  12729. */
  12730. type: SubEmitterType;
  12731. /**
  12732. * 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)
  12733. * Note: This only is supported when using an emitter of type Mesh
  12734. */
  12735. inheritDirection: boolean;
  12736. /**
  12737. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  12738. */
  12739. inheritedVelocityAmount: number;
  12740. /**
  12741. * Creates a sub emitter
  12742. * @param particleSystem the particle system to be used by the sub emitter
  12743. */
  12744. constructor(
  12745. /**
  12746. * the particle system to be used by the sub emitter
  12747. */
  12748. particleSystem: ParticleSystem);
  12749. /**
  12750. * Clones the sub emitter
  12751. * @returns the cloned sub emitter
  12752. */
  12753. clone(): SubEmitter;
  12754. /**
  12755. * Serialize current object to a JSON object
  12756. * @returns the serialized object
  12757. */
  12758. serialize(): any;
  12759. /** @hidden */
  12760. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  12761. /**
  12762. * Creates a new SubEmitter from a serialized JSON version
  12763. * @param serializationObject defines the JSON object to read from
  12764. * @param sceneOrEngine defines the hosting scene or the hosting engine
  12765. * @param rootUrl defines the rootUrl for data loading
  12766. * @returns a new SubEmitter
  12767. */
  12768. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  12769. /** Release associated resources */
  12770. dispose(): void;
  12771. }
  12772. }
  12773. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration" {
  12774. /** @hidden */
  12775. export var imageProcessingDeclaration: {
  12776. name: string;
  12777. shader: string;
  12778. };
  12779. }
  12780. declare module "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions" {
  12781. /** @hidden */
  12782. export var imageProcessingFunctions: {
  12783. name: string;
  12784. shader: string;
  12785. };
  12786. }
  12787. declare module "babylonjs/Shaders/particles.fragment" {
  12788. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  12789. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  12790. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  12791. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  12792. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  12793. /** @hidden */
  12794. export var particlesPixelShader: {
  12795. name: string;
  12796. shader: string;
  12797. };
  12798. }
  12799. declare module "babylonjs/Shaders/particles.vertex" {
  12800. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  12801. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  12802. /** @hidden */
  12803. export var particlesVertexShader: {
  12804. name: string;
  12805. shader: string;
  12806. };
  12807. }
  12808. declare module "babylonjs/Misc/interfaces/iClipPlanesHolder" {
  12809. import { Nullable } from "babylonjs/types";
  12810. import { Plane } from "babylonjs/Maths/math";
  12811. /**
  12812. * Interface used to define entities containing multiple clip planes
  12813. */
  12814. export interface IClipPlanesHolder {
  12815. /**
  12816. * Gets or sets the active clipplane 1
  12817. */
  12818. clipPlane: Nullable<Plane>;
  12819. /**
  12820. * Gets or sets the active clipplane 2
  12821. */
  12822. clipPlane2: Nullable<Plane>;
  12823. /**
  12824. * Gets or sets the active clipplane 3
  12825. */
  12826. clipPlane3: Nullable<Plane>;
  12827. /**
  12828. * Gets or sets the active clipplane 4
  12829. */
  12830. clipPlane4: Nullable<Plane>;
  12831. /**
  12832. * Gets or sets the active clipplane 5
  12833. */
  12834. clipPlane5: Nullable<Plane>;
  12835. /**
  12836. * Gets or sets the active clipplane 6
  12837. */
  12838. clipPlane6: Nullable<Plane>;
  12839. }
  12840. }
  12841. declare module "babylonjs/Materials/thinMaterialHelper" {
  12842. import { Effect } from "babylonjs/Materials/effect";
  12843. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  12844. /**
  12845. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  12846. *
  12847. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  12848. *
  12849. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  12850. */
  12851. export class ThinMaterialHelper {
  12852. /**
  12853. * Binds the clip plane information from the holder to the effect.
  12854. * @param effect The effect we are binding the data to
  12855. * @param holder The entity containing the clip plane information
  12856. */
  12857. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  12858. }
  12859. }
  12860. declare module "babylonjs/Engines/Extensions/engine.alpha" {
  12861. module "babylonjs/Engines/thinEngine" {
  12862. interface ThinEngine {
  12863. /**
  12864. * Sets alpha constants used by some alpha blending modes
  12865. * @param r defines the red component
  12866. * @param g defines the green component
  12867. * @param b defines the blue component
  12868. * @param a defines the alpha component
  12869. */
  12870. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  12871. /**
  12872. * Sets the current alpha mode
  12873. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  12874. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  12875. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12876. */
  12877. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  12878. /**
  12879. * Gets the current alpha mode
  12880. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  12881. * @returns the current alpha mode
  12882. */
  12883. getAlphaMode(): number;
  12884. /**
  12885. * Sets the current alpha equation
  12886. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  12887. */
  12888. setAlphaEquation(equation: number): void;
  12889. /**
  12890. * Gets the current alpha equation.
  12891. * @returns the current alpha equation
  12892. */
  12893. getAlphaEquation(): number;
  12894. }
  12895. }
  12896. }
  12897. declare module "babylonjs/Particles/particleSystem" {
  12898. import { Nullable } from "babylonjs/types";
  12899. import { FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  12900. import { Observable } from "babylonjs/Misc/observable";
  12901. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  12902. import { Effect } from "babylonjs/Materials/effect";
  12903. import { IDisposable } from "babylonjs/scene";
  12904. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  12905. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  12906. import { Particle } from "babylonjs/Particles/particle";
  12907. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  12908. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  12909. import "babylonjs/Shaders/particles.fragment";
  12910. import "babylonjs/Shaders/particles.vertex";
  12911. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  12912. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  12913. import "babylonjs/Engines/Extensions/engine.alpha";
  12914. import { Scene } from "babylonjs/scene";
  12915. /**
  12916. * This represents a particle system in Babylon.
  12917. * 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.
  12918. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  12919. * @example https://doc.babylonjs.com/babylon101/particles
  12920. */
  12921. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  12922. /**
  12923. * Billboard mode will only apply to Y axis
  12924. */
  12925. static readonly BILLBOARDMODE_Y: number;
  12926. /**
  12927. * Billboard mode will apply to all axes
  12928. */
  12929. static readonly BILLBOARDMODE_ALL: number;
  12930. /**
  12931. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  12932. */
  12933. static readonly BILLBOARDMODE_STRETCHED: number;
  12934. /**
  12935. * This function can be defined to provide custom update for active particles.
  12936. * This function will be called instead of regular update (age, position, color, etc.).
  12937. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  12938. */
  12939. updateFunction: (particles: Particle[]) => void;
  12940. private _emitterWorldMatrix;
  12941. /**
  12942. * This function can be defined to specify initial direction for every new particle.
  12943. * It by default use the emitterType defined function
  12944. */
  12945. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12946. /**
  12947. * This function can be defined to specify initial position for every new particle.
  12948. * It by default use the emitterType defined function
  12949. */
  12950. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  12951. /**
  12952. * @hidden
  12953. */
  12954. _inheritedVelocityOffset: Vector3;
  12955. /**
  12956. * An event triggered when the system is disposed
  12957. */
  12958. onDisposeObservable: Observable<IParticleSystem>;
  12959. private _onDisposeObserver;
  12960. /**
  12961. * Sets a callback that will be triggered when the system is disposed
  12962. */
  12963. set onDispose(callback: () => void);
  12964. private _particles;
  12965. private _epsilon;
  12966. private _capacity;
  12967. private _stockParticles;
  12968. private _newPartsExcess;
  12969. private _vertexData;
  12970. private _vertexBuffer;
  12971. private _vertexBuffers;
  12972. private _spriteBuffer;
  12973. private _indexBuffer;
  12974. private _effect;
  12975. private _customEffect;
  12976. private _cachedDefines;
  12977. private _scaledColorStep;
  12978. private _colorDiff;
  12979. private _scaledDirection;
  12980. private _scaledGravity;
  12981. private _currentRenderId;
  12982. private _alive;
  12983. private _useInstancing;
  12984. private _started;
  12985. private _stopped;
  12986. private _actualFrame;
  12987. private _scaledUpdateSpeed;
  12988. private _vertexBufferSize;
  12989. /** @hidden */
  12990. _currentEmitRateGradient: Nullable<FactorGradient>;
  12991. /** @hidden */
  12992. _currentEmitRate1: number;
  12993. /** @hidden */
  12994. _currentEmitRate2: number;
  12995. /** @hidden */
  12996. _currentStartSizeGradient: Nullable<FactorGradient>;
  12997. /** @hidden */
  12998. _currentStartSize1: number;
  12999. /** @hidden */
  13000. _currentStartSize2: number;
  13001. private readonly _rawTextureWidth;
  13002. private _rampGradientsTexture;
  13003. private _useRampGradients;
  13004. /** Gets or sets a matrix to use to compute projection */
  13005. defaultProjectionMatrix: Matrix;
  13006. /** Gets or sets a matrix to use to compute view */
  13007. defaultViewMatrix: Matrix;
  13008. /** Gets or sets a boolean indicating that ramp gradients must be used
  13009. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  13010. */
  13011. get useRampGradients(): boolean;
  13012. set useRampGradients(value: boolean);
  13013. /**
  13014. * 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.
  13015. * 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: [])
  13016. */
  13017. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  13018. private _subEmitters;
  13019. /**
  13020. * @hidden
  13021. * If the particle systems emitter should be disposed when the particle system is disposed
  13022. */
  13023. _disposeEmitterOnDispose: boolean;
  13024. /**
  13025. * The current active Sub-systems, this property is used by the root particle system only.
  13026. */
  13027. activeSubSystems: Array<ParticleSystem>;
  13028. /**
  13029. * Specifies if the particles are updated in emitter local space or world space
  13030. */
  13031. isLocal: boolean;
  13032. private _rootParticleSystem;
  13033. /**
  13034. * Gets the current list of active particles
  13035. */
  13036. get particles(): Particle[];
  13037. /**
  13038. * Gets the number of particles active at the same time.
  13039. * @returns The number of active particles.
  13040. */
  13041. getActiveCount(): number;
  13042. /**
  13043. * Returns the string "ParticleSystem"
  13044. * @returns a string containing the class name
  13045. */
  13046. getClassName(): string;
  13047. /**
  13048. * Gets a boolean indicating that the system is stopping
  13049. * @returns true if the system is currently stopping
  13050. */
  13051. isStopping(): boolean;
  13052. /**
  13053. * Gets the custom effect used to render the particles
  13054. * @param blendMode Blend mode for which the effect should be retrieved
  13055. * @returns The effect
  13056. */
  13057. getCustomEffect(blendMode?: number): Nullable<Effect>;
  13058. /**
  13059. * Sets the custom effect used to render the particles
  13060. * @param effect The effect to set
  13061. * @param blendMode Blend mode for which the effect should be set
  13062. */
  13063. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  13064. /** @hidden */
  13065. private _onBeforeDrawParticlesObservable;
  13066. /**
  13067. * Observable that will be called just before the particles are drawn
  13068. */
  13069. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  13070. /**
  13071. * Gets the name of the particle vertex shader
  13072. */
  13073. get vertexShaderName(): string;
  13074. /**
  13075. * Instantiates a particle system.
  13076. * 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.
  13077. * @param name The name of the particle system
  13078. * @param capacity The max number of particles alive at the same time
  13079. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  13080. * @param customEffect a custom effect used to change the way particles are rendered by default
  13081. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  13082. * @param epsilon Offset used to render the particles
  13083. */
  13084. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  13085. private _addFactorGradient;
  13086. private _removeFactorGradient;
  13087. /**
  13088. * Adds a new life time gradient
  13089. * @param gradient defines the gradient to use (between 0 and 1)
  13090. * @param factor defines the life time factor to affect to the specified gradient
  13091. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13092. * @returns the current particle system
  13093. */
  13094. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13095. /**
  13096. * Remove a specific life time gradient
  13097. * @param gradient defines the gradient to remove
  13098. * @returns the current particle system
  13099. */
  13100. removeLifeTimeGradient(gradient: number): IParticleSystem;
  13101. /**
  13102. * Adds a new size gradient
  13103. * @param gradient defines the gradient to use (between 0 and 1)
  13104. * @param factor defines the size factor to affect to the specified gradient
  13105. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13106. * @returns the current particle system
  13107. */
  13108. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13109. /**
  13110. * Remove a specific size gradient
  13111. * @param gradient defines the gradient to remove
  13112. * @returns the current particle system
  13113. */
  13114. removeSizeGradient(gradient: number): IParticleSystem;
  13115. /**
  13116. * Adds a new color remap gradient
  13117. * @param gradient defines the gradient to use (between 0 and 1)
  13118. * @param min defines the color remap minimal range
  13119. * @param max defines the color remap maximal range
  13120. * @returns the current particle system
  13121. */
  13122. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13123. /**
  13124. * Remove a specific color remap gradient
  13125. * @param gradient defines the gradient to remove
  13126. * @returns the current particle system
  13127. */
  13128. removeColorRemapGradient(gradient: number): IParticleSystem;
  13129. /**
  13130. * Adds a new alpha remap gradient
  13131. * @param gradient defines the gradient to use (between 0 and 1)
  13132. * @param min defines the alpha remap minimal range
  13133. * @param max defines the alpha remap maximal range
  13134. * @returns the current particle system
  13135. */
  13136. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  13137. /**
  13138. * Remove a specific alpha remap gradient
  13139. * @param gradient defines the gradient to remove
  13140. * @returns the current particle system
  13141. */
  13142. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  13143. /**
  13144. * Adds a new angular speed gradient
  13145. * @param gradient defines the gradient to use (between 0 and 1)
  13146. * @param factor defines the angular speed to affect to the specified gradient
  13147. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13148. * @returns the current particle system
  13149. */
  13150. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13151. /**
  13152. * Remove a specific angular speed gradient
  13153. * @param gradient defines the gradient to remove
  13154. * @returns the current particle system
  13155. */
  13156. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  13157. /**
  13158. * Adds a new velocity gradient
  13159. * @param gradient defines the gradient to use (between 0 and 1)
  13160. * @param factor defines the velocity to affect to the specified gradient
  13161. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13162. * @returns the current particle system
  13163. */
  13164. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13165. /**
  13166. * Remove a specific velocity gradient
  13167. * @param gradient defines the gradient to remove
  13168. * @returns the current particle system
  13169. */
  13170. removeVelocityGradient(gradient: number): IParticleSystem;
  13171. /**
  13172. * Adds a new limit velocity gradient
  13173. * @param gradient defines the gradient to use (between 0 and 1)
  13174. * @param factor defines the limit velocity value to affect to the specified gradient
  13175. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13176. * @returns the current particle system
  13177. */
  13178. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13179. /**
  13180. * Remove a specific limit velocity gradient
  13181. * @param gradient defines the gradient to remove
  13182. * @returns the current particle system
  13183. */
  13184. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  13185. /**
  13186. * Adds a new drag gradient
  13187. * @param gradient defines the gradient to use (between 0 and 1)
  13188. * @param factor defines the drag value to affect to the specified gradient
  13189. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13190. * @returns the current particle system
  13191. */
  13192. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13193. /**
  13194. * Remove a specific drag gradient
  13195. * @param gradient defines the gradient to remove
  13196. * @returns the current particle system
  13197. */
  13198. removeDragGradient(gradient: number): IParticleSystem;
  13199. /**
  13200. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  13201. * @param gradient defines the gradient to use (between 0 and 1)
  13202. * @param factor defines the emit rate value to affect to the specified gradient
  13203. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13204. * @returns the current particle system
  13205. */
  13206. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13207. /**
  13208. * Remove a specific emit rate gradient
  13209. * @param gradient defines the gradient to remove
  13210. * @returns the current particle system
  13211. */
  13212. removeEmitRateGradient(gradient: number): IParticleSystem;
  13213. /**
  13214. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  13215. * @param gradient defines the gradient to use (between 0 and 1)
  13216. * @param factor defines the start size value to affect to the specified gradient
  13217. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  13218. * @returns the current particle system
  13219. */
  13220. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  13221. /**
  13222. * Remove a specific start size gradient
  13223. * @param gradient defines the gradient to remove
  13224. * @returns the current particle system
  13225. */
  13226. removeStartSizeGradient(gradient: number): IParticleSystem;
  13227. private _createRampGradientTexture;
  13228. /**
  13229. * Gets the current list of ramp gradients.
  13230. * You must use addRampGradient and removeRampGradient to udpate this list
  13231. * @returns the list of ramp gradients
  13232. */
  13233. getRampGradients(): Nullable<Array<Color3Gradient>>;
  13234. /** Force the system to rebuild all gradients that need to be resync */
  13235. forceRefreshGradients(): void;
  13236. private _syncRampGradientTexture;
  13237. /**
  13238. * Adds a new ramp gradient used to remap particle colors
  13239. * @param gradient defines the gradient to use (between 0 and 1)
  13240. * @param color defines the color to affect to the specified gradient
  13241. * @returns the current particle system
  13242. */
  13243. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  13244. /**
  13245. * Remove a specific ramp gradient
  13246. * @param gradient defines the gradient to remove
  13247. * @returns the current particle system
  13248. */
  13249. removeRampGradient(gradient: number): ParticleSystem;
  13250. /**
  13251. * Adds a new color gradient
  13252. * @param gradient defines the gradient to use (between 0 and 1)
  13253. * @param color1 defines the color to affect to the specified gradient
  13254. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  13255. * @returns this particle system
  13256. */
  13257. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  13258. /**
  13259. * Remove a specific color gradient
  13260. * @param gradient defines the gradient to remove
  13261. * @returns this particle system
  13262. */
  13263. removeColorGradient(gradient: number): IParticleSystem;
  13264. private _fetchR;
  13265. protected _reset(): void;
  13266. private _resetEffect;
  13267. private _createVertexBuffers;
  13268. private _createIndexBuffer;
  13269. /**
  13270. * Gets the maximum number of particles active at the same time.
  13271. * @returns The max number of active particles.
  13272. */
  13273. getCapacity(): number;
  13274. /**
  13275. * Gets whether there are still active particles in the system.
  13276. * @returns True if it is alive, otherwise false.
  13277. */
  13278. isAlive(): boolean;
  13279. /**
  13280. * Gets if the system has been started. (Note: this will still be true after stop is called)
  13281. * @returns True if it has been started, otherwise false.
  13282. */
  13283. isStarted(): boolean;
  13284. private _prepareSubEmitterInternalArray;
  13285. /**
  13286. * Starts the particle system and begins to emit
  13287. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  13288. */
  13289. start(delay?: number): void;
  13290. /**
  13291. * Stops the particle system.
  13292. * @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.
  13293. */
  13294. stop(stopSubEmitters?: boolean): void;
  13295. /**
  13296. * Remove all active particles
  13297. */
  13298. reset(): void;
  13299. /**
  13300. * @hidden (for internal use only)
  13301. */
  13302. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  13303. /**
  13304. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  13305. * Its lifetime will start back at 0.
  13306. */
  13307. recycleParticle: (particle: Particle) => void;
  13308. private _stopSubEmitters;
  13309. private _createParticle;
  13310. private _removeFromRoot;
  13311. private _emitFromParticle;
  13312. private _update;
  13313. /** @hidden */
  13314. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  13315. /** @hidden */
  13316. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  13317. /**
  13318. * Fill the defines array according to the current settings of the particle system
  13319. * @param defines Array to be updated
  13320. * @param blendMode blend mode to take into account when updating the array
  13321. */
  13322. fillDefines(defines: Array<string>, blendMode: number): void;
  13323. /**
  13324. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  13325. * @param uniforms Uniforms array to fill
  13326. * @param attributes Attributes array to fill
  13327. * @param samplers Samplers array to fill
  13328. */
  13329. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  13330. /** @hidden */
  13331. private _getEffect;
  13332. /**
  13333. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  13334. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  13335. */
  13336. animate(preWarmOnly?: boolean): void;
  13337. private _appendParticleVertices;
  13338. /**
  13339. * Rebuilds the particle system.
  13340. */
  13341. rebuild(): void;
  13342. /**
  13343. * Is this system ready to be used/rendered
  13344. * @return true if the system is ready
  13345. */
  13346. isReady(): boolean;
  13347. private _render;
  13348. /**
  13349. * Renders the particle system in its current state.
  13350. * @returns the current number of particles
  13351. */
  13352. render(): number;
  13353. /**
  13354. * Disposes the particle system and free the associated resources
  13355. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  13356. */
  13357. dispose(disposeTexture?: boolean): void;
  13358. /**
  13359. * Clones the particle system.
  13360. * @param name The name of the cloned object
  13361. * @param newEmitter The new emitter to use
  13362. * @returns the cloned particle system
  13363. */
  13364. clone(name: string, newEmitter: any): ParticleSystem;
  13365. /**
  13366. * Serializes the particle system to a JSON object
  13367. * @param serializeTexture defines if the texture must be serialized as well
  13368. * @returns the JSON object
  13369. */
  13370. serialize(serializeTexture?: boolean): any;
  13371. /** @hidden */
  13372. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  13373. /** @hidden */
  13374. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  13375. /**
  13376. * Parses a JSON object to create a particle system.
  13377. * @param parsedParticleSystem The JSON object to parse
  13378. * @param sceneOrEngine The scene or the engine to create the particle system in
  13379. * @param rootUrl The root url to use to load external dependencies like texture
  13380. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  13381. * @returns the Parsed particle system
  13382. */
  13383. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  13384. }
  13385. }
  13386. declare module "babylonjs/Particles/particle" {
  13387. import { Nullable } from "babylonjs/types";
  13388. import { Vector2, Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  13389. import { Color4 } from "babylonjs/Maths/math.color";
  13390. import { ParticleSystem } from "babylonjs/Particles/particleSystem";
  13391. import { SubEmitter } from "babylonjs/Particles/subEmitter";
  13392. import { ColorGradient, FactorGradient } from "babylonjs/Misc/gradients";
  13393. /**
  13394. * A particle represents one of the element emitted by a particle system.
  13395. * This is mainly define by its coordinates, direction, velocity and age.
  13396. */
  13397. export class Particle {
  13398. /**
  13399. * The particle system the particle belongs to.
  13400. */
  13401. particleSystem: ParticleSystem;
  13402. private static _Count;
  13403. /**
  13404. * Unique ID of the particle
  13405. */
  13406. id: number;
  13407. /**
  13408. * The world position of the particle in the scene.
  13409. */
  13410. position: Vector3;
  13411. /**
  13412. * The world direction of the particle in the scene.
  13413. */
  13414. direction: Vector3;
  13415. /**
  13416. * The color of the particle.
  13417. */
  13418. color: Color4;
  13419. /**
  13420. * The color change of the particle per step.
  13421. */
  13422. colorStep: Color4;
  13423. /**
  13424. * Defines how long will the life of the particle be.
  13425. */
  13426. lifeTime: number;
  13427. /**
  13428. * The current age of the particle.
  13429. */
  13430. age: number;
  13431. /**
  13432. * The current size of the particle.
  13433. */
  13434. size: number;
  13435. /**
  13436. * The current scale of the particle.
  13437. */
  13438. scale: Vector2;
  13439. /**
  13440. * The current angle of the particle.
  13441. */
  13442. angle: number;
  13443. /**
  13444. * Defines how fast is the angle changing.
  13445. */
  13446. angularSpeed: number;
  13447. /**
  13448. * Defines the cell index used by the particle to be rendered from a sprite.
  13449. */
  13450. cellIndex: number;
  13451. /**
  13452. * The information required to support color remapping
  13453. */
  13454. remapData: Vector4;
  13455. /** @hidden */
  13456. _randomCellOffset?: number;
  13457. /** @hidden */
  13458. _initialDirection: Nullable<Vector3>;
  13459. /** @hidden */
  13460. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  13461. /** @hidden */
  13462. _initialStartSpriteCellID: number;
  13463. /** @hidden */
  13464. _initialEndSpriteCellID: number;
  13465. /** @hidden */
  13466. _currentColorGradient: Nullable<ColorGradient>;
  13467. /** @hidden */
  13468. _currentColor1: Color4;
  13469. /** @hidden */
  13470. _currentColor2: Color4;
  13471. /** @hidden */
  13472. _currentSizeGradient: Nullable<FactorGradient>;
  13473. /** @hidden */
  13474. _currentSize1: number;
  13475. /** @hidden */
  13476. _currentSize2: number;
  13477. /** @hidden */
  13478. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  13479. /** @hidden */
  13480. _currentAngularSpeed1: number;
  13481. /** @hidden */
  13482. _currentAngularSpeed2: number;
  13483. /** @hidden */
  13484. _currentVelocityGradient: Nullable<FactorGradient>;
  13485. /** @hidden */
  13486. _currentVelocity1: number;
  13487. /** @hidden */
  13488. _currentVelocity2: number;
  13489. /** @hidden */
  13490. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  13491. /** @hidden */
  13492. _currentLimitVelocity1: number;
  13493. /** @hidden */
  13494. _currentLimitVelocity2: number;
  13495. /** @hidden */
  13496. _currentDragGradient: Nullable<FactorGradient>;
  13497. /** @hidden */
  13498. _currentDrag1: number;
  13499. /** @hidden */
  13500. _currentDrag2: number;
  13501. /** @hidden */
  13502. _randomNoiseCoordinates1: Vector3;
  13503. /** @hidden */
  13504. _randomNoiseCoordinates2: Vector3;
  13505. /** @hidden */
  13506. _localPosition?: Vector3;
  13507. /**
  13508. * Creates a new instance Particle
  13509. * @param particleSystem the particle system the particle belongs to
  13510. */
  13511. constructor(
  13512. /**
  13513. * The particle system the particle belongs to.
  13514. */
  13515. particleSystem: ParticleSystem);
  13516. private updateCellInfoFromSystem;
  13517. /**
  13518. * Defines how the sprite cell index is updated for the particle
  13519. */
  13520. updateCellIndex(): void;
  13521. /** @hidden */
  13522. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  13523. /** @hidden */
  13524. _inheritParticleInfoToSubEmitters(): void;
  13525. /** @hidden */
  13526. _reset(): void;
  13527. /**
  13528. * Copy the properties of particle to another one.
  13529. * @param other the particle to copy the information to.
  13530. */
  13531. copyTo(other: Particle): void;
  13532. }
  13533. }
  13534. declare module "babylonjs/Particles/EmitterTypes/IParticleEmitterType" {
  13535. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13536. import { Effect } from "babylonjs/Materials/effect";
  13537. import { Particle } from "babylonjs/Particles/particle";
  13538. import { Nullable } from "babylonjs/types";
  13539. import { Scene } from "babylonjs/scene";
  13540. /**
  13541. * Particle emitter represents a volume emitting particles.
  13542. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  13543. */
  13544. export interface IParticleEmitterType {
  13545. /**
  13546. * Called by the particle System when the direction is computed for the created particle.
  13547. * @param worldMatrix is the world matrix of the particle system
  13548. * @param directionToUpdate is the direction vector to update with the result
  13549. * @param particle is the particle we are computed the direction for
  13550. * @param isLocal defines if the direction should be set in local space
  13551. */
  13552. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13553. /**
  13554. * Called by the particle System when the position is computed for the created particle.
  13555. * @param worldMatrix is the world matrix of the particle system
  13556. * @param positionToUpdate is the position vector to update with the result
  13557. * @param particle is the particle we are computed the position for
  13558. * @param isLocal defines if the position should be set in local space
  13559. */
  13560. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13561. /**
  13562. * Clones the current emitter and returns a copy of it
  13563. * @returns the new emitter
  13564. */
  13565. clone(): IParticleEmitterType;
  13566. /**
  13567. * Called by the GPUParticleSystem to setup the update shader
  13568. * @param effect defines the update shader
  13569. */
  13570. applyToShader(effect: Effect): void;
  13571. /**
  13572. * Returns a string to use to update the GPU particles update shader
  13573. * @returns the effect defines string
  13574. */
  13575. getEffectDefines(): string;
  13576. /**
  13577. * Returns a string representing the class name
  13578. * @returns a string containing the class name
  13579. */
  13580. getClassName(): string;
  13581. /**
  13582. * Serializes the particle system to a JSON object.
  13583. * @returns the JSON object
  13584. */
  13585. serialize(): any;
  13586. /**
  13587. * Parse properties from a JSON object
  13588. * @param serializationObject defines the JSON object
  13589. * @param scene defines the hosting scene
  13590. */
  13591. parse(serializationObject: any, scene: Nullable<Scene>): void;
  13592. }
  13593. }
  13594. declare module "babylonjs/Particles/EmitterTypes/boxParticleEmitter" {
  13595. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13596. import { Effect } from "babylonjs/Materials/effect";
  13597. import { Particle } from "babylonjs/Particles/particle";
  13598. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13599. /**
  13600. * Particle emitter emitting particles from the inside of a box.
  13601. * It emits the particles randomly between 2 given directions.
  13602. */
  13603. export class BoxParticleEmitter implements IParticleEmitterType {
  13604. /**
  13605. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13606. */
  13607. direction1: Vector3;
  13608. /**
  13609. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  13610. */
  13611. direction2: Vector3;
  13612. /**
  13613. * 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.
  13614. */
  13615. minEmitBox: Vector3;
  13616. /**
  13617. * 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.
  13618. */
  13619. maxEmitBox: Vector3;
  13620. /**
  13621. * Creates a new instance BoxParticleEmitter
  13622. */
  13623. constructor();
  13624. /**
  13625. * Called by the particle System when the direction is computed for the created particle.
  13626. * @param worldMatrix is the world matrix of the particle system
  13627. * @param directionToUpdate is the direction vector to update with the result
  13628. * @param particle is the particle we are computed the direction for
  13629. * @param isLocal defines if the direction should be set in local space
  13630. */
  13631. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13632. /**
  13633. * Called by the particle System when the position is computed for the created particle.
  13634. * @param worldMatrix is the world matrix of the particle system
  13635. * @param positionToUpdate is the position vector to update with the result
  13636. * @param particle is the particle we are computed the position for
  13637. * @param isLocal defines if the position should be set in local space
  13638. */
  13639. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13640. /**
  13641. * Clones the current emitter and returns a copy of it
  13642. * @returns the new emitter
  13643. */
  13644. clone(): BoxParticleEmitter;
  13645. /**
  13646. * Called by the GPUParticleSystem to setup the update shader
  13647. * @param effect defines the update shader
  13648. */
  13649. applyToShader(effect: Effect): void;
  13650. /**
  13651. * Returns a string to use to update the GPU particles update shader
  13652. * @returns a string containng the defines string
  13653. */
  13654. getEffectDefines(): string;
  13655. /**
  13656. * Returns the string "BoxParticleEmitter"
  13657. * @returns a string containing the class name
  13658. */
  13659. getClassName(): string;
  13660. /**
  13661. * Serializes the particle system to a JSON object.
  13662. * @returns the JSON object
  13663. */
  13664. serialize(): any;
  13665. /**
  13666. * Parse properties from a JSON object
  13667. * @param serializationObject defines the JSON object
  13668. */
  13669. parse(serializationObject: any): void;
  13670. }
  13671. }
  13672. declare module "babylonjs/Particles/EmitterTypes/coneParticleEmitter" {
  13673. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13674. import { Effect } from "babylonjs/Materials/effect";
  13675. import { Particle } from "babylonjs/Particles/particle";
  13676. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13677. /**
  13678. * Particle emitter emitting particles from the inside of a cone.
  13679. * It emits the particles alongside the cone volume from the base to the particle.
  13680. * The emission direction might be randomized.
  13681. */
  13682. export class ConeParticleEmitter implements IParticleEmitterType {
  13683. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13684. directionRandomizer: number;
  13685. private _radius;
  13686. private _angle;
  13687. private _height;
  13688. /**
  13689. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  13690. */
  13691. radiusRange: number;
  13692. /**
  13693. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  13694. */
  13695. heightRange: number;
  13696. /**
  13697. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  13698. */
  13699. emitFromSpawnPointOnly: boolean;
  13700. /**
  13701. * Gets or sets the radius of the emission cone
  13702. */
  13703. get radius(): number;
  13704. set radius(value: number);
  13705. /**
  13706. * Gets or sets the angle of the emission cone
  13707. */
  13708. get angle(): number;
  13709. set angle(value: number);
  13710. private _buildHeight;
  13711. /**
  13712. * Creates a new instance ConeParticleEmitter
  13713. * @param radius the radius of the emission cone (1 by default)
  13714. * @param angle the cone base angle (PI by default)
  13715. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  13716. */
  13717. constructor(radius?: number, angle?: number,
  13718. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  13719. directionRandomizer?: number);
  13720. /**
  13721. * Called by the particle System when the direction is computed for the created particle.
  13722. * @param worldMatrix is the world matrix of the particle system
  13723. * @param directionToUpdate is the direction vector to update with the result
  13724. * @param particle is the particle we are computed the direction for
  13725. * @param isLocal defines if the direction should be set in local space
  13726. */
  13727. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13728. /**
  13729. * Called by the particle System when the position is computed for the created particle.
  13730. * @param worldMatrix is the world matrix of the particle system
  13731. * @param positionToUpdate is the position vector to update with the result
  13732. * @param particle is the particle we are computed the position for
  13733. * @param isLocal defines if the position should be set in local space
  13734. */
  13735. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13736. /**
  13737. * Clones the current emitter and returns a copy of it
  13738. * @returns the new emitter
  13739. */
  13740. clone(): ConeParticleEmitter;
  13741. /**
  13742. * Called by the GPUParticleSystem to setup the update shader
  13743. * @param effect defines the update shader
  13744. */
  13745. applyToShader(effect: Effect): void;
  13746. /**
  13747. * Returns a string to use to update the GPU particles update shader
  13748. * @returns a string containng the defines string
  13749. */
  13750. getEffectDefines(): string;
  13751. /**
  13752. * Returns the string "ConeParticleEmitter"
  13753. * @returns a string containing the class name
  13754. */
  13755. getClassName(): string;
  13756. /**
  13757. * Serializes the particle system to a JSON object.
  13758. * @returns the JSON object
  13759. */
  13760. serialize(): any;
  13761. /**
  13762. * Parse properties from a JSON object
  13763. * @param serializationObject defines the JSON object
  13764. */
  13765. parse(serializationObject: any): void;
  13766. }
  13767. }
  13768. declare module "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter" {
  13769. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13770. import { Effect } from "babylonjs/Materials/effect";
  13771. import { Particle } from "babylonjs/Particles/particle";
  13772. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13773. /**
  13774. * Particle emitter emitting particles from the inside of a cylinder.
  13775. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  13776. */
  13777. export class CylinderParticleEmitter implements IParticleEmitterType {
  13778. /**
  13779. * The radius of the emission cylinder.
  13780. */
  13781. radius: number;
  13782. /**
  13783. * The height of the emission cylinder.
  13784. */
  13785. height: number;
  13786. /**
  13787. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13788. */
  13789. radiusRange: number;
  13790. /**
  13791. * How much to randomize the particle direction [0-1].
  13792. */
  13793. directionRandomizer: number;
  13794. /**
  13795. * Creates a new instance CylinderParticleEmitter
  13796. * @param radius the radius of the emission cylinder (1 by default)
  13797. * @param height the height of the emission cylinder (1 by default)
  13798. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13799. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13800. */
  13801. constructor(
  13802. /**
  13803. * The radius of the emission cylinder.
  13804. */
  13805. radius?: number,
  13806. /**
  13807. * The height of the emission cylinder.
  13808. */
  13809. height?: number,
  13810. /**
  13811. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13812. */
  13813. radiusRange?: number,
  13814. /**
  13815. * How much to randomize the particle direction [0-1].
  13816. */
  13817. directionRandomizer?: number);
  13818. /**
  13819. * Called by the particle System when the direction is computed for the created particle.
  13820. * @param worldMatrix is the world matrix of the particle system
  13821. * @param directionToUpdate is the direction vector to update with the result
  13822. * @param particle is the particle we are computed the direction for
  13823. * @param isLocal defines if the direction should be set in local space
  13824. */
  13825. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13826. /**
  13827. * Called by the particle System when the position is computed for the created particle.
  13828. * @param worldMatrix is the world matrix of the particle system
  13829. * @param positionToUpdate is the position vector to update with the result
  13830. * @param particle is the particle we are computed the position for
  13831. * @param isLocal defines if the position should be set in local space
  13832. */
  13833. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13834. /**
  13835. * Clones the current emitter and returns a copy of it
  13836. * @returns the new emitter
  13837. */
  13838. clone(): CylinderParticleEmitter;
  13839. /**
  13840. * Called by the GPUParticleSystem to setup the update shader
  13841. * @param effect defines the update shader
  13842. */
  13843. applyToShader(effect: Effect): void;
  13844. /**
  13845. * Returns a string to use to update the GPU particles update shader
  13846. * @returns a string containng the defines string
  13847. */
  13848. getEffectDefines(): string;
  13849. /**
  13850. * Returns the string "CylinderParticleEmitter"
  13851. * @returns a string containing the class name
  13852. */
  13853. getClassName(): string;
  13854. /**
  13855. * Serializes the particle system to a JSON object.
  13856. * @returns the JSON object
  13857. */
  13858. serialize(): any;
  13859. /**
  13860. * Parse properties from a JSON object
  13861. * @param serializationObject defines the JSON object
  13862. */
  13863. parse(serializationObject: any): void;
  13864. }
  13865. /**
  13866. * Particle emitter emitting particles from the inside of a cylinder.
  13867. * It emits the particles randomly between two vectors.
  13868. */
  13869. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  13870. /**
  13871. * The min limit of the emission direction.
  13872. */
  13873. direction1: Vector3;
  13874. /**
  13875. * The max limit of the emission direction.
  13876. */
  13877. direction2: Vector3;
  13878. /**
  13879. * Creates a new instance CylinderDirectedParticleEmitter
  13880. * @param radius the radius of the emission cylinder (1 by default)
  13881. * @param height the height of the emission cylinder (1 by default)
  13882. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13883. * @param direction1 the min limit of the emission direction (up vector by default)
  13884. * @param direction2 the max limit of the emission direction (up vector by default)
  13885. */
  13886. constructor(radius?: number, height?: number, radiusRange?: number,
  13887. /**
  13888. * The min limit of the emission direction.
  13889. */
  13890. direction1?: Vector3,
  13891. /**
  13892. * The max limit of the emission direction.
  13893. */
  13894. direction2?: Vector3);
  13895. /**
  13896. * Called by the particle System when the direction is computed for the created particle.
  13897. * @param worldMatrix is the world matrix of the particle system
  13898. * @param directionToUpdate is the direction vector to update with the result
  13899. * @param particle is the particle we are computed the direction for
  13900. */
  13901. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  13902. /**
  13903. * Clones the current emitter and returns a copy of it
  13904. * @returns the new emitter
  13905. */
  13906. clone(): CylinderDirectedParticleEmitter;
  13907. /**
  13908. * Called by the GPUParticleSystem to setup the update shader
  13909. * @param effect defines the update shader
  13910. */
  13911. applyToShader(effect: Effect): void;
  13912. /**
  13913. * Returns a string to use to update the GPU particles update shader
  13914. * @returns a string containng the defines string
  13915. */
  13916. getEffectDefines(): string;
  13917. /**
  13918. * Returns the string "CylinderDirectedParticleEmitter"
  13919. * @returns a string containing the class name
  13920. */
  13921. getClassName(): string;
  13922. /**
  13923. * Serializes the particle system to a JSON object.
  13924. * @returns the JSON object
  13925. */
  13926. serialize(): any;
  13927. /**
  13928. * Parse properties from a JSON object
  13929. * @param serializationObject defines the JSON object
  13930. */
  13931. parse(serializationObject: any): void;
  13932. }
  13933. }
  13934. declare module "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter" {
  13935. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  13936. import { Effect } from "babylonjs/Materials/effect";
  13937. import { Particle } from "babylonjs/Particles/particle";
  13938. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  13939. /**
  13940. * Particle emitter emitting particles from the inside of a hemisphere.
  13941. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  13942. */
  13943. export class HemisphericParticleEmitter implements IParticleEmitterType {
  13944. /**
  13945. * The radius of the emission hemisphere.
  13946. */
  13947. radius: number;
  13948. /**
  13949. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13950. */
  13951. radiusRange: number;
  13952. /**
  13953. * How much to randomize the particle direction [0-1].
  13954. */
  13955. directionRandomizer: number;
  13956. /**
  13957. * Creates a new instance HemisphericParticleEmitter
  13958. * @param radius the radius of the emission hemisphere (1 by default)
  13959. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  13960. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  13961. */
  13962. constructor(
  13963. /**
  13964. * The radius of the emission hemisphere.
  13965. */
  13966. radius?: number,
  13967. /**
  13968. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  13969. */
  13970. radiusRange?: number,
  13971. /**
  13972. * How much to randomize the particle direction [0-1].
  13973. */
  13974. directionRandomizer?: number);
  13975. /**
  13976. * Called by the particle System when the direction is computed for the created particle.
  13977. * @param worldMatrix is the world matrix of the particle system
  13978. * @param directionToUpdate is the direction vector to update with the result
  13979. * @param particle is the particle we are computed the direction for
  13980. * @param isLocal defines if the direction should be set in local space
  13981. */
  13982. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13983. /**
  13984. * Called by the particle System when the position is computed for the created particle.
  13985. * @param worldMatrix is the world matrix of the particle system
  13986. * @param positionToUpdate is the position vector to update with the result
  13987. * @param particle is the particle we are computed the position for
  13988. * @param isLocal defines if the position should be set in local space
  13989. */
  13990. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  13991. /**
  13992. * Clones the current emitter and returns a copy of it
  13993. * @returns the new emitter
  13994. */
  13995. clone(): HemisphericParticleEmitter;
  13996. /**
  13997. * Called by the GPUParticleSystem to setup the update shader
  13998. * @param effect defines the update shader
  13999. */
  14000. applyToShader(effect: Effect): void;
  14001. /**
  14002. * Returns a string to use to update the GPU particles update shader
  14003. * @returns a string containng the defines string
  14004. */
  14005. getEffectDefines(): string;
  14006. /**
  14007. * Returns the string "HemisphericParticleEmitter"
  14008. * @returns a string containing the class name
  14009. */
  14010. getClassName(): string;
  14011. /**
  14012. * Serializes the particle system to a JSON object.
  14013. * @returns the JSON object
  14014. */
  14015. serialize(): any;
  14016. /**
  14017. * Parse properties from a JSON object
  14018. * @param serializationObject defines the JSON object
  14019. */
  14020. parse(serializationObject: any): void;
  14021. }
  14022. }
  14023. declare module "babylonjs/Particles/EmitterTypes/pointParticleEmitter" {
  14024. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14025. import { Effect } from "babylonjs/Materials/effect";
  14026. import { Particle } from "babylonjs/Particles/particle";
  14027. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14028. /**
  14029. * Particle emitter emitting particles from a point.
  14030. * It emits the particles randomly between 2 given directions.
  14031. */
  14032. export class PointParticleEmitter implements IParticleEmitterType {
  14033. /**
  14034. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14035. */
  14036. direction1: Vector3;
  14037. /**
  14038. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14039. */
  14040. direction2: Vector3;
  14041. /**
  14042. * Creates a new instance PointParticleEmitter
  14043. */
  14044. constructor();
  14045. /**
  14046. * Called by the particle System when the direction is computed for the created particle.
  14047. * @param worldMatrix is the world matrix of the particle system
  14048. * @param directionToUpdate is the direction vector to update with the result
  14049. * @param particle is the particle we are computed the direction for
  14050. * @param isLocal defines if the direction should be set in local space
  14051. */
  14052. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14053. /**
  14054. * Called by the particle System when the position is computed for the created particle.
  14055. * @param worldMatrix is the world matrix of the particle system
  14056. * @param positionToUpdate is the position vector to update with the result
  14057. * @param particle is the particle we are computed the position for
  14058. * @param isLocal defines if the position should be set in local space
  14059. */
  14060. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14061. /**
  14062. * Clones the current emitter and returns a copy of it
  14063. * @returns the new emitter
  14064. */
  14065. clone(): PointParticleEmitter;
  14066. /**
  14067. * Called by the GPUParticleSystem to setup the update shader
  14068. * @param effect defines the update shader
  14069. */
  14070. applyToShader(effect: Effect): void;
  14071. /**
  14072. * Returns a string to use to update the GPU particles update shader
  14073. * @returns a string containng the defines string
  14074. */
  14075. getEffectDefines(): string;
  14076. /**
  14077. * Returns the string "PointParticleEmitter"
  14078. * @returns a string containing the class name
  14079. */
  14080. getClassName(): string;
  14081. /**
  14082. * Serializes the particle system to a JSON object.
  14083. * @returns the JSON object
  14084. */
  14085. serialize(): any;
  14086. /**
  14087. * Parse properties from a JSON object
  14088. * @param serializationObject defines the JSON object
  14089. */
  14090. parse(serializationObject: any): void;
  14091. }
  14092. }
  14093. declare module "babylonjs/Particles/EmitterTypes/sphereParticleEmitter" {
  14094. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14095. import { Effect } from "babylonjs/Materials/effect";
  14096. import { Particle } from "babylonjs/Particles/particle";
  14097. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14098. /**
  14099. * Particle emitter emitting particles from the inside of a sphere.
  14100. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  14101. */
  14102. export class SphereParticleEmitter implements IParticleEmitterType {
  14103. /**
  14104. * The radius of the emission sphere.
  14105. */
  14106. radius: number;
  14107. /**
  14108. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14109. */
  14110. radiusRange: number;
  14111. /**
  14112. * How much to randomize the particle direction [0-1].
  14113. */
  14114. directionRandomizer: number;
  14115. /**
  14116. * Creates a new instance SphereParticleEmitter
  14117. * @param radius the radius of the emission sphere (1 by default)
  14118. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  14119. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  14120. */
  14121. constructor(
  14122. /**
  14123. * The radius of the emission sphere.
  14124. */
  14125. radius?: number,
  14126. /**
  14127. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  14128. */
  14129. radiusRange?: number,
  14130. /**
  14131. * How much to randomize the particle direction [0-1].
  14132. */
  14133. directionRandomizer?: number);
  14134. /**
  14135. * Called by the particle System when the direction is computed for the created particle.
  14136. * @param worldMatrix is the world matrix of the particle system
  14137. * @param directionToUpdate is the direction vector to update with the result
  14138. * @param particle is the particle we are computed the direction for
  14139. * @param isLocal defines if the direction should be set in local space
  14140. */
  14141. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14142. /**
  14143. * Called by the particle System when the position is computed for the created particle.
  14144. * @param worldMatrix is the world matrix of the particle system
  14145. * @param positionToUpdate is the position vector to update with the result
  14146. * @param particle is the particle we are computed the position for
  14147. * @param isLocal defines if the position should be set in local space
  14148. */
  14149. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14150. /**
  14151. * Clones the current emitter and returns a copy of it
  14152. * @returns the new emitter
  14153. */
  14154. clone(): SphereParticleEmitter;
  14155. /**
  14156. * Called by the GPUParticleSystem to setup the update shader
  14157. * @param effect defines the update shader
  14158. */
  14159. applyToShader(effect: Effect): void;
  14160. /**
  14161. * Returns a string to use to update the GPU particles update shader
  14162. * @returns a string containng the defines string
  14163. */
  14164. getEffectDefines(): string;
  14165. /**
  14166. * Returns the string "SphereParticleEmitter"
  14167. * @returns a string containing the class name
  14168. */
  14169. getClassName(): string;
  14170. /**
  14171. * Serializes the particle system to a JSON object.
  14172. * @returns the JSON object
  14173. */
  14174. serialize(): any;
  14175. /**
  14176. * Parse properties from a JSON object
  14177. * @param serializationObject defines the JSON object
  14178. */
  14179. parse(serializationObject: any): void;
  14180. }
  14181. /**
  14182. * Particle emitter emitting particles from the inside of a sphere.
  14183. * It emits the particles randomly between two vectors.
  14184. */
  14185. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  14186. /**
  14187. * The min limit of the emission direction.
  14188. */
  14189. direction1: Vector3;
  14190. /**
  14191. * The max limit of the emission direction.
  14192. */
  14193. direction2: Vector3;
  14194. /**
  14195. * Creates a new instance SphereDirectedParticleEmitter
  14196. * @param radius the radius of the emission sphere (1 by default)
  14197. * @param direction1 the min limit of the emission direction (up vector by default)
  14198. * @param direction2 the max limit of the emission direction (up vector by default)
  14199. */
  14200. constructor(radius?: number,
  14201. /**
  14202. * The min limit of the emission direction.
  14203. */
  14204. direction1?: Vector3,
  14205. /**
  14206. * The max limit of the emission direction.
  14207. */
  14208. direction2?: Vector3);
  14209. /**
  14210. * Called by the particle System when the direction is computed for the created particle.
  14211. * @param worldMatrix is the world matrix of the particle system
  14212. * @param directionToUpdate is the direction vector to update with the result
  14213. * @param particle is the particle we are computed the direction for
  14214. */
  14215. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  14216. /**
  14217. * Clones the current emitter and returns a copy of it
  14218. * @returns the new emitter
  14219. */
  14220. clone(): SphereDirectedParticleEmitter;
  14221. /**
  14222. * Called by the GPUParticleSystem to setup the update shader
  14223. * @param effect defines the update shader
  14224. */
  14225. applyToShader(effect: Effect): void;
  14226. /**
  14227. * Returns a string to use to update the GPU particles update shader
  14228. * @returns a string containng the defines string
  14229. */
  14230. getEffectDefines(): string;
  14231. /**
  14232. * Returns the string "SphereDirectedParticleEmitter"
  14233. * @returns a string containing the class name
  14234. */
  14235. getClassName(): string;
  14236. /**
  14237. * Serializes the particle system to a JSON object.
  14238. * @returns the JSON object
  14239. */
  14240. serialize(): any;
  14241. /**
  14242. * Parse properties from a JSON object
  14243. * @param serializationObject defines the JSON object
  14244. */
  14245. parse(serializationObject: any): void;
  14246. }
  14247. }
  14248. declare module "babylonjs/Particles/EmitterTypes/customParticleEmitter" {
  14249. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14250. import { Effect } from "babylonjs/Materials/effect";
  14251. import { Particle } from "babylonjs/Particles/particle";
  14252. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14253. import { Nullable } from "babylonjs/types";
  14254. /**
  14255. * Particle emitter emitting particles from a custom list of positions.
  14256. */
  14257. export class CustomParticleEmitter implements IParticleEmitterType {
  14258. /**
  14259. * Gets or sets the position generator that will create the inital position of each particle.
  14260. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14261. */
  14262. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  14263. /**
  14264. * Gets or sets the destination generator that will create the final destination of each particle.
  14265. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  14266. */
  14267. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  14268. /**
  14269. * Creates a new instance CustomParticleEmitter
  14270. */
  14271. constructor();
  14272. /**
  14273. * Called by the particle System when the direction is computed for the created particle.
  14274. * @param worldMatrix is the world matrix of the particle system
  14275. * @param directionToUpdate is the direction vector to update with the result
  14276. * @param particle is the particle we are computed the direction for
  14277. * @param isLocal defines if the direction should be set in local space
  14278. */
  14279. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14280. /**
  14281. * Called by the particle System when the position is computed for the created particle.
  14282. * @param worldMatrix is the world matrix of the particle system
  14283. * @param positionToUpdate is the position vector to update with the result
  14284. * @param particle is the particle we are computed the position for
  14285. * @param isLocal defines if the position should be set in local space
  14286. */
  14287. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14288. /**
  14289. * Clones the current emitter and returns a copy of it
  14290. * @returns the new emitter
  14291. */
  14292. clone(): CustomParticleEmitter;
  14293. /**
  14294. * Called by the GPUParticleSystem to setup the update shader
  14295. * @param effect defines the update shader
  14296. */
  14297. applyToShader(effect: Effect): void;
  14298. /**
  14299. * Returns a string to use to update the GPU particles update shader
  14300. * @returns a string containng the defines string
  14301. */
  14302. getEffectDefines(): string;
  14303. /**
  14304. * Returns the string "PointParticleEmitter"
  14305. * @returns a string containing the class name
  14306. */
  14307. getClassName(): string;
  14308. /**
  14309. * Serializes the particle system to a JSON object.
  14310. * @returns the JSON object
  14311. */
  14312. serialize(): any;
  14313. /**
  14314. * Parse properties from a JSON object
  14315. * @param serializationObject defines the JSON object
  14316. */
  14317. parse(serializationObject: any): void;
  14318. }
  14319. }
  14320. declare module "babylonjs/Particles/EmitterTypes/meshParticleEmitter" {
  14321. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14322. import { Effect } from "babylonjs/Materials/effect";
  14323. import { Particle } from "babylonjs/Particles/particle";
  14324. import { IParticleEmitterType } from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14325. import { Nullable } from "babylonjs/types";
  14326. import { Scene } from "babylonjs/scene";
  14327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14328. /**
  14329. * Particle emitter emitting particles from the inside of a box.
  14330. * It emits the particles randomly between 2 given directions.
  14331. */
  14332. export class MeshParticleEmitter implements IParticleEmitterType {
  14333. private _indices;
  14334. private _positions;
  14335. private _normals;
  14336. private _storedNormal;
  14337. private _mesh;
  14338. /**
  14339. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14340. */
  14341. direction1: Vector3;
  14342. /**
  14343. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  14344. */
  14345. direction2: Vector3;
  14346. /**
  14347. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  14348. */
  14349. useMeshNormalsForDirection: boolean;
  14350. /** Defines the mesh to use as source */
  14351. get mesh(): Nullable<AbstractMesh>;
  14352. set mesh(value: Nullable<AbstractMesh>);
  14353. /**
  14354. * Creates a new instance MeshParticleEmitter
  14355. * @param mesh defines the mesh to use as source
  14356. */
  14357. constructor(mesh?: Nullable<AbstractMesh>);
  14358. /**
  14359. * Called by the particle System when the direction is computed for the created particle.
  14360. * @param worldMatrix is the world matrix of the particle system
  14361. * @param directionToUpdate is the direction vector to update with the result
  14362. * @param particle is the particle we are computed the direction for
  14363. * @param isLocal defines if the direction should be set in local space
  14364. */
  14365. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14366. /**
  14367. * Called by the particle System when the position is computed for the created particle.
  14368. * @param worldMatrix is the world matrix of the particle system
  14369. * @param positionToUpdate is the position vector to update with the result
  14370. * @param particle is the particle we are computed the position for
  14371. * @param isLocal defines if the position should be set in local space
  14372. */
  14373. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  14374. /**
  14375. * Clones the current emitter and returns a copy of it
  14376. * @returns the new emitter
  14377. */
  14378. clone(): MeshParticleEmitter;
  14379. /**
  14380. * Called by the GPUParticleSystem to setup the update shader
  14381. * @param effect defines the update shader
  14382. */
  14383. applyToShader(effect: Effect): void;
  14384. /**
  14385. * Returns a string to use to update the GPU particles update shader
  14386. * @returns a string containng the defines string
  14387. */
  14388. getEffectDefines(): string;
  14389. /**
  14390. * Returns the string "BoxParticleEmitter"
  14391. * @returns a string containing the class name
  14392. */
  14393. getClassName(): string;
  14394. /**
  14395. * Serializes the particle system to a JSON object.
  14396. * @returns the JSON object
  14397. */
  14398. serialize(): any;
  14399. /**
  14400. * Parse properties from a JSON object
  14401. * @param serializationObject defines the JSON object
  14402. * @param scene defines the hosting scene
  14403. */
  14404. parse(serializationObject: any, scene: Nullable<Scene>): void;
  14405. }
  14406. }
  14407. declare module "babylonjs/Particles/EmitterTypes/index" {
  14408. export * from "babylonjs/Particles/EmitterTypes/boxParticleEmitter";
  14409. export * from "babylonjs/Particles/EmitterTypes/coneParticleEmitter";
  14410. export * from "babylonjs/Particles/EmitterTypes/cylinderParticleEmitter";
  14411. export * from "babylonjs/Particles/EmitterTypes/hemisphericParticleEmitter";
  14412. export * from "babylonjs/Particles/EmitterTypes/IParticleEmitterType";
  14413. export * from "babylonjs/Particles/EmitterTypes/pointParticleEmitter";
  14414. export * from "babylonjs/Particles/EmitterTypes/sphereParticleEmitter";
  14415. export * from "babylonjs/Particles/EmitterTypes/customParticleEmitter";
  14416. export * from "babylonjs/Particles/EmitterTypes/meshParticleEmitter";
  14417. }
  14418. declare module "babylonjs/Particles/IParticleSystem" {
  14419. import { Nullable } from "babylonjs/types";
  14420. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  14421. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  14422. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  14423. import { BoxParticleEmitter, IParticleEmitterType, PointParticleEmitter, HemisphericParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CylinderParticleEmitter, ConeParticleEmitter } from "babylonjs/Particles/EmitterTypes/index";
  14424. import { Scene } from "babylonjs/scene";
  14425. import { ColorGradient, FactorGradient, Color3Gradient } from "babylonjs/Misc/gradients";
  14426. import { Effect } from "babylonjs/Materials/effect";
  14427. import { Observable } from "babylonjs/Misc/observable";
  14428. import { Animation } from "babylonjs/Animations/animation";
  14429. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  14430. /**
  14431. * Interface representing a particle system in Babylon.js.
  14432. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  14433. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  14434. */
  14435. export interface IParticleSystem {
  14436. /**
  14437. * List of animations used by the particle system.
  14438. */
  14439. animations: Animation[];
  14440. /**
  14441. * The id of the Particle system.
  14442. */
  14443. id: string;
  14444. /**
  14445. * The name of the Particle system.
  14446. */
  14447. name: string;
  14448. /**
  14449. * The emitter represents the Mesh or position we are attaching the particle system to.
  14450. */
  14451. emitter: Nullable<AbstractMesh | Vector3>;
  14452. /**
  14453. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  14454. */
  14455. isBillboardBased: boolean;
  14456. /**
  14457. * The rendering group used by the Particle system to chose when to render.
  14458. */
  14459. renderingGroupId: number;
  14460. /**
  14461. * The layer mask we are rendering the particles through.
  14462. */
  14463. layerMask: number;
  14464. /**
  14465. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  14466. */
  14467. updateSpeed: number;
  14468. /**
  14469. * The amount of time the particle system is running (depends of the overall update speed).
  14470. */
  14471. targetStopDuration: number;
  14472. /**
  14473. * The texture used to render each particle. (this can be a spritesheet)
  14474. */
  14475. particleTexture: Nullable<BaseTexture>;
  14476. /**
  14477. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  14478. */
  14479. blendMode: number;
  14480. /**
  14481. * Minimum life time of emitting particles.
  14482. */
  14483. minLifeTime: number;
  14484. /**
  14485. * Maximum life time of emitting particles.
  14486. */
  14487. maxLifeTime: number;
  14488. /**
  14489. * Minimum Size of emitting particles.
  14490. */
  14491. minSize: number;
  14492. /**
  14493. * Maximum Size of emitting particles.
  14494. */
  14495. maxSize: number;
  14496. /**
  14497. * Minimum scale of emitting particles on X axis.
  14498. */
  14499. minScaleX: number;
  14500. /**
  14501. * Maximum scale of emitting particles on X axis.
  14502. */
  14503. maxScaleX: number;
  14504. /**
  14505. * Minimum scale of emitting particles on Y axis.
  14506. */
  14507. minScaleY: number;
  14508. /**
  14509. * Maximum scale of emitting particles on Y axis.
  14510. */
  14511. maxScaleY: number;
  14512. /**
  14513. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14514. */
  14515. color1: Color4;
  14516. /**
  14517. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  14518. */
  14519. color2: Color4;
  14520. /**
  14521. * Color the particle will have at the end of its lifetime.
  14522. */
  14523. colorDead: Color4;
  14524. /**
  14525. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  14526. */
  14527. emitRate: number;
  14528. /**
  14529. * You can use gravity if you want to give an orientation to your particles.
  14530. */
  14531. gravity: Vector3;
  14532. /**
  14533. * Minimum power of emitting particles.
  14534. */
  14535. minEmitPower: number;
  14536. /**
  14537. * Maximum power of emitting particles.
  14538. */
  14539. maxEmitPower: number;
  14540. /**
  14541. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  14542. */
  14543. minAngularSpeed: number;
  14544. /**
  14545. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  14546. */
  14547. maxAngularSpeed: number;
  14548. /**
  14549. * Gets or sets the minimal initial rotation in radians.
  14550. */
  14551. minInitialRotation: number;
  14552. /**
  14553. * Gets or sets the maximal initial rotation in radians.
  14554. */
  14555. maxInitialRotation: number;
  14556. /**
  14557. * The particle emitter type defines the emitter used by the particle system.
  14558. * It can be for example box, sphere, or cone...
  14559. */
  14560. particleEmitterType: Nullable<IParticleEmitterType>;
  14561. /**
  14562. * Defines the delay in milliseconds before starting the system (0 by default)
  14563. */
  14564. startDelay: number;
  14565. /**
  14566. * 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
  14567. */
  14568. preWarmCycles: number;
  14569. /**
  14570. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  14571. */
  14572. preWarmStepOffset: number;
  14573. /**
  14574. * 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)
  14575. */
  14576. spriteCellChangeSpeed: number;
  14577. /**
  14578. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  14579. */
  14580. startSpriteCellID: number;
  14581. /**
  14582. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  14583. */
  14584. endSpriteCellID: number;
  14585. /**
  14586. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  14587. */
  14588. spriteCellWidth: number;
  14589. /**
  14590. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  14591. */
  14592. spriteCellHeight: number;
  14593. /**
  14594. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  14595. */
  14596. spriteRandomStartCell: boolean;
  14597. /**
  14598. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  14599. */
  14600. isAnimationSheetEnabled: boolean;
  14601. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  14602. translationPivot: Vector2;
  14603. /**
  14604. * Gets or sets a texture used to add random noise to particle positions
  14605. */
  14606. noiseTexture: Nullable<BaseTexture>;
  14607. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  14608. noiseStrength: Vector3;
  14609. /**
  14610. * Gets or sets the billboard mode to use when isBillboardBased = true.
  14611. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  14612. */
  14613. billboardMode: number;
  14614. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  14615. limitVelocityDamping: number;
  14616. /**
  14617. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  14618. */
  14619. beginAnimationOnStart: boolean;
  14620. /**
  14621. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  14622. */
  14623. beginAnimationFrom: number;
  14624. /**
  14625. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  14626. */
  14627. beginAnimationTo: number;
  14628. /**
  14629. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  14630. */
  14631. beginAnimationLoop: boolean;
  14632. /**
  14633. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  14634. */
  14635. disposeOnStop: boolean;
  14636. /**
  14637. * Specifies if the particles are updated in emitter local space or world space
  14638. */
  14639. isLocal: boolean;
  14640. /** Snippet ID if the particle system was created from the snippet server */
  14641. snippetId: string;
  14642. /** Gets or sets a matrix to use to compute projection */
  14643. defaultProjectionMatrix: Matrix;
  14644. /**
  14645. * Gets the maximum number of particles active at the same time.
  14646. * @returns The max number of active particles.
  14647. */
  14648. getCapacity(): number;
  14649. /**
  14650. * Gets the number of particles active at the same time.
  14651. * @returns The number of active particles.
  14652. */
  14653. getActiveCount(): number;
  14654. /**
  14655. * Gets if the system has been started. (Note: this will still be true after stop is called)
  14656. * @returns True if it has been started, otherwise false.
  14657. */
  14658. isStarted(): boolean;
  14659. /**
  14660. * Animates the particle system for this frame.
  14661. */
  14662. animate(): void;
  14663. /**
  14664. * Renders the particle system in its current state.
  14665. * @returns the current number of particles
  14666. */
  14667. render(): number;
  14668. /**
  14669. * Dispose the particle system and frees its associated resources.
  14670. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  14671. */
  14672. dispose(disposeTexture?: boolean): void;
  14673. /**
  14674. * An event triggered when the system is disposed
  14675. */
  14676. onDisposeObservable: Observable<IParticleSystem>;
  14677. /**
  14678. * Clones the particle system.
  14679. * @param name The name of the cloned object
  14680. * @param newEmitter The new emitter to use
  14681. * @returns the cloned particle system
  14682. */
  14683. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  14684. /**
  14685. * Serializes the particle system to a JSON object
  14686. * @param serializeTexture defines if the texture must be serialized as well
  14687. * @returns the JSON object
  14688. */
  14689. serialize(serializeTexture: boolean): any;
  14690. /**
  14691. * Rebuild the particle system
  14692. */
  14693. rebuild(): void;
  14694. /** Force the system to rebuild all gradients that need to be resync */
  14695. forceRefreshGradients(): void;
  14696. /**
  14697. * Starts the particle system and begins to emit
  14698. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  14699. */
  14700. start(delay?: number): void;
  14701. /**
  14702. * Stops the particle system.
  14703. */
  14704. stop(): void;
  14705. /**
  14706. * Remove all active particles
  14707. */
  14708. reset(): void;
  14709. /**
  14710. * Gets a boolean indicating that the system is stopping
  14711. * @returns true if the system is currently stopping
  14712. */
  14713. isStopping(): boolean;
  14714. /**
  14715. * Is this system ready to be used/rendered
  14716. * @return true if the system is ready
  14717. */
  14718. isReady(): boolean;
  14719. /**
  14720. * Returns the string "ParticleSystem"
  14721. * @returns a string containing the class name
  14722. */
  14723. getClassName(): string;
  14724. /**
  14725. * Gets the custom effect used to render the particles
  14726. * @param blendMode Blend mode for which the effect should be retrieved
  14727. * @returns The effect
  14728. */
  14729. getCustomEffect(blendMode: number): Nullable<Effect>;
  14730. /**
  14731. * Sets the custom effect used to render the particles
  14732. * @param effect The effect to set
  14733. * @param blendMode Blend mode for which the effect should be set
  14734. */
  14735. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  14736. /**
  14737. * Fill the defines array according to the current settings of the particle system
  14738. * @param defines Array to be updated
  14739. * @param blendMode blend mode to take into account when updating the array
  14740. */
  14741. fillDefines(defines: Array<string>, blendMode: number): void;
  14742. /**
  14743. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  14744. * @param uniforms Uniforms array to fill
  14745. * @param attributes Attributes array to fill
  14746. * @param samplers Samplers array to fill
  14747. */
  14748. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  14749. /**
  14750. * Observable that will be called just before the particles are drawn
  14751. */
  14752. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  14753. /**
  14754. * Gets the name of the particle vertex shader
  14755. */
  14756. vertexShaderName: string;
  14757. /**
  14758. * Adds a new color gradient
  14759. * @param gradient defines the gradient to use (between 0 and 1)
  14760. * @param color1 defines the color to affect to the specified gradient
  14761. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  14762. * @returns the current particle system
  14763. */
  14764. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  14765. /**
  14766. * Remove a specific color gradient
  14767. * @param gradient defines the gradient to remove
  14768. * @returns the current particle system
  14769. */
  14770. removeColorGradient(gradient: number): IParticleSystem;
  14771. /**
  14772. * Adds a new size gradient
  14773. * @param gradient defines the gradient to use (between 0 and 1)
  14774. * @param factor defines the size factor to affect to the specified gradient
  14775. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14776. * @returns the current particle system
  14777. */
  14778. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14779. /**
  14780. * Remove a specific size gradient
  14781. * @param gradient defines the gradient to remove
  14782. * @returns the current particle system
  14783. */
  14784. removeSizeGradient(gradient: number): IParticleSystem;
  14785. /**
  14786. * Gets the current list of color gradients.
  14787. * You must use addColorGradient and removeColorGradient to udpate this list
  14788. * @returns the list of color gradients
  14789. */
  14790. getColorGradients(): Nullable<Array<ColorGradient>>;
  14791. /**
  14792. * Gets the current list of size gradients.
  14793. * You must use addSizeGradient and removeSizeGradient to udpate this list
  14794. * @returns the list of size gradients
  14795. */
  14796. getSizeGradients(): Nullable<Array<FactorGradient>>;
  14797. /**
  14798. * Gets the current list of angular speed gradients.
  14799. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  14800. * @returns the list of angular speed gradients
  14801. */
  14802. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  14803. /**
  14804. * Adds a new angular speed gradient
  14805. * @param gradient defines the gradient to use (between 0 and 1)
  14806. * @param factor defines the angular speed to affect to the specified gradient
  14807. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14808. * @returns the current particle system
  14809. */
  14810. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14811. /**
  14812. * Remove a specific angular speed gradient
  14813. * @param gradient defines the gradient to remove
  14814. * @returns the current particle system
  14815. */
  14816. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  14817. /**
  14818. * Gets the current list of velocity gradients.
  14819. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  14820. * @returns the list of velocity gradients
  14821. */
  14822. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  14823. /**
  14824. * Adds a new velocity gradient
  14825. * @param gradient defines the gradient to use (between 0 and 1)
  14826. * @param factor defines the velocity to affect to the specified gradient
  14827. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14828. * @returns the current particle system
  14829. */
  14830. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14831. /**
  14832. * Remove a specific velocity gradient
  14833. * @param gradient defines the gradient to remove
  14834. * @returns the current particle system
  14835. */
  14836. removeVelocityGradient(gradient: number): IParticleSystem;
  14837. /**
  14838. * Gets the current list of limit velocity gradients.
  14839. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  14840. * @returns the list of limit velocity gradients
  14841. */
  14842. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  14843. /**
  14844. * Adds a new limit velocity gradient
  14845. * @param gradient defines the gradient to use (between 0 and 1)
  14846. * @param factor defines the limit velocity to affect to the specified gradient
  14847. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14848. * @returns the current particle system
  14849. */
  14850. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14851. /**
  14852. * Remove a specific limit velocity gradient
  14853. * @param gradient defines the gradient to remove
  14854. * @returns the current particle system
  14855. */
  14856. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  14857. /**
  14858. * Adds a new drag gradient
  14859. * @param gradient defines the gradient to use (between 0 and 1)
  14860. * @param factor defines the drag to affect to the specified gradient
  14861. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14862. * @returns the current particle system
  14863. */
  14864. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14865. /**
  14866. * Remove a specific drag gradient
  14867. * @param gradient defines the gradient to remove
  14868. * @returns the current particle system
  14869. */
  14870. removeDragGradient(gradient: number): IParticleSystem;
  14871. /**
  14872. * Gets the current list of drag gradients.
  14873. * You must use addDragGradient and removeDragGradient to udpate this list
  14874. * @returns the list of drag gradients
  14875. */
  14876. getDragGradients(): Nullable<Array<FactorGradient>>;
  14877. /**
  14878. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  14879. * @param gradient defines the gradient to use (between 0 and 1)
  14880. * @param factor defines the emit rate to affect to the specified gradient
  14881. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14882. * @returns the current particle system
  14883. */
  14884. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14885. /**
  14886. * Remove a specific emit rate gradient
  14887. * @param gradient defines the gradient to remove
  14888. * @returns the current particle system
  14889. */
  14890. removeEmitRateGradient(gradient: number): IParticleSystem;
  14891. /**
  14892. * Gets the current list of emit rate gradients.
  14893. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  14894. * @returns the list of emit rate gradients
  14895. */
  14896. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  14897. /**
  14898. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  14899. * @param gradient defines the gradient to use (between 0 and 1)
  14900. * @param factor defines the start size to affect to the specified gradient
  14901. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14902. * @returns the current particle system
  14903. */
  14904. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14905. /**
  14906. * Remove a specific start size gradient
  14907. * @param gradient defines the gradient to remove
  14908. * @returns the current particle system
  14909. */
  14910. removeStartSizeGradient(gradient: number): IParticleSystem;
  14911. /**
  14912. * Gets the current list of start size gradients.
  14913. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  14914. * @returns the list of start size gradients
  14915. */
  14916. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  14917. /**
  14918. * Adds a new life time gradient
  14919. * @param gradient defines the gradient to use (between 0 and 1)
  14920. * @param factor defines the life time factor to affect to the specified gradient
  14921. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  14922. * @returns the current particle system
  14923. */
  14924. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  14925. /**
  14926. * Remove a specific life time gradient
  14927. * @param gradient defines the gradient to remove
  14928. * @returns the current particle system
  14929. */
  14930. removeLifeTimeGradient(gradient: number): IParticleSystem;
  14931. /**
  14932. * Gets the current list of life time gradients.
  14933. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  14934. * @returns the list of life time gradients
  14935. */
  14936. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  14937. /**
  14938. * Gets the current list of color gradients.
  14939. * You must use addColorGradient and removeColorGradient to udpate this list
  14940. * @returns the list of color gradients
  14941. */
  14942. getColorGradients(): Nullable<Array<ColorGradient>>;
  14943. /**
  14944. * Adds a new ramp gradient used to remap particle colors
  14945. * @param gradient defines the gradient to use (between 0 and 1)
  14946. * @param color defines the color to affect to the specified gradient
  14947. * @returns the current particle system
  14948. */
  14949. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  14950. /**
  14951. * Gets the current list of ramp gradients.
  14952. * You must use addRampGradient and removeRampGradient to udpate this list
  14953. * @returns the list of ramp gradients
  14954. */
  14955. getRampGradients(): Nullable<Array<Color3Gradient>>;
  14956. /** Gets or sets a boolean indicating that ramp gradients must be used
  14957. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  14958. */
  14959. useRampGradients: boolean;
  14960. /**
  14961. * Adds a new color remap gradient
  14962. * @param gradient defines the gradient to use (between 0 and 1)
  14963. * @param min defines the color remap minimal range
  14964. * @param max defines the color remap maximal range
  14965. * @returns the current particle system
  14966. */
  14967. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14968. /**
  14969. * Gets the current list of color remap gradients.
  14970. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  14971. * @returns the list of color remap gradients
  14972. */
  14973. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  14974. /**
  14975. * Adds a new alpha remap gradient
  14976. * @param gradient defines the gradient to use (between 0 and 1)
  14977. * @param min defines the alpha remap minimal range
  14978. * @param max defines the alpha remap maximal range
  14979. * @returns the current particle system
  14980. */
  14981. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  14982. /**
  14983. * Gets the current list of alpha remap gradients.
  14984. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  14985. * @returns the list of alpha remap gradients
  14986. */
  14987. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  14988. /**
  14989. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  14990. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  14991. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  14992. * @returns the emitter
  14993. */
  14994. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  14995. /**
  14996. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  14997. * @param radius The radius of the hemisphere to emit from
  14998. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  14999. * @returns the emitter
  15000. */
  15001. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  15002. /**
  15003. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  15004. * @param radius The radius of the sphere to emit from
  15005. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  15006. * @returns the emitter
  15007. */
  15008. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  15009. /**
  15010. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  15011. * @param radius The radius of the sphere to emit from
  15012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  15013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  15014. * @returns the emitter
  15015. */
  15016. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15017. /**
  15018. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  15019. * @param radius The radius of the emission cylinder
  15020. * @param height The height of the emission cylinder
  15021. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  15022. * @param directionRandomizer How much to randomize the particle direction [0-1]
  15023. * @returns the emitter
  15024. */
  15025. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  15026. /**
  15027. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  15028. * @param radius The radius of the cylinder to emit from
  15029. * @param height The height of the emission cylinder
  15030. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  15031. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  15032. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  15033. * @returns the emitter
  15034. */
  15035. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  15036. /**
  15037. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  15038. * @param radius The radius of the cone to emit from
  15039. * @param angle The base angle of the cone
  15040. * @returns the emitter
  15041. */
  15042. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  15043. /**
  15044. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  15045. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  15046. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  15047. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15048. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  15049. * @returns the emitter
  15050. */
  15051. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  15052. /**
  15053. * Get hosting scene
  15054. * @returns the scene
  15055. */
  15056. getScene(): Nullable<Scene>;
  15057. }
  15058. }
  15059. declare module "babylonjs/Meshes/transformNode" {
  15060. import { DeepImmutable } from "babylonjs/types";
  15061. import { Observable } from "babylonjs/Misc/observable";
  15062. import { Nullable } from "babylonjs/types";
  15063. import { Camera } from "babylonjs/Cameras/camera";
  15064. import { Scene } from "babylonjs/scene";
  15065. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  15066. import { Node } from "babylonjs/node";
  15067. import { Bone } from "babylonjs/Bones/bone";
  15068. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15069. import { Space } from "babylonjs/Maths/math.axis";
  15070. /**
  15071. * 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.
  15072. * @see https://doc.babylonjs.com/how_to/transformnode
  15073. */
  15074. export class TransformNode extends Node {
  15075. /**
  15076. * Object will not rotate to face the camera
  15077. */
  15078. static BILLBOARDMODE_NONE: number;
  15079. /**
  15080. * Object will rotate to face the camera but only on the x axis
  15081. */
  15082. static BILLBOARDMODE_X: number;
  15083. /**
  15084. * Object will rotate to face the camera but only on the y axis
  15085. */
  15086. static BILLBOARDMODE_Y: number;
  15087. /**
  15088. * Object will rotate to face the camera but only on the z axis
  15089. */
  15090. static BILLBOARDMODE_Z: number;
  15091. /**
  15092. * Object will rotate to face the camera
  15093. */
  15094. static BILLBOARDMODE_ALL: number;
  15095. /**
  15096. * Object will rotate to face the camera's position instead of orientation
  15097. */
  15098. static BILLBOARDMODE_USE_POSITION: number;
  15099. private static _TmpRotation;
  15100. private static _TmpScaling;
  15101. private static _TmpTranslation;
  15102. private _forward;
  15103. private _forwardInverted;
  15104. private _up;
  15105. private _right;
  15106. private _rightInverted;
  15107. private _position;
  15108. private _rotation;
  15109. private _rotationQuaternion;
  15110. protected _scaling: Vector3;
  15111. protected _isDirty: boolean;
  15112. private _transformToBoneReferal;
  15113. private _isAbsoluteSynced;
  15114. private _billboardMode;
  15115. /**
  15116. * Gets or sets the billboard mode. Default is 0.
  15117. *
  15118. * | Value | Type | Description |
  15119. * | --- | --- | --- |
  15120. * | 0 | BILLBOARDMODE_NONE | |
  15121. * | 1 | BILLBOARDMODE_X | |
  15122. * | 2 | BILLBOARDMODE_Y | |
  15123. * | 4 | BILLBOARDMODE_Z | |
  15124. * | 7 | BILLBOARDMODE_ALL | |
  15125. *
  15126. */
  15127. get billboardMode(): number;
  15128. set billboardMode(value: number);
  15129. private _preserveParentRotationForBillboard;
  15130. /**
  15131. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  15132. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  15133. */
  15134. get preserveParentRotationForBillboard(): boolean;
  15135. set preserveParentRotationForBillboard(value: boolean);
  15136. /**
  15137. * 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
  15138. */
  15139. scalingDeterminant: number;
  15140. private _infiniteDistance;
  15141. /**
  15142. * Gets or sets the distance of the object to max, often used by skybox
  15143. */
  15144. get infiniteDistance(): boolean;
  15145. set infiniteDistance(value: boolean);
  15146. /**
  15147. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  15148. * By default the system will update normals to compensate
  15149. */
  15150. ignoreNonUniformScaling: boolean;
  15151. /**
  15152. * 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
  15153. */
  15154. reIntegrateRotationIntoRotationQuaternion: boolean;
  15155. /** @hidden */
  15156. _poseMatrix: Nullable<Matrix>;
  15157. /** @hidden */
  15158. _localMatrix: Matrix;
  15159. private _usePivotMatrix;
  15160. private _absolutePosition;
  15161. private _absoluteScaling;
  15162. private _absoluteRotationQuaternion;
  15163. private _pivotMatrix;
  15164. private _pivotMatrixInverse;
  15165. /** @hidden */
  15166. _postMultiplyPivotMatrix: boolean;
  15167. protected _isWorldMatrixFrozen: boolean;
  15168. /** @hidden */
  15169. _indexInSceneTransformNodesArray: number;
  15170. /**
  15171. * An event triggered after the world matrix is updated
  15172. */
  15173. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  15174. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  15175. /**
  15176. * Gets a string identifying the name of the class
  15177. * @returns "TransformNode" string
  15178. */
  15179. getClassName(): string;
  15180. /**
  15181. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  15182. */
  15183. get position(): Vector3;
  15184. set position(newPosition: Vector3);
  15185. /**
  15186. * 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)).
  15187. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  15188. */
  15189. get rotation(): Vector3;
  15190. set rotation(newRotation: Vector3);
  15191. /**
  15192. * 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)).
  15193. */
  15194. get scaling(): Vector3;
  15195. set scaling(newScaling: Vector3);
  15196. /**
  15197. * 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).
  15198. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  15199. */
  15200. get rotationQuaternion(): Nullable<Quaternion>;
  15201. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  15202. /**
  15203. * The forward direction of that transform in world space.
  15204. */
  15205. get forward(): Vector3;
  15206. /**
  15207. * The up direction of that transform in world space.
  15208. */
  15209. get up(): Vector3;
  15210. /**
  15211. * The right direction of that transform in world space.
  15212. */
  15213. get right(): Vector3;
  15214. /**
  15215. * Copies the parameter passed Matrix into the mesh Pose matrix.
  15216. * @param matrix the matrix to copy the pose from
  15217. * @returns this TransformNode.
  15218. */
  15219. updatePoseMatrix(matrix: Matrix): TransformNode;
  15220. /**
  15221. * Returns the mesh Pose matrix.
  15222. * @returns the pose matrix
  15223. */
  15224. getPoseMatrix(): Matrix;
  15225. /** @hidden */
  15226. _isSynchronized(): boolean;
  15227. /** @hidden */
  15228. _initCache(): void;
  15229. /**
  15230. * Flag the transform node as dirty (Forcing it to update everything)
  15231. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  15232. * @returns this transform node
  15233. */
  15234. markAsDirty(property: string): TransformNode;
  15235. /**
  15236. * Returns the current mesh absolute position.
  15237. * Returns a Vector3.
  15238. */
  15239. get absolutePosition(): Vector3;
  15240. /**
  15241. * Returns the current mesh absolute scaling.
  15242. * Returns a Vector3.
  15243. */
  15244. get absoluteScaling(): Vector3;
  15245. /**
  15246. * Returns the current mesh absolute rotation.
  15247. * Returns a Quaternion.
  15248. */
  15249. get absoluteRotationQuaternion(): Quaternion;
  15250. /**
  15251. * Sets a new matrix to apply before all other transformation
  15252. * @param matrix defines the transform matrix
  15253. * @returns the current TransformNode
  15254. */
  15255. setPreTransformMatrix(matrix: Matrix): TransformNode;
  15256. /**
  15257. * Sets a new pivot matrix to the current node
  15258. * @param matrix defines the new pivot matrix to use
  15259. * @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
  15260. * @returns the current TransformNode
  15261. */
  15262. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  15263. /**
  15264. * Returns the mesh pivot matrix.
  15265. * Default : Identity.
  15266. * @returns the matrix
  15267. */
  15268. getPivotMatrix(): Matrix;
  15269. /**
  15270. * Instantiate (when possible) or clone that node with its hierarchy
  15271. * @param newParent defines the new parent to use for the instance (or clone)
  15272. * @param options defines options to configure how copy is done
  15273. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  15274. * @returns an instance (or a clone) of the current node with its hiearchy
  15275. */
  15276. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  15277. doNotInstantiate: boolean;
  15278. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  15279. /**
  15280. * Prevents the World matrix to be computed any longer
  15281. * @param newWorldMatrix defines an optional matrix to use as world matrix
  15282. * @returns the TransformNode.
  15283. */
  15284. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  15285. /**
  15286. * Allows back the World matrix computation.
  15287. * @returns the TransformNode.
  15288. */
  15289. unfreezeWorldMatrix(): this;
  15290. /**
  15291. * True if the World matrix has been frozen.
  15292. */
  15293. get isWorldMatrixFrozen(): boolean;
  15294. /**
  15295. * Retuns the mesh absolute position in the World.
  15296. * @returns a Vector3.
  15297. */
  15298. getAbsolutePosition(): Vector3;
  15299. /**
  15300. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  15301. * @param absolutePosition the absolute position to set
  15302. * @returns the TransformNode.
  15303. */
  15304. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  15305. /**
  15306. * Sets the mesh position in its local space.
  15307. * @param vector3 the position to set in localspace
  15308. * @returns the TransformNode.
  15309. */
  15310. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  15311. /**
  15312. * Returns the mesh position in the local space from the current World matrix values.
  15313. * @returns a new Vector3.
  15314. */
  15315. getPositionExpressedInLocalSpace(): Vector3;
  15316. /**
  15317. * Translates the mesh along the passed Vector3 in its local space.
  15318. * @param vector3 the distance to translate in localspace
  15319. * @returns the TransformNode.
  15320. */
  15321. locallyTranslate(vector3: Vector3): TransformNode;
  15322. private static _lookAtVectorCache;
  15323. /**
  15324. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  15325. * @param targetPoint the position (must be in same space as current mesh) to look at
  15326. * @param yawCor optional yaw (y-axis) correction in radians
  15327. * @param pitchCor optional pitch (x-axis) correction in radians
  15328. * @param rollCor optional roll (z-axis) correction in radians
  15329. * @param space the choosen space of the target
  15330. * @returns the TransformNode.
  15331. */
  15332. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  15333. /**
  15334. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15335. * This Vector3 is expressed in the World space.
  15336. * @param localAxis axis to rotate
  15337. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  15338. */
  15339. getDirection(localAxis: Vector3): Vector3;
  15340. /**
  15341. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  15342. * localAxis is expressed in the mesh local space.
  15343. * result is computed in the Wordl space from the mesh World matrix.
  15344. * @param localAxis axis to rotate
  15345. * @param result the resulting transformnode
  15346. * @returns this TransformNode.
  15347. */
  15348. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  15349. /**
  15350. * Sets this transform node rotation to the given local axis.
  15351. * @param localAxis the axis in local space
  15352. * @param yawCor optional yaw (y-axis) correction in radians
  15353. * @param pitchCor optional pitch (x-axis) correction in radians
  15354. * @param rollCor optional roll (z-axis) correction in radians
  15355. * @returns this TransformNode
  15356. */
  15357. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  15358. /**
  15359. * Sets a new pivot point to the current node
  15360. * @param point defines the new pivot point to use
  15361. * @param space defines if the point is in world or local space (local by default)
  15362. * @returns the current TransformNode
  15363. */
  15364. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  15365. /**
  15366. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  15367. * @returns the pivot point
  15368. */
  15369. getPivotPoint(): Vector3;
  15370. /**
  15371. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  15372. * @param result the vector3 to store the result
  15373. * @returns this TransformNode.
  15374. */
  15375. getPivotPointToRef(result: Vector3): TransformNode;
  15376. /**
  15377. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  15378. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  15379. */
  15380. getAbsolutePivotPoint(): Vector3;
  15381. /**
  15382. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  15383. * @param result vector3 to store the result
  15384. * @returns this TransformNode.
  15385. */
  15386. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  15387. /**
  15388. * Defines the passed node as the parent of the current node.
  15389. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  15390. * @see https://doc.babylonjs.com/how_to/parenting
  15391. * @param node the node ot set as the parent
  15392. * @returns this TransformNode.
  15393. */
  15394. setParent(node: Nullable<Node>): TransformNode;
  15395. private _nonUniformScaling;
  15396. /**
  15397. * True if the scaling property of this object is non uniform eg. (1,2,1)
  15398. */
  15399. get nonUniformScaling(): boolean;
  15400. /** @hidden */
  15401. _updateNonUniformScalingState(value: boolean): boolean;
  15402. /**
  15403. * Attach the current TransformNode to another TransformNode associated with a bone
  15404. * @param bone Bone affecting the TransformNode
  15405. * @param affectedTransformNode TransformNode associated with the bone
  15406. * @returns this object
  15407. */
  15408. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  15409. /**
  15410. * Detach the transform node if its associated with a bone
  15411. * @returns this object
  15412. */
  15413. detachFromBone(): TransformNode;
  15414. private static _rotationAxisCache;
  15415. /**
  15416. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  15417. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  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. * @param axis the axis to rotate around
  15421. * @param amount the amount to rotate in radians
  15422. * @param space Space to rotate in (Default: local)
  15423. * @returns the TransformNode.
  15424. */
  15425. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  15426. /**
  15427. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  15428. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  15429. * The passed axis is also normalized. .
  15430. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  15431. * @param point the point to rotate around
  15432. * @param axis the axis to rotate around
  15433. * @param amount the amount to rotate in radians
  15434. * @returns the TransformNode
  15435. */
  15436. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  15437. /**
  15438. * Translates the mesh along the axis vector for the passed distance in the given space.
  15439. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  15440. * @param axis the axis to translate in
  15441. * @param distance the distance to translate
  15442. * @param space Space to rotate in (Default: local)
  15443. * @returns the TransformNode.
  15444. */
  15445. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  15446. /**
  15447. * Adds a rotation step to the mesh current rotation.
  15448. * x, y, z are Euler angles expressed in radians.
  15449. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  15450. * This means this rotation is made in the mesh local space only.
  15451. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  15452. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  15453. * ```javascript
  15454. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  15455. * ```
  15456. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  15457. * 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.
  15458. * @param x Rotation to add
  15459. * @param y Rotation to add
  15460. * @param z Rotation to add
  15461. * @returns the TransformNode.
  15462. */
  15463. addRotation(x: number, y: number, z: number): TransformNode;
  15464. /**
  15465. * @hidden
  15466. */
  15467. protected _getEffectiveParent(): Nullable<Node>;
  15468. /**
  15469. * Computes the world matrix of the node
  15470. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  15471. * @returns the world matrix
  15472. */
  15473. computeWorldMatrix(force?: boolean): Matrix;
  15474. /**
  15475. * Resets this nodeTransform's local matrix to Matrix.Identity().
  15476. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  15477. */
  15478. resetLocalMatrix(independentOfChildren?: boolean): void;
  15479. protected _afterComputeWorldMatrix(): void;
  15480. /**
  15481. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  15482. * @param func callback function to add
  15483. *
  15484. * @returns the TransformNode.
  15485. */
  15486. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15487. /**
  15488. * Removes a registered callback function.
  15489. * @param func callback function to remove
  15490. * @returns the TransformNode.
  15491. */
  15492. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  15493. /**
  15494. * Gets the position of the current mesh in camera space
  15495. * @param camera defines the camera to use
  15496. * @returns a position
  15497. */
  15498. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  15499. /**
  15500. * Returns the distance from the mesh to the active camera
  15501. * @param camera defines the camera to use
  15502. * @returns the distance
  15503. */
  15504. getDistanceToCamera(camera?: Nullable<Camera>): number;
  15505. /**
  15506. * Clone the current transform node
  15507. * @param name Name of the new clone
  15508. * @param newParent New parent for the clone
  15509. * @param doNotCloneChildren Do not clone children hierarchy
  15510. * @returns the new transform node
  15511. */
  15512. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  15513. /**
  15514. * Serializes the objects information.
  15515. * @param currentSerializationObject defines the object to serialize in
  15516. * @returns the serialized object
  15517. */
  15518. serialize(currentSerializationObject?: any): any;
  15519. /**
  15520. * Returns a new TransformNode object parsed from the source provided.
  15521. * @param parsedTransformNode is the source.
  15522. * @param scene the scne the object belongs to
  15523. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  15524. * @returns a new TransformNode object parsed from the source provided.
  15525. */
  15526. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  15527. /**
  15528. * Get all child-transformNodes of this node
  15529. * @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
  15530. * @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
  15531. * @returns an array of TransformNode
  15532. */
  15533. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  15534. /**
  15535. * Releases resources associated with this transform node.
  15536. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  15537. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  15538. */
  15539. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  15540. /**
  15541. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  15542. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  15543. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  15544. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  15545. * @returns the current mesh
  15546. */
  15547. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  15548. private _syncAbsoluteScalingAndRotation;
  15549. }
  15550. }
  15551. declare module "babylonjs/Animations/animationPropertiesOverride" {
  15552. /**
  15553. * Class used to override all child animations of a given target
  15554. */
  15555. export class AnimationPropertiesOverride {
  15556. /**
  15557. * Gets or sets a value indicating if animation blending must be used
  15558. */
  15559. enableBlending: boolean;
  15560. /**
  15561. * Gets or sets the blending speed to use when enableBlending is true
  15562. */
  15563. blendingSpeed: number;
  15564. /**
  15565. * Gets or sets the default loop mode to use
  15566. */
  15567. loopMode: number;
  15568. }
  15569. }
  15570. declare module "babylonjs/Bones/bone" {
  15571. import { Skeleton } from "babylonjs/Bones/skeleton";
  15572. import { Vector3, Quaternion, Matrix } from "babylonjs/Maths/math.vector";
  15573. import { Nullable } from "babylonjs/types";
  15574. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  15575. import { TransformNode } from "babylonjs/Meshes/transformNode";
  15576. import { Node } from "babylonjs/node";
  15577. import { Space } from "babylonjs/Maths/math.axis";
  15578. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  15579. /**
  15580. * Class used to store bone information
  15581. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  15582. */
  15583. export class Bone extends Node {
  15584. /**
  15585. * defines the bone name
  15586. */
  15587. name: string;
  15588. private static _tmpVecs;
  15589. private static _tmpQuat;
  15590. private static _tmpMats;
  15591. /**
  15592. * Gets the list of child bones
  15593. */
  15594. children: Bone[];
  15595. /** Gets the animations associated with this bone */
  15596. animations: import("babylonjs/Animations/animation").Animation[];
  15597. /**
  15598. * Gets or sets bone length
  15599. */
  15600. length: number;
  15601. /**
  15602. * @hidden Internal only
  15603. * Set this value to map this bone to a different index in the transform matrices
  15604. * Set this value to -1 to exclude the bone from the transform matrices
  15605. */
  15606. _index: Nullable<number>;
  15607. private _skeleton;
  15608. private _localMatrix;
  15609. private _restPose;
  15610. private _bindPose;
  15611. private _baseMatrix;
  15612. private _absoluteTransform;
  15613. private _invertedAbsoluteTransform;
  15614. private _parent;
  15615. private _scalingDeterminant;
  15616. private _worldTransform;
  15617. private _localScaling;
  15618. private _localRotation;
  15619. private _localPosition;
  15620. private _needToDecompose;
  15621. private _needToCompose;
  15622. /** @hidden */
  15623. _linkedTransformNode: Nullable<TransformNode>;
  15624. /** @hidden */
  15625. _waitingTransformNodeId: Nullable<string>;
  15626. /** @hidden */
  15627. get _matrix(): Matrix;
  15628. /** @hidden */
  15629. set _matrix(value: Matrix);
  15630. /**
  15631. * Create a new bone
  15632. * @param name defines the bone name
  15633. * @param skeleton defines the parent skeleton
  15634. * @param parentBone defines the parent (can be null if the bone is the root)
  15635. * @param localMatrix defines the local matrix
  15636. * @param restPose defines the rest pose matrix
  15637. * @param baseMatrix defines the base matrix
  15638. * @param index defines index of the bone in the hiearchy
  15639. */
  15640. constructor(
  15641. /**
  15642. * defines the bone name
  15643. */
  15644. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  15645. /**
  15646. * Gets the current object class name.
  15647. * @return the class name
  15648. */
  15649. getClassName(): string;
  15650. /**
  15651. * Gets the parent skeleton
  15652. * @returns a skeleton
  15653. */
  15654. getSkeleton(): Skeleton;
  15655. /**
  15656. * Gets parent bone
  15657. * @returns a bone or null if the bone is the root of the bone hierarchy
  15658. */
  15659. getParent(): Nullable<Bone>;
  15660. /**
  15661. * Returns an array containing the root bones
  15662. * @returns an array containing the root bones
  15663. */
  15664. getChildren(): Array<Bone>;
  15665. /**
  15666. * Gets the node index in matrix array generated for rendering
  15667. * @returns the node index
  15668. */
  15669. getIndex(): number;
  15670. /**
  15671. * Sets the parent bone
  15672. * @param parent defines the parent (can be null if the bone is the root)
  15673. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15674. */
  15675. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  15676. /**
  15677. * Gets the local matrix
  15678. * @returns a matrix
  15679. */
  15680. getLocalMatrix(): Matrix;
  15681. /**
  15682. * Gets the base matrix (initial matrix which remains unchanged)
  15683. * @returns a matrix
  15684. */
  15685. getBaseMatrix(): Matrix;
  15686. /**
  15687. * Gets the rest pose matrix
  15688. * @returns a matrix
  15689. */
  15690. getRestPose(): Matrix;
  15691. /**
  15692. * Sets the rest pose matrix
  15693. * @param matrix the local-space rest pose to set for this bone
  15694. */
  15695. setRestPose(matrix: Matrix): void;
  15696. /**
  15697. * Gets the bind pose matrix
  15698. * @returns the bind pose matrix
  15699. */
  15700. getBindPose(): Matrix;
  15701. /**
  15702. * Sets the bind pose matrix
  15703. * @param matrix the local-space bind pose to set for this bone
  15704. */
  15705. setBindPose(matrix: Matrix): void;
  15706. /**
  15707. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  15708. */
  15709. getWorldMatrix(): Matrix;
  15710. /**
  15711. * Sets the local matrix to rest pose matrix
  15712. */
  15713. returnToRest(): void;
  15714. /**
  15715. * Gets the inverse of the absolute transform matrix.
  15716. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  15717. * @returns a matrix
  15718. */
  15719. getInvertedAbsoluteTransform(): Matrix;
  15720. /**
  15721. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  15722. * @returns a matrix
  15723. */
  15724. getAbsoluteTransform(): Matrix;
  15725. /**
  15726. * Links with the given transform node.
  15727. * The local matrix of this bone is copied from the transform node every frame.
  15728. * @param transformNode defines the transform node to link to
  15729. */
  15730. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  15731. /**
  15732. * Gets the node used to drive the bone's transformation
  15733. * @returns a transform node or null
  15734. */
  15735. getTransformNode(): Nullable<TransformNode>;
  15736. /** Gets or sets current position (in local space) */
  15737. get position(): Vector3;
  15738. set position(newPosition: Vector3);
  15739. /** Gets or sets current rotation (in local space) */
  15740. get rotation(): Vector3;
  15741. set rotation(newRotation: Vector3);
  15742. /** Gets or sets current rotation quaternion (in local space) */
  15743. get rotationQuaternion(): Quaternion;
  15744. set rotationQuaternion(newRotation: Quaternion);
  15745. /** Gets or sets current scaling (in local space) */
  15746. get scaling(): Vector3;
  15747. set scaling(newScaling: Vector3);
  15748. /**
  15749. * Gets the animation properties override
  15750. */
  15751. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  15752. private _decompose;
  15753. private _compose;
  15754. /**
  15755. * Update the base and local matrices
  15756. * @param matrix defines the new base or local matrix
  15757. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  15758. * @param updateLocalMatrix defines if the local matrix should be updated
  15759. */
  15760. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  15761. /** @hidden */
  15762. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  15763. /**
  15764. * Flag the bone as dirty (Forcing it to update everything)
  15765. */
  15766. markAsDirty(): void;
  15767. /** @hidden */
  15768. _markAsDirtyAndCompose(): void;
  15769. private _markAsDirtyAndDecompose;
  15770. /**
  15771. * Translate the bone in local or world space
  15772. * @param vec The amount to translate the bone
  15773. * @param space The space that the translation is in
  15774. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15775. */
  15776. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15777. /**
  15778. * Set the postion of the bone in local or world space
  15779. * @param position The position to set the bone
  15780. * @param space The space that the position is in
  15781. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15782. */
  15783. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15784. /**
  15785. * Set the absolute position of the bone (world space)
  15786. * @param position The position to set the bone
  15787. * @param mesh The mesh that this bone is attached to
  15788. */
  15789. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  15790. /**
  15791. * Scale the bone on the x, y and z axes (in local space)
  15792. * @param x The amount to scale the bone on the x axis
  15793. * @param y The amount to scale the bone on the y axis
  15794. * @param z The amount to scale the bone on the z axis
  15795. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  15796. */
  15797. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  15798. /**
  15799. * Set the bone scaling in local space
  15800. * @param scale defines the scaling vector
  15801. */
  15802. setScale(scale: Vector3): void;
  15803. /**
  15804. * Gets the current scaling in local space
  15805. * @returns the current scaling vector
  15806. */
  15807. getScale(): Vector3;
  15808. /**
  15809. * Gets the current scaling in local space and stores it in a target vector
  15810. * @param result defines the target vector
  15811. */
  15812. getScaleToRef(result: Vector3): void;
  15813. /**
  15814. * Set the yaw, pitch, and roll of the bone in local or world space
  15815. * @param yaw The rotation of the bone on the y axis
  15816. * @param pitch The rotation of the bone on the x axis
  15817. * @param roll The rotation of the bone on the z axis
  15818. * @param space The space that the axes of rotation are in
  15819. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15820. */
  15821. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  15822. /**
  15823. * Add a rotation to the bone on an axis in local or world space
  15824. * @param axis The axis to rotate the bone on
  15825. * @param amount The amount to rotate the bone
  15826. * @param space The space that the axis is in
  15827. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15828. */
  15829. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  15830. /**
  15831. * Set the rotation of the bone to a particular axis angle in local or world space
  15832. * @param axis The axis to rotate the bone on
  15833. * @param angle The angle that the bone should be rotated to
  15834. * @param space The space that the axis is in
  15835. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15836. */
  15837. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  15838. /**
  15839. * Set the euler rotation of the bone in local or world space
  15840. * @param rotation The euler rotation that the bone should be set to
  15841. * @param space The space that the rotation is in
  15842. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15843. */
  15844. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  15845. /**
  15846. * Set the quaternion rotation of the bone in local or world space
  15847. * @param quat The quaternion rotation that the bone should be set to
  15848. * @param space The space that the rotation is in
  15849. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15850. */
  15851. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  15852. /**
  15853. * Set the rotation matrix of the bone in local or world space
  15854. * @param rotMat The rotation matrix that the bone should be set to
  15855. * @param space The space that the rotation is in
  15856. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15857. */
  15858. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  15859. private _rotateWithMatrix;
  15860. private _getNegativeRotationToRef;
  15861. /**
  15862. * Get the position of the bone in local or world space
  15863. * @param space The space that the returned position is in
  15864. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15865. * @returns The position of the bone
  15866. */
  15867. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15868. /**
  15869. * Copy the position of the bone to a vector3 in local or world space
  15870. * @param space The space that the returned position is in
  15871. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15872. * @param result The vector3 to copy the position to
  15873. */
  15874. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  15875. /**
  15876. * Get the absolute position of the bone (world space)
  15877. * @param mesh The mesh that this bone is attached to
  15878. * @returns The absolute position of the bone
  15879. */
  15880. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  15881. /**
  15882. * Copy the absolute position of the bone (world space) to the result param
  15883. * @param mesh The mesh that this bone is attached to
  15884. * @param result The vector3 to copy the absolute position to
  15885. */
  15886. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  15887. /**
  15888. * Compute the absolute transforms of this bone and its children
  15889. */
  15890. computeAbsoluteTransforms(): void;
  15891. /**
  15892. * Get the world direction from an axis that is in the local space of the bone
  15893. * @param localAxis The local direction that is used to compute the world direction
  15894. * @param mesh The mesh that this bone is attached to
  15895. * @returns The world direction
  15896. */
  15897. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15898. /**
  15899. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  15900. * @param localAxis The local direction that is used to compute the world direction
  15901. * @param mesh The mesh that this bone is attached to
  15902. * @param result The vector3 that the world direction will be copied to
  15903. */
  15904. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15905. /**
  15906. * Get the euler rotation of the bone in local or world space
  15907. * @param space The space that the rotation should be in
  15908. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15909. * @returns The euler rotation
  15910. */
  15911. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  15912. /**
  15913. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  15914. * @param space The space that the rotation should be in
  15915. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15916. * @param result The vector3 that the rotation should be copied to
  15917. */
  15918. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15919. /**
  15920. * Get the quaternion rotation of the bone in either local or world space
  15921. * @param space The space that the rotation should be in
  15922. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15923. * @returns The quaternion rotation
  15924. */
  15925. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  15926. /**
  15927. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  15928. * @param space The space that the rotation should be in
  15929. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15930. * @param result The quaternion that the rotation should be copied to
  15931. */
  15932. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  15933. /**
  15934. * Get the rotation matrix of the bone in local or world space
  15935. * @param space The space that the rotation should be in
  15936. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15937. * @returns The rotation matrix
  15938. */
  15939. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  15940. /**
  15941. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  15942. * @param space The space that the rotation should be in
  15943. * @param mesh The mesh that this bone is attached to. This is only used in world space
  15944. * @param result The quaternion that the rotation should be copied to
  15945. */
  15946. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  15947. /**
  15948. * Get the world position of a point that is in the local space of the bone
  15949. * @param position The local position
  15950. * @param mesh The mesh that this bone is attached to
  15951. * @returns The world position
  15952. */
  15953. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15954. /**
  15955. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  15956. * @param position The local position
  15957. * @param mesh The mesh that this bone is attached to
  15958. * @param result The vector3 that the world position should be copied to
  15959. */
  15960. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15961. /**
  15962. * Get the local position of a point that is in world space
  15963. * @param position The world position
  15964. * @param mesh The mesh that this bone is attached to
  15965. * @returns The local position
  15966. */
  15967. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  15968. /**
  15969. * Get the local position of a point that is in world space and copy it to the result param
  15970. * @param position The world position
  15971. * @param mesh The mesh that this bone is attached to
  15972. * @param result The vector3 that the local position should be copied to
  15973. */
  15974. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  15975. /**
  15976. * Set the current local matrix as the restPose for this bone.
  15977. */
  15978. setCurrentPoseAsRest(): void;
  15979. }
  15980. }
  15981. declare module "babylonjs/Animations/runtimeAnimation" {
  15982. import { Animation, _IAnimationState } from "babylonjs/Animations/animation";
  15983. import { Animatable } from "babylonjs/Animations/animatable";
  15984. import { Scene } from "babylonjs/scene";
  15985. /**
  15986. * Defines a runtime animation
  15987. */
  15988. export class RuntimeAnimation {
  15989. private _events;
  15990. /**
  15991. * The current frame of the runtime animation
  15992. */
  15993. private _currentFrame;
  15994. /**
  15995. * The animation used by the runtime animation
  15996. */
  15997. private _animation;
  15998. /**
  15999. * The target of the runtime animation
  16000. */
  16001. private _target;
  16002. /**
  16003. * The initiating animatable
  16004. */
  16005. private _host;
  16006. /**
  16007. * The original value of the runtime animation
  16008. */
  16009. private _originalValue;
  16010. /**
  16011. * The original blend value of the runtime animation
  16012. */
  16013. private _originalBlendValue;
  16014. /**
  16015. * The offsets cache of the runtime animation
  16016. */
  16017. private _offsetsCache;
  16018. /**
  16019. * The high limits cache of the runtime animation
  16020. */
  16021. private _highLimitsCache;
  16022. /**
  16023. * Specifies if the runtime animation has been stopped
  16024. */
  16025. private _stopped;
  16026. /**
  16027. * The blending factor of the runtime animation
  16028. */
  16029. private _blendingFactor;
  16030. /**
  16031. * The BabylonJS scene
  16032. */
  16033. private _scene;
  16034. /**
  16035. * The current value of the runtime animation
  16036. */
  16037. private _currentValue;
  16038. /** @hidden */
  16039. _animationState: _IAnimationState;
  16040. /**
  16041. * The active target of the runtime animation
  16042. */
  16043. private _activeTargets;
  16044. private _currentActiveTarget;
  16045. private _directTarget;
  16046. /**
  16047. * The target path of the runtime animation
  16048. */
  16049. private _targetPath;
  16050. /**
  16051. * The weight of the runtime animation
  16052. */
  16053. private _weight;
  16054. /**
  16055. * The ratio offset of the runtime animation
  16056. */
  16057. private _ratioOffset;
  16058. /**
  16059. * The previous delay of the runtime animation
  16060. */
  16061. private _previousDelay;
  16062. /**
  16063. * The previous ratio of the runtime animation
  16064. */
  16065. private _previousRatio;
  16066. private _enableBlending;
  16067. private _keys;
  16068. private _minFrame;
  16069. private _maxFrame;
  16070. private _minValue;
  16071. private _maxValue;
  16072. private _targetIsArray;
  16073. /**
  16074. * Gets the current frame of the runtime animation
  16075. */
  16076. get currentFrame(): number;
  16077. /**
  16078. * Gets the weight of the runtime animation
  16079. */
  16080. get weight(): number;
  16081. /**
  16082. * Gets the current value of the runtime animation
  16083. */
  16084. get currentValue(): any;
  16085. /**
  16086. * Gets the target path of the runtime animation
  16087. */
  16088. get targetPath(): string;
  16089. /**
  16090. * Gets the actual target of the runtime animation
  16091. */
  16092. get target(): any;
  16093. /**
  16094. * Gets the additive state of the runtime animation
  16095. */
  16096. get isAdditive(): boolean;
  16097. /** @hidden */
  16098. _onLoop: () => void;
  16099. /**
  16100. * Create a new RuntimeAnimation object
  16101. * @param target defines the target of the animation
  16102. * @param animation defines the source animation object
  16103. * @param scene defines the hosting scene
  16104. * @param host defines the initiating Animatable
  16105. */
  16106. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  16107. private _preparePath;
  16108. /**
  16109. * Gets the animation from the runtime animation
  16110. */
  16111. get animation(): Animation;
  16112. /**
  16113. * Resets the runtime animation to the beginning
  16114. * @param restoreOriginal defines whether to restore the target property to the original value
  16115. */
  16116. reset(restoreOriginal?: boolean): void;
  16117. /**
  16118. * Specifies if the runtime animation is stopped
  16119. * @returns Boolean specifying if the runtime animation is stopped
  16120. */
  16121. isStopped(): boolean;
  16122. /**
  16123. * Disposes of the runtime animation
  16124. */
  16125. dispose(): void;
  16126. /**
  16127. * Apply the interpolated value to the target
  16128. * @param currentValue defines the value computed by the animation
  16129. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  16130. */
  16131. setValue(currentValue: any, weight: number): void;
  16132. private _getOriginalValues;
  16133. private _setValue;
  16134. /**
  16135. * Gets the loop pmode of the runtime animation
  16136. * @returns Loop Mode
  16137. */
  16138. private _getCorrectLoopMode;
  16139. /**
  16140. * Move the current animation to a given frame
  16141. * @param frame defines the frame to move to
  16142. */
  16143. goToFrame(frame: number): void;
  16144. /**
  16145. * @hidden Internal use only
  16146. */
  16147. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  16148. /**
  16149. * Execute the current animation
  16150. * @param delay defines the delay to add to the current frame
  16151. * @param from defines the lower bound of the animation range
  16152. * @param to defines the upper bound of the animation range
  16153. * @param loop defines if the current animation must loop
  16154. * @param speedRatio defines the current speed ratio
  16155. * @param weight defines the weight of the animation (default is -1 so no weight)
  16156. * @param onLoop optional callback called when animation loops
  16157. * @returns a boolean indicating if the animation is running
  16158. */
  16159. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  16160. }
  16161. }
  16162. declare module "babylonjs/Animations/animatable" {
  16163. import { Animation } from "babylonjs/Animations/animation";
  16164. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  16165. import { Nullable } from "babylonjs/types";
  16166. import { Observable } from "babylonjs/Misc/observable";
  16167. import { Scene } from "babylonjs/scene";
  16168. import { Matrix, Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  16169. import { Node } from "babylonjs/node";
  16170. /**
  16171. * Class used to store an actual running animation
  16172. */
  16173. export class Animatable {
  16174. /** defines the target object */
  16175. target: any;
  16176. /** defines the starting frame number (default is 0) */
  16177. fromFrame: number;
  16178. /** defines the ending frame number (default is 100) */
  16179. toFrame: number;
  16180. /** defines if the animation must loop (default is false) */
  16181. loopAnimation: boolean;
  16182. /** defines a callback to call when animation ends if it is not looping */
  16183. onAnimationEnd?: (() => void) | null | undefined;
  16184. /** defines a callback to call when animation loops */
  16185. onAnimationLoop?: (() => void) | null | undefined;
  16186. /** defines whether the animation should be evaluated additively */
  16187. isAdditive: boolean;
  16188. private _localDelayOffset;
  16189. private _pausedDelay;
  16190. private _runtimeAnimations;
  16191. private _paused;
  16192. private _scene;
  16193. private _speedRatio;
  16194. private _weight;
  16195. private _syncRoot;
  16196. /**
  16197. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  16198. * This will only apply for non looping animation (default is true)
  16199. */
  16200. disposeOnEnd: boolean;
  16201. /**
  16202. * Gets a boolean indicating if the animation has started
  16203. */
  16204. animationStarted: boolean;
  16205. /**
  16206. * Observer raised when the animation ends
  16207. */
  16208. onAnimationEndObservable: Observable<Animatable>;
  16209. /**
  16210. * Observer raised when the animation loops
  16211. */
  16212. onAnimationLoopObservable: Observable<Animatable>;
  16213. /**
  16214. * Gets the root Animatable used to synchronize and normalize animations
  16215. */
  16216. get syncRoot(): Nullable<Animatable>;
  16217. /**
  16218. * Gets the current frame of the first RuntimeAnimation
  16219. * Used to synchronize Animatables
  16220. */
  16221. get masterFrame(): number;
  16222. /**
  16223. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  16224. */
  16225. get weight(): number;
  16226. set weight(value: number);
  16227. /**
  16228. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  16229. */
  16230. get speedRatio(): number;
  16231. set speedRatio(value: number);
  16232. /**
  16233. * Creates a new Animatable
  16234. * @param scene defines the hosting scene
  16235. * @param target defines the target object
  16236. * @param fromFrame defines the starting frame number (default is 0)
  16237. * @param toFrame defines the ending frame number (default is 100)
  16238. * @param loopAnimation defines if the animation must loop (default is false)
  16239. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  16240. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  16241. * @param animations defines a group of animation to add to the new Animatable
  16242. * @param onAnimationLoop defines a callback to call when animation loops
  16243. * @param isAdditive defines whether the animation should be evaluated additively
  16244. */
  16245. constructor(scene: Scene,
  16246. /** defines the target object */
  16247. target: any,
  16248. /** defines the starting frame number (default is 0) */
  16249. fromFrame?: number,
  16250. /** defines the ending frame number (default is 100) */
  16251. toFrame?: number,
  16252. /** defines if the animation must loop (default is false) */
  16253. loopAnimation?: boolean, speedRatio?: number,
  16254. /** defines a callback to call when animation ends if it is not looping */
  16255. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  16256. /** defines a callback to call when animation loops */
  16257. onAnimationLoop?: (() => void) | null | undefined,
  16258. /** defines whether the animation should be evaluated additively */
  16259. isAdditive?: boolean);
  16260. /**
  16261. * Synchronize and normalize current Animatable with a source Animatable
  16262. * This is useful when using animation weights and when animations are not of the same length
  16263. * @param root defines the root Animatable to synchronize with
  16264. * @returns the current Animatable
  16265. */
  16266. syncWith(root: Animatable): Animatable;
  16267. /**
  16268. * Gets the list of runtime animations
  16269. * @returns an array of RuntimeAnimation
  16270. */
  16271. getAnimations(): RuntimeAnimation[];
  16272. /**
  16273. * Adds more animations to the current animatable
  16274. * @param target defines the target of the animations
  16275. * @param animations defines the new animations to add
  16276. */
  16277. appendAnimations(target: any, animations: Animation[]): void;
  16278. /**
  16279. * Gets the source animation for a specific property
  16280. * @param property defines the propertyu to look for
  16281. * @returns null or the source animation for the given property
  16282. */
  16283. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  16284. /**
  16285. * Gets the runtime animation for a specific property
  16286. * @param property defines the propertyu to look for
  16287. * @returns null or the runtime animation for the given property
  16288. */
  16289. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  16290. /**
  16291. * Resets the animatable to its original state
  16292. */
  16293. reset(): void;
  16294. /**
  16295. * Allows the animatable to blend with current running animations
  16296. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16297. * @param blendingSpeed defines the blending speed to use
  16298. */
  16299. enableBlending(blendingSpeed: number): void;
  16300. /**
  16301. * Disable animation blending
  16302. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16303. */
  16304. disableBlending(): void;
  16305. /**
  16306. * Jump directly to a given frame
  16307. * @param frame defines the frame to jump to
  16308. */
  16309. goToFrame(frame: number): void;
  16310. /**
  16311. * Pause the animation
  16312. */
  16313. pause(): void;
  16314. /**
  16315. * Restart the animation
  16316. */
  16317. restart(): void;
  16318. private _raiseOnAnimationEnd;
  16319. /**
  16320. * Stop and delete the current animation
  16321. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  16322. * @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)
  16323. */
  16324. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  16325. /**
  16326. * Wait asynchronously for the animation to end
  16327. * @returns a promise which will be fullfilled when the animation ends
  16328. */
  16329. waitAsync(): Promise<Animatable>;
  16330. /** @hidden */
  16331. _animate(delay: number): boolean;
  16332. }
  16333. module "babylonjs/scene" {
  16334. interface Scene {
  16335. /** @hidden */
  16336. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  16337. /** @hidden */
  16338. _processLateAnimationBindingsForMatrices(holder: {
  16339. totalWeight: number;
  16340. totalAdditiveWeight: number;
  16341. animations: RuntimeAnimation[];
  16342. additiveAnimations: RuntimeAnimation[];
  16343. originalValue: Matrix;
  16344. }): any;
  16345. /** @hidden */
  16346. _processLateAnimationBindingsForQuaternions(holder: {
  16347. totalWeight: number;
  16348. totalAdditiveWeight: number;
  16349. animations: RuntimeAnimation[];
  16350. additiveAnimations: RuntimeAnimation[];
  16351. originalValue: Quaternion;
  16352. }, refQuaternion: Quaternion): Quaternion;
  16353. /** @hidden */
  16354. _processLateAnimationBindings(): void;
  16355. /**
  16356. * Will start the animation sequence of a given target
  16357. * @param target defines the target
  16358. * @param from defines from which frame should animation start
  16359. * @param to defines until which frame should animation run.
  16360. * @param weight defines the weight to apply to the animation (1.0 by default)
  16361. * @param loop defines if the animation loops
  16362. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16363. * @param onAnimationEnd defines the function to be executed when the animation ends
  16364. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16365. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16366. * @param onAnimationLoop defines the callback to call when an animation loops
  16367. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16368. * @returns the animatable object created for this animation
  16369. */
  16370. 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;
  16371. /**
  16372. * Will start the animation sequence of a given target
  16373. * @param target defines the target
  16374. * @param from defines from which frame should animation start
  16375. * @param to defines until which frame should animation run.
  16376. * @param loop defines if the animation loops
  16377. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16378. * @param onAnimationEnd defines the function to be executed when the animation ends
  16379. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16380. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16381. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  16382. * @param onAnimationLoop defines the callback to call when an animation loops
  16383. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16384. * @returns the animatable object created for this animation
  16385. */
  16386. 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;
  16387. /**
  16388. * Will start the animation sequence of a given target and its hierarchy
  16389. * @param target defines the target
  16390. * @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.
  16391. * @param from defines from which frame should animation start
  16392. * @param to defines until which frame should animation run.
  16393. * @param loop defines if the animation loops
  16394. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  16395. * @param onAnimationEnd defines the function to be executed when the animation ends
  16396. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  16397. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  16398. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  16399. * @param onAnimationLoop defines the callback to call when an animation loops
  16400. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16401. * @returns the list of created animatables
  16402. */
  16403. 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[];
  16404. /**
  16405. * Begin a new animation on a given node
  16406. * @param target defines the target where the animation will take place
  16407. * @param animations defines the list of animations to start
  16408. * @param from defines the initial value
  16409. * @param to defines the final value
  16410. * @param loop defines if you want animation to loop (off by default)
  16411. * @param speedRatio defines the speed ratio to apply to all animations
  16412. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16413. * @param onAnimationLoop defines the callback to call when an animation loops
  16414. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16415. * @returns the list of created animatables
  16416. */
  16417. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  16418. /**
  16419. * Begin a new animation on a given node and its hierarchy
  16420. * @param target defines the root node where the animation will take place
  16421. * @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.
  16422. * @param animations defines the list of animations to start
  16423. * @param from defines the initial value
  16424. * @param to defines the final value
  16425. * @param loop defines if you want animation to loop (off by default)
  16426. * @param speedRatio defines the speed ratio to apply to all animations
  16427. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  16428. * @param onAnimationLoop defines the callback to call when an animation loops
  16429. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  16430. * @returns the list of animatables created for all nodes
  16431. */
  16432. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  16433. /**
  16434. * Gets the animatable associated with a specific target
  16435. * @param target defines the target of the animatable
  16436. * @returns the required animatable if found
  16437. */
  16438. getAnimatableByTarget(target: any): Nullable<Animatable>;
  16439. /**
  16440. * Gets all animatables associated with a given target
  16441. * @param target defines the target to look animatables for
  16442. * @returns an array of Animatables
  16443. */
  16444. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  16445. /**
  16446. * Stops and removes all animations that have been applied to the scene
  16447. */
  16448. stopAllAnimations(): void;
  16449. /**
  16450. * Gets the current delta time used by animation engine
  16451. */
  16452. deltaTime: number;
  16453. }
  16454. }
  16455. module "babylonjs/Bones/bone" {
  16456. interface Bone {
  16457. /**
  16458. * Copy an animation range from another bone
  16459. * @param source defines the source bone
  16460. * @param rangeName defines the range name to copy
  16461. * @param frameOffset defines the frame offset
  16462. * @param rescaleAsRequired defines if rescaling must be applied if required
  16463. * @param skelDimensionsRatio defines the scaling ratio
  16464. * @returns true if operation was successful
  16465. */
  16466. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  16467. }
  16468. }
  16469. }
  16470. declare module "babylonjs/Bones/skeleton" {
  16471. import { Bone } from "babylonjs/Bones/bone";
  16472. import { Observable } from "babylonjs/Misc/observable";
  16473. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16474. import { Scene } from "babylonjs/scene";
  16475. import { Nullable } from "babylonjs/types";
  16476. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16477. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  16478. import { Animatable } from "babylonjs/Animations/animatable";
  16479. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  16480. import { Animation } from "babylonjs/Animations/animation";
  16481. import { AnimationRange } from "babylonjs/Animations/animationRange";
  16482. import { IInspectable } from "babylonjs/Misc/iInspectable";
  16483. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  16484. /**
  16485. * Class used to handle skinning animations
  16486. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  16487. */
  16488. export class Skeleton implements IAnimatable {
  16489. /** defines the skeleton name */
  16490. name: string;
  16491. /** defines the skeleton Id */
  16492. id: string;
  16493. /**
  16494. * Defines the list of child bones
  16495. */
  16496. bones: Bone[];
  16497. /**
  16498. * Defines an estimate of the dimension of the skeleton at rest
  16499. */
  16500. dimensionsAtRest: Vector3;
  16501. /**
  16502. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  16503. */
  16504. needInitialSkinMatrix: boolean;
  16505. /**
  16506. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  16507. */
  16508. overrideMesh: Nullable<AbstractMesh>;
  16509. /**
  16510. * Gets the list of animations attached to this skeleton
  16511. */
  16512. animations: Array<Animation>;
  16513. private _scene;
  16514. private _isDirty;
  16515. private _transformMatrices;
  16516. private _transformMatrixTexture;
  16517. private _meshesWithPoseMatrix;
  16518. private _animatables;
  16519. private _identity;
  16520. private _synchronizedWithMesh;
  16521. private _ranges;
  16522. private _lastAbsoluteTransformsUpdateId;
  16523. private _canUseTextureForBones;
  16524. private _uniqueId;
  16525. /** @hidden */
  16526. _numBonesWithLinkedTransformNode: number;
  16527. /** @hidden */
  16528. _hasWaitingData: Nullable<boolean>;
  16529. /** @hidden */
  16530. _waitingOverrideMeshId: Nullable<string>;
  16531. /**
  16532. * Specifies if the skeleton should be serialized
  16533. */
  16534. doNotSerialize: boolean;
  16535. private _useTextureToStoreBoneMatrices;
  16536. /**
  16537. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  16538. * Please note that this option is not available if the hardware does not support it
  16539. */
  16540. get useTextureToStoreBoneMatrices(): boolean;
  16541. set useTextureToStoreBoneMatrices(value: boolean);
  16542. private _animationPropertiesOverride;
  16543. /**
  16544. * Gets or sets the animation properties override
  16545. */
  16546. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  16547. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  16548. /**
  16549. * List of inspectable custom properties (used by the Inspector)
  16550. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  16551. */
  16552. inspectableCustomProperties: IInspectable[];
  16553. /**
  16554. * An observable triggered before computing the skeleton's matrices
  16555. */
  16556. onBeforeComputeObservable: Observable<Skeleton>;
  16557. /**
  16558. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  16559. */
  16560. get isUsingTextureForMatrices(): boolean;
  16561. /**
  16562. * Gets the unique ID of this skeleton
  16563. */
  16564. get uniqueId(): number;
  16565. /**
  16566. * Creates a new skeleton
  16567. * @param name defines the skeleton name
  16568. * @param id defines the skeleton Id
  16569. * @param scene defines the hosting scene
  16570. */
  16571. constructor(
  16572. /** defines the skeleton name */
  16573. name: string,
  16574. /** defines the skeleton Id */
  16575. id: string, scene: Scene);
  16576. /**
  16577. * Gets the current object class name.
  16578. * @return the class name
  16579. */
  16580. getClassName(): string;
  16581. /**
  16582. * Returns an array containing the root bones
  16583. * @returns an array containing the root bones
  16584. */
  16585. getChildren(): Array<Bone>;
  16586. /**
  16587. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  16588. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16589. * @returns a Float32Array containing matrices data
  16590. */
  16591. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  16592. /**
  16593. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  16594. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  16595. * @returns a raw texture containing the data
  16596. */
  16597. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  16598. /**
  16599. * Gets the current hosting scene
  16600. * @returns a scene object
  16601. */
  16602. getScene(): Scene;
  16603. /**
  16604. * Gets a string representing the current skeleton data
  16605. * @param fullDetails defines a boolean indicating if we want a verbose version
  16606. * @returns a string representing the current skeleton data
  16607. */
  16608. toString(fullDetails?: boolean): string;
  16609. /**
  16610. * Get bone's index searching by name
  16611. * @param name defines bone's name to search for
  16612. * @return the indice of the bone. Returns -1 if not found
  16613. */
  16614. getBoneIndexByName(name: string): number;
  16615. /**
  16616. * Creater a new animation range
  16617. * @param name defines the name of the range
  16618. * @param from defines the start key
  16619. * @param to defines the end key
  16620. */
  16621. createAnimationRange(name: string, from: number, to: number): void;
  16622. /**
  16623. * Delete a specific animation range
  16624. * @param name defines the name of the range
  16625. * @param deleteFrames defines if frames must be removed as well
  16626. */
  16627. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  16628. /**
  16629. * Gets a specific animation range
  16630. * @param name defines the name of the range to look for
  16631. * @returns the requested animation range or null if not found
  16632. */
  16633. getAnimationRange(name: string): Nullable<AnimationRange>;
  16634. /**
  16635. * Gets the list of all animation ranges defined on this skeleton
  16636. * @returns an array
  16637. */
  16638. getAnimationRanges(): Nullable<AnimationRange>[];
  16639. /**
  16640. * Copy animation range from a source skeleton.
  16641. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  16642. * @param source defines the source skeleton
  16643. * @param name defines the name of the range to copy
  16644. * @param rescaleAsRequired defines if rescaling must be applied if required
  16645. * @returns true if operation was successful
  16646. */
  16647. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  16648. /**
  16649. * Forces the skeleton to go to rest pose
  16650. */
  16651. returnToRest(): void;
  16652. private _getHighestAnimationFrame;
  16653. /**
  16654. * Begin a specific animation range
  16655. * @param name defines the name of the range to start
  16656. * @param loop defines if looping must be turned on (false by default)
  16657. * @param speedRatio defines the speed ratio to apply (1 by default)
  16658. * @param onAnimationEnd defines a callback which will be called when animation will end
  16659. * @returns a new animatable
  16660. */
  16661. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  16662. /**
  16663. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  16664. * @param skeleton defines the Skeleton containing the animation range to convert
  16665. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  16666. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  16667. * @returns the original skeleton
  16668. */
  16669. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  16670. /** @hidden */
  16671. _markAsDirty(): void;
  16672. /** @hidden */
  16673. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16674. /** @hidden */
  16675. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  16676. private _computeTransformMatrices;
  16677. /**
  16678. * Build all resources required to render a skeleton
  16679. */
  16680. prepare(): void;
  16681. /**
  16682. * Gets the list of animatables currently running for this skeleton
  16683. * @returns an array of animatables
  16684. */
  16685. getAnimatables(): IAnimatable[];
  16686. /**
  16687. * Clone the current skeleton
  16688. * @param name defines the name of the new skeleton
  16689. * @param id defines the id of the new skeleton
  16690. * @returns the new skeleton
  16691. */
  16692. clone(name: string, id?: string): Skeleton;
  16693. /**
  16694. * Enable animation blending for this skeleton
  16695. * @param blendingSpeed defines the blending speed to apply
  16696. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  16697. */
  16698. enableBlending(blendingSpeed?: number): void;
  16699. /**
  16700. * Releases all resources associated with the current skeleton
  16701. */
  16702. dispose(): void;
  16703. /**
  16704. * Serialize the skeleton in a JSON object
  16705. * @returns a JSON object
  16706. */
  16707. serialize(): any;
  16708. /**
  16709. * Creates a new skeleton from serialized data
  16710. * @param parsedSkeleton defines the serialized data
  16711. * @param scene defines the hosting scene
  16712. * @returns a new skeleton
  16713. */
  16714. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  16715. /**
  16716. * Compute all node absolute transforms
  16717. * @param forceUpdate defines if computation must be done even if cache is up to date
  16718. */
  16719. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  16720. /**
  16721. * Gets the root pose matrix
  16722. * @returns a matrix
  16723. */
  16724. getPoseMatrix(): Nullable<Matrix>;
  16725. /**
  16726. * Sorts bones per internal index
  16727. */
  16728. sortBones(): void;
  16729. private _sortBones;
  16730. /**
  16731. * Set the current local matrix as the restPose for all bones in the skeleton.
  16732. */
  16733. setCurrentPoseAsRest(): void;
  16734. }
  16735. }
  16736. declare module "babylonjs/Meshes/instancedMesh" {
  16737. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  16738. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  16739. import { Camera } from "babylonjs/Cameras/camera";
  16740. import { Node } from "babylonjs/node";
  16741. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16742. import { Mesh } from "babylonjs/Meshes/mesh";
  16743. import { Material } from "babylonjs/Materials/material";
  16744. import { Skeleton } from "babylonjs/Bones/skeleton";
  16745. import { Light } from "babylonjs/Lights/light";
  16746. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  16747. /**
  16748. * Creates an instance based on a source mesh.
  16749. */
  16750. export class InstancedMesh extends AbstractMesh {
  16751. private _sourceMesh;
  16752. private _currentLOD;
  16753. /** @hidden */
  16754. _indexInSourceMeshInstanceArray: number;
  16755. constructor(name: string, source: Mesh);
  16756. /**
  16757. * Returns the string "InstancedMesh".
  16758. */
  16759. getClassName(): string;
  16760. /** Gets the list of lights affecting that mesh */
  16761. get lightSources(): Light[];
  16762. _resyncLightSources(): void;
  16763. _resyncLightSource(light: Light): void;
  16764. _removeLightSource(light: Light, dispose: boolean): void;
  16765. /**
  16766. * If the source mesh receives shadows
  16767. */
  16768. get receiveShadows(): boolean;
  16769. /**
  16770. * The material of the source mesh
  16771. */
  16772. get material(): Nullable<Material>;
  16773. /**
  16774. * Visibility of the source mesh
  16775. */
  16776. get visibility(): number;
  16777. /**
  16778. * Skeleton of the source mesh
  16779. */
  16780. get skeleton(): Nullable<Skeleton>;
  16781. /**
  16782. * Rendering ground id of the source mesh
  16783. */
  16784. get renderingGroupId(): number;
  16785. set renderingGroupId(value: number);
  16786. /**
  16787. * Returns the total number of vertices (integer).
  16788. */
  16789. getTotalVertices(): number;
  16790. /**
  16791. * Returns a positive integer : the total number of indices in this mesh geometry.
  16792. * @returns the numner of indices or zero if the mesh has no geometry.
  16793. */
  16794. getTotalIndices(): number;
  16795. /**
  16796. * The source mesh of the instance
  16797. */
  16798. get sourceMesh(): Mesh;
  16799. /**
  16800. * Creates a new InstancedMesh object from the mesh model.
  16801. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  16802. * @param name defines the name of the new instance
  16803. * @returns a new InstancedMesh
  16804. */
  16805. createInstance(name: string): InstancedMesh;
  16806. /**
  16807. * Is this node ready to be used/rendered
  16808. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  16809. * @return {boolean} is it ready
  16810. */
  16811. isReady(completeCheck?: boolean): boolean;
  16812. /**
  16813. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  16814. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  16815. * @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.
  16816. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  16817. */
  16818. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  16819. /**
  16820. * Sets the vertex data of the mesh geometry for the requested `kind`.
  16821. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  16822. * The `data` are either a numeric array either a Float32Array.
  16823. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  16824. * 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).
  16825. * Note that a new underlying VertexBuffer object is created each call.
  16826. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  16827. *
  16828. * Possible `kind` values :
  16829. * - VertexBuffer.PositionKind
  16830. * - VertexBuffer.UVKind
  16831. * - VertexBuffer.UV2Kind
  16832. * - VertexBuffer.UV3Kind
  16833. * - VertexBuffer.UV4Kind
  16834. * - VertexBuffer.UV5Kind
  16835. * - VertexBuffer.UV6Kind
  16836. * - VertexBuffer.ColorKind
  16837. * - VertexBuffer.MatricesIndicesKind
  16838. * - VertexBuffer.MatricesIndicesExtraKind
  16839. * - VertexBuffer.MatricesWeightsKind
  16840. * - VertexBuffer.MatricesWeightsExtraKind
  16841. *
  16842. * Returns the Mesh.
  16843. */
  16844. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  16845. /**
  16846. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  16847. * If the mesh has no geometry, it is simply returned as it is.
  16848. * The `data` are either a numeric array either a Float32Array.
  16849. * No new underlying VertexBuffer object is created.
  16850. * 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.
  16851. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  16852. *
  16853. * Possible `kind` values :
  16854. * - VertexBuffer.PositionKind
  16855. * - VertexBuffer.UVKind
  16856. * - VertexBuffer.UV2Kind
  16857. * - VertexBuffer.UV3Kind
  16858. * - VertexBuffer.UV4Kind
  16859. * - VertexBuffer.UV5Kind
  16860. * - VertexBuffer.UV6Kind
  16861. * - VertexBuffer.ColorKind
  16862. * - VertexBuffer.MatricesIndicesKind
  16863. * - VertexBuffer.MatricesIndicesExtraKind
  16864. * - VertexBuffer.MatricesWeightsKind
  16865. * - VertexBuffer.MatricesWeightsExtraKind
  16866. *
  16867. * Returns the Mesh.
  16868. */
  16869. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  16870. /**
  16871. * Sets the mesh indices.
  16872. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  16873. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  16874. * This method creates a new index buffer each call.
  16875. * Returns the Mesh.
  16876. */
  16877. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  16878. /**
  16879. * Boolean : True if the mesh owns the requested kind of data.
  16880. */
  16881. isVerticesDataPresent(kind: string): boolean;
  16882. /**
  16883. * Returns an array of indices (IndicesArray).
  16884. */
  16885. getIndices(): Nullable<IndicesArray>;
  16886. get _positions(): Nullable<Vector3[]>;
  16887. /**
  16888. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  16889. * This means the mesh underlying bounding box and sphere are recomputed.
  16890. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  16891. * @returns the current mesh
  16892. */
  16893. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  16894. /** @hidden */
  16895. _preActivate(): InstancedMesh;
  16896. /** @hidden */
  16897. _activate(renderId: number, intermediateRendering: boolean): boolean;
  16898. /** @hidden */
  16899. _postActivate(): void;
  16900. getWorldMatrix(): Matrix;
  16901. get isAnInstance(): boolean;
  16902. /**
  16903. * Returns the current associated LOD AbstractMesh.
  16904. */
  16905. getLOD(camera: Camera): AbstractMesh;
  16906. /** @hidden */
  16907. _preActivateForIntermediateRendering(renderId: number): Mesh;
  16908. /** @hidden */
  16909. _syncSubMeshes(): InstancedMesh;
  16910. /** @hidden */
  16911. _generatePointsArray(): boolean;
  16912. /** @hidden */
  16913. _updateBoundingInfo(): AbstractMesh;
  16914. /**
  16915. * Creates a new InstancedMesh from the current mesh.
  16916. * - name (string) : the cloned mesh name
  16917. * - newParent (optional Node) : the optional Node to parent the clone to.
  16918. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  16919. *
  16920. * Returns the clone.
  16921. */
  16922. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  16923. /**
  16924. * Disposes the InstancedMesh.
  16925. * Returns nothing.
  16926. */
  16927. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  16928. }
  16929. module "babylonjs/Meshes/mesh" {
  16930. interface Mesh {
  16931. /**
  16932. * Register a custom buffer that will be instanced
  16933. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16934. * @param kind defines the buffer kind
  16935. * @param stride defines the stride in floats
  16936. */
  16937. registerInstancedBuffer(kind: string, stride: number): void;
  16938. /**
  16939. * true to use the edge renderer for all instances of this mesh
  16940. */
  16941. edgesShareWithInstances: boolean;
  16942. /** @hidden */
  16943. _userInstancedBuffersStorage: {
  16944. data: {
  16945. [key: string]: Float32Array;
  16946. };
  16947. sizes: {
  16948. [key: string]: number;
  16949. };
  16950. vertexBuffers: {
  16951. [key: string]: Nullable<VertexBuffer>;
  16952. };
  16953. strides: {
  16954. [key: string]: number;
  16955. };
  16956. };
  16957. }
  16958. }
  16959. module "babylonjs/Meshes/abstractMesh" {
  16960. interface AbstractMesh {
  16961. /**
  16962. * Object used to store instanced buffers defined by user
  16963. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  16964. */
  16965. instancedBuffers: {
  16966. [key: string]: any;
  16967. };
  16968. }
  16969. }
  16970. }
  16971. declare module "babylonjs/Materials/shaderMaterial" {
  16972. import { Nullable } from "babylonjs/types";
  16973. import { Scene } from "babylonjs/scene";
  16974. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  16975. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  16976. import { Mesh } from "babylonjs/Meshes/mesh";
  16977. import { SubMesh } from "babylonjs/Meshes/subMesh";
  16978. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  16979. import { Effect } from "babylonjs/Materials/effect";
  16980. import { Material } from "babylonjs/Materials/material";
  16981. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  16982. /**
  16983. * Defines the options associated with the creation of a shader material.
  16984. */
  16985. export interface IShaderMaterialOptions {
  16986. /**
  16987. * Does the material work in alpha blend mode
  16988. */
  16989. needAlphaBlending: boolean;
  16990. /**
  16991. * Does the material work in alpha test mode
  16992. */
  16993. needAlphaTesting: boolean;
  16994. /**
  16995. * The list of attribute names used in the shader
  16996. */
  16997. attributes: string[];
  16998. /**
  16999. * The list of unifrom names used in the shader
  17000. */
  17001. uniforms: string[];
  17002. /**
  17003. * The list of UBO names used in the shader
  17004. */
  17005. uniformBuffers: string[];
  17006. /**
  17007. * The list of sampler names used in the shader
  17008. */
  17009. samplers: string[];
  17010. /**
  17011. * The list of defines used in the shader
  17012. */
  17013. defines: string[];
  17014. }
  17015. /**
  17016. * 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.
  17017. *
  17018. * This returned material effects how the mesh will look based on the code in the shaders.
  17019. *
  17020. * @see https://doc.babylonjs.com/how_to/shader_material
  17021. */
  17022. export class ShaderMaterial extends Material {
  17023. private _shaderPath;
  17024. private _options;
  17025. private _textures;
  17026. private _textureArrays;
  17027. private _floats;
  17028. private _ints;
  17029. private _floatsArrays;
  17030. private _colors3;
  17031. private _colors3Arrays;
  17032. private _colors4;
  17033. private _colors4Arrays;
  17034. private _vectors2;
  17035. private _vectors3;
  17036. private _vectors4;
  17037. private _matrices;
  17038. private _matrixArrays;
  17039. private _matrices3x3;
  17040. private _matrices2x2;
  17041. private _vectors2Arrays;
  17042. private _vectors3Arrays;
  17043. private _vectors4Arrays;
  17044. private _cachedWorldViewMatrix;
  17045. private _cachedWorldViewProjectionMatrix;
  17046. private _renderId;
  17047. private _multiview;
  17048. private _cachedDefines;
  17049. /** Define the Url to load snippets */
  17050. static SnippetUrl: string;
  17051. /** Snippet ID if the material was created from the snippet server */
  17052. snippetId: string;
  17053. /**
  17054. * Instantiate a new shader material.
  17055. * 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.
  17056. * This returned material effects how the mesh will look based on the code in the shaders.
  17057. * @see https://doc.babylonjs.com/how_to/shader_material
  17058. * @param name Define the name of the material in the scene
  17059. * @param scene Define the scene the material belongs to
  17060. * @param shaderPath Defines the route to the shader code in one of three ways:
  17061. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  17062. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  17063. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  17064. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  17065. * @param options Define the options used to create the shader
  17066. */
  17067. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  17068. /**
  17069. * Gets the shader path used to define the shader code
  17070. * It can be modified to trigger a new compilation
  17071. */
  17072. get shaderPath(): any;
  17073. /**
  17074. * Sets the shader path used to define the shader code
  17075. * It can be modified to trigger a new compilation
  17076. */
  17077. set shaderPath(shaderPath: any);
  17078. /**
  17079. * Gets the options used to compile the shader.
  17080. * They can be modified to trigger a new compilation
  17081. */
  17082. get options(): IShaderMaterialOptions;
  17083. /**
  17084. * Gets the current class name of the material e.g. "ShaderMaterial"
  17085. * Mainly use in serialization.
  17086. * @returns the class name
  17087. */
  17088. getClassName(): string;
  17089. /**
  17090. * Specifies if the material will require alpha blending
  17091. * @returns a boolean specifying if alpha blending is needed
  17092. */
  17093. needAlphaBlending(): boolean;
  17094. /**
  17095. * Specifies if this material should be rendered in alpha test mode
  17096. * @returns a boolean specifying if an alpha test is needed.
  17097. */
  17098. needAlphaTesting(): boolean;
  17099. private _checkUniform;
  17100. /**
  17101. * Set a texture in the shader.
  17102. * @param name Define the name of the uniform samplers as defined in the shader
  17103. * @param texture Define the texture to bind to this sampler
  17104. * @return the material itself allowing "fluent" like uniform updates
  17105. */
  17106. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  17107. /**
  17108. * Set a texture array in the shader.
  17109. * @param name Define the name of the uniform sampler array as defined in the shader
  17110. * @param textures Define the list of textures to bind to this sampler
  17111. * @return the material itself allowing "fluent" like uniform updates
  17112. */
  17113. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  17114. /**
  17115. * Set a float in the shader.
  17116. * @param name Define the name of the uniform as defined in the shader
  17117. * @param value Define the value to give to the uniform
  17118. * @return the material itself allowing "fluent" like uniform updates
  17119. */
  17120. setFloat(name: string, value: number): ShaderMaterial;
  17121. /**
  17122. * Set a int in the shader.
  17123. * @param name Define the name of the uniform as defined in the shader
  17124. * @param value Define the value to give to the uniform
  17125. * @return the material itself allowing "fluent" like uniform updates
  17126. */
  17127. setInt(name: string, value: number): ShaderMaterial;
  17128. /**
  17129. * Set an array of floats in the shader.
  17130. * @param name Define the name of the uniform as defined in the shader
  17131. * @param value Define the value to give to the uniform
  17132. * @return the material itself allowing "fluent" like uniform updates
  17133. */
  17134. setFloats(name: string, value: number[]): ShaderMaterial;
  17135. /**
  17136. * Set a vec3 in the shader from a Color3.
  17137. * @param name Define the name of the uniform as defined in the shader
  17138. * @param value Define the value to give to the uniform
  17139. * @return the material itself allowing "fluent" like uniform updates
  17140. */
  17141. setColor3(name: string, value: Color3): ShaderMaterial;
  17142. /**
  17143. * Set a vec3 array in the shader from a Color3 array.
  17144. * @param name Define the name of the uniform as defined in the shader
  17145. * @param value Define the value to give to the uniform
  17146. * @return the material itself allowing "fluent" like uniform updates
  17147. */
  17148. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  17149. /**
  17150. * Set a vec4 in the shader from a Color4.
  17151. * @param name Define the name of the uniform as defined in the shader
  17152. * @param value Define the value to give to the uniform
  17153. * @return the material itself allowing "fluent" like uniform updates
  17154. */
  17155. setColor4(name: string, value: Color4): ShaderMaterial;
  17156. /**
  17157. * Set a vec4 array in the shader from a Color4 array.
  17158. * @param name Define the name of the uniform as defined in the shader
  17159. * @param value Define the value to give to the uniform
  17160. * @return the material itself allowing "fluent" like uniform updates
  17161. */
  17162. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  17163. /**
  17164. * Set a vec2 in the shader from a Vector2.
  17165. * @param name Define the name of the uniform as defined in the shader
  17166. * @param value Define the value to give to the uniform
  17167. * @return the material itself allowing "fluent" like uniform updates
  17168. */
  17169. setVector2(name: string, value: Vector2): ShaderMaterial;
  17170. /**
  17171. * Set a vec3 in the shader from a Vector3.
  17172. * @param name Define the name of the uniform as defined in the shader
  17173. * @param value Define the value to give to the uniform
  17174. * @return the material itself allowing "fluent" like uniform updates
  17175. */
  17176. setVector3(name: string, value: Vector3): ShaderMaterial;
  17177. /**
  17178. * Set a vec4 in the shader from a Vector4.
  17179. * @param name Define the name of the uniform as defined in the shader
  17180. * @param value Define the value to give to the uniform
  17181. * @return the material itself allowing "fluent" like uniform updates
  17182. */
  17183. setVector4(name: string, value: Vector4): ShaderMaterial;
  17184. /**
  17185. * Set a mat4 in the shader from a Matrix.
  17186. * @param name Define the name of the uniform as defined in the shader
  17187. * @param value Define the value to give to the uniform
  17188. * @return the material itself allowing "fluent" like uniform updates
  17189. */
  17190. setMatrix(name: string, value: Matrix): ShaderMaterial;
  17191. /**
  17192. * Set a float32Array in the shader from a matrix array.
  17193. * @param name Define the name of the uniform as defined in the shader
  17194. * @param value Define the value to give to the uniform
  17195. * @return the material itself allowing "fluent" like uniform updates
  17196. */
  17197. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  17198. /**
  17199. * Set a mat3 in the shader from a Float32Array.
  17200. * @param name Define the name of the uniform as defined in the shader
  17201. * @param value Define the value to give to the uniform
  17202. * @return the material itself allowing "fluent" like uniform updates
  17203. */
  17204. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17205. /**
  17206. * Set a mat2 in the shader from a Float32Array.
  17207. * @param name Define the name of the uniform as defined in the shader
  17208. * @param value Define the value to give to the uniform
  17209. * @return the material itself allowing "fluent" like uniform updates
  17210. */
  17211. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  17212. /**
  17213. * Set a vec2 array in the shader from a number array.
  17214. * @param name Define the name of the uniform as defined in the shader
  17215. * @param value Define the value to give to the uniform
  17216. * @return the material itself allowing "fluent" like uniform updates
  17217. */
  17218. setArray2(name: string, value: number[]): ShaderMaterial;
  17219. /**
  17220. * Set a vec3 array in the shader from a number array.
  17221. * @param name Define the name of the uniform as defined in the shader
  17222. * @param value Define the value to give to the uniform
  17223. * @return the material itself allowing "fluent" like uniform updates
  17224. */
  17225. setArray3(name: string, value: number[]): ShaderMaterial;
  17226. /**
  17227. * Set a vec4 array in the shader from a number array.
  17228. * @param name Define the name of the uniform as defined in the shader
  17229. * @param value Define the value to give to the uniform
  17230. * @return the material itself allowing "fluent" like uniform updates
  17231. */
  17232. setArray4(name: string, value: number[]): ShaderMaterial;
  17233. private _checkCache;
  17234. /**
  17235. * Specifies that the submesh is ready to be used
  17236. * @param mesh defines the mesh to check
  17237. * @param subMesh defines which submesh to check
  17238. * @param useInstances specifies that instances should be used
  17239. * @returns a boolean indicating that the submesh is ready or not
  17240. */
  17241. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  17242. /**
  17243. * Checks if the material is ready to render the requested mesh
  17244. * @param mesh Define the mesh to render
  17245. * @param useInstances Define whether or not the material is used with instances
  17246. * @returns true if ready, otherwise false
  17247. */
  17248. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  17249. /**
  17250. * Binds the world matrix to the material
  17251. * @param world defines the world transformation matrix
  17252. * @param effectOverride - If provided, use this effect instead of internal effect
  17253. */
  17254. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  17255. /**
  17256. * Binds the submesh to this material by preparing the effect and shader to draw
  17257. * @param world defines the world transformation matrix
  17258. * @param mesh defines the mesh containing the submesh
  17259. * @param subMesh defines the submesh to bind the material to
  17260. */
  17261. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  17262. /**
  17263. * Binds the material to the mesh
  17264. * @param world defines the world transformation matrix
  17265. * @param mesh defines the mesh to bind the material to
  17266. * @param effectOverride - If provided, use this effect instead of internal effect
  17267. */
  17268. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  17269. protected _afterBind(mesh?: Mesh): void;
  17270. /**
  17271. * Gets the active textures from the material
  17272. * @returns an array of textures
  17273. */
  17274. getActiveTextures(): BaseTexture[];
  17275. /**
  17276. * Specifies if the material uses a texture
  17277. * @param texture defines the texture to check against the material
  17278. * @returns a boolean specifying if the material uses the texture
  17279. */
  17280. hasTexture(texture: BaseTexture): boolean;
  17281. /**
  17282. * Makes a duplicate of the material, and gives it a new name
  17283. * @param name defines the new name for the duplicated material
  17284. * @returns the cloned material
  17285. */
  17286. clone(name: string): ShaderMaterial;
  17287. /**
  17288. * Disposes the material
  17289. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  17290. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  17291. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  17292. */
  17293. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  17294. /**
  17295. * Serializes this material in a JSON representation
  17296. * @returns the serialized material object
  17297. */
  17298. serialize(): any;
  17299. /**
  17300. * Creates a shader material from parsed shader material data
  17301. * @param source defines the JSON represnetation of the material
  17302. * @param scene defines the hosting scene
  17303. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17304. * @returns a new material
  17305. */
  17306. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  17307. /**
  17308. * Creates a new ShaderMaterial from a snippet saved in a remote file
  17309. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  17310. * @param url defines the url to load from
  17311. * @param scene defines the hosting scene
  17312. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17313. * @returns a promise that will resolve to the new ShaderMaterial
  17314. */
  17315. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17316. /**
  17317. * Creates a ShaderMaterial from a snippet saved by the Inspector
  17318. * @param snippetId defines the snippet to load
  17319. * @param scene defines the hosting scene
  17320. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  17321. * @returns a promise that will resolve to the new ShaderMaterial
  17322. */
  17323. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  17324. }
  17325. }
  17326. declare module "babylonjs/Shaders/color.fragment" {
  17327. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  17328. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  17329. /** @hidden */
  17330. export var colorPixelShader: {
  17331. name: string;
  17332. shader: string;
  17333. };
  17334. }
  17335. declare module "babylonjs/Shaders/color.vertex" {
  17336. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  17337. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  17338. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17339. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17340. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  17341. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  17342. /** @hidden */
  17343. export var colorVertexShader: {
  17344. name: string;
  17345. shader: string;
  17346. };
  17347. }
  17348. declare module "babylonjs/Meshes/linesMesh" {
  17349. import { Nullable } from "babylonjs/types";
  17350. import { Scene } from "babylonjs/scene";
  17351. import { Color3 } from "babylonjs/Maths/math.color";
  17352. import { Node } from "babylonjs/node";
  17353. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17354. import { Mesh } from "babylonjs/Meshes/mesh";
  17355. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  17356. import { Effect } from "babylonjs/Materials/effect";
  17357. import { Material } from "babylonjs/Materials/material";
  17358. import "babylonjs/Shaders/color.fragment";
  17359. import "babylonjs/Shaders/color.vertex";
  17360. /**
  17361. * Line mesh
  17362. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  17363. */
  17364. export class LinesMesh extends Mesh {
  17365. /**
  17366. * If vertex color should be applied to the mesh
  17367. */
  17368. readonly useVertexColor?: boolean | undefined;
  17369. /**
  17370. * If vertex alpha should be applied to the mesh
  17371. */
  17372. readonly useVertexAlpha?: boolean | undefined;
  17373. /**
  17374. * Color of the line (Default: White)
  17375. */
  17376. color: Color3;
  17377. /**
  17378. * Alpha of the line (Default: 1)
  17379. */
  17380. alpha: number;
  17381. /**
  17382. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17383. * This margin is expressed in world space coordinates, so its value may vary.
  17384. * Default value is 0.1
  17385. */
  17386. intersectionThreshold: number;
  17387. private _colorShader;
  17388. private color4;
  17389. /**
  17390. * Creates a new LinesMesh
  17391. * @param name defines the name
  17392. * @param scene defines the hosting scene
  17393. * @param parent defines the parent mesh if any
  17394. * @param source defines the optional source LinesMesh used to clone data from
  17395. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  17396. * When false, achieved by calling a clone(), also passing False.
  17397. * This will make creation of children, recursive.
  17398. * @param useVertexColor defines if this LinesMesh supports vertex color
  17399. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  17400. */
  17401. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  17402. /**
  17403. * If vertex color should be applied to the mesh
  17404. */
  17405. useVertexColor?: boolean | undefined,
  17406. /**
  17407. * If vertex alpha should be applied to the mesh
  17408. */
  17409. useVertexAlpha?: boolean | undefined);
  17410. private _addClipPlaneDefine;
  17411. private _removeClipPlaneDefine;
  17412. isReady(): boolean;
  17413. /**
  17414. * Returns the string "LineMesh"
  17415. */
  17416. getClassName(): string;
  17417. /**
  17418. * @hidden
  17419. */
  17420. get material(): Material;
  17421. /**
  17422. * @hidden
  17423. */
  17424. set material(value: Material);
  17425. /**
  17426. * @hidden
  17427. */
  17428. get checkCollisions(): boolean;
  17429. /** @hidden */
  17430. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  17431. /** @hidden */
  17432. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  17433. /**
  17434. * Disposes of the line mesh
  17435. * @param doNotRecurse If children should be disposed
  17436. */
  17437. dispose(doNotRecurse?: boolean): void;
  17438. /**
  17439. * Returns a new LineMesh object cloned from the current one.
  17440. */
  17441. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  17442. /**
  17443. * Creates a new InstancedLinesMesh object from the mesh model.
  17444. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  17445. * @param name defines the name of the new instance
  17446. * @returns a new InstancedLinesMesh
  17447. */
  17448. createInstance(name: string): InstancedLinesMesh;
  17449. }
  17450. /**
  17451. * Creates an instance based on a source LinesMesh
  17452. */
  17453. export class InstancedLinesMesh extends InstancedMesh {
  17454. /**
  17455. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  17456. * This margin is expressed in world space coordinates, so its value may vary.
  17457. * Initilized with the intersectionThreshold value of the source LinesMesh
  17458. */
  17459. intersectionThreshold: number;
  17460. constructor(name: string, source: LinesMesh);
  17461. /**
  17462. * Returns the string "InstancedLinesMesh".
  17463. */
  17464. getClassName(): string;
  17465. }
  17466. }
  17467. declare module "babylonjs/Shaders/line.fragment" {
  17468. /** @hidden */
  17469. export var linePixelShader: {
  17470. name: string;
  17471. shader: string;
  17472. };
  17473. }
  17474. declare module "babylonjs/Shaders/line.vertex" {
  17475. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  17476. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  17477. /** @hidden */
  17478. export var lineVertexShader: {
  17479. name: string;
  17480. shader: string;
  17481. };
  17482. }
  17483. declare module "babylonjs/Rendering/edgesRenderer" {
  17484. import { Nullable } from "babylonjs/types";
  17485. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  17486. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17487. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  17488. import { IDisposable } from "babylonjs/scene";
  17489. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  17490. import "babylonjs/Shaders/line.fragment";
  17491. import "babylonjs/Shaders/line.vertex";
  17492. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  17493. import { SmartArray } from "babylonjs/Misc/smartArray";
  17494. module "babylonjs/scene" {
  17495. interface Scene {
  17496. /** @hidden */
  17497. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  17498. }
  17499. }
  17500. module "babylonjs/Meshes/abstractMesh" {
  17501. interface AbstractMesh {
  17502. /**
  17503. * Gets the edgesRenderer associated with the mesh
  17504. */
  17505. edgesRenderer: Nullable<EdgesRenderer>;
  17506. }
  17507. }
  17508. module "babylonjs/Meshes/linesMesh" {
  17509. interface LinesMesh {
  17510. /**
  17511. * Enables the edge rendering mode on the mesh.
  17512. * This mode makes the mesh edges visible
  17513. * @param epsilon defines the maximal distance between two angles to detect a face
  17514. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17515. * @returns the currentAbstractMesh
  17516. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17517. */
  17518. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  17519. }
  17520. }
  17521. module "babylonjs/Meshes/linesMesh" {
  17522. interface InstancedLinesMesh {
  17523. /**
  17524. * Enables the edge rendering mode on the mesh.
  17525. * This mode makes the mesh edges visible
  17526. * @param epsilon defines the maximal distance between two angles to detect a face
  17527. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  17528. * @returns the current InstancedLinesMesh
  17529. * @see https://www.babylonjs-playground.com/#19O9TU#0
  17530. */
  17531. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  17532. }
  17533. }
  17534. /**
  17535. * Defines the minimum contract an Edges renderer should follow.
  17536. */
  17537. export interface IEdgesRenderer extends IDisposable {
  17538. /**
  17539. * Gets or sets a boolean indicating if the edgesRenderer is active
  17540. */
  17541. isEnabled: boolean;
  17542. /**
  17543. * Renders the edges of the attached mesh,
  17544. */
  17545. render(): void;
  17546. /**
  17547. * Checks wether or not the edges renderer is ready to render.
  17548. * @return true if ready, otherwise false.
  17549. */
  17550. isReady(): boolean;
  17551. /**
  17552. * List of instances to render in case the source mesh has instances
  17553. */
  17554. customInstances: SmartArray<Matrix>;
  17555. }
  17556. /**
  17557. * Defines the additional options of the edges renderer
  17558. */
  17559. export interface IEdgesRendererOptions {
  17560. /**
  17561. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  17562. * If not defined, the default value is true
  17563. */
  17564. useAlternateEdgeFinder?: boolean;
  17565. /**
  17566. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  17567. * If not defined, the default value is true.
  17568. * 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)
  17569. * This option is used only if useAlternateEdgeFinder = true
  17570. */
  17571. useFastVertexMerger?: boolean;
  17572. /**
  17573. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  17574. * The default value is 1e-6
  17575. * This option is used only if useAlternateEdgeFinder = true
  17576. */
  17577. epsilonVertexMerge?: number;
  17578. /**
  17579. * 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
  17580. * 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.
  17581. * This option is used only if useAlternateEdgeFinder = true
  17582. */
  17583. applyTessellation?: boolean;
  17584. /**
  17585. * 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
  17586. * The default value is 1e-6
  17587. * This option is used only if useAlternateEdgeFinder = true
  17588. */
  17589. epsilonVertexAligned?: number;
  17590. }
  17591. /**
  17592. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  17593. */
  17594. export class EdgesRenderer implements IEdgesRenderer {
  17595. /**
  17596. * Define the size of the edges with an orthographic camera
  17597. */
  17598. edgesWidthScalerForOrthographic: number;
  17599. /**
  17600. * Define the size of the edges with a perspective camera
  17601. */
  17602. edgesWidthScalerForPerspective: number;
  17603. protected _source: AbstractMesh;
  17604. protected _linesPositions: number[];
  17605. protected _linesNormals: number[];
  17606. protected _linesIndices: number[];
  17607. protected _epsilon: number;
  17608. protected _indicesCount: number;
  17609. protected _lineShader: ShaderMaterial;
  17610. protected _ib: DataBuffer;
  17611. protected _buffers: {
  17612. [key: string]: Nullable<VertexBuffer>;
  17613. };
  17614. protected _buffersForInstances: {
  17615. [key: string]: Nullable<VertexBuffer>;
  17616. };
  17617. protected _checkVerticesInsteadOfIndices: boolean;
  17618. protected _options: Nullable<IEdgesRendererOptions>;
  17619. private _meshRebuildObserver;
  17620. private _meshDisposeObserver;
  17621. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  17622. isEnabled: boolean;
  17623. /**
  17624. * List of instances to render in case the source mesh has instances
  17625. */
  17626. customInstances: SmartArray<Matrix>;
  17627. private static GetShader;
  17628. /**
  17629. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  17630. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  17631. * @param source Mesh used to create edges
  17632. * @param epsilon sum of angles in adjacency to check for edge
  17633. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  17634. * @param generateEdgesLines - should generate Lines or only prepare resources.
  17635. * @param options The options to apply when generating the edges
  17636. */
  17637. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  17638. protected _prepareRessources(): void;
  17639. /** @hidden */
  17640. _rebuild(): void;
  17641. /**
  17642. * Releases the required resources for the edges renderer
  17643. */
  17644. dispose(): void;
  17645. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  17646. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  17647. /**
  17648. * Checks if the pair of p0 and p1 is en edge
  17649. * @param faceIndex
  17650. * @param edge
  17651. * @param faceNormals
  17652. * @param p0
  17653. * @param p1
  17654. * @private
  17655. */
  17656. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  17657. /**
  17658. * push line into the position, normal and index buffer
  17659. * @protected
  17660. */
  17661. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  17662. /**
  17663. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  17664. */
  17665. private _tessellateTriangle;
  17666. private _generateEdgesLinesAlternate;
  17667. /**
  17668. * Generates lines edges from adjacencjes
  17669. * @private
  17670. */
  17671. _generateEdgesLines(): void;
  17672. /**
  17673. * Checks wether or not the edges renderer is ready to render.
  17674. * @return true if ready, otherwise false.
  17675. */
  17676. isReady(): boolean;
  17677. /**
  17678. * Renders the edges of the attached mesh,
  17679. */
  17680. render(): void;
  17681. }
  17682. /**
  17683. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  17684. */
  17685. export class LineEdgesRenderer extends EdgesRenderer {
  17686. /**
  17687. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  17688. * @param source LineMesh used to generate edges
  17689. * @param epsilon not important (specified angle for edge detection)
  17690. * @param checkVerticesInsteadOfIndices not important for LineMesh
  17691. */
  17692. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  17693. /**
  17694. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  17695. */
  17696. _generateEdgesLines(): void;
  17697. }
  17698. }
  17699. declare module "babylonjs/Rendering/renderingGroup" {
  17700. import { SmartArray, SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  17701. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17702. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17703. import { Nullable } from "babylonjs/types";
  17704. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17705. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  17706. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17707. import { Material } from "babylonjs/Materials/material";
  17708. import { Scene } from "babylonjs/scene";
  17709. /**
  17710. * This represents the object necessary to create a rendering group.
  17711. * This is exclusively used and created by the rendering manager.
  17712. * To modify the behavior, you use the available helpers in your scene or meshes.
  17713. * @hidden
  17714. */
  17715. export class RenderingGroup {
  17716. index: number;
  17717. private static _zeroVector;
  17718. private _scene;
  17719. private _opaqueSubMeshes;
  17720. private _transparentSubMeshes;
  17721. private _alphaTestSubMeshes;
  17722. private _depthOnlySubMeshes;
  17723. private _particleSystems;
  17724. private _spriteManagers;
  17725. private _opaqueSortCompareFn;
  17726. private _alphaTestSortCompareFn;
  17727. private _transparentSortCompareFn;
  17728. private _renderOpaque;
  17729. private _renderAlphaTest;
  17730. private _renderTransparent;
  17731. /** @hidden */
  17732. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  17733. onBeforeTransparentRendering: () => void;
  17734. /**
  17735. * Set the opaque sort comparison function.
  17736. * If null the sub meshes will be render in the order they were created
  17737. */
  17738. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17739. /**
  17740. * Set the alpha test sort comparison function.
  17741. * If null the sub meshes will be render in the order they were created
  17742. */
  17743. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17744. /**
  17745. * Set the transparent sort comparison function.
  17746. * If null the sub meshes will be render in the order they were created
  17747. */
  17748. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  17749. /**
  17750. * Creates a new rendering group.
  17751. * @param index The rendering group index
  17752. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  17753. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  17754. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  17755. */
  17756. 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>);
  17757. /**
  17758. * Render all the sub meshes contained in the group.
  17759. * @param customRenderFunction Used to override the default render behaviour of the group.
  17760. * @returns true if rendered some submeshes.
  17761. */
  17762. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  17763. /**
  17764. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  17765. * @param subMeshes The submeshes to render
  17766. */
  17767. private renderOpaqueSorted;
  17768. /**
  17769. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  17770. * @param subMeshes The submeshes to render
  17771. */
  17772. private renderAlphaTestSorted;
  17773. /**
  17774. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  17775. * @param subMeshes The submeshes to render
  17776. */
  17777. private renderTransparentSorted;
  17778. /**
  17779. * Renders the submeshes in a specified order.
  17780. * @param subMeshes The submeshes to sort before render
  17781. * @param sortCompareFn The comparison function use to sort
  17782. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  17783. * @param transparent Specifies to activate blending if true
  17784. */
  17785. private static renderSorted;
  17786. /**
  17787. * Renders the submeshes in the order they were dispatched (no sort applied).
  17788. * @param subMeshes The submeshes to render
  17789. */
  17790. private static renderUnsorted;
  17791. /**
  17792. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17793. * are rendered back to front if in the same alpha index.
  17794. *
  17795. * @param a The first submesh
  17796. * @param b The second submesh
  17797. * @returns The result of the comparison
  17798. */
  17799. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  17800. /**
  17801. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17802. * are rendered back to front.
  17803. *
  17804. * @param a The first submesh
  17805. * @param b The second submesh
  17806. * @returns The result of the comparison
  17807. */
  17808. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  17809. /**
  17810. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  17811. * are rendered front to back (prevent overdraw).
  17812. *
  17813. * @param a The first submesh
  17814. * @param b The second submesh
  17815. * @returns The result of the comparison
  17816. */
  17817. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  17818. /**
  17819. * Resets the different lists of submeshes to prepare a new frame.
  17820. */
  17821. prepare(): void;
  17822. dispose(): void;
  17823. /**
  17824. * Inserts the submesh in its correct queue depending on its material.
  17825. * @param subMesh The submesh to dispatch
  17826. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17827. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17828. */
  17829. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17830. dispatchSprites(spriteManager: ISpriteManager): void;
  17831. dispatchParticles(particleSystem: IParticleSystem): void;
  17832. private _renderParticles;
  17833. private _renderSprites;
  17834. }
  17835. }
  17836. declare module "babylonjs/Rendering/renderingManager" {
  17837. import { Nullable } from "babylonjs/types";
  17838. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17839. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17840. import { SmartArray } from "babylonjs/Misc/smartArray";
  17841. import { ISpriteManager } from "babylonjs/Sprites/spriteManager";
  17842. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  17843. import { Material } from "babylonjs/Materials/material";
  17844. import { Scene } from "babylonjs/scene";
  17845. import { Camera } from "babylonjs/Cameras/camera";
  17846. /**
  17847. * Interface describing the different options available in the rendering manager
  17848. * regarding Auto Clear between groups.
  17849. */
  17850. export interface IRenderingManagerAutoClearSetup {
  17851. /**
  17852. * Defines whether or not autoclear is enable.
  17853. */
  17854. autoClear: boolean;
  17855. /**
  17856. * Defines whether or not to autoclear the depth buffer.
  17857. */
  17858. depth: boolean;
  17859. /**
  17860. * Defines whether or not to autoclear the stencil buffer.
  17861. */
  17862. stencil: boolean;
  17863. }
  17864. /**
  17865. * This class is used by the onRenderingGroupObservable
  17866. */
  17867. export class RenderingGroupInfo {
  17868. /**
  17869. * The Scene that being rendered
  17870. */
  17871. scene: Scene;
  17872. /**
  17873. * The camera currently used for the rendering pass
  17874. */
  17875. camera: Nullable<Camera>;
  17876. /**
  17877. * The ID of the renderingGroup being processed
  17878. */
  17879. renderingGroupId: number;
  17880. }
  17881. /**
  17882. * This is the manager responsible of all the rendering for meshes sprites and particles.
  17883. * It is enable to manage the different groups as well as the different necessary sort functions.
  17884. * This should not be used directly aside of the few static configurations
  17885. */
  17886. export class RenderingManager {
  17887. /**
  17888. * The max id used for rendering groups (not included)
  17889. */
  17890. static MAX_RENDERINGGROUPS: number;
  17891. /**
  17892. * The min id used for rendering groups (included)
  17893. */
  17894. static MIN_RENDERINGGROUPS: number;
  17895. /**
  17896. * Used to globally prevent autoclearing scenes.
  17897. */
  17898. static AUTOCLEAR: boolean;
  17899. /**
  17900. * @hidden
  17901. */
  17902. _useSceneAutoClearSetup: boolean;
  17903. private _scene;
  17904. private _renderingGroups;
  17905. private _depthStencilBufferAlreadyCleaned;
  17906. private _autoClearDepthStencil;
  17907. private _customOpaqueSortCompareFn;
  17908. private _customAlphaTestSortCompareFn;
  17909. private _customTransparentSortCompareFn;
  17910. private _renderingGroupInfo;
  17911. /**
  17912. * Instantiates a new rendering group for a particular scene
  17913. * @param scene Defines the scene the groups belongs to
  17914. */
  17915. constructor(scene: Scene);
  17916. private _clearDepthStencilBuffer;
  17917. /**
  17918. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  17919. * @hidden
  17920. */
  17921. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  17922. /**
  17923. * Resets the different information of the group to prepare a new frame
  17924. * @hidden
  17925. */
  17926. reset(): void;
  17927. /**
  17928. * Dispose and release the group and its associated resources.
  17929. * @hidden
  17930. */
  17931. dispose(): void;
  17932. /**
  17933. * Clear the info related to rendering groups preventing retention points during dispose.
  17934. */
  17935. freeRenderingGroups(): void;
  17936. private _prepareRenderingGroup;
  17937. /**
  17938. * Add a sprite manager to the rendering manager in order to render it this frame.
  17939. * @param spriteManager Define the sprite manager to render
  17940. */
  17941. dispatchSprites(spriteManager: ISpriteManager): void;
  17942. /**
  17943. * Add a particle system to the rendering manager in order to render it this frame.
  17944. * @param particleSystem Define the particle system to render
  17945. */
  17946. dispatchParticles(particleSystem: IParticleSystem): void;
  17947. /**
  17948. * Add a submesh to the manager in order to render it this frame
  17949. * @param subMesh The submesh to dispatch
  17950. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  17951. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  17952. */
  17953. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  17954. /**
  17955. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  17956. * This allowed control for front to back rendering or reversly depending of the special needs.
  17957. *
  17958. * @param renderingGroupId The rendering group id corresponding to its index
  17959. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  17960. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  17961. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  17962. */
  17963. 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;
  17964. /**
  17965. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  17966. *
  17967. * @param renderingGroupId The rendering group id corresponding to its index
  17968. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  17969. * @param depth Automatically clears depth between groups if true and autoClear is true.
  17970. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  17971. */
  17972. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  17973. /**
  17974. * Gets the current auto clear configuration for one rendering group of the rendering
  17975. * manager.
  17976. * @param index the rendering group index to get the information for
  17977. * @returns The auto clear setup for the requested rendering group
  17978. */
  17979. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  17980. }
  17981. }
  17982. declare module "babylonjs/Lights/Shadows/shadowGenerator" {
  17983. import { SmartArray } from "babylonjs/Misc/smartArray";
  17984. import { Nullable } from "babylonjs/types";
  17985. import { Scene } from "babylonjs/scene";
  17986. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  17987. import { SubMesh } from "babylonjs/Meshes/subMesh";
  17988. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  17989. import { Mesh } from "babylonjs/Meshes/mesh";
  17990. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  17991. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  17992. import { Effect } from "babylonjs/Materials/effect";
  17993. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  17994. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  17995. import "babylonjs/Shaders/shadowMap.fragment";
  17996. import "babylonjs/Shaders/shadowMap.vertex";
  17997. import "babylonjs/Shaders/depthBoxBlur.fragment";
  17998. import "babylonjs/Shaders/ShadersInclude/shadowMapFragmentSoftTransparentShadow";
  17999. import { Observable } from "babylonjs/Misc/observable";
  18000. /**
  18001. * Defines the options associated with the creation of a custom shader for a shadow generator.
  18002. */
  18003. export interface ICustomShaderOptions {
  18004. /**
  18005. * Gets or sets the custom shader name to use
  18006. */
  18007. shaderName: string;
  18008. /**
  18009. * The list of attribute names used in the shader
  18010. */
  18011. attributes?: string[];
  18012. /**
  18013. * The list of unifrom names used in the shader
  18014. */
  18015. uniforms?: string[];
  18016. /**
  18017. * The list of sampler names used in the shader
  18018. */
  18019. samplers?: string[];
  18020. /**
  18021. * The list of defines used in the shader
  18022. */
  18023. defines?: string[];
  18024. }
  18025. /**
  18026. * Interface to implement to create a shadow generator compatible with BJS.
  18027. */
  18028. export interface IShadowGenerator {
  18029. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18030. id: string;
  18031. /**
  18032. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18033. * @returns The render target texture if present otherwise, null
  18034. */
  18035. getShadowMap(): Nullable<RenderTargetTexture>;
  18036. /**
  18037. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18038. * @param subMesh The submesh we want to render in the shadow map
  18039. * @param useInstances Defines wether will draw in the map using instances
  18040. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18041. * @returns true if ready otherwise, false
  18042. */
  18043. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18044. /**
  18045. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18046. * @param defines Defines of the material we want to update
  18047. * @param lightIndex Index of the light in the enabled light list of the material
  18048. */
  18049. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  18050. /**
  18051. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18052. * defined in the generator but impacting the effect).
  18053. * It implies the unifroms available on the materials are the standard BJS ones.
  18054. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18055. * @param effect The effect we are binfing the information for
  18056. */
  18057. bindShadowLight(lightIndex: string, effect: Effect): void;
  18058. /**
  18059. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18060. * (eq to shadow prjection matrix * light transform matrix)
  18061. * @returns The transform matrix used to create the shadow map
  18062. */
  18063. getTransformMatrix(): Matrix;
  18064. /**
  18065. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18066. * Cube and 2D textures for instance.
  18067. */
  18068. recreateShadowMap(): void;
  18069. /**
  18070. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18071. * @param onCompiled Callback triggered at the and of the effects compilation
  18072. * @param options Sets of optional options forcing the compilation with different modes
  18073. */
  18074. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18075. useInstances: boolean;
  18076. }>): void;
  18077. /**
  18078. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18079. * @param options Sets of optional options forcing the compilation with different modes
  18080. * @returns A promise that resolves when the compilation completes
  18081. */
  18082. forceCompilationAsync(options?: Partial<{
  18083. useInstances: boolean;
  18084. }>): Promise<void>;
  18085. /**
  18086. * Serializes the shadow generator setup to a json object.
  18087. * @returns The serialized JSON object
  18088. */
  18089. serialize(): any;
  18090. /**
  18091. * Disposes the Shadow map and related Textures and effects.
  18092. */
  18093. dispose(): void;
  18094. }
  18095. /**
  18096. * Default implementation IShadowGenerator.
  18097. * This is the main object responsible of generating shadows in the framework.
  18098. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  18099. */
  18100. export class ShadowGenerator implements IShadowGenerator {
  18101. /**
  18102. * Name of the shadow generator class
  18103. */
  18104. static CLASSNAME: string;
  18105. /**
  18106. * Shadow generator mode None: no filtering applied.
  18107. */
  18108. static readonly FILTER_NONE: number;
  18109. /**
  18110. * Shadow generator mode ESM: Exponential Shadow Mapping.
  18111. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18112. */
  18113. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  18114. /**
  18115. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  18116. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  18117. */
  18118. static readonly FILTER_POISSONSAMPLING: number;
  18119. /**
  18120. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  18121. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18122. */
  18123. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  18124. /**
  18125. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  18126. * edge artifacts on steep falloff.
  18127. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18128. */
  18129. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  18130. /**
  18131. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  18132. * edge artifacts on steep falloff.
  18133. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  18134. */
  18135. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  18136. /**
  18137. * Shadow generator mode PCF: Percentage Closer Filtering
  18138. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18139. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  18140. */
  18141. static readonly FILTER_PCF: number;
  18142. /**
  18143. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  18144. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  18145. * Contact Hardening
  18146. */
  18147. static readonly FILTER_PCSS: number;
  18148. /**
  18149. * Reserved for PCF and PCSS
  18150. * Highest Quality.
  18151. *
  18152. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  18153. *
  18154. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  18155. */
  18156. static readonly QUALITY_HIGH: number;
  18157. /**
  18158. * Reserved for PCF and PCSS
  18159. * Good tradeoff for quality/perf cross devices
  18160. *
  18161. * Execute PCF on a 3*3 kernel.
  18162. *
  18163. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  18164. */
  18165. static readonly QUALITY_MEDIUM: number;
  18166. /**
  18167. * Reserved for PCF and PCSS
  18168. * The lowest quality but the fastest.
  18169. *
  18170. * Execute PCF on a 1*1 kernel.
  18171. *
  18172. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  18173. */
  18174. static readonly QUALITY_LOW: number;
  18175. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  18176. id: string;
  18177. /** Gets or sets the custom shader name to use */
  18178. customShaderOptions: ICustomShaderOptions;
  18179. /**
  18180. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  18181. */
  18182. onBeforeShadowMapRenderObservable: Observable<Effect>;
  18183. /**
  18184. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  18185. */
  18186. onAfterShadowMapRenderObservable: Observable<Effect>;
  18187. /**
  18188. * Observable triggered before a mesh is rendered in the shadow map.
  18189. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  18190. */
  18191. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  18192. /**
  18193. * Observable triggered after a mesh is rendered in the shadow map.
  18194. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  18195. */
  18196. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  18197. protected _bias: number;
  18198. /**
  18199. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  18200. */
  18201. get bias(): number;
  18202. /**
  18203. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  18204. */
  18205. set bias(bias: number);
  18206. protected _normalBias: number;
  18207. /**
  18208. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18209. */
  18210. get normalBias(): number;
  18211. /**
  18212. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  18213. */
  18214. set normalBias(normalBias: number);
  18215. protected _blurBoxOffset: number;
  18216. /**
  18217. * Gets the blur box offset: offset applied during the blur pass.
  18218. * Only useful if useKernelBlur = false
  18219. */
  18220. get blurBoxOffset(): number;
  18221. /**
  18222. * Sets the blur box offset: offset applied during the blur pass.
  18223. * Only useful if useKernelBlur = false
  18224. */
  18225. set blurBoxOffset(value: number);
  18226. protected _blurScale: number;
  18227. /**
  18228. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  18229. * 2 means half of the size.
  18230. */
  18231. get blurScale(): number;
  18232. /**
  18233. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  18234. * 2 means half of the size.
  18235. */
  18236. set blurScale(value: number);
  18237. protected _blurKernel: number;
  18238. /**
  18239. * Gets the blur kernel: kernel size of the blur pass.
  18240. * Only useful if useKernelBlur = true
  18241. */
  18242. get blurKernel(): number;
  18243. /**
  18244. * Sets the blur kernel: kernel size of the blur pass.
  18245. * Only useful if useKernelBlur = true
  18246. */
  18247. set blurKernel(value: number);
  18248. protected _useKernelBlur: boolean;
  18249. /**
  18250. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  18251. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18252. */
  18253. get useKernelBlur(): boolean;
  18254. /**
  18255. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  18256. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  18257. */
  18258. set useKernelBlur(value: boolean);
  18259. protected _depthScale: number;
  18260. /**
  18261. * Gets the depth scale used in ESM mode.
  18262. */
  18263. get depthScale(): number;
  18264. /**
  18265. * Sets the depth scale used in ESM mode.
  18266. * This can override the scale stored on the light.
  18267. */
  18268. set depthScale(value: number);
  18269. protected _validateFilter(filter: number): number;
  18270. protected _filter: number;
  18271. /**
  18272. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  18273. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18274. */
  18275. get filter(): number;
  18276. /**
  18277. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  18278. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  18279. */
  18280. set filter(value: number);
  18281. /**
  18282. * Gets if the current filter is set to Poisson Sampling.
  18283. */
  18284. get usePoissonSampling(): boolean;
  18285. /**
  18286. * Sets the current filter to Poisson Sampling.
  18287. */
  18288. set usePoissonSampling(value: boolean);
  18289. /**
  18290. * Gets if the current filter is set to ESM.
  18291. */
  18292. get useExponentialShadowMap(): boolean;
  18293. /**
  18294. * Sets the current filter is to ESM.
  18295. */
  18296. set useExponentialShadowMap(value: boolean);
  18297. /**
  18298. * Gets if the current filter is set to filtered ESM.
  18299. */
  18300. get useBlurExponentialShadowMap(): boolean;
  18301. /**
  18302. * Gets if the current filter is set to filtered ESM.
  18303. */
  18304. set useBlurExponentialShadowMap(value: boolean);
  18305. /**
  18306. * Gets if the current filter is set to "close ESM" (using the inverse of the
  18307. * exponential to prevent steep falloff artifacts).
  18308. */
  18309. get useCloseExponentialShadowMap(): boolean;
  18310. /**
  18311. * Sets the current filter to "close ESM" (using the inverse of the
  18312. * exponential to prevent steep falloff artifacts).
  18313. */
  18314. set useCloseExponentialShadowMap(value: boolean);
  18315. /**
  18316. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  18317. * exponential to prevent steep falloff artifacts).
  18318. */
  18319. get useBlurCloseExponentialShadowMap(): boolean;
  18320. /**
  18321. * Sets the current filter to filtered "close ESM" (using the inverse of the
  18322. * exponential to prevent steep falloff artifacts).
  18323. */
  18324. set useBlurCloseExponentialShadowMap(value: boolean);
  18325. /**
  18326. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  18327. */
  18328. get usePercentageCloserFiltering(): boolean;
  18329. /**
  18330. * Sets the current filter to "PCF" (percentage closer filtering).
  18331. */
  18332. set usePercentageCloserFiltering(value: boolean);
  18333. protected _filteringQuality: number;
  18334. /**
  18335. * Gets the PCF or PCSS Quality.
  18336. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18337. */
  18338. get filteringQuality(): number;
  18339. /**
  18340. * Sets the PCF or PCSS Quality.
  18341. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  18342. */
  18343. set filteringQuality(filteringQuality: number);
  18344. /**
  18345. * Gets if the current filter is set to "PCSS" (contact hardening).
  18346. */
  18347. get useContactHardeningShadow(): boolean;
  18348. /**
  18349. * Sets the current filter to "PCSS" (contact hardening).
  18350. */
  18351. set useContactHardeningShadow(value: boolean);
  18352. protected _contactHardeningLightSizeUVRatio: number;
  18353. /**
  18354. * Gets 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. get contactHardeningLightSizeUVRatio(): number;
  18363. /**
  18364. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  18365. * Using a ratio helps keeping shape stability independently of the map size.
  18366. *
  18367. * It does not account for the light projection as it was having too much
  18368. * instability during the light setup or during light position changes.
  18369. *
  18370. * Only valid if useContactHardeningShadow is true.
  18371. */
  18372. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  18373. protected _darkness: number;
  18374. /** Gets or sets the actual darkness of a shadow */
  18375. get darkness(): number;
  18376. set darkness(value: number);
  18377. /**
  18378. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  18379. * 0 means strongest and 1 would means no shadow.
  18380. * @returns the darkness.
  18381. */
  18382. getDarkness(): number;
  18383. /**
  18384. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  18385. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  18386. * @returns the shadow generator allowing fluent coding.
  18387. */
  18388. setDarkness(darkness: number): ShadowGenerator;
  18389. protected _transparencyShadow: boolean;
  18390. /** Gets or sets the ability to have transparent shadow */
  18391. get transparencyShadow(): boolean;
  18392. set transparencyShadow(value: boolean);
  18393. /**
  18394. * Sets the ability to have transparent shadow (boolean).
  18395. * @param transparent True if transparent else False
  18396. * @returns the shadow generator allowing fluent coding
  18397. */
  18398. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  18399. /**
  18400. * Enables or disables shadows with varying strength based on the transparency
  18401. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  18402. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  18403. * mesh.visibility * alphaTexture.a
  18404. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  18405. */
  18406. enableSoftTransparentShadow: boolean;
  18407. protected _shadowMap: Nullable<RenderTargetTexture>;
  18408. protected _shadowMap2: Nullable<RenderTargetTexture>;
  18409. /**
  18410. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  18411. * @returns The render target texture if present otherwise, null
  18412. */
  18413. getShadowMap(): Nullable<RenderTargetTexture>;
  18414. /**
  18415. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  18416. * @returns The render target texture if the shadow map is present otherwise, null
  18417. */
  18418. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  18419. /**
  18420. * Gets the class name of that object
  18421. * @returns "ShadowGenerator"
  18422. */
  18423. getClassName(): string;
  18424. /**
  18425. * Helper function to add a mesh and its descendants to the list of shadow casters.
  18426. * @param mesh Mesh to add
  18427. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  18428. * @returns the Shadow Generator itself
  18429. */
  18430. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18431. /**
  18432. * Helper function to remove a mesh and its descendants from the list of shadow casters
  18433. * @param mesh Mesh to remove
  18434. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  18435. * @returns the Shadow Generator itself
  18436. */
  18437. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  18438. /**
  18439. * Controls the extent to which the shadows fade out at the edge of the frustum
  18440. */
  18441. frustumEdgeFalloff: number;
  18442. protected _light: IShadowLight;
  18443. /**
  18444. * Returns the associated light object.
  18445. * @returns the light generating the shadow
  18446. */
  18447. getLight(): IShadowLight;
  18448. /**
  18449. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  18450. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  18451. * It might on the other hand introduce peter panning.
  18452. */
  18453. forceBackFacesOnly: boolean;
  18454. protected _scene: Scene;
  18455. protected _lightDirection: Vector3;
  18456. protected _effect: Effect;
  18457. protected _viewMatrix: Matrix;
  18458. protected _projectionMatrix: Matrix;
  18459. protected _transformMatrix: Matrix;
  18460. protected _cachedPosition: Vector3;
  18461. protected _cachedDirection: Vector3;
  18462. protected _cachedDefines: string;
  18463. protected _currentRenderID: number;
  18464. protected _boxBlurPostprocess: Nullable<PostProcess>;
  18465. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  18466. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  18467. protected _blurPostProcesses: PostProcess[];
  18468. protected _mapSize: number;
  18469. protected _currentFaceIndex: number;
  18470. protected _currentFaceIndexCache: number;
  18471. protected _textureType: number;
  18472. protected _defaultTextureMatrix: Matrix;
  18473. protected _storedUniqueId: Nullable<number>;
  18474. /** @hidden */
  18475. static _SceneComponentInitialization: (scene: Scene) => void;
  18476. /**
  18477. * Creates a ShadowGenerator object.
  18478. * A ShadowGenerator is the required tool to use the shadows.
  18479. * Each light casting shadows needs to use its own ShadowGenerator.
  18480. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  18481. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  18482. * @param light The light object generating the shadows.
  18483. * @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.
  18484. */
  18485. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  18486. protected _initializeGenerator(): void;
  18487. protected _createTargetRenderTexture(): void;
  18488. protected _initializeShadowMap(): void;
  18489. protected _initializeBlurRTTAndPostProcesses(): void;
  18490. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  18491. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  18492. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  18493. protected _applyFilterValues(): void;
  18494. /**
  18495. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18496. * @param onCompiled Callback triggered at the and of the effects compilation
  18497. * @param options Sets of optional options forcing the compilation with different modes
  18498. */
  18499. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  18500. useInstances: boolean;
  18501. }>): void;
  18502. /**
  18503. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  18504. * @param options Sets of optional options forcing the compilation with different modes
  18505. * @returns A promise that resolves when the compilation completes
  18506. */
  18507. forceCompilationAsync(options?: Partial<{
  18508. useInstances: boolean;
  18509. }>): Promise<void>;
  18510. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  18511. private _prepareShadowDefines;
  18512. /**
  18513. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  18514. * @param subMesh The submesh we want to render in the shadow map
  18515. * @param useInstances Defines wether will draw in the map using instances
  18516. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  18517. * @returns true if ready otherwise, false
  18518. */
  18519. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  18520. /**
  18521. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  18522. * @param defines Defines of the material we want to update
  18523. * @param lightIndex Index of the light in the enabled light list of the material
  18524. */
  18525. prepareDefines(defines: any, lightIndex: number): void;
  18526. /**
  18527. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  18528. * defined in the generator but impacting the effect).
  18529. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  18530. * @param effect The effect we are binfing the information for
  18531. */
  18532. bindShadowLight(lightIndex: string, effect: Effect): void;
  18533. /**
  18534. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  18535. * (eq to shadow prjection matrix * light transform matrix)
  18536. * @returns The transform matrix used to create the shadow map
  18537. */
  18538. getTransformMatrix(): Matrix;
  18539. /**
  18540. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  18541. * Cube and 2D textures for instance.
  18542. */
  18543. recreateShadowMap(): void;
  18544. protected _disposeBlurPostProcesses(): void;
  18545. protected _disposeRTTandPostProcesses(): void;
  18546. /**
  18547. * Disposes the ShadowGenerator.
  18548. * Returns nothing.
  18549. */
  18550. dispose(): void;
  18551. /**
  18552. * Serializes the shadow generator setup to a json object.
  18553. * @returns The serialized JSON object
  18554. */
  18555. serialize(): any;
  18556. /**
  18557. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  18558. * @param parsedShadowGenerator The JSON object to parse
  18559. * @param scene The scene to create the shadow map for
  18560. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  18561. * @returns The parsed shadow generator
  18562. */
  18563. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  18564. }
  18565. }
  18566. declare module "babylonjs/Lights/light" {
  18567. import { Nullable } from "babylonjs/types";
  18568. import { Scene } from "babylonjs/scene";
  18569. import { Vector3 } from "babylonjs/Maths/math.vector";
  18570. import { Color3 } from "babylonjs/Maths/math.color";
  18571. import { Node } from "babylonjs/node";
  18572. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  18573. import { Effect } from "babylonjs/Materials/effect";
  18574. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  18575. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  18576. /**
  18577. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  18578. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  18579. * 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.
  18580. */
  18581. export abstract class Light extends Node {
  18582. /**
  18583. * Falloff Default: light is falling off following the material specification:
  18584. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  18585. */
  18586. static readonly FALLOFF_DEFAULT: number;
  18587. /**
  18588. * Falloff Physical: light is falling off following the inverse squared distance law.
  18589. */
  18590. static readonly FALLOFF_PHYSICAL: number;
  18591. /**
  18592. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  18593. * to enhance interoperability with other engines.
  18594. */
  18595. static readonly FALLOFF_GLTF: number;
  18596. /**
  18597. * Falloff Standard: light is falling off like in the standard material
  18598. * to enhance interoperability with other materials.
  18599. */
  18600. static readonly FALLOFF_STANDARD: number;
  18601. /**
  18602. * If every light affecting the material is in this lightmapMode,
  18603. * material.lightmapTexture adds or multiplies
  18604. * (depends on material.useLightmapAsShadowmap)
  18605. * after every other light calculations.
  18606. */
  18607. static readonly LIGHTMAP_DEFAULT: number;
  18608. /**
  18609. * material.lightmapTexture as only diffuse lighting from this light
  18610. * adds only specular lighting from this light
  18611. * adds dynamic shadows
  18612. */
  18613. static readonly LIGHTMAP_SPECULAR: number;
  18614. /**
  18615. * material.lightmapTexture as only lighting
  18616. * no light calculation from this light
  18617. * only adds dynamic shadows from this light
  18618. */
  18619. static readonly LIGHTMAP_SHADOWSONLY: number;
  18620. /**
  18621. * Each light type uses the default quantity according to its type:
  18622. * point/spot lights use luminous intensity
  18623. * directional lights use illuminance
  18624. */
  18625. static readonly INTENSITYMODE_AUTOMATIC: number;
  18626. /**
  18627. * lumen (lm)
  18628. */
  18629. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  18630. /**
  18631. * candela (lm/sr)
  18632. */
  18633. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  18634. /**
  18635. * lux (lm/m^2)
  18636. */
  18637. static readonly INTENSITYMODE_ILLUMINANCE: number;
  18638. /**
  18639. * nit (cd/m^2)
  18640. */
  18641. static readonly INTENSITYMODE_LUMINANCE: number;
  18642. /**
  18643. * Light type const id of the point light.
  18644. */
  18645. static readonly LIGHTTYPEID_POINTLIGHT: number;
  18646. /**
  18647. * Light type const id of the directional light.
  18648. */
  18649. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  18650. /**
  18651. * Light type const id of the spot light.
  18652. */
  18653. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  18654. /**
  18655. * Light type const id of the hemispheric light.
  18656. */
  18657. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  18658. /**
  18659. * Diffuse gives the basic color to an object.
  18660. */
  18661. diffuse: Color3;
  18662. /**
  18663. * Specular produces a highlight color on an object.
  18664. * Note: This is note affecting PBR materials.
  18665. */
  18666. specular: Color3;
  18667. /**
  18668. * Defines the falloff type for this light. This lets overrriding how punctual light are
  18669. * falling off base on range or angle.
  18670. * This can be set to any values in Light.FALLOFF_x.
  18671. *
  18672. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  18673. * other types of materials.
  18674. */
  18675. falloffType: number;
  18676. /**
  18677. * Strength of the light.
  18678. * Note: By default it is define in the framework own unit.
  18679. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  18680. */
  18681. intensity: number;
  18682. private _range;
  18683. protected _inverseSquaredRange: number;
  18684. /**
  18685. * Defines how far from the source the light is impacting in scene units.
  18686. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18687. */
  18688. get range(): number;
  18689. /**
  18690. * Defines how far from the source the light is impacting in scene units.
  18691. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  18692. */
  18693. set range(value: number);
  18694. /**
  18695. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  18696. * of light.
  18697. */
  18698. private _photometricScale;
  18699. private _intensityMode;
  18700. /**
  18701. * Gets the photometric scale used to interpret the intensity.
  18702. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18703. */
  18704. get intensityMode(): number;
  18705. /**
  18706. * Sets the photometric scale used to interpret the intensity.
  18707. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  18708. */
  18709. set intensityMode(value: number);
  18710. private _radius;
  18711. /**
  18712. * Gets the light radius used by PBR Materials to simulate soft area lights.
  18713. */
  18714. get radius(): number;
  18715. /**
  18716. * sets the light radius used by PBR Materials to simulate soft area lights.
  18717. */
  18718. set radius(value: number);
  18719. private _renderPriority;
  18720. /**
  18721. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  18722. * exceeding the number allowed of the materials.
  18723. */
  18724. renderPriority: number;
  18725. private _shadowEnabled;
  18726. /**
  18727. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18728. * the current shadow generator.
  18729. */
  18730. get shadowEnabled(): boolean;
  18731. /**
  18732. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  18733. * the current shadow generator.
  18734. */
  18735. set shadowEnabled(value: boolean);
  18736. private _includedOnlyMeshes;
  18737. /**
  18738. * Gets the only meshes impacted by this light.
  18739. */
  18740. get includedOnlyMeshes(): AbstractMesh[];
  18741. /**
  18742. * Sets the only meshes impacted by this light.
  18743. */
  18744. set includedOnlyMeshes(value: AbstractMesh[]);
  18745. private _excludedMeshes;
  18746. /**
  18747. * Gets the meshes not impacted by this light.
  18748. */
  18749. get excludedMeshes(): AbstractMesh[];
  18750. /**
  18751. * Sets the meshes not impacted by this light.
  18752. */
  18753. set excludedMeshes(value: AbstractMesh[]);
  18754. private _excludeWithLayerMask;
  18755. /**
  18756. * Gets the layer id use to find what meshes are not impacted by the light.
  18757. * Inactive if 0
  18758. */
  18759. get excludeWithLayerMask(): number;
  18760. /**
  18761. * Sets the layer id use to find what meshes are not impacted by the light.
  18762. * Inactive if 0
  18763. */
  18764. set excludeWithLayerMask(value: number);
  18765. private _includeOnlyWithLayerMask;
  18766. /**
  18767. * Gets the layer id use to find what meshes are impacted by the light.
  18768. * Inactive if 0
  18769. */
  18770. get includeOnlyWithLayerMask(): number;
  18771. /**
  18772. * Sets the layer id use to find what meshes are impacted by the light.
  18773. * Inactive if 0
  18774. */
  18775. set includeOnlyWithLayerMask(value: number);
  18776. private _lightmapMode;
  18777. /**
  18778. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18779. */
  18780. get lightmapMode(): number;
  18781. /**
  18782. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  18783. */
  18784. set lightmapMode(value: number);
  18785. /**
  18786. * Shadow generator associted to the light.
  18787. * @hidden Internal use only.
  18788. */
  18789. _shadowGenerator: Nullable<IShadowGenerator>;
  18790. /**
  18791. * @hidden Internal use only.
  18792. */
  18793. _excludedMeshesIds: string[];
  18794. /**
  18795. * @hidden Internal use only.
  18796. */
  18797. _includedOnlyMeshesIds: string[];
  18798. /**
  18799. * The current light unifom buffer.
  18800. * @hidden Internal use only.
  18801. */
  18802. _uniformBuffer: UniformBuffer;
  18803. /** @hidden */
  18804. _renderId: number;
  18805. /**
  18806. * Creates a Light object in the scene.
  18807. * Documentation : https://doc.babylonjs.com/babylon101/lights
  18808. * @param name The firendly name of the light
  18809. * @param scene The scene the light belongs too
  18810. */
  18811. constructor(name: string, scene: Scene);
  18812. protected abstract _buildUniformLayout(): void;
  18813. /**
  18814. * Sets the passed Effect "effect" with the Light information.
  18815. * @param effect The effect to update
  18816. * @param lightIndex The index of the light in the effect to update
  18817. * @returns The light
  18818. */
  18819. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  18820. /**
  18821. * Sets the passed Effect "effect" with the Light textures.
  18822. * @param effect The effect to update
  18823. * @param lightIndex The index of the light in the effect to update
  18824. * @returns The light
  18825. */
  18826. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  18827. /**
  18828. * Binds the lights information from the scene to the effect for the given mesh.
  18829. * @param lightIndex Light index
  18830. * @param scene The scene where the light belongs to
  18831. * @param effect The effect we are binding the data to
  18832. * @param useSpecular Defines if specular is supported
  18833. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  18834. */
  18835. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  18836. /**
  18837. * Sets the passed Effect "effect" with the Light information.
  18838. * @param effect The effect to update
  18839. * @param lightDataUniformName The uniform used to store light data (position or direction)
  18840. * @returns The light
  18841. */
  18842. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  18843. /**
  18844. * Returns the string "Light".
  18845. * @returns the class name
  18846. */
  18847. getClassName(): string;
  18848. /** @hidden */
  18849. readonly _isLight: boolean;
  18850. /**
  18851. * Converts the light information to a readable string for debug purpose.
  18852. * @param fullDetails Supports for multiple levels of logging within scene loading
  18853. * @returns the human readable light info
  18854. */
  18855. toString(fullDetails?: boolean): string;
  18856. /** @hidden */
  18857. protected _syncParentEnabledState(): void;
  18858. /**
  18859. * Set the enabled state of this node.
  18860. * @param value - the new enabled state
  18861. */
  18862. setEnabled(value: boolean): void;
  18863. /**
  18864. * Returns the Light associated shadow generator if any.
  18865. * @return the associated shadow generator.
  18866. */
  18867. getShadowGenerator(): Nullable<IShadowGenerator>;
  18868. /**
  18869. * Returns a Vector3, the absolute light position in the World.
  18870. * @returns the world space position of the light
  18871. */
  18872. getAbsolutePosition(): Vector3;
  18873. /**
  18874. * Specifies if the light will affect the passed mesh.
  18875. * @param mesh The mesh to test against the light
  18876. * @return true the mesh is affected otherwise, false.
  18877. */
  18878. canAffectMesh(mesh: AbstractMesh): boolean;
  18879. /**
  18880. * Sort function to order lights for rendering.
  18881. * @param a First Light object to compare to second.
  18882. * @param b Second Light object to compare first.
  18883. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  18884. */
  18885. static CompareLightsPriority(a: Light, b: Light): number;
  18886. /**
  18887. * Releases resources associated with this node.
  18888. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  18889. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  18890. */
  18891. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  18892. /**
  18893. * Returns the light type ID (integer).
  18894. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  18895. */
  18896. getTypeID(): number;
  18897. /**
  18898. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  18899. * @returns the scaled intensity in intensity mode unit
  18900. */
  18901. getScaledIntensity(): number;
  18902. /**
  18903. * Returns a new Light object, named "name", from the current one.
  18904. * @param name The name of the cloned light
  18905. * @param newParent The parent of this light, if it has one
  18906. * @returns the new created light
  18907. */
  18908. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  18909. /**
  18910. * Serializes the current light into a Serialization object.
  18911. * @returns the serialized object.
  18912. */
  18913. serialize(): any;
  18914. /**
  18915. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  18916. * This new light is named "name" and added to the passed scene.
  18917. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  18918. * @param name The friendly name of the light
  18919. * @param scene The scene the new light will belong to
  18920. * @returns the constructor function
  18921. */
  18922. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  18923. /**
  18924. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  18925. * @param parsedLight The JSON representation of the light
  18926. * @param scene The scene to create the parsed light in
  18927. * @returns the created light after parsing
  18928. */
  18929. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  18930. private _hookArrayForExcluded;
  18931. private _hookArrayForIncludedOnly;
  18932. private _resyncMeshes;
  18933. /**
  18934. * Forces the meshes to update their light related information in their rendering used effects
  18935. * @hidden Internal Use Only
  18936. */
  18937. _markMeshesAsLightDirty(): void;
  18938. /**
  18939. * Recomputes the cached photometric scale if needed.
  18940. */
  18941. private _computePhotometricScale;
  18942. /**
  18943. * Returns the Photometric Scale according to the light type and intensity mode.
  18944. */
  18945. private _getPhotometricScale;
  18946. /**
  18947. * Reorder the light in the scene according to their defined priority.
  18948. * @hidden Internal Use Only
  18949. */
  18950. _reorderLightsInScene(): void;
  18951. /**
  18952. * Prepares the list of defines specific to the light type.
  18953. * @param defines the list of defines
  18954. * @param lightIndex defines the index of the light for the effect
  18955. */
  18956. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  18957. }
  18958. }
  18959. declare module "babylonjs/Materials/prePassConfiguration" {
  18960. import { Matrix } from "babylonjs/Maths/math.vector";
  18961. import { Mesh } from "babylonjs/Meshes/mesh";
  18962. import { Scene } from "babylonjs/scene";
  18963. import { Effect } from "babylonjs/Materials/effect";
  18964. /**
  18965. * Configuration needed for prepass-capable materials
  18966. */
  18967. export class PrePassConfiguration {
  18968. /**
  18969. * Previous world matrices of meshes carrying this material
  18970. * Used for computing velocity
  18971. */
  18972. previousWorldMatrices: {
  18973. [index: number]: Matrix;
  18974. };
  18975. /**
  18976. * Previous view project matrix
  18977. * Used for computing velocity
  18978. */
  18979. previousViewProjection: Matrix;
  18980. /**
  18981. * Previous bones of meshes carrying this material
  18982. * Used for computing velocity
  18983. */
  18984. previousBones: {
  18985. [index: number]: Float32Array;
  18986. };
  18987. /**
  18988. * Add the required uniforms to the current list.
  18989. * @param uniforms defines the current uniform list.
  18990. */
  18991. static AddUniforms(uniforms: string[]): void;
  18992. /**
  18993. * Add the required samplers to the current list.
  18994. * @param samplers defines the current sampler list.
  18995. */
  18996. static AddSamplers(samplers: string[]): void;
  18997. /**
  18998. * Binds the material data.
  18999. * @param effect defines the effect to update
  19000. * @param scene defines the scene the material belongs to.
  19001. * @param mesh The mesh
  19002. * @param world World matrix of this mesh
  19003. * @param isFrozen Is the material frozen
  19004. */
  19005. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  19006. }
  19007. }
  19008. declare module "babylonjs/Cameras/targetCamera" {
  19009. import { Nullable } from "babylonjs/types";
  19010. import { Camera } from "babylonjs/Cameras/camera";
  19011. import { Scene } from "babylonjs/scene";
  19012. import { Quaternion, Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  19013. /**
  19014. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  19015. * This is the base of the follow, arc rotate cameras and Free camera
  19016. * @see https://doc.babylonjs.com/features/cameras
  19017. */
  19018. export class TargetCamera extends Camera {
  19019. private static _RigCamTransformMatrix;
  19020. private static _TargetTransformMatrix;
  19021. private static _TargetFocalPoint;
  19022. private _tmpUpVector;
  19023. private _tmpTargetVector;
  19024. /**
  19025. * Define the current direction the camera is moving to
  19026. */
  19027. cameraDirection: Vector3;
  19028. /**
  19029. * Define the current rotation the camera is rotating to
  19030. */
  19031. cameraRotation: Vector2;
  19032. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  19033. ignoreParentScaling: boolean;
  19034. /**
  19035. * When set, the up vector of the camera will be updated by the rotation of the camera
  19036. */
  19037. updateUpVectorFromRotation: boolean;
  19038. private _tmpQuaternion;
  19039. /**
  19040. * Define the current rotation of the camera
  19041. */
  19042. rotation: Vector3;
  19043. /**
  19044. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  19045. */
  19046. rotationQuaternion: Quaternion;
  19047. /**
  19048. * Define the current speed of the camera
  19049. */
  19050. speed: number;
  19051. /**
  19052. * Add constraint to the camera to prevent it to move freely in all directions and
  19053. * around all axis.
  19054. */
  19055. noRotationConstraint: boolean;
  19056. /**
  19057. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  19058. * panning
  19059. */
  19060. invertRotation: boolean;
  19061. /**
  19062. * Speed multiplier for inverse camera panning
  19063. */
  19064. inverseRotationSpeed: number;
  19065. /**
  19066. * Define the current target of the camera as an object or a position.
  19067. */
  19068. lockedTarget: any;
  19069. /** @hidden */
  19070. _currentTarget: Vector3;
  19071. /** @hidden */
  19072. _initialFocalDistance: number;
  19073. /** @hidden */
  19074. _viewMatrix: Matrix;
  19075. /** @hidden */
  19076. _camMatrix: Matrix;
  19077. /** @hidden */
  19078. _cameraTransformMatrix: Matrix;
  19079. /** @hidden */
  19080. _cameraRotationMatrix: Matrix;
  19081. /** @hidden */
  19082. _referencePoint: Vector3;
  19083. /** @hidden */
  19084. _transformedReferencePoint: Vector3;
  19085. /** @hidden */
  19086. _reset: () => void;
  19087. private _defaultUp;
  19088. /**
  19089. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  19090. * This is the base of the follow, arc rotate cameras and Free camera
  19091. * @see https://doc.babylonjs.com/features/cameras
  19092. * @param name Defines the name of the camera in the scene
  19093. * @param position Defines the start position of the camera in the scene
  19094. * @param scene Defines the scene the camera belongs to
  19095. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19096. */
  19097. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19098. /**
  19099. * Gets the position in front of the camera at a given distance.
  19100. * @param distance The distance from the camera we want the position to be
  19101. * @returns the position
  19102. */
  19103. getFrontPosition(distance: number): Vector3;
  19104. /** @hidden */
  19105. _getLockedTargetPosition(): Nullable<Vector3>;
  19106. private _storedPosition;
  19107. private _storedRotation;
  19108. private _storedRotationQuaternion;
  19109. /**
  19110. * Store current camera state of the camera (fov, position, rotation, etc..)
  19111. * @returns the camera
  19112. */
  19113. storeState(): Camera;
  19114. /**
  19115. * Restored camera state. You must call storeState() first
  19116. * @returns whether it was successful or not
  19117. * @hidden
  19118. */
  19119. _restoreStateValues(): boolean;
  19120. /** @hidden */
  19121. _initCache(): void;
  19122. /** @hidden */
  19123. _updateCache(ignoreParentClass?: boolean): void;
  19124. /** @hidden */
  19125. _isSynchronizedViewMatrix(): boolean;
  19126. /** @hidden */
  19127. _computeLocalCameraSpeed(): number;
  19128. /**
  19129. * Defines the target the camera should look at.
  19130. * @param target Defines the new target as a Vector or a mesh
  19131. */
  19132. setTarget(target: Vector3): void;
  19133. /**
  19134. * Defines the target point of the camera.
  19135. * The camera looks towards it form the radius distance.
  19136. */
  19137. get target(): Vector3;
  19138. set target(value: Vector3);
  19139. /**
  19140. * Return the current target position of the camera. This value is expressed in local space.
  19141. * @returns the target position
  19142. */
  19143. getTarget(): Vector3;
  19144. /** @hidden */
  19145. _decideIfNeedsToMove(): boolean;
  19146. /** @hidden */
  19147. _updatePosition(): void;
  19148. /** @hidden */
  19149. _checkInputs(): void;
  19150. protected _updateCameraRotationMatrix(): void;
  19151. /**
  19152. * 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)
  19153. * @returns the current camera
  19154. */
  19155. private _rotateUpVectorWithCameraRotationMatrix;
  19156. private _cachedRotationZ;
  19157. private _cachedQuaternionRotationZ;
  19158. /** @hidden */
  19159. _getViewMatrix(): Matrix;
  19160. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  19161. /**
  19162. * @hidden
  19163. */
  19164. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  19165. /**
  19166. * @hidden
  19167. */
  19168. _updateRigCameras(): void;
  19169. private _getRigCamPositionAndTarget;
  19170. /**
  19171. * Gets the current object class name.
  19172. * @return the class name
  19173. */
  19174. getClassName(): string;
  19175. }
  19176. }
  19177. declare module "babylonjs/Events/keyboardEvents" {
  19178. /**
  19179. * Gather the list of keyboard event types as constants.
  19180. */
  19181. export class KeyboardEventTypes {
  19182. /**
  19183. * The keydown event is fired when a key becomes active (pressed).
  19184. */
  19185. static readonly KEYDOWN: number;
  19186. /**
  19187. * The keyup event is fired when a key has been released.
  19188. */
  19189. static readonly KEYUP: number;
  19190. }
  19191. /**
  19192. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19193. */
  19194. export class KeyboardInfo {
  19195. /**
  19196. * Defines the type of event (KeyboardEventTypes)
  19197. */
  19198. type: number;
  19199. /**
  19200. * Defines the related dom event
  19201. */
  19202. event: KeyboardEvent;
  19203. /**
  19204. * Instantiates a new keyboard info.
  19205. * This class is used to store keyboard related info for the onKeyboardObservable event.
  19206. * @param type Defines the type of event (KeyboardEventTypes)
  19207. * @param event Defines the related dom event
  19208. */
  19209. constructor(
  19210. /**
  19211. * Defines the type of event (KeyboardEventTypes)
  19212. */
  19213. type: number,
  19214. /**
  19215. * Defines the related dom event
  19216. */
  19217. event: KeyboardEvent);
  19218. }
  19219. /**
  19220. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19221. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  19222. */
  19223. export class KeyboardInfoPre extends KeyboardInfo {
  19224. /**
  19225. * Defines the type of event (KeyboardEventTypes)
  19226. */
  19227. type: number;
  19228. /**
  19229. * Defines the related dom event
  19230. */
  19231. event: KeyboardEvent;
  19232. /**
  19233. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  19234. */
  19235. skipOnPointerObservable: boolean;
  19236. /**
  19237. * Instantiates a new keyboard pre info.
  19238. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  19239. * @param type Defines the type of event (KeyboardEventTypes)
  19240. * @param event Defines the related dom event
  19241. */
  19242. constructor(
  19243. /**
  19244. * Defines the type of event (KeyboardEventTypes)
  19245. */
  19246. type: number,
  19247. /**
  19248. * Defines the related dom event
  19249. */
  19250. event: KeyboardEvent);
  19251. }
  19252. }
  19253. declare module "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput" {
  19254. import { Nullable } from "babylonjs/types";
  19255. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19256. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19257. /**
  19258. * Manage the keyboard inputs to control the movement of a free camera.
  19259. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19260. */
  19261. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  19262. /**
  19263. * Defines the camera the input is attached to.
  19264. */
  19265. camera: FreeCamera;
  19266. /**
  19267. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19268. */
  19269. keysUp: number[];
  19270. /**
  19271. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19272. */
  19273. keysUpward: number[];
  19274. /**
  19275. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19276. */
  19277. keysDown: number[];
  19278. /**
  19279. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19280. */
  19281. keysDownward: number[];
  19282. /**
  19283. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19284. */
  19285. keysLeft: number[];
  19286. /**
  19287. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19288. */
  19289. keysRight: number[];
  19290. private _keys;
  19291. private _onCanvasBlurObserver;
  19292. private _onKeyboardObserver;
  19293. private _engine;
  19294. private _scene;
  19295. /**
  19296. * Attach the input controls to a specific dom element to get the input from.
  19297. * @param element Defines the element the controls should be listened from
  19298. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19299. */
  19300. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19301. /**
  19302. * Detach the current controls from the specified dom element.
  19303. * @param element Defines the element to stop listening the inputs from
  19304. */
  19305. detachControl(element: Nullable<HTMLElement>): void;
  19306. /**
  19307. * Update the current camera state depending on the inputs that have been used this frame.
  19308. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19309. */
  19310. checkInputs(): void;
  19311. /**
  19312. * Gets the class name of the current intput.
  19313. * @returns the class name
  19314. */
  19315. getClassName(): string;
  19316. /** @hidden */
  19317. _onLostFocus(): void;
  19318. /**
  19319. * Get the friendly name associated with the input class.
  19320. * @returns the input friendly name
  19321. */
  19322. getSimpleName(): string;
  19323. }
  19324. }
  19325. declare module "babylonjs/Events/pointerEvents" {
  19326. import { Nullable } from "babylonjs/types";
  19327. import { Vector2 } from "babylonjs/Maths/math.vector";
  19328. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  19329. import { Ray } from "babylonjs/Culling/ray";
  19330. /**
  19331. * Gather the list of pointer event types as constants.
  19332. */
  19333. export class PointerEventTypes {
  19334. /**
  19335. * 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.
  19336. */
  19337. static readonly POINTERDOWN: number;
  19338. /**
  19339. * The pointerup event is fired when a pointer is no longer active.
  19340. */
  19341. static readonly POINTERUP: number;
  19342. /**
  19343. * The pointermove event is fired when a pointer changes coordinates.
  19344. */
  19345. static readonly POINTERMOVE: number;
  19346. /**
  19347. * The pointerwheel event is fired when a mouse wheel has been rotated.
  19348. */
  19349. static readonly POINTERWHEEL: number;
  19350. /**
  19351. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  19352. */
  19353. static readonly POINTERPICK: number;
  19354. /**
  19355. * The pointertap event is fired when a the object has been touched and released without drag.
  19356. */
  19357. static readonly POINTERTAP: number;
  19358. /**
  19359. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  19360. */
  19361. static readonly POINTERDOUBLETAP: number;
  19362. }
  19363. /**
  19364. * Base class of pointer info types.
  19365. */
  19366. export class PointerInfoBase {
  19367. /**
  19368. * Defines the type of event (PointerEventTypes)
  19369. */
  19370. type: number;
  19371. /**
  19372. * Defines the related dom event
  19373. */
  19374. event: PointerEvent | MouseWheelEvent;
  19375. /**
  19376. * Instantiates the base class of pointers info.
  19377. * @param type Defines the type of event (PointerEventTypes)
  19378. * @param event Defines the related dom event
  19379. */
  19380. constructor(
  19381. /**
  19382. * Defines the type of event (PointerEventTypes)
  19383. */
  19384. type: number,
  19385. /**
  19386. * Defines the related dom event
  19387. */
  19388. event: PointerEvent | MouseWheelEvent);
  19389. }
  19390. /**
  19391. * This class is used to store pointer related info for the onPrePointerObservable event.
  19392. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  19393. */
  19394. export class PointerInfoPre extends PointerInfoBase {
  19395. /**
  19396. * Ray from a pointer if availible (eg. 6dof controller)
  19397. */
  19398. ray: Nullable<Ray>;
  19399. /**
  19400. * Defines the local position of the pointer on the canvas.
  19401. */
  19402. localPosition: Vector2;
  19403. /**
  19404. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  19405. */
  19406. skipOnPointerObservable: boolean;
  19407. /**
  19408. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  19409. * @param type Defines the type of event (PointerEventTypes)
  19410. * @param event Defines the related dom event
  19411. * @param localX Defines the local x coordinates of the pointer when the event occured
  19412. * @param localY Defines the local y coordinates of the pointer when the event occured
  19413. */
  19414. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  19415. }
  19416. /**
  19417. * This type contains all the data related to a pointer event in Babylon.js.
  19418. * 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.
  19419. */
  19420. export class PointerInfo extends PointerInfoBase {
  19421. /**
  19422. * Defines the picking info associated to the info (if any)\
  19423. */
  19424. pickInfo: Nullable<PickingInfo>;
  19425. /**
  19426. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  19427. * @param type Defines the type of event (PointerEventTypes)
  19428. * @param event Defines the related dom event
  19429. * @param pickInfo Defines the picking info associated to the info (if any)\
  19430. */
  19431. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  19432. /**
  19433. * Defines the picking info associated to the info (if any)\
  19434. */
  19435. pickInfo: Nullable<PickingInfo>);
  19436. }
  19437. /**
  19438. * Data relating to a touch event on the screen.
  19439. */
  19440. export interface PointerTouch {
  19441. /**
  19442. * X coordinate of touch.
  19443. */
  19444. x: number;
  19445. /**
  19446. * Y coordinate of touch.
  19447. */
  19448. y: number;
  19449. /**
  19450. * Id of touch. Unique for each finger.
  19451. */
  19452. pointerId: number;
  19453. /**
  19454. * Event type passed from DOM.
  19455. */
  19456. type: any;
  19457. }
  19458. }
  19459. declare module "babylonjs/Cameras/Inputs/freeCameraMouseInput" {
  19460. import { Observable } from "babylonjs/Misc/observable";
  19461. import { Nullable } from "babylonjs/types";
  19462. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19463. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19464. /**
  19465. * Manage the mouse inputs to control the movement of a free camera.
  19466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19467. */
  19468. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  19469. /**
  19470. * Define if touch is enabled in the mouse input
  19471. */
  19472. touchEnabled: boolean;
  19473. /**
  19474. * Defines the camera the input is attached to.
  19475. */
  19476. camera: FreeCamera;
  19477. /**
  19478. * Defines the buttons associated with the input to handle camera move.
  19479. */
  19480. buttons: number[];
  19481. /**
  19482. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  19483. */
  19484. angularSensibility: number;
  19485. private _pointerInput;
  19486. private _onMouseMove;
  19487. private _observer;
  19488. private previousPosition;
  19489. /**
  19490. * Observable for when a pointer move event occurs containing the move offset
  19491. */
  19492. onPointerMovedObservable: Observable<{
  19493. offsetX: number;
  19494. offsetY: number;
  19495. }>;
  19496. /**
  19497. * @hidden
  19498. * If the camera should be rotated automatically based on pointer movement
  19499. */
  19500. _allowCameraRotation: boolean;
  19501. /**
  19502. * Manage the mouse inputs to control the movement of a free camera.
  19503. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19504. * @param touchEnabled Defines if touch is enabled or not
  19505. */
  19506. constructor(
  19507. /**
  19508. * Define if touch is enabled in the mouse input
  19509. */
  19510. touchEnabled?: boolean);
  19511. /**
  19512. * Attach the input controls to a specific dom element to get the input from.
  19513. * @param element Defines the element the controls should be listened from
  19514. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19515. */
  19516. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19517. /**
  19518. * Called on JS contextmenu event.
  19519. * Override this method to provide functionality.
  19520. */
  19521. protected onContextMenu(evt: PointerEvent): void;
  19522. /**
  19523. * Detach the current controls from the specified dom element.
  19524. * @param element Defines the element to stop listening the inputs from
  19525. */
  19526. detachControl(element: Nullable<HTMLElement>): void;
  19527. /**
  19528. * Gets the class name of the current intput.
  19529. * @returns the class name
  19530. */
  19531. getClassName(): string;
  19532. /**
  19533. * Get the friendly name associated with the input class.
  19534. * @returns the input friendly name
  19535. */
  19536. getSimpleName(): string;
  19537. }
  19538. }
  19539. declare module "babylonjs/Cameras/Inputs/freeCameraTouchInput" {
  19540. import { Nullable } from "babylonjs/types";
  19541. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  19542. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19543. /**
  19544. * Manage the touch inputs to control the movement of a free camera.
  19545. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19546. */
  19547. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  19548. /**
  19549. * Define if mouse events can be treated as touch events
  19550. */
  19551. allowMouse: boolean;
  19552. /**
  19553. * Defines the camera the input is attached to.
  19554. */
  19555. camera: FreeCamera;
  19556. /**
  19557. * Defines the touch sensibility for rotation.
  19558. * The higher the faster.
  19559. */
  19560. touchAngularSensibility: number;
  19561. /**
  19562. * Defines the touch sensibility for move.
  19563. * The higher the faster.
  19564. */
  19565. touchMoveSensibility: number;
  19566. private _offsetX;
  19567. private _offsetY;
  19568. private _pointerPressed;
  19569. private _pointerInput;
  19570. private _observer;
  19571. private _onLostFocus;
  19572. /**
  19573. * Manage the touch inputs to control the movement of a free camera.
  19574. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19575. * @param allowMouse Defines if mouse events can be treated as touch events
  19576. */
  19577. constructor(
  19578. /**
  19579. * Define if mouse events can be treated as touch events
  19580. */
  19581. allowMouse?: boolean);
  19582. /**
  19583. * Attach the input controls to a specific dom element to get the input from.
  19584. * @param element Defines the element the controls should be listened from
  19585. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19586. */
  19587. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19588. /**
  19589. * Detach the current controls from the specified dom element.
  19590. * @param element Defines the element to stop listening the inputs from
  19591. */
  19592. detachControl(element: Nullable<HTMLElement>): void;
  19593. /**
  19594. * Update the current camera state depending on the inputs that have been used this frame.
  19595. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  19596. */
  19597. checkInputs(): void;
  19598. /**
  19599. * Gets the class name of the current intput.
  19600. * @returns the class name
  19601. */
  19602. getClassName(): string;
  19603. /**
  19604. * Get the friendly name associated with the input class.
  19605. * @returns the input friendly name
  19606. */
  19607. getSimpleName(): string;
  19608. }
  19609. }
  19610. declare module "babylonjs/Cameras/freeCameraInputsManager" {
  19611. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  19612. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  19613. import { FreeCameraMouseInput } from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  19614. import { Nullable } from "babylonjs/types";
  19615. /**
  19616. * Default Inputs manager for the FreeCamera.
  19617. * It groups all the default supported inputs for ease of use.
  19618. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  19619. */
  19620. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  19621. /**
  19622. * @hidden
  19623. */
  19624. _mouseInput: Nullable<FreeCameraMouseInput>;
  19625. /**
  19626. * Instantiates a new FreeCameraInputsManager.
  19627. * @param camera Defines the camera the inputs belong to
  19628. */
  19629. constructor(camera: FreeCamera);
  19630. /**
  19631. * Add keyboard input support to the input manager.
  19632. * @returns the current input manager
  19633. */
  19634. addKeyboard(): FreeCameraInputsManager;
  19635. /**
  19636. * Add mouse input support to the input manager.
  19637. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  19638. * @returns the current input manager
  19639. */
  19640. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  19641. /**
  19642. * Removes the mouse input support from the manager
  19643. * @returns the current input manager
  19644. */
  19645. removeMouse(): FreeCameraInputsManager;
  19646. /**
  19647. * Add touch input support to the input manager.
  19648. * @returns the current input manager
  19649. */
  19650. addTouch(): FreeCameraInputsManager;
  19651. /**
  19652. * Remove all attached input methods from a camera
  19653. */
  19654. clear(): void;
  19655. }
  19656. }
  19657. declare module "babylonjs/Cameras/freeCamera" {
  19658. import { Vector3 } from "babylonjs/Maths/math.vector";
  19659. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  19660. import { Scene } from "babylonjs/scene";
  19661. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  19662. import { FreeCameraInputsManager } from "babylonjs/Cameras/freeCameraInputsManager";
  19663. /**
  19664. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19665. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  19666. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19667. */
  19668. export class FreeCamera extends TargetCamera {
  19669. /**
  19670. * Define the collision ellipsoid of the camera.
  19671. * This is helpful to simulate a camera body like the player body around the camera
  19672. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  19673. */
  19674. ellipsoid: Vector3;
  19675. /**
  19676. * Define an offset for the position of the ellipsoid around the camera.
  19677. * This can be helpful to determine the center of the body near the gravity center of the body
  19678. * instead of its head.
  19679. */
  19680. ellipsoidOffset: Vector3;
  19681. /**
  19682. * Enable or disable collisions of the camera with the rest of the scene objects.
  19683. */
  19684. checkCollisions: boolean;
  19685. /**
  19686. * Enable or disable gravity on the camera.
  19687. */
  19688. applyGravity: boolean;
  19689. /**
  19690. * Define the input manager associated to the camera.
  19691. */
  19692. inputs: FreeCameraInputsManager;
  19693. /**
  19694. * Gets the input sensibility for a mouse input. (default is 2000.0)
  19695. * Higher values reduce sensitivity.
  19696. */
  19697. get angularSensibility(): number;
  19698. /**
  19699. * Sets the input sensibility for a mouse input. (default is 2000.0)
  19700. * Higher values reduce sensitivity.
  19701. */
  19702. set angularSensibility(value: number);
  19703. /**
  19704. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  19705. */
  19706. get keysUp(): number[];
  19707. set keysUp(value: number[]);
  19708. /**
  19709. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  19710. */
  19711. get keysUpward(): number[];
  19712. set keysUpward(value: number[]);
  19713. /**
  19714. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  19715. */
  19716. get keysDown(): number[];
  19717. set keysDown(value: number[]);
  19718. /**
  19719. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  19720. */
  19721. get keysDownward(): number[];
  19722. set keysDownward(value: number[]);
  19723. /**
  19724. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  19725. */
  19726. get keysLeft(): number[];
  19727. set keysLeft(value: number[]);
  19728. /**
  19729. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  19730. */
  19731. get keysRight(): number[];
  19732. set keysRight(value: number[]);
  19733. /**
  19734. * Event raised when the camera collide with a mesh in the scene.
  19735. */
  19736. onCollide: (collidedMesh: AbstractMesh) => void;
  19737. private _collider;
  19738. private _needMoveForGravity;
  19739. private _oldPosition;
  19740. private _diffPosition;
  19741. private _newPosition;
  19742. /** @hidden */
  19743. _localDirection: Vector3;
  19744. /** @hidden */
  19745. _transformedDirection: Vector3;
  19746. /**
  19747. * Instantiates a Free Camera.
  19748. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  19749. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  19750. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  19751. * @param name Define the name of the camera in the scene
  19752. * @param position Define the start position of the camera in the scene
  19753. * @param scene Define the scene the camera belongs to
  19754. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  19755. */
  19756. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  19757. /**
  19758. * Attached controls to the current camera.
  19759. * @param element Defines the element the controls should be listened from
  19760. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19761. */
  19762. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  19763. /**
  19764. * Detach the current controls from the camera.
  19765. * The camera will stop reacting to inputs.
  19766. * @param element Defines the element to stop listening the inputs from
  19767. */
  19768. detachControl(element: HTMLElement): void;
  19769. private _collisionMask;
  19770. /**
  19771. * Define a collision mask to limit the list of object the camera can collide with
  19772. */
  19773. get collisionMask(): number;
  19774. set collisionMask(mask: number);
  19775. /** @hidden */
  19776. _collideWithWorld(displacement: Vector3): void;
  19777. private _onCollisionPositionChange;
  19778. /** @hidden */
  19779. _checkInputs(): void;
  19780. /** @hidden */
  19781. _decideIfNeedsToMove(): boolean;
  19782. /** @hidden */
  19783. _updatePosition(): void;
  19784. /**
  19785. * Destroy the camera and release the current resources hold by it.
  19786. */
  19787. dispose(): void;
  19788. /**
  19789. * Gets the current object class name.
  19790. * @return the class name
  19791. */
  19792. getClassName(): string;
  19793. }
  19794. }
  19795. declare module "babylonjs/Gamepads/gamepad" {
  19796. import { Observable } from "babylonjs/Misc/observable";
  19797. /**
  19798. * Represents a gamepad control stick position
  19799. */
  19800. export class StickValues {
  19801. /**
  19802. * The x component of the control stick
  19803. */
  19804. x: number;
  19805. /**
  19806. * The y component of the control stick
  19807. */
  19808. y: number;
  19809. /**
  19810. * Initializes the gamepad x and y control stick values
  19811. * @param x The x component of the gamepad control stick value
  19812. * @param y The y component of the gamepad control stick value
  19813. */
  19814. constructor(
  19815. /**
  19816. * The x component of the control stick
  19817. */
  19818. x: number,
  19819. /**
  19820. * The y component of the control stick
  19821. */
  19822. y: number);
  19823. }
  19824. /**
  19825. * An interface which manages callbacks for gamepad button changes
  19826. */
  19827. export interface GamepadButtonChanges {
  19828. /**
  19829. * Called when a gamepad has been changed
  19830. */
  19831. changed: boolean;
  19832. /**
  19833. * Called when a gamepad press event has been triggered
  19834. */
  19835. pressChanged: boolean;
  19836. /**
  19837. * Called when a touch event has been triggered
  19838. */
  19839. touchChanged: boolean;
  19840. /**
  19841. * Called when a value has changed
  19842. */
  19843. valueChanged: boolean;
  19844. }
  19845. /**
  19846. * Represents a gamepad
  19847. */
  19848. export class Gamepad {
  19849. /**
  19850. * The id of the gamepad
  19851. */
  19852. id: string;
  19853. /**
  19854. * The index of the gamepad
  19855. */
  19856. index: number;
  19857. /**
  19858. * The browser gamepad
  19859. */
  19860. browserGamepad: any;
  19861. /**
  19862. * Specifies what type of gamepad this represents
  19863. */
  19864. type: number;
  19865. private _leftStick;
  19866. private _rightStick;
  19867. /** @hidden */
  19868. _isConnected: boolean;
  19869. private _leftStickAxisX;
  19870. private _leftStickAxisY;
  19871. private _rightStickAxisX;
  19872. private _rightStickAxisY;
  19873. /**
  19874. * Triggered when the left control stick has been changed
  19875. */
  19876. private _onleftstickchanged;
  19877. /**
  19878. * Triggered when the right control stick has been changed
  19879. */
  19880. private _onrightstickchanged;
  19881. /**
  19882. * Represents a gamepad controller
  19883. */
  19884. static GAMEPAD: number;
  19885. /**
  19886. * Represents a generic controller
  19887. */
  19888. static GENERIC: number;
  19889. /**
  19890. * Represents an XBox controller
  19891. */
  19892. static XBOX: number;
  19893. /**
  19894. * Represents a pose-enabled controller
  19895. */
  19896. static POSE_ENABLED: number;
  19897. /**
  19898. * Represents an Dual Shock controller
  19899. */
  19900. static DUALSHOCK: number;
  19901. /**
  19902. * Specifies whether the left control stick should be Y-inverted
  19903. */
  19904. protected _invertLeftStickY: boolean;
  19905. /**
  19906. * Specifies if the gamepad has been connected
  19907. */
  19908. get isConnected(): boolean;
  19909. /**
  19910. * Initializes the gamepad
  19911. * @param id The id of the gamepad
  19912. * @param index The index of the gamepad
  19913. * @param browserGamepad The browser gamepad
  19914. * @param leftStickX The x component of the left joystick
  19915. * @param leftStickY The y component of the left joystick
  19916. * @param rightStickX The x component of the right joystick
  19917. * @param rightStickY The y component of the right joystick
  19918. */
  19919. constructor(
  19920. /**
  19921. * The id of the gamepad
  19922. */
  19923. id: string,
  19924. /**
  19925. * The index of the gamepad
  19926. */
  19927. index: number,
  19928. /**
  19929. * The browser gamepad
  19930. */
  19931. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  19932. /**
  19933. * Callback triggered when the left joystick has changed
  19934. * @param callback
  19935. */
  19936. onleftstickchanged(callback: (values: StickValues) => void): void;
  19937. /**
  19938. * Callback triggered when the right joystick has changed
  19939. * @param callback
  19940. */
  19941. onrightstickchanged(callback: (values: StickValues) => void): void;
  19942. /**
  19943. * Gets the left joystick
  19944. */
  19945. get leftStick(): StickValues;
  19946. /**
  19947. * Sets the left joystick values
  19948. */
  19949. set leftStick(newValues: StickValues);
  19950. /**
  19951. * Gets the right joystick
  19952. */
  19953. get rightStick(): StickValues;
  19954. /**
  19955. * Sets the right joystick value
  19956. */
  19957. set rightStick(newValues: StickValues);
  19958. /**
  19959. * Updates the gamepad joystick positions
  19960. */
  19961. update(): void;
  19962. /**
  19963. * Disposes the gamepad
  19964. */
  19965. dispose(): void;
  19966. }
  19967. /**
  19968. * Represents a generic gamepad
  19969. */
  19970. export class GenericPad extends Gamepad {
  19971. private _buttons;
  19972. private _onbuttondown;
  19973. private _onbuttonup;
  19974. /**
  19975. * Observable triggered when a button has been pressed
  19976. */
  19977. onButtonDownObservable: Observable<number>;
  19978. /**
  19979. * Observable triggered when a button has been released
  19980. */
  19981. onButtonUpObservable: Observable<number>;
  19982. /**
  19983. * Callback triggered when a button has been pressed
  19984. * @param callback Called when a button has been pressed
  19985. */
  19986. onbuttondown(callback: (buttonPressed: number) => void): void;
  19987. /**
  19988. * Callback triggered when a button has been released
  19989. * @param callback Called when a button has been released
  19990. */
  19991. onbuttonup(callback: (buttonReleased: number) => void): void;
  19992. /**
  19993. * Initializes the generic gamepad
  19994. * @param id The id of the generic gamepad
  19995. * @param index The index of the generic gamepad
  19996. * @param browserGamepad The browser gamepad
  19997. */
  19998. constructor(id: string, index: number, browserGamepad: any);
  19999. private _setButtonValue;
  20000. /**
  20001. * Updates the generic gamepad
  20002. */
  20003. update(): void;
  20004. /**
  20005. * Disposes the generic gamepad
  20006. */
  20007. dispose(): void;
  20008. }
  20009. }
  20010. declare module "babylonjs/Gamepads/Controllers/poseEnabledController" {
  20011. import { Observable } from "babylonjs/Misc/observable";
  20012. import { Nullable } from "babylonjs/types";
  20013. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20014. import { TransformNode } from "babylonjs/Meshes/transformNode";
  20015. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20016. import { Ray } from "babylonjs/Culling/ray";
  20017. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  20018. import { PoseControlled, DevicePose } from "babylonjs/Cameras/VR/webVRCamera";
  20019. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  20020. /**
  20021. * Defines the types of pose enabled controllers that are supported
  20022. */
  20023. export enum PoseEnabledControllerType {
  20024. /**
  20025. * HTC Vive
  20026. */
  20027. VIVE = 0,
  20028. /**
  20029. * Oculus Rift
  20030. */
  20031. OCULUS = 1,
  20032. /**
  20033. * Windows mixed reality
  20034. */
  20035. WINDOWS = 2,
  20036. /**
  20037. * Samsung gear VR
  20038. */
  20039. GEAR_VR = 3,
  20040. /**
  20041. * Google Daydream
  20042. */
  20043. DAYDREAM = 4,
  20044. /**
  20045. * Generic
  20046. */
  20047. GENERIC = 5
  20048. }
  20049. /**
  20050. * Defines the MutableGamepadButton interface for the state of a gamepad button
  20051. */
  20052. export interface MutableGamepadButton {
  20053. /**
  20054. * Value of the button/trigger
  20055. */
  20056. value: number;
  20057. /**
  20058. * If the button/trigger is currently touched
  20059. */
  20060. touched: boolean;
  20061. /**
  20062. * If the button/trigger is currently pressed
  20063. */
  20064. pressed: boolean;
  20065. }
  20066. /**
  20067. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  20068. * @hidden
  20069. */
  20070. export interface ExtendedGamepadButton extends GamepadButton {
  20071. /**
  20072. * If the button/trigger is currently pressed
  20073. */
  20074. readonly pressed: boolean;
  20075. /**
  20076. * If the button/trigger is currently touched
  20077. */
  20078. readonly touched: boolean;
  20079. /**
  20080. * Value of the button/trigger
  20081. */
  20082. readonly value: number;
  20083. }
  20084. /** @hidden */
  20085. export interface _GamePadFactory {
  20086. /**
  20087. * Returns whether or not the current gamepad can be created for this type of controller.
  20088. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20089. * @returns true if it can be created, otherwise false
  20090. */
  20091. canCreate(gamepadInfo: any): boolean;
  20092. /**
  20093. * Creates a new instance of the Gamepad.
  20094. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  20095. * @returns the new gamepad instance
  20096. */
  20097. create(gamepadInfo: any): Gamepad;
  20098. }
  20099. /**
  20100. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20101. */
  20102. export class PoseEnabledControllerHelper {
  20103. /** @hidden */
  20104. static _ControllerFactories: _GamePadFactory[];
  20105. /** @hidden */
  20106. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  20107. /**
  20108. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  20109. * @param vrGamepad the gamepad to initialized
  20110. * @returns a vr controller of the type the gamepad identified as
  20111. */
  20112. static InitiateController(vrGamepad: any): Gamepad;
  20113. }
  20114. /**
  20115. * Defines the PoseEnabledController object that contains state of a vr capable controller
  20116. */
  20117. export class PoseEnabledController extends Gamepad implements PoseControlled {
  20118. /**
  20119. * If the controller is used in a webXR session
  20120. */
  20121. isXR: boolean;
  20122. private _deviceRoomPosition;
  20123. private _deviceRoomRotationQuaternion;
  20124. /**
  20125. * The device position in babylon space
  20126. */
  20127. devicePosition: Vector3;
  20128. /**
  20129. * The device rotation in babylon space
  20130. */
  20131. deviceRotationQuaternion: Quaternion;
  20132. /**
  20133. * The scale factor of the device in babylon space
  20134. */
  20135. deviceScaleFactor: number;
  20136. /**
  20137. * (Likely devicePosition should be used instead) The device position in its room space
  20138. */
  20139. position: Vector3;
  20140. /**
  20141. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  20142. */
  20143. rotationQuaternion: Quaternion;
  20144. /**
  20145. * The type of controller (Eg. Windows mixed reality)
  20146. */
  20147. controllerType: PoseEnabledControllerType;
  20148. protected _calculatedPosition: Vector3;
  20149. private _calculatedRotation;
  20150. /**
  20151. * The raw pose from the device
  20152. */
  20153. rawPose: DevicePose;
  20154. private _trackPosition;
  20155. private _maxRotationDistFromHeadset;
  20156. private _draggedRoomRotation;
  20157. /**
  20158. * @hidden
  20159. */
  20160. _disableTrackPosition(fixedPosition: Vector3): void;
  20161. /**
  20162. * Internal, the mesh attached to the controller
  20163. * @hidden
  20164. */
  20165. _mesh: Nullable<AbstractMesh>;
  20166. private _poseControlledCamera;
  20167. private _leftHandSystemQuaternion;
  20168. /**
  20169. * Internal, matrix used to convert room space to babylon space
  20170. * @hidden
  20171. */
  20172. _deviceToWorld: Matrix;
  20173. /**
  20174. * Node to be used when casting a ray from the controller
  20175. * @hidden
  20176. */
  20177. _pointingPoseNode: Nullable<TransformNode>;
  20178. /**
  20179. * Name of the child mesh that can be used to cast a ray from the controller
  20180. */
  20181. static readonly POINTING_POSE: string;
  20182. /**
  20183. * Creates a new PoseEnabledController from a gamepad
  20184. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  20185. */
  20186. constructor(browserGamepad: any);
  20187. private _workingMatrix;
  20188. /**
  20189. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  20190. */
  20191. update(): void;
  20192. /**
  20193. * Updates only the pose device and mesh without doing any button event checking
  20194. */
  20195. protected _updatePoseAndMesh(): void;
  20196. /**
  20197. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  20198. * @param poseData raw pose fromthe device
  20199. */
  20200. updateFromDevice(poseData: DevicePose): void;
  20201. /**
  20202. * @hidden
  20203. */
  20204. _meshAttachedObservable: Observable<AbstractMesh>;
  20205. /**
  20206. * Attaches a mesh to the controller
  20207. * @param mesh the mesh to be attached
  20208. */
  20209. attachToMesh(mesh: AbstractMesh): void;
  20210. /**
  20211. * Attaches the controllers mesh to a camera
  20212. * @param camera the camera the mesh should be attached to
  20213. */
  20214. attachToPoseControlledCamera(camera: TargetCamera): void;
  20215. /**
  20216. * Disposes of the controller
  20217. */
  20218. dispose(): void;
  20219. /**
  20220. * The mesh that is attached to the controller
  20221. */
  20222. get mesh(): Nullable<AbstractMesh>;
  20223. /**
  20224. * Gets the ray of the controller in the direction the controller is pointing
  20225. * @param length the length the resulting ray should be
  20226. * @returns a ray in the direction the controller is pointing
  20227. */
  20228. getForwardRay(length?: number): Ray;
  20229. }
  20230. }
  20231. declare module "babylonjs/Gamepads/Controllers/webVRController" {
  20232. import { Observable } from "babylonjs/Misc/observable";
  20233. import { Scene } from "babylonjs/scene";
  20234. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20235. import { PoseEnabledController, ExtendedGamepadButton, MutableGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  20236. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  20237. import { Nullable } from "babylonjs/types";
  20238. /**
  20239. * Defines the WebVRController object that represents controllers tracked in 3D space
  20240. */
  20241. export abstract class WebVRController extends PoseEnabledController {
  20242. /**
  20243. * Internal, the default controller model for the controller
  20244. */
  20245. protected _defaultModel: Nullable<AbstractMesh>;
  20246. /**
  20247. * Fired when the trigger state has changed
  20248. */
  20249. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  20250. /**
  20251. * Fired when the main button state has changed
  20252. */
  20253. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20254. /**
  20255. * Fired when the secondary button state has changed
  20256. */
  20257. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  20258. /**
  20259. * Fired when the pad state has changed
  20260. */
  20261. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  20262. /**
  20263. * Fired when controllers stick values have changed
  20264. */
  20265. onPadValuesChangedObservable: Observable<StickValues>;
  20266. /**
  20267. * Array of button availible on the controller
  20268. */
  20269. protected _buttons: Array<MutableGamepadButton>;
  20270. private _onButtonStateChange;
  20271. /**
  20272. * Fired when a controller button's state has changed
  20273. * @param callback the callback containing the button that was modified
  20274. */
  20275. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  20276. /**
  20277. * X and Y axis corresponding to the controllers joystick
  20278. */
  20279. pad: StickValues;
  20280. /**
  20281. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  20282. */
  20283. hand: string;
  20284. /**
  20285. * The default controller model for the controller
  20286. */
  20287. get defaultModel(): Nullable<AbstractMesh>;
  20288. /**
  20289. * Creates a new WebVRController from a gamepad
  20290. * @param vrGamepad the gamepad that the WebVRController should be created from
  20291. */
  20292. constructor(vrGamepad: any);
  20293. /**
  20294. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  20295. */
  20296. update(): void;
  20297. /**
  20298. * Function to be called when a button is modified
  20299. */
  20300. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  20301. /**
  20302. * Loads a mesh and attaches it to the controller
  20303. * @param scene the scene the mesh should be added to
  20304. * @param meshLoaded callback for when the mesh has been loaded
  20305. */
  20306. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  20307. private _setButtonValue;
  20308. private _changes;
  20309. private _checkChanges;
  20310. /**
  20311. * Disposes of th webVRCOntroller
  20312. */
  20313. dispose(): void;
  20314. }
  20315. }
  20316. declare module "babylonjs/Lights/hemisphericLight" {
  20317. import { Nullable } from "babylonjs/types";
  20318. import { Scene } from "babylonjs/scene";
  20319. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20320. import { Color3 } from "babylonjs/Maths/math.color";
  20321. import { Effect } from "babylonjs/Materials/effect";
  20322. import { Light } from "babylonjs/Lights/light";
  20323. import { IShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  20324. /**
  20325. * The HemisphericLight simulates the ambient environment light,
  20326. * so the passed direction is the light reflection direction, not the incoming direction.
  20327. */
  20328. export class HemisphericLight extends Light {
  20329. /**
  20330. * The groundColor is the light in the opposite direction to the one specified during creation.
  20331. * 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.
  20332. */
  20333. groundColor: Color3;
  20334. /**
  20335. * The light reflection direction, not the incoming direction.
  20336. */
  20337. direction: Vector3;
  20338. /**
  20339. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  20340. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  20341. * The HemisphericLight can't cast shadows.
  20342. * Documentation : https://doc.babylonjs.com/babylon101/lights
  20343. * @param name The friendly name of the light
  20344. * @param direction The direction of the light reflection
  20345. * @param scene The scene the light belongs to
  20346. */
  20347. constructor(name: string, direction: Vector3, scene: Scene);
  20348. protected _buildUniformLayout(): void;
  20349. /**
  20350. * Returns the string "HemisphericLight".
  20351. * @return The class name
  20352. */
  20353. getClassName(): string;
  20354. /**
  20355. * Sets the HemisphericLight direction towards the passed target (Vector3).
  20356. * Returns the updated direction.
  20357. * @param target The target the direction should point to
  20358. * @return The computed direction
  20359. */
  20360. setDirectionToTarget(target: Vector3): Vector3;
  20361. /**
  20362. * Returns the shadow generator associated to the light.
  20363. * @returns Always null for hemispheric lights because it does not support shadows.
  20364. */
  20365. getShadowGenerator(): Nullable<IShadowGenerator>;
  20366. /**
  20367. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  20368. * @param effect The effect to update
  20369. * @param lightIndex The index of the light in the effect to update
  20370. * @returns The hemispheric light
  20371. */
  20372. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  20373. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  20374. /**
  20375. * Computes the world matrix of the node
  20376. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  20377. * @param useWasUpdatedFlag defines a reserved property
  20378. * @returns the world matrix
  20379. */
  20380. computeWorldMatrix(): Matrix;
  20381. /**
  20382. * Returns the integer 3.
  20383. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  20384. */
  20385. getTypeID(): number;
  20386. /**
  20387. * Prepares the list of defines specific to the light type.
  20388. * @param defines the list of defines
  20389. * @param lightIndex defines the index of the light for the effect
  20390. */
  20391. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  20392. }
  20393. }
  20394. declare module "babylonjs/Shaders/vrMultiviewToSingleview.fragment" {
  20395. /** @hidden */
  20396. export var vrMultiviewToSingleviewPixelShader: {
  20397. name: string;
  20398. shader: string;
  20399. };
  20400. }
  20401. declare module "babylonjs/Materials/Textures/MultiviewRenderTarget" {
  20402. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20403. import { Scene } from "babylonjs/scene";
  20404. /**
  20405. * Renders to multiple views with a single draw call
  20406. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  20407. */
  20408. export class MultiviewRenderTarget extends RenderTargetTexture {
  20409. /**
  20410. * Creates a multiview render target
  20411. * @param scene scene used with the render target
  20412. * @param size the size of the render target (used for each view)
  20413. */
  20414. constructor(scene: Scene, size?: number | {
  20415. width: number;
  20416. height: number;
  20417. } | {
  20418. ratio: number;
  20419. });
  20420. /**
  20421. * @hidden
  20422. * @param faceIndex the face index, if its a cube texture
  20423. */
  20424. _bindFrameBuffer(faceIndex?: number): void;
  20425. /**
  20426. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  20427. * @returns the view count
  20428. */
  20429. getViewCount(): number;
  20430. }
  20431. }
  20432. declare module "babylonjs/Engines/Extensions/engine.multiview" {
  20433. import { Camera } from "babylonjs/Cameras/camera";
  20434. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  20435. import { Nullable } from "babylonjs/types";
  20436. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  20437. import { Matrix } from "babylonjs/Maths/math.vector";
  20438. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20439. module "babylonjs/Engines/engine" {
  20440. interface Engine {
  20441. /**
  20442. * Creates a new multiview render target
  20443. * @param width defines the width of the texture
  20444. * @param height defines the height of the texture
  20445. * @returns the created multiview texture
  20446. */
  20447. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  20448. /**
  20449. * Binds a multiview framebuffer to be drawn to
  20450. * @param multiviewTexture texture to bind
  20451. */
  20452. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  20453. }
  20454. }
  20455. module "babylonjs/Cameras/camera" {
  20456. interface Camera {
  20457. /**
  20458. * @hidden
  20459. * 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)
  20460. */
  20461. _useMultiviewToSingleView: boolean;
  20462. /**
  20463. * @hidden
  20464. * 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)
  20465. */
  20466. _multiviewTexture: Nullable<RenderTargetTexture>;
  20467. /**
  20468. * @hidden
  20469. * ensures the multiview texture of the camera exists and has the specified width/height
  20470. * @param width height to set on the multiview texture
  20471. * @param height width to set on the multiview texture
  20472. */
  20473. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  20474. }
  20475. }
  20476. module "babylonjs/scene" {
  20477. interface Scene {
  20478. /** @hidden */
  20479. _transformMatrixR: Matrix;
  20480. /** @hidden */
  20481. _multiviewSceneUbo: Nullable<UniformBuffer>;
  20482. /** @hidden */
  20483. _createMultiviewUbo(): void;
  20484. /** @hidden */
  20485. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  20486. /** @hidden */
  20487. _renderMultiviewToSingleView(camera: Camera): void;
  20488. }
  20489. }
  20490. }
  20491. declare module "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess" {
  20492. import { Camera } from "babylonjs/Cameras/camera";
  20493. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  20494. import "babylonjs/Shaders/vrMultiviewToSingleview.fragment";
  20495. import "babylonjs/Engines/Extensions/engine.multiview";
  20496. /**
  20497. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  20498. * This will not be used for webXR as it supports displaying texture arrays directly
  20499. */
  20500. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  20501. /**
  20502. * Gets a string identifying the name of the class
  20503. * @returns "VRMultiviewToSingleviewPostProcess" string
  20504. */
  20505. getClassName(): string;
  20506. /**
  20507. * Initializes a VRMultiviewToSingleview
  20508. * @param name name of the post process
  20509. * @param camera camera to be applied to
  20510. * @param scaleFactor scaling factor to the size of the output texture
  20511. */
  20512. constructor(name: string, camera: Camera, scaleFactor: number);
  20513. }
  20514. }
  20515. declare module "babylonjs/Cameras/RigModes/webVRRigMode" { }
  20516. declare module "babylonjs/Engines/Extensions/engine.webVR" {
  20517. import { Nullable } from "babylonjs/types";
  20518. import { Size } from "babylonjs/Maths/math.size";
  20519. import { Observable } from "babylonjs/Misc/observable";
  20520. import { WebVROptions } from "babylonjs/Cameras/VR/webVRCamera";
  20521. /**
  20522. * Interface used to define additional presentation attributes
  20523. */
  20524. export interface IVRPresentationAttributes {
  20525. /**
  20526. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  20527. */
  20528. highRefreshRate: boolean;
  20529. /**
  20530. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  20531. */
  20532. foveationLevel: number;
  20533. }
  20534. module "babylonjs/Engines/engine" {
  20535. interface Engine {
  20536. /** @hidden */
  20537. _vrDisplay: any;
  20538. /** @hidden */
  20539. _vrSupported: boolean;
  20540. /** @hidden */
  20541. _oldSize: Size;
  20542. /** @hidden */
  20543. _oldHardwareScaleFactor: number;
  20544. /** @hidden */
  20545. _vrExclusivePointerMode: boolean;
  20546. /** @hidden */
  20547. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  20548. /** @hidden */
  20549. _onVRDisplayPointerRestricted: () => void;
  20550. /** @hidden */
  20551. _onVRDisplayPointerUnrestricted: () => void;
  20552. /** @hidden */
  20553. _onVrDisplayConnect: Nullable<(display: any) => void>;
  20554. /** @hidden */
  20555. _onVrDisplayDisconnect: Nullable<() => void>;
  20556. /** @hidden */
  20557. _onVrDisplayPresentChange: Nullable<() => void>;
  20558. /**
  20559. * Observable signaled when VR display mode changes
  20560. */
  20561. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  20562. /**
  20563. * Observable signaled when VR request present is complete
  20564. */
  20565. onVRRequestPresentComplete: Observable<boolean>;
  20566. /**
  20567. * Observable signaled when VR request present starts
  20568. */
  20569. onVRRequestPresentStart: Observable<Engine>;
  20570. /**
  20571. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  20572. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  20573. */
  20574. isInVRExclusivePointerMode: boolean;
  20575. /**
  20576. * Gets a boolean indicating if a webVR device was detected
  20577. * @returns true if a webVR device was detected
  20578. */
  20579. isVRDevicePresent(): boolean;
  20580. /**
  20581. * Gets the current webVR device
  20582. * @returns the current webVR device (or null)
  20583. */
  20584. getVRDevice(): any;
  20585. /**
  20586. * Initializes a webVR display and starts listening to display change events
  20587. * The onVRDisplayChangedObservable will be notified upon these changes
  20588. * @returns A promise containing a VRDisplay and if vr is supported
  20589. */
  20590. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  20591. /** @hidden */
  20592. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  20593. /**
  20594. * Gets or sets the presentation attributes used to configure VR rendering
  20595. */
  20596. vrPresentationAttributes?: IVRPresentationAttributes;
  20597. /**
  20598. * Call this function to switch to webVR mode
  20599. * Will do nothing if webVR is not supported or if there is no webVR device
  20600. * @param options the webvr options provided to the camera. mainly used for multiview
  20601. * @see https://doc.babylonjs.com/how_to/webvr_camera
  20602. */
  20603. enableVR(options: WebVROptions): void;
  20604. /** @hidden */
  20605. _onVRFullScreenTriggered(): void;
  20606. }
  20607. }
  20608. }
  20609. declare module "babylonjs/Cameras/VR/webVRCamera" {
  20610. import { Nullable } from "babylonjs/types";
  20611. import { Observable } from "babylonjs/Misc/observable";
  20612. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  20613. import { Scene } from "babylonjs/scene";
  20614. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  20615. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  20616. import { Node } from "babylonjs/node";
  20617. import { Ray } from "babylonjs/Culling/ray";
  20618. import "babylonjs/Cameras/RigModes/webVRRigMode";
  20619. import "babylonjs/Engines/Extensions/engine.webVR";
  20620. /**
  20621. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  20622. * IMPORTANT!! The data is right-hand data.
  20623. * @export
  20624. * @interface DevicePose
  20625. */
  20626. export interface DevicePose {
  20627. /**
  20628. * The position of the device, values in array are [x,y,z].
  20629. */
  20630. readonly position: Nullable<Float32Array>;
  20631. /**
  20632. * The linearVelocity of the device, values in array are [x,y,z].
  20633. */
  20634. readonly linearVelocity: Nullable<Float32Array>;
  20635. /**
  20636. * The linearAcceleration of the device, values in array are [x,y,z].
  20637. */
  20638. readonly linearAcceleration: Nullable<Float32Array>;
  20639. /**
  20640. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  20641. */
  20642. readonly orientation: Nullable<Float32Array>;
  20643. /**
  20644. * The angularVelocity of the device, values in array are [x,y,z].
  20645. */
  20646. readonly angularVelocity: Nullable<Float32Array>;
  20647. /**
  20648. * The angularAcceleration of the device, values in array are [x,y,z].
  20649. */
  20650. readonly angularAcceleration: Nullable<Float32Array>;
  20651. }
  20652. /**
  20653. * Interface representing a pose controlled object in Babylon.
  20654. * A pose controlled object has both regular pose values as well as pose values
  20655. * from an external device such as a VR head mounted display
  20656. */
  20657. export interface PoseControlled {
  20658. /**
  20659. * The position of the object in babylon space.
  20660. */
  20661. position: Vector3;
  20662. /**
  20663. * The rotation quaternion of the object in babylon space.
  20664. */
  20665. rotationQuaternion: Quaternion;
  20666. /**
  20667. * The position of the device in babylon space.
  20668. */
  20669. devicePosition?: Vector3;
  20670. /**
  20671. * The rotation quaternion of the device in babylon space.
  20672. */
  20673. deviceRotationQuaternion: Quaternion;
  20674. /**
  20675. * The raw pose coming from the device.
  20676. */
  20677. rawPose: Nullable<DevicePose>;
  20678. /**
  20679. * The scale of the device to be used when translating from device space to babylon space.
  20680. */
  20681. deviceScaleFactor: number;
  20682. /**
  20683. * Updates the poseControlled values based on the input device pose.
  20684. * @param poseData the pose data to update the object with
  20685. */
  20686. updateFromDevice(poseData: DevicePose): void;
  20687. }
  20688. /**
  20689. * Set of options to customize the webVRCamera
  20690. */
  20691. export interface WebVROptions {
  20692. /**
  20693. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  20694. */
  20695. trackPosition?: boolean;
  20696. /**
  20697. * Sets the scale of the vrDevice in babylon space. (default: 1)
  20698. */
  20699. positionScale?: number;
  20700. /**
  20701. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  20702. */
  20703. displayName?: string;
  20704. /**
  20705. * Should the native controller meshes be initialized. (default: true)
  20706. */
  20707. controllerMeshes?: boolean;
  20708. /**
  20709. * Creating a default HemiLight only on controllers. (default: true)
  20710. */
  20711. defaultLightingOnControllers?: boolean;
  20712. /**
  20713. * If you don't want to use the default VR button of the helper. (default: false)
  20714. */
  20715. useCustomVRButton?: boolean;
  20716. /**
  20717. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  20718. */
  20719. customVRButton?: HTMLButtonElement;
  20720. /**
  20721. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  20722. */
  20723. rayLength?: number;
  20724. /**
  20725. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  20726. */
  20727. defaultHeight?: number;
  20728. /**
  20729. * If multiview should be used if availible (default: false)
  20730. */
  20731. useMultiview?: boolean;
  20732. }
  20733. /**
  20734. * This represents a WebVR camera.
  20735. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  20736. * @example https://doc.babylonjs.com/how_to/webvr_camera
  20737. */
  20738. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  20739. private webVROptions;
  20740. /**
  20741. * @hidden
  20742. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  20743. */
  20744. _vrDevice: any;
  20745. /**
  20746. * The rawPose of the vrDevice.
  20747. */
  20748. rawPose: Nullable<DevicePose>;
  20749. private _onVREnabled;
  20750. private _specsVersion;
  20751. private _attached;
  20752. private _frameData;
  20753. protected _descendants: Array<Node>;
  20754. private _deviceRoomPosition;
  20755. /** @hidden */
  20756. _deviceRoomRotationQuaternion: Quaternion;
  20757. private _standingMatrix;
  20758. /**
  20759. * Represents device position in babylon space.
  20760. */
  20761. devicePosition: Vector3;
  20762. /**
  20763. * Represents device rotation in babylon space.
  20764. */
  20765. deviceRotationQuaternion: Quaternion;
  20766. /**
  20767. * The scale of the device to be used when translating from device space to babylon space.
  20768. */
  20769. deviceScaleFactor: number;
  20770. private _deviceToWorld;
  20771. private _worldToDevice;
  20772. /**
  20773. * References to the webVR controllers for the vrDevice.
  20774. */
  20775. controllers: Array<WebVRController>;
  20776. /**
  20777. * Emits an event when a controller is attached.
  20778. */
  20779. onControllersAttachedObservable: Observable<WebVRController[]>;
  20780. /**
  20781. * Emits an event when a controller's mesh has been loaded;
  20782. */
  20783. onControllerMeshLoadedObservable: Observable<WebVRController>;
  20784. /**
  20785. * Emits an event when the HMD's pose has been updated.
  20786. */
  20787. onPoseUpdatedFromDeviceObservable: Observable<any>;
  20788. private _poseSet;
  20789. /**
  20790. * If the rig cameras be used as parent instead of this camera.
  20791. */
  20792. rigParenting: boolean;
  20793. private _lightOnControllers;
  20794. private _defaultHeight?;
  20795. /**
  20796. * Instantiates a WebVRFreeCamera.
  20797. * @param name The name of the WebVRFreeCamera
  20798. * @param position The starting anchor position for the camera
  20799. * @param scene The scene the camera belongs to
  20800. * @param webVROptions a set of customizable options for the webVRCamera
  20801. */
  20802. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  20803. /**
  20804. * Gets the device distance from the ground in meters.
  20805. * @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.
  20806. */
  20807. deviceDistanceToRoomGround(): number;
  20808. /**
  20809. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20810. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  20811. */
  20812. useStandingMatrix(callback?: (bool: boolean) => void): void;
  20813. /**
  20814. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  20815. * @returns A promise with a boolean set to if the standing matrix is supported.
  20816. */
  20817. useStandingMatrixAsync(): Promise<boolean>;
  20818. /**
  20819. * Disposes the camera
  20820. */
  20821. dispose(): void;
  20822. /**
  20823. * Gets a vrController by name.
  20824. * @param name The name of the controller to retreive
  20825. * @returns the controller matching the name specified or null if not found
  20826. */
  20827. getControllerByName(name: string): Nullable<WebVRController>;
  20828. private _leftController;
  20829. /**
  20830. * The controller corresponding to the users left hand.
  20831. */
  20832. get leftController(): Nullable<WebVRController>;
  20833. private _rightController;
  20834. /**
  20835. * The controller corresponding to the users right hand.
  20836. */
  20837. get rightController(): Nullable<WebVRController>;
  20838. /**
  20839. * Casts a ray forward from the vrCamera's gaze.
  20840. * @param length Length of the ray (default: 100)
  20841. * @returns the ray corresponding to the gaze
  20842. */
  20843. getForwardRay(length?: number): Ray;
  20844. /**
  20845. * @hidden
  20846. * Updates the camera based on device's frame data
  20847. */
  20848. _checkInputs(): void;
  20849. /**
  20850. * Updates the poseControlled values based on the input device pose.
  20851. * @param poseData Pose coming from the device
  20852. */
  20853. updateFromDevice(poseData: DevicePose): void;
  20854. private _htmlElementAttached;
  20855. private _detachIfAttached;
  20856. /**
  20857. * WebVR's attach control will start broadcasting frames to the device.
  20858. * Note that in certain browsers (chrome for example) this function must be called
  20859. * within a user-interaction callback. Example:
  20860. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  20861. *
  20862. * @param element html element to attach the vrDevice to
  20863. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  20864. */
  20865. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  20866. /**
  20867. * Detaches the camera from the html element and disables VR
  20868. *
  20869. * @param element html element to detach from
  20870. */
  20871. detachControl(element: HTMLElement): void;
  20872. /**
  20873. * @returns the name of this class
  20874. */
  20875. getClassName(): string;
  20876. /**
  20877. * Calls resetPose on the vrDisplay
  20878. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  20879. */
  20880. resetToCurrentRotation(): void;
  20881. /**
  20882. * @hidden
  20883. * Updates the rig cameras (left and right eye)
  20884. */
  20885. _updateRigCameras(): void;
  20886. private _workingVector;
  20887. private _oneVector;
  20888. private _workingMatrix;
  20889. private updateCacheCalled;
  20890. private _correctPositionIfNotTrackPosition;
  20891. /**
  20892. * @hidden
  20893. * Updates the cached values of the camera
  20894. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  20895. */
  20896. _updateCache(ignoreParentClass?: boolean): void;
  20897. /**
  20898. * @hidden
  20899. * Get current device position in babylon world
  20900. */
  20901. _computeDevicePosition(): void;
  20902. /**
  20903. * Updates the current device position and rotation in the babylon world
  20904. */
  20905. update(): void;
  20906. /**
  20907. * @hidden
  20908. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  20909. * @returns an identity matrix
  20910. */
  20911. _getViewMatrix(): Matrix;
  20912. private _tmpMatrix;
  20913. /**
  20914. * This function is called by the two RIG cameras.
  20915. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  20916. * @hidden
  20917. */
  20918. _getWebVRViewMatrix(): Matrix;
  20919. /** @hidden */
  20920. _getWebVRProjectionMatrix(): Matrix;
  20921. private _onGamepadConnectedObserver;
  20922. private _onGamepadDisconnectedObserver;
  20923. private _updateCacheWhenTrackingDisabledObserver;
  20924. /**
  20925. * Initializes the controllers and their meshes
  20926. */
  20927. initControllers(): void;
  20928. }
  20929. }
  20930. declare module "babylonjs/Materials/materialHelper" {
  20931. import { Nullable } from "babylonjs/types";
  20932. import { Scene } from "babylonjs/scene";
  20933. import { Engine } from "babylonjs/Engines/engine";
  20934. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  20935. import { Light } from "babylonjs/Lights/light";
  20936. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  20937. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  20938. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  20939. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  20940. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  20941. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  20942. /**
  20943. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  20944. *
  20945. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  20946. *
  20947. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  20948. */
  20949. export class MaterialHelper {
  20950. /**
  20951. * Bind the current view position to an effect.
  20952. * @param effect The effect to be bound
  20953. * @param scene The scene the eyes position is used from
  20954. * @param variableName name of the shader variable that will hold the eye position
  20955. */
  20956. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  20957. /**
  20958. * Helps preparing the defines values about the UVs in used in the effect.
  20959. * UVs are shared as much as we can accross channels in the shaders.
  20960. * @param texture The texture we are preparing the UVs for
  20961. * @param defines The defines to update
  20962. * @param key The channel key "diffuse", "specular"... used in the shader
  20963. */
  20964. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  20965. /**
  20966. * Binds a texture matrix value to its corrsponding uniform
  20967. * @param texture The texture to bind the matrix for
  20968. * @param uniformBuffer The uniform buffer receivin the data
  20969. * @param key The channel key "diffuse", "specular"... used in the shader
  20970. */
  20971. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  20972. /**
  20973. * Gets the current status of the fog (should it be enabled?)
  20974. * @param mesh defines the mesh to evaluate for fog support
  20975. * @param scene defines the hosting scene
  20976. * @returns true if fog must be enabled
  20977. */
  20978. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  20979. /**
  20980. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  20981. * @param mesh defines the current mesh
  20982. * @param scene defines the current scene
  20983. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  20984. * @param pointsCloud defines if point cloud rendering has to be turned on
  20985. * @param fogEnabled defines if fog has to be turned on
  20986. * @param alphaTest defines if alpha testing has to be turned on
  20987. * @param defines defines the current list of defines
  20988. */
  20989. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  20990. /**
  20991. * Helper used to prepare the list of defines associated with frame values for shader compilation
  20992. * @param scene defines the current scene
  20993. * @param engine defines the current engine
  20994. * @param defines specifies the list of active defines
  20995. * @param useInstances defines if instances have to be turned on
  20996. * @param useClipPlane defines if clip plane have to be turned on
  20997. * @param useInstances defines if instances have to be turned on
  20998. * @param useThinInstances defines if thin instances have to be turned on
  20999. */
  21000. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  21001. /**
  21002. * Prepares the defines for bones
  21003. * @param mesh The mesh containing the geometry data we will draw
  21004. * @param defines The defines to update
  21005. */
  21006. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  21007. /**
  21008. * Prepares the defines for morph targets
  21009. * @param mesh The mesh containing the geometry data we will draw
  21010. * @param defines The defines to update
  21011. */
  21012. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  21013. /**
  21014. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  21015. * @param mesh The mesh containing the geometry data we will draw
  21016. * @param defines The defines to update
  21017. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  21018. * @param useBones Precise whether bones should be used or not (override mesh info)
  21019. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  21020. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  21021. * @returns false if defines are considered not dirty and have not been checked
  21022. */
  21023. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  21024. /**
  21025. * Prepares the defines related to multiview
  21026. * @param scene The scene we are intending to draw
  21027. * @param defines The defines to update
  21028. */
  21029. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  21030. /**
  21031. * Prepares the defines related to the prepass
  21032. * @param scene The scene we are intending to draw
  21033. * @param defines The defines to update
  21034. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  21035. */
  21036. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  21037. /**
  21038. * Prepares the defines related to the light information passed in parameter
  21039. * @param scene The scene we are intending to draw
  21040. * @param mesh The mesh the effect is compiling for
  21041. * @param light The light the effect is compiling for
  21042. * @param lightIndex The index of the light
  21043. * @param defines The defines to update
  21044. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21045. * @param state Defines the current state regarding what is needed (normals, etc...)
  21046. */
  21047. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  21048. needNormals: boolean;
  21049. needRebuild: boolean;
  21050. shadowEnabled: boolean;
  21051. specularEnabled: boolean;
  21052. lightmapMode: boolean;
  21053. }): void;
  21054. /**
  21055. * Prepares the defines related to the light information passed in parameter
  21056. * @param scene The scene we are intending to draw
  21057. * @param mesh The mesh the effect is compiling for
  21058. * @param defines The defines to update
  21059. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  21060. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  21061. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  21062. * @returns true if normals will be required for the rest of the effect
  21063. */
  21064. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  21065. /**
  21066. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  21067. * @param lightIndex defines the light index
  21068. * @param uniformsList The uniform list
  21069. * @param samplersList The sampler list
  21070. * @param projectedLightTexture defines if projected texture must be used
  21071. * @param uniformBuffersList defines an optional list of uniform buffers
  21072. */
  21073. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  21074. /**
  21075. * Prepares the uniforms and samplers list to be used in the effect
  21076. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  21077. * @param samplersList The sampler list
  21078. * @param defines The defines helping in the list generation
  21079. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  21080. */
  21081. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  21082. /**
  21083. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  21084. * @param defines The defines to update while falling back
  21085. * @param fallbacks The authorized effect fallbacks
  21086. * @param maxSimultaneousLights The maximum number of lights allowed
  21087. * @param rank the current rank of the Effect
  21088. * @returns The newly affected rank
  21089. */
  21090. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  21091. private static _TmpMorphInfluencers;
  21092. /**
  21093. * Prepares the list of attributes required for morph targets according to the effect defines.
  21094. * @param attribs The current list of supported attribs
  21095. * @param mesh The mesh to prepare the morph targets attributes for
  21096. * @param influencers The number of influencers
  21097. */
  21098. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  21099. /**
  21100. * Prepares the list of attributes required for morph targets according to the effect defines.
  21101. * @param attribs The current list of supported attribs
  21102. * @param mesh The mesh to prepare the morph targets attributes for
  21103. * @param defines The current Defines of the effect
  21104. */
  21105. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  21106. /**
  21107. * Prepares the list of attributes required for bones according to the effect defines.
  21108. * @param attribs The current list of supported attribs
  21109. * @param mesh The mesh to prepare the bones attributes for
  21110. * @param defines The current Defines of the effect
  21111. * @param fallbacks The current efffect fallback strategy
  21112. */
  21113. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  21114. /**
  21115. * Check and prepare the list of attributes required for instances according to the effect defines.
  21116. * @param attribs The current list of supported attribs
  21117. * @param defines The current MaterialDefines of the effect
  21118. */
  21119. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  21120. /**
  21121. * Add the list of attributes required for instances to the attribs array.
  21122. * @param attribs The current list of supported attribs
  21123. */
  21124. static PushAttributesForInstances(attribs: string[]): void;
  21125. /**
  21126. * Binds the light information to the effect.
  21127. * @param light The light containing the generator
  21128. * @param effect The effect we are binding the data to
  21129. * @param lightIndex The light index in the effect used to render
  21130. */
  21131. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  21132. /**
  21133. * Binds the lights information from the scene to the effect for the given mesh.
  21134. * @param light Light to bind
  21135. * @param lightIndex Light index
  21136. * @param scene The scene where the light belongs to
  21137. * @param effect The effect we are binding the data to
  21138. * @param useSpecular Defines if specular is supported
  21139. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21140. */
  21141. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  21142. /**
  21143. * Binds the lights information from the scene to the effect for the given mesh.
  21144. * @param scene The scene the lights belongs to
  21145. * @param mesh The mesh we are binding the information to render
  21146. * @param effect The effect we are binding the data to
  21147. * @param defines The generated defines for the effect
  21148. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  21149. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  21150. */
  21151. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  21152. private static _tempFogColor;
  21153. /**
  21154. * Binds the fog information from the scene to the effect for the given mesh.
  21155. * @param scene The scene the lights belongs to
  21156. * @param mesh The mesh we are binding the information to render
  21157. * @param effect The effect we are binding the data to
  21158. * @param linearSpace Defines if the fog effect is applied in linear space
  21159. */
  21160. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  21161. /**
  21162. * Binds the bones information from the mesh to the effect.
  21163. * @param mesh The mesh we are binding the information to render
  21164. * @param effect The effect we are binding the data to
  21165. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  21166. */
  21167. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  21168. private static _CopyBonesTransformationMatrices;
  21169. /**
  21170. * Binds the morph targets information from the mesh to the effect.
  21171. * @param abstractMesh The mesh we are binding the information to render
  21172. * @param effect The effect we are binding the data to
  21173. */
  21174. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  21175. /**
  21176. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  21177. * @param defines The generated defines used in the effect
  21178. * @param effect The effect we are binding the data to
  21179. * @param scene The scene we are willing to render with logarithmic scale for
  21180. */
  21181. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  21182. /**
  21183. * Binds the clip plane information from the scene to the effect.
  21184. * @param scene The scene the clip plane information are extracted from
  21185. * @param effect The effect we are binding the data to
  21186. */
  21187. static BindClipPlane(effect: Effect, scene: Scene): void;
  21188. }
  21189. }
  21190. declare module "babylonjs/Materials/Node/Blocks/Input/inputBlock" {
  21191. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21192. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21193. import { NodeMaterialSystemValues } from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  21194. import { Nullable } from "babylonjs/types";
  21195. import { Effect } from "babylonjs/Materials/effect";
  21196. import { Matrix } from "babylonjs/Maths/math.vector";
  21197. import { Scene } from "babylonjs/scene";
  21198. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21199. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21200. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21201. import { AnimatedInputBlockTypes } from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  21202. import { Observable } from "babylonjs/Misc/observable";
  21203. /**
  21204. * Block used to expose an input value
  21205. */
  21206. export class InputBlock extends NodeMaterialBlock {
  21207. private _mode;
  21208. private _associatedVariableName;
  21209. private _storedValue;
  21210. private _valueCallback;
  21211. private _type;
  21212. private _animationType;
  21213. /** Gets or set a value used to limit the range of float values */
  21214. min: number;
  21215. /** Gets or set a value used to limit the range of float values */
  21216. max: number;
  21217. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  21218. isBoolean: boolean;
  21219. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  21220. matrixMode: number;
  21221. /** @hidden */
  21222. _systemValue: Nullable<NodeMaterialSystemValues>;
  21223. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  21224. isConstant: boolean;
  21225. /** Gets or sets the group to use to display this block in the Inspector */
  21226. groupInInspector: string;
  21227. /** Gets an observable raised when the value is changed */
  21228. onValueChangedObservable: Observable<InputBlock>;
  21229. /**
  21230. * Gets or sets the connection point type (default is float)
  21231. */
  21232. get type(): NodeMaterialBlockConnectionPointTypes;
  21233. /**
  21234. * Creates a new InputBlock
  21235. * @param name defines the block name
  21236. * @param target defines the target of that block (Vertex by default)
  21237. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  21238. */
  21239. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  21240. /**
  21241. * Validates if a name is a reserve word.
  21242. * @param newName the new name to be given to the node.
  21243. * @returns false if the name is a reserve word, else true.
  21244. */
  21245. validateBlockName(newName: string): boolean;
  21246. /**
  21247. * Gets the output component
  21248. */
  21249. get output(): NodeMaterialConnectionPoint;
  21250. /**
  21251. * Set the source of this connection point to a vertex attribute
  21252. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  21253. * @returns the current connection point
  21254. */
  21255. setAsAttribute(attributeName?: string): InputBlock;
  21256. /**
  21257. * Set the source of this connection point to a system value
  21258. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  21259. * @returns the current connection point
  21260. */
  21261. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  21262. /**
  21263. * Gets or sets the value of that point.
  21264. * Please note that this value will be ignored if valueCallback is defined
  21265. */
  21266. get value(): any;
  21267. set value(value: any);
  21268. /**
  21269. * Gets or sets a callback used to get the value of that point.
  21270. * Please note that setting this value will force the connection point to ignore the value property
  21271. */
  21272. get valueCallback(): () => any;
  21273. set valueCallback(value: () => any);
  21274. /**
  21275. * Gets or sets the associated variable name in the shader
  21276. */
  21277. get associatedVariableName(): string;
  21278. set associatedVariableName(value: string);
  21279. /** Gets or sets the type of animation applied to the input */
  21280. get animationType(): AnimatedInputBlockTypes;
  21281. set animationType(value: AnimatedInputBlockTypes);
  21282. /**
  21283. * Gets a boolean indicating that this connection point not defined yet
  21284. */
  21285. get isUndefined(): boolean;
  21286. /**
  21287. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  21288. * In this case the connection point name must be the name of the uniform to use.
  21289. * Can only be set on inputs
  21290. */
  21291. get isUniform(): boolean;
  21292. set isUniform(value: boolean);
  21293. /**
  21294. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  21295. * In this case the connection point name must be the name of the attribute to use
  21296. * Can only be set on inputs
  21297. */
  21298. get isAttribute(): boolean;
  21299. set isAttribute(value: boolean);
  21300. /**
  21301. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  21302. * Can only be set on exit points
  21303. */
  21304. get isVarying(): boolean;
  21305. set isVarying(value: boolean);
  21306. /**
  21307. * Gets a boolean indicating that the current connection point is a system value
  21308. */
  21309. get isSystemValue(): boolean;
  21310. /**
  21311. * Gets or sets the current well known value or null if not defined as a system value
  21312. */
  21313. get systemValue(): Nullable<NodeMaterialSystemValues>;
  21314. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  21315. /**
  21316. * Gets the current class name
  21317. * @returns the class name
  21318. */
  21319. getClassName(): string;
  21320. /**
  21321. * Animate the input if animationType !== None
  21322. * @param scene defines the rendering scene
  21323. */
  21324. animate(scene: Scene): void;
  21325. private _emitDefine;
  21326. initialize(state: NodeMaterialBuildState): void;
  21327. /**
  21328. * Set the input block to its default value (based on its type)
  21329. */
  21330. setDefaultValue(): void;
  21331. private _emitConstant;
  21332. /** @hidden */
  21333. get _noContextSwitch(): boolean;
  21334. private _emit;
  21335. /** @hidden */
  21336. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  21337. /** @hidden */
  21338. _transmit(effect: Effect, scene: Scene): void;
  21339. protected _buildBlock(state: NodeMaterialBuildState): void;
  21340. protected _dumpPropertiesCode(): string;
  21341. dispose(): void;
  21342. serialize(): any;
  21343. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21344. }
  21345. }
  21346. declare module "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint" {
  21347. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  21348. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21349. import { Nullable } from "babylonjs/types";
  21350. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  21351. import { Observable } from "babylonjs/Misc/observable";
  21352. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21353. /**
  21354. * Enum used to define the compatibility state between two connection points
  21355. */
  21356. export enum NodeMaterialConnectionPointCompatibilityStates {
  21357. /** Points are compatibles */
  21358. Compatible = 0,
  21359. /** Points are incompatible because of their types */
  21360. TypeIncompatible = 1,
  21361. /** Points are incompatible because of their targets (vertex vs fragment) */
  21362. TargetIncompatible = 2
  21363. }
  21364. /**
  21365. * Defines the direction of a connection point
  21366. */
  21367. export enum NodeMaterialConnectionPointDirection {
  21368. /** Input */
  21369. Input = 0,
  21370. /** Output */
  21371. Output = 1
  21372. }
  21373. /**
  21374. * Defines a connection point for a block
  21375. */
  21376. export class NodeMaterialConnectionPoint {
  21377. /** @hidden */
  21378. _ownerBlock: NodeMaterialBlock;
  21379. /** @hidden */
  21380. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  21381. private _endpoints;
  21382. private _associatedVariableName;
  21383. private _direction;
  21384. /** @hidden */
  21385. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21386. /** @hidden */
  21387. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  21388. private _type;
  21389. /** @hidden */
  21390. _enforceAssociatedVariableName: boolean;
  21391. /** Gets the direction of the point */
  21392. get direction(): NodeMaterialConnectionPointDirection;
  21393. /** Indicates that this connection point needs dual validation before being connected to another point */
  21394. needDualDirectionValidation: boolean;
  21395. /**
  21396. * Gets or sets the additional types supported by this connection point
  21397. */
  21398. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21399. /**
  21400. * Gets or sets the additional types excluded by this connection point
  21401. */
  21402. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  21403. /**
  21404. * Observable triggered when this point is connected
  21405. */
  21406. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  21407. /**
  21408. * Gets or sets the associated variable name in the shader
  21409. */
  21410. get associatedVariableName(): string;
  21411. set associatedVariableName(value: string);
  21412. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  21413. get innerType(): NodeMaterialBlockConnectionPointTypes;
  21414. /**
  21415. * Gets or sets the connection point type (default is float)
  21416. */
  21417. get type(): NodeMaterialBlockConnectionPointTypes;
  21418. set type(value: NodeMaterialBlockConnectionPointTypes);
  21419. /**
  21420. * Gets or sets the connection point name
  21421. */
  21422. name: string;
  21423. /**
  21424. * Gets or sets the connection point name
  21425. */
  21426. displayName: string;
  21427. /**
  21428. * Gets or sets a boolean indicating that this connection point can be omitted
  21429. */
  21430. isOptional: boolean;
  21431. /**
  21432. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  21433. */
  21434. isExposedOnFrame: boolean;
  21435. /**
  21436. * Gets or sets number indicating the position that the port is exposed to on a frame
  21437. */
  21438. exposedPortPosition: number;
  21439. /**
  21440. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  21441. */
  21442. define: string;
  21443. /** @hidden */
  21444. _prioritizeVertex: boolean;
  21445. private _target;
  21446. /** Gets or sets the target of that connection point */
  21447. get target(): NodeMaterialBlockTargets;
  21448. set target(value: NodeMaterialBlockTargets);
  21449. /**
  21450. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  21451. */
  21452. get isConnected(): boolean;
  21453. /**
  21454. * Gets a boolean indicating that the current point is connected to an input block
  21455. */
  21456. get isConnectedToInputBlock(): boolean;
  21457. /**
  21458. * Gets a the connected input block (if any)
  21459. */
  21460. get connectInputBlock(): Nullable<InputBlock>;
  21461. /** Get the other side of the connection (if any) */
  21462. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  21463. /** Get the block that owns this connection point */
  21464. get ownerBlock(): NodeMaterialBlock;
  21465. /** Get the block connected on the other side of this connection (if any) */
  21466. get sourceBlock(): Nullable<NodeMaterialBlock>;
  21467. /** Get the block connected on the endpoints of this connection (if any) */
  21468. get connectedBlocks(): Array<NodeMaterialBlock>;
  21469. /** Gets the list of connected endpoints */
  21470. get endpoints(): NodeMaterialConnectionPoint[];
  21471. /** Gets a boolean indicating if that output point is connected to at least one input */
  21472. get hasEndpoints(): boolean;
  21473. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  21474. get isConnectedInVertexShader(): boolean;
  21475. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  21476. get isConnectedInFragmentShader(): boolean;
  21477. /**
  21478. * Creates a block suitable to be used as an input for this input point.
  21479. * If null is returned, a block based on the point type will be created.
  21480. * @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
  21481. */
  21482. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21483. /**
  21484. * Creates a new connection point
  21485. * @param name defines the connection point name
  21486. * @param ownerBlock defines the block hosting this connection point
  21487. * @param direction defines the direction of the connection point
  21488. */
  21489. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  21490. /**
  21491. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  21492. * @returns the class name
  21493. */
  21494. getClassName(): string;
  21495. /**
  21496. * Gets a boolean indicating if the current point can be connected to another point
  21497. * @param connectionPoint defines the other connection point
  21498. * @returns a boolean
  21499. */
  21500. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  21501. /**
  21502. * Gets a number indicating if the current point can be connected to another point
  21503. * @param connectionPoint defines the other connection point
  21504. * @returns a number defining the compatibility state
  21505. */
  21506. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21507. /**
  21508. * Connect this point to another connection point
  21509. * @param connectionPoint defines the other connection point
  21510. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  21511. * @returns the current connection point
  21512. */
  21513. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  21514. /**
  21515. * Disconnect this point from one of his endpoint
  21516. * @param endpoint defines the other connection point
  21517. * @returns the current connection point
  21518. */
  21519. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  21520. /**
  21521. * Serializes this point in a JSON representation
  21522. * @param isInput defines if the connection point is an input (default is true)
  21523. * @returns the serialized point object
  21524. */
  21525. serialize(isInput?: boolean): any;
  21526. /**
  21527. * Release resources
  21528. */
  21529. dispose(): void;
  21530. }
  21531. }
  21532. declare module "babylonjs/Materials/Node/Enums/nodeMaterialModes" {
  21533. /**
  21534. * Enum used to define the material modes
  21535. */
  21536. export enum NodeMaterialModes {
  21537. /** Regular material */
  21538. Material = 0,
  21539. /** For post process */
  21540. PostProcess = 1,
  21541. /** For particle system */
  21542. Particle = 2,
  21543. /** For procedural texture */
  21544. ProceduralTexture = 3
  21545. }
  21546. }
  21547. declare module "babylonjs/Materials/Node/Blocks/Dual/textureBlock" {
  21548. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21549. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21550. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21552. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21553. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21554. import { Effect } from "babylonjs/Materials/effect";
  21555. import { Mesh } from "babylonjs/Meshes/mesh";
  21556. import { Nullable } from "babylonjs/types";
  21557. import { Texture } from "babylonjs/Materials/Textures/texture";
  21558. import { Scene } from "babylonjs/scene";
  21559. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  21560. /**
  21561. * Block used to read a texture from a sampler
  21562. */
  21563. export class TextureBlock extends NodeMaterialBlock {
  21564. private _defineName;
  21565. private _linearDefineName;
  21566. private _gammaDefineName;
  21567. private _tempTextureRead;
  21568. private _samplerName;
  21569. private _transformedUVName;
  21570. private _textureTransformName;
  21571. private _textureInfoName;
  21572. private _mainUVName;
  21573. private _mainUVDefineName;
  21574. private _fragmentOnly;
  21575. /**
  21576. * Gets or sets the texture associated with the node
  21577. */
  21578. texture: Nullable<Texture>;
  21579. /**
  21580. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  21581. */
  21582. convertToGammaSpace: boolean;
  21583. /**
  21584. * Gets or sets a boolean indicating if content needs to be converted to linear space
  21585. */
  21586. convertToLinearSpace: boolean;
  21587. /**
  21588. * Create a new TextureBlock
  21589. * @param name defines the block name
  21590. */
  21591. constructor(name: string, fragmentOnly?: boolean);
  21592. /**
  21593. * Gets the current class name
  21594. * @returns the class name
  21595. */
  21596. getClassName(): string;
  21597. /**
  21598. * Gets the uv input component
  21599. */
  21600. get uv(): NodeMaterialConnectionPoint;
  21601. /**
  21602. * Gets the rgba output component
  21603. */
  21604. get rgba(): NodeMaterialConnectionPoint;
  21605. /**
  21606. * Gets the rgb output component
  21607. */
  21608. get rgb(): NodeMaterialConnectionPoint;
  21609. /**
  21610. * Gets the r output component
  21611. */
  21612. get r(): NodeMaterialConnectionPoint;
  21613. /**
  21614. * Gets the g output component
  21615. */
  21616. get g(): NodeMaterialConnectionPoint;
  21617. /**
  21618. * Gets the b output component
  21619. */
  21620. get b(): NodeMaterialConnectionPoint;
  21621. /**
  21622. * Gets the a output component
  21623. */
  21624. get a(): NodeMaterialConnectionPoint;
  21625. get target(): NodeMaterialBlockTargets;
  21626. autoConfigure(material: NodeMaterial): void;
  21627. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  21628. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21629. isReady(): boolean;
  21630. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21631. private get _isMixed();
  21632. private _injectVertexCode;
  21633. private _writeTextureRead;
  21634. private _writeOutput;
  21635. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  21636. protected _dumpPropertiesCode(): string;
  21637. serialize(): any;
  21638. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21639. }
  21640. }
  21641. declare module "babylonjs/Shaders/ShadersInclude/reflectionFunction" {
  21642. /** @hidden */
  21643. export var reflectionFunction: {
  21644. name: string;
  21645. shader: string;
  21646. };
  21647. }
  21648. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock" {
  21649. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21650. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21651. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21652. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21654. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21655. import { Effect } from "babylonjs/Materials/effect";
  21656. import { Mesh } from "babylonjs/Meshes/mesh";
  21657. import { Nullable } from "babylonjs/types";
  21658. import { Scene } from "babylonjs/scene";
  21659. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  21660. /**
  21661. * Base block used to read a reflection texture from a sampler
  21662. */
  21663. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  21664. /** @hidden */
  21665. _define3DName: string;
  21666. /** @hidden */
  21667. _defineCubicName: string;
  21668. /** @hidden */
  21669. _defineExplicitName: string;
  21670. /** @hidden */
  21671. _defineProjectionName: string;
  21672. /** @hidden */
  21673. _defineLocalCubicName: string;
  21674. /** @hidden */
  21675. _defineSphericalName: string;
  21676. /** @hidden */
  21677. _definePlanarName: string;
  21678. /** @hidden */
  21679. _defineEquirectangularName: string;
  21680. /** @hidden */
  21681. _defineMirroredEquirectangularFixedName: string;
  21682. /** @hidden */
  21683. _defineEquirectangularFixedName: string;
  21684. /** @hidden */
  21685. _defineSkyboxName: string;
  21686. /** @hidden */
  21687. _defineOppositeZ: string;
  21688. /** @hidden */
  21689. _cubeSamplerName: string;
  21690. /** @hidden */
  21691. _2DSamplerName: string;
  21692. protected _positionUVWName: string;
  21693. protected _directionWName: string;
  21694. protected _reflectionVectorName: string;
  21695. /** @hidden */
  21696. _reflectionCoordsName: string;
  21697. /** @hidden */
  21698. _reflectionMatrixName: string;
  21699. protected _reflectionColorName: string;
  21700. /**
  21701. * Gets or sets the texture associated with the node
  21702. */
  21703. texture: Nullable<BaseTexture>;
  21704. /**
  21705. * Create a new ReflectionTextureBaseBlock
  21706. * @param name defines the block name
  21707. */
  21708. constructor(name: string);
  21709. /**
  21710. * Gets the current class name
  21711. * @returns the class name
  21712. */
  21713. getClassName(): string;
  21714. /**
  21715. * Gets the world position input component
  21716. */
  21717. abstract get position(): NodeMaterialConnectionPoint;
  21718. /**
  21719. * Gets the world position input component
  21720. */
  21721. abstract get worldPosition(): NodeMaterialConnectionPoint;
  21722. /**
  21723. * Gets the world normal input component
  21724. */
  21725. abstract get worldNormal(): NodeMaterialConnectionPoint;
  21726. /**
  21727. * Gets the world input component
  21728. */
  21729. abstract get world(): NodeMaterialConnectionPoint;
  21730. /**
  21731. * Gets the camera (or eye) position component
  21732. */
  21733. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  21734. /**
  21735. * Gets the view input component
  21736. */
  21737. abstract get view(): NodeMaterialConnectionPoint;
  21738. protected _getTexture(): Nullable<BaseTexture>;
  21739. autoConfigure(material: NodeMaterial): void;
  21740. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21741. isReady(): boolean;
  21742. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  21743. /**
  21744. * Gets the code to inject in the vertex shader
  21745. * @param state current state of the node material building
  21746. * @returns the shader code
  21747. */
  21748. handleVertexSide(state: NodeMaterialBuildState): string;
  21749. /**
  21750. * Handles the inits for the fragment code path
  21751. * @param state node material build state
  21752. */
  21753. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  21754. /**
  21755. * Generates the reflection coords code for the fragment code path
  21756. * @param worldNormalVarName name of the world normal variable
  21757. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  21758. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  21759. * @returns the shader code
  21760. */
  21761. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  21762. /**
  21763. * Generates the reflection color code for the fragment code path
  21764. * @param lodVarName name of the lod variable
  21765. * @param swizzleLookupTexture swizzle to use for the final color variable
  21766. * @returns the shader code
  21767. */
  21768. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  21769. /**
  21770. * Generates the code corresponding to the connected output points
  21771. * @param state node material build state
  21772. * @param varName name of the variable to output
  21773. * @returns the shader code
  21774. */
  21775. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  21776. protected _buildBlock(state: NodeMaterialBuildState): this;
  21777. protected _dumpPropertiesCode(): string;
  21778. serialize(): any;
  21779. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21780. }
  21781. }
  21782. declare module "babylonjs/Materials/Node/nodeMaterialConnectionPointCustomObject" {
  21783. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21784. import { NodeMaterialConnectionPoint, NodeMaterialConnectionPointDirection, NodeMaterialConnectionPointCompatibilityStates } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21785. import { Nullable } from "babylonjs/types";
  21786. /**
  21787. * Defines a connection point to be used for points with a custom object type
  21788. */
  21789. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  21790. private _blockType;
  21791. private _blockName;
  21792. private _nameForCheking?;
  21793. /**
  21794. * Creates a new connection point
  21795. * @param name defines the connection point name
  21796. * @param ownerBlock defines the block hosting this connection point
  21797. * @param direction defines the direction of the connection point
  21798. */
  21799. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  21800. /**
  21801. * Gets a number indicating if the current point can be connected to another point
  21802. * @param connectionPoint defines the other connection point
  21803. * @returns a number defining the compatibility state
  21804. */
  21805. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  21806. /**
  21807. * Creates a block suitable to be used as an input for this input point.
  21808. * If null is returned, a block based on the point type will be created.
  21809. * @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
  21810. */
  21811. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  21812. }
  21813. }
  21814. declare module "babylonjs/Materials/Node/nodeMaterialDecorator" {
  21815. /**
  21816. * Enum defining the type of properties that can be edited in the property pages in the NME
  21817. */
  21818. export enum PropertyTypeForEdition {
  21819. /** property is a boolean */
  21820. Boolean = 0,
  21821. /** property is a float */
  21822. Float = 1,
  21823. /** property is a Vector2 */
  21824. Vector2 = 2,
  21825. /** property is a list of values */
  21826. List = 3
  21827. }
  21828. /**
  21829. * Interface that defines an option in a variable of type list
  21830. */
  21831. export interface IEditablePropertyListOption {
  21832. /** label of the option */
  21833. "label": string;
  21834. /** value of the option */
  21835. "value": number;
  21836. }
  21837. /**
  21838. * Interface that defines the options available for an editable property
  21839. */
  21840. export interface IEditablePropertyOption {
  21841. /** min value */
  21842. "min"?: number;
  21843. /** max value */
  21844. "max"?: number;
  21845. /** notifiers: indicates which actions to take when the property is changed */
  21846. "notifiers"?: {
  21847. /** the material should be rebuilt */
  21848. "rebuild"?: boolean;
  21849. /** the preview should be updated */
  21850. "update"?: boolean;
  21851. };
  21852. /** list of the options for a variable of type list */
  21853. "options"?: IEditablePropertyListOption[];
  21854. }
  21855. /**
  21856. * Interface that describes an editable property
  21857. */
  21858. export interface IPropertyDescriptionForEdition {
  21859. /** name of the property */
  21860. "propertyName": string;
  21861. /** display name of the property */
  21862. "displayName": string;
  21863. /** type of the property */
  21864. "type": PropertyTypeForEdition;
  21865. /** group of the property - all properties with the same group value will be displayed in a specific section */
  21866. "groupName": string;
  21867. /** options for the property */
  21868. "options": IEditablePropertyOption;
  21869. }
  21870. /**
  21871. * Decorator that flags a property in a node material block as being editable
  21872. */
  21873. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  21874. }
  21875. declare module "babylonjs/Materials/Node/Blocks/PBR/refractionBlock" {
  21876. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21877. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21878. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21879. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21880. import { Nullable } from "babylonjs/types";
  21881. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21882. import { Mesh } from "babylonjs/Meshes/mesh";
  21883. import { SubMesh } from "babylonjs/Meshes/subMesh";
  21884. import { Effect } from "babylonjs/Materials/effect";
  21885. import { Scene } from "babylonjs/scene";
  21886. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21887. /**
  21888. * Block used to implement the refraction part of the sub surface module of the PBR material
  21889. */
  21890. export class RefractionBlock extends NodeMaterialBlock {
  21891. /** @hidden */
  21892. _define3DName: string;
  21893. /** @hidden */
  21894. _refractionMatrixName: string;
  21895. /** @hidden */
  21896. _defineLODRefractionAlpha: string;
  21897. /** @hidden */
  21898. _defineLinearSpecularRefraction: string;
  21899. /** @hidden */
  21900. _defineOppositeZ: string;
  21901. /** @hidden */
  21902. _cubeSamplerName: string;
  21903. /** @hidden */
  21904. _2DSamplerName: string;
  21905. /** @hidden */
  21906. _vRefractionMicrosurfaceInfosName: string;
  21907. /** @hidden */
  21908. _vRefractionInfosName: string;
  21909. private _scene;
  21910. /**
  21911. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  21912. * Materials half opaque for instance using refraction could benefit from this control.
  21913. */
  21914. linkRefractionWithTransparency: boolean;
  21915. /**
  21916. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  21917. */
  21918. invertRefractionY: boolean;
  21919. /**
  21920. * Gets or sets the texture associated with the node
  21921. */
  21922. texture: Nullable<BaseTexture>;
  21923. /**
  21924. * Create a new RefractionBlock
  21925. * @param name defines the block name
  21926. */
  21927. constructor(name: string);
  21928. /**
  21929. * Gets the current class name
  21930. * @returns the class name
  21931. */
  21932. getClassName(): string;
  21933. /**
  21934. * Gets the intensity input component
  21935. */
  21936. get intensity(): NodeMaterialConnectionPoint;
  21937. /**
  21938. * Gets the index of refraction input component
  21939. */
  21940. get indexOfRefraction(): NodeMaterialConnectionPoint;
  21941. /**
  21942. * Gets the tint at distance input component
  21943. */
  21944. get tintAtDistance(): NodeMaterialConnectionPoint;
  21945. /**
  21946. * Gets the view input component
  21947. */
  21948. get view(): NodeMaterialConnectionPoint;
  21949. /**
  21950. * Gets the refraction object output component
  21951. */
  21952. get refraction(): NodeMaterialConnectionPoint;
  21953. /**
  21954. * Returns true if the block has a texture
  21955. */
  21956. get hasTexture(): boolean;
  21957. protected _getTexture(): Nullable<BaseTexture>;
  21958. autoConfigure(material: NodeMaterial): void;
  21959. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  21960. isReady(): boolean;
  21961. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  21962. /**
  21963. * Gets the main code of the block (fragment side)
  21964. * @param state current state of the node material building
  21965. * @returns the shader code
  21966. */
  21967. getCode(state: NodeMaterialBuildState): string;
  21968. protected _buildBlock(state: NodeMaterialBuildState): this;
  21969. protected _dumpPropertiesCode(): string;
  21970. serialize(): any;
  21971. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  21972. }
  21973. }
  21974. declare module "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock" {
  21975. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  21976. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  21977. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  21978. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  21979. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  21980. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  21981. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  21982. import { Nullable } from "babylonjs/types";
  21983. import { Scene } from "babylonjs/scene";
  21984. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  21985. /**
  21986. * Base block used as input for post process
  21987. */
  21988. export class CurrentScreenBlock extends NodeMaterialBlock {
  21989. private _samplerName;
  21990. private _linearDefineName;
  21991. private _gammaDefineName;
  21992. private _mainUVName;
  21993. private _tempTextureRead;
  21994. /**
  21995. * Gets or sets the texture associated with the node
  21996. */
  21997. texture: Nullable<BaseTexture>;
  21998. /**
  21999. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22000. */
  22001. convertToGammaSpace: boolean;
  22002. /**
  22003. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22004. */
  22005. convertToLinearSpace: boolean;
  22006. /**
  22007. * Create a new CurrentScreenBlock
  22008. * @param name defines the block name
  22009. */
  22010. constructor(name: string);
  22011. /**
  22012. * Gets the current class name
  22013. * @returns the class name
  22014. */
  22015. getClassName(): string;
  22016. /**
  22017. * Gets the uv input component
  22018. */
  22019. get uv(): NodeMaterialConnectionPoint;
  22020. /**
  22021. * Gets the rgba output component
  22022. */
  22023. get rgba(): NodeMaterialConnectionPoint;
  22024. /**
  22025. * Gets the rgb output component
  22026. */
  22027. get rgb(): NodeMaterialConnectionPoint;
  22028. /**
  22029. * Gets the r output component
  22030. */
  22031. get r(): NodeMaterialConnectionPoint;
  22032. /**
  22033. * Gets the g output component
  22034. */
  22035. get g(): NodeMaterialConnectionPoint;
  22036. /**
  22037. * Gets the b output component
  22038. */
  22039. get b(): NodeMaterialConnectionPoint;
  22040. /**
  22041. * Gets the a output component
  22042. */
  22043. get a(): NodeMaterialConnectionPoint;
  22044. /**
  22045. * Initialize the block and prepare the context for build
  22046. * @param state defines the state that will be used for the build
  22047. */
  22048. initialize(state: NodeMaterialBuildState): void;
  22049. get target(): NodeMaterialBlockTargets;
  22050. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22051. isReady(): boolean;
  22052. private _injectVertexCode;
  22053. private _writeTextureRead;
  22054. private _writeOutput;
  22055. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22056. serialize(): any;
  22057. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22058. }
  22059. }
  22060. declare module "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock" {
  22061. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22062. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22063. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22064. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22065. import { NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22066. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  22067. import { Nullable } from "babylonjs/types";
  22068. import { Scene } from "babylonjs/scene";
  22069. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  22070. /**
  22071. * Base block used for the particle texture
  22072. */
  22073. export class ParticleTextureBlock extends NodeMaterialBlock {
  22074. private _samplerName;
  22075. private _linearDefineName;
  22076. private _gammaDefineName;
  22077. private _tempTextureRead;
  22078. /**
  22079. * Gets or sets the texture associated with the node
  22080. */
  22081. texture: Nullable<BaseTexture>;
  22082. /**
  22083. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  22084. */
  22085. convertToGammaSpace: boolean;
  22086. /**
  22087. * Gets or sets a boolean indicating if content needs to be converted to linear space
  22088. */
  22089. convertToLinearSpace: boolean;
  22090. /**
  22091. * Create a new ParticleTextureBlock
  22092. * @param name defines the block name
  22093. */
  22094. constructor(name: string);
  22095. /**
  22096. * Gets the current class name
  22097. * @returns the class name
  22098. */
  22099. getClassName(): string;
  22100. /**
  22101. * Gets the uv input component
  22102. */
  22103. get uv(): NodeMaterialConnectionPoint;
  22104. /**
  22105. * Gets the rgba output component
  22106. */
  22107. get rgba(): NodeMaterialConnectionPoint;
  22108. /**
  22109. * Gets the rgb output component
  22110. */
  22111. get rgb(): NodeMaterialConnectionPoint;
  22112. /**
  22113. * Gets the r output component
  22114. */
  22115. get r(): NodeMaterialConnectionPoint;
  22116. /**
  22117. * Gets the g output component
  22118. */
  22119. get g(): NodeMaterialConnectionPoint;
  22120. /**
  22121. * Gets the b output component
  22122. */
  22123. get b(): NodeMaterialConnectionPoint;
  22124. /**
  22125. * Gets the a output component
  22126. */
  22127. get a(): NodeMaterialConnectionPoint;
  22128. /**
  22129. * Initialize the block and prepare the context for build
  22130. * @param state defines the state that will be used for the build
  22131. */
  22132. initialize(state: NodeMaterialBuildState): void;
  22133. autoConfigure(material: NodeMaterial): void;
  22134. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  22135. isReady(): boolean;
  22136. private _writeOutput;
  22137. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22138. serialize(): any;
  22139. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22140. }
  22141. }
  22142. declare module "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData" {
  22143. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22144. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22145. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  22146. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  22147. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  22148. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  22149. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  22150. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  22151. import { Scene } from "babylonjs/scene";
  22152. /**
  22153. * Class used to store shared data between 2 NodeMaterialBuildState
  22154. */
  22155. export class NodeMaterialBuildStateSharedData {
  22156. /**
  22157. * Gets the list of emitted varyings
  22158. */
  22159. temps: string[];
  22160. /**
  22161. * Gets the list of emitted varyings
  22162. */
  22163. varyings: string[];
  22164. /**
  22165. * Gets the varying declaration string
  22166. */
  22167. varyingDeclaration: string;
  22168. /**
  22169. * Input blocks
  22170. */
  22171. inputBlocks: InputBlock[];
  22172. /**
  22173. * Input blocks
  22174. */
  22175. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  22176. /**
  22177. * Bindable blocks (Blocks that need to set data to the effect)
  22178. */
  22179. bindableBlocks: NodeMaterialBlock[];
  22180. /**
  22181. * List of blocks that can provide a compilation fallback
  22182. */
  22183. blocksWithFallbacks: NodeMaterialBlock[];
  22184. /**
  22185. * List of blocks that can provide a define update
  22186. */
  22187. blocksWithDefines: NodeMaterialBlock[];
  22188. /**
  22189. * List of blocks that can provide a repeatable content
  22190. */
  22191. repeatableContentBlocks: NodeMaterialBlock[];
  22192. /**
  22193. * List of blocks that can provide a dynamic list of uniforms
  22194. */
  22195. dynamicUniformBlocks: NodeMaterialBlock[];
  22196. /**
  22197. * List of blocks that can block the isReady function for the material
  22198. */
  22199. blockingBlocks: NodeMaterialBlock[];
  22200. /**
  22201. * Gets the list of animated inputs
  22202. */
  22203. animatedInputs: InputBlock[];
  22204. /**
  22205. * Build Id used to avoid multiple recompilations
  22206. */
  22207. buildId: number;
  22208. /** List of emitted variables */
  22209. variableNames: {
  22210. [key: string]: number;
  22211. };
  22212. /** List of emitted defines */
  22213. defineNames: {
  22214. [key: string]: number;
  22215. };
  22216. /** Should emit comments? */
  22217. emitComments: boolean;
  22218. /** Emit build activity */
  22219. verbose: boolean;
  22220. /** Gets or sets the hosting scene */
  22221. scene: Scene;
  22222. /**
  22223. * Gets the compilation hints emitted at compilation time
  22224. */
  22225. hints: {
  22226. needWorldViewMatrix: boolean;
  22227. needWorldViewProjectionMatrix: boolean;
  22228. needAlphaBlending: boolean;
  22229. needAlphaTesting: boolean;
  22230. };
  22231. /**
  22232. * List of compilation checks
  22233. */
  22234. checks: {
  22235. emitVertex: boolean;
  22236. emitFragment: boolean;
  22237. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  22238. };
  22239. /**
  22240. * Is vertex program allowed to be empty?
  22241. */
  22242. allowEmptyVertexProgram: boolean;
  22243. /** Creates a new shared data */
  22244. constructor();
  22245. /**
  22246. * Emits console errors and exceptions if there is a failing check
  22247. */
  22248. emitErrors(): void;
  22249. }
  22250. }
  22251. declare module "babylonjs/Materials/Node/nodeMaterialBuildState" {
  22252. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22253. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22254. import { NodeMaterialBuildStateSharedData } from "babylonjs/Materials/Node/nodeMaterialBuildStateSharedData";
  22255. /**
  22256. * Class used to store node based material build state
  22257. */
  22258. export class NodeMaterialBuildState {
  22259. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  22260. supportUniformBuffers: boolean;
  22261. /**
  22262. * Gets the list of emitted attributes
  22263. */
  22264. attributes: string[];
  22265. /**
  22266. * Gets the list of emitted uniforms
  22267. */
  22268. uniforms: string[];
  22269. /**
  22270. * Gets the list of emitted constants
  22271. */
  22272. constants: string[];
  22273. /**
  22274. * Gets the list of emitted samplers
  22275. */
  22276. samplers: string[];
  22277. /**
  22278. * Gets the list of emitted functions
  22279. */
  22280. functions: {
  22281. [key: string]: string;
  22282. };
  22283. /**
  22284. * Gets the list of emitted extensions
  22285. */
  22286. extensions: {
  22287. [key: string]: string;
  22288. };
  22289. /**
  22290. * Gets the target of the compilation state
  22291. */
  22292. target: NodeMaterialBlockTargets;
  22293. /**
  22294. * Gets the list of emitted counters
  22295. */
  22296. counters: {
  22297. [key: string]: number;
  22298. };
  22299. /**
  22300. * Shared data between multiple NodeMaterialBuildState instances
  22301. */
  22302. sharedData: NodeMaterialBuildStateSharedData;
  22303. /** @hidden */
  22304. _vertexState: NodeMaterialBuildState;
  22305. /** @hidden */
  22306. _attributeDeclaration: string;
  22307. /** @hidden */
  22308. _uniformDeclaration: string;
  22309. /** @hidden */
  22310. _constantDeclaration: string;
  22311. /** @hidden */
  22312. _samplerDeclaration: string;
  22313. /** @hidden */
  22314. _varyingTransfer: string;
  22315. /** @hidden */
  22316. _injectAtEnd: string;
  22317. private _repeatableContentAnchorIndex;
  22318. /** @hidden */
  22319. _builtCompilationString: string;
  22320. /**
  22321. * Gets the emitted compilation strings
  22322. */
  22323. compilationString: string;
  22324. /**
  22325. * Finalize the compilation strings
  22326. * @param state defines the current compilation state
  22327. */
  22328. finalize(state: NodeMaterialBuildState): void;
  22329. /** @hidden */
  22330. get _repeatableContentAnchor(): string;
  22331. /** @hidden */
  22332. _getFreeVariableName(prefix: string): string;
  22333. /** @hidden */
  22334. _getFreeDefineName(prefix: string): string;
  22335. /** @hidden */
  22336. _excludeVariableName(name: string): void;
  22337. /** @hidden */
  22338. _emit2DSampler(name: string): void;
  22339. /** @hidden */
  22340. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  22341. /** @hidden */
  22342. _emitExtension(name: string, extension: string, define?: string): void;
  22343. /** @hidden */
  22344. _emitFunction(name: string, code: string, comments: string): void;
  22345. /** @hidden */
  22346. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  22347. replaceStrings?: {
  22348. search: RegExp;
  22349. replace: string;
  22350. }[];
  22351. repeatKey?: string;
  22352. }): string;
  22353. /** @hidden */
  22354. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  22355. repeatKey?: string;
  22356. removeAttributes?: boolean;
  22357. removeUniforms?: boolean;
  22358. removeVaryings?: boolean;
  22359. removeIfDef?: boolean;
  22360. replaceStrings?: {
  22361. search: RegExp;
  22362. replace: string;
  22363. }[];
  22364. }, storeKey?: string): void;
  22365. /** @hidden */
  22366. _registerTempVariable(name: string): boolean;
  22367. /** @hidden */
  22368. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  22369. /** @hidden */
  22370. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  22371. /** @hidden */
  22372. _emitFloat(value: number): string;
  22373. }
  22374. }
  22375. declare module "babylonjs/Misc/uniqueIdGenerator" {
  22376. /**
  22377. * Helper class used to generate session unique ID
  22378. */
  22379. export class UniqueIdGenerator {
  22380. private static _UniqueIdCounter;
  22381. /**
  22382. * Gets an unique (relatively to the current scene) Id
  22383. */
  22384. static get UniqueId(): number;
  22385. }
  22386. }
  22387. declare module "babylonjs/Materials/Node/nodeMaterialBlock" {
  22388. import { NodeMaterialBlockConnectionPointTypes } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  22389. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22390. import { Nullable } from "babylonjs/types";
  22391. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22392. import { NodeMaterialBlockTargets } from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  22393. import { Effect } from "babylonjs/Materials/effect";
  22394. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22395. import { Mesh } from "babylonjs/Meshes/mesh";
  22396. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22397. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22398. import { Scene } from "babylonjs/scene";
  22399. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  22400. /**
  22401. * Defines a block that can be used inside a node based material
  22402. */
  22403. export class NodeMaterialBlock {
  22404. private _buildId;
  22405. private _buildTarget;
  22406. private _target;
  22407. private _isFinalMerger;
  22408. private _isInput;
  22409. private _name;
  22410. protected _isUnique: boolean;
  22411. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  22412. inputsAreExclusive: boolean;
  22413. /** @hidden */
  22414. _codeVariableName: string;
  22415. /** @hidden */
  22416. _inputs: NodeMaterialConnectionPoint[];
  22417. /** @hidden */
  22418. _outputs: NodeMaterialConnectionPoint[];
  22419. /** @hidden */
  22420. _preparationId: number;
  22421. /**
  22422. * Gets the name of the block
  22423. */
  22424. get name(): string;
  22425. /**
  22426. * Sets the name of the block. Will check if the name is valid.
  22427. */
  22428. set name(newName: string);
  22429. /**
  22430. * Gets or sets the unique id of the node
  22431. */
  22432. uniqueId: number;
  22433. /**
  22434. * Gets or sets the comments associated with this block
  22435. */
  22436. comments: string;
  22437. /**
  22438. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  22439. */
  22440. get isUnique(): boolean;
  22441. /**
  22442. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  22443. */
  22444. get isFinalMerger(): boolean;
  22445. /**
  22446. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  22447. */
  22448. get isInput(): boolean;
  22449. /**
  22450. * Gets or sets the build Id
  22451. */
  22452. get buildId(): number;
  22453. set buildId(value: number);
  22454. /**
  22455. * Gets or sets the target of the block
  22456. */
  22457. get target(): NodeMaterialBlockTargets;
  22458. set target(value: NodeMaterialBlockTargets);
  22459. /**
  22460. * Gets the list of input points
  22461. */
  22462. get inputs(): NodeMaterialConnectionPoint[];
  22463. /** Gets the list of output points */
  22464. get outputs(): NodeMaterialConnectionPoint[];
  22465. /**
  22466. * Find an input by its name
  22467. * @param name defines the name of the input to look for
  22468. * @returns the input or null if not found
  22469. */
  22470. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22471. /**
  22472. * Find an output by its name
  22473. * @param name defines the name of the outputto look for
  22474. * @returns the output or null if not found
  22475. */
  22476. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  22477. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  22478. visibleInInspector: boolean;
  22479. /**
  22480. * Creates a new NodeMaterialBlock
  22481. * @param name defines the block name
  22482. * @param target defines the target of that block (Vertex by default)
  22483. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  22484. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  22485. */
  22486. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  22487. /**
  22488. * Initialize the block and prepare the context for build
  22489. * @param state defines the state that will be used for the build
  22490. */
  22491. initialize(state: NodeMaterialBuildState): void;
  22492. /**
  22493. * Bind data to effect. Will only be called for blocks with isBindable === true
  22494. * @param effect defines the effect to bind data to
  22495. * @param nodeMaterial defines the hosting NodeMaterial
  22496. * @param mesh defines the mesh that will be rendered
  22497. * @param subMesh defines the submesh that will be rendered
  22498. */
  22499. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  22500. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  22501. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  22502. protected _writeFloat(value: number): string;
  22503. /**
  22504. * Gets the current class name e.g. "NodeMaterialBlock"
  22505. * @returns the class name
  22506. */
  22507. getClassName(): string;
  22508. /**
  22509. * Register a new input. Must be called inside a block constructor
  22510. * @param name defines the connection point name
  22511. * @param type defines the connection point type
  22512. * @param isOptional defines a boolean indicating that this input can be omitted
  22513. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22514. * @param point an already created connection point. If not provided, create a new one
  22515. * @returns the current block
  22516. */
  22517. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22518. /**
  22519. * Register a new output. Must be called inside a block constructor
  22520. * @param name defines the connection point name
  22521. * @param type defines the connection point type
  22522. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  22523. * @param point an already created connection point. If not provided, create a new one
  22524. * @returns the current block
  22525. */
  22526. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  22527. /**
  22528. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  22529. * @param forOutput defines an optional connection point to check compatibility with
  22530. * @returns the first available input or null
  22531. */
  22532. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  22533. /**
  22534. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  22535. * @param forBlock defines an optional block to check compatibility with
  22536. * @returns the first available input or null
  22537. */
  22538. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  22539. /**
  22540. * Gets the sibling of the given output
  22541. * @param current defines the current output
  22542. * @returns the next output in the list or null
  22543. */
  22544. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  22545. /**
  22546. * Connect current block with another block
  22547. * @param other defines the block to connect with
  22548. * @param options define the various options to help pick the right connections
  22549. * @returns the current block
  22550. */
  22551. connectTo(other: NodeMaterialBlock, options?: {
  22552. input?: string;
  22553. output?: string;
  22554. outputSwizzle?: string;
  22555. }): this | undefined;
  22556. protected _buildBlock(state: NodeMaterialBuildState): void;
  22557. /**
  22558. * Add uniforms, samplers and uniform buffers at compilation time
  22559. * @param state defines the state to update
  22560. * @param nodeMaterial defines the node material requesting the update
  22561. * @param defines defines the material defines to update
  22562. * @param uniformBuffers defines the list of uniform buffer names
  22563. */
  22564. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  22565. /**
  22566. * Add potential fallbacks if shader compilation fails
  22567. * @param mesh defines the mesh to be rendered
  22568. * @param fallbacks defines the current prioritized list of fallbacks
  22569. */
  22570. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  22571. /**
  22572. * Initialize defines for shader compilation
  22573. * @param mesh defines the mesh to be rendered
  22574. * @param nodeMaterial defines the node material requesting the update
  22575. * @param defines defines the material defines to update
  22576. * @param useInstances specifies that instances should be used
  22577. */
  22578. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  22579. /**
  22580. * Update defines for shader compilation
  22581. * @param mesh defines the mesh to be rendered
  22582. * @param nodeMaterial defines the node material requesting the update
  22583. * @param defines defines the material defines to update
  22584. * @param useInstances specifies that instances should be used
  22585. * @param subMesh defines which submesh to render
  22586. */
  22587. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22588. /**
  22589. * Lets the block try to connect some inputs automatically
  22590. * @param material defines the hosting NodeMaterial
  22591. */
  22592. autoConfigure(material: NodeMaterial): void;
  22593. /**
  22594. * Function called when a block is declared as repeatable content generator
  22595. * @param vertexShaderState defines the current compilation state for the vertex shader
  22596. * @param fragmentShaderState defines the current compilation state for the fragment shader
  22597. * @param mesh defines the mesh to be rendered
  22598. * @param defines defines the material defines to update
  22599. */
  22600. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  22601. /**
  22602. * Checks if the block is ready
  22603. * @param mesh defines the mesh to be rendered
  22604. * @param nodeMaterial defines the node material requesting the update
  22605. * @param defines defines the material defines to update
  22606. * @param useInstances specifies that instances should be used
  22607. * @returns true if the block is ready
  22608. */
  22609. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  22610. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  22611. private _processBuild;
  22612. /**
  22613. * Validates the new name for the block node.
  22614. * @param newName the new name to be given to the node.
  22615. * @returns false if the name is a reserve word, else true.
  22616. */
  22617. validateBlockName(newName: string): boolean;
  22618. /**
  22619. * Compile the current node and generate the shader code
  22620. * @param state defines the current compilation state (uniforms, samplers, current string)
  22621. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  22622. * @returns true if already built
  22623. */
  22624. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  22625. protected _inputRename(name: string): string;
  22626. protected _outputRename(name: string): string;
  22627. protected _dumpPropertiesCode(): string;
  22628. /** @hidden */
  22629. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  22630. /** @hidden */
  22631. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  22632. /**
  22633. * Clone the current block to a new identical block
  22634. * @param scene defines the hosting scene
  22635. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  22636. * @returns a copy of the current block
  22637. */
  22638. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  22639. /**
  22640. * Serializes this block in a JSON representation
  22641. * @returns the serialized block object
  22642. */
  22643. serialize(): any;
  22644. /** @hidden */
  22645. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22646. private _deserializePortDisplayNamesAndExposedOnFrame;
  22647. /**
  22648. * Release resources
  22649. */
  22650. dispose(): void;
  22651. }
  22652. }
  22653. declare module "babylonjs/Materials/pushMaterial" {
  22654. import { Nullable } from "babylonjs/types";
  22655. import { Scene } from "babylonjs/scene";
  22656. import { Matrix } from "babylonjs/Maths/math.vector";
  22657. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22658. import { Mesh } from "babylonjs/Meshes/mesh";
  22659. import { Material } from "babylonjs/Materials/material";
  22660. import { Effect } from "babylonjs/Materials/effect";
  22661. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22662. /**
  22663. * Base class of materials working in push mode in babylon JS
  22664. * @hidden
  22665. */
  22666. export class PushMaterial extends Material {
  22667. protected _activeEffect: Effect;
  22668. protected _normalMatrix: Matrix;
  22669. constructor(name: string, scene: Scene);
  22670. getEffect(): Effect;
  22671. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  22672. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  22673. /**
  22674. * Binds the given world matrix to the active effect
  22675. *
  22676. * @param world the matrix to bind
  22677. */
  22678. bindOnlyWorldMatrix(world: Matrix): void;
  22679. /**
  22680. * Binds the given normal matrix to the active effect
  22681. *
  22682. * @param normalMatrix the matrix to bind
  22683. */
  22684. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  22685. bind(world: Matrix, mesh?: Mesh): void;
  22686. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  22687. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  22688. }
  22689. }
  22690. declare module "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer" {
  22691. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22692. /**
  22693. * Root class for all node material optimizers
  22694. */
  22695. export class NodeMaterialOptimizer {
  22696. /**
  22697. * Function used to optimize a NodeMaterial graph
  22698. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  22699. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  22700. */
  22701. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  22702. }
  22703. }
  22704. declare module "babylonjs/Materials/Node/Blocks/transformBlock" {
  22705. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22706. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22707. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22708. import { Scene } from "babylonjs/scene";
  22709. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  22710. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  22711. import { SubMesh } from "babylonjs/Meshes/subMesh";
  22712. /**
  22713. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  22714. */
  22715. export class TransformBlock extends NodeMaterialBlock {
  22716. /**
  22717. * Defines the value to use to complement W value to transform it to a Vector4
  22718. */
  22719. complementW: number;
  22720. /**
  22721. * Defines the value to use to complement z value to transform it to a Vector4
  22722. */
  22723. complementZ: number;
  22724. /**
  22725. * Creates a new TransformBlock
  22726. * @param name defines the block name
  22727. */
  22728. constructor(name: string);
  22729. /**
  22730. * Gets the current class name
  22731. * @returns the class name
  22732. */
  22733. getClassName(): string;
  22734. /**
  22735. * Gets the vector input
  22736. */
  22737. get vector(): NodeMaterialConnectionPoint;
  22738. /**
  22739. * Gets the output component
  22740. */
  22741. get output(): NodeMaterialConnectionPoint;
  22742. /**
  22743. * Gets the xyz output component
  22744. */
  22745. get xyz(): NodeMaterialConnectionPoint;
  22746. /**
  22747. * Gets the matrix transform input
  22748. */
  22749. get transform(): NodeMaterialConnectionPoint;
  22750. protected _buildBlock(state: NodeMaterialBuildState): this;
  22751. /**
  22752. * Update defines for shader compilation
  22753. * @param mesh defines the mesh to be rendered
  22754. * @param nodeMaterial defines the node material requesting the update
  22755. * @param defines defines the material defines to update
  22756. * @param useInstances specifies that instances should be used
  22757. * @param subMesh defines which submesh to render
  22758. */
  22759. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  22760. serialize(): any;
  22761. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  22762. protected _dumpPropertiesCode(): string;
  22763. }
  22764. }
  22765. declare module "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock" {
  22766. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22767. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22768. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22769. /**
  22770. * Block used to output the vertex position
  22771. */
  22772. export class VertexOutputBlock extends NodeMaterialBlock {
  22773. /**
  22774. * Creates a new VertexOutputBlock
  22775. * @param name defines the block name
  22776. */
  22777. constructor(name: string);
  22778. /**
  22779. * Gets the current class name
  22780. * @returns the class name
  22781. */
  22782. getClassName(): string;
  22783. /**
  22784. * Gets the vector input component
  22785. */
  22786. get vector(): NodeMaterialConnectionPoint;
  22787. protected _buildBlock(state: NodeMaterialBuildState): this;
  22788. }
  22789. }
  22790. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock" {
  22791. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22792. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22793. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22794. /**
  22795. * Block used to output the final color
  22796. */
  22797. export class FragmentOutputBlock extends NodeMaterialBlock {
  22798. /**
  22799. * Create a new FragmentOutputBlock
  22800. * @param name defines the block name
  22801. */
  22802. constructor(name: string);
  22803. /**
  22804. * Gets the current class name
  22805. * @returns the class name
  22806. */
  22807. getClassName(): string;
  22808. /**
  22809. * Gets the rgba input component
  22810. */
  22811. get rgba(): NodeMaterialConnectionPoint;
  22812. /**
  22813. * Gets the rgb input component
  22814. */
  22815. get rgb(): NodeMaterialConnectionPoint;
  22816. /**
  22817. * Gets the a input component
  22818. */
  22819. get a(): NodeMaterialConnectionPoint;
  22820. protected _buildBlock(state: NodeMaterialBuildState): this;
  22821. }
  22822. }
  22823. declare module "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock" {
  22824. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22825. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22826. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22827. /**
  22828. * Block used for the particle ramp gradient section
  22829. */
  22830. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  22831. /**
  22832. * Create a new ParticleRampGradientBlock
  22833. * @param name defines the block name
  22834. */
  22835. constructor(name: string);
  22836. /**
  22837. * Gets the current class name
  22838. * @returns the class name
  22839. */
  22840. getClassName(): string;
  22841. /**
  22842. * Gets the color input component
  22843. */
  22844. get color(): NodeMaterialConnectionPoint;
  22845. /**
  22846. * Gets the rampColor output component
  22847. */
  22848. get rampColor(): NodeMaterialConnectionPoint;
  22849. /**
  22850. * Initialize the block and prepare the context for build
  22851. * @param state defines the state that will be used for the build
  22852. */
  22853. initialize(state: NodeMaterialBuildState): void;
  22854. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22855. }
  22856. }
  22857. declare module "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock" {
  22858. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22859. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22860. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22861. /**
  22862. * Block used for the particle blend multiply section
  22863. */
  22864. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  22865. /**
  22866. * Create a new ParticleBlendMultiplyBlock
  22867. * @param name defines the block name
  22868. */
  22869. constructor(name: string);
  22870. /**
  22871. * Gets the current class name
  22872. * @returns the class name
  22873. */
  22874. getClassName(): string;
  22875. /**
  22876. * Gets the color input component
  22877. */
  22878. get color(): NodeMaterialConnectionPoint;
  22879. /**
  22880. * Gets the alphaTexture input component
  22881. */
  22882. get alphaTexture(): NodeMaterialConnectionPoint;
  22883. /**
  22884. * Gets the alphaColor input component
  22885. */
  22886. get alphaColor(): NodeMaterialConnectionPoint;
  22887. /**
  22888. * Gets the blendColor output component
  22889. */
  22890. get blendColor(): NodeMaterialConnectionPoint;
  22891. /**
  22892. * Initialize the block and prepare the context for build
  22893. * @param state defines the state that will be used for the build
  22894. */
  22895. initialize(state: NodeMaterialBuildState): void;
  22896. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  22897. }
  22898. }
  22899. declare module "babylonjs/Materials/Node/Blocks/vectorMergerBlock" {
  22900. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22901. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22902. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22903. /**
  22904. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  22905. */
  22906. export class VectorMergerBlock extends NodeMaterialBlock {
  22907. /**
  22908. * Create a new VectorMergerBlock
  22909. * @param name defines the block name
  22910. */
  22911. constructor(name: string);
  22912. /**
  22913. * Gets the current class name
  22914. * @returns the class name
  22915. */
  22916. getClassName(): string;
  22917. /**
  22918. * Gets the xyz component (input)
  22919. */
  22920. get xyzIn(): NodeMaterialConnectionPoint;
  22921. /**
  22922. * Gets the xy component (input)
  22923. */
  22924. get xyIn(): NodeMaterialConnectionPoint;
  22925. /**
  22926. * Gets the x component (input)
  22927. */
  22928. get x(): NodeMaterialConnectionPoint;
  22929. /**
  22930. * Gets the y component (input)
  22931. */
  22932. get y(): NodeMaterialConnectionPoint;
  22933. /**
  22934. * Gets the z component (input)
  22935. */
  22936. get z(): NodeMaterialConnectionPoint;
  22937. /**
  22938. * Gets the w component (input)
  22939. */
  22940. get w(): NodeMaterialConnectionPoint;
  22941. /**
  22942. * Gets the xyzw component (output)
  22943. */
  22944. get xyzw(): NodeMaterialConnectionPoint;
  22945. /**
  22946. * Gets the xyz component (output)
  22947. */
  22948. get xyzOut(): NodeMaterialConnectionPoint;
  22949. /**
  22950. * Gets the xy component (output)
  22951. */
  22952. get xyOut(): NodeMaterialConnectionPoint;
  22953. /**
  22954. * Gets the xy component (output)
  22955. * @deprecated Please use xyOut instead.
  22956. */
  22957. get xy(): NodeMaterialConnectionPoint;
  22958. /**
  22959. * Gets the xyz component (output)
  22960. * @deprecated Please use xyzOut instead.
  22961. */
  22962. get xyz(): NodeMaterialConnectionPoint;
  22963. protected _buildBlock(state: NodeMaterialBuildState): this;
  22964. }
  22965. }
  22966. declare module "babylonjs/Materials/Node/Blocks/remapBlock" {
  22967. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  22968. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  22969. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  22970. import { Vector2 } from "babylonjs/Maths/math.vector";
  22971. import { Scene } from "babylonjs/scene";
  22972. /**
  22973. * Block used to remap a float from a range to a new one
  22974. */
  22975. export class RemapBlock extends NodeMaterialBlock {
  22976. /**
  22977. * Gets or sets the source range
  22978. */
  22979. sourceRange: Vector2;
  22980. /**
  22981. * Gets or sets the target range
  22982. */
  22983. targetRange: Vector2;
  22984. /**
  22985. * Creates a new RemapBlock
  22986. * @param name defines the block name
  22987. */
  22988. constructor(name: string);
  22989. /**
  22990. * Gets the current class name
  22991. * @returns the class name
  22992. */
  22993. getClassName(): string;
  22994. /**
  22995. * Gets the input component
  22996. */
  22997. get input(): NodeMaterialConnectionPoint;
  22998. /**
  22999. * Gets the source min input component
  23000. */
  23001. get sourceMin(): NodeMaterialConnectionPoint;
  23002. /**
  23003. * Gets the source max input component
  23004. */
  23005. get sourceMax(): NodeMaterialConnectionPoint;
  23006. /**
  23007. * Gets the target min input component
  23008. */
  23009. get targetMin(): NodeMaterialConnectionPoint;
  23010. /**
  23011. * Gets the target max input component
  23012. */
  23013. get targetMax(): NodeMaterialConnectionPoint;
  23014. /**
  23015. * Gets the output component
  23016. */
  23017. get output(): NodeMaterialConnectionPoint;
  23018. protected _buildBlock(state: NodeMaterialBuildState): this;
  23019. protected _dumpPropertiesCode(): string;
  23020. serialize(): any;
  23021. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23022. }
  23023. }
  23024. declare module "babylonjs/Materials/Node/Blocks/multiplyBlock" {
  23025. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23026. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23027. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23028. /**
  23029. * Block used to multiply 2 values
  23030. */
  23031. export class MultiplyBlock extends NodeMaterialBlock {
  23032. /**
  23033. * Creates a new MultiplyBlock
  23034. * @param name defines the block name
  23035. */
  23036. constructor(name: string);
  23037. /**
  23038. * Gets the current class name
  23039. * @returns the class name
  23040. */
  23041. getClassName(): string;
  23042. /**
  23043. * Gets the left operand input component
  23044. */
  23045. get left(): NodeMaterialConnectionPoint;
  23046. /**
  23047. * Gets the right operand input component
  23048. */
  23049. get right(): NodeMaterialConnectionPoint;
  23050. /**
  23051. * Gets the output component
  23052. */
  23053. get output(): NodeMaterialConnectionPoint;
  23054. protected _buildBlock(state: NodeMaterialBuildState): this;
  23055. }
  23056. }
  23057. declare module "babylonjs/Materials/Node/Blocks/colorSplitterBlock" {
  23058. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23059. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23060. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23061. /**
  23062. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  23063. */
  23064. export class ColorSplitterBlock extends NodeMaterialBlock {
  23065. /**
  23066. * Create a new ColorSplitterBlock
  23067. * @param name defines the block name
  23068. */
  23069. constructor(name: string);
  23070. /**
  23071. * Gets the current class name
  23072. * @returns the class name
  23073. */
  23074. getClassName(): string;
  23075. /**
  23076. * Gets the rgba component (input)
  23077. */
  23078. get rgba(): NodeMaterialConnectionPoint;
  23079. /**
  23080. * Gets the rgb component (input)
  23081. */
  23082. get rgbIn(): NodeMaterialConnectionPoint;
  23083. /**
  23084. * Gets the rgb component (output)
  23085. */
  23086. get rgbOut(): NodeMaterialConnectionPoint;
  23087. /**
  23088. * Gets the r component (output)
  23089. */
  23090. get r(): NodeMaterialConnectionPoint;
  23091. /**
  23092. * Gets the g component (output)
  23093. */
  23094. get g(): NodeMaterialConnectionPoint;
  23095. /**
  23096. * Gets the b component (output)
  23097. */
  23098. get b(): NodeMaterialConnectionPoint;
  23099. /**
  23100. * Gets the a component (output)
  23101. */
  23102. get a(): NodeMaterialConnectionPoint;
  23103. protected _inputRename(name: string): string;
  23104. protected _outputRename(name: string): string;
  23105. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  23106. }
  23107. }
  23108. declare module "babylonjs/Materials/Node/Blocks/trigonometryBlock" {
  23109. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23110. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  23111. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  23112. import { Scene } from "babylonjs/scene";
  23113. /**
  23114. * Operations supported by the Trigonometry block
  23115. */
  23116. export enum TrigonometryBlockOperations {
  23117. /** Cos */
  23118. Cos = 0,
  23119. /** Sin */
  23120. Sin = 1,
  23121. /** Abs */
  23122. Abs = 2,
  23123. /** Exp */
  23124. Exp = 3,
  23125. /** Exp2 */
  23126. Exp2 = 4,
  23127. /** Round */
  23128. Round = 5,
  23129. /** Floor */
  23130. Floor = 6,
  23131. /** Ceiling */
  23132. Ceiling = 7,
  23133. /** Square root */
  23134. Sqrt = 8,
  23135. /** Log */
  23136. Log = 9,
  23137. /** Tangent */
  23138. Tan = 10,
  23139. /** Arc tangent */
  23140. ArcTan = 11,
  23141. /** Arc cosinus */
  23142. ArcCos = 12,
  23143. /** Arc sinus */
  23144. ArcSin = 13,
  23145. /** Fraction */
  23146. Fract = 14,
  23147. /** Sign */
  23148. Sign = 15,
  23149. /** To radians (from degrees) */
  23150. Radians = 16,
  23151. /** To degrees (from radians) */
  23152. Degrees = 17
  23153. }
  23154. /**
  23155. * Block used to apply trigonometry operation to floats
  23156. */
  23157. export class TrigonometryBlock extends NodeMaterialBlock {
  23158. /**
  23159. * Gets or sets the operation applied by the block
  23160. */
  23161. operation: TrigonometryBlockOperations;
  23162. /**
  23163. * Creates a new TrigonometryBlock
  23164. * @param name defines the block name
  23165. */
  23166. constructor(name: string);
  23167. /**
  23168. * Gets the current class name
  23169. * @returns the class name
  23170. */
  23171. getClassName(): string;
  23172. /**
  23173. * Gets the input component
  23174. */
  23175. get input(): NodeMaterialConnectionPoint;
  23176. /**
  23177. * Gets the output component
  23178. */
  23179. get output(): NodeMaterialConnectionPoint;
  23180. protected _buildBlock(state: NodeMaterialBuildState): this;
  23181. serialize(): any;
  23182. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  23183. protected _dumpPropertiesCode(): string;
  23184. }
  23185. }
  23186. declare module "babylonjs/Materials/Node/nodeMaterial" {
  23187. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  23188. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  23189. import { Scene } from "babylonjs/scene";
  23190. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  23191. import { Matrix } from "babylonjs/Maths/math.vector";
  23192. import { Mesh } from "babylonjs/Meshes/mesh";
  23193. import { Engine } from "babylonjs/Engines/engine";
  23194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23195. import { Observable } from "babylonjs/Misc/observable";
  23196. import { SubMesh } from "babylonjs/Meshes/subMesh";
  23197. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  23198. import { NodeMaterialOptimizer } from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  23199. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  23200. import { Nullable } from "babylonjs/types";
  23201. import { InputBlock } from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  23202. import { TextureBlock } from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  23203. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  23204. import { RefractionBlock } from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  23205. import { CurrentScreenBlock } from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  23206. import { ParticleTextureBlock } from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  23207. import { Effect } from "babylonjs/Materials/effect";
  23208. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23209. import { Camera } from "babylonjs/Cameras/camera";
  23210. import { NodeMaterialModes } from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  23211. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  23212. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  23213. /**
  23214. * Interface used to configure the node material editor
  23215. */
  23216. export interface INodeMaterialEditorOptions {
  23217. /** Define the URl to load node editor script */
  23218. editorURL?: string;
  23219. }
  23220. /** @hidden */
  23221. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  23222. NORMAL: boolean;
  23223. TANGENT: boolean;
  23224. UV1: boolean;
  23225. /** BONES */
  23226. NUM_BONE_INFLUENCERS: number;
  23227. BonesPerMesh: number;
  23228. BONETEXTURE: boolean;
  23229. /** MORPH TARGETS */
  23230. MORPHTARGETS: boolean;
  23231. MORPHTARGETS_NORMAL: boolean;
  23232. MORPHTARGETS_TANGENT: boolean;
  23233. MORPHTARGETS_UV: boolean;
  23234. NUM_MORPH_INFLUENCERS: number;
  23235. /** IMAGE PROCESSING */
  23236. IMAGEPROCESSING: boolean;
  23237. VIGNETTE: boolean;
  23238. VIGNETTEBLENDMODEMULTIPLY: boolean;
  23239. VIGNETTEBLENDMODEOPAQUE: boolean;
  23240. TONEMAPPING: boolean;
  23241. TONEMAPPING_ACES: boolean;
  23242. CONTRAST: boolean;
  23243. EXPOSURE: boolean;
  23244. COLORCURVES: boolean;
  23245. COLORGRADING: boolean;
  23246. COLORGRADING3D: boolean;
  23247. SAMPLER3DGREENDEPTH: boolean;
  23248. SAMPLER3DBGRMAP: boolean;
  23249. IMAGEPROCESSINGPOSTPROCESS: boolean;
  23250. /** MISC. */
  23251. BUMPDIRECTUV: number;
  23252. constructor();
  23253. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  23254. }
  23255. /**
  23256. * Class used to configure NodeMaterial
  23257. */
  23258. export interface INodeMaterialOptions {
  23259. /**
  23260. * Defines if blocks should emit comments
  23261. */
  23262. emitComments: boolean;
  23263. }
  23264. /**
  23265. * Class used to create a node based material built by assembling shader blocks
  23266. */
  23267. export class NodeMaterial extends PushMaterial {
  23268. private static _BuildIdGenerator;
  23269. private _options;
  23270. private _vertexCompilationState;
  23271. private _fragmentCompilationState;
  23272. private _sharedData;
  23273. private _buildId;
  23274. private _buildWasSuccessful;
  23275. private _cachedWorldViewMatrix;
  23276. private _cachedWorldViewProjectionMatrix;
  23277. private _optimizers;
  23278. private _animationFrame;
  23279. /** Define the Url to load node editor script */
  23280. static EditorURL: string;
  23281. /** Define the Url to load snippets */
  23282. static SnippetUrl: string;
  23283. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  23284. static IgnoreTexturesAtLoadTime: boolean;
  23285. private BJSNODEMATERIALEDITOR;
  23286. /** Get the inspector from bundle or global */
  23287. private _getGlobalNodeMaterialEditor;
  23288. /**
  23289. * Snippet ID if the material was created from the snippet server
  23290. */
  23291. snippetId: string;
  23292. /**
  23293. * Gets or sets data used by visual editor
  23294. * @see https://nme.babylonjs.com
  23295. */
  23296. editorData: any;
  23297. /**
  23298. * 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)
  23299. */
  23300. ignoreAlpha: boolean;
  23301. /**
  23302. * Defines the maximum number of lights that can be used in the material
  23303. */
  23304. maxSimultaneousLights: number;
  23305. /**
  23306. * Observable raised when the material is built
  23307. */
  23308. onBuildObservable: Observable<NodeMaterial>;
  23309. /**
  23310. * Gets or sets the root nodes of the material vertex shader
  23311. */
  23312. _vertexOutputNodes: NodeMaterialBlock[];
  23313. /**
  23314. * Gets or sets the root nodes of the material fragment (pixel) shader
  23315. */
  23316. _fragmentOutputNodes: NodeMaterialBlock[];
  23317. /** Gets or sets options to control the node material overall behavior */
  23318. get options(): INodeMaterialOptions;
  23319. set options(options: INodeMaterialOptions);
  23320. /**
  23321. * Default configuration related to image processing available in the standard Material.
  23322. */
  23323. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23324. /**
  23325. * Gets the image processing configuration used either in this material.
  23326. */
  23327. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23328. /**
  23329. * Sets the Default image processing configuration used either in the this material.
  23330. *
  23331. * If sets to null, the scene one is in use.
  23332. */
  23333. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23334. /**
  23335. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  23336. */
  23337. attachedBlocks: NodeMaterialBlock[];
  23338. /**
  23339. * Specifies the mode of the node material
  23340. * @hidden
  23341. */
  23342. _mode: NodeMaterialModes;
  23343. /**
  23344. * Gets the mode property
  23345. */
  23346. get mode(): NodeMaterialModes;
  23347. /**
  23348. * Create a new node based material
  23349. * @param name defines the material name
  23350. * @param scene defines the hosting scene
  23351. * @param options defines creation option
  23352. */
  23353. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  23354. /**
  23355. * Gets the current class name of the material e.g. "NodeMaterial"
  23356. * @returns the class name
  23357. */
  23358. getClassName(): string;
  23359. /**
  23360. * Keep track of the image processing observer to allow dispose and replace.
  23361. */
  23362. private _imageProcessingObserver;
  23363. /**
  23364. * Attaches a new image processing configuration to the Standard Material.
  23365. * @param configuration
  23366. */
  23367. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  23368. /**
  23369. * Get a block by its name
  23370. * @param name defines the name of the block to retrieve
  23371. * @returns the required block or null if not found
  23372. */
  23373. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  23374. /**
  23375. * Get a block by its name
  23376. * @param predicate defines the predicate used to find the good candidate
  23377. * @returns the required block or null if not found
  23378. */
  23379. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  23380. /**
  23381. * Get an input block by its name
  23382. * @param predicate defines the predicate used to find the good candidate
  23383. * @returns the required input block or null if not found
  23384. */
  23385. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  23386. /**
  23387. * Gets the list of input blocks attached to this material
  23388. * @returns an array of InputBlocks
  23389. */
  23390. getInputBlocks(): InputBlock[];
  23391. /**
  23392. * Adds a new optimizer to the list of optimizers
  23393. * @param optimizer defines the optimizers to add
  23394. * @returns the current material
  23395. */
  23396. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23397. /**
  23398. * Remove an optimizer from the list of optimizers
  23399. * @param optimizer defines the optimizers to remove
  23400. * @returns the current material
  23401. */
  23402. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  23403. /**
  23404. * Add a new block to the list of output nodes
  23405. * @param node defines the node to add
  23406. * @returns the current material
  23407. */
  23408. addOutputNode(node: NodeMaterialBlock): this;
  23409. /**
  23410. * Remove a block from the list of root nodes
  23411. * @param node defines the node to remove
  23412. * @returns the current material
  23413. */
  23414. removeOutputNode(node: NodeMaterialBlock): this;
  23415. private _addVertexOutputNode;
  23416. private _removeVertexOutputNode;
  23417. private _addFragmentOutputNode;
  23418. private _removeFragmentOutputNode;
  23419. /**
  23420. * Specifies if the material will require alpha blending
  23421. * @returns a boolean specifying if alpha blending is needed
  23422. */
  23423. needAlphaBlending(): boolean;
  23424. /**
  23425. * Specifies if this material should be rendered in alpha test mode
  23426. * @returns a boolean specifying if an alpha test is needed.
  23427. */
  23428. needAlphaTesting(): boolean;
  23429. private _initializeBlock;
  23430. private _resetDualBlocks;
  23431. /**
  23432. * Remove a block from the current node material
  23433. * @param block defines the block to remove
  23434. */
  23435. removeBlock(block: NodeMaterialBlock): void;
  23436. /**
  23437. * Build the material and generates the inner effect
  23438. * @param verbose defines if the build should log activity
  23439. */
  23440. build(verbose?: boolean): void;
  23441. /**
  23442. * Runs an otpimization phase to try to improve the shader code
  23443. */
  23444. optimize(): void;
  23445. private _prepareDefinesForAttributes;
  23446. /**
  23447. * Create a post process from the material
  23448. * @param camera The camera to apply the render pass to.
  23449. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  23450. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  23451. * @param engine The engine which the post process will be applied. (default: current engine)
  23452. * @param reusable If the post process can be reused on the same frame. (default: false)
  23453. * @param textureType Type of textures used when performing the post process. (default: 0)
  23454. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  23455. * @returns the post process created
  23456. */
  23457. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  23458. /**
  23459. * Create the post process effect from the material
  23460. * @param postProcess The post process to create the effect for
  23461. */
  23462. createEffectForPostProcess(postProcess: PostProcess): void;
  23463. private _createEffectForPostProcess;
  23464. /**
  23465. * Create a new procedural texture based on this node material
  23466. * @param size defines the size of the texture
  23467. * @param scene defines the hosting scene
  23468. * @returns the new procedural texture attached to this node material
  23469. */
  23470. createProceduralTexture(size: number | {
  23471. width: number;
  23472. height: number;
  23473. layers?: number;
  23474. }, scene: Scene): Nullable<ProceduralTexture>;
  23475. private _createEffectForParticles;
  23476. private _checkInternals;
  23477. /**
  23478. * Create the effect to be used as the custom effect for a particle system
  23479. * @param particleSystem Particle system to create the effect for
  23480. * @param onCompiled defines a function to call when the effect creation is successful
  23481. * @param onError defines a function to call when the effect creation has failed
  23482. */
  23483. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  23484. private _processDefines;
  23485. /**
  23486. * Get if the submesh is ready to be used and all its information available.
  23487. * Child classes can use it to update shaders
  23488. * @param mesh defines the mesh to check
  23489. * @param subMesh defines which submesh to check
  23490. * @param useInstances specifies that instances should be used
  23491. * @returns a boolean indicating that the submesh is ready or not
  23492. */
  23493. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  23494. /**
  23495. * Get a string representing the shaders built by the current node graph
  23496. */
  23497. get compiledShaders(): string;
  23498. /**
  23499. * Binds the world matrix to the material
  23500. * @param world defines the world transformation matrix
  23501. */
  23502. bindOnlyWorldMatrix(world: Matrix): void;
  23503. /**
  23504. * Binds the submesh to this material by preparing the effect and shader to draw
  23505. * @param world defines the world transformation matrix
  23506. * @param mesh defines the mesh containing the submesh
  23507. * @param subMesh defines the submesh to bind the material to
  23508. */
  23509. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  23510. /**
  23511. * Gets the active textures from the material
  23512. * @returns an array of textures
  23513. */
  23514. getActiveTextures(): BaseTexture[];
  23515. /**
  23516. * Gets the list of texture blocks
  23517. * @returns an array of texture blocks
  23518. */
  23519. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  23520. /**
  23521. * Specifies if the material uses a texture
  23522. * @param texture defines the texture to check against the material
  23523. * @returns a boolean specifying if the material uses the texture
  23524. */
  23525. hasTexture(texture: BaseTexture): boolean;
  23526. /**
  23527. * Disposes the material
  23528. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  23529. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  23530. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  23531. */
  23532. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  23533. /** Creates the node editor window. */
  23534. private _createNodeEditor;
  23535. /**
  23536. * Launch the node material editor
  23537. * @param config Define the configuration of the editor
  23538. * @return a promise fulfilled when the node editor is visible
  23539. */
  23540. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  23541. /**
  23542. * Clear the current material
  23543. */
  23544. clear(): void;
  23545. /**
  23546. * Clear the current material and set it to a default state
  23547. */
  23548. setToDefault(): void;
  23549. /**
  23550. * Clear the current material and set it to a default state for post process
  23551. */
  23552. setToDefaultPostProcess(): void;
  23553. /**
  23554. * Clear the current material and set it to a default state for procedural texture
  23555. */
  23556. setToDefaultProceduralTexture(): void;
  23557. /**
  23558. * Clear the current material and set it to a default state for particle
  23559. */
  23560. setToDefaultParticle(): void;
  23561. /**
  23562. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  23563. * @param url defines the url to load from
  23564. * @returns a promise that will fullfil when the material is fully loaded
  23565. */
  23566. loadAsync(url: string): Promise<void>;
  23567. private _gatherBlocks;
  23568. /**
  23569. * Generate a string containing the code declaration required to create an equivalent of this material
  23570. * @returns a string
  23571. */
  23572. generateCode(): string;
  23573. /**
  23574. * Serializes this material in a JSON representation
  23575. * @returns the serialized material object
  23576. */
  23577. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  23578. private _restoreConnections;
  23579. /**
  23580. * Clear the current graph and load a new one from a serialization object
  23581. * @param source defines the JSON representation of the material
  23582. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23583. * @param merge defines whether or not the source must be merged or replace the current content
  23584. */
  23585. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  23586. /**
  23587. * Makes a duplicate of the current material.
  23588. * @param name - name to use for the new material.
  23589. */
  23590. clone(name: string): NodeMaterial;
  23591. /**
  23592. * Creates a node material from parsed material data
  23593. * @param source defines the JSON representation of the material
  23594. * @param scene defines the hosting scene
  23595. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23596. * @returns a new node material
  23597. */
  23598. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  23599. /**
  23600. * Creates a node material from a snippet saved in a remote file
  23601. * @param name defines the name of the material to create
  23602. * @param url defines the url to load from
  23603. * @param scene defines the hosting scene
  23604. * @returns a promise that will resolve to the new node material
  23605. */
  23606. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  23607. /**
  23608. * Creates a node material from a snippet saved by the node material editor
  23609. * @param snippetId defines the snippet to load
  23610. * @param scene defines the hosting scene
  23611. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  23612. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  23613. * @returns a promise that will resolve to the new node material
  23614. */
  23615. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  23616. /**
  23617. * Creates a new node material set to default basic configuration
  23618. * @param name defines the name of the material
  23619. * @param scene defines the hosting scene
  23620. * @returns a new NodeMaterial
  23621. */
  23622. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  23623. }
  23624. }
  23625. declare module "babylonjs/Engines/Extensions/engine.multiRender" {
  23626. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  23627. import { IMultiRenderTargetOptions } from "babylonjs/Materials/Textures/multiRenderTarget";
  23628. import { Nullable } from "babylonjs/types";
  23629. module "babylonjs/Engines/thinEngine" {
  23630. interface ThinEngine {
  23631. /**
  23632. * Unbind a list of render target textures from the webGL context
  23633. * This is used only when drawBuffer extension or webGL2 are active
  23634. * @param textures defines the render target textures to unbind
  23635. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  23636. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  23637. */
  23638. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  23639. /**
  23640. * Create a multi render target texture
  23641. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  23642. * @param size defines the size of the texture
  23643. * @param options defines the creation options
  23644. * @returns the cube texture as an InternalTexture
  23645. */
  23646. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  23647. /**
  23648. * Update the sample count for a given multiple render target texture
  23649. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  23650. * @param textures defines the textures to update
  23651. * @param samples defines the sample count to set
  23652. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  23653. */
  23654. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  23655. /**
  23656. * Select a subsets of attachments to draw to.
  23657. * @param attachments gl attachments
  23658. */
  23659. bindAttachments(attachments: number[]): void;
  23660. }
  23661. }
  23662. }
  23663. declare module "babylonjs/Materials/Textures/multiRenderTarget" {
  23664. import { Scene } from "babylonjs/scene";
  23665. import { Engine } from "babylonjs/Engines/engine";
  23666. import { Texture } from "babylonjs/Materials/Textures/texture";
  23667. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  23668. import "babylonjs/Engines/Extensions/engine.multiRender";
  23669. /**
  23670. * Creation options of the multi render target texture.
  23671. */
  23672. export interface IMultiRenderTargetOptions {
  23673. /**
  23674. * Define if the texture needs to create mip maps after render.
  23675. */
  23676. generateMipMaps?: boolean;
  23677. /**
  23678. * Define the types of all the draw buffers we want to create
  23679. */
  23680. types?: number[];
  23681. /**
  23682. * Define the sampling modes of all the draw buffers we want to create
  23683. */
  23684. samplingModes?: number[];
  23685. /**
  23686. * Define if a depth buffer is required
  23687. */
  23688. generateDepthBuffer?: boolean;
  23689. /**
  23690. * Define if a stencil buffer is required
  23691. */
  23692. generateStencilBuffer?: boolean;
  23693. /**
  23694. * Define if a depth texture is required instead of a depth buffer
  23695. */
  23696. generateDepthTexture?: boolean;
  23697. /**
  23698. * Define the number of desired draw buffers
  23699. */
  23700. textureCount?: number;
  23701. /**
  23702. * Define if aspect ratio should be adapted to the texture or stay the scene one
  23703. */
  23704. doNotChangeAspectRatio?: boolean;
  23705. /**
  23706. * Define the default type of the buffers we are creating
  23707. */
  23708. defaultType?: number;
  23709. }
  23710. /**
  23711. * A multi render target, like a render target provides the ability to render to a texture.
  23712. * Unlike the render target, it can render to several draw buffers in one draw.
  23713. * This is specially interesting in deferred rendering or for any effects requiring more than
  23714. * just one color from a single pass.
  23715. */
  23716. export class MultiRenderTarget extends RenderTargetTexture {
  23717. private _internalTextures;
  23718. private _textures;
  23719. private _multiRenderTargetOptions;
  23720. private _count;
  23721. /**
  23722. * Get if draw buffers are currently supported by the used hardware and browser.
  23723. */
  23724. get isSupported(): boolean;
  23725. /**
  23726. * Get the list of textures generated by the multi render target.
  23727. */
  23728. get textures(): Texture[];
  23729. /**
  23730. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  23731. */
  23732. get count(): number;
  23733. /**
  23734. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  23735. */
  23736. get depthTexture(): Texture;
  23737. /**
  23738. * Set the wrapping mode on U of all the textures we are rendering to.
  23739. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23740. */
  23741. set wrapU(wrap: number);
  23742. /**
  23743. * Set the wrapping mode on V of all the textures we are rendering to.
  23744. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  23745. */
  23746. set wrapV(wrap: number);
  23747. /**
  23748. * Instantiate a new multi render target texture.
  23749. * A multi render target, like a render target provides the ability to render to a texture.
  23750. * Unlike the render target, it can render to several draw buffers in one draw.
  23751. * This is specially interesting in deferred rendering or for any effects requiring more than
  23752. * just one color from a single pass.
  23753. * @param name Define the name of the texture
  23754. * @param size Define the size of the buffers to render to
  23755. * @param count Define the number of target we are rendering into
  23756. * @param scene Define the scene the texture belongs to
  23757. * @param options Define the options used to create the multi render target
  23758. */
  23759. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  23760. private _initTypes;
  23761. /** @hidden */
  23762. _rebuild(forceFullRebuild?: boolean): void;
  23763. private _createInternalTextures;
  23764. private _createTextures;
  23765. /**
  23766. * Define the number of samples used if MSAA is enabled.
  23767. */
  23768. get samples(): number;
  23769. set samples(value: number);
  23770. /**
  23771. * Resize all the textures in the multi render target.
  23772. * Be careful as it will recreate all the data in the new texture.
  23773. * @param size Define the new size
  23774. */
  23775. resize(size: any): void;
  23776. /**
  23777. * Changes the number of render targets in this MRT
  23778. * Be careful as it will recreate all the data in the new texture.
  23779. * @param count new texture count
  23780. * @param options Specifies texture types and sampling modes for new textures
  23781. */
  23782. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  23783. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  23784. /**
  23785. * Dispose the render targets and their associated resources
  23786. */
  23787. dispose(): void;
  23788. /**
  23789. * Release all the underlying texture used as draw buffers.
  23790. */
  23791. releaseInternalTextures(): void;
  23792. }
  23793. }
  23794. declare module "babylonjs/Shaders/imageProcessing.fragment" {
  23795. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  23796. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  23797. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  23798. /** @hidden */
  23799. export var imageProcessingPixelShader: {
  23800. name: string;
  23801. shader: string;
  23802. };
  23803. }
  23804. declare module "babylonjs/PostProcesses/imageProcessingPostProcess" {
  23805. import { Nullable } from "babylonjs/types";
  23806. import { Color4 } from "babylonjs/Maths/math.color";
  23807. import { Camera } from "babylonjs/Cameras/camera";
  23808. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  23809. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  23810. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  23811. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  23812. import { Engine } from "babylonjs/Engines/engine";
  23813. import "babylonjs/Shaders/imageProcessing.fragment";
  23814. import "babylonjs/Shaders/postprocess.vertex";
  23815. /**
  23816. * ImageProcessingPostProcess
  23817. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  23818. */
  23819. export class ImageProcessingPostProcess extends PostProcess {
  23820. /**
  23821. * Default configuration related to image processing available in the PBR Material.
  23822. */
  23823. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  23824. /**
  23825. * Gets the image processing configuration used either in this material.
  23826. */
  23827. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  23828. /**
  23829. * Sets the Default image processing configuration used either in the this material.
  23830. *
  23831. * If sets to null, the scene one is in use.
  23832. */
  23833. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  23834. /**
  23835. * Keep track of the image processing observer to allow dispose and replace.
  23836. */
  23837. private _imageProcessingObserver;
  23838. /**
  23839. * Attaches a new image processing configuration to the PBR Material.
  23840. * @param configuration
  23841. */
  23842. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  23843. /**
  23844. * If the post process is supported.
  23845. */
  23846. get isSupported(): boolean;
  23847. /**
  23848. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23849. */
  23850. get colorCurves(): Nullable<ColorCurves>;
  23851. /**
  23852. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  23853. */
  23854. set colorCurves(value: Nullable<ColorCurves>);
  23855. /**
  23856. * Gets wether the color curves effect is enabled.
  23857. */
  23858. get colorCurvesEnabled(): boolean;
  23859. /**
  23860. * Sets wether the color curves effect is enabled.
  23861. */
  23862. set colorCurvesEnabled(value: boolean);
  23863. /**
  23864. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23865. */
  23866. get colorGradingTexture(): Nullable<BaseTexture>;
  23867. /**
  23868. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  23869. */
  23870. set colorGradingTexture(value: Nullable<BaseTexture>);
  23871. /**
  23872. * Gets wether the color grading effect is enabled.
  23873. */
  23874. get colorGradingEnabled(): boolean;
  23875. /**
  23876. * Gets wether the color grading effect is enabled.
  23877. */
  23878. set colorGradingEnabled(value: boolean);
  23879. /**
  23880. * Gets exposure used in the effect.
  23881. */
  23882. get exposure(): number;
  23883. /**
  23884. * Sets exposure used in the effect.
  23885. */
  23886. set exposure(value: number);
  23887. /**
  23888. * Gets wether tonemapping is enabled or not.
  23889. */
  23890. get toneMappingEnabled(): boolean;
  23891. /**
  23892. * Sets wether tonemapping is enabled or not
  23893. */
  23894. set toneMappingEnabled(value: boolean);
  23895. /**
  23896. * Gets the type of tone mapping effect.
  23897. */
  23898. get toneMappingType(): number;
  23899. /**
  23900. * Sets the type of tone mapping effect.
  23901. */
  23902. set toneMappingType(value: number);
  23903. /**
  23904. * Gets contrast used in the effect.
  23905. */
  23906. get contrast(): number;
  23907. /**
  23908. * Sets contrast used in the effect.
  23909. */
  23910. set contrast(value: number);
  23911. /**
  23912. * Gets Vignette stretch size.
  23913. */
  23914. get vignetteStretch(): number;
  23915. /**
  23916. * Sets Vignette stretch size.
  23917. */
  23918. set vignetteStretch(value: number);
  23919. /**
  23920. * Gets Vignette centre X Offset.
  23921. */
  23922. get vignetteCentreX(): number;
  23923. /**
  23924. * Sets Vignette centre X Offset.
  23925. */
  23926. set vignetteCentreX(value: number);
  23927. /**
  23928. * Gets Vignette centre Y Offset.
  23929. */
  23930. get vignetteCentreY(): number;
  23931. /**
  23932. * Sets Vignette centre Y Offset.
  23933. */
  23934. set vignetteCentreY(value: number);
  23935. /**
  23936. * Gets Vignette weight or intensity of the vignette effect.
  23937. */
  23938. get vignetteWeight(): number;
  23939. /**
  23940. * Sets Vignette weight or intensity of the vignette effect.
  23941. */
  23942. set vignetteWeight(value: number);
  23943. /**
  23944. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23945. * if vignetteEnabled is set to true.
  23946. */
  23947. get vignetteColor(): Color4;
  23948. /**
  23949. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  23950. * if vignetteEnabled is set to true.
  23951. */
  23952. set vignetteColor(value: Color4);
  23953. /**
  23954. * Gets Camera field of view used by the Vignette effect.
  23955. */
  23956. get vignetteCameraFov(): number;
  23957. /**
  23958. * Sets Camera field of view used by the Vignette effect.
  23959. */
  23960. set vignetteCameraFov(value: number);
  23961. /**
  23962. * Gets the vignette blend mode allowing different kind of effect.
  23963. */
  23964. get vignetteBlendMode(): number;
  23965. /**
  23966. * Sets the vignette blend mode allowing different kind of effect.
  23967. */
  23968. set vignetteBlendMode(value: number);
  23969. /**
  23970. * Gets wether the vignette effect is enabled.
  23971. */
  23972. get vignetteEnabled(): boolean;
  23973. /**
  23974. * Sets wether the vignette effect is enabled.
  23975. */
  23976. set vignetteEnabled(value: boolean);
  23977. private _fromLinearSpace;
  23978. /**
  23979. * Gets wether the input of the processing is in Gamma or Linear Space.
  23980. */
  23981. get fromLinearSpace(): boolean;
  23982. /**
  23983. * Sets wether the input of the processing is in Gamma or Linear Space.
  23984. */
  23985. set fromLinearSpace(value: boolean);
  23986. /**
  23987. * Defines cache preventing GC.
  23988. */
  23989. private _defines;
  23990. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  23991. /**
  23992. * "ImageProcessingPostProcess"
  23993. * @returns "ImageProcessingPostProcess"
  23994. */
  23995. getClassName(): string;
  23996. /**
  23997. * @hidden
  23998. */
  23999. _updateParameters(): void;
  24000. dispose(camera?: Camera): void;
  24001. }
  24002. }
  24003. declare module "babylonjs/Rendering/prePassEffectConfiguration" {
  24004. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  24005. /**
  24006. * Interface for defining prepass effects in the prepass post-process pipeline
  24007. */
  24008. export interface PrePassEffectConfiguration {
  24009. /**
  24010. * Name of the effect
  24011. */
  24012. name: string;
  24013. /**
  24014. * Post process to attach for this effect
  24015. */
  24016. postProcess?: PostProcess;
  24017. /**
  24018. * Textures required in the MRT
  24019. */
  24020. texturesRequired: number[];
  24021. /**
  24022. * Is the effect enabled
  24023. */
  24024. enabled: boolean;
  24025. /**
  24026. * Disposes the effect configuration
  24027. */
  24028. dispose?: () => void;
  24029. /**
  24030. * Creates the associated post process
  24031. */
  24032. createPostProcess?: () => PostProcess;
  24033. }
  24034. }
  24035. declare module "babylonjs/Rendering/prePassRenderer" {
  24036. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  24037. import { Scene } from "babylonjs/scene";
  24038. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  24039. import { Effect } from "babylonjs/Materials/effect";
  24040. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24041. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  24042. /**
  24043. * Renders a pre pass of the scene
  24044. * This means every mesh in the scene will be rendered to a render target texture
  24045. * And then this texture will be composited to the rendering canvas with post processes
  24046. * It is necessary for effects like subsurface scattering or deferred shading
  24047. */
  24048. export class PrePassRenderer {
  24049. /** @hidden */
  24050. static _SceneComponentInitialization: (scene: Scene) => void;
  24051. private _textureFormats;
  24052. /**
  24053. * To save performance, we can excluded skinned meshes from the prepass
  24054. */
  24055. excludedSkinnedMesh: AbstractMesh[];
  24056. private _textureIndices;
  24057. private _scene;
  24058. private _engine;
  24059. private _isDirty;
  24060. /**
  24061. * Number of textures in the multi render target texture where the scene is directly rendered
  24062. */
  24063. mrtCount: number;
  24064. /**
  24065. * The render target where the scene is directly rendered
  24066. */
  24067. prePassRT: MultiRenderTarget;
  24068. private _multiRenderAttachments;
  24069. private _defaultAttachments;
  24070. private _clearAttachments;
  24071. private _postProcesses;
  24072. private readonly _clearColor;
  24073. /**
  24074. * Image processing post process for composition
  24075. */
  24076. imageProcessingPostProcess: ImageProcessingPostProcess;
  24077. /**
  24078. * Configuration for prepass effects
  24079. */
  24080. private _effectConfigurations;
  24081. private _mrtFormats;
  24082. private _mrtLayout;
  24083. private _enabled;
  24084. /**
  24085. * Indicates if the prepass is enabled
  24086. */
  24087. get enabled(): boolean;
  24088. /**
  24089. * How many samples are used for MSAA of the scene render target
  24090. */
  24091. get samples(): number;
  24092. set samples(n: number);
  24093. /**
  24094. * Instanciates a prepass renderer
  24095. * @param scene The scene
  24096. */
  24097. constructor(scene: Scene);
  24098. private _initializeAttachments;
  24099. private _createCompositionEffect;
  24100. /**
  24101. * Indicates if rendering a prepass is supported
  24102. */
  24103. get isSupported(): boolean;
  24104. /**
  24105. * Sets the proper output textures to draw in the engine.
  24106. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  24107. */
  24108. bindAttachmentsForEffect(effect: Effect): void;
  24109. /**
  24110. * @hidden
  24111. */
  24112. _beforeCameraDraw(): void;
  24113. /**
  24114. * @hidden
  24115. */
  24116. _afterCameraDraw(): void;
  24117. private _checkRTSize;
  24118. private _bindFrameBuffer;
  24119. /**
  24120. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  24121. */
  24122. clear(): void;
  24123. private _setState;
  24124. /**
  24125. * Adds an effect configuration to the prepass.
  24126. * If an effect has already been added, it won't add it twice and will return the configuration
  24127. * already present.
  24128. * @param cfg the effect configuration
  24129. * @return the effect configuration now used by the prepass
  24130. */
  24131. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  24132. /**
  24133. * Returns the index of a texture in the multi render target texture array.
  24134. * @param type Texture type
  24135. * @return The index
  24136. */
  24137. getIndex(type: number): number;
  24138. private _enable;
  24139. private _disable;
  24140. private _resetLayout;
  24141. private _resetPostProcessChain;
  24142. private _bindPostProcessChain;
  24143. /**
  24144. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  24145. */
  24146. markAsDirty(): void;
  24147. /**
  24148. * Enables a texture on the MultiRenderTarget for prepass
  24149. */
  24150. private _enableTextures;
  24151. private _update;
  24152. private _markAllMaterialsAsPrePassDirty;
  24153. /**
  24154. * Disposes the prepass renderer.
  24155. */
  24156. dispose(): void;
  24157. }
  24158. }
  24159. declare module "babylonjs/PostProcesses/postProcess" {
  24160. import { Nullable } from "babylonjs/types";
  24161. import { SmartArray } from "babylonjs/Misc/smartArray";
  24162. import { Observable } from "babylonjs/Misc/observable";
  24163. import { Vector2 } from "babylonjs/Maths/math.vector";
  24164. import { Camera } from "babylonjs/Cameras/camera";
  24165. import { Effect } from "babylonjs/Materials/effect";
  24166. import "babylonjs/Shaders/postprocess.vertex";
  24167. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24168. import { Engine } from "babylonjs/Engines/engine";
  24169. import { Color4 } from "babylonjs/Maths/math.color";
  24170. import "babylonjs/Engines/Extensions/engine.renderTarget";
  24171. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  24172. import { Scene } from "babylonjs/scene";
  24173. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  24174. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  24175. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  24176. /**
  24177. * Size options for a post process
  24178. */
  24179. export type PostProcessOptions = {
  24180. width: number;
  24181. height: number;
  24182. };
  24183. /**
  24184. * PostProcess can be used to apply a shader to a texture after it has been rendered
  24185. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  24186. */
  24187. export class PostProcess {
  24188. /**
  24189. * Gets or sets the unique id of the post process
  24190. */
  24191. uniqueId: number;
  24192. /** Name of the PostProcess. */
  24193. name: string;
  24194. /**
  24195. * Width of the texture to apply the post process on
  24196. */
  24197. width: number;
  24198. /**
  24199. * Height of the texture to apply the post process on
  24200. */
  24201. height: number;
  24202. /**
  24203. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  24204. */
  24205. nodeMaterialSource: Nullable<NodeMaterial>;
  24206. /**
  24207. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  24208. * @hidden
  24209. */
  24210. _outputTexture: Nullable<InternalTexture>;
  24211. /**
  24212. * Sampling mode used by the shader
  24213. * See https://doc.babylonjs.com/classes/3.1/texture
  24214. */
  24215. renderTargetSamplingMode: number;
  24216. /**
  24217. * Clear color to use when screen clearing
  24218. */
  24219. clearColor: Color4;
  24220. /**
  24221. * If the buffer needs to be cleared before applying the post process. (default: true)
  24222. * Should be set to false if shader will overwrite all previous pixels.
  24223. */
  24224. autoClear: boolean;
  24225. /**
  24226. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  24227. */
  24228. alphaMode: number;
  24229. /**
  24230. * Sets the setAlphaBlendConstants of the babylon engine
  24231. */
  24232. alphaConstants: Color4;
  24233. /**
  24234. * Animations to be used for the post processing
  24235. */
  24236. animations: import("babylonjs/Animations/animation").Animation[];
  24237. /**
  24238. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  24239. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  24240. */
  24241. enablePixelPerfectMode: boolean;
  24242. /**
  24243. * Force the postprocess to be applied without taking in account viewport
  24244. */
  24245. forceFullscreenViewport: boolean;
  24246. /**
  24247. * List of inspectable custom properties (used by the Inspector)
  24248. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24249. */
  24250. inspectableCustomProperties: IInspectable[];
  24251. /**
  24252. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  24253. *
  24254. * | Value | Type | Description |
  24255. * | ----- | ----------------------------------- | ----------- |
  24256. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  24257. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  24258. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  24259. *
  24260. */
  24261. scaleMode: number;
  24262. /**
  24263. * Force textures to be a power of two (default: false)
  24264. */
  24265. alwaysForcePOT: boolean;
  24266. private _samples;
  24267. /**
  24268. * Number of sample textures (default: 1)
  24269. */
  24270. get samples(): number;
  24271. set samples(n: number);
  24272. /**
  24273. * Modify the scale of the post process to be the same as the viewport (default: false)
  24274. */
  24275. adaptScaleToCurrentViewport: boolean;
  24276. private _camera;
  24277. protected _scene: Scene;
  24278. private _engine;
  24279. private _options;
  24280. private _reusable;
  24281. private _textureType;
  24282. private _textureFormat;
  24283. /**
  24284. * Smart array of input and output textures for the post process.
  24285. * @hidden
  24286. */
  24287. _textures: SmartArray<import("babylonjs/Materials/Textures/internalTexture").InternalTexture>;
  24288. /**
  24289. * The index in _textures that corresponds to the output texture.
  24290. * @hidden
  24291. */
  24292. _currentRenderTextureInd: number;
  24293. private _effect;
  24294. private _samplers;
  24295. private _fragmentUrl;
  24296. private _vertexUrl;
  24297. private _parameters;
  24298. private _scaleRatio;
  24299. protected _indexParameters: any;
  24300. private _shareOutputWithPostProcess;
  24301. private _texelSize;
  24302. private _forcedOutputTexture;
  24303. /**
  24304. * Prepass configuration in case this post process needs a texture from prepass
  24305. * @hidden
  24306. */
  24307. _prePassEffectConfiguration: PrePassEffectConfiguration;
  24308. /**
  24309. * Returns the fragment url or shader name used in the post process.
  24310. * @returns the fragment url or name in the shader store.
  24311. */
  24312. getEffectName(): string;
  24313. /**
  24314. * An event triggered when the postprocess is activated.
  24315. */
  24316. onActivateObservable: Observable<Camera>;
  24317. private _onActivateObserver;
  24318. /**
  24319. * A function that is added to the onActivateObservable
  24320. */
  24321. set onActivate(callback: Nullable<(camera: Camera) => void>);
  24322. /**
  24323. * An event triggered when the postprocess changes its size.
  24324. */
  24325. onSizeChangedObservable: Observable<PostProcess>;
  24326. private _onSizeChangedObserver;
  24327. /**
  24328. * A function that is added to the onSizeChangedObservable
  24329. */
  24330. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  24331. /**
  24332. * An event triggered when the postprocess applies its effect.
  24333. */
  24334. onApplyObservable: Observable<Effect>;
  24335. private _onApplyObserver;
  24336. /**
  24337. * A function that is added to the onApplyObservable
  24338. */
  24339. set onApply(callback: (effect: Effect) => void);
  24340. /**
  24341. * An event triggered before rendering the postprocess
  24342. */
  24343. onBeforeRenderObservable: Observable<Effect>;
  24344. private _onBeforeRenderObserver;
  24345. /**
  24346. * A function that is added to the onBeforeRenderObservable
  24347. */
  24348. set onBeforeRender(callback: (effect: Effect) => void);
  24349. /**
  24350. * An event triggered after rendering the postprocess
  24351. */
  24352. onAfterRenderObservable: Observable<Effect>;
  24353. private _onAfterRenderObserver;
  24354. /**
  24355. * A function that is added to the onAfterRenderObservable
  24356. */
  24357. set onAfterRender(callback: (efect: Effect) => void);
  24358. /**
  24359. * 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
  24360. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  24361. */
  24362. get inputTexture(): InternalTexture;
  24363. set inputTexture(value: InternalTexture);
  24364. /**
  24365. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  24366. * the only way to unset it is to use this function to restore its internal state
  24367. */
  24368. restoreDefaultInputTexture(): void;
  24369. /**
  24370. * Gets the camera which post process is applied to.
  24371. * @returns The camera the post process is applied to.
  24372. */
  24373. getCamera(): Camera;
  24374. /**
  24375. * Gets the texel size of the postprocess.
  24376. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  24377. */
  24378. get texelSize(): Vector2;
  24379. /**
  24380. * Creates a new instance PostProcess
  24381. * @param name The name of the PostProcess.
  24382. * @param fragmentUrl The url of the fragment shader to be used.
  24383. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  24384. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  24385. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24386. * @param camera The camera to apply the render pass to.
  24387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24388. * @param engine The engine which the post process will be applied. (default: current engine)
  24389. * @param reusable If the post process can be reused on the same frame. (default: false)
  24390. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  24391. * @param textureType Type of textures used when performing the post process. (default: 0)
  24392. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  24393. * @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
  24394. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  24395. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  24396. */
  24397. 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);
  24398. /**
  24399. * Gets a string identifying the name of the class
  24400. * @returns "PostProcess" string
  24401. */
  24402. getClassName(): string;
  24403. /**
  24404. * Gets the engine which this post process belongs to.
  24405. * @returns The engine the post process was enabled with.
  24406. */
  24407. getEngine(): Engine;
  24408. /**
  24409. * The effect that is created when initializing the post process.
  24410. * @returns The created effect corresponding the the postprocess.
  24411. */
  24412. getEffect(): Effect;
  24413. /**
  24414. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  24415. * @param postProcess The post process to share the output with.
  24416. * @returns This post process.
  24417. */
  24418. shareOutputWith(postProcess: PostProcess): PostProcess;
  24419. /**
  24420. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  24421. * This should be called if the post process that shares output with this post process is disabled/disposed.
  24422. */
  24423. useOwnOutput(): void;
  24424. /**
  24425. * Updates the effect with the current post process compile time values and recompiles the shader.
  24426. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24427. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24428. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24429. * @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
  24430. * @param onCompiled Called when the shader has been compiled.
  24431. * @param onError Called if there is an error when compiling a shader.
  24432. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  24433. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  24434. */
  24435. 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;
  24436. /**
  24437. * The post process is reusable if it can be used multiple times within one frame.
  24438. * @returns If the post process is reusable
  24439. */
  24440. isReusable(): boolean;
  24441. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  24442. markTextureDirty(): void;
  24443. /**
  24444. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  24445. * 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.
  24446. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  24447. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  24448. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  24449. * @returns The target texture that was bound to be written to.
  24450. */
  24451. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  24452. /**
  24453. * If the post process is supported.
  24454. */
  24455. get isSupported(): boolean;
  24456. /**
  24457. * The aspect ratio of the output texture.
  24458. */
  24459. get aspectRatio(): number;
  24460. /**
  24461. * Get a value indicating if the post-process is ready to be used
  24462. * @returns true if the post-process is ready (shader is compiled)
  24463. */
  24464. isReady(): boolean;
  24465. /**
  24466. * Binds all textures and uniforms to the shader, this will be run on every pass.
  24467. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  24468. */
  24469. apply(): Nullable<Effect>;
  24470. private _disposeTextures;
  24471. /**
  24472. * Sets the required values to the prepass renderer.
  24473. * @param prePassRenderer defines the prepass renderer to setup.
  24474. * @returns true if the pre pass is needed.
  24475. */
  24476. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  24477. /**
  24478. * Disposes the post process.
  24479. * @param camera The camera to dispose the post process on.
  24480. */
  24481. dispose(camera?: Camera): void;
  24482. /**
  24483. * Serializes the particle system to a JSON object
  24484. * @returns the JSON object
  24485. */
  24486. serialize(): any;
  24487. /**
  24488. * Creates a material from parsed material data
  24489. * @param parsedPostProcess defines parsed post process data
  24490. * @param scene defines the hosting scene
  24491. * @param rootUrl defines the root URL to use to load textures
  24492. * @returns a new post process
  24493. */
  24494. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  24495. }
  24496. }
  24497. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration" {
  24498. /** @hidden */
  24499. export var kernelBlurVaryingDeclaration: {
  24500. name: string;
  24501. shader: string;
  24502. };
  24503. }
  24504. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment" {
  24505. /** @hidden */
  24506. export var kernelBlurFragment: {
  24507. name: string;
  24508. shader: string;
  24509. };
  24510. }
  24511. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2" {
  24512. /** @hidden */
  24513. export var kernelBlurFragment2: {
  24514. name: string;
  24515. shader: string;
  24516. };
  24517. }
  24518. declare module "babylonjs/Shaders/kernelBlur.fragment" {
  24519. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24520. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  24521. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment";
  24522. import "babylonjs/Shaders/ShadersInclude/kernelBlurFragment2";
  24523. /** @hidden */
  24524. export var kernelBlurPixelShader: {
  24525. name: string;
  24526. shader: string;
  24527. };
  24528. }
  24529. declare module "babylonjs/Shaders/ShadersInclude/kernelBlurVertex" {
  24530. /** @hidden */
  24531. export var kernelBlurVertex: {
  24532. name: string;
  24533. shader: string;
  24534. };
  24535. }
  24536. declare module "babylonjs/Shaders/kernelBlur.vertex" {
  24537. import "babylonjs/Shaders/ShadersInclude/kernelBlurVaryingDeclaration";
  24538. import "babylonjs/Shaders/ShadersInclude/kernelBlurVertex";
  24539. /** @hidden */
  24540. export var kernelBlurVertexShader: {
  24541. name: string;
  24542. shader: string;
  24543. };
  24544. }
  24545. declare module "babylonjs/PostProcesses/blurPostProcess" {
  24546. import { Vector2 } from "babylonjs/Maths/math.vector";
  24547. import { Nullable } from "babylonjs/types";
  24548. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  24549. import { Camera } from "babylonjs/Cameras/camera";
  24550. import { Effect } from "babylonjs/Materials/effect";
  24551. import { Engine } from "babylonjs/Engines/engine";
  24552. import "babylonjs/Shaders/kernelBlur.fragment";
  24553. import "babylonjs/Shaders/kernelBlur.vertex";
  24554. import { Scene } from "babylonjs/scene";
  24555. /**
  24556. * The Blur Post Process which blurs an image based on a kernel and direction.
  24557. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  24558. */
  24559. export class BlurPostProcess extends PostProcess {
  24560. private blockCompilation;
  24561. protected _kernel: number;
  24562. protected _idealKernel: number;
  24563. protected _packedFloat: boolean;
  24564. private _staticDefines;
  24565. /** The direction in which to blur the image. */
  24566. direction: Vector2;
  24567. /**
  24568. * Sets the length in pixels of the blur sample region
  24569. */
  24570. set kernel(v: number);
  24571. /**
  24572. * Gets the length in pixels of the blur sample region
  24573. */
  24574. get kernel(): number;
  24575. /**
  24576. * Sets wether or not the blur needs to unpack/repack floats
  24577. */
  24578. set packedFloat(v: boolean);
  24579. /**
  24580. * Gets wether or not the blur is unpacking/repacking floats
  24581. */
  24582. get packedFloat(): boolean;
  24583. /**
  24584. * Gets a string identifying the name of the class
  24585. * @returns "BlurPostProcess" string
  24586. */
  24587. getClassName(): string;
  24588. /**
  24589. * Creates a new instance BlurPostProcess
  24590. * @param name The name of the effect.
  24591. * @param direction The direction in which to blur the image.
  24592. * @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.
  24593. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  24594. * @param camera The camera to apply the render pass to.
  24595. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  24596. * @param engine The engine which the post process will be applied. (default: current engine)
  24597. * @param reusable If the post process can be reused on the same frame. (default: false)
  24598. * @param textureType Type of textures used when performing the post process. (default: 0)
  24599. * @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)
  24600. */
  24601. 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);
  24602. /**
  24603. * Updates the effect with the current post process compile time values and recompiles the shader.
  24604. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  24605. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  24606. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  24607. * @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
  24608. * @param onCompiled Called when the shader has been compiled.
  24609. * @param onError Called if there is an error when compiling a shader.
  24610. */
  24611. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24612. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  24613. /**
  24614. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  24615. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  24616. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  24617. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  24618. * The gaps between physical kernels are compensated for in the weighting of the samples
  24619. * @param idealKernel Ideal blur kernel.
  24620. * @return Nearest best kernel.
  24621. */
  24622. protected _nearestBestKernel(idealKernel: number): number;
  24623. /**
  24624. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  24625. * @param x The point on the Gaussian distribution to sample.
  24626. * @return the value of the Gaussian function at x.
  24627. */
  24628. protected _gaussianWeight(x: number): number;
  24629. /**
  24630. * Generates a string that can be used as a floating point number in GLSL.
  24631. * @param x Value to print.
  24632. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  24633. * @return GLSL float string.
  24634. */
  24635. protected _glslFloat(x: number, decimalFigures?: number): string;
  24636. /** @hidden */
  24637. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  24638. }
  24639. }
  24640. declare module "babylonjs/Materials/Textures/mirrorTexture" {
  24641. import { Scene } from "babylonjs/scene";
  24642. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24643. import { Plane } from "babylonjs/Maths/math.plane";
  24644. /**
  24645. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24646. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24647. * You can then easily use it as a reflectionTexture on a flat surface.
  24648. * In case the surface is not a plane, please consider relying on reflection probes.
  24649. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24650. */
  24651. export class MirrorTexture extends RenderTargetTexture {
  24652. private scene;
  24653. /**
  24654. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  24655. * 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.
  24656. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24657. */
  24658. mirrorPlane: Plane;
  24659. /**
  24660. * Define the blur ratio used to blur the reflection if needed.
  24661. */
  24662. set blurRatio(value: number);
  24663. get blurRatio(): number;
  24664. /**
  24665. * Define the adaptive blur kernel used to blur the reflection if needed.
  24666. * This will autocompute the closest best match for the `blurKernel`
  24667. */
  24668. set adaptiveBlurKernel(value: number);
  24669. /**
  24670. * Define the blur kernel used to blur the reflection if needed.
  24671. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24672. */
  24673. set blurKernel(value: number);
  24674. /**
  24675. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  24676. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24677. */
  24678. set blurKernelX(value: number);
  24679. get blurKernelX(): number;
  24680. /**
  24681. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  24682. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  24683. */
  24684. set blurKernelY(value: number);
  24685. get blurKernelY(): number;
  24686. private _autoComputeBlurKernel;
  24687. protected _onRatioRescale(): void;
  24688. private _updateGammaSpace;
  24689. private _imageProcessingConfigChangeObserver;
  24690. private _transformMatrix;
  24691. private _mirrorMatrix;
  24692. private _savedViewMatrix;
  24693. private _blurX;
  24694. private _blurY;
  24695. private _adaptiveBlurKernel;
  24696. private _blurKernelX;
  24697. private _blurKernelY;
  24698. private _blurRatio;
  24699. /**
  24700. * Instantiates a Mirror Texture.
  24701. * Mirror texture can be used to simulate the view from a mirror in a scene.
  24702. * It will dynamically be rendered every frame to adapt to the camera point of view.
  24703. * You can then easily use it as a reflectionTexture on a flat surface.
  24704. * In case the surface is not a plane, please consider relying on reflection probes.
  24705. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  24706. * @param name
  24707. * @param size
  24708. * @param scene
  24709. * @param generateMipMaps
  24710. * @param type
  24711. * @param samplingMode
  24712. * @param generateDepthBuffer
  24713. */
  24714. constructor(name: string, size: number | {
  24715. width: number;
  24716. height: number;
  24717. } | {
  24718. ratio: number;
  24719. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  24720. private _preparePostProcesses;
  24721. /**
  24722. * Clone the mirror texture.
  24723. * @returns the cloned texture
  24724. */
  24725. clone(): MirrorTexture;
  24726. /**
  24727. * Serialize the texture to a JSON representation you could use in Parse later on
  24728. * @returns the serialized JSON representation
  24729. */
  24730. serialize(): any;
  24731. /**
  24732. * Dispose the texture and release its associated resources.
  24733. */
  24734. dispose(): void;
  24735. }
  24736. }
  24737. declare module "babylonjs/Materials/Textures/texture" {
  24738. import { Observable } from "babylonjs/Misc/observable";
  24739. import { Nullable } from "babylonjs/types";
  24740. import { Matrix } from "babylonjs/Maths/math.vector";
  24741. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  24742. import { IInspectable } from "babylonjs/Misc/iInspectable";
  24743. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  24744. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  24745. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  24746. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  24747. import { Scene } from "babylonjs/scene";
  24748. /**
  24749. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24750. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24751. */
  24752. export class Texture extends BaseTexture {
  24753. /**
  24754. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  24755. */
  24756. static SerializeBuffers: boolean;
  24757. /** @hidden */
  24758. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  24759. /** @hidden */
  24760. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  24761. /** @hidden */
  24762. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  24763. /** nearest is mag = nearest and min = nearest and mip = linear */
  24764. static readonly NEAREST_SAMPLINGMODE: number;
  24765. /** nearest is mag = nearest and min = nearest and mip = linear */
  24766. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  24767. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24768. static readonly BILINEAR_SAMPLINGMODE: number;
  24769. /** Bilinear is mag = linear and min = linear and mip = nearest */
  24770. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  24771. /** Trilinear is mag = linear and min = linear and mip = linear */
  24772. static readonly TRILINEAR_SAMPLINGMODE: number;
  24773. /** Trilinear is mag = linear and min = linear and mip = linear */
  24774. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  24775. /** mag = nearest and min = nearest and mip = nearest */
  24776. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  24777. /** mag = nearest and min = linear and mip = nearest */
  24778. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  24779. /** mag = nearest and min = linear and mip = linear */
  24780. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  24781. /** mag = nearest and min = linear and mip = none */
  24782. static readonly NEAREST_LINEAR: number;
  24783. /** mag = nearest and min = nearest and mip = none */
  24784. static readonly NEAREST_NEAREST: number;
  24785. /** mag = linear and min = nearest and mip = nearest */
  24786. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  24787. /** mag = linear and min = nearest and mip = linear */
  24788. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  24789. /** mag = linear and min = linear and mip = none */
  24790. static readonly LINEAR_LINEAR: number;
  24791. /** mag = linear and min = nearest and mip = none */
  24792. static readonly LINEAR_NEAREST: number;
  24793. /** Explicit coordinates mode */
  24794. static readonly EXPLICIT_MODE: number;
  24795. /** Spherical coordinates mode */
  24796. static readonly SPHERICAL_MODE: number;
  24797. /** Planar coordinates mode */
  24798. static readonly PLANAR_MODE: number;
  24799. /** Cubic coordinates mode */
  24800. static readonly CUBIC_MODE: number;
  24801. /** Projection coordinates mode */
  24802. static readonly PROJECTION_MODE: number;
  24803. /** Inverse Cubic coordinates mode */
  24804. static readonly SKYBOX_MODE: number;
  24805. /** Inverse Cubic coordinates mode */
  24806. static readonly INVCUBIC_MODE: number;
  24807. /** Equirectangular coordinates mode */
  24808. static readonly EQUIRECTANGULAR_MODE: number;
  24809. /** Equirectangular Fixed coordinates mode */
  24810. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  24811. /** Equirectangular Fixed Mirrored coordinates mode */
  24812. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  24813. /** Texture is not repeating outside of 0..1 UVs */
  24814. static readonly CLAMP_ADDRESSMODE: number;
  24815. /** Texture is repeating outside of 0..1 UVs */
  24816. static readonly WRAP_ADDRESSMODE: number;
  24817. /** Texture is repeating and mirrored */
  24818. static readonly MIRROR_ADDRESSMODE: number;
  24819. /**
  24820. * 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
  24821. */
  24822. static UseSerializedUrlIfAny: boolean;
  24823. /**
  24824. * Define the url of the texture.
  24825. */
  24826. url: Nullable<string>;
  24827. /**
  24828. * Define an offset on the texture to offset the u coordinates of the UVs
  24829. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24830. */
  24831. uOffset: number;
  24832. /**
  24833. * Define an offset on the texture to offset the v coordinates of the UVs
  24834. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  24835. */
  24836. vOffset: number;
  24837. /**
  24838. * Define an offset on the texture to scale the u coordinates of the UVs
  24839. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24840. */
  24841. uScale: number;
  24842. /**
  24843. * Define an offset on the texture to scale the v coordinates of the UVs
  24844. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  24845. */
  24846. vScale: number;
  24847. /**
  24848. * Define an offset on the texture to rotate around the u coordinates of the UVs
  24849. * @see https://doc.babylonjs.com/how_to/more_materials
  24850. */
  24851. uAng: number;
  24852. /**
  24853. * Define an offset on the texture to rotate around the v coordinates of the UVs
  24854. * @see https://doc.babylonjs.com/how_to/more_materials
  24855. */
  24856. vAng: number;
  24857. /**
  24858. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  24859. * @see https://doc.babylonjs.com/how_to/more_materials
  24860. */
  24861. wAng: number;
  24862. /**
  24863. * Defines the center of rotation (U)
  24864. */
  24865. uRotationCenter: number;
  24866. /**
  24867. * Defines the center of rotation (V)
  24868. */
  24869. vRotationCenter: number;
  24870. /**
  24871. * Defines the center of rotation (W)
  24872. */
  24873. wRotationCenter: number;
  24874. /**
  24875. * Are mip maps generated for this texture or not.
  24876. */
  24877. get noMipmap(): boolean;
  24878. /**
  24879. * List of inspectable custom properties (used by the Inspector)
  24880. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  24881. */
  24882. inspectableCustomProperties: Nullable<IInspectable[]>;
  24883. private _noMipmap;
  24884. /** @hidden */
  24885. _invertY: boolean;
  24886. private _rowGenerationMatrix;
  24887. private _cachedTextureMatrix;
  24888. private _projectionModeMatrix;
  24889. private _t0;
  24890. private _t1;
  24891. private _t2;
  24892. private _cachedUOffset;
  24893. private _cachedVOffset;
  24894. private _cachedUScale;
  24895. private _cachedVScale;
  24896. private _cachedUAng;
  24897. private _cachedVAng;
  24898. private _cachedWAng;
  24899. private _cachedProjectionMatrixId;
  24900. private _cachedCoordinatesMode;
  24901. /** @hidden */
  24902. protected _initialSamplingMode: number;
  24903. /** @hidden */
  24904. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  24905. private _deleteBuffer;
  24906. protected _format: Nullable<number>;
  24907. private _delayedOnLoad;
  24908. private _delayedOnError;
  24909. private _mimeType?;
  24910. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  24911. get mimeType(): string | undefined;
  24912. /**
  24913. * Observable triggered once the texture has been loaded.
  24914. */
  24915. onLoadObservable: Observable<Texture>;
  24916. protected _isBlocking: boolean;
  24917. /**
  24918. * Is the texture preventing material to render while loading.
  24919. * If false, a default texture will be used instead of the loading one during the preparation step.
  24920. */
  24921. set isBlocking(value: boolean);
  24922. get isBlocking(): boolean;
  24923. /**
  24924. * Get the current sampling mode associated with the texture.
  24925. */
  24926. get samplingMode(): number;
  24927. /**
  24928. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  24929. */
  24930. get invertY(): boolean;
  24931. /**
  24932. * Instantiates a new texture.
  24933. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  24934. * @see https://doc.babylonjs.com/babylon101/materials#texture
  24935. * @param url defines the url of the picture to load as a texture
  24936. * @param sceneOrEngine defines the scene or engine the texture will belong to
  24937. * @param noMipmap defines if the texture will require mip maps or not
  24938. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  24939. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  24940. * @param onLoad defines a callback triggered when the texture has been loaded
  24941. * @param onError defines a callback triggered when an error occurred during the loading session
  24942. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  24943. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  24944. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  24945. * @param mimeType defines an optional mime type information
  24946. */
  24947. 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);
  24948. /**
  24949. * Update the url (and optional buffer) of this texture if url was null during construction.
  24950. * @param url the url of the texture
  24951. * @param buffer the buffer of the texture (defaults to null)
  24952. * @param onLoad callback called when the texture is loaded (defaults to null)
  24953. */
  24954. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  24955. /**
  24956. * Finish the loading sequence of a texture flagged as delayed load.
  24957. * @hidden
  24958. */
  24959. delayLoad(): void;
  24960. private _prepareRowForTextureGeneration;
  24961. /**
  24962. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  24963. * @returns the transform matrix of the texture.
  24964. */
  24965. getTextureMatrix(uBase?: number): Matrix;
  24966. /**
  24967. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  24968. * @returns The reflection texture transform
  24969. */
  24970. getReflectionTextureMatrix(): Matrix;
  24971. /**
  24972. * Clones the texture.
  24973. * @returns the cloned texture
  24974. */
  24975. clone(): Texture;
  24976. /**
  24977. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  24978. * @returns The JSON representation of the texture
  24979. */
  24980. serialize(): any;
  24981. /**
  24982. * Get the current class name of the texture useful for serialization or dynamic coding.
  24983. * @returns "Texture"
  24984. */
  24985. getClassName(): string;
  24986. /**
  24987. * Dispose the texture and release its associated resources.
  24988. */
  24989. dispose(): void;
  24990. /**
  24991. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  24992. * @param parsedTexture Define the JSON representation of the texture
  24993. * @param scene Define the scene the parsed texture should be instantiated in
  24994. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  24995. * @returns The parsed texture if successful
  24996. */
  24997. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  24998. /**
  24999. * Creates a texture from its base 64 representation.
  25000. * @param data Define the base64 payload without the data: prefix
  25001. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25002. * @param scene Define the scene the texture should belong to
  25003. * @param noMipmap Forces the texture to not create mip map information if true
  25004. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25005. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  25006. * @param onLoad define a callback triggered when the texture has been loaded
  25007. * @param onError define a callback triggered when an error occurred during the loading session
  25008. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25009. * @returns the created texture
  25010. */
  25011. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  25012. /**
  25013. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  25014. * @param data Define the base64 payload without the data: prefix
  25015. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  25016. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  25017. * @param scene Define the scene the texture should belong to
  25018. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  25019. * @param noMipmap Forces the texture to not create mip map information if true
  25020. * @param invertY define if the texture needs to be inverted on the y axis during loading
  25021. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  25022. * @param onLoad define a callback triggered when the texture has been loaded
  25023. * @param onError define a callback triggered when an error occurred during the loading session
  25024. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  25025. * @returns the created texture
  25026. */
  25027. 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;
  25028. }
  25029. }
  25030. declare module "babylonjs/PostProcesses/postProcessManager" {
  25031. import { Nullable } from "babylonjs/types";
  25032. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25033. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25034. import { Scene } from "babylonjs/scene";
  25035. /**
  25036. * PostProcessManager is used to manage one or more post processes or post process pipelines
  25037. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  25038. */
  25039. export class PostProcessManager {
  25040. private _scene;
  25041. private _indexBuffer;
  25042. private _vertexBuffers;
  25043. /**
  25044. * Creates a new instance PostProcess
  25045. * @param scene The scene that the post process is associated with.
  25046. */
  25047. constructor(scene: Scene);
  25048. private _prepareBuffers;
  25049. private _buildIndexBuffer;
  25050. /**
  25051. * Rebuilds the vertex buffers of the manager.
  25052. * @hidden
  25053. */
  25054. _rebuild(): void;
  25055. /**
  25056. * Prepares a frame to be run through a post process.
  25057. * @param sourceTexture The input texture to the post procesess. (default: null)
  25058. * @param postProcesses An array of post processes to be run. (default: null)
  25059. * @returns True if the post processes were able to be run.
  25060. * @hidden
  25061. */
  25062. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  25063. /**
  25064. * Manually render a set of post processes to a texture.
  25065. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  25066. * @param postProcesses An array of post processes to be run.
  25067. * @param targetTexture The target texture to render to.
  25068. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  25069. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  25070. * @param lodLevel defines which lod of the texture to render to
  25071. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  25072. */
  25073. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  25074. /**
  25075. * Finalize the result of the output of the postprocesses.
  25076. * @param doNotPresent If true the result will not be displayed to the screen.
  25077. * @param targetTexture The target texture to render to.
  25078. * @param faceIndex The index of the face to bind the target texture to.
  25079. * @param postProcesses The array of post processes to render.
  25080. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  25081. * @hidden
  25082. */
  25083. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  25084. /**
  25085. * Disposes of the post process manager.
  25086. */
  25087. dispose(): void;
  25088. }
  25089. }
  25090. declare module "babylonjs/Materials/Textures/renderTargetTexture" {
  25091. import { Observable } from "babylonjs/Misc/observable";
  25092. import { SmartArray } from "babylonjs/Misc/smartArray";
  25093. import { Nullable, Immutable } from "babylonjs/types";
  25094. import { Camera } from "babylonjs/Cameras/camera";
  25095. import { Scene } from "babylonjs/scene";
  25096. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  25097. import { Color4 } from "babylonjs/Maths/math.color";
  25098. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  25099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25100. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25101. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  25102. import { Texture } from "babylonjs/Materials/Textures/texture";
  25103. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  25104. import { RenderingManager } from "babylonjs/Rendering/renderingManager";
  25105. import "babylonjs/Engines/Extensions/engine.renderTarget";
  25106. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  25107. import { Engine } from "babylonjs/Engines/engine";
  25108. /**
  25109. * This Helps creating a texture that will be created from a camera in your scene.
  25110. * It is basically a dynamic texture that could be used to create special effects for instance.
  25111. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  25112. */
  25113. export class RenderTargetTexture extends Texture {
  25114. /**
  25115. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  25116. */
  25117. static readonly REFRESHRATE_RENDER_ONCE: number;
  25118. /**
  25119. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  25120. */
  25121. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  25122. /**
  25123. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  25124. * the central point of your effect and can save a lot of performances.
  25125. */
  25126. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  25127. /**
  25128. * Use this predicate to dynamically define the list of mesh you want to render.
  25129. * If set, the renderList property will be overwritten.
  25130. */
  25131. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  25132. private _renderList;
  25133. /**
  25134. * Use this list to define the list of mesh you want to render.
  25135. */
  25136. get renderList(): Nullable<Array<AbstractMesh>>;
  25137. set renderList(value: Nullable<Array<AbstractMesh>>);
  25138. /**
  25139. * Use this function to overload the renderList array at rendering time.
  25140. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  25141. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  25142. * the cube (if the RTT is a cube, else layerOrFace=0).
  25143. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  25144. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  25145. * hold dummy elements!
  25146. */
  25147. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  25148. private _hookArray;
  25149. /**
  25150. * Define if particles should be rendered in your texture.
  25151. */
  25152. renderParticles: boolean;
  25153. /**
  25154. * Define if sprites should be rendered in your texture.
  25155. */
  25156. renderSprites: boolean;
  25157. /**
  25158. * Define the camera used to render the texture.
  25159. */
  25160. activeCamera: Nullable<Camera>;
  25161. /**
  25162. * Override the mesh isReady function with your own one.
  25163. */
  25164. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  25165. /**
  25166. * Override the render function of the texture with your own one.
  25167. */
  25168. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  25169. /**
  25170. * Define if camera post processes should be use while rendering the texture.
  25171. */
  25172. useCameraPostProcesses: boolean;
  25173. /**
  25174. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  25175. */
  25176. ignoreCameraViewport: boolean;
  25177. private _postProcessManager;
  25178. private _postProcesses;
  25179. private _resizeObserver;
  25180. /**
  25181. * An event triggered when the texture is unbind.
  25182. */
  25183. onBeforeBindObservable: Observable<RenderTargetTexture>;
  25184. /**
  25185. * An event triggered when the texture is unbind.
  25186. */
  25187. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  25188. private _onAfterUnbindObserver;
  25189. /**
  25190. * Set a after unbind callback in the texture.
  25191. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  25192. */
  25193. set onAfterUnbind(callback: () => void);
  25194. /**
  25195. * An event triggered before rendering the texture
  25196. */
  25197. onBeforeRenderObservable: Observable<number>;
  25198. private _onBeforeRenderObserver;
  25199. /**
  25200. * Set a before render callback in the texture.
  25201. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  25202. */
  25203. set onBeforeRender(callback: (faceIndex: number) => void);
  25204. /**
  25205. * An event triggered after rendering the texture
  25206. */
  25207. onAfterRenderObservable: Observable<number>;
  25208. private _onAfterRenderObserver;
  25209. /**
  25210. * Set a after render callback in the texture.
  25211. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  25212. */
  25213. set onAfterRender(callback: (faceIndex: number) => void);
  25214. /**
  25215. * An event triggered after the texture clear
  25216. */
  25217. onClearObservable: Observable<Engine>;
  25218. private _onClearObserver;
  25219. /**
  25220. * Set a clear callback in the texture.
  25221. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  25222. */
  25223. set onClear(callback: (Engine: Engine) => void);
  25224. /**
  25225. * An event triggered when the texture is resized.
  25226. */
  25227. onResizeObservable: Observable<RenderTargetTexture>;
  25228. /**
  25229. * Define the clear color of the Render Target if it should be different from the scene.
  25230. */
  25231. clearColor: Color4;
  25232. protected _size: number | {
  25233. width: number;
  25234. height: number;
  25235. layers?: number;
  25236. };
  25237. protected _initialSizeParameter: number | {
  25238. width: number;
  25239. height: number;
  25240. } | {
  25241. ratio: number;
  25242. };
  25243. protected _sizeRatio: Nullable<number>;
  25244. /** @hidden */
  25245. _generateMipMaps: boolean;
  25246. protected _renderingManager: RenderingManager;
  25247. /** @hidden */
  25248. _waitingRenderList?: string[];
  25249. protected _doNotChangeAspectRatio: boolean;
  25250. protected _currentRefreshId: number;
  25251. protected _refreshRate: number;
  25252. protected _textureMatrix: Matrix;
  25253. protected _samples: number;
  25254. protected _renderTargetOptions: RenderTargetCreationOptions;
  25255. /**
  25256. * Gets render target creation options that were used.
  25257. */
  25258. get renderTargetOptions(): RenderTargetCreationOptions;
  25259. protected _onRatioRescale(): void;
  25260. /**
  25261. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  25262. * It must define where the camera used to render the texture is set
  25263. */
  25264. boundingBoxPosition: Vector3;
  25265. private _boundingBoxSize;
  25266. /**
  25267. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  25268. * When defined, the cubemap will switch to local mode
  25269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  25270. * @example https://www.babylonjs-playground.com/#RNASML
  25271. */
  25272. set boundingBoxSize(value: Vector3);
  25273. get boundingBoxSize(): Vector3;
  25274. /**
  25275. * In case the RTT has been created with a depth texture, get the associated
  25276. * depth texture.
  25277. * Otherwise, return null.
  25278. */
  25279. get depthStencilTexture(): Nullable<InternalTexture>;
  25280. /**
  25281. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  25282. * or used a shadow, depth texture...
  25283. * @param name The friendly name of the texture
  25284. * @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)
  25285. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  25286. * @param generateMipMaps True if mip maps need to be generated after render.
  25287. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  25288. * @param type The type of the buffer in the RTT (int, half float, float...)
  25289. * @param isCube True if a cube texture needs to be created
  25290. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  25291. * @param generateDepthBuffer True to generate a depth buffer
  25292. * @param generateStencilBuffer True to generate a stencil buffer
  25293. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  25294. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  25295. * @param delayAllocation if the texture allocation should be delayed (default: false)
  25296. */
  25297. constructor(name: string, size: number | {
  25298. width: number;
  25299. height: number;
  25300. layers?: number;
  25301. } | {
  25302. ratio: number;
  25303. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  25304. /**
  25305. * Creates a depth stencil texture.
  25306. * This is only available in WebGL 2 or with the depth texture extension available.
  25307. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  25308. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  25309. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  25310. */
  25311. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  25312. private _processSizeParameter;
  25313. /**
  25314. * Define the number of samples to use in case of MSAA.
  25315. * It defaults to one meaning no MSAA has been enabled.
  25316. */
  25317. get samples(): number;
  25318. set samples(value: number);
  25319. /**
  25320. * Resets the refresh counter of the texture and start bak from scratch.
  25321. * Could be useful to regenerate the texture if it is setup to render only once.
  25322. */
  25323. resetRefreshCounter(): void;
  25324. /**
  25325. * Define the refresh rate of the texture or the rendering frequency.
  25326. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  25327. */
  25328. get refreshRate(): number;
  25329. set refreshRate(value: number);
  25330. /**
  25331. * Adds a post process to the render target rendering passes.
  25332. * @param postProcess define the post process to add
  25333. */
  25334. addPostProcess(postProcess: PostProcess): void;
  25335. /**
  25336. * Clear all the post processes attached to the render target
  25337. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  25338. */
  25339. clearPostProcesses(dispose?: boolean): void;
  25340. /**
  25341. * Remove one of the post process from the list of attached post processes to the texture
  25342. * @param postProcess define the post process to remove from the list
  25343. */
  25344. removePostProcess(postProcess: PostProcess): void;
  25345. /** @hidden */
  25346. _shouldRender(): boolean;
  25347. /**
  25348. * Gets the actual render size of the texture.
  25349. * @returns the width of the render size
  25350. */
  25351. getRenderSize(): number;
  25352. /**
  25353. * Gets the actual render width of the texture.
  25354. * @returns the width of the render size
  25355. */
  25356. getRenderWidth(): number;
  25357. /**
  25358. * Gets the actual render height of the texture.
  25359. * @returns the height of the render size
  25360. */
  25361. getRenderHeight(): number;
  25362. /**
  25363. * Gets the actual number of layers of the texture.
  25364. * @returns the number of layers
  25365. */
  25366. getRenderLayers(): number;
  25367. /**
  25368. * Get if the texture can be rescaled or not.
  25369. */
  25370. get canRescale(): boolean;
  25371. /**
  25372. * Resize the texture using a ratio.
  25373. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  25374. */
  25375. scale(ratio: number): void;
  25376. /**
  25377. * Get the texture reflection matrix used to rotate/transform the reflection.
  25378. * @returns the reflection matrix
  25379. */
  25380. getReflectionTextureMatrix(): Matrix;
  25381. /**
  25382. * Resize the texture to a new desired size.
  25383. * Be carrefull as it will recreate all the data in the new texture.
  25384. * @param size Define the new size. It can be:
  25385. * - a number for squared texture,
  25386. * - an object containing { width: number, height: number }
  25387. * - or an object containing a ratio { ratio: number }
  25388. */
  25389. resize(size: number | {
  25390. width: number;
  25391. height: number;
  25392. } | {
  25393. ratio: number;
  25394. }): void;
  25395. private _defaultRenderListPrepared;
  25396. /**
  25397. * Renders all the objects from the render list into the texture.
  25398. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  25399. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  25400. */
  25401. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  25402. private _bestReflectionRenderTargetDimension;
  25403. private _prepareRenderingManager;
  25404. /**
  25405. * @hidden
  25406. * @param faceIndex face index to bind to if this is a cubetexture
  25407. * @param layer defines the index of the texture to bind in the array
  25408. */
  25409. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  25410. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  25411. private renderToTarget;
  25412. /**
  25413. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  25414. * This allowed control for front to back rendering or reversly depending of the special needs.
  25415. *
  25416. * @param renderingGroupId The rendering group id corresponding to its index
  25417. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  25418. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  25419. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  25420. */
  25421. 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;
  25422. /**
  25423. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  25424. *
  25425. * @param renderingGroupId The rendering group id corresponding to its index
  25426. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  25427. */
  25428. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  25429. /**
  25430. * Clones the texture.
  25431. * @returns the cloned texture
  25432. */
  25433. clone(): RenderTargetTexture;
  25434. /**
  25435. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  25436. * @returns The JSON representation of the texture
  25437. */
  25438. serialize(): any;
  25439. /**
  25440. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  25441. */
  25442. disposeFramebufferObjects(): void;
  25443. /**
  25444. * Dispose the texture and release its associated resources.
  25445. */
  25446. dispose(): void;
  25447. /** @hidden */
  25448. _rebuild(): void;
  25449. /**
  25450. * Clear the info related to rendering groups preventing retention point in material dispose.
  25451. */
  25452. freeRenderingGroups(): void;
  25453. /**
  25454. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  25455. * @returns the view count
  25456. */
  25457. getViewCount(): number;
  25458. }
  25459. }
  25460. declare module "babylonjs/Misc/guid" {
  25461. /**
  25462. * Class used to manipulate GUIDs
  25463. */
  25464. export class GUID {
  25465. /**
  25466. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  25467. * Be aware Math.random() could cause collisions, but:
  25468. * "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"
  25469. * @returns a pseudo random id
  25470. */
  25471. static RandomId(): string;
  25472. }
  25473. }
  25474. declare module "babylonjs/Materials/shadowDepthWrapper" {
  25475. import { Nullable } from "babylonjs/types";
  25476. import { Scene } from "babylonjs/scene";
  25477. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25478. import { Material } from "babylonjs/Materials/material";
  25479. import { Effect } from "babylonjs/Materials/effect";
  25480. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  25481. /**
  25482. * Options to be used when creating a shadow depth material
  25483. */
  25484. export interface IIOptionShadowDepthMaterial {
  25485. /** Variables in the vertex shader code that need to have their names remapped.
  25486. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  25487. * "var_name" should be either: worldPos or vNormalW
  25488. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  25489. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  25490. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  25491. */
  25492. remappedVariables?: string[];
  25493. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  25494. standalone?: boolean;
  25495. }
  25496. /**
  25497. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  25498. */
  25499. export class ShadowDepthWrapper {
  25500. private _scene;
  25501. private _options?;
  25502. private _baseMaterial;
  25503. private _onEffectCreatedObserver;
  25504. private _subMeshToEffect;
  25505. private _subMeshToDepthEffect;
  25506. private _meshes;
  25507. /** @hidden */
  25508. _matriceNames: any;
  25509. /** Gets the standalone status of the wrapper */
  25510. get standalone(): boolean;
  25511. /** Gets the base material the wrapper is built upon */
  25512. get baseMaterial(): Material;
  25513. /**
  25514. * Instantiate a new shadow depth wrapper.
  25515. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  25516. * generate the shadow depth map. For more information, please refer to the documentation:
  25517. * https://doc.babylonjs.com/babylon101/shadows
  25518. * @param baseMaterial Material to wrap
  25519. * @param scene Define the scene the material belongs to
  25520. * @param options Options used to create the wrapper
  25521. */
  25522. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  25523. /**
  25524. * Gets the effect to use to generate the depth map
  25525. * @param subMesh subMesh to get the effect for
  25526. * @param shadowGenerator shadow generator to get the effect for
  25527. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  25528. */
  25529. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  25530. /**
  25531. * Specifies that the submesh is ready to be used for depth rendering
  25532. * @param subMesh submesh to check
  25533. * @param defines the list of defines to take into account when checking the effect
  25534. * @param shadowGenerator combined with subMesh, it defines the effect to check
  25535. * @param useInstances specifies that instances should be used
  25536. * @returns a boolean indicating that the submesh is ready or not
  25537. */
  25538. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  25539. /**
  25540. * Disposes the resources
  25541. */
  25542. dispose(): void;
  25543. private _makeEffect;
  25544. }
  25545. }
  25546. declare module "babylonjs/Materials/material" {
  25547. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  25548. import { SmartArray } from "babylonjs/Misc/smartArray";
  25549. import { Observable } from "babylonjs/Misc/observable";
  25550. import { Nullable } from "babylonjs/types";
  25551. import { Scene } from "babylonjs/scene";
  25552. import { Matrix } from "babylonjs/Maths/math.vector";
  25553. import { SubMesh } from "babylonjs/Meshes/subMesh";
  25554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  25555. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  25556. import { Effect } from "babylonjs/Materials/effect";
  25557. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  25558. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  25559. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  25560. import { IInspectable } from "babylonjs/Misc/iInspectable";
  25561. import { ShadowDepthWrapper } from "babylonjs/Materials/shadowDepthWrapper";
  25562. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  25563. import { Mesh } from "babylonjs/Meshes/mesh";
  25564. import { Animation } from "babylonjs/Animations/animation";
  25565. /**
  25566. * Options for compiling materials.
  25567. */
  25568. export interface IMaterialCompilationOptions {
  25569. /**
  25570. * Defines whether clip planes are enabled.
  25571. */
  25572. clipPlane: boolean;
  25573. /**
  25574. * Defines whether instances are enabled.
  25575. */
  25576. useInstances: boolean;
  25577. }
  25578. /**
  25579. * Options passed when calling customShaderNameResolve
  25580. */
  25581. export interface ICustomShaderNameResolveOptions {
  25582. /**
  25583. * 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
  25584. */
  25585. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  25586. }
  25587. /**
  25588. * Base class for the main features of a material in Babylon.js
  25589. */
  25590. export class Material implements IAnimatable {
  25591. /**
  25592. * Returns the triangle fill mode
  25593. */
  25594. static readonly TriangleFillMode: number;
  25595. /**
  25596. * Returns the wireframe mode
  25597. */
  25598. static readonly WireFrameFillMode: number;
  25599. /**
  25600. * Returns the point fill mode
  25601. */
  25602. static readonly PointFillMode: number;
  25603. /**
  25604. * Returns the point list draw mode
  25605. */
  25606. static readonly PointListDrawMode: number;
  25607. /**
  25608. * Returns the line list draw mode
  25609. */
  25610. static readonly LineListDrawMode: number;
  25611. /**
  25612. * Returns the line loop draw mode
  25613. */
  25614. static readonly LineLoopDrawMode: number;
  25615. /**
  25616. * Returns the line strip draw mode
  25617. */
  25618. static readonly LineStripDrawMode: number;
  25619. /**
  25620. * Returns the triangle strip draw mode
  25621. */
  25622. static readonly TriangleStripDrawMode: number;
  25623. /**
  25624. * Returns the triangle fan draw mode
  25625. */
  25626. static readonly TriangleFanDrawMode: number;
  25627. /**
  25628. * Stores the clock-wise side orientation
  25629. */
  25630. static readonly ClockWiseSideOrientation: number;
  25631. /**
  25632. * Stores the counter clock-wise side orientation
  25633. */
  25634. static readonly CounterClockWiseSideOrientation: number;
  25635. /**
  25636. * The dirty texture flag value
  25637. */
  25638. static readonly TextureDirtyFlag: number;
  25639. /**
  25640. * The dirty light flag value
  25641. */
  25642. static readonly LightDirtyFlag: number;
  25643. /**
  25644. * The dirty fresnel flag value
  25645. */
  25646. static readonly FresnelDirtyFlag: number;
  25647. /**
  25648. * The dirty attribute flag value
  25649. */
  25650. static readonly AttributesDirtyFlag: number;
  25651. /**
  25652. * The dirty misc flag value
  25653. */
  25654. static readonly MiscDirtyFlag: number;
  25655. /**
  25656. * The dirty prepass flag value
  25657. */
  25658. static readonly PrePassDirtyFlag: number;
  25659. /**
  25660. * The all dirty flag value
  25661. */
  25662. static readonly AllDirtyFlag: number;
  25663. /**
  25664. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  25665. */
  25666. static readonly MATERIAL_OPAQUE: number;
  25667. /**
  25668. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  25669. */
  25670. static readonly MATERIAL_ALPHATEST: number;
  25671. /**
  25672. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25673. */
  25674. static readonly MATERIAL_ALPHABLEND: number;
  25675. /**
  25676. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  25677. * They are also discarded below the alpha cutoff threshold to improve performances.
  25678. */
  25679. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  25680. /**
  25681. * The Whiteout method is used to blend normals.
  25682. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25683. */
  25684. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  25685. /**
  25686. * The Reoriented Normal Mapping method is used to blend normals.
  25687. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  25688. */
  25689. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  25690. /**
  25691. * Custom callback helping to override the default shader used in the material.
  25692. */
  25693. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  25694. /**
  25695. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  25696. */
  25697. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  25698. /**
  25699. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  25700. * This means that the material can keep using a previous shader while a new one is being compiled.
  25701. * This is mostly used when shader parallel compilation is supported (true by default)
  25702. */
  25703. allowShaderHotSwapping: boolean;
  25704. /**
  25705. * The ID of the material
  25706. */
  25707. id: string;
  25708. /**
  25709. * Gets or sets the unique id of the material
  25710. */
  25711. uniqueId: number;
  25712. /**
  25713. * The name of the material
  25714. */
  25715. name: string;
  25716. /**
  25717. * Gets or sets user defined metadata
  25718. */
  25719. metadata: any;
  25720. /**
  25721. * For internal use only. Please do not use.
  25722. */
  25723. reservedDataStore: any;
  25724. /**
  25725. * Specifies if the ready state should be checked on each call
  25726. */
  25727. checkReadyOnEveryCall: boolean;
  25728. /**
  25729. * Specifies if the ready state should be checked once
  25730. */
  25731. checkReadyOnlyOnce: boolean;
  25732. /**
  25733. * The state of the material
  25734. */
  25735. state: string;
  25736. /**
  25737. * If the material can be rendered to several textures with MRT extension
  25738. */
  25739. get canRenderToMRT(): boolean;
  25740. /**
  25741. * The alpha value of the material
  25742. */
  25743. protected _alpha: number;
  25744. /**
  25745. * List of inspectable custom properties (used by the Inspector)
  25746. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  25747. */
  25748. inspectableCustomProperties: IInspectable[];
  25749. /**
  25750. * Sets the alpha value of the material
  25751. */
  25752. set alpha(value: number);
  25753. /**
  25754. * Gets the alpha value of the material
  25755. */
  25756. get alpha(): number;
  25757. /**
  25758. * Specifies if back face culling is enabled
  25759. */
  25760. protected _backFaceCulling: boolean;
  25761. /**
  25762. * Sets the back-face culling state
  25763. */
  25764. set backFaceCulling(value: boolean);
  25765. /**
  25766. * Gets the back-face culling state
  25767. */
  25768. get backFaceCulling(): boolean;
  25769. /**
  25770. * Stores the value for side orientation
  25771. */
  25772. sideOrientation: number;
  25773. /**
  25774. * Callback triggered when the material is compiled
  25775. */
  25776. onCompiled: Nullable<(effect: Effect) => void>;
  25777. /**
  25778. * Callback triggered when an error occurs
  25779. */
  25780. onError: Nullable<(effect: Effect, errors: string) => void>;
  25781. /**
  25782. * Callback triggered to get the render target textures
  25783. */
  25784. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  25785. /**
  25786. * Gets a boolean indicating that current material needs to register RTT
  25787. */
  25788. get hasRenderTargetTextures(): boolean;
  25789. /**
  25790. * Specifies if the material should be serialized
  25791. */
  25792. doNotSerialize: boolean;
  25793. /**
  25794. * @hidden
  25795. */
  25796. _storeEffectOnSubMeshes: boolean;
  25797. /**
  25798. * Stores the animations for the material
  25799. */
  25800. animations: Nullable<Array<Animation>>;
  25801. /**
  25802. * An event triggered when the material is disposed
  25803. */
  25804. onDisposeObservable: Observable<Material>;
  25805. /**
  25806. * An observer which watches for dispose events
  25807. */
  25808. private _onDisposeObserver;
  25809. private _onUnBindObservable;
  25810. /**
  25811. * Called during a dispose event
  25812. */
  25813. set onDispose(callback: () => void);
  25814. private _onBindObservable;
  25815. /**
  25816. * An event triggered when the material is bound
  25817. */
  25818. get onBindObservable(): Observable<AbstractMesh>;
  25819. /**
  25820. * An observer which watches for bind events
  25821. */
  25822. private _onBindObserver;
  25823. /**
  25824. * Called during a bind event
  25825. */
  25826. set onBind(callback: (Mesh: AbstractMesh) => void);
  25827. /**
  25828. * An event triggered when the material is unbound
  25829. */
  25830. get onUnBindObservable(): Observable<Material>;
  25831. protected _onEffectCreatedObservable: Nullable<Observable<{
  25832. effect: Effect;
  25833. subMesh: Nullable<SubMesh>;
  25834. }>>;
  25835. /**
  25836. * An event triggered when the effect is (re)created
  25837. */
  25838. get onEffectCreatedObservable(): Observable<{
  25839. effect: Effect;
  25840. subMesh: Nullable<SubMesh>;
  25841. }>;
  25842. /**
  25843. * Stores the value of the alpha mode
  25844. */
  25845. private _alphaMode;
  25846. /**
  25847. * Sets the value of the alpha mode.
  25848. *
  25849. * | Value | Type | Description |
  25850. * | --- | --- | --- |
  25851. * | 0 | ALPHA_DISABLE | |
  25852. * | 1 | ALPHA_ADD | |
  25853. * | 2 | ALPHA_COMBINE | |
  25854. * | 3 | ALPHA_SUBTRACT | |
  25855. * | 4 | ALPHA_MULTIPLY | |
  25856. * | 5 | ALPHA_MAXIMIZED | |
  25857. * | 6 | ALPHA_ONEONE | |
  25858. * | 7 | ALPHA_PREMULTIPLIED | |
  25859. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  25860. * | 9 | ALPHA_INTERPOLATE | |
  25861. * | 10 | ALPHA_SCREENMODE | |
  25862. *
  25863. */
  25864. set alphaMode(value: number);
  25865. /**
  25866. * Gets the value of the alpha mode
  25867. */
  25868. get alphaMode(): number;
  25869. /**
  25870. * Stores the state of the need depth pre-pass value
  25871. */
  25872. private _needDepthPrePass;
  25873. /**
  25874. * Sets the need depth pre-pass value
  25875. */
  25876. set needDepthPrePass(value: boolean);
  25877. /**
  25878. * Gets the depth pre-pass value
  25879. */
  25880. get needDepthPrePass(): boolean;
  25881. /**
  25882. * Specifies if depth writing should be disabled
  25883. */
  25884. disableDepthWrite: boolean;
  25885. /**
  25886. * Specifies if color writing should be disabled
  25887. */
  25888. disableColorWrite: boolean;
  25889. /**
  25890. * Specifies if depth writing should be forced
  25891. */
  25892. forceDepthWrite: boolean;
  25893. /**
  25894. * Specifies the depth function that should be used. 0 means the default engine function
  25895. */
  25896. depthFunction: number;
  25897. /**
  25898. * Specifies if there should be a separate pass for culling
  25899. */
  25900. separateCullingPass: boolean;
  25901. /**
  25902. * Stores the state specifing if fog should be enabled
  25903. */
  25904. private _fogEnabled;
  25905. /**
  25906. * Sets the state for enabling fog
  25907. */
  25908. set fogEnabled(value: boolean);
  25909. /**
  25910. * Gets the value of the fog enabled state
  25911. */
  25912. get fogEnabled(): boolean;
  25913. /**
  25914. * Stores the size of points
  25915. */
  25916. pointSize: number;
  25917. /**
  25918. * Stores the z offset value
  25919. */
  25920. zOffset: number;
  25921. get wireframe(): boolean;
  25922. /**
  25923. * Sets the state of wireframe mode
  25924. */
  25925. set wireframe(value: boolean);
  25926. /**
  25927. * Gets the value specifying if point clouds are enabled
  25928. */
  25929. get pointsCloud(): boolean;
  25930. /**
  25931. * Sets the state of point cloud mode
  25932. */
  25933. set pointsCloud(value: boolean);
  25934. /**
  25935. * Gets the material fill mode
  25936. */
  25937. get fillMode(): number;
  25938. /**
  25939. * Sets the material fill mode
  25940. */
  25941. set fillMode(value: number);
  25942. /**
  25943. * @hidden
  25944. * Stores the effects for the material
  25945. */
  25946. _effect: Nullable<Effect>;
  25947. /**
  25948. * Specifies if uniform buffers should be used
  25949. */
  25950. private _useUBO;
  25951. /**
  25952. * Stores a reference to the scene
  25953. */
  25954. private _scene;
  25955. /**
  25956. * Stores the fill mode state
  25957. */
  25958. private _fillMode;
  25959. /**
  25960. * Specifies if the depth write state should be cached
  25961. */
  25962. private _cachedDepthWriteState;
  25963. /**
  25964. * Specifies if the color write state should be cached
  25965. */
  25966. private _cachedColorWriteState;
  25967. /**
  25968. * Specifies if the depth function state should be cached
  25969. */
  25970. private _cachedDepthFunctionState;
  25971. /**
  25972. * Stores the uniform buffer
  25973. */
  25974. protected _uniformBuffer: UniformBuffer;
  25975. /** @hidden */
  25976. _indexInSceneMaterialArray: number;
  25977. /** @hidden */
  25978. meshMap: Nullable<{
  25979. [id: string]: AbstractMesh | undefined;
  25980. }>;
  25981. /**
  25982. * Creates a material instance
  25983. * @param name defines the name of the material
  25984. * @param scene defines the scene to reference
  25985. * @param doNotAdd specifies if the material should be added to the scene
  25986. */
  25987. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  25988. /**
  25989. * Returns a string representation of the current material
  25990. * @param fullDetails defines a boolean indicating which levels of logging is desired
  25991. * @returns a string with material information
  25992. */
  25993. toString(fullDetails?: boolean): string;
  25994. /**
  25995. * Gets the class name of the material
  25996. * @returns a string with the class name of the material
  25997. */
  25998. getClassName(): string;
  25999. /**
  26000. * Specifies if updates for the material been locked
  26001. */
  26002. get isFrozen(): boolean;
  26003. /**
  26004. * Locks updates for the material
  26005. */
  26006. freeze(): void;
  26007. /**
  26008. * Unlocks updates for the material
  26009. */
  26010. unfreeze(): void;
  26011. /**
  26012. * Specifies if the material is ready to be used
  26013. * @param mesh defines the mesh to check
  26014. * @param useInstances specifies if instances should be used
  26015. * @returns a boolean indicating if the material is ready to be used
  26016. */
  26017. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  26018. /**
  26019. * Specifies that the submesh is ready to be used
  26020. * @param mesh defines the mesh to check
  26021. * @param subMesh defines which submesh to check
  26022. * @param useInstances specifies that instances should be used
  26023. * @returns a boolean indicating that the submesh is ready or not
  26024. */
  26025. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26026. /**
  26027. * Returns the material effect
  26028. * @returns the effect associated with the material
  26029. */
  26030. getEffect(): Nullable<Effect>;
  26031. /**
  26032. * Returns the current scene
  26033. * @returns a Scene
  26034. */
  26035. getScene(): Scene;
  26036. /**
  26037. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  26038. */
  26039. protected _forceAlphaTest: boolean;
  26040. /**
  26041. * The transparency mode of the material.
  26042. */
  26043. protected _transparencyMode: Nullable<number>;
  26044. /**
  26045. * Gets the current transparency mode.
  26046. */
  26047. get transparencyMode(): Nullable<number>;
  26048. /**
  26049. * Sets the transparency mode of the material.
  26050. *
  26051. * | Value | Type | Description |
  26052. * | ----- | ----------------------------------- | ----------- |
  26053. * | 0 | OPAQUE | |
  26054. * | 1 | ALPHATEST | |
  26055. * | 2 | ALPHABLEND | |
  26056. * | 3 | ALPHATESTANDBLEND | |
  26057. *
  26058. */
  26059. set transparencyMode(value: Nullable<number>);
  26060. /**
  26061. * Returns true if alpha blending should be disabled.
  26062. */
  26063. protected get _disableAlphaBlending(): boolean;
  26064. /**
  26065. * Specifies whether or not this material should be rendered in alpha blend mode.
  26066. * @returns a boolean specifying if alpha blending is needed
  26067. */
  26068. needAlphaBlending(): boolean;
  26069. /**
  26070. * Specifies if the mesh will require alpha blending
  26071. * @param mesh defines the mesh to check
  26072. * @returns a boolean specifying if alpha blending is needed for the mesh
  26073. */
  26074. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  26075. /**
  26076. * Specifies whether or not this material should be rendered in alpha test mode.
  26077. * @returns a boolean specifying if an alpha test is needed.
  26078. */
  26079. needAlphaTesting(): boolean;
  26080. /**
  26081. * Specifies if material alpha testing should be turned on for the mesh
  26082. * @param mesh defines the mesh to check
  26083. */
  26084. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  26085. /**
  26086. * Gets the texture used for the alpha test
  26087. * @returns the texture to use for alpha testing
  26088. */
  26089. getAlphaTestTexture(): Nullable<BaseTexture>;
  26090. /**
  26091. * Marks the material to indicate that it needs to be re-calculated
  26092. */
  26093. markDirty(): void;
  26094. /** @hidden */
  26095. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  26096. /**
  26097. * Binds the material to the mesh
  26098. * @param world defines the world transformation matrix
  26099. * @param mesh defines the mesh to bind the material to
  26100. */
  26101. bind(world: Matrix, mesh?: Mesh): void;
  26102. /**
  26103. * Binds the submesh to the material
  26104. * @param world defines the world transformation matrix
  26105. * @param mesh defines the mesh containing the submesh
  26106. * @param subMesh defines the submesh to bind the material to
  26107. */
  26108. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  26109. /**
  26110. * Binds the world matrix to the material
  26111. * @param world defines the world transformation matrix
  26112. */
  26113. bindOnlyWorldMatrix(world: Matrix): void;
  26114. /**
  26115. * Binds the scene's uniform buffer to the effect.
  26116. * @param effect defines the effect to bind to the scene uniform buffer
  26117. * @param sceneUbo defines the uniform buffer storing scene data
  26118. */
  26119. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  26120. /**
  26121. * Binds the view matrix to the effect
  26122. * @param effect defines the effect to bind the view matrix to
  26123. */
  26124. bindView(effect: Effect): void;
  26125. /**
  26126. * Binds the view projection matrix to the effect
  26127. * @param effect defines the effect to bind the view projection matrix to
  26128. */
  26129. bindViewProjection(effect: Effect): void;
  26130. /**
  26131. * Processes to execute after binding the material to a mesh
  26132. * @param mesh defines the rendered mesh
  26133. */
  26134. protected _afterBind(mesh?: Mesh): void;
  26135. /**
  26136. * Unbinds the material from the mesh
  26137. */
  26138. unbind(): void;
  26139. /**
  26140. * Gets the active textures from the material
  26141. * @returns an array of textures
  26142. */
  26143. getActiveTextures(): BaseTexture[];
  26144. /**
  26145. * Specifies if the material uses a texture
  26146. * @param texture defines the texture to check against the material
  26147. * @returns a boolean specifying if the material uses the texture
  26148. */
  26149. hasTexture(texture: BaseTexture): boolean;
  26150. /**
  26151. * Makes a duplicate of the material, and gives it a new name
  26152. * @param name defines the new name for the duplicated material
  26153. * @returns the cloned material
  26154. */
  26155. clone(name: string): Nullable<Material>;
  26156. /**
  26157. * Gets the meshes bound to the material
  26158. * @returns an array of meshes bound to the material
  26159. */
  26160. getBindedMeshes(): AbstractMesh[];
  26161. /**
  26162. * Force shader compilation
  26163. * @param mesh defines the mesh associated with this material
  26164. * @param onCompiled defines a function to execute once the material is compiled
  26165. * @param options defines the options to configure the compilation
  26166. * @param onError defines a function to execute if the material fails compiling
  26167. */
  26168. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  26169. /**
  26170. * Force shader compilation
  26171. * @param mesh defines the mesh that will use this material
  26172. * @param options defines additional options for compiling the shaders
  26173. * @returns a promise that resolves when the compilation completes
  26174. */
  26175. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  26176. private static readonly _AllDirtyCallBack;
  26177. private static readonly _ImageProcessingDirtyCallBack;
  26178. private static readonly _TextureDirtyCallBack;
  26179. private static readonly _FresnelDirtyCallBack;
  26180. private static readonly _MiscDirtyCallBack;
  26181. private static readonly _PrePassDirtyCallBack;
  26182. private static readonly _LightsDirtyCallBack;
  26183. private static readonly _AttributeDirtyCallBack;
  26184. private static _FresnelAndMiscDirtyCallBack;
  26185. private static _TextureAndMiscDirtyCallBack;
  26186. private static readonly _DirtyCallbackArray;
  26187. private static readonly _RunDirtyCallBacks;
  26188. /**
  26189. * Marks a define in the material to indicate that it needs to be re-computed
  26190. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  26191. */
  26192. markAsDirty(flag: number): void;
  26193. /**
  26194. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  26195. * @param func defines a function which checks material defines against the submeshes
  26196. */
  26197. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  26198. /**
  26199. * Indicates that the scene should check if the rendering now needs a prepass
  26200. */
  26201. protected _markScenePrePassDirty(): void;
  26202. /**
  26203. * Indicates that we need to re-calculated for all submeshes
  26204. */
  26205. protected _markAllSubMeshesAsAllDirty(): void;
  26206. /**
  26207. * Indicates that image processing needs to be re-calculated for all submeshes
  26208. */
  26209. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  26210. /**
  26211. * Indicates that textures need to be re-calculated for all submeshes
  26212. */
  26213. protected _markAllSubMeshesAsTexturesDirty(): void;
  26214. /**
  26215. * Indicates that fresnel needs to be re-calculated for all submeshes
  26216. */
  26217. protected _markAllSubMeshesAsFresnelDirty(): void;
  26218. /**
  26219. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  26220. */
  26221. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  26222. /**
  26223. * Indicates that lights need to be re-calculated for all submeshes
  26224. */
  26225. protected _markAllSubMeshesAsLightsDirty(): void;
  26226. /**
  26227. * Indicates that attributes need to be re-calculated for all submeshes
  26228. */
  26229. protected _markAllSubMeshesAsAttributesDirty(): void;
  26230. /**
  26231. * Indicates that misc needs to be re-calculated for all submeshes
  26232. */
  26233. protected _markAllSubMeshesAsMiscDirty(): void;
  26234. /**
  26235. * Indicates that prepass needs to be re-calculated for all submeshes
  26236. */
  26237. protected _markAllSubMeshesAsPrePassDirty(): void;
  26238. /**
  26239. * Indicates that textures and misc need to be re-calculated for all submeshes
  26240. */
  26241. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  26242. /**
  26243. * Sets the required values to the prepass renderer.
  26244. * @param prePassRenderer defines the prepass renderer to setup.
  26245. * @returns true if the pre pass is needed.
  26246. */
  26247. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  26248. /**
  26249. * Disposes the material
  26250. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  26251. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  26252. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  26253. */
  26254. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  26255. /** @hidden */
  26256. private releaseVertexArrayObject;
  26257. /**
  26258. * Serializes this material
  26259. * @returns the serialized material object
  26260. */
  26261. serialize(): any;
  26262. /**
  26263. * Creates a material from parsed material data
  26264. * @param parsedMaterial defines parsed material data
  26265. * @param scene defines the hosting scene
  26266. * @param rootUrl defines the root URL to use to load textures
  26267. * @returns a new material
  26268. */
  26269. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  26270. }
  26271. }
  26272. declare module "babylonjs/Materials/multiMaterial" {
  26273. import { Nullable } from "babylonjs/types";
  26274. import { Scene } from "babylonjs/scene";
  26275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26276. import { SubMesh } from "babylonjs/Meshes/subMesh";
  26277. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  26278. import { Material } from "babylonjs/Materials/material";
  26279. /**
  26280. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26281. * separate meshes. This can be use to improve performances.
  26282. * @see https://doc.babylonjs.com/how_to/multi_materials
  26283. */
  26284. export class MultiMaterial extends Material {
  26285. private _subMaterials;
  26286. /**
  26287. * Gets or Sets the list of Materials used within the multi material.
  26288. * They need to be ordered according to the submeshes order in the associated mesh
  26289. */
  26290. get subMaterials(): Nullable<Material>[];
  26291. set subMaterials(value: Nullable<Material>[]);
  26292. /**
  26293. * Function used to align with Node.getChildren()
  26294. * @returns the list of Materials used within the multi material
  26295. */
  26296. getChildren(): Nullable<Material>[];
  26297. /**
  26298. * Instantiates a new Multi Material
  26299. * A multi-material is used to apply different materials to different parts of the same object without the need of
  26300. * separate meshes. This can be use to improve performances.
  26301. * @see https://doc.babylonjs.com/how_to/multi_materials
  26302. * @param name Define the name in the scene
  26303. * @param scene Define the scene the material belongs to
  26304. */
  26305. constructor(name: string, scene: Scene);
  26306. private _hookArray;
  26307. /**
  26308. * Get one of the submaterial by its index in the submaterials array
  26309. * @param index The index to look the sub material at
  26310. * @returns The Material if the index has been defined
  26311. */
  26312. getSubMaterial(index: number): Nullable<Material>;
  26313. /**
  26314. * Get the list of active textures for the whole sub materials list.
  26315. * @returns All the textures that will be used during the rendering
  26316. */
  26317. getActiveTextures(): BaseTexture[];
  26318. /**
  26319. * Gets the current class name of the material e.g. "MultiMaterial"
  26320. * Mainly use in serialization.
  26321. * @returns the class name
  26322. */
  26323. getClassName(): string;
  26324. /**
  26325. * Checks if the material is ready to render the requested sub mesh
  26326. * @param mesh Define the mesh the submesh belongs to
  26327. * @param subMesh Define the sub mesh to look readyness for
  26328. * @param useInstances Define whether or not the material is used with instances
  26329. * @returns true if ready, otherwise false
  26330. */
  26331. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  26332. /**
  26333. * Clones the current material and its related sub materials
  26334. * @param name Define the name of the newly cloned material
  26335. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  26336. * @returns the cloned material
  26337. */
  26338. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  26339. /**
  26340. * Serializes the materials into a JSON representation.
  26341. * @returns the JSON representation
  26342. */
  26343. serialize(): any;
  26344. /**
  26345. * Dispose the material and release its associated resources
  26346. * @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)
  26347. * @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)
  26348. * @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)
  26349. */
  26350. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  26351. /**
  26352. * Creates a MultiMaterial from parsed MultiMaterial data.
  26353. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  26354. * @param scene defines the hosting scene
  26355. * @returns a new MultiMaterial
  26356. */
  26357. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  26358. }
  26359. }
  26360. declare module "babylonjs/Meshes/subMesh" {
  26361. import { Nullable, IndicesArray, DeepImmutable, FloatArray } from "babylonjs/types";
  26362. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  26363. import { Engine } from "babylonjs/Engines/engine";
  26364. import { IntersectionInfo } from "babylonjs/Collisions/intersectionInfo";
  26365. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26366. import { Effect } from "babylonjs/Materials/effect";
  26367. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26368. import { Plane } from "babylonjs/Maths/math.plane";
  26369. import { Collider } from "babylonjs/Collisions/collider";
  26370. import { Material } from "babylonjs/Materials/material";
  26371. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  26372. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  26373. import { Mesh } from "babylonjs/Meshes/mesh";
  26374. import { Ray } from "babylonjs/Culling/ray";
  26375. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  26376. /**
  26377. * Defines a subdivision inside a mesh
  26378. */
  26379. export class SubMesh implements ICullable {
  26380. /** the material index to use */
  26381. materialIndex: number;
  26382. /** vertex index start */
  26383. verticesStart: number;
  26384. /** vertices count */
  26385. verticesCount: number;
  26386. /** index start */
  26387. indexStart: number;
  26388. /** indices count */
  26389. indexCount: number;
  26390. /** @hidden */
  26391. _materialDefines: Nullable<MaterialDefines>;
  26392. /** @hidden */
  26393. _materialEffect: Nullable<Effect>;
  26394. /** @hidden */
  26395. _effectOverride: Nullable<Effect>;
  26396. /**
  26397. * Gets material defines used by the effect associated to the sub mesh
  26398. */
  26399. get materialDefines(): Nullable<MaterialDefines>;
  26400. /**
  26401. * Sets material defines used by the effect associated to the sub mesh
  26402. */
  26403. set materialDefines(defines: Nullable<MaterialDefines>);
  26404. /**
  26405. * Gets associated effect
  26406. */
  26407. get effect(): Nullable<Effect>;
  26408. /**
  26409. * Sets associated effect (effect used to render this submesh)
  26410. * @param effect defines the effect to associate with
  26411. * @param defines defines the set of defines used to compile this effect
  26412. */
  26413. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  26414. /** @hidden */
  26415. _linesIndexCount: number;
  26416. private _mesh;
  26417. private _renderingMesh;
  26418. private _boundingInfo;
  26419. private _linesIndexBuffer;
  26420. /** @hidden */
  26421. _lastColliderWorldVertices: Nullable<Vector3[]>;
  26422. /** @hidden */
  26423. _trianglePlanes: Plane[];
  26424. /** @hidden */
  26425. _lastColliderTransformMatrix: Nullable<Matrix>;
  26426. /** @hidden */
  26427. _renderId: number;
  26428. /** @hidden */
  26429. _alphaIndex: number;
  26430. /** @hidden */
  26431. _distanceToCamera: number;
  26432. /** @hidden */
  26433. _id: number;
  26434. private _currentMaterial;
  26435. /**
  26436. * Add a new submesh to a mesh
  26437. * @param materialIndex defines the material index to use
  26438. * @param verticesStart defines vertex index start
  26439. * @param verticesCount defines vertices count
  26440. * @param indexStart defines index start
  26441. * @param indexCount defines indices count
  26442. * @param mesh defines the parent mesh
  26443. * @param renderingMesh defines an optional rendering mesh
  26444. * @param createBoundingBox defines if bounding box should be created for this submesh
  26445. * @returns the new submesh
  26446. */
  26447. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  26448. /**
  26449. * Creates a new submesh
  26450. * @param materialIndex defines the material index to use
  26451. * @param verticesStart defines vertex index start
  26452. * @param verticesCount defines vertices count
  26453. * @param indexStart defines index start
  26454. * @param indexCount defines indices count
  26455. * @param mesh defines the parent mesh
  26456. * @param renderingMesh defines an optional rendering mesh
  26457. * @param createBoundingBox defines if bounding box should be created for this submesh
  26458. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  26459. */
  26460. constructor(
  26461. /** the material index to use */
  26462. materialIndex: number,
  26463. /** vertex index start */
  26464. verticesStart: number,
  26465. /** vertices count */
  26466. verticesCount: number,
  26467. /** index start */
  26468. indexStart: number,
  26469. /** indices count */
  26470. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  26471. /**
  26472. * Returns true if this submesh covers the entire parent mesh
  26473. * @ignorenaming
  26474. */
  26475. get IsGlobal(): boolean;
  26476. /**
  26477. * Returns the submesh BoudingInfo object
  26478. * @returns current bounding info (or mesh's one if the submesh is global)
  26479. */
  26480. getBoundingInfo(): BoundingInfo;
  26481. /**
  26482. * Sets the submesh BoundingInfo
  26483. * @param boundingInfo defines the new bounding info to use
  26484. * @returns the SubMesh
  26485. */
  26486. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  26487. /**
  26488. * Returns the mesh of the current submesh
  26489. * @return the parent mesh
  26490. */
  26491. getMesh(): AbstractMesh;
  26492. /**
  26493. * Returns the rendering mesh of the submesh
  26494. * @returns the rendering mesh (could be different from parent mesh)
  26495. */
  26496. getRenderingMesh(): Mesh;
  26497. /**
  26498. * Returns the replacement mesh of the submesh
  26499. * @returns the replacement mesh (could be different from parent mesh)
  26500. */
  26501. getReplacementMesh(): Nullable<AbstractMesh>;
  26502. /**
  26503. * Returns the effective mesh of the submesh
  26504. * @returns the effective mesh (could be different from parent mesh)
  26505. */
  26506. getEffectiveMesh(): AbstractMesh;
  26507. /**
  26508. * Returns the submesh material
  26509. * @returns null or the current material
  26510. */
  26511. getMaterial(): Nullable<Material>;
  26512. private _IsMultiMaterial;
  26513. /**
  26514. * Sets a new updated BoundingInfo object to the submesh
  26515. * @param data defines an optional position array to use to determine the bounding info
  26516. * @returns the SubMesh
  26517. */
  26518. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  26519. /** @hidden */
  26520. _checkCollision(collider: Collider): boolean;
  26521. /**
  26522. * Updates the submesh BoundingInfo
  26523. * @param world defines the world matrix to use to update the bounding info
  26524. * @returns the submesh
  26525. */
  26526. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  26527. /**
  26528. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  26529. * @param frustumPlanes defines the frustum planes
  26530. * @returns true if the submesh is intersecting with the frustum
  26531. */
  26532. isInFrustum(frustumPlanes: Plane[]): boolean;
  26533. /**
  26534. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  26535. * @param frustumPlanes defines the frustum planes
  26536. * @returns true if the submesh is inside the frustum
  26537. */
  26538. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  26539. /**
  26540. * Renders the submesh
  26541. * @param enableAlphaMode defines if alpha needs to be used
  26542. * @returns the submesh
  26543. */
  26544. render(enableAlphaMode: boolean): SubMesh;
  26545. /**
  26546. * @hidden
  26547. */
  26548. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  26549. /**
  26550. * Checks if the submesh intersects with a ray
  26551. * @param ray defines the ray to test
  26552. * @returns true is the passed ray intersects the submesh bounding box
  26553. */
  26554. canIntersects(ray: Ray): boolean;
  26555. /**
  26556. * Intersects current submesh with a ray
  26557. * @param ray defines the ray to test
  26558. * @param positions defines mesh's positions array
  26559. * @param indices defines mesh's indices array
  26560. * @param fastCheck defines if the first intersection will be used (and not the closest)
  26561. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  26562. * @returns intersection info or null if no intersection
  26563. */
  26564. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  26565. /** @hidden */
  26566. private _intersectLines;
  26567. /** @hidden */
  26568. private _intersectUnIndexedLines;
  26569. /** @hidden */
  26570. private _intersectTriangles;
  26571. /** @hidden */
  26572. private _intersectUnIndexedTriangles;
  26573. /** @hidden */
  26574. _rebuild(): void;
  26575. /**
  26576. * Creates a new submesh from the passed mesh
  26577. * @param newMesh defines the new hosting mesh
  26578. * @param newRenderingMesh defines an optional rendering mesh
  26579. * @returns the new submesh
  26580. */
  26581. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  26582. /**
  26583. * Release associated resources
  26584. */
  26585. dispose(): void;
  26586. /**
  26587. * Gets the class name
  26588. * @returns the string "SubMesh".
  26589. */
  26590. getClassName(): string;
  26591. /**
  26592. * Creates a new submesh from indices data
  26593. * @param materialIndex the index of the main mesh material
  26594. * @param startIndex the index where to start the copy in the mesh indices array
  26595. * @param indexCount the number of indices to copy then from the startIndex
  26596. * @param mesh the main mesh to create the submesh from
  26597. * @param renderingMesh the optional rendering mesh
  26598. * @returns a new submesh
  26599. */
  26600. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  26601. }
  26602. }
  26603. declare module "babylonjs/Loading/sceneLoaderFlags" {
  26604. /**
  26605. * Class used to represent data loading progression
  26606. */
  26607. export class SceneLoaderFlags {
  26608. private static _ForceFullSceneLoadingForIncremental;
  26609. private static _ShowLoadingScreen;
  26610. private static _CleanBoneMatrixWeights;
  26611. private static _loggingLevel;
  26612. /**
  26613. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  26614. */
  26615. static get ForceFullSceneLoadingForIncremental(): boolean;
  26616. static set ForceFullSceneLoadingForIncremental(value: boolean);
  26617. /**
  26618. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  26619. */
  26620. static get ShowLoadingScreen(): boolean;
  26621. static set ShowLoadingScreen(value: boolean);
  26622. /**
  26623. * Defines the current logging level (while loading the scene)
  26624. * @ignorenaming
  26625. */
  26626. static get loggingLevel(): number;
  26627. static set loggingLevel(value: number);
  26628. /**
  26629. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  26630. */
  26631. static get CleanBoneMatrixWeights(): boolean;
  26632. static set CleanBoneMatrixWeights(value: boolean);
  26633. }
  26634. }
  26635. declare module "babylonjs/Meshes/geometry" {
  26636. import { Nullable, FloatArray, DataArray, IndicesArray } from "babylonjs/types";
  26637. import { Scene } from "babylonjs/scene";
  26638. import { Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  26639. import { Engine } from "babylonjs/Engines/engine";
  26640. import { IGetSetVerticesData, VertexData } from "babylonjs/Meshes/mesh.vertexData";
  26641. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  26642. import { Effect } from "babylonjs/Materials/effect";
  26643. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  26644. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  26645. import { Mesh } from "babylonjs/Meshes/mesh";
  26646. /**
  26647. * Class used to store geometry data (vertex buffers + index buffer)
  26648. */
  26649. export class Geometry implements IGetSetVerticesData {
  26650. /**
  26651. * Gets or sets the ID of the geometry
  26652. */
  26653. id: string;
  26654. /**
  26655. * Gets or sets the unique ID of the geometry
  26656. */
  26657. uniqueId: number;
  26658. /**
  26659. * Gets the delay loading state of the geometry (none by default which means not delayed)
  26660. */
  26661. delayLoadState: number;
  26662. /**
  26663. * Gets the file containing the data to load when running in delay load state
  26664. */
  26665. delayLoadingFile: Nullable<string>;
  26666. /**
  26667. * Callback called when the geometry is updated
  26668. */
  26669. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  26670. private _scene;
  26671. private _engine;
  26672. private _meshes;
  26673. private _totalVertices;
  26674. /** @hidden */
  26675. _indices: IndicesArray;
  26676. /** @hidden */
  26677. _vertexBuffers: {
  26678. [key: string]: VertexBuffer;
  26679. };
  26680. private _isDisposed;
  26681. private _extend;
  26682. private _boundingBias;
  26683. /** @hidden */
  26684. _delayInfo: Array<string>;
  26685. private _indexBuffer;
  26686. private _indexBufferIsUpdatable;
  26687. /** @hidden */
  26688. _boundingInfo: Nullable<BoundingInfo>;
  26689. /** @hidden */
  26690. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  26691. /** @hidden */
  26692. _softwareSkinningFrameId: number;
  26693. private _vertexArrayObjects;
  26694. private _updatable;
  26695. /** @hidden */
  26696. _positions: Nullable<Vector3[]>;
  26697. /**
  26698. * 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
  26699. */
  26700. get boundingBias(): Vector2;
  26701. /**
  26702. * 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
  26703. */
  26704. set boundingBias(value: Vector2);
  26705. /**
  26706. * Static function used to attach a new empty geometry to a mesh
  26707. * @param mesh defines the mesh to attach the geometry to
  26708. * @returns the new Geometry
  26709. */
  26710. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  26711. /** Get the list of meshes using this geometry */
  26712. get meshes(): Mesh[];
  26713. /**
  26714. * 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
  26715. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  26716. */
  26717. useBoundingInfoFromGeometry: boolean;
  26718. /**
  26719. * Creates a new geometry
  26720. * @param id defines the unique ID
  26721. * @param scene defines the hosting scene
  26722. * @param vertexData defines the VertexData used to get geometry data
  26723. * @param updatable defines if geometry must be updatable (false by default)
  26724. * @param mesh defines the mesh that will be associated with the geometry
  26725. */
  26726. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  26727. /**
  26728. * Gets the current extend of the geometry
  26729. */
  26730. get extend(): {
  26731. minimum: Vector3;
  26732. maximum: Vector3;
  26733. };
  26734. /**
  26735. * Gets the hosting scene
  26736. * @returns the hosting Scene
  26737. */
  26738. getScene(): Scene;
  26739. /**
  26740. * Gets the hosting engine
  26741. * @returns the hosting Engine
  26742. */
  26743. getEngine(): Engine;
  26744. /**
  26745. * Defines if the geometry is ready to use
  26746. * @returns true if the geometry is ready to be used
  26747. */
  26748. isReady(): boolean;
  26749. /**
  26750. * Gets a value indicating that the geometry should not be serialized
  26751. */
  26752. get doNotSerialize(): boolean;
  26753. /** @hidden */
  26754. _rebuild(): void;
  26755. /**
  26756. * Affects all geometry data in one call
  26757. * @param vertexData defines the geometry data
  26758. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  26759. */
  26760. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  26761. /**
  26762. * Set specific vertex data
  26763. * @param kind defines the data kind (Position, normal, etc...)
  26764. * @param data defines the vertex data to use
  26765. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26766. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26767. */
  26768. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  26769. /**
  26770. * Removes a specific vertex data
  26771. * @param kind defines the data kind (Position, normal, etc...)
  26772. */
  26773. removeVerticesData(kind: string): void;
  26774. /**
  26775. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  26776. * @param buffer defines the vertex buffer to use
  26777. * @param totalVertices defines the total number of vertices for position kind (could be null)
  26778. */
  26779. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  26780. /**
  26781. * Update a specific vertex buffer
  26782. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  26783. * It will do nothing if the buffer is not updatable
  26784. * @param kind defines the data kind (Position, normal, etc...)
  26785. * @param data defines the data to use
  26786. * @param offset defines the offset in the target buffer where to store the data
  26787. * @param useBytes set to true if the offset is in bytes
  26788. */
  26789. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  26790. /**
  26791. * Update a specific vertex buffer
  26792. * This function will create a new buffer if the current one is not updatable
  26793. * @param kind defines the data kind (Position, normal, etc...)
  26794. * @param data defines the data to use
  26795. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  26796. */
  26797. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  26798. private _updateBoundingInfo;
  26799. /** @hidden */
  26800. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  26801. /**
  26802. * Gets total number of vertices
  26803. * @returns the total number of vertices
  26804. */
  26805. getTotalVertices(): number;
  26806. /**
  26807. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26808. * @param kind defines the data kind (Position, normal, etc...)
  26809. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26810. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26811. * @returns a float array containing vertex data
  26812. */
  26813. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26814. /**
  26815. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  26816. * @param kind defines the data kind (Position, normal, etc...)
  26817. * @returns true if the vertex buffer with the specified kind is updatable
  26818. */
  26819. isVertexBufferUpdatable(kind: string): boolean;
  26820. /**
  26821. * Gets a specific vertex buffer
  26822. * @param kind defines the data kind (Position, normal, etc...)
  26823. * @returns a VertexBuffer
  26824. */
  26825. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  26826. /**
  26827. * Returns all vertex buffers
  26828. * @return an object holding all vertex buffers indexed by kind
  26829. */
  26830. getVertexBuffers(): Nullable<{
  26831. [key: string]: VertexBuffer;
  26832. }>;
  26833. /**
  26834. * Gets a boolean indicating if specific vertex buffer is present
  26835. * @param kind defines the data kind (Position, normal, etc...)
  26836. * @returns true if data is present
  26837. */
  26838. isVerticesDataPresent(kind: string): boolean;
  26839. /**
  26840. * Gets a list of all attached data kinds (Position, normal, etc...)
  26841. * @returns a list of string containing all kinds
  26842. */
  26843. getVerticesDataKinds(): string[];
  26844. /**
  26845. * Update index buffer
  26846. * @param indices defines the indices to store in the index buffer
  26847. * @param offset defines the offset in the target buffer where to store the data
  26848. * @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)
  26849. */
  26850. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  26851. /**
  26852. * Creates a new index buffer
  26853. * @param indices defines the indices to store in the index buffer
  26854. * @param totalVertices defines the total number of vertices (could be null)
  26855. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  26856. */
  26857. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  26858. /**
  26859. * Return the total number of indices
  26860. * @returns the total number of indices
  26861. */
  26862. getTotalIndices(): number;
  26863. /**
  26864. * Gets the index buffer array
  26865. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26866. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26867. * @returns the index buffer array
  26868. */
  26869. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26870. /**
  26871. * Gets the index buffer
  26872. * @return the index buffer
  26873. */
  26874. getIndexBuffer(): Nullable<DataBuffer>;
  26875. /** @hidden */
  26876. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  26877. /**
  26878. * Release the associated resources for a specific mesh
  26879. * @param mesh defines the source mesh
  26880. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  26881. */
  26882. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  26883. /**
  26884. * Apply current geometry to a given mesh
  26885. * @param mesh defines the mesh to apply geometry to
  26886. */
  26887. applyToMesh(mesh: Mesh): void;
  26888. private _updateExtend;
  26889. private _applyToMesh;
  26890. private notifyUpdate;
  26891. /**
  26892. * Load the geometry if it was flagged as delay loaded
  26893. * @param scene defines the hosting scene
  26894. * @param onLoaded defines a callback called when the geometry is loaded
  26895. */
  26896. load(scene: Scene, onLoaded?: () => void): void;
  26897. private _queueLoad;
  26898. /**
  26899. * Invert the geometry to move from a right handed system to a left handed one.
  26900. */
  26901. toLeftHanded(): void;
  26902. /** @hidden */
  26903. _resetPointsArrayCache(): void;
  26904. /** @hidden */
  26905. _generatePointsArray(): boolean;
  26906. /**
  26907. * Gets a value indicating if the geometry is disposed
  26908. * @returns true if the geometry was disposed
  26909. */
  26910. isDisposed(): boolean;
  26911. private _disposeVertexArrayObjects;
  26912. /**
  26913. * Free all associated resources
  26914. */
  26915. dispose(): void;
  26916. /**
  26917. * Clone the current geometry into a new geometry
  26918. * @param id defines the unique ID of the new geometry
  26919. * @returns a new geometry object
  26920. */
  26921. copy(id: string): Geometry;
  26922. /**
  26923. * Serialize the current geometry info (and not the vertices data) into a JSON object
  26924. * @return a JSON representation of the current geometry data (without the vertices data)
  26925. */
  26926. serialize(): any;
  26927. private toNumberArray;
  26928. /**
  26929. * Serialize all vertices data into a JSON oject
  26930. * @returns a JSON representation of the current geometry data
  26931. */
  26932. serializeVerticeData(): any;
  26933. /**
  26934. * Extracts a clone of a mesh geometry
  26935. * @param mesh defines the source mesh
  26936. * @param id defines the unique ID of the new geometry object
  26937. * @returns the new geometry object
  26938. */
  26939. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  26940. /**
  26941. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  26942. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  26943. * Be aware Math.random() could cause collisions, but:
  26944. * "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"
  26945. * @returns a string containing a new GUID
  26946. */
  26947. static RandomId(): string;
  26948. /** @hidden */
  26949. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  26950. private static _CleanMatricesWeights;
  26951. /**
  26952. * Create a new geometry from persisted data (Using .babylon file format)
  26953. * @param parsedVertexData defines the persisted data
  26954. * @param scene defines the hosting scene
  26955. * @param rootUrl defines the root url to use to load assets (like delayed data)
  26956. * @returns the new geometry object
  26957. */
  26958. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  26959. }
  26960. }
  26961. declare module "babylonjs/Meshes/mesh.vertexData" {
  26962. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  26963. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  26964. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  26965. import { Geometry } from "babylonjs/Meshes/geometry";
  26966. import { Mesh } from "babylonjs/Meshes/mesh";
  26967. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  26968. /**
  26969. * Define an interface for all classes that will get and set the data on vertices
  26970. */
  26971. export interface IGetSetVerticesData {
  26972. /**
  26973. * Gets a boolean indicating if specific vertex data is present
  26974. * @param kind defines the vertex data kind to use
  26975. * @returns true is data kind is present
  26976. */
  26977. isVerticesDataPresent(kind: string): boolean;
  26978. /**
  26979. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  26980. * @param kind defines the data kind (Position, normal, etc...)
  26981. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  26982. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26983. * @returns a float array containing vertex data
  26984. */
  26985. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  26986. /**
  26987. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  26988. * @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.
  26989. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  26990. * @returns the indices array or an empty array if the mesh has no geometry
  26991. */
  26992. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  26993. /**
  26994. * Set specific vertex data
  26995. * @param kind defines the data kind (Position, normal, etc...)
  26996. * @param data defines the vertex data to use
  26997. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  26998. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  26999. */
  27000. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  27001. /**
  27002. * Update a specific associated vertex buffer
  27003. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  27004. * - VertexBuffer.PositionKind
  27005. * - VertexBuffer.UVKind
  27006. * - VertexBuffer.UV2Kind
  27007. * - VertexBuffer.UV3Kind
  27008. * - VertexBuffer.UV4Kind
  27009. * - VertexBuffer.UV5Kind
  27010. * - VertexBuffer.UV6Kind
  27011. * - VertexBuffer.ColorKind
  27012. * - VertexBuffer.MatricesIndicesKind
  27013. * - VertexBuffer.MatricesIndicesExtraKind
  27014. * - VertexBuffer.MatricesWeightsKind
  27015. * - VertexBuffer.MatricesWeightsExtraKind
  27016. * @param data defines the data source
  27017. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  27018. * @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)
  27019. */
  27020. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  27021. /**
  27022. * Creates a new index buffer
  27023. * @param indices defines the indices to store in the index buffer
  27024. * @param totalVertices defines the total number of vertices (could be null)
  27025. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  27026. */
  27027. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  27028. }
  27029. /**
  27030. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  27031. */
  27032. export class VertexData {
  27033. /**
  27034. * Mesh side orientation : usually the external or front surface
  27035. */
  27036. static readonly FRONTSIDE: number;
  27037. /**
  27038. * Mesh side orientation : usually the internal or back surface
  27039. */
  27040. static readonly BACKSIDE: number;
  27041. /**
  27042. * Mesh side orientation : both internal and external or front and back surfaces
  27043. */
  27044. static readonly DOUBLESIDE: number;
  27045. /**
  27046. * Mesh side orientation : by default, `FRONTSIDE`
  27047. */
  27048. static readonly DEFAULTSIDE: number;
  27049. /**
  27050. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  27051. */
  27052. positions: Nullable<FloatArray>;
  27053. /**
  27054. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  27055. */
  27056. normals: Nullable<FloatArray>;
  27057. /**
  27058. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  27059. */
  27060. tangents: Nullable<FloatArray>;
  27061. /**
  27062. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27063. */
  27064. uvs: Nullable<FloatArray>;
  27065. /**
  27066. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27067. */
  27068. uvs2: Nullable<FloatArray>;
  27069. /**
  27070. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27071. */
  27072. uvs3: Nullable<FloatArray>;
  27073. /**
  27074. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27075. */
  27076. uvs4: Nullable<FloatArray>;
  27077. /**
  27078. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27079. */
  27080. uvs5: Nullable<FloatArray>;
  27081. /**
  27082. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  27083. */
  27084. uvs6: Nullable<FloatArray>;
  27085. /**
  27086. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  27087. */
  27088. colors: Nullable<FloatArray>;
  27089. /**
  27090. * 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).
  27091. */
  27092. matricesIndices: Nullable<FloatArray>;
  27093. /**
  27094. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  27095. */
  27096. matricesWeights: Nullable<FloatArray>;
  27097. /**
  27098. * An array extending the number of possible indices
  27099. */
  27100. matricesIndicesExtra: Nullable<FloatArray>;
  27101. /**
  27102. * An array extending the number of possible weights when the number of indices is extended
  27103. */
  27104. matricesWeightsExtra: Nullable<FloatArray>;
  27105. /**
  27106. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  27107. */
  27108. indices: Nullable<IndicesArray>;
  27109. /**
  27110. * Uses the passed data array to set the set the values for the specified kind of data
  27111. * @param data a linear array of floating numbers
  27112. * @param kind the type of data that is being set, eg positions, colors etc
  27113. */
  27114. set(data: FloatArray, kind: string): void;
  27115. /**
  27116. * Associates the vertexData to the passed Mesh.
  27117. * Sets it as updatable or not (default `false`)
  27118. * @param mesh the mesh the vertexData is applied to
  27119. * @param updatable when used and having the value true allows new data to update the vertexData
  27120. * @returns the VertexData
  27121. */
  27122. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  27123. /**
  27124. * Associates the vertexData to the passed Geometry.
  27125. * Sets it as updatable or not (default `false`)
  27126. * @param geometry the geometry the vertexData is applied to
  27127. * @param updatable when used and having the value true allows new data to update the vertexData
  27128. * @returns VertexData
  27129. */
  27130. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  27131. /**
  27132. * Updates the associated mesh
  27133. * @param mesh the mesh to be updated
  27134. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27135. * @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
  27136. * @returns VertexData
  27137. */
  27138. updateMesh(mesh: Mesh): VertexData;
  27139. /**
  27140. * Updates the associated geometry
  27141. * @param geometry the geometry to be updated
  27142. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  27143. * @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
  27144. * @returns VertexData.
  27145. */
  27146. updateGeometry(geometry: Geometry): VertexData;
  27147. private _applyTo;
  27148. private _update;
  27149. /**
  27150. * Transforms each position and each normal of the vertexData according to the passed Matrix
  27151. * @param matrix the transforming matrix
  27152. * @returns the VertexData
  27153. */
  27154. transform(matrix: Matrix): VertexData;
  27155. /**
  27156. * Merges the passed VertexData into the current one
  27157. * @param other the VertexData to be merged into the current one
  27158. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  27159. * @returns the modified VertexData
  27160. */
  27161. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  27162. private _mergeElement;
  27163. private _validate;
  27164. /**
  27165. * Serializes the VertexData
  27166. * @returns a serialized object
  27167. */
  27168. serialize(): any;
  27169. /**
  27170. * Extracts the vertexData from a mesh
  27171. * @param mesh the mesh from which to extract the VertexData
  27172. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  27173. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27174. * @returns the object VertexData associated to the passed mesh
  27175. */
  27176. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27177. /**
  27178. * Extracts the vertexData from the geometry
  27179. * @param geometry the geometry from which to extract the VertexData
  27180. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  27181. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  27182. * @returns the object VertexData associated to the passed mesh
  27183. */
  27184. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  27185. private static _ExtractFrom;
  27186. /**
  27187. * Creates the VertexData for a Ribbon
  27188. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  27189. * * pathArray array of paths, each of which an array of successive Vector3
  27190. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  27191. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  27192. * * 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
  27193. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27194. * * 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)
  27195. * * 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)
  27196. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  27197. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  27198. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  27199. * @returns the VertexData of the ribbon
  27200. */
  27201. static CreateRibbon(options: {
  27202. pathArray: Vector3[][];
  27203. closeArray?: boolean;
  27204. closePath?: boolean;
  27205. offset?: number;
  27206. sideOrientation?: number;
  27207. frontUVs?: Vector4;
  27208. backUVs?: Vector4;
  27209. invertUV?: boolean;
  27210. uvs?: Vector2[];
  27211. colors?: Color4[];
  27212. }): VertexData;
  27213. /**
  27214. * Creates the VertexData for a box
  27215. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27216. * * size sets the width, height and depth of the box to the value of size, optional default 1
  27217. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  27218. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  27219. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  27220. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27221. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27222. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27223. * * 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)
  27224. * * 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)
  27225. * @returns the VertexData of the box
  27226. */
  27227. static CreateBox(options: {
  27228. size?: number;
  27229. width?: number;
  27230. height?: number;
  27231. depth?: number;
  27232. faceUV?: Vector4[];
  27233. faceColors?: Color4[];
  27234. sideOrientation?: number;
  27235. frontUVs?: Vector4;
  27236. backUVs?: Vector4;
  27237. }): VertexData;
  27238. /**
  27239. * Creates the VertexData for a tiled box
  27240. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27241. * * faceTiles sets the pattern, tile size and number of tiles for a face
  27242. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  27243. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  27244. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27245. * @returns the VertexData of the box
  27246. */
  27247. static CreateTiledBox(options: {
  27248. pattern?: number;
  27249. width?: number;
  27250. height?: number;
  27251. depth?: number;
  27252. tileSize?: number;
  27253. tileWidth?: number;
  27254. tileHeight?: number;
  27255. alignHorizontal?: number;
  27256. alignVertical?: number;
  27257. faceUV?: Vector4[];
  27258. faceColors?: Color4[];
  27259. sideOrientation?: number;
  27260. }): VertexData;
  27261. /**
  27262. * Creates the VertexData for a tiled plane
  27263. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27264. * * pattern a limited pattern arrangement depending on the number
  27265. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  27266. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  27267. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  27268. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27269. * * 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)
  27270. * * 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)
  27271. * @returns the VertexData of the tiled plane
  27272. */
  27273. static CreateTiledPlane(options: {
  27274. pattern?: number;
  27275. tileSize?: number;
  27276. tileWidth?: number;
  27277. tileHeight?: number;
  27278. size?: number;
  27279. width?: number;
  27280. height?: number;
  27281. alignHorizontal?: number;
  27282. alignVertical?: number;
  27283. sideOrientation?: number;
  27284. frontUVs?: Vector4;
  27285. backUVs?: Vector4;
  27286. }): VertexData;
  27287. /**
  27288. * Creates the VertexData for an ellipsoid, defaults to a sphere
  27289. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27290. * * segments sets the number of horizontal strips optional, default 32
  27291. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  27292. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  27293. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  27294. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  27295. * * 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
  27296. * * 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
  27297. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27298. * * 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)
  27299. * * 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)
  27300. * @returns the VertexData of the ellipsoid
  27301. */
  27302. static CreateSphere(options: {
  27303. segments?: number;
  27304. diameter?: number;
  27305. diameterX?: number;
  27306. diameterY?: number;
  27307. diameterZ?: number;
  27308. arc?: number;
  27309. slice?: number;
  27310. sideOrientation?: number;
  27311. frontUVs?: Vector4;
  27312. backUVs?: Vector4;
  27313. }): VertexData;
  27314. /**
  27315. * Creates the VertexData for a cylinder, cone or prism
  27316. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27317. * * height sets the height (y direction) of the cylinder, optional, default 2
  27318. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  27319. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  27320. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  27321. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27322. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  27323. * * 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
  27324. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27325. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27326. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  27327. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  27328. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27329. * * 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)
  27330. * * 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)
  27331. * @returns the VertexData of the cylinder, cone or prism
  27332. */
  27333. static CreateCylinder(options: {
  27334. height?: number;
  27335. diameterTop?: number;
  27336. diameterBottom?: number;
  27337. diameter?: number;
  27338. tessellation?: number;
  27339. subdivisions?: number;
  27340. arc?: number;
  27341. faceColors?: Color4[];
  27342. faceUV?: Vector4[];
  27343. hasRings?: boolean;
  27344. enclose?: boolean;
  27345. sideOrientation?: number;
  27346. frontUVs?: Vector4;
  27347. backUVs?: Vector4;
  27348. }): VertexData;
  27349. /**
  27350. * Creates the VertexData for a torus
  27351. * @param options an object used to set the following optional parameters for the box, required but can be empty
  27352. * * diameter the diameter of the torus, optional default 1
  27353. * * thickness the diameter of the tube forming the torus, optional default 0.5
  27354. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  27355. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27356. * * 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)
  27357. * * 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)
  27358. * @returns the VertexData of the torus
  27359. */
  27360. static CreateTorus(options: {
  27361. diameter?: number;
  27362. thickness?: number;
  27363. tessellation?: number;
  27364. sideOrientation?: number;
  27365. frontUVs?: Vector4;
  27366. backUVs?: Vector4;
  27367. }): VertexData;
  27368. /**
  27369. * Creates the VertexData of the LineSystem
  27370. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  27371. * - lines an array of lines, each line being an array of successive Vector3
  27372. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  27373. * @returns the VertexData of the LineSystem
  27374. */
  27375. static CreateLineSystem(options: {
  27376. lines: Vector3[][];
  27377. colors?: Nullable<Color4[][]>;
  27378. }): VertexData;
  27379. /**
  27380. * Create the VertexData for a DashedLines
  27381. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  27382. * - points an array successive Vector3
  27383. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  27384. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  27385. * - dashNb the intended total number of dashes, optional, default 200
  27386. * @returns the VertexData for the DashedLines
  27387. */
  27388. static CreateDashedLines(options: {
  27389. points: Vector3[];
  27390. dashSize?: number;
  27391. gapSize?: number;
  27392. dashNb?: number;
  27393. }): VertexData;
  27394. /**
  27395. * Creates the VertexData for a Ground
  27396. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27397. * - width the width (x direction) of the ground, optional, default 1
  27398. * - height the height (z direction) of the ground, optional, default 1
  27399. * - subdivisions the number of subdivisions per side, optional, default 1
  27400. * @returns the VertexData of the Ground
  27401. */
  27402. static CreateGround(options: {
  27403. width?: number;
  27404. height?: number;
  27405. subdivisions?: number;
  27406. subdivisionsX?: number;
  27407. subdivisionsY?: number;
  27408. }): VertexData;
  27409. /**
  27410. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  27411. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  27412. * * xmin the ground minimum X coordinate, optional, default -1
  27413. * * zmin the ground minimum Z coordinate, optional, default -1
  27414. * * xmax the ground maximum X coordinate, optional, default 1
  27415. * * zmax the ground maximum Z coordinate, optional, default 1
  27416. * * 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}
  27417. * * 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}
  27418. * @returns the VertexData of the TiledGround
  27419. */
  27420. static CreateTiledGround(options: {
  27421. xmin: number;
  27422. zmin: number;
  27423. xmax: number;
  27424. zmax: number;
  27425. subdivisions?: {
  27426. w: number;
  27427. h: number;
  27428. };
  27429. precision?: {
  27430. w: number;
  27431. h: number;
  27432. };
  27433. }): VertexData;
  27434. /**
  27435. * Creates the VertexData of the Ground designed from a heightmap
  27436. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  27437. * * width the width (x direction) of the ground
  27438. * * height the height (z direction) of the ground
  27439. * * subdivisions the number of subdivisions per side
  27440. * * minHeight the minimum altitude on the ground, optional, default 0
  27441. * * maxHeight the maximum altitude on the ground, optional default 1
  27442. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  27443. * * buffer the array holding the image color data
  27444. * * bufferWidth the width of image
  27445. * * bufferHeight the height of image
  27446. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  27447. * @returns the VertexData of the Ground designed from a heightmap
  27448. */
  27449. static CreateGroundFromHeightMap(options: {
  27450. width: number;
  27451. height: number;
  27452. subdivisions: number;
  27453. minHeight: number;
  27454. maxHeight: number;
  27455. colorFilter: Color3;
  27456. buffer: Uint8Array;
  27457. bufferWidth: number;
  27458. bufferHeight: number;
  27459. alphaFilter: number;
  27460. }): VertexData;
  27461. /**
  27462. * Creates the VertexData for a Plane
  27463. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  27464. * * size sets the width and height of the plane to the value of size, optional default 1
  27465. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  27466. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  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 box
  27471. */
  27472. static CreatePlane(options: {
  27473. size?: number;
  27474. width?: number;
  27475. height?: number;
  27476. sideOrientation?: number;
  27477. frontUVs?: Vector4;
  27478. backUVs?: Vector4;
  27479. }): VertexData;
  27480. /**
  27481. * Creates the VertexData of the Disc or regular Polygon
  27482. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  27483. * * radius the radius of the disc, optional default 0.5
  27484. * * tessellation the number of polygon sides, optional, default 64
  27485. * * 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
  27486. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27487. * * 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)
  27488. * * 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)
  27489. * @returns the VertexData of the box
  27490. */
  27491. static CreateDisc(options: {
  27492. radius?: number;
  27493. tessellation?: number;
  27494. arc?: number;
  27495. sideOrientation?: number;
  27496. frontUVs?: Vector4;
  27497. backUVs?: Vector4;
  27498. }): VertexData;
  27499. /**
  27500. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  27501. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  27502. * @param polygon a mesh built from polygonTriangulation.build()
  27503. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27504. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27505. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27506. * @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)
  27507. * @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)
  27508. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  27509. * @returns the VertexData of the Polygon
  27510. */
  27511. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  27512. /**
  27513. * Creates the VertexData of the IcoSphere
  27514. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  27515. * * radius the radius of the IcoSphere, optional default 1
  27516. * * radiusX allows stretching in the x direction, optional, default radius
  27517. * * radiusY allows stretching in the y direction, optional, default radius
  27518. * * radiusZ allows stretching in the z direction, optional, default radius
  27519. * * flat when true creates a flat shaded mesh, optional, default true
  27520. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27521. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27522. * * 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)
  27523. * * 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)
  27524. * @returns the VertexData of the IcoSphere
  27525. */
  27526. static CreateIcoSphere(options: {
  27527. radius?: number;
  27528. radiusX?: number;
  27529. radiusY?: number;
  27530. radiusZ?: number;
  27531. flat?: boolean;
  27532. subdivisions?: number;
  27533. sideOrientation?: number;
  27534. frontUVs?: Vector4;
  27535. backUVs?: Vector4;
  27536. }): VertexData;
  27537. /**
  27538. * Creates the VertexData for a Polyhedron
  27539. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  27540. * * type provided types are:
  27541. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  27542. * * 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)
  27543. * * size the size of the IcoSphere, optional default 1
  27544. * * sizeX allows stretching in the x direction, optional, default size
  27545. * * sizeY allows stretching in the y direction, optional, default size
  27546. * * sizeZ allows stretching in the z direction, optional, default size
  27547. * * 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
  27548. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  27549. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  27550. * * flat when true creates a flat shaded mesh, optional, default true
  27551. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  27552. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27553. * * 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)
  27554. * * 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)
  27555. * @returns the VertexData of the Polyhedron
  27556. */
  27557. static CreatePolyhedron(options: {
  27558. type?: number;
  27559. size?: number;
  27560. sizeX?: number;
  27561. sizeY?: number;
  27562. sizeZ?: number;
  27563. custom?: any;
  27564. faceUV?: Vector4[];
  27565. faceColors?: Color4[];
  27566. flat?: boolean;
  27567. sideOrientation?: number;
  27568. frontUVs?: Vector4;
  27569. backUVs?: Vector4;
  27570. }): VertexData;
  27571. /**
  27572. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  27573. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  27574. * @returns the VertexData of the Capsule
  27575. */
  27576. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  27577. /**
  27578. * Creates the VertexData for a TorusKnot
  27579. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  27580. * * radius the radius of the torus knot, optional, default 2
  27581. * * tube the thickness of the tube, optional, default 0.5
  27582. * * radialSegments the number of sides on each tube segments, optional, default 32
  27583. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  27584. * * p the number of windings around the z axis, optional, default 2
  27585. * * q the number of windings around the x axis, optional, default 3
  27586. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  27587. * * 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)
  27588. * * 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)
  27589. * @returns the VertexData of the Torus Knot
  27590. */
  27591. static CreateTorusKnot(options: {
  27592. radius?: number;
  27593. tube?: number;
  27594. radialSegments?: number;
  27595. tubularSegments?: number;
  27596. p?: number;
  27597. q?: number;
  27598. sideOrientation?: number;
  27599. frontUVs?: Vector4;
  27600. backUVs?: Vector4;
  27601. }): VertexData;
  27602. /**
  27603. * Compute normals for given positions and indices
  27604. * @param positions an array of vertex positions, [...., x, y, z, ......]
  27605. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  27606. * @param normals an array of vertex normals, [...., x, y, z, ......]
  27607. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  27608. * * facetNormals : optional array of facet normals (vector3)
  27609. * * facetPositions : optional array of facet positions (vector3)
  27610. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  27611. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  27612. * * bInfo : optional bounding info, required for facetPartitioning computation
  27613. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  27614. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  27615. * * useRightHandedSystem: optional boolean to for right handed system computation
  27616. * * depthSort : optional boolean to enable the facet depth sort computation
  27617. * * distanceTo : optional Vector3 to compute the facet depth from this location
  27618. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  27619. */
  27620. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  27621. facetNormals?: any;
  27622. facetPositions?: any;
  27623. facetPartitioning?: any;
  27624. ratio?: number;
  27625. bInfo?: any;
  27626. bbSize?: Vector3;
  27627. subDiv?: any;
  27628. useRightHandedSystem?: boolean;
  27629. depthSort?: boolean;
  27630. distanceTo?: Vector3;
  27631. depthSortedFacets?: any;
  27632. }): void;
  27633. /** @hidden */
  27634. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  27635. /**
  27636. * Applies VertexData created from the imported parameters to the geometry
  27637. * @param parsedVertexData the parsed data from an imported file
  27638. * @param geometry the geometry to apply the VertexData to
  27639. */
  27640. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  27641. }
  27642. }
  27643. declare module "babylonjs/Morph/morphTarget" {
  27644. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  27645. import { Observable } from "babylonjs/Misc/observable";
  27646. import { Nullable, FloatArray } from "babylonjs/types";
  27647. import { Scene } from "babylonjs/scene";
  27648. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  27649. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  27650. /**
  27651. * Defines a target to use with MorphTargetManager
  27652. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27653. */
  27654. export class MorphTarget implements IAnimatable {
  27655. /** defines the name of the target */
  27656. name: string;
  27657. /**
  27658. * Gets or sets the list of animations
  27659. */
  27660. animations: import("babylonjs/Animations/animation").Animation[];
  27661. private _scene;
  27662. private _positions;
  27663. private _normals;
  27664. private _tangents;
  27665. private _uvs;
  27666. private _influence;
  27667. private _uniqueId;
  27668. /**
  27669. * Observable raised when the influence changes
  27670. */
  27671. onInfluenceChanged: Observable<boolean>;
  27672. /** @hidden */
  27673. _onDataLayoutChanged: Observable<void>;
  27674. /**
  27675. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  27676. */
  27677. get influence(): number;
  27678. set influence(influence: number);
  27679. /**
  27680. * Gets or sets the id of the morph Target
  27681. */
  27682. id: string;
  27683. private _animationPropertiesOverride;
  27684. /**
  27685. * Gets or sets the animation properties override
  27686. */
  27687. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  27688. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  27689. /**
  27690. * Creates a new MorphTarget
  27691. * @param name defines the name of the target
  27692. * @param influence defines the influence to use
  27693. * @param scene defines the scene the morphtarget belongs to
  27694. */
  27695. constructor(
  27696. /** defines the name of the target */
  27697. name: string, influence?: number, scene?: Nullable<Scene>);
  27698. /**
  27699. * Gets the unique ID of this manager
  27700. */
  27701. get uniqueId(): number;
  27702. /**
  27703. * Gets a boolean defining if the target contains position data
  27704. */
  27705. get hasPositions(): boolean;
  27706. /**
  27707. * Gets a boolean defining if the target contains normal data
  27708. */
  27709. get hasNormals(): boolean;
  27710. /**
  27711. * Gets a boolean defining if the target contains tangent data
  27712. */
  27713. get hasTangents(): boolean;
  27714. /**
  27715. * Gets a boolean defining if the target contains texture coordinates data
  27716. */
  27717. get hasUVs(): boolean;
  27718. /**
  27719. * Affects position data to this target
  27720. * @param data defines the position data to use
  27721. */
  27722. setPositions(data: Nullable<FloatArray>): void;
  27723. /**
  27724. * Gets the position data stored in this target
  27725. * @returns a FloatArray containing the position data (or null if not present)
  27726. */
  27727. getPositions(): Nullable<FloatArray>;
  27728. /**
  27729. * Affects normal data to this target
  27730. * @param data defines the normal data to use
  27731. */
  27732. setNormals(data: Nullable<FloatArray>): void;
  27733. /**
  27734. * Gets the normal data stored in this target
  27735. * @returns a FloatArray containing the normal data (or null if not present)
  27736. */
  27737. getNormals(): Nullable<FloatArray>;
  27738. /**
  27739. * Affects tangent data to this target
  27740. * @param data defines the tangent data to use
  27741. */
  27742. setTangents(data: Nullable<FloatArray>): void;
  27743. /**
  27744. * Gets the tangent data stored in this target
  27745. * @returns a FloatArray containing the tangent data (or null if not present)
  27746. */
  27747. getTangents(): Nullable<FloatArray>;
  27748. /**
  27749. * Affects texture coordinates data to this target
  27750. * @param data defines the texture coordinates data to use
  27751. */
  27752. setUVs(data: Nullable<FloatArray>): void;
  27753. /**
  27754. * Gets the texture coordinates data stored in this target
  27755. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  27756. */
  27757. getUVs(): Nullable<FloatArray>;
  27758. /**
  27759. * Clone the current target
  27760. * @returns a new MorphTarget
  27761. */
  27762. clone(): MorphTarget;
  27763. /**
  27764. * Serializes the current target into a Serialization object
  27765. * @returns the serialized object
  27766. */
  27767. serialize(): any;
  27768. /**
  27769. * Returns the string "MorphTarget"
  27770. * @returns "MorphTarget"
  27771. */
  27772. getClassName(): string;
  27773. /**
  27774. * Creates a new target from serialized data
  27775. * @param serializationObject defines the serialized data to use
  27776. * @returns a new MorphTarget
  27777. */
  27778. static Parse(serializationObject: any): MorphTarget;
  27779. /**
  27780. * Creates a MorphTarget from mesh data
  27781. * @param mesh defines the source mesh
  27782. * @param name defines the name to use for the new target
  27783. * @param influence defines the influence to attach to the target
  27784. * @returns a new MorphTarget
  27785. */
  27786. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  27787. }
  27788. }
  27789. declare module "babylonjs/Morph/morphTargetManager" {
  27790. import { Nullable } from "babylonjs/types";
  27791. import { Scene } from "babylonjs/scene";
  27792. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  27793. /**
  27794. * This class is used to deform meshes using morphing between different targets
  27795. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  27796. */
  27797. export class MorphTargetManager {
  27798. private _targets;
  27799. private _targetInfluenceChangedObservers;
  27800. private _targetDataLayoutChangedObservers;
  27801. private _activeTargets;
  27802. private _scene;
  27803. private _influences;
  27804. private _supportsNormals;
  27805. private _supportsTangents;
  27806. private _supportsUVs;
  27807. private _vertexCount;
  27808. private _uniqueId;
  27809. private _tempInfluences;
  27810. /**
  27811. * Gets or sets a boolean indicating if normals must be morphed
  27812. */
  27813. enableNormalMorphing: boolean;
  27814. /**
  27815. * Gets or sets a boolean indicating if tangents must be morphed
  27816. */
  27817. enableTangentMorphing: boolean;
  27818. /**
  27819. * Gets or sets a boolean indicating if UV must be morphed
  27820. */
  27821. enableUVMorphing: boolean;
  27822. /**
  27823. * Creates a new MorphTargetManager
  27824. * @param scene defines the current scene
  27825. */
  27826. constructor(scene?: Nullable<Scene>);
  27827. /**
  27828. * Gets the unique ID of this manager
  27829. */
  27830. get uniqueId(): number;
  27831. /**
  27832. * Gets the number of vertices handled by this manager
  27833. */
  27834. get vertexCount(): number;
  27835. /**
  27836. * Gets a boolean indicating if this manager supports morphing of normals
  27837. */
  27838. get supportsNormals(): boolean;
  27839. /**
  27840. * Gets a boolean indicating if this manager supports morphing of tangents
  27841. */
  27842. get supportsTangents(): boolean;
  27843. /**
  27844. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  27845. */
  27846. get supportsUVs(): boolean;
  27847. /**
  27848. * Gets the number of targets stored in this manager
  27849. */
  27850. get numTargets(): number;
  27851. /**
  27852. * Gets the number of influencers (ie. the number of targets with influences > 0)
  27853. */
  27854. get numInfluencers(): number;
  27855. /**
  27856. * Gets the list of influences (one per target)
  27857. */
  27858. get influences(): Float32Array;
  27859. /**
  27860. * Gets the active target at specified index. An active target is a target with an influence > 0
  27861. * @param index defines the index to check
  27862. * @returns the requested target
  27863. */
  27864. getActiveTarget(index: number): MorphTarget;
  27865. /**
  27866. * Gets the target at specified index
  27867. * @param index defines the index to check
  27868. * @returns the requested target
  27869. */
  27870. getTarget(index: number): MorphTarget;
  27871. /**
  27872. * Add a new target to this manager
  27873. * @param target defines the target to add
  27874. */
  27875. addTarget(target: MorphTarget): void;
  27876. /**
  27877. * Removes a target from the manager
  27878. * @param target defines the target to remove
  27879. */
  27880. removeTarget(target: MorphTarget): void;
  27881. /**
  27882. * Clone the current manager
  27883. * @returns a new MorphTargetManager
  27884. */
  27885. clone(): MorphTargetManager;
  27886. /**
  27887. * Serializes the current manager into a Serialization object
  27888. * @returns the serialized object
  27889. */
  27890. serialize(): any;
  27891. private _syncActiveTargets;
  27892. /**
  27893. * Syncrhonize the targets with all the meshes using this morph target manager
  27894. */
  27895. synchronize(): void;
  27896. /**
  27897. * Creates a new MorphTargetManager from serialized data
  27898. * @param serializationObject defines the serialized data
  27899. * @param scene defines the hosting scene
  27900. * @returns the new MorphTargetManager
  27901. */
  27902. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  27903. }
  27904. }
  27905. declare module "babylonjs/Meshes/meshLODLevel" {
  27906. import { Mesh } from "babylonjs/Meshes/mesh";
  27907. import { Nullable } from "babylonjs/types";
  27908. /**
  27909. * Class used to represent a specific level of detail of a mesh
  27910. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  27911. */
  27912. export class MeshLODLevel {
  27913. /** Defines the distance where this level should start being displayed */
  27914. distance: number;
  27915. /** Defines the mesh to use to render this level */
  27916. mesh: Nullable<Mesh>;
  27917. /**
  27918. * Creates a new LOD level
  27919. * @param distance defines the distance where this level should star being displayed
  27920. * @param mesh defines the mesh to use to render this level
  27921. */
  27922. constructor(
  27923. /** Defines the distance where this level should start being displayed */
  27924. distance: number,
  27925. /** Defines the mesh to use to render this level */
  27926. mesh: Nullable<Mesh>);
  27927. }
  27928. }
  27929. declare module "babylonjs/Misc/canvasGenerator" {
  27930. /**
  27931. * Helper class used to generate a canvas to manipulate images
  27932. */
  27933. export class CanvasGenerator {
  27934. /**
  27935. * Create a new canvas (or offscreen canvas depending on the context)
  27936. * @param width defines the expected width
  27937. * @param height defines the expected height
  27938. * @return a new canvas or offscreen canvas
  27939. */
  27940. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  27941. }
  27942. }
  27943. declare module "babylonjs/Meshes/groundMesh" {
  27944. import { Scene } from "babylonjs/scene";
  27945. import { Vector3 } from "babylonjs/Maths/math.vector";
  27946. import { Mesh } from "babylonjs/Meshes/mesh";
  27947. /**
  27948. * Mesh representing the gorund
  27949. */
  27950. export class GroundMesh extends Mesh {
  27951. /** If octree should be generated */
  27952. generateOctree: boolean;
  27953. private _heightQuads;
  27954. /** @hidden */
  27955. _subdivisionsX: number;
  27956. /** @hidden */
  27957. _subdivisionsY: number;
  27958. /** @hidden */
  27959. _width: number;
  27960. /** @hidden */
  27961. _height: number;
  27962. /** @hidden */
  27963. _minX: number;
  27964. /** @hidden */
  27965. _maxX: number;
  27966. /** @hidden */
  27967. _minZ: number;
  27968. /** @hidden */
  27969. _maxZ: number;
  27970. constructor(name: string, scene: Scene);
  27971. /**
  27972. * "GroundMesh"
  27973. * @returns "GroundMesh"
  27974. */
  27975. getClassName(): string;
  27976. /**
  27977. * The minimum of x and y subdivisions
  27978. */
  27979. get subdivisions(): number;
  27980. /**
  27981. * X subdivisions
  27982. */
  27983. get subdivisionsX(): number;
  27984. /**
  27985. * Y subdivisions
  27986. */
  27987. get subdivisionsY(): number;
  27988. /**
  27989. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  27990. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  27991. * @param chunksCount the number of subdivisions for x and y
  27992. * @param octreeBlocksSize (Default: 32)
  27993. */
  27994. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  27995. /**
  27996. * Returns a height (y) value in the Worl system :
  27997. * the ground altitude at the coordinates (x, z) expressed in the World system.
  27998. * @param x x coordinate
  27999. * @param z z coordinate
  28000. * @returns the ground y position if (x, z) are outside the ground surface.
  28001. */
  28002. getHeightAtCoordinates(x: number, z: number): number;
  28003. /**
  28004. * Returns a normalized vector (Vector3) orthogonal to the ground
  28005. * at the ground coordinates (x, z) expressed in the World system.
  28006. * @param x x coordinate
  28007. * @param z z coordinate
  28008. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  28009. */
  28010. getNormalAtCoordinates(x: number, z: number): Vector3;
  28011. /**
  28012. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  28013. * at the ground coordinates (x, z) expressed in the World system.
  28014. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  28015. * @param x x coordinate
  28016. * @param z z coordinate
  28017. * @param ref vector to store the result
  28018. * @returns the GroundMesh.
  28019. */
  28020. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  28021. /**
  28022. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  28023. * if the ground has been updated.
  28024. * This can be used in the render loop.
  28025. * @returns the GroundMesh.
  28026. */
  28027. updateCoordinateHeights(): GroundMesh;
  28028. private _getFacetAt;
  28029. private _initHeightQuads;
  28030. private _computeHeightQuads;
  28031. /**
  28032. * Serializes this ground mesh
  28033. * @param serializationObject object to write serialization to
  28034. */
  28035. serialize(serializationObject: any): void;
  28036. /**
  28037. * Parses a serialized ground mesh
  28038. * @param parsedMesh the serialized mesh
  28039. * @param scene the scene to create the ground mesh in
  28040. * @returns the created ground mesh
  28041. */
  28042. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  28043. }
  28044. }
  28045. declare module "babylonjs/Physics/physicsJoint" {
  28046. import { Vector3 } from "babylonjs/Maths/math.vector";
  28047. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  28048. /**
  28049. * Interface for Physics-Joint data
  28050. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28051. */
  28052. export interface PhysicsJointData {
  28053. /**
  28054. * The main pivot of the joint
  28055. */
  28056. mainPivot?: Vector3;
  28057. /**
  28058. * The connected pivot of the joint
  28059. */
  28060. connectedPivot?: Vector3;
  28061. /**
  28062. * The main axis of the joint
  28063. */
  28064. mainAxis?: Vector3;
  28065. /**
  28066. * The connected axis of the joint
  28067. */
  28068. connectedAxis?: Vector3;
  28069. /**
  28070. * The collision of the joint
  28071. */
  28072. collision?: boolean;
  28073. /**
  28074. * Native Oimo/Cannon/Energy data
  28075. */
  28076. nativeParams?: any;
  28077. }
  28078. /**
  28079. * This is a holder class for the physics joint created by the physics plugin
  28080. * It holds a set of functions to control the underlying joint
  28081. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28082. */
  28083. export class PhysicsJoint {
  28084. /**
  28085. * The type of the physics joint
  28086. */
  28087. type: number;
  28088. /**
  28089. * The data for the physics joint
  28090. */
  28091. jointData: PhysicsJointData;
  28092. private _physicsJoint;
  28093. protected _physicsPlugin: IPhysicsEnginePlugin;
  28094. /**
  28095. * Initializes the physics joint
  28096. * @param type The type of the physics joint
  28097. * @param jointData The data for the physics joint
  28098. */
  28099. constructor(
  28100. /**
  28101. * The type of the physics joint
  28102. */
  28103. type: number,
  28104. /**
  28105. * The data for the physics joint
  28106. */
  28107. jointData: PhysicsJointData);
  28108. /**
  28109. * Gets the physics joint
  28110. */
  28111. get physicsJoint(): any;
  28112. /**
  28113. * Sets the physics joint
  28114. */
  28115. set physicsJoint(newJoint: any);
  28116. /**
  28117. * Sets the physics plugin
  28118. */
  28119. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  28120. /**
  28121. * Execute a function that is physics-plugin specific.
  28122. * @param {Function} func the function that will be executed.
  28123. * It accepts two parameters: the physics world and the physics joint
  28124. */
  28125. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  28126. /**
  28127. * Distance-Joint type
  28128. */
  28129. static DistanceJoint: number;
  28130. /**
  28131. * Hinge-Joint type
  28132. */
  28133. static HingeJoint: number;
  28134. /**
  28135. * Ball-and-Socket joint type
  28136. */
  28137. static BallAndSocketJoint: number;
  28138. /**
  28139. * Wheel-Joint type
  28140. */
  28141. static WheelJoint: number;
  28142. /**
  28143. * Slider-Joint type
  28144. */
  28145. static SliderJoint: number;
  28146. /**
  28147. * Prismatic-Joint type
  28148. */
  28149. static PrismaticJoint: number;
  28150. /**
  28151. * Universal-Joint type
  28152. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  28153. */
  28154. static UniversalJoint: number;
  28155. /**
  28156. * Hinge-Joint 2 type
  28157. */
  28158. static Hinge2Joint: number;
  28159. /**
  28160. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  28161. */
  28162. static PointToPointJoint: number;
  28163. /**
  28164. * Spring-Joint type
  28165. */
  28166. static SpringJoint: number;
  28167. /**
  28168. * Lock-Joint type
  28169. */
  28170. static LockJoint: number;
  28171. }
  28172. /**
  28173. * A class representing a physics distance joint
  28174. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28175. */
  28176. export class DistanceJoint extends PhysicsJoint {
  28177. /**
  28178. *
  28179. * @param jointData The data for the Distance-Joint
  28180. */
  28181. constructor(jointData: DistanceJointData);
  28182. /**
  28183. * Update the predefined distance.
  28184. * @param maxDistance The maximum preferred distance
  28185. * @param minDistance The minimum preferred distance
  28186. */
  28187. updateDistance(maxDistance: number, minDistance?: number): void;
  28188. }
  28189. /**
  28190. * Represents a Motor-Enabled Joint
  28191. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28192. */
  28193. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  28194. /**
  28195. * Initializes the Motor-Enabled Joint
  28196. * @param type The type of the joint
  28197. * @param jointData The physica joint data for the joint
  28198. */
  28199. constructor(type: number, jointData: PhysicsJointData);
  28200. /**
  28201. * Set the motor values.
  28202. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28203. * @param force the force to apply
  28204. * @param maxForce max force for this motor.
  28205. */
  28206. setMotor(force?: number, maxForce?: number): void;
  28207. /**
  28208. * Set the motor's limits.
  28209. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28210. * @param upperLimit The upper limit of the motor
  28211. * @param lowerLimit The lower limit of the motor
  28212. */
  28213. setLimit(upperLimit: number, lowerLimit?: number): void;
  28214. }
  28215. /**
  28216. * This class represents a single physics Hinge-Joint
  28217. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28218. */
  28219. export class HingeJoint extends MotorEnabledJoint {
  28220. /**
  28221. * Initializes the Hinge-Joint
  28222. * @param jointData The joint data for the Hinge-Joint
  28223. */
  28224. constructor(jointData: PhysicsJointData);
  28225. /**
  28226. * Set the motor values.
  28227. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28228. * @param {number} force the force to apply
  28229. * @param {number} maxForce max force for this motor.
  28230. */
  28231. setMotor(force?: number, maxForce?: number): void;
  28232. /**
  28233. * Set the motor's limits.
  28234. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28235. * @param upperLimit The upper limit of the motor
  28236. * @param lowerLimit The lower limit of the motor
  28237. */
  28238. setLimit(upperLimit: number, lowerLimit?: number): void;
  28239. }
  28240. /**
  28241. * This class represents a dual hinge physics joint (same as wheel joint)
  28242. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28243. */
  28244. export class Hinge2Joint extends MotorEnabledJoint {
  28245. /**
  28246. * Initializes the Hinge2-Joint
  28247. * @param jointData The joint data for the Hinge2-Joint
  28248. */
  28249. constructor(jointData: PhysicsJointData);
  28250. /**
  28251. * Set the motor values.
  28252. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28253. * @param {number} targetSpeed the speed the motor is to reach
  28254. * @param {number} maxForce max force for this motor.
  28255. * @param {motorIndex} the motor's index, 0 or 1.
  28256. */
  28257. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  28258. /**
  28259. * Set the motor limits.
  28260. * Attention, this function is plugin specific. Engines won't react 100% the same.
  28261. * @param {number} upperLimit the upper limit
  28262. * @param {number} lowerLimit lower limit
  28263. * @param {motorIndex} the motor's index, 0 or 1.
  28264. */
  28265. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28266. }
  28267. /**
  28268. * Interface for a motor enabled joint
  28269. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28270. */
  28271. export interface IMotorEnabledJoint {
  28272. /**
  28273. * Physics joint
  28274. */
  28275. physicsJoint: any;
  28276. /**
  28277. * Sets the motor of the motor-enabled joint
  28278. * @param force The force of the motor
  28279. * @param maxForce The maximum force of the motor
  28280. * @param motorIndex The index of the motor
  28281. */
  28282. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  28283. /**
  28284. * Sets the limit of the motor
  28285. * @param upperLimit The upper limit of the motor
  28286. * @param lowerLimit The lower limit of the motor
  28287. * @param motorIndex The index of the motor
  28288. */
  28289. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28290. }
  28291. /**
  28292. * Joint data for a Distance-Joint
  28293. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28294. */
  28295. export interface DistanceJointData extends PhysicsJointData {
  28296. /**
  28297. * Max distance the 2 joint objects can be apart
  28298. */
  28299. maxDistance: number;
  28300. }
  28301. /**
  28302. * Joint data from a spring joint
  28303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28304. */
  28305. export interface SpringJointData extends PhysicsJointData {
  28306. /**
  28307. * Length of the spring
  28308. */
  28309. length: number;
  28310. /**
  28311. * Stiffness of the spring
  28312. */
  28313. stiffness: number;
  28314. /**
  28315. * Damping of the spring
  28316. */
  28317. damping: number;
  28318. /** this callback will be called when applying the force to the impostors. */
  28319. forceApplicationCallback: () => void;
  28320. }
  28321. }
  28322. declare module "babylonjs/Physics/physicsRaycastResult" {
  28323. import { Vector3 } from "babylonjs/Maths/math.vector";
  28324. /**
  28325. * Holds the data for the raycast result
  28326. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28327. */
  28328. export class PhysicsRaycastResult {
  28329. private _hasHit;
  28330. private _hitDistance;
  28331. private _hitNormalWorld;
  28332. private _hitPointWorld;
  28333. private _rayFromWorld;
  28334. private _rayToWorld;
  28335. /**
  28336. * Gets if there was a hit
  28337. */
  28338. get hasHit(): boolean;
  28339. /**
  28340. * Gets the distance from the hit
  28341. */
  28342. get hitDistance(): number;
  28343. /**
  28344. * Gets the hit normal/direction in the world
  28345. */
  28346. get hitNormalWorld(): Vector3;
  28347. /**
  28348. * Gets the hit point in the world
  28349. */
  28350. get hitPointWorld(): Vector3;
  28351. /**
  28352. * Gets the ray "start point" of the ray in the world
  28353. */
  28354. get rayFromWorld(): Vector3;
  28355. /**
  28356. * Gets the ray "end point" of the ray in the world
  28357. */
  28358. get rayToWorld(): Vector3;
  28359. /**
  28360. * Sets the hit data (normal & point in world space)
  28361. * @param hitNormalWorld defines the normal in world space
  28362. * @param hitPointWorld defines the point in world space
  28363. */
  28364. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  28365. /**
  28366. * Sets the distance from the start point to the hit point
  28367. * @param distance
  28368. */
  28369. setHitDistance(distance: number): void;
  28370. /**
  28371. * Calculates the distance manually
  28372. */
  28373. calculateHitDistance(): void;
  28374. /**
  28375. * Resets all the values to default
  28376. * @param from The from point on world space
  28377. * @param to The to point on world space
  28378. */
  28379. reset(from?: Vector3, to?: Vector3): void;
  28380. }
  28381. /**
  28382. * Interface for the size containing width and height
  28383. */
  28384. interface IXYZ {
  28385. /**
  28386. * X
  28387. */
  28388. x: number;
  28389. /**
  28390. * Y
  28391. */
  28392. y: number;
  28393. /**
  28394. * Z
  28395. */
  28396. z: number;
  28397. }
  28398. }
  28399. declare module "babylonjs/Physics/IPhysicsEngine" {
  28400. import { Nullable } from "babylonjs/types";
  28401. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  28402. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28403. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  28404. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  28405. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  28406. /**
  28407. * Interface used to describe a physics joint
  28408. */
  28409. export interface PhysicsImpostorJoint {
  28410. /** Defines the main impostor to which the joint is linked */
  28411. mainImpostor: PhysicsImpostor;
  28412. /** Defines the impostor that is connected to the main impostor using this joint */
  28413. connectedImpostor: PhysicsImpostor;
  28414. /** Defines the joint itself */
  28415. joint: PhysicsJoint;
  28416. }
  28417. /** @hidden */
  28418. export interface IPhysicsEnginePlugin {
  28419. world: any;
  28420. name: string;
  28421. setGravity(gravity: Vector3): void;
  28422. setTimeStep(timeStep: number): void;
  28423. getTimeStep(): number;
  28424. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  28425. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28426. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  28427. generatePhysicsBody(impostor: PhysicsImpostor): void;
  28428. removePhysicsBody(impostor: PhysicsImpostor): void;
  28429. generateJoint(joint: PhysicsImpostorJoint): void;
  28430. removeJoint(joint: PhysicsImpostorJoint): void;
  28431. isSupported(): boolean;
  28432. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  28433. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  28434. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28435. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  28436. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28437. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  28438. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  28439. getBodyMass(impostor: PhysicsImpostor): number;
  28440. getBodyFriction(impostor: PhysicsImpostor): number;
  28441. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  28442. getBodyRestitution(impostor: PhysicsImpostor): number;
  28443. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  28444. getBodyPressure?(impostor: PhysicsImpostor): number;
  28445. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  28446. getBodyStiffness?(impostor: PhysicsImpostor): number;
  28447. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  28448. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  28449. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  28450. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  28451. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  28452. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28453. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  28454. sleepBody(impostor: PhysicsImpostor): void;
  28455. wakeUpBody(impostor: PhysicsImpostor): void;
  28456. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28457. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  28458. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  28459. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  28460. getRadius(impostor: PhysicsImpostor): number;
  28461. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  28462. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  28463. dispose(): void;
  28464. }
  28465. /**
  28466. * Interface used to define a physics engine
  28467. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28468. */
  28469. export interface IPhysicsEngine {
  28470. /**
  28471. * Gets the gravity vector used by the simulation
  28472. */
  28473. gravity: Vector3;
  28474. /**
  28475. * Sets the gravity vector used by the simulation
  28476. * @param gravity defines the gravity vector to use
  28477. */
  28478. setGravity(gravity: Vector3): void;
  28479. /**
  28480. * Set the time step of the physics engine.
  28481. * Default is 1/60.
  28482. * To slow it down, enter 1/600 for example.
  28483. * To speed it up, 1/30
  28484. * @param newTimeStep the new timestep to apply to this world.
  28485. */
  28486. setTimeStep(newTimeStep: number): void;
  28487. /**
  28488. * Get the time step of the physics engine.
  28489. * @returns the current time step
  28490. */
  28491. getTimeStep(): number;
  28492. /**
  28493. * Set the sub time step of the physics engine.
  28494. * Default is 0 meaning there is no sub steps
  28495. * To increase physics resolution precision, set a small value (like 1 ms)
  28496. * @param subTimeStep defines the new sub timestep used for physics resolution.
  28497. */
  28498. setSubTimeStep(subTimeStep: number): void;
  28499. /**
  28500. * Get the sub time step of the physics engine.
  28501. * @returns the current sub time step
  28502. */
  28503. getSubTimeStep(): number;
  28504. /**
  28505. * Release all resources
  28506. */
  28507. dispose(): void;
  28508. /**
  28509. * Gets the name of the current physics plugin
  28510. * @returns the name of the plugin
  28511. */
  28512. getPhysicsPluginName(): string;
  28513. /**
  28514. * Adding a new impostor for the impostor tracking.
  28515. * This will be done by the impostor itself.
  28516. * @param impostor the impostor to add
  28517. */
  28518. addImpostor(impostor: PhysicsImpostor): void;
  28519. /**
  28520. * Remove an impostor from the engine.
  28521. * This impostor and its mesh will not longer be updated by the physics engine.
  28522. * @param impostor the impostor to remove
  28523. */
  28524. removeImpostor(impostor: PhysicsImpostor): void;
  28525. /**
  28526. * Add a joint to the physics engine
  28527. * @param mainImpostor defines the main impostor to which the joint is added.
  28528. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  28529. * @param joint defines the joint that will connect both impostors.
  28530. */
  28531. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28532. /**
  28533. * Removes a joint from the simulation
  28534. * @param mainImpostor defines the impostor used with the joint
  28535. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  28536. * @param joint defines the joint to remove
  28537. */
  28538. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  28539. /**
  28540. * Gets the current plugin used to run the simulation
  28541. * @returns current plugin
  28542. */
  28543. getPhysicsPlugin(): IPhysicsEnginePlugin;
  28544. /**
  28545. * Gets the list of physic impostors
  28546. * @returns an array of PhysicsImpostor
  28547. */
  28548. getImpostors(): Array<PhysicsImpostor>;
  28549. /**
  28550. * Gets the impostor for a physics enabled object
  28551. * @param object defines the object impersonated by the impostor
  28552. * @returns the PhysicsImpostor or null if not found
  28553. */
  28554. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  28555. /**
  28556. * Gets the impostor for a physics body object
  28557. * @param body defines physics body used by the impostor
  28558. * @returns the PhysicsImpostor or null if not found
  28559. */
  28560. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  28561. /**
  28562. * Does a raycast in the physics world
  28563. * @param from when should the ray start?
  28564. * @param to when should the ray end?
  28565. * @returns PhysicsRaycastResult
  28566. */
  28567. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  28568. /**
  28569. * Called by the scene. No need to call it.
  28570. * @param delta defines the timespam between frames
  28571. */
  28572. _step(delta: number): void;
  28573. }
  28574. }
  28575. declare module "babylonjs/Physics/physicsImpostor" {
  28576. import { Nullable, IndicesArray } from "babylonjs/types";
  28577. import { Vector3, Matrix, Quaternion } from "babylonjs/Maths/math.vector";
  28578. import { TransformNode } from "babylonjs/Meshes/transformNode";
  28579. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  28580. import { Scene } from "babylonjs/scene";
  28581. import { Bone } from "babylonjs/Bones/bone";
  28582. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  28583. import { PhysicsJoint, PhysicsJointData } from "babylonjs/Physics/physicsJoint";
  28584. import { Space } from "babylonjs/Maths/math.axis";
  28585. /**
  28586. * The interface for the physics imposter parameters
  28587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28588. */
  28589. export interface PhysicsImpostorParameters {
  28590. /**
  28591. * The mass of the physics imposter
  28592. */
  28593. mass: number;
  28594. /**
  28595. * The friction of the physics imposter
  28596. */
  28597. friction?: number;
  28598. /**
  28599. * The coefficient of restitution of the physics imposter
  28600. */
  28601. restitution?: number;
  28602. /**
  28603. * The native options of the physics imposter
  28604. */
  28605. nativeOptions?: any;
  28606. /**
  28607. * Specifies if the parent should be ignored
  28608. */
  28609. ignoreParent?: boolean;
  28610. /**
  28611. * Specifies if bi-directional transformations should be disabled
  28612. */
  28613. disableBidirectionalTransformation?: boolean;
  28614. /**
  28615. * The pressure inside the physics imposter, soft object only
  28616. */
  28617. pressure?: number;
  28618. /**
  28619. * The stiffness the physics imposter, soft object only
  28620. */
  28621. stiffness?: number;
  28622. /**
  28623. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  28624. */
  28625. velocityIterations?: number;
  28626. /**
  28627. * The number of iterations used in maintaining consistent vertex positions, soft object only
  28628. */
  28629. positionIterations?: number;
  28630. /**
  28631. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  28632. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  28633. * Add to fix multiple points
  28634. */
  28635. fixedPoints?: number;
  28636. /**
  28637. * The collision margin around a soft object
  28638. */
  28639. margin?: number;
  28640. /**
  28641. * The collision margin around a soft object
  28642. */
  28643. damping?: number;
  28644. /**
  28645. * The path for a rope based on an extrusion
  28646. */
  28647. path?: any;
  28648. /**
  28649. * The shape of an extrusion used for a rope based on an extrusion
  28650. */
  28651. shape?: any;
  28652. }
  28653. /**
  28654. * Interface for a physics-enabled object
  28655. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28656. */
  28657. export interface IPhysicsEnabledObject {
  28658. /**
  28659. * The position of the physics-enabled object
  28660. */
  28661. position: Vector3;
  28662. /**
  28663. * The rotation of the physics-enabled object
  28664. */
  28665. rotationQuaternion: Nullable<Quaternion>;
  28666. /**
  28667. * The scale of the physics-enabled object
  28668. */
  28669. scaling: Vector3;
  28670. /**
  28671. * The rotation of the physics-enabled object
  28672. */
  28673. rotation?: Vector3;
  28674. /**
  28675. * The parent of the physics-enabled object
  28676. */
  28677. parent?: any;
  28678. /**
  28679. * The bounding info of the physics-enabled object
  28680. * @returns The bounding info of the physics-enabled object
  28681. */
  28682. getBoundingInfo(): BoundingInfo;
  28683. /**
  28684. * Computes the world matrix
  28685. * @param force Specifies if the world matrix should be computed by force
  28686. * @returns A world matrix
  28687. */
  28688. computeWorldMatrix(force: boolean): Matrix;
  28689. /**
  28690. * Gets the world matrix
  28691. * @returns A world matrix
  28692. */
  28693. getWorldMatrix?(): Matrix;
  28694. /**
  28695. * Gets the child meshes
  28696. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  28697. * @returns An array of abstract meshes
  28698. */
  28699. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  28700. /**
  28701. * Gets the vertex data
  28702. * @param kind The type of vertex data
  28703. * @returns A nullable array of numbers, or a float32 array
  28704. */
  28705. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  28706. /**
  28707. * Gets the indices from the mesh
  28708. * @returns A nullable array of index arrays
  28709. */
  28710. getIndices?(): Nullable<IndicesArray>;
  28711. /**
  28712. * Gets the scene from the mesh
  28713. * @returns the indices array or null
  28714. */
  28715. getScene?(): Scene;
  28716. /**
  28717. * Gets the absolute position from the mesh
  28718. * @returns the absolute position
  28719. */
  28720. getAbsolutePosition(): Vector3;
  28721. /**
  28722. * Gets the absolute pivot point from the mesh
  28723. * @returns the absolute pivot point
  28724. */
  28725. getAbsolutePivotPoint(): Vector3;
  28726. /**
  28727. * Rotates the mesh
  28728. * @param axis The axis of rotation
  28729. * @param amount The amount of rotation
  28730. * @param space The space of the rotation
  28731. * @returns The rotation transform node
  28732. */
  28733. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  28734. /**
  28735. * Translates the mesh
  28736. * @param axis The axis of translation
  28737. * @param distance The distance of translation
  28738. * @param space The space of the translation
  28739. * @returns The transform node
  28740. */
  28741. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  28742. /**
  28743. * Sets the absolute position of the mesh
  28744. * @param absolutePosition The absolute position of the mesh
  28745. * @returns The transform node
  28746. */
  28747. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  28748. /**
  28749. * Gets the class name of the mesh
  28750. * @returns The class name
  28751. */
  28752. getClassName(): string;
  28753. }
  28754. /**
  28755. * Represents a physics imposter
  28756. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  28757. */
  28758. export class PhysicsImpostor {
  28759. /**
  28760. * The physics-enabled object used as the physics imposter
  28761. */
  28762. object: IPhysicsEnabledObject;
  28763. /**
  28764. * The type of the physics imposter
  28765. */
  28766. type: number;
  28767. private _options;
  28768. private _scene?;
  28769. /**
  28770. * The default object size of the imposter
  28771. */
  28772. static DEFAULT_OBJECT_SIZE: Vector3;
  28773. /**
  28774. * The identity quaternion of the imposter
  28775. */
  28776. static IDENTITY_QUATERNION: Quaternion;
  28777. /** @hidden */
  28778. _pluginData: any;
  28779. private _physicsEngine;
  28780. private _physicsBody;
  28781. private _bodyUpdateRequired;
  28782. private _onBeforePhysicsStepCallbacks;
  28783. private _onAfterPhysicsStepCallbacks;
  28784. /** @hidden */
  28785. _onPhysicsCollideCallbacks: Array<{
  28786. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  28787. otherImpostors: Array<PhysicsImpostor>;
  28788. }>;
  28789. private _deltaPosition;
  28790. private _deltaRotation;
  28791. private _deltaRotationConjugated;
  28792. /** @hidden */
  28793. _isFromLine: boolean;
  28794. private _parent;
  28795. private _isDisposed;
  28796. private static _tmpVecs;
  28797. private static _tmpQuat;
  28798. /**
  28799. * Specifies if the physics imposter is disposed
  28800. */
  28801. get isDisposed(): boolean;
  28802. /**
  28803. * Gets the mass of the physics imposter
  28804. */
  28805. get mass(): number;
  28806. set mass(value: number);
  28807. /**
  28808. * Gets the coefficient of friction
  28809. */
  28810. get friction(): number;
  28811. /**
  28812. * Sets the coefficient of friction
  28813. */
  28814. set friction(value: number);
  28815. /**
  28816. * Gets the coefficient of restitution
  28817. */
  28818. get restitution(): number;
  28819. /**
  28820. * Sets the coefficient of restitution
  28821. */
  28822. set restitution(value: number);
  28823. /**
  28824. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  28825. */
  28826. get pressure(): number;
  28827. /**
  28828. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  28829. */
  28830. set pressure(value: number);
  28831. /**
  28832. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28833. */
  28834. get stiffness(): number;
  28835. /**
  28836. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  28837. */
  28838. set stiffness(value: number);
  28839. /**
  28840. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28841. */
  28842. get velocityIterations(): number;
  28843. /**
  28844. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  28845. */
  28846. set velocityIterations(value: number);
  28847. /**
  28848. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28849. */
  28850. get positionIterations(): number;
  28851. /**
  28852. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  28853. */
  28854. set positionIterations(value: number);
  28855. /**
  28856. * The unique id of the physics imposter
  28857. * set by the physics engine when adding this impostor to the array
  28858. */
  28859. uniqueId: number;
  28860. /**
  28861. * @hidden
  28862. */
  28863. soft: boolean;
  28864. /**
  28865. * @hidden
  28866. */
  28867. segments: number;
  28868. private _joints;
  28869. /**
  28870. * Initializes the physics imposter
  28871. * @param object The physics-enabled object used as the physics imposter
  28872. * @param type The type of the physics imposter
  28873. * @param _options The options for the physics imposter
  28874. * @param _scene The Babylon scene
  28875. */
  28876. constructor(
  28877. /**
  28878. * The physics-enabled object used as the physics imposter
  28879. */
  28880. object: IPhysicsEnabledObject,
  28881. /**
  28882. * The type of the physics imposter
  28883. */
  28884. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  28885. /**
  28886. * This function will completly initialize this impostor.
  28887. * It will create a new body - but only if this mesh has no parent.
  28888. * If it has, this impostor will not be used other than to define the impostor
  28889. * of the child mesh.
  28890. * @hidden
  28891. */
  28892. _init(): void;
  28893. private _getPhysicsParent;
  28894. /**
  28895. * Should a new body be generated.
  28896. * @returns boolean specifying if body initialization is required
  28897. */
  28898. isBodyInitRequired(): boolean;
  28899. /**
  28900. * Sets the updated scaling
  28901. * @param updated Specifies if the scaling is updated
  28902. */
  28903. setScalingUpdated(): void;
  28904. /**
  28905. * Force a regeneration of this or the parent's impostor's body.
  28906. * Use under cautious - This will remove all joints already implemented.
  28907. */
  28908. forceUpdate(): void;
  28909. /**
  28910. * Gets the body that holds this impostor. Either its own, or its parent.
  28911. */
  28912. get physicsBody(): any;
  28913. /**
  28914. * Get the parent of the physics imposter
  28915. * @returns Physics imposter or null
  28916. */
  28917. get parent(): Nullable<PhysicsImpostor>;
  28918. /**
  28919. * Sets the parent of the physics imposter
  28920. */
  28921. set parent(value: Nullable<PhysicsImpostor>);
  28922. /**
  28923. * Set the physics body. Used mainly by the physics engine/plugin
  28924. */
  28925. set physicsBody(physicsBody: any);
  28926. /**
  28927. * Resets the update flags
  28928. */
  28929. resetUpdateFlags(): void;
  28930. /**
  28931. * Gets the object extend size
  28932. * @returns the object extend size
  28933. */
  28934. getObjectExtendSize(): Vector3;
  28935. /**
  28936. * Gets the object center
  28937. * @returns The object center
  28938. */
  28939. getObjectCenter(): Vector3;
  28940. /**
  28941. * Get a specific parameter from the options parameters
  28942. * @param paramName The object parameter name
  28943. * @returns The object parameter
  28944. */
  28945. getParam(paramName: string): any;
  28946. /**
  28947. * Sets a specific parameter in the options given to the physics plugin
  28948. * @param paramName The parameter name
  28949. * @param value The value of the parameter
  28950. */
  28951. setParam(paramName: string, value: number): void;
  28952. /**
  28953. * Specifically change the body's mass option. Won't recreate the physics body object
  28954. * @param mass The mass of the physics imposter
  28955. */
  28956. setMass(mass: number): void;
  28957. /**
  28958. * Gets the linear velocity
  28959. * @returns linear velocity or null
  28960. */
  28961. getLinearVelocity(): Nullable<Vector3>;
  28962. /**
  28963. * Sets the linear velocity
  28964. * @param velocity linear velocity or null
  28965. */
  28966. setLinearVelocity(velocity: Nullable<Vector3>): void;
  28967. /**
  28968. * Gets the angular velocity
  28969. * @returns angular velocity or null
  28970. */
  28971. getAngularVelocity(): Nullable<Vector3>;
  28972. /**
  28973. * Sets the angular velocity
  28974. * @param velocity The velocity or null
  28975. */
  28976. setAngularVelocity(velocity: Nullable<Vector3>): void;
  28977. /**
  28978. * Execute a function with the physics plugin native code
  28979. * Provide a function the will have two variables - the world object and the physics body object
  28980. * @param func The function to execute with the physics plugin native code
  28981. */
  28982. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  28983. /**
  28984. * Register a function that will be executed before the physics world is stepping forward
  28985. * @param func The function to execute before the physics world is stepped forward
  28986. */
  28987. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28988. /**
  28989. * Unregister a function that will be executed before the physics world is stepping forward
  28990. * @param func The function to execute before the physics world is stepped forward
  28991. */
  28992. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28993. /**
  28994. * Register a function that will be executed after the physics step
  28995. * @param func The function to execute after physics step
  28996. */
  28997. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  28998. /**
  28999. * Unregisters a function that will be executed after the physics step
  29000. * @param func The function to execute after physics step
  29001. */
  29002. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  29003. /**
  29004. * register a function that will be executed when this impostor collides against a different body
  29005. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  29006. * @param func Callback that is executed on collision
  29007. */
  29008. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  29009. /**
  29010. * Unregisters the physics imposter on contact
  29011. * @param collideAgainst The physics object to collide against
  29012. * @param func Callback to execute on collision
  29013. */
  29014. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  29015. private _tmpQuat;
  29016. private _tmpQuat2;
  29017. /**
  29018. * Get the parent rotation
  29019. * @returns The parent rotation
  29020. */
  29021. getParentsRotation(): Quaternion;
  29022. /**
  29023. * this function is executed by the physics engine.
  29024. */
  29025. beforeStep: () => void;
  29026. /**
  29027. * this function is executed by the physics engine
  29028. */
  29029. afterStep: () => void;
  29030. /**
  29031. * Legacy collision detection event support
  29032. */
  29033. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  29034. /**
  29035. * event and body object due to cannon's event-based architecture.
  29036. */
  29037. onCollide: (e: {
  29038. body: any;
  29039. }) => void;
  29040. /**
  29041. * Apply a force
  29042. * @param force The force to apply
  29043. * @param contactPoint The contact point for the force
  29044. * @returns The physics imposter
  29045. */
  29046. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29047. /**
  29048. * Apply an impulse
  29049. * @param force The impulse force
  29050. * @param contactPoint The contact point for the impulse force
  29051. * @returns The physics imposter
  29052. */
  29053. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  29054. /**
  29055. * A help function to create a joint
  29056. * @param otherImpostor A physics imposter used to create a joint
  29057. * @param jointType The type of joint
  29058. * @param jointData The data for the joint
  29059. * @returns The physics imposter
  29060. */
  29061. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  29062. /**
  29063. * Add a joint to this impostor with a different impostor
  29064. * @param otherImpostor A physics imposter used to add a joint
  29065. * @param joint The joint to add
  29066. * @returns The physics imposter
  29067. */
  29068. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  29069. /**
  29070. * Add an anchor to a cloth impostor
  29071. * @param otherImpostor rigid impostor to anchor to
  29072. * @param width ratio across width from 0 to 1
  29073. * @param height ratio up height from 0 to 1
  29074. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  29075. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  29076. * @returns impostor the soft imposter
  29077. */
  29078. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29079. /**
  29080. * Add a hook to a rope impostor
  29081. * @param otherImpostor rigid impostor to anchor to
  29082. * @param length ratio across rope from 0 to 1
  29083. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  29084. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  29085. * @returns impostor the rope imposter
  29086. */
  29087. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  29088. /**
  29089. * Will keep this body still, in a sleep mode.
  29090. * @returns the physics imposter
  29091. */
  29092. sleep(): PhysicsImpostor;
  29093. /**
  29094. * Wake the body up.
  29095. * @returns The physics imposter
  29096. */
  29097. wakeUp(): PhysicsImpostor;
  29098. /**
  29099. * Clones the physics imposter
  29100. * @param newObject The physics imposter clones to this physics-enabled object
  29101. * @returns A nullable physics imposter
  29102. */
  29103. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  29104. /**
  29105. * Disposes the physics imposter
  29106. */
  29107. dispose(): void;
  29108. /**
  29109. * Sets the delta position
  29110. * @param position The delta position amount
  29111. */
  29112. setDeltaPosition(position: Vector3): void;
  29113. /**
  29114. * Sets the delta rotation
  29115. * @param rotation The delta rotation amount
  29116. */
  29117. setDeltaRotation(rotation: Quaternion): void;
  29118. /**
  29119. * Gets the box size of the physics imposter and stores the result in the input parameter
  29120. * @param result Stores the box size
  29121. * @returns The physics imposter
  29122. */
  29123. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  29124. /**
  29125. * Gets the radius of the physics imposter
  29126. * @returns Radius of the physics imposter
  29127. */
  29128. getRadius(): number;
  29129. /**
  29130. * Sync a bone with this impostor
  29131. * @param bone The bone to sync to the impostor.
  29132. * @param boneMesh The mesh that the bone is influencing.
  29133. * @param jointPivot The pivot of the joint / bone in local space.
  29134. * @param distToJoint Optional distance from the impostor to the joint.
  29135. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29136. */
  29137. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  29138. /**
  29139. * Sync impostor to a bone
  29140. * @param bone The bone that the impostor will be synced to.
  29141. * @param boneMesh The mesh that the bone is influencing.
  29142. * @param jointPivot The pivot of the joint / bone in local space.
  29143. * @param distToJoint Optional distance from the impostor to the joint.
  29144. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  29145. * @param boneAxis Optional vector3 axis the bone is aligned with
  29146. */
  29147. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  29148. /**
  29149. * No-Imposter type
  29150. */
  29151. static NoImpostor: number;
  29152. /**
  29153. * Sphere-Imposter type
  29154. */
  29155. static SphereImpostor: number;
  29156. /**
  29157. * Box-Imposter type
  29158. */
  29159. static BoxImpostor: number;
  29160. /**
  29161. * Plane-Imposter type
  29162. */
  29163. static PlaneImpostor: number;
  29164. /**
  29165. * Mesh-imposter type
  29166. */
  29167. static MeshImpostor: number;
  29168. /**
  29169. * Capsule-Impostor type (Ammo.js plugin only)
  29170. */
  29171. static CapsuleImpostor: number;
  29172. /**
  29173. * Cylinder-Imposter type
  29174. */
  29175. static CylinderImpostor: number;
  29176. /**
  29177. * Particle-Imposter type
  29178. */
  29179. static ParticleImpostor: number;
  29180. /**
  29181. * Heightmap-Imposter type
  29182. */
  29183. static HeightmapImpostor: number;
  29184. /**
  29185. * ConvexHull-Impostor type (Ammo.js plugin only)
  29186. */
  29187. static ConvexHullImpostor: number;
  29188. /**
  29189. * Custom-Imposter type (Ammo.js plugin only)
  29190. */
  29191. static CustomImpostor: number;
  29192. /**
  29193. * Rope-Imposter type
  29194. */
  29195. static RopeImpostor: number;
  29196. /**
  29197. * Cloth-Imposter type
  29198. */
  29199. static ClothImpostor: number;
  29200. /**
  29201. * Softbody-Imposter type
  29202. */
  29203. static SoftbodyImpostor: number;
  29204. }
  29205. }
  29206. declare module "babylonjs/Meshes/mesh" {
  29207. import { Observable } from "babylonjs/Misc/observable";
  29208. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  29209. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  29210. import { Camera } from "babylonjs/Cameras/camera";
  29211. import { Scene } from "babylonjs/scene";
  29212. import { Matrix, Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  29213. import { Color4 } from "babylonjs/Maths/math.color";
  29214. import { Engine } from "babylonjs/Engines/engine";
  29215. import { Node } from "babylonjs/node";
  29216. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  29217. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  29218. import { Buffer } from "babylonjs/Meshes/buffer";
  29219. import { Geometry } from "babylonjs/Meshes/geometry";
  29220. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  29221. import { SubMesh } from "babylonjs/Meshes/subMesh";
  29222. import { BoundingSphere } from "babylonjs/Culling/boundingSphere";
  29223. import { Effect } from "babylonjs/Materials/effect";
  29224. import { Material } from "babylonjs/Materials/material";
  29225. import { Skeleton } from "babylonjs/Bones/skeleton";
  29226. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  29227. import { MeshLODLevel } from "babylonjs/Meshes/meshLODLevel";
  29228. import { Path3D } from "babylonjs/Maths/math.path";
  29229. import { Plane } from "babylonjs/Maths/math.plane";
  29230. import { TransformNode } from "babylonjs/Meshes/transformNode";
  29231. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  29232. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  29233. import { InstancedMesh } from "babylonjs/Meshes/instancedMesh";
  29234. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  29235. import { IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  29236. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  29237. /**
  29238. * @hidden
  29239. **/
  29240. export class _CreationDataStorage {
  29241. closePath?: boolean;
  29242. closeArray?: boolean;
  29243. idx: number[];
  29244. dashSize: number;
  29245. gapSize: number;
  29246. path3D: Path3D;
  29247. pathArray: Vector3[][];
  29248. arc: number;
  29249. radius: number;
  29250. cap: number;
  29251. tessellation: number;
  29252. }
  29253. /**
  29254. * @hidden
  29255. **/
  29256. class _InstanceDataStorage {
  29257. visibleInstances: any;
  29258. batchCache: _InstancesBatch;
  29259. instancesBufferSize: number;
  29260. instancesBuffer: Nullable<Buffer>;
  29261. instancesData: Float32Array;
  29262. overridenInstanceCount: number;
  29263. isFrozen: boolean;
  29264. previousBatch: Nullable<_InstancesBatch>;
  29265. hardwareInstancedRendering: boolean;
  29266. sideOrientation: number;
  29267. manualUpdate: boolean;
  29268. previousRenderId: number;
  29269. }
  29270. /**
  29271. * @hidden
  29272. **/
  29273. export class _InstancesBatch {
  29274. mustReturn: boolean;
  29275. visibleInstances: Nullable<import("babylonjs/Meshes/instancedMesh").InstancedMesh[]>[];
  29276. renderSelf: boolean[];
  29277. hardwareInstancedRendering: boolean[];
  29278. }
  29279. /**
  29280. * @hidden
  29281. **/
  29282. class _ThinInstanceDataStorage {
  29283. instancesCount: number;
  29284. matrixBuffer: Nullable<Buffer>;
  29285. matrixBufferSize: number;
  29286. matrixData: Nullable<Float32Array>;
  29287. boundingVectors: Array<Vector3>;
  29288. worldMatrices: Nullable<Matrix[]>;
  29289. }
  29290. /**
  29291. * Class used to represent renderable models
  29292. */
  29293. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  29294. /**
  29295. * Mesh side orientation : usually the external or front surface
  29296. */
  29297. static readonly FRONTSIDE: number;
  29298. /**
  29299. * Mesh side orientation : usually the internal or back surface
  29300. */
  29301. static readonly BACKSIDE: number;
  29302. /**
  29303. * Mesh side orientation : both internal and external or front and back surfaces
  29304. */
  29305. static readonly DOUBLESIDE: number;
  29306. /**
  29307. * Mesh side orientation : by default, `FRONTSIDE`
  29308. */
  29309. static readonly DEFAULTSIDE: number;
  29310. /**
  29311. * Mesh cap setting : no cap
  29312. */
  29313. static readonly NO_CAP: number;
  29314. /**
  29315. * Mesh cap setting : one cap at the beginning of the mesh
  29316. */
  29317. static readonly CAP_START: number;
  29318. /**
  29319. * Mesh cap setting : one cap at the end of the mesh
  29320. */
  29321. static readonly CAP_END: number;
  29322. /**
  29323. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  29324. */
  29325. static readonly CAP_ALL: number;
  29326. /**
  29327. * Mesh pattern setting : no flip or rotate
  29328. */
  29329. static readonly NO_FLIP: number;
  29330. /**
  29331. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  29332. */
  29333. static readonly FLIP_TILE: number;
  29334. /**
  29335. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  29336. */
  29337. static readonly ROTATE_TILE: number;
  29338. /**
  29339. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  29340. */
  29341. static readonly FLIP_ROW: number;
  29342. /**
  29343. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  29344. */
  29345. static readonly ROTATE_ROW: number;
  29346. /**
  29347. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  29348. */
  29349. static readonly FLIP_N_ROTATE_TILE: number;
  29350. /**
  29351. * Mesh pattern setting : rotate pattern and rotate
  29352. */
  29353. static readonly FLIP_N_ROTATE_ROW: number;
  29354. /**
  29355. * Mesh tile positioning : part tiles same on left/right or top/bottom
  29356. */
  29357. static readonly CENTER: number;
  29358. /**
  29359. * Mesh tile positioning : part tiles on left
  29360. */
  29361. static readonly LEFT: number;
  29362. /**
  29363. * Mesh tile positioning : part tiles on right
  29364. */
  29365. static readonly RIGHT: number;
  29366. /**
  29367. * Mesh tile positioning : part tiles on top
  29368. */
  29369. static readonly TOP: number;
  29370. /**
  29371. * Mesh tile positioning : part tiles on bottom
  29372. */
  29373. static readonly BOTTOM: number;
  29374. /**
  29375. * Gets the default side orientation.
  29376. * @param orientation the orientation to value to attempt to get
  29377. * @returns the default orientation
  29378. * @hidden
  29379. */
  29380. static _GetDefaultSideOrientation(orientation?: number): number;
  29381. private _internalMeshDataInfo;
  29382. get computeBonesUsingShaders(): boolean;
  29383. set computeBonesUsingShaders(value: boolean);
  29384. /**
  29385. * An event triggered before rendering the mesh
  29386. */
  29387. get onBeforeRenderObservable(): Observable<Mesh>;
  29388. /**
  29389. * An event triggered before binding the mesh
  29390. */
  29391. get onBeforeBindObservable(): Observable<Mesh>;
  29392. /**
  29393. * An event triggered after rendering the mesh
  29394. */
  29395. get onAfterRenderObservable(): Observable<Mesh>;
  29396. /**
  29397. * An event triggered before drawing the mesh
  29398. */
  29399. get onBeforeDrawObservable(): Observable<Mesh>;
  29400. private _onBeforeDrawObserver;
  29401. /**
  29402. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  29403. */
  29404. set onBeforeDraw(callback: () => void);
  29405. get hasInstances(): boolean;
  29406. get hasThinInstances(): boolean;
  29407. /**
  29408. * Gets the delay loading state of the mesh (when delay loading is turned on)
  29409. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  29410. */
  29411. delayLoadState: number;
  29412. /**
  29413. * Gets the list of instances created from this mesh
  29414. * it is not supposed to be modified manually.
  29415. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  29416. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  29417. */
  29418. instances: import("babylonjs/Meshes/instancedMesh").InstancedMesh[];
  29419. /**
  29420. * Gets the file containing delay loading data for this mesh
  29421. */
  29422. delayLoadingFile: string;
  29423. /** @hidden */
  29424. _binaryInfo: any;
  29425. /**
  29426. * User defined function used to change how LOD level selection is done
  29427. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29428. */
  29429. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  29430. /**
  29431. * Gets or sets the morph target manager
  29432. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  29433. */
  29434. get morphTargetManager(): Nullable<MorphTargetManager>;
  29435. set morphTargetManager(value: Nullable<MorphTargetManager>);
  29436. /** @hidden */
  29437. _creationDataStorage: Nullable<_CreationDataStorage>;
  29438. /** @hidden */
  29439. _geometry: Nullable<Geometry>;
  29440. /** @hidden */
  29441. _delayInfo: Array<string>;
  29442. /** @hidden */
  29443. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  29444. /** @hidden */
  29445. _instanceDataStorage: _InstanceDataStorage;
  29446. /** @hidden */
  29447. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  29448. private _effectiveMaterial;
  29449. /** @hidden */
  29450. _shouldGenerateFlatShading: boolean;
  29451. /** @hidden */
  29452. _originalBuilderSideOrientation: number;
  29453. /**
  29454. * Use this property to change the original side orientation defined at construction time
  29455. */
  29456. overrideMaterialSideOrientation: Nullable<number>;
  29457. /**
  29458. * Gets the source mesh (the one used to clone this one from)
  29459. */
  29460. get source(): Nullable<Mesh>;
  29461. /**
  29462. * Gets the list of clones of this mesh
  29463. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  29464. * Note that useClonedMeshMap=true is the default setting
  29465. */
  29466. get cloneMeshMap(): Nullable<{
  29467. [id: string]: Mesh | undefined;
  29468. }>;
  29469. /**
  29470. * Gets or sets a boolean indicating that this mesh does not use index buffer
  29471. */
  29472. get isUnIndexed(): boolean;
  29473. set isUnIndexed(value: boolean);
  29474. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  29475. get worldMatrixInstancedBuffer(): Float32Array;
  29476. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  29477. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  29478. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  29479. /**
  29480. * @constructor
  29481. * @param name The value used by scene.getMeshByName() to do a lookup.
  29482. * @param scene The scene to add this mesh to.
  29483. * @param parent The parent of this mesh, if it has one
  29484. * @param source An optional Mesh from which geometry is shared, cloned.
  29485. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  29486. * When false, achieved by calling a clone(), also passing False.
  29487. * This will make creation of children, recursive.
  29488. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  29489. */
  29490. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  29491. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  29492. doNotInstantiate: boolean;
  29493. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  29494. /**
  29495. * Gets the class name
  29496. * @returns the string "Mesh".
  29497. */
  29498. getClassName(): string;
  29499. /** @hidden */
  29500. get _isMesh(): boolean;
  29501. /**
  29502. * Returns a description of this mesh
  29503. * @param fullDetails define if full details about this mesh must be used
  29504. * @returns a descriptive string representing this mesh
  29505. */
  29506. toString(fullDetails?: boolean): string;
  29507. /** @hidden */
  29508. _unBindEffect(): void;
  29509. /**
  29510. * Gets a boolean indicating if this mesh has LOD
  29511. */
  29512. get hasLODLevels(): boolean;
  29513. /**
  29514. * Gets the list of MeshLODLevel associated with the current mesh
  29515. * @returns an array of MeshLODLevel
  29516. */
  29517. getLODLevels(): MeshLODLevel[];
  29518. private _sortLODLevels;
  29519. /**
  29520. * Add a mesh as LOD level triggered at the given distance.
  29521. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29522. * @param distance The distance from the center of the object to show this level
  29523. * @param mesh The mesh to be added as LOD level (can be null)
  29524. * @return This mesh (for chaining)
  29525. */
  29526. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  29527. /**
  29528. * Returns the LOD level mesh at the passed distance or null if not found.
  29529. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29530. * @param distance The distance from the center of the object to show this level
  29531. * @returns a Mesh or `null`
  29532. */
  29533. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  29534. /**
  29535. * Remove a mesh from the LOD array
  29536. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29537. * @param mesh defines the mesh to be removed
  29538. * @return This mesh (for chaining)
  29539. */
  29540. removeLODLevel(mesh: Mesh): Mesh;
  29541. /**
  29542. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  29543. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  29544. * @param camera defines the camera to use to compute distance
  29545. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  29546. * @return This mesh (for chaining)
  29547. */
  29548. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  29549. /**
  29550. * Gets the mesh internal Geometry object
  29551. */
  29552. get geometry(): Nullable<Geometry>;
  29553. /**
  29554. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  29555. * @returns the total number of vertices
  29556. */
  29557. getTotalVertices(): number;
  29558. /**
  29559. * Returns the content of an associated vertex buffer
  29560. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29561. * - VertexBuffer.PositionKind
  29562. * - VertexBuffer.UVKind
  29563. * - VertexBuffer.UV2Kind
  29564. * - VertexBuffer.UV3Kind
  29565. * - VertexBuffer.UV4Kind
  29566. * - VertexBuffer.UV5Kind
  29567. * - VertexBuffer.UV6Kind
  29568. * - VertexBuffer.ColorKind
  29569. * - VertexBuffer.MatricesIndicesKind
  29570. * - VertexBuffer.MatricesIndicesExtraKind
  29571. * - VertexBuffer.MatricesWeightsKind
  29572. * - VertexBuffer.MatricesWeightsExtraKind
  29573. * @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
  29574. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  29575. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  29576. */
  29577. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  29578. /**
  29579. * Returns the mesh VertexBuffer object from the requested `kind`
  29580. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29581. * - VertexBuffer.PositionKind
  29582. * - VertexBuffer.NormalKind
  29583. * - VertexBuffer.UVKind
  29584. * - VertexBuffer.UV2Kind
  29585. * - VertexBuffer.UV3Kind
  29586. * - VertexBuffer.UV4Kind
  29587. * - VertexBuffer.UV5Kind
  29588. * - VertexBuffer.UV6Kind
  29589. * - VertexBuffer.ColorKind
  29590. * - VertexBuffer.MatricesIndicesKind
  29591. * - VertexBuffer.MatricesIndicesExtraKind
  29592. * - VertexBuffer.MatricesWeightsKind
  29593. * - VertexBuffer.MatricesWeightsExtraKind
  29594. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  29595. */
  29596. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  29597. /**
  29598. * Tests if a specific vertex buffer is associated with this mesh
  29599. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29600. * - VertexBuffer.PositionKind
  29601. * - VertexBuffer.NormalKind
  29602. * - VertexBuffer.UVKind
  29603. * - VertexBuffer.UV2Kind
  29604. * - VertexBuffer.UV3Kind
  29605. * - VertexBuffer.UV4Kind
  29606. * - VertexBuffer.UV5Kind
  29607. * - VertexBuffer.UV6Kind
  29608. * - VertexBuffer.ColorKind
  29609. * - VertexBuffer.MatricesIndicesKind
  29610. * - VertexBuffer.MatricesIndicesExtraKind
  29611. * - VertexBuffer.MatricesWeightsKind
  29612. * - VertexBuffer.MatricesWeightsExtraKind
  29613. * @returns a boolean
  29614. */
  29615. isVerticesDataPresent(kind: string): boolean;
  29616. /**
  29617. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  29618. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  29619. * - VertexBuffer.PositionKind
  29620. * - VertexBuffer.UVKind
  29621. * - VertexBuffer.UV2Kind
  29622. * - VertexBuffer.UV3Kind
  29623. * - VertexBuffer.UV4Kind
  29624. * - VertexBuffer.UV5Kind
  29625. * - VertexBuffer.UV6Kind
  29626. * - VertexBuffer.ColorKind
  29627. * - VertexBuffer.MatricesIndicesKind
  29628. * - VertexBuffer.MatricesIndicesExtraKind
  29629. * - VertexBuffer.MatricesWeightsKind
  29630. * - VertexBuffer.MatricesWeightsExtraKind
  29631. * @returns a boolean
  29632. */
  29633. isVertexBufferUpdatable(kind: string): boolean;
  29634. /**
  29635. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  29636. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  29637. * - VertexBuffer.PositionKind
  29638. * - VertexBuffer.NormalKind
  29639. * - VertexBuffer.UVKind
  29640. * - VertexBuffer.UV2Kind
  29641. * - VertexBuffer.UV3Kind
  29642. * - VertexBuffer.UV4Kind
  29643. * - VertexBuffer.UV5Kind
  29644. * - VertexBuffer.UV6Kind
  29645. * - VertexBuffer.ColorKind
  29646. * - VertexBuffer.MatricesIndicesKind
  29647. * - VertexBuffer.MatricesIndicesExtraKind
  29648. * - VertexBuffer.MatricesWeightsKind
  29649. * - VertexBuffer.MatricesWeightsExtraKind
  29650. * @returns an array of strings
  29651. */
  29652. getVerticesDataKinds(): string[];
  29653. /**
  29654. * Returns a positive integer : the total number of indices in this mesh geometry.
  29655. * @returns the numner of indices or zero if the mesh has no geometry.
  29656. */
  29657. getTotalIndices(): number;
  29658. /**
  29659. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  29660. * @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.
  29661. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  29662. * @returns the indices array or an empty array if the mesh has no geometry
  29663. */
  29664. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  29665. get isBlocked(): boolean;
  29666. /**
  29667. * Determine if the current mesh is ready to be rendered
  29668. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  29669. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  29670. * @returns true if all associated assets are ready (material, textures, shaders)
  29671. */
  29672. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  29673. /**
  29674. * 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.
  29675. */
  29676. get areNormalsFrozen(): boolean;
  29677. /**
  29678. * 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.
  29679. * @returns the current mesh
  29680. */
  29681. freezeNormals(): Mesh;
  29682. /**
  29683. * 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
  29684. * @returns the current mesh
  29685. */
  29686. unfreezeNormals(): Mesh;
  29687. /**
  29688. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  29689. */
  29690. set overridenInstanceCount(count: number);
  29691. /** @hidden */
  29692. _preActivate(): Mesh;
  29693. /** @hidden */
  29694. _preActivateForIntermediateRendering(renderId: number): Mesh;
  29695. /** @hidden */
  29696. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  29697. protected _afterComputeWorldMatrix(): void;
  29698. /** @hidden */
  29699. _postActivate(): void;
  29700. /**
  29701. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  29702. * This means the mesh underlying bounding box and sphere are recomputed.
  29703. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  29704. * @returns the current mesh
  29705. */
  29706. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  29707. /** @hidden */
  29708. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  29709. /**
  29710. * This function will subdivide the mesh into multiple submeshes
  29711. * @param count defines the expected number of submeshes
  29712. */
  29713. subdivide(count: number): void;
  29714. /**
  29715. * Copy a FloatArray into a specific associated vertex buffer
  29716. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29717. * - VertexBuffer.PositionKind
  29718. * - VertexBuffer.UVKind
  29719. * - VertexBuffer.UV2Kind
  29720. * - VertexBuffer.UV3Kind
  29721. * - VertexBuffer.UV4Kind
  29722. * - VertexBuffer.UV5Kind
  29723. * - VertexBuffer.UV6Kind
  29724. * - VertexBuffer.ColorKind
  29725. * - VertexBuffer.MatricesIndicesKind
  29726. * - VertexBuffer.MatricesIndicesExtraKind
  29727. * - VertexBuffer.MatricesWeightsKind
  29728. * - VertexBuffer.MatricesWeightsExtraKind
  29729. * @param data defines the data source
  29730. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29731. * @param stride defines the data stride size (can be null)
  29732. * @returns the current mesh
  29733. */
  29734. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  29735. /**
  29736. * Delete a vertex buffer associated with this mesh
  29737. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  29738. * - VertexBuffer.PositionKind
  29739. * - VertexBuffer.UVKind
  29740. * - VertexBuffer.UV2Kind
  29741. * - VertexBuffer.UV3Kind
  29742. * - VertexBuffer.UV4Kind
  29743. * - VertexBuffer.UV5Kind
  29744. * - VertexBuffer.UV6Kind
  29745. * - VertexBuffer.ColorKind
  29746. * - VertexBuffer.MatricesIndicesKind
  29747. * - VertexBuffer.MatricesIndicesExtraKind
  29748. * - VertexBuffer.MatricesWeightsKind
  29749. * - VertexBuffer.MatricesWeightsExtraKind
  29750. */
  29751. removeVerticesData(kind: string): void;
  29752. /**
  29753. * Flags an associated vertex buffer as updatable
  29754. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  29755. * - VertexBuffer.PositionKind
  29756. * - VertexBuffer.UVKind
  29757. * - VertexBuffer.UV2Kind
  29758. * - VertexBuffer.UV3Kind
  29759. * - VertexBuffer.UV4Kind
  29760. * - VertexBuffer.UV5Kind
  29761. * - VertexBuffer.UV6Kind
  29762. * - VertexBuffer.ColorKind
  29763. * - VertexBuffer.MatricesIndicesKind
  29764. * - VertexBuffer.MatricesIndicesExtraKind
  29765. * - VertexBuffer.MatricesWeightsKind
  29766. * - VertexBuffer.MatricesWeightsExtraKind
  29767. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  29768. */
  29769. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  29770. /**
  29771. * Sets the mesh global Vertex Buffer
  29772. * @param buffer defines the buffer to use
  29773. * @returns the current mesh
  29774. */
  29775. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  29776. /**
  29777. * Update a specific associated vertex buffer
  29778. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  29779. * - VertexBuffer.PositionKind
  29780. * - VertexBuffer.UVKind
  29781. * - VertexBuffer.UV2Kind
  29782. * - VertexBuffer.UV3Kind
  29783. * - VertexBuffer.UV4Kind
  29784. * - VertexBuffer.UV5Kind
  29785. * - VertexBuffer.UV6Kind
  29786. * - VertexBuffer.ColorKind
  29787. * - VertexBuffer.MatricesIndicesKind
  29788. * - VertexBuffer.MatricesIndicesExtraKind
  29789. * - VertexBuffer.MatricesWeightsKind
  29790. * - VertexBuffer.MatricesWeightsExtraKind
  29791. * @param data defines the data source
  29792. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  29793. * @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)
  29794. * @returns the current mesh
  29795. */
  29796. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  29797. /**
  29798. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  29799. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  29800. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  29801. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  29802. * @returns the current mesh
  29803. */
  29804. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  29805. /**
  29806. * Creates a un-shared specific occurence of the geometry for the mesh.
  29807. * @returns the current mesh
  29808. */
  29809. makeGeometryUnique(): Mesh;
  29810. /**
  29811. * Set the index buffer of this mesh
  29812. * @param indices defines the source data
  29813. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  29814. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  29815. * @returns the current mesh
  29816. */
  29817. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  29818. /**
  29819. * Update the current index buffer
  29820. * @param indices defines the source data
  29821. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  29822. * @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)
  29823. * @returns the current mesh
  29824. */
  29825. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  29826. /**
  29827. * Invert the geometry to move from a right handed system to a left handed one.
  29828. * @returns the current mesh
  29829. */
  29830. toLeftHanded(): Mesh;
  29831. /** @hidden */
  29832. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  29833. /** @hidden */
  29834. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  29835. /**
  29836. * Registers for this mesh a javascript function called just before the rendering process
  29837. * @param func defines the function to call before rendering this mesh
  29838. * @returns the current mesh
  29839. */
  29840. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29841. /**
  29842. * Disposes a previously registered javascript function called before the rendering
  29843. * @param func defines the function to remove
  29844. * @returns the current mesh
  29845. */
  29846. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  29847. /**
  29848. * Registers for this mesh a javascript function called just after the rendering is complete
  29849. * @param func defines the function to call after rendering this mesh
  29850. * @returns the current mesh
  29851. */
  29852. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29853. /**
  29854. * Disposes a previously registered javascript function called after the rendering.
  29855. * @param func defines the function to remove
  29856. * @returns the current mesh
  29857. */
  29858. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  29859. /** @hidden */
  29860. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  29861. /** @hidden */
  29862. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  29863. /** @hidden */
  29864. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  29865. /** @hidden */
  29866. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  29867. /** @hidden */
  29868. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  29869. /** @hidden */
  29870. _rebuild(): void;
  29871. /** @hidden */
  29872. _freeze(): void;
  29873. /** @hidden */
  29874. _unFreeze(): void;
  29875. /**
  29876. * 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
  29877. * @param subMesh defines the subMesh to render
  29878. * @param enableAlphaMode defines if alpha mode can be changed
  29879. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  29880. * @returns the current mesh
  29881. */
  29882. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  29883. private _onBeforeDraw;
  29884. /**
  29885. * Renormalize the mesh and patch it up if there are no weights
  29886. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  29887. * However in the case of zero weights then we set just a single influence to 1.
  29888. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  29889. */
  29890. cleanMatrixWeights(): void;
  29891. private normalizeSkinFourWeights;
  29892. private normalizeSkinWeightsAndExtra;
  29893. /**
  29894. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  29895. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  29896. * the user know there was an issue with importing the mesh
  29897. * @returns a validation object with skinned, valid and report string
  29898. */
  29899. validateSkinning(): {
  29900. skinned: boolean;
  29901. valid: boolean;
  29902. report: string;
  29903. };
  29904. /** @hidden */
  29905. _checkDelayState(): Mesh;
  29906. private _queueLoad;
  29907. /**
  29908. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  29909. * A mesh is in the frustum if its bounding box intersects the frustum
  29910. * @param frustumPlanes defines the frustum to test
  29911. * @returns true if the mesh is in the frustum planes
  29912. */
  29913. isInFrustum(frustumPlanes: Plane[]): boolean;
  29914. /**
  29915. * Sets the mesh material by the material or multiMaterial `id` property
  29916. * @param id is a string identifying the material or the multiMaterial
  29917. * @returns the current mesh
  29918. */
  29919. setMaterialByID(id: string): Mesh;
  29920. /**
  29921. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  29922. * @returns an array of IAnimatable
  29923. */
  29924. getAnimatables(): IAnimatable[];
  29925. /**
  29926. * Modifies the mesh geometry according to the passed transformation matrix.
  29927. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  29928. * The mesh normals are modified using the same transformation.
  29929. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29930. * @param transform defines the transform matrix to use
  29931. * @see https://doc.babylonjs.com/resources/baking_transformations
  29932. * @returns the current mesh
  29933. */
  29934. bakeTransformIntoVertices(transform: Matrix): Mesh;
  29935. /**
  29936. * Modifies the mesh geometry according to its own current World Matrix.
  29937. * The mesh World Matrix is then reset.
  29938. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  29939. * Note that, under the hood, this method sets a new VertexBuffer each call.
  29940. * @see https://doc.babylonjs.com/resources/baking_transformations
  29941. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  29942. * @returns the current mesh
  29943. */
  29944. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  29945. /** @hidden */
  29946. get _positions(): Nullable<Vector3[]>;
  29947. /** @hidden */
  29948. _resetPointsArrayCache(): Mesh;
  29949. /** @hidden */
  29950. _generatePointsArray(): boolean;
  29951. /**
  29952. * Returns a new Mesh object generated from the current mesh properties.
  29953. * This method must not get confused with createInstance()
  29954. * @param name is a string, the name given to the new mesh
  29955. * @param newParent can be any Node object (default `null`)
  29956. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  29957. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  29958. * @returns a new mesh
  29959. */
  29960. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  29961. /**
  29962. * Releases resources associated with this mesh.
  29963. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  29964. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  29965. */
  29966. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  29967. /** @hidden */
  29968. _disposeInstanceSpecificData(): void;
  29969. /** @hidden */
  29970. _disposeThinInstanceSpecificData(): void;
  29971. /**
  29972. * Modifies the mesh geometry according to a displacement map.
  29973. * 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.
  29974. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29975. * @param url is a string, the URL from the image file is to be downloaded.
  29976. * @param minHeight is the lower limit of the displacement.
  29977. * @param maxHeight is the upper limit of the displacement.
  29978. * @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.
  29979. * @param uvOffset is an optional vector2 used to offset UV.
  29980. * @param uvScale is an optional vector2 used to scale UV.
  29981. * @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.
  29982. * @returns the Mesh.
  29983. */
  29984. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  29985. /**
  29986. * Modifies the mesh geometry according to a displacementMap buffer.
  29987. * 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.
  29988. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  29989. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  29990. * @param heightMapWidth is the width of the buffer image.
  29991. * @param heightMapHeight is the height of the buffer image.
  29992. * @param minHeight is the lower limit of the displacement.
  29993. * @param maxHeight is the upper limit of the displacement.
  29994. * @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.
  29995. * @param uvOffset is an optional vector2 used to offset UV.
  29996. * @param uvScale is an optional vector2 used to scale UV.
  29997. * @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.
  29998. * @returns the Mesh.
  29999. */
  30000. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  30001. /**
  30002. * Modify the mesh to get a flat shading rendering.
  30003. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  30004. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  30005. * @returns current mesh
  30006. */
  30007. convertToFlatShadedMesh(): Mesh;
  30008. /**
  30009. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  30010. * In other words, more vertices, no more indices and a single bigger VBO.
  30011. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  30012. * @returns current mesh
  30013. */
  30014. convertToUnIndexedMesh(): Mesh;
  30015. /**
  30016. * Inverses facet orientations.
  30017. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30018. * @param flipNormals will also inverts the normals
  30019. * @returns current mesh
  30020. */
  30021. flipFaces(flipNormals?: boolean): Mesh;
  30022. /**
  30023. * Increase the number of facets and hence vertices in a mesh
  30024. * Vertex normals are interpolated from existing vertex normals
  30025. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30026. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  30027. */
  30028. increaseVertices(numberPerEdge: number): void;
  30029. /**
  30030. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  30031. * This will undo any application of covertToFlatShadedMesh
  30032. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  30033. */
  30034. forceSharedVertices(): void;
  30035. /** @hidden */
  30036. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  30037. /** @hidden */
  30038. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  30039. /**
  30040. * Creates a new InstancedMesh object from the mesh model.
  30041. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  30042. * @param name defines the name of the new instance
  30043. * @returns a new InstancedMesh
  30044. */
  30045. createInstance(name: string): InstancedMesh;
  30046. /**
  30047. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  30048. * After this call, all the mesh instances have the same submeshes than the current mesh.
  30049. * @returns the current mesh
  30050. */
  30051. synchronizeInstances(): Mesh;
  30052. /**
  30053. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  30054. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  30055. * This should be used together with the simplification to avoid disappearing triangles.
  30056. * @param successCallback an optional success callback to be called after the optimization finished.
  30057. * @returns the current mesh
  30058. */
  30059. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  30060. /**
  30061. * Serialize current mesh
  30062. * @param serializationObject defines the object which will receive the serialization data
  30063. */
  30064. serialize(serializationObject: any): void;
  30065. /** @hidden */
  30066. _syncGeometryWithMorphTargetManager(): void;
  30067. /** @hidden */
  30068. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  30069. /**
  30070. * Returns a new Mesh object parsed from the source provided.
  30071. * @param parsedMesh is the source
  30072. * @param scene defines the hosting scene
  30073. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  30074. * @returns a new Mesh
  30075. */
  30076. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  30077. /**
  30078. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  30079. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30080. * @param name defines the name of the mesh to create
  30081. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  30082. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  30083. * @param closePath creates a seam between the first and the last points of each path of the path array
  30084. * @param offset is taken in account only if the `pathArray` is containing a single path
  30085. * @param scene defines the hosting scene
  30086. * @param updatable defines if the mesh must be flagged as updatable
  30087. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30088. * @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)
  30089. * @returns a new Mesh
  30090. */
  30091. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30092. /**
  30093. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  30094. * @param name defines the name of the mesh to create
  30095. * @param radius sets the radius size (float) of the polygon (default 0.5)
  30096. * @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
  30097. * @param scene defines the hosting scene
  30098. * @param updatable defines if the mesh must be flagged as updatable
  30099. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30100. * @returns a new Mesh
  30101. */
  30102. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30103. /**
  30104. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  30105. * @param name defines the name of the mesh to create
  30106. * @param size sets the size (float) of each box side (default 1)
  30107. * @param scene defines the hosting scene
  30108. * @param updatable defines if the mesh must be flagged as updatable
  30109. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30110. * @returns a new Mesh
  30111. */
  30112. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  30113. /**
  30114. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  30115. * @param name defines the name of the mesh to create
  30116. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30117. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30118. * @param scene defines the hosting scene
  30119. * @param updatable defines if the mesh must be flagged as updatable
  30120. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30121. * @returns a new Mesh
  30122. */
  30123. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30124. /**
  30125. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  30126. * @param name defines the name of the mesh to create
  30127. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  30128. * @param diameter sets the diameter size (float) of the sphere (default 1)
  30129. * @param scene defines the hosting scene
  30130. * @returns a new Mesh
  30131. */
  30132. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  30133. /**
  30134. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  30135. * @param name defines the name of the mesh to create
  30136. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  30137. * @param diameterTop set the top cap diameter (floats, default 1)
  30138. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  30139. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  30140. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  30141. * @param scene defines the hosting scene
  30142. * @param updatable defines if the mesh must be flagged as updatable
  30143. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30144. * @returns a new Mesh
  30145. */
  30146. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  30147. /**
  30148. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  30149. * @param name defines the name of the mesh to create
  30150. * @param diameter sets the diameter size (float) of the torus (default 1)
  30151. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  30152. * @param tessellation sets the number of torus sides (postive integer, default 16)
  30153. * @param scene defines the hosting scene
  30154. * @param updatable defines if the mesh must be flagged as updatable
  30155. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30156. * @returns a new Mesh
  30157. */
  30158. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30159. /**
  30160. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  30161. * @param name defines the name of the mesh to create
  30162. * @param radius sets the global radius size (float) of the torus knot (default 2)
  30163. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  30164. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  30165. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  30166. * @param p the number of windings on X axis (positive integers, default 2)
  30167. * @param q the number of windings on Y axis (positive integers, default 3)
  30168. * @param scene defines the hosting scene
  30169. * @param updatable defines if the mesh must be flagged as updatable
  30170. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30171. * @returns a new Mesh
  30172. */
  30173. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30174. /**
  30175. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  30176. * @param name defines the name of the mesh to create
  30177. * @param points is an array successive Vector3
  30178. * @param scene defines the hosting scene
  30179. * @param updatable defines if the mesh must be flagged as updatable
  30180. * @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).
  30181. * @returns a new Mesh
  30182. */
  30183. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  30184. /**
  30185. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  30186. * @param name defines the name of the mesh to create
  30187. * @param points is an array successive Vector3
  30188. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  30189. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  30190. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  30191. * @param scene defines the hosting scene
  30192. * @param updatable defines if the mesh must be flagged as updatable
  30193. * @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)
  30194. * @returns a new Mesh
  30195. */
  30196. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  30197. /**
  30198. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  30199. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  30200. * 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.
  30201. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30202. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  30203. * Remember you can only change the shape positions, not their number when updating a polygon.
  30204. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  30205. * @param name defines the name of the mesh to create
  30206. * @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
  30207. * @param scene defines the hosting scene
  30208. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30209. * @param updatable defines if the mesh must be flagged as updatable
  30210. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30211. * @param earcutInjection can be used to inject your own earcut reference
  30212. * @returns a new Mesh
  30213. */
  30214. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30215. /**
  30216. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  30217. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  30218. * @param name defines the name of the mesh to create
  30219. * @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
  30220. * @param depth defines the height of extrusion
  30221. * @param scene defines the hosting scene
  30222. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  30223. * @param updatable defines if the mesh must be flagged as updatable
  30224. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30225. * @param earcutInjection can be used to inject your own earcut reference
  30226. * @returns a new Mesh
  30227. */
  30228. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  30229. /**
  30230. * Creates an extruded shape mesh.
  30231. * 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
  30232. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30233. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30234. * @param name defines the name of the mesh to create
  30235. * @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
  30236. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30237. * @param scale is the value to scale the shape
  30238. * @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
  30239. * @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
  30240. * @param scene defines the hosting scene
  30241. * @param updatable defines if the mesh must be flagged as updatable
  30242. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30243. * @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)
  30244. * @returns a new Mesh
  30245. */
  30246. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30247. /**
  30248. * Creates an custom extruded shape mesh.
  30249. * The custom extrusion is a parametric shape.
  30250. * It has no predefined shape. Its final shape will depend on the input parameters.
  30251. * Please consider using the same method from the MeshBuilder class instead
  30252. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  30253. * @param name defines the name of the mesh to create
  30254. * @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
  30255. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  30256. * @param scaleFunction is a custom Javascript function called on each path point
  30257. * @param rotationFunction is a custom Javascript function called on each path point
  30258. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  30259. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  30260. * @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
  30261. * @param scene defines the hosting scene
  30262. * @param updatable defines if the mesh must be flagged as updatable
  30263. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30264. * @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)
  30265. * @returns a new Mesh
  30266. */
  30267. 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;
  30268. /**
  30269. * Creates lathe mesh.
  30270. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  30271. * Please consider using the same method from the MeshBuilder class instead
  30272. * @param name defines the name of the mesh to create
  30273. * @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
  30274. * @param radius is the radius value of the lathe
  30275. * @param tessellation is the side number of the lathe.
  30276. * @param scene defines the hosting scene
  30277. * @param updatable defines if the mesh must be flagged as updatable
  30278. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30279. * @returns a new Mesh
  30280. */
  30281. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30282. /**
  30283. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  30284. * @param name defines the name of the mesh to create
  30285. * @param size sets the size (float) of both sides of the plane at once (default 1)
  30286. * @param scene defines the hosting scene
  30287. * @param updatable defines if the mesh must be flagged as updatable
  30288. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30289. * @returns a new Mesh
  30290. */
  30291. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  30292. /**
  30293. * Creates a ground mesh.
  30294. * Please consider using the same method from the MeshBuilder class instead
  30295. * @param name defines the name of the mesh to create
  30296. * @param width set the width of the ground
  30297. * @param height set the height of the ground
  30298. * @param subdivisions sets the number of subdivisions per side
  30299. * @param scene defines the hosting scene
  30300. * @param updatable defines if the mesh must be flagged as updatable
  30301. * @returns a new Mesh
  30302. */
  30303. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  30304. /**
  30305. * Creates a tiled ground mesh.
  30306. * Please consider using the same method from the MeshBuilder class instead
  30307. * @param name defines the name of the mesh to create
  30308. * @param xmin set the ground minimum X coordinate
  30309. * @param zmin set the ground minimum Y coordinate
  30310. * @param xmax set the ground maximum X coordinate
  30311. * @param zmax set the ground maximum Z coordinate
  30312. * @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
  30313. * @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
  30314. * @param scene defines the hosting scene
  30315. * @param updatable defines if the mesh must be flagged as updatable
  30316. * @returns a new Mesh
  30317. */
  30318. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  30319. w: number;
  30320. h: number;
  30321. }, precision: {
  30322. w: number;
  30323. h: number;
  30324. }, scene: Scene, updatable?: boolean): Mesh;
  30325. /**
  30326. * Creates a ground mesh from a height map.
  30327. * Please consider using the same method from the MeshBuilder class instead
  30328. * @see https://doc.babylonjs.com/babylon101/height_map
  30329. * @param name defines the name of the mesh to create
  30330. * @param url sets the URL of the height map image resource
  30331. * @param width set the ground width size
  30332. * @param height set the ground height size
  30333. * @param subdivisions sets the number of subdivision per side
  30334. * @param minHeight is the minimum altitude on the ground
  30335. * @param maxHeight is the maximum altitude on the ground
  30336. * @param scene defines the hosting scene
  30337. * @param updatable defines if the mesh must be flagged as updatable
  30338. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  30339. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  30340. * @returns a new Mesh
  30341. */
  30342. 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;
  30343. /**
  30344. * Creates a tube mesh.
  30345. * The tube is a parametric shape.
  30346. * It has no predefined shape. Its final shape will depend on the input parameters.
  30347. * Please consider using the same method from the MeshBuilder class instead
  30348. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  30349. * @param name defines the name of the mesh to create
  30350. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  30351. * @param radius sets the tube radius size
  30352. * @param tessellation is the number of sides on the tubular surface
  30353. * @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
  30354. * @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
  30355. * @param scene defines the hosting scene
  30356. * @param updatable defines if the mesh must be flagged as updatable
  30357. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  30358. * @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)
  30359. * @returns a new Mesh
  30360. */
  30361. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  30362. (i: number, distance: number): number;
  30363. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  30364. /**
  30365. * Creates a polyhedron mesh.
  30366. * Please consider using the same method from the MeshBuilder class instead.
  30367. * * 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
  30368. * * The parameter `size` (positive float, default 1) sets the polygon size
  30369. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  30370. * * 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`
  30371. * * 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
  30372. * * 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)`)
  30373. * * 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
  30374. * * 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
  30375. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30376. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30377. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30378. * @param name defines the name of the mesh to create
  30379. * @param options defines the options used to create the mesh
  30380. * @param scene defines the hosting scene
  30381. * @returns a new Mesh
  30382. */
  30383. static CreatePolyhedron(name: string, options: {
  30384. type?: number;
  30385. size?: number;
  30386. sizeX?: number;
  30387. sizeY?: number;
  30388. sizeZ?: number;
  30389. custom?: any;
  30390. faceUV?: Vector4[];
  30391. faceColors?: Color4[];
  30392. updatable?: boolean;
  30393. sideOrientation?: number;
  30394. }, scene: Scene): Mesh;
  30395. /**
  30396. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  30397. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  30398. * * 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`)
  30399. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  30400. * * 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
  30401. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  30402. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  30403. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  30404. * @param name defines the name of the mesh
  30405. * @param options defines the options used to create the mesh
  30406. * @param scene defines the hosting scene
  30407. * @returns a new Mesh
  30408. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  30409. */
  30410. static CreateIcoSphere(name: string, options: {
  30411. radius?: number;
  30412. flat?: boolean;
  30413. subdivisions?: number;
  30414. sideOrientation?: number;
  30415. updatable?: boolean;
  30416. }, scene: Scene): Mesh;
  30417. /**
  30418. * Creates a decal mesh.
  30419. * Please consider using the same method from the MeshBuilder class instead.
  30420. * A decal is a mesh usually applied as a model onto the surface of another mesh
  30421. * @param name defines the name of the mesh
  30422. * @param sourceMesh defines the mesh receiving the decal
  30423. * @param position sets the position of the decal in world coordinates
  30424. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  30425. * @param size sets the decal scaling
  30426. * @param angle sets the angle to rotate the decal
  30427. * @returns a new Mesh
  30428. */
  30429. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  30430. /** Creates a Capsule Mesh
  30431. * @param name defines the name of the mesh.
  30432. * @param options the constructors options used to shape the mesh.
  30433. * @param scene defines the scene the mesh is scoped to.
  30434. * @returns the capsule mesh
  30435. * @see https://doc.babylonjs.com/how_to/capsule_shape
  30436. */
  30437. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  30438. /**
  30439. * Prepare internal position array for software CPU skinning
  30440. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  30441. */
  30442. setPositionsForCPUSkinning(): Float32Array;
  30443. /**
  30444. * Prepare internal normal array for software CPU skinning
  30445. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  30446. */
  30447. setNormalsForCPUSkinning(): Float32Array;
  30448. /**
  30449. * Updates the vertex buffer by applying transformation from the bones
  30450. * @param skeleton defines the skeleton to apply to current mesh
  30451. * @returns the current mesh
  30452. */
  30453. applySkeleton(skeleton: Skeleton): Mesh;
  30454. /**
  30455. * 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
  30456. * @param meshes defines the list of meshes to scan
  30457. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  30458. */
  30459. static MinMax(meshes: AbstractMesh[]): {
  30460. min: Vector3;
  30461. max: Vector3;
  30462. };
  30463. /**
  30464. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  30465. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  30466. * @returns a vector3
  30467. */
  30468. static Center(meshesOrMinMaxVector: {
  30469. min: Vector3;
  30470. max: Vector3;
  30471. } | AbstractMesh[]): Vector3;
  30472. /**
  30473. * Merge the array of meshes into a single mesh for performance reasons.
  30474. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  30475. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  30476. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  30477. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  30478. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  30479. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  30480. * @returns a new mesh
  30481. */
  30482. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  30483. /** @hidden */
  30484. addInstance(instance: InstancedMesh): void;
  30485. /** @hidden */
  30486. removeInstance(instance: InstancedMesh): void;
  30487. }
  30488. }
  30489. declare module "babylonjs/Cameras/camera" {
  30490. import { SmartArray } from "babylonjs/Misc/smartArray";
  30491. import { Observable } from "babylonjs/Misc/observable";
  30492. import { Nullable } from "babylonjs/types";
  30493. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  30494. import { Scene } from "babylonjs/scene";
  30495. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  30496. import { Node } from "babylonjs/node";
  30497. import { Mesh } from "babylonjs/Meshes/mesh";
  30498. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  30499. import { ICullable } from "babylonjs/Culling/boundingInfo";
  30500. import { Viewport } from "babylonjs/Maths/math.viewport";
  30501. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  30502. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  30503. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  30504. import { Ray } from "babylonjs/Culling/ray";
  30505. /**
  30506. * This is the base class of all the camera used in the application.
  30507. * @see https://doc.babylonjs.com/features/cameras
  30508. */
  30509. export class Camera extends Node {
  30510. /** @hidden */
  30511. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  30512. /**
  30513. * This is the default projection mode used by the cameras.
  30514. * It helps recreating a feeling of perspective and better appreciate depth.
  30515. * This is the best way to simulate real life cameras.
  30516. */
  30517. static readonly PERSPECTIVE_CAMERA: number;
  30518. /**
  30519. * This helps creating camera with an orthographic mode.
  30520. * 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.
  30521. */
  30522. static readonly ORTHOGRAPHIC_CAMERA: number;
  30523. /**
  30524. * This is the default FOV mode for perspective cameras.
  30525. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  30526. */
  30527. static readonly FOVMODE_VERTICAL_FIXED: number;
  30528. /**
  30529. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  30530. */
  30531. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  30532. /**
  30533. * This specifies ther is no need for a camera rig.
  30534. * Basically only one eye is rendered corresponding to the camera.
  30535. */
  30536. static readonly RIG_MODE_NONE: number;
  30537. /**
  30538. * Simulates a camera Rig with one blue eye and one red eye.
  30539. * This can be use with 3d blue and red glasses.
  30540. */
  30541. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  30542. /**
  30543. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  30544. */
  30545. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  30546. /**
  30547. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  30548. */
  30549. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  30550. /**
  30551. * Defines that both eyes of the camera will be rendered over under each other.
  30552. */
  30553. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  30554. /**
  30555. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  30556. */
  30557. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  30558. /**
  30559. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  30560. */
  30561. static readonly RIG_MODE_VR: number;
  30562. /**
  30563. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  30564. */
  30565. static readonly RIG_MODE_WEBVR: number;
  30566. /**
  30567. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  30568. */
  30569. static readonly RIG_MODE_CUSTOM: number;
  30570. /**
  30571. * Defines if by default attaching controls should prevent the default javascript event to continue.
  30572. */
  30573. static ForceAttachControlToAlwaysPreventDefault: boolean;
  30574. /**
  30575. * Define the input manager associated with the camera.
  30576. */
  30577. inputs: CameraInputsManager<Camera>;
  30578. /** @hidden */
  30579. _position: Vector3;
  30580. /**
  30581. * Define the current local position of the camera in the scene
  30582. */
  30583. get position(): Vector3;
  30584. set position(newPosition: Vector3);
  30585. protected _upVector: Vector3;
  30586. /**
  30587. * The vector the camera should consider as up.
  30588. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  30589. */
  30590. set upVector(vec: Vector3);
  30591. get upVector(): Vector3;
  30592. /**
  30593. * Define the current limit on the left side for an orthographic camera
  30594. * In scene unit
  30595. */
  30596. orthoLeft: Nullable<number>;
  30597. /**
  30598. * Define the current limit on the right side for an orthographic camera
  30599. * In scene unit
  30600. */
  30601. orthoRight: Nullable<number>;
  30602. /**
  30603. * Define the current limit on the bottom side for an orthographic camera
  30604. * In scene unit
  30605. */
  30606. orthoBottom: Nullable<number>;
  30607. /**
  30608. * Define the current limit on the top side for an orthographic camera
  30609. * In scene unit
  30610. */
  30611. orthoTop: Nullable<number>;
  30612. /**
  30613. * Field Of View is set in Radians. (default is 0.8)
  30614. */
  30615. fov: number;
  30616. /**
  30617. * Define the minimum distance the camera can see from.
  30618. * This is important to note that the depth buffer are not infinite and the closer it starts
  30619. * the more your scene might encounter depth fighting issue.
  30620. */
  30621. minZ: number;
  30622. /**
  30623. * Define the maximum distance the camera can see to.
  30624. * This is important to note that the depth buffer are not infinite and the further it end
  30625. * the more your scene might encounter depth fighting issue.
  30626. */
  30627. maxZ: number;
  30628. /**
  30629. * Define the default inertia of the camera.
  30630. * This helps giving a smooth feeling to the camera movement.
  30631. */
  30632. inertia: number;
  30633. /**
  30634. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  30635. */
  30636. mode: number;
  30637. /**
  30638. * Define whether the camera is intermediate.
  30639. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  30640. */
  30641. isIntermediate: boolean;
  30642. /**
  30643. * Define the viewport of the camera.
  30644. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  30645. */
  30646. viewport: Viewport;
  30647. /**
  30648. * Restricts the camera to viewing objects with the same layerMask.
  30649. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  30650. */
  30651. layerMask: number;
  30652. /**
  30653. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  30654. */
  30655. fovMode: number;
  30656. /**
  30657. * Rig mode of the camera.
  30658. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  30659. * This is normally controlled byt the camera themselves as internal use.
  30660. */
  30661. cameraRigMode: number;
  30662. /**
  30663. * Defines the distance between both "eyes" in case of a RIG
  30664. */
  30665. interaxialDistance: number;
  30666. /**
  30667. * Defines if stereoscopic rendering is done side by side or over under.
  30668. */
  30669. isStereoscopicSideBySide: boolean;
  30670. /**
  30671. * 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
  30672. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  30673. * else in the scene. (Eg. security camera)
  30674. *
  30675. * 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)
  30676. */
  30677. customRenderTargets: import("babylonjs/Materials/Textures/renderTargetTexture").RenderTargetTexture[];
  30678. /**
  30679. * When set, the camera will render to this render target instead of the default canvas
  30680. *
  30681. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  30682. */
  30683. outputRenderTarget: Nullable<RenderTargetTexture>;
  30684. /**
  30685. * Observable triggered when the camera view matrix has changed.
  30686. */
  30687. onViewMatrixChangedObservable: Observable<Camera>;
  30688. /**
  30689. * Observable triggered when the camera Projection matrix has changed.
  30690. */
  30691. onProjectionMatrixChangedObservable: Observable<Camera>;
  30692. /**
  30693. * Observable triggered when the inputs have been processed.
  30694. */
  30695. onAfterCheckInputsObservable: Observable<Camera>;
  30696. /**
  30697. * Observable triggered when reset has been called and applied to the camera.
  30698. */
  30699. onRestoreStateObservable: Observable<Camera>;
  30700. /**
  30701. * Is this camera a part of a rig system?
  30702. */
  30703. isRigCamera: boolean;
  30704. /**
  30705. * If isRigCamera set to true this will be set with the parent camera.
  30706. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  30707. */
  30708. rigParent?: Camera;
  30709. /** @hidden */
  30710. _cameraRigParams: any;
  30711. /** @hidden */
  30712. _rigCameras: Camera[];
  30713. /** @hidden */
  30714. _rigPostProcess: Nullable<PostProcess>;
  30715. protected _webvrViewMatrix: Matrix;
  30716. /** @hidden */
  30717. _skipRendering: boolean;
  30718. /** @hidden */
  30719. _projectionMatrix: Matrix;
  30720. /** @hidden */
  30721. _postProcesses: Nullable<import("babylonjs/PostProcesses/postProcess").PostProcess>[];
  30722. /** @hidden */
  30723. _activeMeshes: SmartArray<AbstractMesh>;
  30724. protected _globalPosition: Vector3;
  30725. /** @hidden */
  30726. _computedViewMatrix: Matrix;
  30727. private _doNotComputeProjectionMatrix;
  30728. private _transformMatrix;
  30729. private _frustumPlanes;
  30730. private _refreshFrustumPlanes;
  30731. private _storedFov;
  30732. private _stateStored;
  30733. /**
  30734. * Instantiates a new camera object.
  30735. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  30736. * @see https://doc.babylonjs.com/features/cameras
  30737. * @param name Defines the name of the camera in the scene
  30738. * @param position Defines the position of the camera
  30739. * @param scene Defines the scene the camera belongs too
  30740. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  30741. */
  30742. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  30743. /**
  30744. * Store current camera state (fov, position, etc..)
  30745. * @returns the camera
  30746. */
  30747. storeState(): Camera;
  30748. /**
  30749. * Restores the camera state values if it has been stored. You must call storeState() first
  30750. */
  30751. protected _restoreStateValues(): boolean;
  30752. /**
  30753. * Restored camera state. You must call storeState() first.
  30754. * @returns true if restored and false otherwise
  30755. */
  30756. restoreState(): boolean;
  30757. /**
  30758. * Gets the class name of the camera.
  30759. * @returns the class name
  30760. */
  30761. getClassName(): string;
  30762. /** @hidden */
  30763. readonly _isCamera: boolean;
  30764. /**
  30765. * Gets a string representation of the camera useful for debug purpose.
  30766. * @param fullDetails Defines that a more verboe level of logging is required
  30767. * @returns the string representation
  30768. */
  30769. toString(fullDetails?: boolean): string;
  30770. /**
  30771. * Gets the current world space position of the camera.
  30772. */
  30773. get globalPosition(): Vector3;
  30774. /**
  30775. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  30776. * @returns the active meshe list
  30777. */
  30778. getActiveMeshes(): SmartArray<AbstractMesh>;
  30779. /**
  30780. * Check whether a mesh is part of the current active mesh list of the camera
  30781. * @param mesh Defines the mesh to check
  30782. * @returns true if active, false otherwise
  30783. */
  30784. isActiveMesh(mesh: Mesh): boolean;
  30785. /**
  30786. * Is this camera ready to be used/rendered
  30787. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  30788. * @return true if the camera is ready
  30789. */
  30790. isReady(completeCheck?: boolean): boolean;
  30791. /** @hidden */
  30792. _initCache(): void;
  30793. /** @hidden */
  30794. _updateCache(ignoreParentClass?: boolean): void;
  30795. /** @hidden */
  30796. _isSynchronized(): boolean;
  30797. /** @hidden */
  30798. _isSynchronizedViewMatrix(): boolean;
  30799. /** @hidden */
  30800. _isSynchronizedProjectionMatrix(): boolean;
  30801. /**
  30802. * Attach the input controls to a specific dom element to get the input from.
  30803. * @param element Defines the element the controls should be listened from
  30804. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  30805. */
  30806. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  30807. /**
  30808. * Detach the current controls from the specified dom element.
  30809. * @param element Defines the element to stop listening the inputs from
  30810. */
  30811. detachControl(element: HTMLElement): void;
  30812. /**
  30813. * Update the camera state according to the different inputs gathered during the frame.
  30814. */
  30815. update(): void;
  30816. /** @hidden */
  30817. _checkInputs(): void;
  30818. /** @hidden */
  30819. get rigCameras(): Camera[];
  30820. /**
  30821. * Gets the post process used by the rig cameras
  30822. */
  30823. get rigPostProcess(): Nullable<PostProcess>;
  30824. /**
  30825. * Internal, gets the first post proces.
  30826. * @returns the first post process to be run on this camera.
  30827. */
  30828. _getFirstPostProcess(): Nullable<PostProcess>;
  30829. private _cascadePostProcessesToRigCams;
  30830. /**
  30831. * Attach a post process to the camera.
  30832. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30833. * @param postProcess The post process to attach to the camera
  30834. * @param insertAt The position of the post process in case several of them are in use in the scene
  30835. * @returns the position the post process has been inserted at
  30836. */
  30837. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  30838. /**
  30839. * Detach a post process to the camera.
  30840. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  30841. * @param postProcess The post process to detach from the camera
  30842. */
  30843. detachPostProcess(postProcess: PostProcess): void;
  30844. /**
  30845. * Gets the current world matrix of the camera
  30846. */
  30847. getWorldMatrix(): Matrix;
  30848. /** @hidden */
  30849. _getViewMatrix(): Matrix;
  30850. /**
  30851. * Gets the current view matrix of the camera.
  30852. * @param force forces the camera to recompute the matrix without looking at the cached state
  30853. * @returns the view matrix
  30854. */
  30855. getViewMatrix(force?: boolean): Matrix;
  30856. /**
  30857. * Freeze the projection matrix.
  30858. * It will prevent the cache check of the camera projection compute and can speed up perf
  30859. * if no parameter of the camera are meant to change
  30860. * @param projection Defines manually a projection if necessary
  30861. */
  30862. freezeProjectionMatrix(projection?: Matrix): void;
  30863. /**
  30864. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  30865. */
  30866. unfreezeProjectionMatrix(): void;
  30867. /**
  30868. * Gets the current projection matrix of the camera.
  30869. * @param force forces the camera to recompute the matrix without looking at the cached state
  30870. * @returns the projection matrix
  30871. */
  30872. getProjectionMatrix(force?: boolean): Matrix;
  30873. /**
  30874. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  30875. * @returns a Matrix
  30876. */
  30877. getTransformationMatrix(): Matrix;
  30878. private _updateFrustumPlanes;
  30879. /**
  30880. * Checks if a cullable object (mesh...) is in the camera frustum
  30881. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  30882. * @param target The object to check
  30883. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  30884. * @returns true if the object is in frustum otherwise false
  30885. */
  30886. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  30887. /**
  30888. * Checks if a cullable object (mesh...) is in the camera frustum
  30889. * Unlike isInFrustum this cheks the full bounding box
  30890. * @param target The object to check
  30891. * @returns true if the object is in frustum otherwise false
  30892. */
  30893. isCompletelyInFrustum(target: ICullable): boolean;
  30894. /**
  30895. * Gets a ray in the forward direction from the camera.
  30896. * @param length Defines the length of the ray to create
  30897. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30898. * @param origin Defines the start point of the ray which defaults to the camera position
  30899. * @returns the forward ray
  30900. */
  30901. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30902. /**
  30903. * Gets a ray in the forward direction from the camera.
  30904. * @param refRay the ray to (re)use when setting the values
  30905. * @param length Defines the length of the ray to create
  30906. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  30907. * @param origin Defines the start point of the ray which defaults to the camera position
  30908. * @returns the forward ray
  30909. */
  30910. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  30911. /**
  30912. * Releases resources associated with this node.
  30913. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  30914. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  30915. */
  30916. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  30917. /** @hidden */
  30918. _isLeftCamera: boolean;
  30919. /**
  30920. * Gets the left camera of a rig setup in case of Rigged Camera
  30921. */
  30922. get isLeftCamera(): boolean;
  30923. /** @hidden */
  30924. _isRightCamera: boolean;
  30925. /**
  30926. * Gets the right camera of a rig setup in case of Rigged Camera
  30927. */
  30928. get isRightCamera(): boolean;
  30929. /**
  30930. * Gets the left camera of a rig setup in case of Rigged Camera
  30931. */
  30932. get leftCamera(): Nullable<FreeCamera>;
  30933. /**
  30934. * Gets the right camera of a rig setup in case of Rigged Camera
  30935. */
  30936. get rightCamera(): Nullable<FreeCamera>;
  30937. /**
  30938. * Gets the left camera target of a rig setup in case of Rigged Camera
  30939. * @returns the target position
  30940. */
  30941. getLeftTarget(): Nullable<Vector3>;
  30942. /**
  30943. * Gets the right camera target of a rig setup in case of Rigged Camera
  30944. * @returns the target position
  30945. */
  30946. getRightTarget(): Nullable<Vector3>;
  30947. /**
  30948. * @hidden
  30949. */
  30950. setCameraRigMode(mode: number, rigParams: any): void;
  30951. /** @hidden */
  30952. static _setStereoscopicRigMode(camera: Camera): void;
  30953. /** @hidden */
  30954. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  30955. /** @hidden */
  30956. static _setVRRigMode(camera: Camera, rigParams: any): void;
  30957. /** @hidden */
  30958. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  30959. /** @hidden */
  30960. _getVRProjectionMatrix(): Matrix;
  30961. protected _updateCameraRotationMatrix(): void;
  30962. protected _updateWebVRCameraRotationMatrix(): void;
  30963. /**
  30964. * This function MUST be overwritten by the different WebVR cameras available.
  30965. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30966. * @hidden
  30967. */
  30968. _getWebVRProjectionMatrix(): Matrix;
  30969. /**
  30970. * This function MUST be overwritten by the different WebVR cameras available.
  30971. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  30972. * @hidden
  30973. */
  30974. _getWebVRViewMatrix(): Matrix;
  30975. /** @hidden */
  30976. setCameraRigParameter(name: string, value: any): void;
  30977. /**
  30978. * needs to be overridden by children so sub has required properties to be copied
  30979. * @hidden
  30980. */
  30981. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  30982. /**
  30983. * May need to be overridden by children
  30984. * @hidden
  30985. */
  30986. _updateRigCameras(): void;
  30987. /** @hidden */
  30988. _setupInputs(): void;
  30989. /**
  30990. * Serialiaze the camera setup to a json represention
  30991. * @returns the JSON representation
  30992. */
  30993. serialize(): any;
  30994. /**
  30995. * Clones the current camera.
  30996. * @param name The cloned camera name
  30997. * @returns the cloned camera
  30998. */
  30999. clone(name: string): Camera;
  31000. /**
  31001. * Gets the direction of the camera relative to a given local axis.
  31002. * @param localAxis Defines the reference axis to provide a relative direction.
  31003. * @return the direction
  31004. */
  31005. getDirection(localAxis: Vector3): Vector3;
  31006. /**
  31007. * Returns the current camera absolute rotation
  31008. */
  31009. get absoluteRotation(): Quaternion;
  31010. /**
  31011. * Gets the direction of the camera relative to a given local axis into a passed vector.
  31012. * @param localAxis Defines the reference axis to provide a relative direction.
  31013. * @param result Defines the vector to store the result in
  31014. */
  31015. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  31016. /**
  31017. * Gets a camera constructor for a given camera type
  31018. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  31019. * @param name The name of the camera the result will be able to instantiate
  31020. * @param scene The scene the result will construct the camera in
  31021. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  31022. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  31023. * @returns a factory method to construc the camera
  31024. */
  31025. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  31026. /**
  31027. * Compute the world matrix of the camera.
  31028. * @returns the camera world matrix
  31029. */
  31030. computeWorldMatrix(): Matrix;
  31031. /**
  31032. * Parse a JSON and creates the camera from the parsed information
  31033. * @param parsedCamera The JSON to parse
  31034. * @param scene The scene to instantiate the camera in
  31035. * @returns the newly constructed camera
  31036. */
  31037. static Parse(parsedCamera: any, scene: Scene): Camera;
  31038. }
  31039. }
  31040. declare module "babylonjs/Meshes/Builders/discBuilder" {
  31041. import { Nullable } from "babylonjs/types";
  31042. import { Scene } from "babylonjs/scene";
  31043. import { Vector4 } from "babylonjs/Maths/math.vector";
  31044. import { Mesh } from "babylonjs/Meshes/mesh";
  31045. /**
  31046. * Class containing static functions to help procedurally build meshes
  31047. */
  31048. export class DiscBuilder {
  31049. /**
  31050. * Creates a plane polygonal mesh. By default, this is a disc
  31051. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  31052. * * 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
  31053. * * 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
  31054. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  31055. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  31056. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  31057. * @param name defines the name of the mesh
  31058. * @param options defines the options used to create the mesh
  31059. * @param scene defines the hosting scene
  31060. * @returns the plane polygonal mesh
  31061. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  31062. */
  31063. static CreateDisc(name: string, options: {
  31064. radius?: number;
  31065. tessellation?: number;
  31066. arc?: number;
  31067. updatable?: boolean;
  31068. sideOrientation?: number;
  31069. frontUVs?: Vector4;
  31070. backUVs?: Vector4;
  31071. }, scene?: Nullable<Scene>): Mesh;
  31072. }
  31073. }
  31074. declare module "babylonjs/Materials/fresnelParameters" {
  31075. import { DeepImmutable } from "babylonjs/types";
  31076. import { Color3 } from "babylonjs/Maths/math.color";
  31077. /**
  31078. * Options to be used when creating a FresnelParameters.
  31079. */
  31080. export type IFresnelParametersCreationOptions = {
  31081. /**
  31082. * Define the color used on edges (grazing angle)
  31083. */
  31084. leftColor?: Color3;
  31085. /**
  31086. * Define the color used on center
  31087. */
  31088. rightColor?: Color3;
  31089. /**
  31090. * Define bias applied to computed fresnel term
  31091. */
  31092. bias?: number;
  31093. /**
  31094. * Defined the power exponent applied to fresnel term
  31095. */
  31096. power?: number;
  31097. /**
  31098. * Define if the fresnel effect is enable or not.
  31099. */
  31100. isEnabled?: boolean;
  31101. };
  31102. /**
  31103. * Serialized format for FresnelParameters.
  31104. */
  31105. export type IFresnelParametersSerialized = {
  31106. /**
  31107. * Define the color used on edges (grazing angle) [as an array]
  31108. */
  31109. leftColor: number[];
  31110. /**
  31111. * Define the color used on center [as an array]
  31112. */
  31113. rightColor: number[];
  31114. /**
  31115. * Define bias applied to computed fresnel term
  31116. */
  31117. bias: number;
  31118. /**
  31119. * Defined the power exponent applied to fresnel term
  31120. */
  31121. power?: number;
  31122. /**
  31123. * Define if the fresnel effect is enable or not.
  31124. */
  31125. isEnabled: boolean;
  31126. };
  31127. /**
  31128. * This represents all the required information to add a fresnel effect on a material:
  31129. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31130. */
  31131. export class FresnelParameters {
  31132. private _isEnabled;
  31133. /**
  31134. * Define if the fresnel effect is enable or not.
  31135. */
  31136. get isEnabled(): boolean;
  31137. set isEnabled(value: boolean);
  31138. /**
  31139. * Define the color used on edges (grazing angle)
  31140. */
  31141. leftColor: Color3;
  31142. /**
  31143. * Define the color used on center
  31144. */
  31145. rightColor: Color3;
  31146. /**
  31147. * Define bias applied to computed fresnel term
  31148. */
  31149. bias: number;
  31150. /**
  31151. * Defined the power exponent applied to fresnel term
  31152. */
  31153. power: number;
  31154. /**
  31155. * Creates a new FresnelParameters object.
  31156. *
  31157. * @param options provide your own settings to optionally to override defaults
  31158. */
  31159. constructor(options?: IFresnelParametersCreationOptions);
  31160. /**
  31161. * Clones the current fresnel and its valuues
  31162. * @returns a clone fresnel configuration
  31163. */
  31164. clone(): FresnelParameters;
  31165. /**
  31166. * Determines equality between FresnelParameters objects
  31167. * @param otherFresnelParameters defines the second operand
  31168. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  31169. */
  31170. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  31171. /**
  31172. * Serializes the current fresnel parameters to a JSON representation.
  31173. * @return the JSON serialization
  31174. */
  31175. serialize(): IFresnelParametersSerialized;
  31176. /**
  31177. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  31178. * @param parsedFresnelParameters Define the JSON representation
  31179. * @returns the parsed parameters
  31180. */
  31181. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  31182. }
  31183. }
  31184. declare module "babylonjs/Materials/materialFlags" {
  31185. /**
  31186. * This groups all the flags used to control the materials channel.
  31187. */
  31188. export class MaterialFlags {
  31189. private static _DiffuseTextureEnabled;
  31190. /**
  31191. * Are diffuse textures enabled in the application.
  31192. */
  31193. static get DiffuseTextureEnabled(): boolean;
  31194. static set DiffuseTextureEnabled(value: boolean);
  31195. private static _DetailTextureEnabled;
  31196. /**
  31197. * Are detail textures enabled in the application.
  31198. */
  31199. static get DetailTextureEnabled(): boolean;
  31200. static set DetailTextureEnabled(value: boolean);
  31201. private static _AmbientTextureEnabled;
  31202. /**
  31203. * Are ambient textures enabled in the application.
  31204. */
  31205. static get AmbientTextureEnabled(): boolean;
  31206. static set AmbientTextureEnabled(value: boolean);
  31207. private static _OpacityTextureEnabled;
  31208. /**
  31209. * Are opacity textures enabled in the application.
  31210. */
  31211. static get OpacityTextureEnabled(): boolean;
  31212. static set OpacityTextureEnabled(value: boolean);
  31213. private static _ReflectionTextureEnabled;
  31214. /**
  31215. * Are reflection textures enabled in the application.
  31216. */
  31217. static get ReflectionTextureEnabled(): boolean;
  31218. static set ReflectionTextureEnabled(value: boolean);
  31219. private static _EmissiveTextureEnabled;
  31220. /**
  31221. * Are emissive textures enabled in the application.
  31222. */
  31223. static get EmissiveTextureEnabled(): boolean;
  31224. static set EmissiveTextureEnabled(value: boolean);
  31225. private static _SpecularTextureEnabled;
  31226. /**
  31227. * Are specular textures enabled in the application.
  31228. */
  31229. static get SpecularTextureEnabled(): boolean;
  31230. static set SpecularTextureEnabled(value: boolean);
  31231. private static _BumpTextureEnabled;
  31232. /**
  31233. * Are bump textures enabled in the application.
  31234. */
  31235. static get BumpTextureEnabled(): boolean;
  31236. static set BumpTextureEnabled(value: boolean);
  31237. private static _LightmapTextureEnabled;
  31238. /**
  31239. * Are lightmap textures enabled in the application.
  31240. */
  31241. static get LightmapTextureEnabled(): boolean;
  31242. static set LightmapTextureEnabled(value: boolean);
  31243. private static _RefractionTextureEnabled;
  31244. /**
  31245. * Are refraction textures enabled in the application.
  31246. */
  31247. static get RefractionTextureEnabled(): boolean;
  31248. static set RefractionTextureEnabled(value: boolean);
  31249. private static _ColorGradingTextureEnabled;
  31250. /**
  31251. * Are color grading textures enabled in the application.
  31252. */
  31253. static get ColorGradingTextureEnabled(): boolean;
  31254. static set ColorGradingTextureEnabled(value: boolean);
  31255. private static _FresnelEnabled;
  31256. /**
  31257. * Are fresnels enabled in the application.
  31258. */
  31259. static get FresnelEnabled(): boolean;
  31260. static set FresnelEnabled(value: boolean);
  31261. private static _ClearCoatTextureEnabled;
  31262. /**
  31263. * Are clear coat textures enabled in the application.
  31264. */
  31265. static get ClearCoatTextureEnabled(): boolean;
  31266. static set ClearCoatTextureEnabled(value: boolean);
  31267. private static _ClearCoatBumpTextureEnabled;
  31268. /**
  31269. * Are clear coat bump textures enabled in the application.
  31270. */
  31271. static get ClearCoatBumpTextureEnabled(): boolean;
  31272. static set ClearCoatBumpTextureEnabled(value: boolean);
  31273. private static _ClearCoatTintTextureEnabled;
  31274. /**
  31275. * Are clear coat tint textures enabled in the application.
  31276. */
  31277. static get ClearCoatTintTextureEnabled(): boolean;
  31278. static set ClearCoatTintTextureEnabled(value: boolean);
  31279. private static _SheenTextureEnabled;
  31280. /**
  31281. * Are sheen textures enabled in the application.
  31282. */
  31283. static get SheenTextureEnabled(): boolean;
  31284. static set SheenTextureEnabled(value: boolean);
  31285. private static _AnisotropicTextureEnabled;
  31286. /**
  31287. * Are anisotropic textures enabled in the application.
  31288. */
  31289. static get AnisotropicTextureEnabled(): boolean;
  31290. static set AnisotropicTextureEnabled(value: boolean);
  31291. private static _ThicknessTextureEnabled;
  31292. /**
  31293. * Are thickness textures enabled in the application.
  31294. */
  31295. static get ThicknessTextureEnabled(): boolean;
  31296. static set ThicknessTextureEnabled(value: boolean);
  31297. }
  31298. }
  31299. declare module "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration" {
  31300. /** @hidden */
  31301. export var defaultFragmentDeclaration: {
  31302. name: string;
  31303. shader: string;
  31304. };
  31305. }
  31306. declare module "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration" {
  31307. /** @hidden */
  31308. export var defaultUboDeclaration: {
  31309. name: string;
  31310. shader: string;
  31311. };
  31312. }
  31313. declare module "babylonjs/Shaders/ShadersInclude/prePassDeclaration" {
  31314. /** @hidden */
  31315. export var prePassDeclaration: {
  31316. name: string;
  31317. shader: string;
  31318. };
  31319. }
  31320. declare module "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration" {
  31321. /** @hidden */
  31322. export var lightFragmentDeclaration: {
  31323. name: string;
  31324. shader: string;
  31325. };
  31326. }
  31327. declare module "babylonjs/Shaders/ShadersInclude/lightUboDeclaration" {
  31328. /** @hidden */
  31329. export var lightUboDeclaration: {
  31330. name: string;
  31331. shader: string;
  31332. };
  31333. }
  31334. declare module "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions" {
  31335. /** @hidden */
  31336. export var lightsFragmentFunctions: {
  31337. name: string;
  31338. shader: string;
  31339. };
  31340. }
  31341. declare module "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions" {
  31342. /** @hidden */
  31343. export var shadowsFragmentFunctions: {
  31344. name: string;
  31345. shader: string;
  31346. };
  31347. }
  31348. declare module "babylonjs/Shaders/ShadersInclude/fresnelFunction" {
  31349. /** @hidden */
  31350. export var fresnelFunction: {
  31351. name: string;
  31352. shader: string;
  31353. };
  31354. }
  31355. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions" {
  31356. /** @hidden */
  31357. export var bumpFragmentMainFunctions: {
  31358. name: string;
  31359. shader: string;
  31360. };
  31361. }
  31362. declare module "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions" {
  31363. /** @hidden */
  31364. export var bumpFragmentFunctions: {
  31365. name: string;
  31366. shader: string;
  31367. };
  31368. }
  31369. declare module "babylonjs/Shaders/ShadersInclude/logDepthDeclaration" {
  31370. /** @hidden */
  31371. export var logDepthDeclaration: {
  31372. name: string;
  31373. shader: string;
  31374. };
  31375. }
  31376. declare module "babylonjs/Shaders/ShadersInclude/bumpFragment" {
  31377. /** @hidden */
  31378. export var bumpFragment: {
  31379. name: string;
  31380. shader: string;
  31381. };
  31382. }
  31383. declare module "babylonjs/Shaders/ShadersInclude/depthPrePass" {
  31384. /** @hidden */
  31385. export var depthPrePass: {
  31386. name: string;
  31387. shader: string;
  31388. };
  31389. }
  31390. declare module "babylonjs/Shaders/ShadersInclude/lightFragment" {
  31391. /** @hidden */
  31392. export var lightFragment: {
  31393. name: string;
  31394. shader: string;
  31395. };
  31396. }
  31397. declare module "babylonjs/Shaders/ShadersInclude/logDepthFragment" {
  31398. /** @hidden */
  31399. export var logDepthFragment: {
  31400. name: string;
  31401. shader: string;
  31402. };
  31403. }
  31404. declare module "babylonjs/Shaders/default.fragment" {
  31405. import "babylonjs/Shaders/ShadersInclude/defaultFragmentDeclaration";
  31406. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31407. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  31408. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31409. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31410. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31411. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  31412. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  31413. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  31414. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  31415. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  31416. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  31417. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  31418. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  31419. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  31420. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31421. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  31422. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  31423. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  31424. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  31425. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  31426. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  31427. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  31428. /** @hidden */
  31429. export var defaultPixelShader: {
  31430. name: string;
  31431. shader: string;
  31432. };
  31433. }
  31434. declare module "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration" {
  31435. /** @hidden */
  31436. export var defaultVertexDeclaration: {
  31437. name: string;
  31438. shader: string;
  31439. };
  31440. }
  31441. declare module "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration" {
  31442. /** @hidden */
  31443. export var prePassVertexDeclaration: {
  31444. name: string;
  31445. shader: string;
  31446. };
  31447. }
  31448. declare module "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration" {
  31449. /** @hidden */
  31450. export var bumpVertexDeclaration: {
  31451. name: string;
  31452. shader: string;
  31453. };
  31454. }
  31455. declare module "babylonjs/Shaders/ShadersInclude/prePassVertex" {
  31456. /** @hidden */
  31457. export var prePassVertex: {
  31458. name: string;
  31459. shader: string;
  31460. };
  31461. }
  31462. declare module "babylonjs/Shaders/ShadersInclude/bumpVertex" {
  31463. /** @hidden */
  31464. export var bumpVertex: {
  31465. name: string;
  31466. shader: string;
  31467. };
  31468. }
  31469. declare module "babylonjs/Shaders/ShadersInclude/fogVertex" {
  31470. /** @hidden */
  31471. export var fogVertex: {
  31472. name: string;
  31473. shader: string;
  31474. };
  31475. }
  31476. declare module "babylonjs/Shaders/ShadersInclude/shadowsVertex" {
  31477. /** @hidden */
  31478. export var shadowsVertex: {
  31479. name: string;
  31480. shader: string;
  31481. };
  31482. }
  31483. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertex" {
  31484. /** @hidden */
  31485. export var pointCloudVertex: {
  31486. name: string;
  31487. shader: string;
  31488. };
  31489. }
  31490. declare module "babylonjs/Shaders/ShadersInclude/logDepthVertex" {
  31491. /** @hidden */
  31492. export var logDepthVertex: {
  31493. name: string;
  31494. shader: string;
  31495. };
  31496. }
  31497. declare module "babylonjs/Shaders/default.vertex" {
  31498. import "babylonjs/Shaders/ShadersInclude/defaultVertexDeclaration";
  31499. import "babylonjs/Shaders/ShadersInclude/defaultUboDeclaration";
  31500. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  31501. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  31502. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  31503. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  31504. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  31505. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  31506. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  31507. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  31508. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  31509. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  31510. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  31511. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  31512. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  31513. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  31514. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  31515. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  31516. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  31517. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  31518. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  31519. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  31520. import "babylonjs/Shaders/ShadersInclude/pointCloudVertex";
  31521. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  31522. /** @hidden */
  31523. export var defaultVertexShader: {
  31524. name: string;
  31525. shader: string;
  31526. };
  31527. }
  31528. declare module "babylonjs/Materials/material.detailMapConfiguration" {
  31529. import { Nullable } from "babylonjs/types";
  31530. import { Scene } from "babylonjs/scene";
  31531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31532. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  31533. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31534. /**
  31535. * @hidden
  31536. */
  31537. export interface IMaterialDetailMapDefines {
  31538. DETAIL: boolean;
  31539. DETAILDIRECTUV: number;
  31540. DETAIL_NORMALBLENDMETHOD: number;
  31541. /** @hidden */
  31542. _areTexturesDirty: boolean;
  31543. }
  31544. /**
  31545. * Define the code related to the detail map parameters of a material
  31546. *
  31547. * Inspired from:
  31548. * 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
  31549. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  31550. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  31551. */
  31552. export class DetailMapConfiguration {
  31553. private _texture;
  31554. /**
  31555. * The detail texture of the material.
  31556. */
  31557. texture: Nullable<BaseTexture>;
  31558. /**
  31559. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  31560. * Bigger values mean stronger blending
  31561. */
  31562. diffuseBlendLevel: number;
  31563. /**
  31564. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  31565. * Bigger values mean stronger blending. Only used with PBR materials
  31566. */
  31567. roughnessBlendLevel: number;
  31568. /**
  31569. * Defines how strong the bump effect from the detail map is
  31570. * Bigger values mean stronger effect
  31571. */
  31572. bumpLevel: number;
  31573. private _normalBlendMethod;
  31574. /**
  31575. * The method used to blend the bump and detail normals together
  31576. */
  31577. normalBlendMethod: number;
  31578. private _isEnabled;
  31579. /**
  31580. * Enable or disable the detail map on this material
  31581. */
  31582. isEnabled: boolean;
  31583. /** @hidden */
  31584. private _internalMarkAllSubMeshesAsTexturesDirty;
  31585. /** @hidden */
  31586. _markAllSubMeshesAsTexturesDirty(): void;
  31587. /**
  31588. * Instantiate a new detail map
  31589. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  31590. */
  31591. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  31592. /**
  31593. * Gets whether the submesh is ready to be used or not.
  31594. * @param defines the list of "defines" to update.
  31595. * @param scene defines the scene the material belongs to.
  31596. * @returns - boolean indicating that the submesh is ready or not.
  31597. */
  31598. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  31599. /**
  31600. * Update the defines for detail map usage
  31601. * @param defines the list of "defines" to update.
  31602. * @param scene defines the scene the material belongs to.
  31603. */
  31604. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  31605. /**
  31606. * Binds the material data.
  31607. * @param uniformBuffer defines the Uniform buffer to fill in.
  31608. * @param scene defines the scene the material belongs to.
  31609. * @param isFrozen defines whether the material is frozen or not.
  31610. */
  31611. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  31612. /**
  31613. * Checks to see if a texture is used in the material.
  31614. * @param texture - Base texture to use.
  31615. * @returns - Boolean specifying if a texture is used in the material.
  31616. */
  31617. hasTexture(texture: BaseTexture): boolean;
  31618. /**
  31619. * Returns an array of the actively used textures.
  31620. * @param activeTextures Array of BaseTextures
  31621. */
  31622. getActiveTextures(activeTextures: BaseTexture[]): void;
  31623. /**
  31624. * Returns the animatable textures.
  31625. * @param animatables Array of animatable textures.
  31626. */
  31627. getAnimatables(animatables: IAnimatable[]): void;
  31628. /**
  31629. * Disposes the resources of the material.
  31630. * @param forceDisposeTextures - Forces the disposal of all textures.
  31631. */
  31632. dispose(forceDisposeTextures?: boolean): void;
  31633. /**
  31634. * Get the current class name useful for serialization or dynamic coding.
  31635. * @returns "DetailMap"
  31636. */
  31637. getClassName(): string;
  31638. /**
  31639. * Add the required uniforms to the current list.
  31640. * @param uniforms defines the current uniform list.
  31641. */
  31642. static AddUniforms(uniforms: string[]): void;
  31643. /**
  31644. * Add the required samplers to the current list.
  31645. * @param samplers defines the current sampler list.
  31646. */
  31647. static AddSamplers(samplers: string[]): void;
  31648. /**
  31649. * Add the required uniforms to the current buffer.
  31650. * @param uniformBuffer defines the current uniform buffer.
  31651. */
  31652. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  31653. /**
  31654. * Makes a duplicate of the current instance into another one.
  31655. * @param detailMap define the instance where to copy the info
  31656. */
  31657. copyTo(detailMap: DetailMapConfiguration): void;
  31658. /**
  31659. * Serializes this detail map instance
  31660. * @returns - An object with the serialized instance.
  31661. */
  31662. serialize(): any;
  31663. /**
  31664. * Parses a detail map setting from a serialized object.
  31665. * @param source - Serialized object.
  31666. * @param scene Defines the scene we are parsing for
  31667. * @param rootUrl Defines the rootUrl to load from
  31668. */
  31669. parse(source: any, scene: Scene, rootUrl: string): void;
  31670. }
  31671. }
  31672. declare module "babylonjs/Materials/standardMaterial" {
  31673. import { SmartArray } from "babylonjs/Misc/smartArray";
  31674. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  31675. import { Nullable } from "babylonjs/types";
  31676. import { Scene } from "babylonjs/scene";
  31677. import { Matrix } from "babylonjs/Maths/math.vector";
  31678. import { Color3 } from "babylonjs/Maths/math.color";
  31679. import { SubMesh } from "babylonjs/Meshes/subMesh";
  31680. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  31681. import { Mesh } from "babylonjs/Meshes/mesh";
  31682. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  31683. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  31684. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  31685. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  31686. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  31687. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  31688. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  31689. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  31690. import "babylonjs/Shaders/default.fragment";
  31691. import "babylonjs/Shaders/default.vertex";
  31692. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  31693. /** @hidden */
  31694. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  31695. MAINUV1: boolean;
  31696. MAINUV2: boolean;
  31697. DIFFUSE: boolean;
  31698. DIFFUSEDIRECTUV: number;
  31699. DETAIL: boolean;
  31700. DETAILDIRECTUV: number;
  31701. DETAIL_NORMALBLENDMETHOD: number;
  31702. AMBIENT: boolean;
  31703. AMBIENTDIRECTUV: number;
  31704. OPACITY: boolean;
  31705. OPACITYDIRECTUV: number;
  31706. OPACITYRGB: boolean;
  31707. REFLECTION: boolean;
  31708. EMISSIVE: boolean;
  31709. EMISSIVEDIRECTUV: number;
  31710. SPECULAR: boolean;
  31711. SPECULARDIRECTUV: number;
  31712. BUMP: boolean;
  31713. BUMPDIRECTUV: number;
  31714. PARALLAX: boolean;
  31715. PARALLAXOCCLUSION: boolean;
  31716. SPECULAROVERALPHA: boolean;
  31717. CLIPPLANE: boolean;
  31718. CLIPPLANE2: boolean;
  31719. CLIPPLANE3: boolean;
  31720. CLIPPLANE4: boolean;
  31721. CLIPPLANE5: boolean;
  31722. CLIPPLANE6: boolean;
  31723. ALPHATEST: boolean;
  31724. DEPTHPREPASS: boolean;
  31725. ALPHAFROMDIFFUSE: boolean;
  31726. POINTSIZE: boolean;
  31727. FOG: boolean;
  31728. SPECULARTERM: boolean;
  31729. DIFFUSEFRESNEL: boolean;
  31730. OPACITYFRESNEL: boolean;
  31731. REFLECTIONFRESNEL: boolean;
  31732. REFRACTIONFRESNEL: boolean;
  31733. EMISSIVEFRESNEL: boolean;
  31734. FRESNEL: boolean;
  31735. NORMAL: boolean;
  31736. UV1: boolean;
  31737. UV2: boolean;
  31738. VERTEXCOLOR: boolean;
  31739. VERTEXALPHA: boolean;
  31740. NUM_BONE_INFLUENCERS: number;
  31741. BonesPerMesh: number;
  31742. BONETEXTURE: boolean;
  31743. BONES_VELOCITY_ENABLED: boolean;
  31744. INSTANCES: boolean;
  31745. THIN_INSTANCES: boolean;
  31746. GLOSSINESS: boolean;
  31747. ROUGHNESS: boolean;
  31748. EMISSIVEASILLUMINATION: boolean;
  31749. LINKEMISSIVEWITHDIFFUSE: boolean;
  31750. REFLECTIONFRESNELFROMSPECULAR: boolean;
  31751. LIGHTMAP: boolean;
  31752. LIGHTMAPDIRECTUV: number;
  31753. OBJECTSPACE_NORMALMAP: boolean;
  31754. USELIGHTMAPASSHADOWMAP: boolean;
  31755. REFLECTIONMAP_3D: boolean;
  31756. REFLECTIONMAP_SPHERICAL: boolean;
  31757. REFLECTIONMAP_PLANAR: boolean;
  31758. REFLECTIONMAP_CUBIC: boolean;
  31759. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  31760. REFLECTIONMAP_PROJECTION: boolean;
  31761. REFLECTIONMAP_SKYBOX: boolean;
  31762. REFLECTIONMAP_EXPLICIT: boolean;
  31763. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  31764. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  31765. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  31766. INVERTCUBICMAP: boolean;
  31767. LOGARITHMICDEPTH: boolean;
  31768. REFRACTION: boolean;
  31769. REFRACTIONMAP_3D: boolean;
  31770. REFLECTIONOVERALPHA: boolean;
  31771. TWOSIDEDLIGHTING: boolean;
  31772. SHADOWFLOAT: boolean;
  31773. MORPHTARGETS: boolean;
  31774. MORPHTARGETS_NORMAL: boolean;
  31775. MORPHTARGETS_TANGENT: boolean;
  31776. MORPHTARGETS_UV: boolean;
  31777. NUM_MORPH_INFLUENCERS: number;
  31778. NONUNIFORMSCALING: boolean;
  31779. PREMULTIPLYALPHA: boolean;
  31780. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  31781. ALPHABLEND: boolean;
  31782. PREPASS: boolean;
  31783. PREPASS_IRRADIANCE: boolean;
  31784. PREPASS_IRRADIANCE_INDEX: number;
  31785. PREPASS_ALBEDO: boolean;
  31786. PREPASS_ALBEDO_INDEX: number;
  31787. PREPASS_DEPTHNORMAL: boolean;
  31788. PREPASS_DEPTHNORMAL_INDEX: number;
  31789. PREPASS_POSITION: boolean;
  31790. PREPASS_POSITION_INDEX: number;
  31791. PREPASS_VELOCITY: boolean;
  31792. PREPASS_VELOCITY_INDEX: number;
  31793. PREPASS_REFLECTIVITY: boolean;
  31794. PREPASS_REFLECTIVITY_INDEX: number;
  31795. SCENE_MRT_COUNT: number;
  31796. RGBDLIGHTMAP: boolean;
  31797. RGBDREFLECTION: boolean;
  31798. RGBDREFRACTION: boolean;
  31799. IMAGEPROCESSING: boolean;
  31800. VIGNETTE: boolean;
  31801. VIGNETTEBLENDMODEMULTIPLY: boolean;
  31802. VIGNETTEBLENDMODEOPAQUE: boolean;
  31803. TONEMAPPING: boolean;
  31804. TONEMAPPING_ACES: boolean;
  31805. CONTRAST: boolean;
  31806. COLORCURVES: boolean;
  31807. COLORGRADING: boolean;
  31808. COLORGRADING3D: boolean;
  31809. SAMPLER3DGREENDEPTH: boolean;
  31810. SAMPLER3DBGRMAP: boolean;
  31811. IMAGEPROCESSINGPOSTPROCESS: boolean;
  31812. MULTIVIEW: boolean;
  31813. /**
  31814. * If the reflection texture on this material is in linear color space
  31815. * @hidden
  31816. */
  31817. IS_REFLECTION_LINEAR: boolean;
  31818. /**
  31819. * If the refraction texture on this material is in linear color space
  31820. * @hidden
  31821. */
  31822. IS_REFRACTION_LINEAR: boolean;
  31823. EXPOSURE: boolean;
  31824. constructor();
  31825. setReflectionMode(modeToEnable: string): void;
  31826. }
  31827. /**
  31828. * This is the default material used in Babylon. It is the best trade off between quality
  31829. * and performances.
  31830. * @see https://doc.babylonjs.com/babylon101/materials
  31831. */
  31832. export class StandardMaterial extends PushMaterial {
  31833. private _diffuseTexture;
  31834. /**
  31835. * The basic texture of the material as viewed under a light.
  31836. */
  31837. diffuseTexture: Nullable<BaseTexture>;
  31838. private _ambientTexture;
  31839. /**
  31840. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  31841. */
  31842. ambientTexture: Nullable<BaseTexture>;
  31843. private _opacityTexture;
  31844. /**
  31845. * Define the transparency of the material from a texture.
  31846. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  31847. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  31848. */
  31849. opacityTexture: Nullable<BaseTexture>;
  31850. private _reflectionTexture;
  31851. /**
  31852. * Define the texture used to display the reflection.
  31853. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31854. */
  31855. reflectionTexture: Nullable<BaseTexture>;
  31856. private _emissiveTexture;
  31857. /**
  31858. * Define texture of the material as if self lit.
  31859. * This will be mixed in the final result even in the absence of light.
  31860. */
  31861. emissiveTexture: Nullable<BaseTexture>;
  31862. private _specularTexture;
  31863. /**
  31864. * Define how the color and intensity of the highlight given by the light in the material.
  31865. */
  31866. specularTexture: Nullable<BaseTexture>;
  31867. private _bumpTexture;
  31868. /**
  31869. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  31870. * 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.
  31871. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  31872. */
  31873. bumpTexture: Nullable<BaseTexture>;
  31874. private _lightmapTexture;
  31875. /**
  31876. * Complex lighting can be computationally expensive to compute at runtime.
  31877. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  31878. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  31879. */
  31880. lightmapTexture: Nullable<BaseTexture>;
  31881. private _refractionTexture;
  31882. /**
  31883. * Define the texture used to display the refraction.
  31884. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31885. */
  31886. refractionTexture: Nullable<BaseTexture>;
  31887. /**
  31888. * The color of the material lit by the environmental background lighting.
  31889. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  31890. */
  31891. ambientColor: Color3;
  31892. /**
  31893. * The basic color of the material as viewed under a light.
  31894. */
  31895. diffuseColor: Color3;
  31896. /**
  31897. * Define how the color and intensity of the highlight given by the light in the material.
  31898. */
  31899. specularColor: Color3;
  31900. /**
  31901. * Define the color of the material as if self lit.
  31902. * This will be mixed in the final result even in the absence of light.
  31903. */
  31904. emissiveColor: Color3;
  31905. /**
  31906. * Defines how sharp are the highlights in the material.
  31907. * The bigger the value the sharper giving a more glossy feeling to the result.
  31908. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  31909. */
  31910. specularPower: number;
  31911. private _useAlphaFromDiffuseTexture;
  31912. /**
  31913. * Does the transparency come from the diffuse texture alpha channel.
  31914. */
  31915. useAlphaFromDiffuseTexture: boolean;
  31916. private _useEmissiveAsIllumination;
  31917. /**
  31918. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  31919. */
  31920. useEmissiveAsIllumination: boolean;
  31921. private _linkEmissiveWithDiffuse;
  31922. /**
  31923. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  31924. * the emissive level when the final color is close to one.
  31925. */
  31926. linkEmissiveWithDiffuse: boolean;
  31927. private _useSpecularOverAlpha;
  31928. /**
  31929. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  31930. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  31931. */
  31932. useSpecularOverAlpha: boolean;
  31933. private _useReflectionOverAlpha;
  31934. /**
  31935. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  31936. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  31937. */
  31938. useReflectionOverAlpha: boolean;
  31939. private _disableLighting;
  31940. /**
  31941. * Does lights from the scene impacts this material.
  31942. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  31943. */
  31944. disableLighting: boolean;
  31945. private _useObjectSpaceNormalMap;
  31946. /**
  31947. * Allows using an object space normal map (instead of tangent space).
  31948. */
  31949. useObjectSpaceNormalMap: boolean;
  31950. private _useParallax;
  31951. /**
  31952. * Is parallax enabled or not.
  31953. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31954. */
  31955. useParallax: boolean;
  31956. private _useParallaxOcclusion;
  31957. /**
  31958. * Is parallax occlusion enabled or not.
  31959. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  31960. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  31961. */
  31962. useParallaxOcclusion: boolean;
  31963. /**
  31964. * 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.
  31965. */
  31966. parallaxScaleBias: number;
  31967. private _roughness;
  31968. /**
  31969. * Helps to define how blurry the reflections should appears in the material.
  31970. */
  31971. roughness: number;
  31972. /**
  31973. * In case of refraction, define the value of the index of refraction.
  31974. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31975. */
  31976. indexOfRefraction: number;
  31977. /**
  31978. * Invert the refraction texture alongside the y axis.
  31979. * It can be useful with procedural textures or probe for instance.
  31980. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  31981. */
  31982. invertRefractionY: boolean;
  31983. /**
  31984. * Defines the alpha limits in alpha test mode.
  31985. */
  31986. alphaCutOff: number;
  31987. private _useLightmapAsShadowmap;
  31988. /**
  31989. * In case of light mapping, define whether the map contains light or shadow informations.
  31990. */
  31991. useLightmapAsShadowmap: boolean;
  31992. private _diffuseFresnelParameters;
  31993. /**
  31994. * Define the diffuse fresnel parameters of the material.
  31995. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  31996. */
  31997. diffuseFresnelParameters: FresnelParameters;
  31998. private _opacityFresnelParameters;
  31999. /**
  32000. * Define the opacity fresnel parameters of the material.
  32001. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32002. */
  32003. opacityFresnelParameters: FresnelParameters;
  32004. private _reflectionFresnelParameters;
  32005. /**
  32006. * Define the reflection fresnel parameters of the material.
  32007. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32008. */
  32009. reflectionFresnelParameters: FresnelParameters;
  32010. private _refractionFresnelParameters;
  32011. /**
  32012. * Define the refraction fresnel parameters of the material.
  32013. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32014. */
  32015. refractionFresnelParameters: FresnelParameters;
  32016. private _emissiveFresnelParameters;
  32017. /**
  32018. * Define the emissive fresnel parameters of the material.
  32019. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32020. */
  32021. emissiveFresnelParameters: FresnelParameters;
  32022. private _useReflectionFresnelFromSpecular;
  32023. /**
  32024. * If true automatically deducts the fresnels values from the material specularity.
  32025. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  32026. */
  32027. useReflectionFresnelFromSpecular: boolean;
  32028. private _useGlossinessFromSpecularMapAlpha;
  32029. /**
  32030. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  32031. */
  32032. useGlossinessFromSpecularMapAlpha: boolean;
  32033. private _maxSimultaneousLights;
  32034. /**
  32035. * Defines the maximum number of lights that can be used in the material
  32036. */
  32037. maxSimultaneousLights: number;
  32038. private _invertNormalMapX;
  32039. /**
  32040. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  32041. */
  32042. invertNormalMapX: boolean;
  32043. private _invertNormalMapY;
  32044. /**
  32045. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  32046. */
  32047. invertNormalMapY: boolean;
  32048. private _twoSidedLighting;
  32049. /**
  32050. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  32051. */
  32052. twoSidedLighting: boolean;
  32053. /**
  32054. * Default configuration related to image processing available in the standard Material.
  32055. */
  32056. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  32057. /**
  32058. * Gets the image processing configuration used either in this material.
  32059. */
  32060. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  32061. /**
  32062. * Sets the Default image processing configuration used either in the this material.
  32063. *
  32064. * If sets to null, the scene one is in use.
  32065. */
  32066. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  32067. /**
  32068. * Keep track of the image processing observer to allow dispose and replace.
  32069. */
  32070. private _imageProcessingObserver;
  32071. /**
  32072. * Attaches a new image processing configuration to the Standard Material.
  32073. * @param configuration
  32074. */
  32075. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  32076. /**
  32077. * Defines additionnal PrePass parameters for the material.
  32078. */
  32079. readonly prePassConfiguration: PrePassConfiguration;
  32080. /**
  32081. * Gets wether the color curves effect is enabled.
  32082. */
  32083. get cameraColorCurvesEnabled(): boolean;
  32084. /**
  32085. * Sets wether the color curves effect is enabled.
  32086. */
  32087. set cameraColorCurvesEnabled(value: boolean);
  32088. /**
  32089. * Gets wether the color grading effect is enabled.
  32090. */
  32091. get cameraColorGradingEnabled(): boolean;
  32092. /**
  32093. * Gets wether the color grading effect is enabled.
  32094. */
  32095. set cameraColorGradingEnabled(value: boolean);
  32096. /**
  32097. * Gets wether tonemapping is enabled or not.
  32098. */
  32099. get cameraToneMappingEnabled(): boolean;
  32100. /**
  32101. * Sets wether tonemapping is enabled or not
  32102. */
  32103. set cameraToneMappingEnabled(value: boolean);
  32104. /**
  32105. * The camera exposure used on this material.
  32106. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32107. * This corresponds to a photographic exposure.
  32108. */
  32109. get cameraExposure(): number;
  32110. /**
  32111. * The camera exposure used on this material.
  32112. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  32113. * This corresponds to a photographic exposure.
  32114. */
  32115. set cameraExposure(value: number);
  32116. /**
  32117. * Gets The camera contrast used on this material.
  32118. */
  32119. get cameraContrast(): number;
  32120. /**
  32121. * Sets The camera contrast used on this material.
  32122. */
  32123. set cameraContrast(value: number);
  32124. /**
  32125. * Gets the Color Grading 2D Lookup Texture.
  32126. */
  32127. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  32128. /**
  32129. * Sets the Color Grading 2D Lookup Texture.
  32130. */
  32131. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  32132. /**
  32133. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32134. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32135. * 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;
  32136. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32137. */
  32138. get cameraColorCurves(): Nullable<ColorCurves>;
  32139. /**
  32140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  32141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  32142. * 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;
  32143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  32144. */
  32145. set cameraColorCurves(value: Nullable<ColorCurves>);
  32146. /**
  32147. * Can this material render to several textures at once
  32148. */
  32149. get canRenderToMRT(): boolean;
  32150. /**
  32151. * Defines the detail map parameters for the material.
  32152. */
  32153. readonly detailMap: DetailMapConfiguration;
  32154. protected _renderTargets: SmartArray<RenderTargetTexture>;
  32155. protected _worldViewProjectionMatrix: Matrix;
  32156. protected _globalAmbientColor: Color3;
  32157. protected _useLogarithmicDepth: boolean;
  32158. protected _rebuildInParallel: boolean;
  32159. /**
  32160. * Instantiates a new standard material.
  32161. * This is the default material used in Babylon. It is the best trade off between quality
  32162. * and performances.
  32163. * @see https://doc.babylonjs.com/babylon101/materials
  32164. * @param name Define the name of the material in the scene
  32165. * @param scene Define the scene the material belong to
  32166. */
  32167. constructor(name: string, scene: Scene);
  32168. /**
  32169. * Gets a boolean indicating that current material needs to register RTT
  32170. */
  32171. get hasRenderTargetTextures(): boolean;
  32172. /**
  32173. * Gets the current class name of the material e.g. "StandardMaterial"
  32174. * Mainly use in serialization.
  32175. * @returns the class name
  32176. */
  32177. getClassName(): string;
  32178. /**
  32179. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  32180. * You can try switching to logarithmic depth.
  32181. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  32182. */
  32183. get useLogarithmicDepth(): boolean;
  32184. set useLogarithmicDepth(value: boolean);
  32185. /**
  32186. * Specifies if the material will require alpha blending
  32187. * @returns a boolean specifying if alpha blending is needed
  32188. */
  32189. needAlphaBlending(): boolean;
  32190. /**
  32191. * Specifies if this material should be rendered in alpha test mode
  32192. * @returns a boolean specifying if an alpha test is needed.
  32193. */
  32194. needAlphaTesting(): boolean;
  32195. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  32196. /**
  32197. * Get the texture used for alpha test purpose.
  32198. * @returns the diffuse texture in case of the standard material.
  32199. */
  32200. getAlphaTestTexture(): Nullable<BaseTexture>;
  32201. /**
  32202. * Get if the submesh is ready to be used and all its information available.
  32203. * Child classes can use it to update shaders
  32204. * @param mesh defines the mesh to check
  32205. * @param subMesh defines which submesh to check
  32206. * @param useInstances specifies that instances should be used
  32207. * @returns a boolean indicating that the submesh is ready or not
  32208. */
  32209. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  32210. /**
  32211. * Builds the material UBO layouts.
  32212. * Used internally during the effect preparation.
  32213. */
  32214. buildUniformLayout(): void;
  32215. /**
  32216. * Unbinds the material from the mesh
  32217. */
  32218. unbind(): void;
  32219. /**
  32220. * Binds the submesh to this material by preparing the effect and shader to draw
  32221. * @param world defines the world transformation matrix
  32222. * @param mesh defines the mesh containing the submesh
  32223. * @param subMesh defines the submesh to bind the material to
  32224. */
  32225. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  32226. /**
  32227. * Get the list of animatables in the material.
  32228. * @returns the list of animatables object used in the material
  32229. */
  32230. getAnimatables(): IAnimatable[];
  32231. /**
  32232. * Gets the active textures from the material
  32233. * @returns an array of textures
  32234. */
  32235. getActiveTextures(): BaseTexture[];
  32236. /**
  32237. * Specifies if the material uses a texture
  32238. * @param texture defines the texture to check against the material
  32239. * @returns a boolean specifying if the material uses the texture
  32240. */
  32241. hasTexture(texture: BaseTexture): boolean;
  32242. /**
  32243. * Disposes the material
  32244. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  32245. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  32246. */
  32247. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  32248. /**
  32249. * Makes a duplicate of the material, and gives it a new name
  32250. * @param name defines the new name for the duplicated material
  32251. * @returns the cloned material
  32252. */
  32253. clone(name: string): StandardMaterial;
  32254. /**
  32255. * Serializes this material in a JSON representation
  32256. * @returns the serialized material object
  32257. */
  32258. serialize(): any;
  32259. /**
  32260. * Creates a standard material from parsed material data
  32261. * @param source defines the JSON representation of the material
  32262. * @param scene defines the hosting scene
  32263. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  32264. * @returns a new standard material
  32265. */
  32266. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  32267. /**
  32268. * Are diffuse textures enabled in the application.
  32269. */
  32270. static get DiffuseTextureEnabled(): boolean;
  32271. static set DiffuseTextureEnabled(value: boolean);
  32272. /**
  32273. * Are detail textures enabled in the application.
  32274. */
  32275. static get DetailTextureEnabled(): boolean;
  32276. static set DetailTextureEnabled(value: boolean);
  32277. /**
  32278. * Are ambient textures enabled in the application.
  32279. */
  32280. static get AmbientTextureEnabled(): boolean;
  32281. static set AmbientTextureEnabled(value: boolean);
  32282. /**
  32283. * Are opacity textures enabled in the application.
  32284. */
  32285. static get OpacityTextureEnabled(): boolean;
  32286. static set OpacityTextureEnabled(value: boolean);
  32287. /**
  32288. * Are reflection textures enabled in the application.
  32289. */
  32290. static get ReflectionTextureEnabled(): boolean;
  32291. static set ReflectionTextureEnabled(value: boolean);
  32292. /**
  32293. * Are emissive textures enabled in the application.
  32294. */
  32295. static get EmissiveTextureEnabled(): boolean;
  32296. static set EmissiveTextureEnabled(value: boolean);
  32297. /**
  32298. * Are specular textures enabled in the application.
  32299. */
  32300. static get SpecularTextureEnabled(): boolean;
  32301. static set SpecularTextureEnabled(value: boolean);
  32302. /**
  32303. * Are bump textures enabled in the application.
  32304. */
  32305. static get BumpTextureEnabled(): boolean;
  32306. static set BumpTextureEnabled(value: boolean);
  32307. /**
  32308. * Are lightmap textures enabled in the application.
  32309. */
  32310. static get LightmapTextureEnabled(): boolean;
  32311. static set LightmapTextureEnabled(value: boolean);
  32312. /**
  32313. * Are refraction textures enabled in the application.
  32314. */
  32315. static get RefractionTextureEnabled(): boolean;
  32316. static set RefractionTextureEnabled(value: boolean);
  32317. /**
  32318. * Are color grading textures enabled in the application.
  32319. */
  32320. static get ColorGradingTextureEnabled(): boolean;
  32321. static set ColorGradingTextureEnabled(value: boolean);
  32322. /**
  32323. * Are fresnels enabled in the application.
  32324. */
  32325. static get FresnelEnabled(): boolean;
  32326. static set FresnelEnabled(value: boolean);
  32327. }
  32328. }
  32329. declare module "babylonjs/Particles/solidParticleSystem" {
  32330. import { Nullable } from "babylonjs/types";
  32331. import { Mesh } from "babylonjs/Meshes/mesh";
  32332. import { Scene, IDisposable } from "babylonjs/scene";
  32333. import { DepthSortedParticle, SolidParticle, SolidParticleVertex } from "babylonjs/Particles/solidParticle";
  32334. import { Material } from "babylonjs/Materials/material";
  32335. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  32336. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  32337. /**
  32338. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  32339. *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.
  32340. * The SPS is also a particle system. It provides some methods to manage the particles.
  32341. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  32342. *
  32343. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  32344. */
  32345. export class SolidParticleSystem implements IDisposable {
  32346. /**
  32347. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  32348. * Example : var p = SPS.particles[i];
  32349. */
  32350. particles: SolidParticle[];
  32351. /**
  32352. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  32353. */
  32354. nbParticles: number;
  32355. /**
  32356. * If the particles must ever face the camera (default false). Useful for planar particles.
  32357. */
  32358. billboard: boolean;
  32359. /**
  32360. * Recompute normals when adding a shape
  32361. */
  32362. recomputeNormals: boolean;
  32363. /**
  32364. * This a counter ofr your own usage. It's not set by any SPS functions.
  32365. */
  32366. counter: number;
  32367. /**
  32368. * The SPS name. This name is also given to the underlying mesh.
  32369. */
  32370. name: string;
  32371. /**
  32372. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  32373. */
  32374. mesh: Mesh;
  32375. /**
  32376. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  32377. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  32378. */
  32379. vars: any;
  32380. /**
  32381. * This array is populated when the SPS is set as 'pickable'.
  32382. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  32383. * Each element of this array is an object `{idx: int, faceId: int}`.
  32384. * `idx` is the picked particle index in the `SPS.particles` array
  32385. * `faceId` is the picked face index counted within this particle.
  32386. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  32387. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  32388. * Use the method SPS.pickedParticle(pickingInfo) instead.
  32389. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32390. */
  32391. pickedParticles: {
  32392. idx: number;
  32393. faceId: number;
  32394. }[];
  32395. /**
  32396. * This array is populated when the SPS is set as 'pickable'
  32397. * Each key of this array is a submesh index.
  32398. * Each element of this array is a second array defined like this :
  32399. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  32400. * Each element of this second array is an object `{idx: int, faceId: int}`.
  32401. * `idx` is the picked particle index in the `SPS.particles` array
  32402. * `faceId` is the picked face index counted within this particle.
  32403. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  32404. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  32405. */
  32406. pickedBySubMesh: {
  32407. idx: number;
  32408. faceId: number;
  32409. }[][];
  32410. /**
  32411. * This array is populated when `enableDepthSort` is set to true.
  32412. * Each element of this array is an instance of the class DepthSortedParticle.
  32413. */
  32414. depthSortedParticles: DepthSortedParticle[];
  32415. /**
  32416. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  32417. * @hidden
  32418. */
  32419. _bSphereOnly: boolean;
  32420. /**
  32421. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  32422. * @hidden
  32423. */
  32424. _bSphereRadiusFactor: number;
  32425. private _scene;
  32426. private _positions;
  32427. private _indices;
  32428. private _normals;
  32429. private _colors;
  32430. private _uvs;
  32431. private _indices32;
  32432. private _positions32;
  32433. private _normals32;
  32434. private _fixedNormal32;
  32435. private _colors32;
  32436. private _uvs32;
  32437. private _index;
  32438. private _updatable;
  32439. private _pickable;
  32440. private _isVisibilityBoxLocked;
  32441. private _alwaysVisible;
  32442. private _depthSort;
  32443. private _expandable;
  32444. private _shapeCounter;
  32445. private _copy;
  32446. private _color;
  32447. private _computeParticleColor;
  32448. private _computeParticleTexture;
  32449. private _computeParticleRotation;
  32450. private _computeParticleVertex;
  32451. private _computeBoundingBox;
  32452. private _depthSortParticles;
  32453. private _camera;
  32454. private _mustUnrotateFixedNormals;
  32455. private _particlesIntersect;
  32456. private _needs32Bits;
  32457. private _isNotBuilt;
  32458. private _lastParticleId;
  32459. private _idxOfId;
  32460. private _multimaterialEnabled;
  32461. private _useModelMaterial;
  32462. private _indicesByMaterial;
  32463. private _materialIndexes;
  32464. private _depthSortFunction;
  32465. private _materialSortFunction;
  32466. private _materials;
  32467. private _multimaterial;
  32468. private _materialIndexesById;
  32469. private _defaultMaterial;
  32470. private _autoUpdateSubMeshes;
  32471. private _tmpVertex;
  32472. /**
  32473. * Creates a SPS (Solid Particle System) object.
  32474. * @param name (String) is the SPS name, this will be the underlying mesh name.
  32475. * @param scene (Scene) is the scene in which the SPS is added.
  32476. * @param options defines the options of the sps e.g.
  32477. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  32478. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  32479. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  32480. * * 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.
  32481. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  32482. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  32483. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  32484. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  32485. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  32486. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  32487. */
  32488. constructor(name: string, scene: Scene, options?: {
  32489. updatable?: boolean;
  32490. isPickable?: boolean;
  32491. enableDepthSort?: boolean;
  32492. particleIntersection?: boolean;
  32493. boundingSphereOnly?: boolean;
  32494. bSphereRadiusFactor?: number;
  32495. expandable?: boolean;
  32496. useModelMaterial?: boolean;
  32497. enableMultiMaterial?: boolean;
  32498. });
  32499. /**
  32500. * Builds the SPS underlying mesh. Returns a standard Mesh.
  32501. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  32502. * @returns the created mesh
  32503. */
  32504. buildMesh(): Mesh;
  32505. /**
  32506. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  32507. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  32508. * Thus the particles generated from `digest()` have their property `position` set yet.
  32509. * @param mesh ( Mesh ) is the mesh to be digested
  32510. * @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
  32511. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  32512. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  32513. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32514. * @returns the current SPS
  32515. */
  32516. digest(mesh: Mesh, options?: {
  32517. facetNb?: number;
  32518. number?: number;
  32519. delta?: number;
  32520. storage?: [];
  32521. }): SolidParticleSystem;
  32522. /**
  32523. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  32524. * @hidden
  32525. */
  32526. private _unrotateFixedNormals;
  32527. /**
  32528. * Resets the temporary working copy particle
  32529. * @hidden
  32530. */
  32531. private _resetCopy;
  32532. /**
  32533. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  32534. * @param p the current index in the positions array to be updated
  32535. * @param ind the current index in the indices array
  32536. * @param shape a Vector3 array, the shape geometry
  32537. * @param positions the positions array to be updated
  32538. * @param meshInd the shape indices array
  32539. * @param indices the indices array to be updated
  32540. * @param meshUV the shape uv array
  32541. * @param uvs the uv array to be updated
  32542. * @param meshCol the shape color array
  32543. * @param colors the color array to be updated
  32544. * @param meshNor the shape normals array
  32545. * @param normals the normals array to be updated
  32546. * @param idx the particle index
  32547. * @param idxInShape the particle index in its shape
  32548. * @param options the addShape() method passed options
  32549. * @model the particle model
  32550. * @hidden
  32551. */
  32552. private _meshBuilder;
  32553. /**
  32554. * Returns a shape Vector3 array from positions float array
  32555. * @param positions float array
  32556. * @returns a vector3 array
  32557. * @hidden
  32558. */
  32559. private _posToShape;
  32560. /**
  32561. * Returns a shapeUV array from a float uvs (array deep copy)
  32562. * @param uvs as a float array
  32563. * @returns a shapeUV array
  32564. * @hidden
  32565. */
  32566. private _uvsToShapeUV;
  32567. /**
  32568. * Adds a new particle object in the particles array
  32569. * @param idx particle index in particles array
  32570. * @param id particle id
  32571. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  32572. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  32573. * @param model particle ModelShape object
  32574. * @param shapeId model shape identifier
  32575. * @param idxInShape index of the particle in the current model
  32576. * @param bInfo model bounding info object
  32577. * @param storage target storage array, if any
  32578. * @hidden
  32579. */
  32580. private _addParticle;
  32581. /**
  32582. * Adds some particles to the SPS from the model shape. Returns the shape id.
  32583. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  32584. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  32585. * @param nb (positive integer) the number of particles to be created from this model
  32586. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  32587. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  32588. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  32589. * @returns the number of shapes in the system
  32590. */
  32591. addShape(mesh: Mesh, nb: number, options?: {
  32592. positionFunction?: any;
  32593. vertexFunction?: any;
  32594. storage?: [];
  32595. }): number;
  32596. /**
  32597. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  32598. * @hidden
  32599. */
  32600. private _rebuildParticle;
  32601. /**
  32602. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  32603. * @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.
  32604. * @returns the SPS.
  32605. */
  32606. rebuildMesh(reset?: boolean): SolidParticleSystem;
  32607. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  32608. * Returns an array with the removed particles.
  32609. * 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.
  32610. * The SPS can't be empty so at least one particle needs to remain in place.
  32611. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  32612. * @param start index of the first particle to remove
  32613. * @param end index of the last particle to remove (included)
  32614. * @returns an array populated with the removed particles
  32615. */
  32616. removeParticles(start: number, end: number): SolidParticle[];
  32617. /**
  32618. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  32619. * @param solidParticleArray an array populated with Solid Particles objects
  32620. * @returns the SPS
  32621. */
  32622. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  32623. /**
  32624. * Creates a new particle and modifies the SPS mesh geometry :
  32625. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  32626. * - calls _addParticle() to populate the particle array
  32627. * factorized code from addShape() and insertParticlesFromArray()
  32628. * @param idx particle index in the particles array
  32629. * @param i particle index in its shape
  32630. * @param modelShape particle ModelShape object
  32631. * @param shape shape vertex array
  32632. * @param meshInd shape indices array
  32633. * @param meshUV shape uv array
  32634. * @param meshCol shape color array
  32635. * @param meshNor shape normals array
  32636. * @param bbInfo shape bounding info
  32637. * @param storage target particle storage
  32638. * @options addShape() passed options
  32639. * @hidden
  32640. */
  32641. private _insertNewParticle;
  32642. /**
  32643. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  32644. * This method calls `updateParticle()` for each particle of the SPS.
  32645. * For an animated SPS, it is usually called within the render loop.
  32646. * 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.
  32647. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  32648. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  32649. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  32650. * @returns the SPS.
  32651. */
  32652. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  32653. /**
  32654. * Disposes the SPS.
  32655. */
  32656. dispose(): void;
  32657. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  32658. * idx is the particle index in the SPS
  32659. * faceId is the picked face index counted within this particle.
  32660. * Returns null if the pickInfo can't identify a picked particle.
  32661. * @param pickingInfo (PickingInfo object)
  32662. * @returns {idx: number, faceId: number} or null
  32663. */
  32664. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  32665. idx: number;
  32666. faceId: number;
  32667. }>;
  32668. /**
  32669. * Returns a SolidParticle object from its identifier : particle.id
  32670. * @param id (integer) the particle Id
  32671. * @returns the searched particle or null if not found in the SPS.
  32672. */
  32673. getParticleById(id: number): Nullable<SolidParticle>;
  32674. /**
  32675. * Returns a new array populated with the particles having the passed shapeId.
  32676. * @param shapeId (integer) the shape identifier
  32677. * @returns a new solid particle array
  32678. */
  32679. getParticlesByShapeId(shapeId: number): SolidParticle[];
  32680. /**
  32681. * Populates the passed array "ref" with the particles having the passed shapeId.
  32682. * @param shapeId the shape identifier
  32683. * @returns the SPS
  32684. * @param ref
  32685. */
  32686. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  32687. /**
  32688. * Computes the required SubMeshes according the materials assigned to the particles.
  32689. * @returns the solid particle system.
  32690. * Does nothing if called before the SPS mesh is built.
  32691. */
  32692. computeSubMeshes(): SolidParticleSystem;
  32693. /**
  32694. * Sorts the solid particles by material when MultiMaterial is enabled.
  32695. * Updates the indices32 array.
  32696. * Updates the indicesByMaterial array.
  32697. * Updates the mesh indices array.
  32698. * @returns the SPS
  32699. * @hidden
  32700. */
  32701. private _sortParticlesByMaterial;
  32702. /**
  32703. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  32704. * @hidden
  32705. */
  32706. private _setMaterialIndexesById;
  32707. /**
  32708. * Returns an array with unique values of Materials from the passed array
  32709. * @param array the material array to be checked and filtered
  32710. * @hidden
  32711. */
  32712. private _filterUniqueMaterialId;
  32713. /**
  32714. * Sets a new Standard Material as _defaultMaterial if not already set.
  32715. * @hidden
  32716. */
  32717. private _setDefaultMaterial;
  32718. /**
  32719. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  32720. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32721. * @returns the SPS.
  32722. */
  32723. refreshVisibleSize(): SolidParticleSystem;
  32724. /**
  32725. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  32726. * @param size the size (float) of the visibility box
  32727. * note : this doesn't lock the SPS mesh bounding box.
  32728. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32729. */
  32730. setVisibilityBox(size: number): void;
  32731. /**
  32732. * Gets whether the SPS as always visible or not
  32733. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32734. */
  32735. get isAlwaysVisible(): boolean;
  32736. /**
  32737. * Sets the SPS as always visible or not
  32738. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32739. */
  32740. set isAlwaysVisible(val: boolean);
  32741. /**
  32742. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32743. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32744. */
  32745. set isVisibilityBoxLocked(val: boolean);
  32746. /**
  32747. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  32748. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  32749. */
  32750. get isVisibilityBoxLocked(): boolean;
  32751. /**
  32752. * Tells to `setParticles()` to compute the particle rotations or not.
  32753. * Default value : true. The SPS is faster when it's set to false.
  32754. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32755. */
  32756. set computeParticleRotation(val: boolean);
  32757. /**
  32758. * Tells to `setParticles()` to compute the particle colors or not.
  32759. * Default value : true. The SPS is faster when it's set to false.
  32760. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32761. */
  32762. set computeParticleColor(val: boolean);
  32763. set computeParticleTexture(val: boolean);
  32764. /**
  32765. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  32766. * Default value : false. The SPS is faster when it's set to false.
  32767. * Note : the particle custom vertex positions aren't stored values.
  32768. */
  32769. set computeParticleVertex(val: boolean);
  32770. /**
  32771. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  32772. */
  32773. set computeBoundingBox(val: boolean);
  32774. /**
  32775. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  32776. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32777. * Default : `true`
  32778. */
  32779. set depthSortParticles(val: boolean);
  32780. /**
  32781. * Gets if `setParticles()` computes the particle rotations or not.
  32782. * Default value : true. The SPS is faster when it's set to false.
  32783. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  32784. */
  32785. get computeParticleRotation(): boolean;
  32786. /**
  32787. * Gets if `setParticles()` computes the particle colors or not.
  32788. * Default value : true. The SPS is faster when it's set to false.
  32789. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  32790. */
  32791. get computeParticleColor(): boolean;
  32792. /**
  32793. * Gets if `setParticles()` computes the particle textures or not.
  32794. * Default value : true. The SPS is faster when it's set to false.
  32795. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  32796. */
  32797. get computeParticleTexture(): boolean;
  32798. /**
  32799. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  32800. * Default value : false. The SPS is faster when it's set to false.
  32801. * Note : the particle custom vertex positions aren't stored values.
  32802. */
  32803. get computeParticleVertex(): boolean;
  32804. /**
  32805. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  32806. */
  32807. get computeBoundingBox(): boolean;
  32808. /**
  32809. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  32810. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  32811. * Default : `true`
  32812. */
  32813. get depthSortParticles(): boolean;
  32814. /**
  32815. * Gets if the SPS is created as expandable at construction time.
  32816. * Default : `false`
  32817. */
  32818. get expandable(): boolean;
  32819. /**
  32820. * Gets if the SPS supports the Multi Materials
  32821. */
  32822. get multimaterialEnabled(): boolean;
  32823. /**
  32824. * Gets if the SPS uses the model materials for its own multimaterial.
  32825. */
  32826. get useModelMaterial(): boolean;
  32827. /**
  32828. * The SPS used material array.
  32829. */
  32830. get materials(): Material[];
  32831. /**
  32832. * Sets the SPS MultiMaterial from the passed materials.
  32833. * Note : the passed array is internally copied and not used then by reference.
  32834. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  32835. */
  32836. setMultiMaterial(materials: Material[]): void;
  32837. /**
  32838. * The SPS computed multimaterial object
  32839. */
  32840. get multimaterial(): MultiMaterial;
  32841. set multimaterial(mm: MultiMaterial);
  32842. /**
  32843. * If the subMeshes must be updated on the next call to setParticles()
  32844. */
  32845. get autoUpdateSubMeshes(): boolean;
  32846. set autoUpdateSubMeshes(val: boolean);
  32847. /**
  32848. * This function does nothing. It may be overwritten to set all the particle first values.
  32849. * The SPS doesn't call this function, you may have to call it by your own.
  32850. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32851. */
  32852. initParticles(): void;
  32853. /**
  32854. * This function does nothing. It may be overwritten to recycle a particle.
  32855. * The SPS doesn't call this function, you may have to call it by your own.
  32856. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32857. * @param particle The particle to recycle
  32858. * @returns the recycled particle
  32859. */
  32860. recycleParticle(particle: SolidParticle): SolidParticle;
  32861. /**
  32862. * Updates a particle : this function should be overwritten by the user.
  32863. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  32864. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  32865. * @example : just set a particle position or velocity and recycle conditions
  32866. * @param particle The particle to update
  32867. * @returns the updated particle
  32868. */
  32869. updateParticle(particle: SolidParticle): SolidParticle;
  32870. /**
  32871. * Updates a vertex of a particle : it can be overwritten by the user.
  32872. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  32873. * @param particle the current particle
  32874. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  32875. * @param pt the index of the current vertex in the particle shape
  32876. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  32877. * @example : just set a vertex particle position or color
  32878. * @returns the sps
  32879. */
  32880. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  32881. /**
  32882. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  32883. * This does nothing and may be overwritten by the user.
  32884. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32885. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32886. * @param update the boolean update value actually passed to setParticles()
  32887. */
  32888. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32889. /**
  32890. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  32891. * This will be passed three parameters.
  32892. * This does nothing and may be overwritten by the user.
  32893. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32894. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  32895. * @param update the boolean update value actually passed to setParticles()
  32896. */
  32897. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  32898. }
  32899. }
  32900. declare module "babylonjs/Particles/solidParticle" {
  32901. import { Nullable } from "babylonjs/types";
  32902. import { Vector3, Matrix, Quaternion, Vector4, Vector2 } from "babylonjs/Maths/math.vector";
  32903. import { Color4 } from "babylonjs/Maths/math.color";
  32904. import { Mesh } from "babylonjs/Meshes/mesh";
  32905. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  32906. import { SolidParticleSystem } from "babylonjs/Particles/solidParticleSystem";
  32907. import { Plane } from "babylonjs/Maths/math.plane";
  32908. import { Material } from "babylonjs/Materials/material";
  32909. /**
  32910. * Represents one particle of a solid particle system.
  32911. */
  32912. export class SolidParticle {
  32913. /**
  32914. * particle global index
  32915. */
  32916. idx: number;
  32917. /**
  32918. * particle identifier
  32919. */
  32920. id: number;
  32921. /**
  32922. * The color of the particle
  32923. */
  32924. color: Nullable<Color4>;
  32925. /**
  32926. * The world space position of the particle.
  32927. */
  32928. position: Vector3;
  32929. /**
  32930. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  32931. */
  32932. rotation: Vector3;
  32933. /**
  32934. * The world space rotation quaternion of the particle.
  32935. */
  32936. rotationQuaternion: Nullable<Quaternion>;
  32937. /**
  32938. * The scaling of the particle.
  32939. */
  32940. scaling: Vector3;
  32941. /**
  32942. * The uvs of the particle.
  32943. */
  32944. uvs: Vector4;
  32945. /**
  32946. * The current speed of the particle.
  32947. */
  32948. velocity: Vector3;
  32949. /**
  32950. * The pivot point in the particle local space.
  32951. */
  32952. pivot: Vector3;
  32953. /**
  32954. * Must the particle be translated from its pivot point in its local space ?
  32955. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  32956. * Default : false
  32957. */
  32958. translateFromPivot: boolean;
  32959. /**
  32960. * Is the particle active or not ?
  32961. */
  32962. alive: boolean;
  32963. /**
  32964. * Is the particle visible or not ?
  32965. */
  32966. isVisible: boolean;
  32967. /**
  32968. * Index of this particle in the global "positions" array (Internal use)
  32969. * @hidden
  32970. */
  32971. _pos: number;
  32972. /**
  32973. * @hidden Index of this particle in the global "indices" array (Internal use)
  32974. */
  32975. _ind: number;
  32976. /**
  32977. * @hidden ModelShape of this particle (Internal use)
  32978. */
  32979. _model: ModelShape;
  32980. /**
  32981. * ModelShape id of this particle
  32982. */
  32983. shapeId: number;
  32984. /**
  32985. * Index of the particle in its shape id
  32986. */
  32987. idxInShape: number;
  32988. /**
  32989. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  32990. */
  32991. _modelBoundingInfo: BoundingInfo;
  32992. /**
  32993. * @hidden Particle BoundingInfo object (Internal use)
  32994. */
  32995. _boundingInfo: BoundingInfo;
  32996. /**
  32997. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  32998. */
  32999. _sps: SolidParticleSystem;
  33000. /**
  33001. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  33002. */
  33003. _stillInvisible: boolean;
  33004. /**
  33005. * @hidden Last computed particle rotation matrix
  33006. */
  33007. _rotationMatrix: number[];
  33008. /**
  33009. * Parent particle Id, if any.
  33010. * Default null.
  33011. */
  33012. parentId: Nullable<number>;
  33013. /**
  33014. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  33015. */
  33016. materialIndex: Nullable<number>;
  33017. /**
  33018. * Custom object or properties.
  33019. */
  33020. props: Nullable<any>;
  33021. /**
  33022. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  33023. * The possible values are :
  33024. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33025. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33026. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33027. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33028. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33029. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  33030. * */
  33031. cullingStrategy: number;
  33032. /**
  33033. * @hidden Internal global position in the SPS.
  33034. */
  33035. _globalPosition: Vector3;
  33036. /**
  33037. * Creates a Solid Particle object.
  33038. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  33039. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  33040. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  33041. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  33042. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  33043. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  33044. * @param shapeId (integer) is the model shape identifier in the SPS.
  33045. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  33046. * @param sps defines the sps it is associated to
  33047. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  33048. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  33049. */
  33050. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  33051. /**
  33052. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  33053. * @param target the particle target
  33054. * @returns the current particle
  33055. */
  33056. copyToRef(target: SolidParticle): SolidParticle;
  33057. /**
  33058. * Legacy support, changed scale to scaling
  33059. */
  33060. get scale(): Vector3;
  33061. /**
  33062. * Legacy support, changed scale to scaling
  33063. */
  33064. set scale(scale: Vector3);
  33065. /**
  33066. * Legacy support, changed quaternion to rotationQuaternion
  33067. */
  33068. get quaternion(): Nullable<Quaternion>;
  33069. /**
  33070. * Legacy support, changed quaternion to rotationQuaternion
  33071. */
  33072. set quaternion(q: Nullable<Quaternion>);
  33073. /**
  33074. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  33075. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  33076. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  33077. * @returns true if it intersects
  33078. */
  33079. intersectsMesh(target: Mesh | SolidParticle): boolean;
  33080. /**
  33081. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  33082. * A particle is in the frustum if its bounding box intersects the frustum
  33083. * @param frustumPlanes defines the frustum to test
  33084. * @returns true if the particle is in the frustum planes
  33085. */
  33086. isInFrustum(frustumPlanes: Plane[]): boolean;
  33087. /**
  33088. * get the rotation matrix of the particle
  33089. * @hidden
  33090. */
  33091. getRotationMatrix(m: Matrix): void;
  33092. }
  33093. /**
  33094. * Represents the shape of the model used by one particle of a solid particle system.
  33095. * SPS internal tool, don't use it manually.
  33096. */
  33097. export class ModelShape {
  33098. /**
  33099. * The shape id
  33100. * @hidden
  33101. */
  33102. shapeID: number;
  33103. /**
  33104. * flat array of model positions (internal use)
  33105. * @hidden
  33106. */
  33107. _shape: Vector3[];
  33108. /**
  33109. * flat array of model UVs (internal use)
  33110. * @hidden
  33111. */
  33112. _shapeUV: number[];
  33113. /**
  33114. * color array of the model
  33115. * @hidden
  33116. */
  33117. _shapeColors: number[];
  33118. /**
  33119. * indices array of the model
  33120. * @hidden
  33121. */
  33122. _indices: number[];
  33123. /**
  33124. * normals array of the model
  33125. * @hidden
  33126. */
  33127. _normals: number[];
  33128. /**
  33129. * length of the shape in the model indices array (internal use)
  33130. * @hidden
  33131. */
  33132. _indicesLength: number;
  33133. /**
  33134. * Custom position function (internal use)
  33135. * @hidden
  33136. */
  33137. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  33138. /**
  33139. * Custom vertex function (internal use)
  33140. * @hidden
  33141. */
  33142. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  33143. /**
  33144. * Model material (internal use)
  33145. * @hidden
  33146. */
  33147. _material: Nullable<Material>;
  33148. /**
  33149. * 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.
  33150. * SPS internal tool, don't use it manually.
  33151. * @hidden
  33152. */
  33153. 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>);
  33154. }
  33155. /**
  33156. * Represents a Depth Sorted Particle in the solid particle system.
  33157. * @hidden
  33158. */
  33159. export class DepthSortedParticle {
  33160. /**
  33161. * Particle index
  33162. */
  33163. idx: number;
  33164. /**
  33165. * Index of the particle in the "indices" array
  33166. */
  33167. ind: number;
  33168. /**
  33169. * Length of the particle shape in the "indices" array
  33170. */
  33171. indicesLength: number;
  33172. /**
  33173. * Squared distance from the particle to the camera
  33174. */
  33175. sqDistance: number;
  33176. /**
  33177. * Material index when used with MultiMaterials
  33178. */
  33179. materialIndex: number;
  33180. /**
  33181. * Creates a new sorted particle
  33182. * @param materialIndex
  33183. */
  33184. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  33185. }
  33186. /**
  33187. * Represents a solid particle vertex
  33188. */
  33189. export class SolidParticleVertex {
  33190. /**
  33191. * Vertex position
  33192. */
  33193. position: Vector3;
  33194. /**
  33195. * Vertex color
  33196. */
  33197. color: Color4;
  33198. /**
  33199. * Vertex UV
  33200. */
  33201. uv: Vector2;
  33202. /**
  33203. * Creates a new solid particle vertex
  33204. */
  33205. constructor();
  33206. /** Vertex x coordinate */
  33207. get x(): number;
  33208. set x(val: number);
  33209. /** Vertex y coordinate */
  33210. get y(): number;
  33211. set y(val: number);
  33212. /** Vertex z coordinate */
  33213. get z(): number;
  33214. set z(val: number);
  33215. }
  33216. }
  33217. declare module "babylonjs/Collisions/meshCollisionData" {
  33218. import { Collider } from "babylonjs/Collisions/collider";
  33219. import { Vector3 } from "babylonjs/Maths/math.vector";
  33220. import { Nullable } from "babylonjs/types";
  33221. import { Observer } from "babylonjs/Misc/observable";
  33222. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  33223. /**
  33224. * @hidden
  33225. */
  33226. export class _MeshCollisionData {
  33227. _checkCollisions: boolean;
  33228. _collisionMask: number;
  33229. _collisionGroup: number;
  33230. _surroundingMeshes: Nullable<AbstractMesh[]>;
  33231. _collider: Nullable<Collider>;
  33232. _oldPositionForCollisions: Vector3;
  33233. _diffPositionForCollisions: Vector3;
  33234. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  33235. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  33236. _collisionResponse: boolean;
  33237. }
  33238. }
  33239. declare module "babylonjs/Meshes/abstractMesh" {
  33240. import { Observable } from "babylonjs/Misc/observable";
  33241. import { Nullable, FloatArray, IndicesArray, DeepImmutable } from "babylonjs/types";
  33242. import { Camera } from "babylonjs/Cameras/camera";
  33243. import { Scene, IDisposable } from "babylonjs/scene";
  33244. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  33245. import { Node } from "babylonjs/node";
  33246. import { IGetSetVerticesData } from "babylonjs/Meshes/mesh.vertexData";
  33247. import { TransformNode } from "babylonjs/Meshes/transformNode";
  33248. import { SubMesh } from "babylonjs/Meshes/subMesh";
  33249. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  33250. import { ICullable, BoundingInfo } from "babylonjs/Culling/boundingInfo";
  33251. import { Material } from "babylonjs/Materials/material";
  33252. import { Light } from "babylonjs/Lights/light";
  33253. import { Skeleton } from "babylonjs/Bones/skeleton";
  33254. import { IEdgesRenderer } from "babylonjs/Rendering/edgesRenderer";
  33255. import { SolidParticle } from "babylonjs/Particles/solidParticle";
  33256. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  33257. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  33258. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  33259. import { Plane } from "babylonjs/Maths/math.plane";
  33260. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  33261. import { Ray } from "babylonjs/Culling/ray";
  33262. import { Collider } from "babylonjs/Collisions/collider";
  33263. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  33264. import { RenderingGroup } from "babylonjs/Rendering/renderingGroup";
  33265. /** @hidden */
  33266. class _FacetDataStorage {
  33267. facetPositions: Vector3[];
  33268. facetNormals: Vector3[];
  33269. facetPartitioning: number[][];
  33270. facetNb: number;
  33271. partitioningSubdivisions: number;
  33272. partitioningBBoxRatio: number;
  33273. facetDataEnabled: boolean;
  33274. facetParameters: any;
  33275. bbSize: Vector3;
  33276. subDiv: {
  33277. max: number;
  33278. X: number;
  33279. Y: number;
  33280. Z: number;
  33281. };
  33282. facetDepthSort: boolean;
  33283. facetDepthSortEnabled: boolean;
  33284. depthSortedIndices: IndicesArray;
  33285. depthSortedFacets: {
  33286. ind: number;
  33287. sqDistance: number;
  33288. }[];
  33289. facetDepthSortFunction: (f1: {
  33290. ind: number;
  33291. sqDistance: number;
  33292. }, f2: {
  33293. ind: number;
  33294. sqDistance: number;
  33295. }) => number;
  33296. facetDepthSortFrom: Vector3;
  33297. facetDepthSortOrigin: Vector3;
  33298. invertedMatrix: Matrix;
  33299. }
  33300. /**
  33301. * @hidden
  33302. **/
  33303. class _InternalAbstractMeshDataInfo {
  33304. _hasVertexAlpha: boolean;
  33305. _useVertexColors: boolean;
  33306. _numBoneInfluencers: number;
  33307. _applyFog: boolean;
  33308. _receiveShadows: boolean;
  33309. _facetData: _FacetDataStorage;
  33310. _visibility: number;
  33311. _skeleton: Nullable<Skeleton>;
  33312. _layerMask: number;
  33313. _computeBonesUsingShaders: boolean;
  33314. _isActive: boolean;
  33315. _onlyForInstances: boolean;
  33316. _isActiveIntermediate: boolean;
  33317. _onlyForInstancesIntermediate: boolean;
  33318. _actAsRegularMesh: boolean;
  33319. }
  33320. /**
  33321. * Class used to store all common mesh properties
  33322. */
  33323. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  33324. /** No occlusion */
  33325. static OCCLUSION_TYPE_NONE: number;
  33326. /** Occlusion set to optimisitic */
  33327. static OCCLUSION_TYPE_OPTIMISTIC: number;
  33328. /** Occlusion set to strict */
  33329. static OCCLUSION_TYPE_STRICT: number;
  33330. /** Use an accurante occlusion algorithm */
  33331. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  33332. /** Use a conservative occlusion algorithm */
  33333. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  33334. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  33335. * Test order :
  33336. * Is the bounding sphere outside the frustum ?
  33337. * If not, are the bounding box vertices outside the frustum ?
  33338. * It not, then the cullable object is in the frustum.
  33339. */
  33340. static readonly CULLINGSTRATEGY_STANDARD: number;
  33341. /** Culling strategy : Bounding Sphere Only.
  33342. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  33343. * It's also less accurate than the standard because some not visible objects can still be selected.
  33344. * Test : is the bounding sphere outside the frustum ?
  33345. * If not, then the cullable object is in the frustum.
  33346. */
  33347. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  33348. /** Culling strategy : Optimistic Inclusion.
  33349. * This in an inclusion test first, then the standard exclusion test.
  33350. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  33351. * 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.
  33352. * Anyway, it's as accurate as the standard strategy.
  33353. * Test :
  33354. * Is the cullable object bounding sphere center in the frustum ?
  33355. * If not, apply the default culling strategy.
  33356. */
  33357. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  33358. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  33359. * This in an inclusion test first, then the bounding sphere only exclusion test.
  33360. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  33361. * 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.
  33362. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  33363. * Test :
  33364. * Is the cullable object bounding sphere center in the frustum ?
  33365. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  33366. */
  33367. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  33368. /**
  33369. * No billboard
  33370. */
  33371. static get BILLBOARDMODE_NONE(): number;
  33372. /** Billboard on X axis */
  33373. static get BILLBOARDMODE_X(): number;
  33374. /** Billboard on Y axis */
  33375. static get BILLBOARDMODE_Y(): number;
  33376. /** Billboard on Z axis */
  33377. static get BILLBOARDMODE_Z(): number;
  33378. /** Billboard on all axes */
  33379. static get BILLBOARDMODE_ALL(): number;
  33380. /** Billboard on using position instead of orientation */
  33381. static get BILLBOARDMODE_USE_POSITION(): number;
  33382. /** @hidden */
  33383. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  33384. /**
  33385. * The culling strategy to use to check whether the mesh must be rendered or not.
  33386. * This value can be changed at any time and will be used on the next render mesh selection.
  33387. * The possible values are :
  33388. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  33389. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  33390. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  33391. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  33392. * Please read each static variable documentation to get details about the culling process.
  33393. * */
  33394. cullingStrategy: number;
  33395. /**
  33396. * Gets the number of facets in the mesh
  33397. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33398. */
  33399. get facetNb(): number;
  33400. /**
  33401. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  33402. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33403. */
  33404. get partitioningSubdivisions(): number;
  33405. set partitioningSubdivisions(nb: number);
  33406. /**
  33407. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  33408. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  33409. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  33410. */
  33411. get partitioningBBoxRatio(): number;
  33412. set partitioningBBoxRatio(ratio: number);
  33413. /**
  33414. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  33415. * Works only for updatable meshes.
  33416. * Doesn't work with multi-materials
  33417. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33418. */
  33419. get mustDepthSortFacets(): boolean;
  33420. set mustDepthSortFacets(sort: boolean);
  33421. /**
  33422. * The location (Vector3) where the facet depth sort must be computed from.
  33423. * By default, the active camera position.
  33424. * Used only when facet depth sort is enabled
  33425. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  33426. */
  33427. get facetDepthSortFrom(): Vector3;
  33428. set facetDepthSortFrom(location: Vector3);
  33429. /**
  33430. * gets a boolean indicating if facetData is enabled
  33431. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  33432. */
  33433. get isFacetDataEnabled(): boolean;
  33434. /** @hidden */
  33435. _updateNonUniformScalingState(value: boolean): boolean;
  33436. /**
  33437. * An event triggered when this mesh collides with another one
  33438. */
  33439. onCollideObservable: Observable<AbstractMesh>;
  33440. /** Set a function to call when this mesh collides with another one */
  33441. set onCollide(callback: () => void);
  33442. /**
  33443. * An event triggered when the collision's position changes
  33444. */
  33445. onCollisionPositionChangeObservable: Observable<Vector3>;
  33446. /** Set a function to call when the collision's position changes */
  33447. set onCollisionPositionChange(callback: () => void);
  33448. /**
  33449. * An event triggered when material is changed
  33450. */
  33451. onMaterialChangedObservable: Observable<AbstractMesh>;
  33452. /**
  33453. * Gets or sets the orientation for POV movement & rotation
  33454. */
  33455. definedFacingForward: boolean;
  33456. /** @hidden */
  33457. _occlusionQuery: Nullable<WebGLQuery>;
  33458. /** @hidden */
  33459. _renderingGroup: Nullable<RenderingGroup>;
  33460. /**
  33461. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33462. */
  33463. get visibility(): number;
  33464. /**
  33465. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  33466. */
  33467. set visibility(value: number);
  33468. /** Gets or sets the alpha index used to sort transparent meshes
  33469. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  33470. */
  33471. alphaIndex: number;
  33472. /**
  33473. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  33474. */
  33475. isVisible: boolean;
  33476. /**
  33477. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  33478. */
  33479. isPickable: boolean;
  33480. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  33481. showSubMeshesBoundingBox: boolean;
  33482. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  33483. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  33484. */
  33485. isBlocker: boolean;
  33486. /**
  33487. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  33488. */
  33489. enablePointerMoveEvents: boolean;
  33490. private _renderingGroupId;
  33491. /**
  33492. * Specifies the rendering group id for this mesh (0 by default)
  33493. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  33494. */
  33495. get renderingGroupId(): number;
  33496. set renderingGroupId(value: number);
  33497. private _material;
  33498. /** Gets or sets current material */
  33499. get material(): Nullable<Material>;
  33500. set material(value: Nullable<Material>);
  33501. /**
  33502. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  33503. * @see https://doc.babylonjs.com/babylon101/shadows
  33504. */
  33505. get receiveShadows(): boolean;
  33506. set receiveShadows(value: boolean);
  33507. /** Defines color to use when rendering outline */
  33508. outlineColor: Color3;
  33509. /** Define width to use when rendering outline */
  33510. outlineWidth: number;
  33511. /** Defines color to use when rendering overlay */
  33512. overlayColor: Color3;
  33513. /** Defines alpha to use when rendering overlay */
  33514. overlayAlpha: number;
  33515. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  33516. get hasVertexAlpha(): boolean;
  33517. set hasVertexAlpha(value: boolean);
  33518. /** 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) */
  33519. get useVertexColors(): boolean;
  33520. set useVertexColors(value: boolean);
  33521. /**
  33522. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  33523. */
  33524. get computeBonesUsingShaders(): boolean;
  33525. set computeBonesUsingShaders(value: boolean);
  33526. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  33527. get numBoneInfluencers(): number;
  33528. set numBoneInfluencers(value: number);
  33529. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  33530. get applyFog(): boolean;
  33531. set applyFog(value: boolean);
  33532. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  33533. useOctreeForRenderingSelection: boolean;
  33534. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  33535. useOctreeForPicking: boolean;
  33536. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  33537. useOctreeForCollisions: boolean;
  33538. /**
  33539. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  33540. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  33541. */
  33542. get layerMask(): number;
  33543. set layerMask(value: number);
  33544. /**
  33545. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  33546. */
  33547. alwaysSelectAsActiveMesh: boolean;
  33548. /**
  33549. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  33550. */
  33551. doNotSyncBoundingInfo: boolean;
  33552. /**
  33553. * Gets or sets the current action manager
  33554. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  33555. */
  33556. actionManager: Nullable<AbstractActionManager>;
  33557. private _meshCollisionData;
  33558. /**
  33559. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  33560. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33561. */
  33562. ellipsoid: Vector3;
  33563. /**
  33564. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  33565. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33566. */
  33567. ellipsoidOffset: Vector3;
  33568. /**
  33569. * Gets or sets a collision mask used to mask collisions (default is -1).
  33570. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33571. */
  33572. get collisionMask(): number;
  33573. set collisionMask(mask: number);
  33574. /**
  33575. * Gets or sets a collision response flag (default is true).
  33576. * when collisionResponse is false, events are still triggered but colliding entity has no response
  33577. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  33578. * to respond to the collision.
  33579. */
  33580. get collisionResponse(): boolean;
  33581. set collisionResponse(response: boolean);
  33582. /**
  33583. * Gets or sets the current collision group mask (-1 by default).
  33584. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  33585. */
  33586. get collisionGroup(): number;
  33587. set collisionGroup(mask: number);
  33588. /**
  33589. * Gets or sets current surrounding meshes (null by default).
  33590. *
  33591. * By default collision detection is tested against every mesh in the scene.
  33592. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  33593. * meshes will be tested for the collision.
  33594. *
  33595. * Note: if set to an empty array no collision will happen when this mesh is moved.
  33596. */
  33597. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  33598. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  33599. /**
  33600. * Defines edge width used when edgesRenderer is enabled
  33601. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33602. */
  33603. edgesWidth: number;
  33604. /**
  33605. * Defines edge color used when edgesRenderer is enabled
  33606. * @see https://www.babylonjs-playground.com/#10OJSG#13
  33607. */
  33608. edgesColor: Color4;
  33609. /** @hidden */
  33610. _edgesRenderer: Nullable<IEdgesRenderer>;
  33611. /** @hidden */
  33612. _masterMesh: Nullable<AbstractMesh>;
  33613. /** @hidden */
  33614. _boundingInfo: Nullable<BoundingInfo>;
  33615. /** @hidden */
  33616. _renderId: number;
  33617. /**
  33618. * Gets or sets the list of subMeshes
  33619. * @see https://doc.babylonjs.com/how_to/multi_materials
  33620. */
  33621. subMeshes: SubMesh[];
  33622. /** @hidden */
  33623. _intersectionsInProgress: AbstractMesh[];
  33624. /** @hidden */
  33625. _unIndexed: boolean;
  33626. /** @hidden */
  33627. _lightSources: Light[];
  33628. /** Gets the list of lights affecting that mesh */
  33629. get lightSources(): Light[];
  33630. /** @hidden */
  33631. get _positions(): Nullable<Vector3[]>;
  33632. /** @hidden */
  33633. _waitingData: {
  33634. lods: Nullable<any>;
  33635. actions: Nullable<any>;
  33636. freezeWorldMatrix: Nullable<boolean>;
  33637. };
  33638. /** @hidden */
  33639. _bonesTransformMatrices: Nullable<Float32Array>;
  33640. /** @hidden */
  33641. _transformMatrixTexture: Nullable<RawTexture>;
  33642. /**
  33643. * Gets or sets a skeleton to apply skining transformations
  33644. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  33645. */
  33646. set skeleton(value: Nullable<Skeleton>);
  33647. get skeleton(): Nullable<Skeleton>;
  33648. /**
  33649. * An event triggered when the mesh is rebuilt.
  33650. */
  33651. onRebuildObservable: Observable<AbstractMesh>;
  33652. /**
  33653. * Creates a new AbstractMesh
  33654. * @param name defines the name of the mesh
  33655. * @param scene defines the hosting scene
  33656. */
  33657. constructor(name: string, scene?: Nullable<Scene>);
  33658. /**
  33659. * Returns the string "AbstractMesh"
  33660. * @returns "AbstractMesh"
  33661. */
  33662. getClassName(): string;
  33663. /**
  33664. * Gets a string representation of the current mesh
  33665. * @param fullDetails defines a boolean indicating if full details must be included
  33666. * @returns a string representation of the current mesh
  33667. */
  33668. toString(fullDetails?: boolean): string;
  33669. /**
  33670. * @hidden
  33671. */
  33672. protected _getEffectiveParent(): Nullable<Node>;
  33673. /** @hidden */
  33674. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  33675. /** @hidden */
  33676. _rebuild(): void;
  33677. /** @hidden */
  33678. _resyncLightSources(): void;
  33679. /** @hidden */
  33680. _resyncLightSource(light: Light): void;
  33681. /** @hidden */
  33682. _unBindEffect(): void;
  33683. /** @hidden */
  33684. _removeLightSource(light: Light, dispose: boolean): void;
  33685. private _markSubMeshesAsDirty;
  33686. /** @hidden */
  33687. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  33688. /** @hidden */
  33689. _markSubMeshesAsAttributesDirty(): void;
  33690. /** @hidden */
  33691. _markSubMeshesAsMiscDirty(): void;
  33692. /**
  33693. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  33694. */
  33695. get scaling(): Vector3;
  33696. set scaling(newScaling: Vector3);
  33697. /**
  33698. * Returns true if the mesh is blocked. Implemented by child classes
  33699. */
  33700. get isBlocked(): boolean;
  33701. /**
  33702. * Returns the mesh itself by default. Implemented by child classes
  33703. * @param camera defines the camera to use to pick the right LOD level
  33704. * @returns the currentAbstractMesh
  33705. */
  33706. getLOD(camera: Camera): Nullable<AbstractMesh>;
  33707. /**
  33708. * Returns 0 by default. Implemented by child classes
  33709. * @returns an integer
  33710. */
  33711. getTotalVertices(): number;
  33712. /**
  33713. * Returns a positive integer : the total number of indices in this mesh geometry.
  33714. * @returns the numner of indices or zero if the mesh has no geometry.
  33715. */
  33716. getTotalIndices(): number;
  33717. /**
  33718. * Returns null by default. Implemented by child classes
  33719. * @returns null
  33720. */
  33721. getIndices(): Nullable<IndicesArray>;
  33722. /**
  33723. * Returns the array of the requested vertex data kind. Implemented by child classes
  33724. * @param kind defines the vertex data kind to use
  33725. * @returns null
  33726. */
  33727. getVerticesData(kind: string): Nullable<FloatArray>;
  33728. /**
  33729. * Sets the vertex data of the mesh geometry for the requested `kind`.
  33730. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  33731. * Note that a new underlying VertexBuffer object is created each call.
  33732. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  33733. * @param kind defines vertex data kind:
  33734. * * VertexBuffer.PositionKind
  33735. * * VertexBuffer.UVKind
  33736. * * VertexBuffer.UV2Kind
  33737. * * VertexBuffer.UV3Kind
  33738. * * VertexBuffer.UV4Kind
  33739. * * VertexBuffer.UV5Kind
  33740. * * VertexBuffer.UV6Kind
  33741. * * VertexBuffer.ColorKind
  33742. * * VertexBuffer.MatricesIndicesKind
  33743. * * VertexBuffer.MatricesIndicesExtraKind
  33744. * * VertexBuffer.MatricesWeightsKind
  33745. * * VertexBuffer.MatricesWeightsExtraKind
  33746. * @param data defines the data source
  33747. * @param updatable defines if the data must be flagged as updatable (or static)
  33748. * @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
  33749. * @returns the current mesh
  33750. */
  33751. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  33752. /**
  33753. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  33754. * If the mesh has no geometry, it is simply returned as it is.
  33755. * @param kind defines vertex data kind:
  33756. * * VertexBuffer.PositionKind
  33757. * * VertexBuffer.UVKind
  33758. * * VertexBuffer.UV2Kind
  33759. * * VertexBuffer.UV3Kind
  33760. * * VertexBuffer.UV4Kind
  33761. * * VertexBuffer.UV5Kind
  33762. * * VertexBuffer.UV6Kind
  33763. * * VertexBuffer.ColorKind
  33764. * * VertexBuffer.MatricesIndicesKind
  33765. * * VertexBuffer.MatricesIndicesExtraKind
  33766. * * VertexBuffer.MatricesWeightsKind
  33767. * * VertexBuffer.MatricesWeightsExtraKind
  33768. * @param data defines the data source
  33769. * @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
  33770. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  33771. * @returns the current mesh
  33772. */
  33773. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  33774. /**
  33775. * Sets the mesh indices,
  33776. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  33777. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  33778. * @param totalVertices Defines the total number of vertices
  33779. * @returns the current mesh
  33780. */
  33781. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  33782. /**
  33783. * Gets a boolean indicating if specific vertex data is present
  33784. * @param kind defines the vertex data kind to use
  33785. * @returns true is data kind is present
  33786. */
  33787. isVerticesDataPresent(kind: string): boolean;
  33788. /**
  33789. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  33790. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  33791. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  33792. * @returns a BoundingInfo
  33793. */
  33794. getBoundingInfo(): BoundingInfo;
  33795. /**
  33796. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  33797. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  33798. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  33799. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  33800. * @returns the current mesh
  33801. */
  33802. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  33803. /**
  33804. * Overwrite the current bounding info
  33805. * @param boundingInfo defines the new bounding info
  33806. * @returns the current mesh
  33807. */
  33808. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  33809. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  33810. get useBones(): boolean;
  33811. /** @hidden */
  33812. _preActivate(): void;
  33813. /** @hidden */
  33814. _preActivateForIntermediateRendering(renderId: number): void;
  33815. /** @hidden */
  33816. _activate(renderId: number, intermediateRendering: boolean): boolean;
  33817. /** @hidden */
  33818. _postActivate(): void;
  33819. /** @hidden */
  33820. _freeze(): void;
  33821. /** @hidden */
  33822. _unFreeze(): void;
  33823. /**
  33824. * Gets the current world matrix
  33825. * @returns a Matrix
  33826. */
  33827. getWorldMatrix(): Matrix;
  33828. /** @hidden */
  33829. _getWorldMatrixDeterminant(): number;
  33830. /**
  33831. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  33832. */
  33833. get isAnInstance(): boolean;
  33834. /**
  33835. * Gets a boolean indicating if this mesh has instances
  33836. */
  33837. get hasInstances(): boolean;
  33838. /**
  33839. * Gets a boolean indicating if this mesh has thin instances
  33840. */
  33841. get hasThinInstances(): boolean;
  33842. /**
  33843. * Perform relative position change from the point of view of behind the front of the mesh.
  33844. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33845. * Supports definition of mesh facing forward or backward
  33846. * @param amountRight defines the distance on the right axis
  33847. * @param amountUp defines the distance on the up axis
  33848. * @param amountForward defines the distance on the forward axis
  33849. * @returns the current mesh
  33850. */
  33851. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  33852. /**
  33853. * Calculate relative position change from the point of view of behind the front of the mesh.
  33854. * This is performed taking into account the meshes current rotation, so you do not have to care.
  33855. * Supports definition of mesh facing forward or backward
  33856. * @param amountRight defines the distance on the right axis
  33857. * @param amountUp defines the distance on the up axis
  33858. * @param amountForward defines the distance on the forward axis
  33859. * @returns the new displacement vector
  33860. */
  33861. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  33862. /**
  33863. * Perform relative rotation change from the point of view of behind the front of the mesh.
  33864. * Supports definition of mesh facing forward or backward
  33865. * @param flipBack defines the flip
  33866. * @param twirlClockwise defines the twirl
  33867. * @param tiltRight defines the tilt
  33868. * @returns the current mesh
  33869. */
  33870. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  33871. /**
  33872. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  33873. * Supports definition of mesh facing forward or backward.
  33874. * @param flipBack defines the flip
  33875. * @param twirlClockwise defines the twirl
  33876. * @param tiltRight defines the tilt
  33877. * @returns the new rotation vector
  33878. */
  33879. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  33880. /**
  33881. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  33882. * This means the mesh underlying bounding box and sphere are recomputed.
  33883. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  33884. * @returns the current mesh
  33885. */
  33886. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  33887. /** @hidden */
  33888. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  33889. /** @hidden */
  33890. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  33891. /** @hidden */
  33892. _updateBoundingInfo(): AbstractMesh;
  33893. /** @hidden */
  33894. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  33895. /** @hidden */
  33896. protected _afterComputeWorldMatrix(): void;
  33897. /** @hidden */
  33898. get _effectiveMesh(): AbstractMesh;
  33899. /**
  33900. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  33901. * A mesh is in the frustum if its bounding box intersects the frustum
  33902. * @param frustumPlanes defines the frustum to test
  33903. * @returns true if the mesh is in the frustum planes
  33904. */
  33905. isInFrustum(frustumPlanes: Plane[]): boolean;
  33906. /**
  33907. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  33908. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  33909. * @param frustumPlanes defines the frustum to test
  33910. * @returns true if the mesh is completely in the frustum planes
  33911. */
  33912. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  33913. /**
  33914. * True if the mesh intersects another mesh or a SolidParticle object
  33915. * @param mesh defines a target mesh or SolidParticle to test
  33916. * @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)
  33917. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  33918. * @returns true if there is an intersection
  33919. */
  33920. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  33921. /**
  33922. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  33923. * @param point defines the point to test
  33924. * @returns true if there is an intersection
  33925. */
  33926. intersectsPoint(point: Vector3): boolean;
  33927. /**
  33928. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  33929. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33930. */
  33931. get checkCollisions(): boolean;
  33932. set checkCollisions(collisionEnabled: boolean);
  33933. /**
  33934. * Gets Collider object used to compute collisions (not physics)
  33935. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33936. */
  33937. get collider(): Nullable<Collider>;
  33938. /**
  33939. * Move the mesh using collision engine
  33940. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  33941. * @param displacement defines the requested displacement vector
  33942. * @returns the current mesh
  33943. */
  33944. moveWithCollisions(displacement: Vector3): AbstractMesh;
  33945. private _onCollisionPositionChange;
  33946. /** @hidden */
  33947. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  33948. /** @hidden */
  33949. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  33950. /** @hidden */
  33951. _checkCollision(collider: Collider): AbstractMesh;
  33952. /** @hidden */
  33953. _generatePointsArray(): boolean;
  33954. /**
  33955. * Checks if the passed Ray intersects with the mesh
  33956. * @param ray defines the ray to use
  33957. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  33958. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  33959. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  33960. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  33961. * @returns the picking info
  33962. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  33963. */
  33964. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  33965. /**
  33966. * Clones the current mesh
  33967. * @param name defines the mesh name
  33968. * @param newParent defines the new mesh parent
  33969. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  33970. * @returns the new mesh
  33971. */
  33972. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  33973. /**
  33974. * Disposes all the submeshes of the current meshnp
  33975. * @returns the current mesh
  33976. */
  33977. releaseSubMeshes(): AbstractMesh;
  33978. /**
  33979. * Releases resources associated with this abstract mesh.
  33980. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  33981. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  33982. */
  33983. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  33984. /**
  33985. * Adds the passed mesh as a child to the current mesh
  33986. * @param mesh defines the child mesh
  33987. * @returns the current mesh
  33988. */
  33989. addChild(mesh: AbstractMesh): AbstractMesh;
  33990. /**
  33991. * Removes the passed mesh from the current mesh children list
  33992. * @param mesh defines the child mesh
  33993. * @returns the current mesh
  33994. */
  33995. removeChild(mesh: AbstractMesh): AbstractMesh;
  33996. /** @hidden */
  33997. private _initFacetData;
  33998. /**
  33999. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  34000. * This method can be called within the render loop.
  34001. * 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
  34002. * @returns the current mesh
  34003. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34004. */
  34005. updateFacetData(): AbstractMesh;
  34006. /**
  34007. * Returns the facetLocalNormals array.
  34008. * The normals are expressed in the mesh local spac
  34009. * @returns an array of Vector3
  34010. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34011. */
  34012. getFacetLocalNormals(): Vector3[];
  34013. /**
  34014. * Returns the facetLocalPositions array.
  34015. * The facet positions are expressed in the mesh local space
  34016. * @returns an array of Vector3
  34017. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34018. */
  34019. getFacetLocalPositions(): Vector3[];
  34020. /**
  34021. * Returns the facetLocalPartioning array
  34022. * @returns an array of array of numbers
  34023. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34024. */
  34025. getFacetLocalPartitioning(): number[][];
  34026. /**
  34027. * Returns the i-th facet position in the world system.
  34028. * This method allocates a new Vector3 per call
  34029. * @param i defines the facet index
  34030. * @returns a new Vector3
  34031. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34032. */
  34033. getFacetPosition(i: number): Vector3;
  34034. /**
  34035. * Sets the reference Vector3 with the i-th facet position in the world system
  34036. * @param i defines the facet index
  34037. * @param ref defines the target vector
  34038. * @returns the current mesh
  34039. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34040. */
  34041. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  34042. /**
  34043. * Returns the i-th facet normal in the world system.
  34044. * This method allocates a new Vector3 per call
  34045. * @param i defines the facet index
  34046. * @returns a new Vector3
  34047. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34048. */
  34049. getFacetNormal(i: number): Vector3;
  34050. /**
  34051. * Sets the reference Vector3 with the i-th facet normal in the world system
  34052. * @param i defines the facet index
  34053. * @param ref defines the target vector
  34054. * @returns the current mesh
  34055. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34056. */
  34057. getFacetNormalToRef(i: number, ref: Vector3): this;
  34058. /**
  34059. * 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)
  34060. * @param x defines x coordinate
  34061. * @param y defines y coordinate
  34062. * @param z defines z coordinate
  34063. * @returns the array of facet indexes
  34064. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34065. */
  34066. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  34067. /**
  34068. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  34069. * @param projected sets as the (x,y,z) world projection on the facet
  34070. * @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
  34071. * @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
  34072. * @param x defines x coordinate
  34073. * @param y defines y coordinate
  34074. * @param z defines z coordinate
  34075. * @returns the face index if found (or null instead)
  34076. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34077. */
  34078. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34079. /**
  34080. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  34081. * @param projected sets as the (x,y,z) local projection on the facet
  34082. * @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
  34083. * @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
  34084. * @param x defines x coordinate
  34085. * @param y defines y coordinate
  34086. * @param z defines z coordinate
  34087. * @returns the face index if found (or null instead)
  34088. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34089. */
  34090. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  34091. /**
  34092. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  34093. * @returns the parameters
  34094. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34095. */
  34096. getFacetDataParameters(): any;
  34097. /**
  34098. * Disables the feature FacetData and frees the related memory
  34099. * @returns the current mesh
  34100. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  34101. */
  34102. disableFacetData(): AbstractMesh;
  34103. /**
  34104. * Updates the AbstractMesh indices array
  34105. * @param indices defines the data source
  34106. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  34107. * @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)
  34108. * @returns the current mesh
  34109. */
  34110. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  34111. /**
  34112. * Creates new normals data for the mesh
  34113. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  34114. * @returns the current mesh
  34115. */
  34116. createNormals(updatable: boolean): AbstractMesh;
  34117. /**
  34118. * Align the mesh with a normal
  34119. * @param normal defines the normal to use
  34120. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  34121. * @returns the current mesh
  34122. */
  34123. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  34124. /** @hidden */
  34125. _checkOcclusionQuery(): boolean;
  34126. /**
  34127. * Disables the mesh edge rendering mode
  34128. * @returns the currentAbstractMesh
  34129. */
  34130. disableEdgesRendering(): AbstractMesh;
  34131. /**
  34132. * Enables the edge rendering mode on the mesh.
  34133. * This mode makes the mesh edges visible
  34134. * @param epsilon defines the maximal distance between two angles to detect a face
  34135. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  34136. * @returns the currentAbstractMesh
  34137. * @see https://www.babylonjs-playground.com/#19O9TU#0
  34138. */
  34139. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  34140. /**
  34141. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  34142. * @returns an array of particle systems in the scene that use the mesh as an emitter
  34143. */
  34144. getConnectedParticleSystems(): IParticleSystem[];
  34145. }
  34146. }
  34147. declare module "babylonjs/Actions/actionEvent" {
  34148. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34149. import { Nullable } from "babylonjs/types";
  34150. import { Sprite } from "babylonjs/Sprites/sprite";
  34151. import { Scene } from "babylonjs/scene";
  34152. import { Vector2 } from "babylonjs/Maths/math.vector";
  34153. /**
  34154. * Interface used to define ActionEvent
  34155. */
  34156. export interface IActionEvent {
  34157. /** The mesh or sprite that triggered the action */
  34158. source: any;
  34159. /** The X mouse cursor position at the time of the event */
  34160. pointerX: number;
  34161. /** The Y mouse cursor position at the time of the event */
  34162. pointerY: number;
  34163. /** The mesh that is currently pointed at (can be null) */
  34164. meshUnderPointer: Nullable<AbstractMesh>;
  34165. /** the original (browser) event that triggered the ActionEvent */
  34166. sourceEvent?: any;
  34167. /** additional data for the event */
  34168. additionalData?: any;
  34169. }
  34170. /**
  34171. * ActionEvent is the event being sent when an action is triggered.
  34172. */
  34173. export class ActionEvent implements IActionEvent {
  34174. /** The mesh or sprite that triggered the action */
  34175. source: any;
  34176. /** The X mouse cursor position at the time of the event */
  34177. pointerX: number;
  34178. /** The Y mouse cursor position at the time of the event */
  34179. pointerY: number;
  34180. /** The mesh that is currently pointed at (can be null) */
  34181. meshUnderPointer: Nullable<AbstractMesh>;
  34182. /** the original (browser) event that triggered the ActionEvent */
  34183. sourceEvent?: any;
  34184. /** additional data for the event */
  34185. additionalData?: any;
  34186. /**
  34187. * Creates a new ActionEvent
  34188. * @param source The mesh or sprite that triggered the action
  34189. * @param pointerX The X mouse cursor position at the time of the event
  34190. * @param pointerY The Y mouse cursor position at the time of the event
  34191. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  34192. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  34193. * @param additionalData additional data for the event
  34194. */
  34195. constructor(
  34196. /** The mesh or sprite that triggered the action */
  34197. source: any,
  34198. /** The X mouse cursor position at the time of the event */
  34199. pointerX: number,
  34200. /** The Y mouse cursor position at the time of the event */
  34201. pointerY: number,
  34202. /** The mesh that is currently pointed at (can be null) */
  34203. meshUnderPointer: Nullable<AbstractMesh>,
  34204. /** the original (browser) event that triggered the ActionEvent */
  34205. sourceEvent?: any,
  34206. /** additional data for the event */
  34207. additionalData?: any);
  34208. /**
  34209. * Helper function to auto-create an ActionEvent from a source mesh.
  34210. * @param source The source mesh that triggered the event
  34211. * @param evt The original (browser) event
  34212. * @param additionalData additional data for the event
  34213. * @returns the new ActionEvent
  34214. */
  34215. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  34216. /**
  34217. * Helper function to auto-create an ActionEvent from a source sprite
  34218. * @param source The source sprite that triggered the event
  34219. * @param scene Scene associated with the sprite
  34220. * @param evt The original (browser) event
  34221. * @param additionalData additional data for the event
  34222. * @returns the new ActionEvent
  34223. */
  34224. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  34225. /**
  34226. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  34227. * @param scene the scene where the event occurred
  34228. * @param evt The original (browser) event
  34229. * @returns the new ActionEvent
  34230. */
  34231. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  34232. /**
  34233. * Helper function to auto-create an ActionEvent from a primitive
  34234. * @param prim defines the target primitive
  34235. * @param pointerPos defines the pointer position
  34236. * @param evt The original (browser) event
  34237. * @param additionalData additional data for the event
  34238. * @returns the new ActionEvent
  34239. */
  34240. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  34241. }
  34242. }
  34243. declare module "babylonjs/Actions/abstractActionManager" {
  34244. import { IDisposable } from "babylonjs/scene";
  34245. import { IActionEvent } from "babylonjs/Actions/actionEvent";
  34246. import { IAction } from "babylonjs/Actions/action";
  34247. import { Nullable } from "babylonjs/types";
  34248. /**
  34249. * Abstract class used to decouple action Manager from scene and meshes.
  34250. * Do not instantiate.
  34251. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  34252. */
  34253. export abstract class AbstractActionManager implements IDisposable {
  34254. /** Gets the list of active triggers */
  34255. static Triggers: {
  34256. [key: string]: number;
  34257. };
  34258. /** Gets the cursor to use when hovering items */
  34259. hoverCursor: string;
  34260. /** Gets the list of actions */
  34261. actions: IAction[];
  34262. /**
  34263. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  34264. */
  34265. isRecursive: boolean;
  34266. /**
  34267. * Releases all associated resources
  34268. */
  34269. abstract dispose(): void;
  34270. /**
  34271. * Does this action manager has pointer triggers
  34272. */
  34273. abstract get hasPointerTriggers(): boolean;
  34274. /**
  34275. * Does this action manager has pick triggers
  34276. */
  34277. abstract get hasPickTriggers(): boolean;
  34278. /**
  34279. * Process a specific trigger
  34280. * @param trigger defines the trigger to process
  34281. * @param evt defines the event details to be processed
  34282. */
  34283. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  34284. /**
  34285. * Does this action manager handles actions of any of the given triggers
  34286. * @param triggers defines the triggers to be tested
  34287. * @return a boolean indicating whether one (or more) of the triggers is handled
  34288. */
  34289. abstract hasSpecificTriggers(triggers: number[]): boolean;
  34290. /**
  34291. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  34292. * speed.
  34293. * @param triggerA defines the trigger to be tested
  34294. * @param triggerB defines the trigger to be tested
  34295. * @return a boolean indicating whether one (or more) of the triggers is handled
  34296. */
  34297. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  34298. /**
  34299. * Does this action manager handles actions of a given trigger
  34300. * @param trigger defines the trigger to be tested
  34301. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  34302. * @return whether the trigger is handled
  34303. */
  34304. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  34305. /**
  34306. * Serialize this manager to a JSON object
  34307. * @param name defines the property name to store this manager
  34308. * @returns a JSON representation of this manager
  34309. */
  34310. abstract serialize(name: string): any;
  34311. /**
  34312. * Registers an action to this action manager
  34313. * @param action defines the action to be registered
  34314. * @return the action amended (prepared) after registration
  34315. */
  34316. abstract registerAction(action: IAction): Nullable<IAction>;
  34317. /**
  34318. * Unregisters an action to this action manager
  34319. * @param action defines the action to be unregistered
  34320. * @return a boolean indicating whether the action has been unregistered
  34321. */
  34322. abstract unregisterAction(action: IAction): Boolean;
  34323. /**
  34324. * Does exist one action manager with at least one trigger
  34325. **/
  34326. static get HasTriggers(): boolean;
  34327. /**
  34328. * Does exist one action manager with at least one pick trigger
  34329. **/
  34330. static get HasPickTriggers(): boolean;
  34331. /**
  34332. * Does exist one action manager that handles actions of a given trigger
  34333. * @param trigger defines the trigger to be tested
  34334. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  34335. **/
  34336. static HasSpecificTrigger(trigger: number): boolean;
  34337. }
  34338. }
  34339. declare module "babylonjs/node" {
  34340. import { Scene } from "babylonjs/scene";
  34341. import { Nullable } from "babylonjs/types";
  34342. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  34343. import { Engine } from "babylonjs/Engines/engine";
  34344. import { IBehaviorAware, Behavior } from "babylonjs/Behaviors/behavior";
  34345. import { Observable } from "babylonjs/Misc/observable";
  34346. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  34347. import { IInspectable } from "babylonjs/Misc/iInspectable";
  34348. import { Animatable } from "babylonjs/Animations/animatable";
  34349. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  34350. import { Animation } from "babylonjs/Animations/animation";
  34351. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34352. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  34353. /**
  34354. * Defines how a node can be built from a string name.
  34355. */
  34356. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  34357. /**
  34358. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  34359. */
  34360. export class Node implements IBehaviorAware<Node> {
  34361. /** @hidden */
  34362. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  34363. private static _NodeConstructors;
  34364. /**
  34365. * Add a new node constructor
  34366. * @param type defines the type name of the node to construct
  34367. * @param constructorFunc defines the constructor function
  34368. */
  34369. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  34370. /**
  34371. * Returns a node constructor based on type name
  34372. * @param type defines the type name
  34373. * @param name defines the new node name
  34374. * @param scene defines the hosting scene
  34375. * @param options defines optional options to transmit to constructors
  34376. * @returns the new constructor or null
  34377. */
  34378. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  34379. /**
  34380. * Gets or sets the name of the node
  34381. */
  34382. name: string;
  34383. /**
  34384. * Gets or sets the id of the node
  34385. */
  34386. id: string;
  34387. /**
  34388. * Gets or sets the unique id of the node
  34389. */
  34390. uniqueId: number;
  34391. /**
  34392. * Gets or sets a string used to store user defined state for the node
  34393. */
  34394. state: string;
  34395. /**
  34396. * Gets or sets an object used to store user defined information for the node
  34397. */
  34398. metadata: any;
  34399. /**
  34400. * For internal use only. Please do not use.
  34401. */
  34402. reservedDataStore: any;
  34403. /**
  34404. * List of inspectable custom properties (used by the Inspector)
  34405. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  34406. */
  34407. inspectableCustomProperties: IInspectable[];
  34408. private _doNotSerialize;
  34409. /**
  34410. * Gets or sets a boolean used to define if the node must be serialized
  34411. */
  34412. get doNotSerialize(): boolean;
  34413. set doNotSerialize(value: boolean);
  34414. /** @hidden */
  34415. _isDisposed: boolean;
  34416. /**
  34417. * Gets a list of Animations associated with the node
  34418. */
  34419. animations: import("babylonjs/Animations/animation").Animation[];
  34420. protected _ranges: {
  34421. [name: string]: Nullable<AnimationRange>;
  34422. };
  34423. /**
  34424. * Callback raised when the node is ready to be used
  34425. */
  34426. onReady: Nullable<(node: Node) => void>;
  34427. private _isEnabled;
  34428. private _isParentEnabled;
  34429. private _isReady;
  34430. /** @hidden */
  34431. _currentRenderId: number;
  34432. private _parentUpdateId;
  34433. /** @hidden */
  34434. _childUpdateId: number;
  34435. /** @hidden */
  34436. _waitingParentId: Nullable<string>;
  34437. /** @hidden */
  34438. _scene: Scene;
  34439. /** @hidden */
  34440. _cache: any;
  34441. private _parentNode;
  34442. private _children;
  34443. /** @hidden */
  34444. _worldMatrix: Matrix;
  34445. /** @hidden */
  34446. _worldMatrixDeterminant: number;
  34447. /** @hidden */
  34448. _worldMatrixDeterminantIsDirty: boolean;
  34449. /** @hidden */
  34450. private _sceneRootNodesIndex;
  34451. /**
  34452. * Gets a boolean indicating if the node has been disposed
  34453. * @returns true if the node was disposed
  34454. */
  34455. isDisposed(): boolean;
  34456. /**
  34457. * Gets or sets the parent of the node (without keeping the current position in the scene)
  34458. * @see https://doc.babylonjs.com/how_to/parenting
  34459. */
  34460. set parent(parent: Nullable<Node>);
  34461. get parent(): Nullable<Node>;
  34462. /** @hidden */
  34463. _addToSceneRootNodes(): void;
  34464. /** @hidden */
  34465. _removeFromSceneRootNodes(): void;
  34466. private _animationPropertiesOverride;
  34467. /**
  34468. * Gets or sets the animation properties override
  34469. */
  34470. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  34471. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  34472. /**
  34473. * Gets a string identifying the name of the class
  34474. * @returns "Node" string
  34475. */
  34476. getClassName(): string;
  34477. /** @hidden */
  34478. readonly _isNode: boolean;
  34479. /**
  34480. * An event triggered when the mesh is disposed
  34481. */
  34482. onDisposeObservable: Observable<Node>;
  34483. private _onDisposeObserver;
  34484. /**
  34485. * Sets a callback that will be raised when the node will be disposed
  34486. */
  34487. set onDispose(callback: () => void);
  34488. /**
  34489. * Creates a new Node
  34490. * @param name the name and id to be given to this node
  34491. * @param scene the scene this node will be added to
  34492. */
  34493. constructor(name: string, scene?: Nullable<Scene>);
  34494. /**
  34495. * Gets the scene of the node
  34496. * @returns a scene
  34497. */
  34498. getScene(): Scene;
  34499. /**
  34500. * Gets the engine of the node
  34501. * @returns a Engine
  34502. */
  34503. getEngine(): Engine;
  34504. private _behaviors;
  34505. /**
  34506. * Attach a behavior to the node
  34507. * @see https://doc.babylonjs.com/features/behaviour
  34508. * @param behavior defines the behavior to attach
  34509. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  34510. * @returns the current Node
  34511. */
  34512. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  34513. /**
  34514. * Remove an attached behavior
  34515. * @see https://doc.babylonjs.com/features/behaviour
  34516. * @param behavior defines the behavior to attach
  34517. * @returns the current Node
  34518. */
  34519. removeBehavior(behavior: Behavior<Node>): Node;
  34520. /**
  34521. * Gets the list of attached behaviors
  34522. * @see https://doc.babylonjs.com/features/behaviour
  34523. */
  34524. get behaviors(): Behavior<Node>[];
  34525. /**
  34526. * Gets an attached behavior by name
  34527. * @param name defines the name of the behavior to look for
  34528. * @see https://doc.babylonjs.com/features/behaviour
  34529. * @returns null if behavior was not found else the requested behavior
  34530. */
  34531. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  34532. /**
  34533. * Returns the latest update of the World matrix
  34534. * @returns a Matrix
  34535. */
  34536. getWorldMatrix(): Matrix;
  34537. /** @hidden */
  34538. _getWorldMatrixDeterminant(): number;
  34539. /**
  34540. * Returns directly the latest state of the mesh World matrix.
  34541. * A Matrix is returned.
  34542. */
  34543. get worldMatrixFromCache(): Matrix;
  34544. /** @hidden */
  34545. _initCache(): void;
  34546. /** @hidden */
  34547. updateCache(force?: boolean): void;
  34548. /** @hidden */
  34549. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  34550. /** @hidden */
  34551. _updateCache(ignoreParentClass?: boolean): void;
  34552. /** @hidden */
  34553. _isSynchronized(): boolean;
  34554. /** @hidden */
  34555. _markSyncedWithParent(): void;
  34556. /** @hidden */
  34557. isSynchronizedWithParent(): boolean;
  34558. /** @hidden */
  34559. isSynchronized(): boolean;
  34560. /**
  34561. * Is this node ready to be used/rendered
  34562. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  34563. * @return true if the node is ready
  34564. */
  34565. isReady(completeCheck?: boolean): boolean;
  34566. /**
  34567. * Is this node enabled?
  34568. * 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
  34569. * @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
  34570. * @return whether this node (and its parent) is enabled
  34571. */
  34572. isEnabled(checkAncestors?: boolean): boolean;
  34573. /** @hidden */
  34574. protected _syncParentEnabledState(): void;
  34575. /**
  34576. * Set the enabled state of this node
  34577. * @param value defines the new enabled state
  34578. */
  34579. setEnabled(value: boolean): void;
  34580. /**
  34581. * Is this node a descendant of the given node?
  34582. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  34583. * @param ancestor defines the parent node to inspect
  34584. * @returns a boolean indicating if this node is a descendant of the given node
  34585. */
  34586. isDescendantOf(ancestor: Node): boolean;
  34587. /** @hidden */
  34588. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  34589. /**
  34590. * Will return all nodes that have this node as ascendant
  34591. * @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
  34592. * @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
  34593. * @return all children nodes of all types
  34594. */
  34595. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  34596. /**
  34597. * Get all child-meshes of this node
  34598. * @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)
  34599. * @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
  34600. * @returns an array of AbstractMesh
  34601. */
  34602. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  34603. /**
  34604. * Get all direct children of this node
  34605. * @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
  34606. * @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)
  34607. * @returns an array of Node
  34608. */
  34609. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  34610. /** @hidden */
  34611. _setReady(state: boolean): void;
  34612. /**
  34613. * Get an animation by name
  34614. * @param name defines the name of the animation to look for
  34615. * @returns null if not found else the requested animation
  34616. */
  34617. getAnimationByName(name: string): Nullable<Animation>;
  34618. /**
  34619. * Creates an animation range for this node
  34620. * @param name defines the name of the range
  34621. * @param from defines the starting key
  34622. * @param to defines the end key
  34623. */
  34624. createAnimationRange(name: string, from: number, to: number): void;
  34625. /**
  34626. * Delete a specific animation range
  34627. * @param name defines the name of the range to delete
  34628. * @param deleteFrames defines if animation frames from the range must be deleted as well
  34629. */
  34630. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  34631. /**
  34632. * Get an animation range by name
  34633. * @param name defines the name of the animation range to look for
  34634. * @returns null if not found else the requested animation range
  34635. */
  34636. getAnimationRange(name: string): Nullable<AnimationRange>;
  34637. /**
  34638. * Gets the list of all animation ranges defined on this node
  34639. * @returns an array
  34640. */
  34641. getAnimationRanges(): Nullable<AnimationRange>[];
  34642. /**
  34643. * Will start the animation sequence
  34644. * @param name defines the range frames for animation sequence
  34645. * @param loop defines if the animation should loop (false by default)
  34646. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  34647. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  34648. * @returns the object created for this animation. If range does not exist, it will return null
  34649. */
  34650. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  34651. /**
  34652. * Serialize animation ranges into a JSON compatible object
  34653. * @returns serialization object
  34654. */
  34655. serializeAnimationRanges(): any;
  34656. /**
  34657. * Computes the world matrix of the node
  34658. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  34659. * @returns the world matrix
  34660. */
  34661. computeWorldMatrix(force?: boolean): Matrix;
  34662. /**
  34663. * Releases resources associated with this node.
  34664. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  34665. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  34666. */
  34667. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  34668. /**
  34669. * Parse animation range data from a serialization object and store them into a given node
  34670. * @param node defines where to store the animation ranges
  34671. * @param parsedNode defines the serialization object to read data from
  34672. * @param scene defines the hosting scene
  34673. */
  34674. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  34675. /**
  34676. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  34677. * @param includeDescendants Include bounding info from descendants as well (true by default)
  34678. * @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
  34679. * @returns the new bounding vectors
  34680. */
  34681. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  34682. min: Vector3;
  34683. max: Vector3;
  34684. };
  34685. }
  34686. }
  34687. declare module "babylonjs/Animations/animation" {
  34688. import { IEasingFunction, EasingFunction } from "babylonjs/Animations/easing";
  34689. import { Vector3, Quaternion, Vector2, Matrix } from "babylonjs/Maths/math.vector";
  34690. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  34691. import { Nullable } from "babylonjs/types";
  34692. import { Scene } from "babylonjs/scene";
  34693. import { IAnimationKey } from "babylonjs/Animations/animationKey";
  34694. import { AnimationRange } from "babylonjs/Animations/animationRange";
  34695. import { AnimationEvent } from "babylonjs/Animations/animationEvent";
  34696. import { Node } from "babylonjs/node";
  34697. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  34698. import { Size } from "babylonjs/Maths/math.size";
  34699. import { Animatable } from "babylonjs/Animations/animatable";
  34700. import { RuntimeAnimation } from "babylonjs/Animations/runtimeAnimation";
  34701. /**
  34702. * @hidden
  34703. */
  34704. export class _IAnimationState {
  34705. key: number;
  34706. repeatCount: number;
  34707. workValue?: any;
  34708. loopMode?: number;
  34709. offsetValue?: any;
  34710. highLimitValue?: any;
  34711. }
  34712. /**
  34713. * Class used to store any kind of animation
  34714. */
  34715. export class Animation {
  34716. /**Name of the animation */
  34717. name: string;
  34718. /**Property to animate */
  34719. targetProperty: string;
  34720. /**The frames per second of the animation */
  34721. framePerSecond: number;
  34722. /**The data type of the animation */
  34723. dataType: number;
  34724. /**The loop mode of the animation */
  34725. loopMode?: number | undefined;
  34726. /**Specifies if blending should be enabled */
  34727. enableBlending?: boolean | undefined;
  34728. /**
  34729. * Use matrix interpolation instead of using direct key value when animating matrices
  34730. */
  34731. static AllowMatricesInterpolation: boolean;
  34732. /**
  34733. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  34734. */
  34735. static AllowMatrixDecomposeForInterpolation: boolean;
  34736. /** Define the Url to load snippets */
  34737. static SnippetUrl: string;
  34738. /** Snippet ID if the animation was created from the snippet server */
  34739. snippetId: string;
  34740. /**
  34741. * Stores the key frames of the animation
  34742. */
  34743. private _keys;
  34744. /**
  34745. * Stores the easing function of the animation
  34746. */
  34747. private _easingFunction;
  34748. /**
  34749. * @hidden Internal use only
  34750. */
  34751. _runtimeAnimations: import("babylonjs/Animations/runtimeAnimation").RuntimeAnimation[];
  34752. /**
  34753. * The set of event that will be linked to this animation
  34754. */
  34755. private _events;
  34756. /**
  34757. * Stores an array of target property paths
  34758. */
  34759. targetPropertyPath: string[];
  34760. /**
  34761. * Stores the blending speed of the animation
  34762. */
  34763. blendingSpeed: number;
  34764. /**
  34765. * Stores the animation ranges for the animation
  34766. */
  34767. private _ranges;
  34768. /**
  34769. * @hidden Internal use
  34770. */
  34771. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  34772. /**
  34773. * Sets up an animation
  34774. * @param property The property to animate
  34775. * @param animationType The animation type to apply
  34776. * @param framePerSecond The frames per second of the animation
  34777. * @param easingFunction The easing function used in the animation
  34778. * @returns The created animation
  34779. */
  34780. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  34781. /**
  34782. * Create and start an animation on a node
  34783. * @param name defines the name of the global animation that will be run on all nodes
  34784. * @param node defines the root node where the animation will take place
  34785. * @param targetProperty defines property to animate
  34786. * @param framePerSecond defines the number of frame per second yo use
  34787. * @param totalFrame defines the number of frames in total
  34788. * @param from defines the initial value
  34789. * @param to defines the final value
  34790. * @param loopMode defines which loop mode you want to use (off by default)
  34791. * @param easingFunction defines the easing function to use (linear by default)
  34792. * @param onAnimationEnd defines the callback to call when animation end
  34793. * @returns the animatable created for this animation
  34794. */
  34795. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34796. /**
  34797. * Create and start an animation on a node and its descendants
  34798. * @param name defines the name of the global animation that will be run on all nodes
  34799. * @param node defines the root node where the animation will take place
  34800. * @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
  34801. * @param targetProperty defines property to animate
  34802. * @param framePerSecond defines the number of frame per second to use
  34803. * @param totalFrame defines the number of frames in total
  34804. * @param from defines the initial value
  34805. * @param to defines the final value
  34806. * @param loopMode defines which loop mode you want to use (off by default)
  34807. * @param easingFunction defines the easing function to use (linear by default)
  34808. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  34809. * @returns the list of animatables created for all nodes
  34810. * @example https://www.babylonjs-playground.com/#MH0VLI
  34811. */
  34812. 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[]>;
  34813. /**
  34814. * Creates a new animation, merges it with the existing animations and starts it
  34815. * @param name Name of the animation
  34816. * @param node Node which contains the scene that begins the animations
  34817. * @param targetProperty Specifies which property to animate
  34818. * @param framePerSecond The frames per second of the animation
  34819. * @param totalFrame The total number of frames
  34820. * @param from The frame at the beginning of the animation
  34821. * @param to The frame at the end of the animation
  34822. * @param loopMode Specifies the loop mode of the animation
  34823. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  34824. * @param onAnimationEnd Callback to run once the animation is complete
  34825. * @returns Nullable animation
  34826. */
  34827. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  34828. /**
  34829. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  34830. * @param sourceAnimation defines the Animation containing keyframes to convert
  34831. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  34832. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  34833. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  34834. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  34835. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  34836. */
  34837. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  34838. /**
  34839. * Transition property of an host to the target Value
  34840. * @param property The property to transition
  34841. * @param targetValue The target Value of the property
  34842. * @param host The object where the property to animate belongs
  34843. * @param scene Scene used to run the animation
  34844. * @param frameRate Framerate (in frame/s) to use
  34845. * @param transition The transition type we want to use
  34846. * @param duration The duration of the animation, in milliseconds
  34847. * @param onAnimationEnd Callback trigger at the end of the animation
  34848. * @returns Nullable animation
  34849. */
  34850. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  34851. /**
  34852. * Return the array of runtime animations currently using this animation
  34853. */
  34854. get runtimeAnimations(): RuntimeAnimation[];
  34855. /**
  34856. * Specifies if any of the runtime animations are currently running
  34857. */
  34858. get hasRunningRuntimeAnimations(): boolean;
  34859. /**
  34860. * Initializes the animation
  34861. * @param name Name of the animation
  34862. * @param targetProperty Property to animate
  34863. * @param framePerSecond The frames per second of the animation
  34864. * @param dataType The data type of the animation
  34865. * @param loopMode The loop mode of the animation
  34866. * @param enableBlending Specifies if blending should be enabled
  34867. */
  34868. constructor(
  34869. /**Name of the animation */
  34870. name: string,
  34871. /**Property to animate */
  34872. targetProperty: string,
  34873. /**The frames per second of the animation */
  34874. framePerSecond: number,
  34875. /**The data type of the animation */
  34876. dataType: number,
  34877. /**The loop mode of the animation */
  34878. loopMode?: number | undefined,
  34879. /**Specifies if blending should be enabled */
  34880. enableBlending?: boolean | undefined);
  34881. /**
  34882. * Converts the animation to a string
  34883. * @param fullDetails support for multiple levels of logging within scene loading
  34884. * @returns String form of the animation
  34885. */
  34886. toString(fullDetails?: boolean): string;
  34887. /**
  34888. * Add an event to this animation
  34889. * @param event Event to add
  34890. */
  34891. addEvent(event: AnimationEvent): void;
  34892. /**
  34893. * Remove all events found at the given frame
  34894. * @param frame The frame to remove events from
  34895. */
  34896. removeEvents(frame: number): void;
  34897. /**
  34898. * Retrieves all the events from the animation
  34899. * @returns Events from the animation
  34900. */
  34901. getEvents(): AnimationEvent[];
  34902. /**
  34903. * Creates an animation range
  34904. * @param name Name of the animation range
  34905. * @param from Starting frame of the animation range
  34906. * @param to Ending frame of the animation
  34907. */
  34908. createRange(name: string, from: number, to: number): void;
  34909. /**
  34910. * Deletes an animation range by name
  34911. * @param name Name of the animation range to delete
  34912. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  34913. */
  34914. deleteRange(name: string, deleteFrames?: boolean): void;
  34915. /**
  34916. * Gets the animation range by name, or null if not defined
  34917. * @param name Name of the animation range
  34918. * @returns Nullable animation range
  34919. */
  34920. getRange(name: string): Nullable<AnimationRange>;
  34921. /**
  34922. * Gets the key frames from the animation
  34923. * @returns The key frames of the animation
  34924. */
  34925. getKeys(): Array<IAnimationKey>;
  34926. /**
  34927. * Gets the highest frame rate of the animation
  34928. * @returns Highest frame rate of the animation
  34929. */
  34930. getHighestFrame(): number;
  34931. /**
  34932. * Gets the easing function of the animation
  34933. * @returns Easing function of the animation
  34934. */
  34935. getEasingFunction(): IEasingFunction;
  34936. /**
  34937. * Sets the easing function of the animation
  34938. * @param easingFunction A custom mathematical formula for animation
  34939. */
  34940. setEasingFunction(easingFunction: EasingFunction): void;
  34941. /**
  34942. * Interpolates a scalar linearly
  34943. * @param startValue Start value of the animation curve
  34944. * @param endValue End value of the animation curve
  34945. * @param gradient Scalar amount to interpolate
  34946. * @returns Interpolated scalar value
  34947. */
  34948. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  34949. /**
  34950. * Interpolates a scalar cubically
  34951. * @param startValue Start value of the animation curve
  34952. * @param outTangent End tangent of the animation
  34953. * @param endValue End value of the animation curve
  34954. * @param inTangent Start tangent of the animation curve
  34955. * @param gradient Scalar amount to interpolate
  34956. * @returns Interpolated scalar value
  34957. */
  34958. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  34959. /**
  34960. * Interpolates a quaternion using a spherical linear interpolation
  34961. * @param startValue Start value of the animation curve
  34962. * @param endValue End value of the animation curve
  34963. * @param gradient Scalar amount to interpolate
  34964. * @returns Interpolated quaternion value
  34965. */
  34966. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  34967. /**
  34968. * Interpolates a quaternion cubically
  34969. * @param startValue Start value of the animation curve
  34970. * @param outTangent End tangent of the animation curve
  34971. * @param endValue End value of the animation curve
  34972. * @param inTangent Start tangent of the animation curve
  34973. * @param gradient Scalar amount to interpolate
  34974. * @returns Interpolated quaternion value
  34975. */
  34976. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  34977. /**
  34978. * Interpolates a Vector3 linearl
  34979. * @param startValue Start value of the animation curve
  34980. * @param endValue End value of the animation curve
  34981. * @param gradient Scalar amount to interpolate
  34982. * @returns Interpolated scalar value
  34983. */
  34984. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  34985. /**
  34986. * Interpolates a Vector3 cubically
  34987. * @param startValue Start value of the animation curve
  34988. * @param outTangent End tangent of the animation
  34989. * @param endValue End value of the animation curve
  34990. * @param inTangent Start tangent of the animation curve
  34991. * @param gradient Scalar amount to interpolate
  34992. * @returns InterpolatedVector3 value
  34993. */
  34994. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  34995. /**
  34996. * Interpolates a Vector2 linearly
  34997. * @param startValue Start value of the animation curve
  34998. * @param endValue End value of the animation curve
  34999. * @param gradient Scalar amount to interpolate
  35000. * @returns Interpolated Vector2 value
  35001. */
  35002. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  35003. /**
  35004. * Interpolates a Vector2 cubically
  35005. * @param startValue Start value of the animation curve
  35006. * @param outTangent End tangent of the animation
  35007. * @param endValue End value of the animation curve
  35008. * @param inTangent Start tangent of the animation curve
  35009. * @param gradient Scalar amount to interpolate
  35010. * @returns Interpolated Vector2 value
  35011. */
  35012. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  35013. /**
  35014. * Interpolates a size linearly
  35015. * @param startValue Start value of the animation curve
  35016. * @param endValue End value of the animation curve
  35017. * @param gradient Scalar amount to interpolate
  35018. * @returns Interpolated Size value
  35019. */
  35020. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  35021. /**
  35022. * Interpolates a Color3 linearly
  35023. * @param startValue Start value of the animation curve
  35024. * @param endValue End value of the animation curve
  35025. * @param gradient Scalar amount to interpolate
  35026. * @returns Interpolated Color3 value
  35027. */
  35028. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  35029. /**
  35030. * Interpolates a Color4 linearly
  35031. * @param startValue Start value of the animation curve
  35032. * @param endValue End value of the animation curve
  35033. * @param gradient Scalar amount to interpolate
  35034. * @returns Interpolated Color3 value
  35035. */
  35036. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  35037. /**
  35038. * @hidden Internal use only
  35039. */
  35040. _getKeyValue(value: any): any;
  35041. /**
  35042. * @hidden Internal use only
  35043. */
  35044. _interpolate(currentFrame: number, state: _IAnimationState): any;
  35045. /**
  35046. * Defines the function to use to interpolate matrices
  35047. * @param startValue defines the start matrix
  35048. * @param endValue defines the end matrix
  35049. * @param gradient defines the gradient between both matrices
  35050. * @param result defines an optional target matrix where to store the interpolation
  35051. * @returns the interpolated matrix
  35052. */
  35053. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  35054. /**
  35055. * Makes a copy of the animation
  35056. * @returns Cloned animation
  35057. */
  35058. clone(): Animation;
  35059. /**
  35060. * Sets the key frames of the animation
  35061. * @param values The animation key frames to set
  35062. */
  35063. setKeys(values: Array<IAnimationKey>): void;
  35064. /**
  35065. * Serializes the animation to an object
  35066. * @returns Serialized object
  35067. */
  35068. serialize(): any;
  35069. /**
  35070. * Float animation type
  35071. */
  35072. static readonly ANIMATIONTYPE_FLOAT: number;
  35073. /**
  35074. * Vector3 animation type
  35075. */
  35076. static readonly ANIMATIONTYPE_VECTOR3: number;
  35077. /**
  35078. * Quaternion animation type
  35079. */
  35080. static readonly ANIMATIONTYPE_QUATERNION: number;
  35081. /**
  35082. * Matrix animation type
  35083. */
  35084. static readonly ANIMATIONTYPE_MATRIX: number;
  35085. /**
  35086. * Color3 animation type
  35087. */
  35088. static readonly ANIMATIONTYPE_COLOR3: number;
  35089. /**
  35090. * Color3 animation type
  35091. */
  35092. static readonly ANIMATIONTYPE_COLOR4: number;
  35093. /**
  35094. * Vector2 animation type
  35095. */
  35096. static readonly ANIMATIONTYPE_VECTOR2: number;
  35097. /**
  35098. * Size animation type
  35099. */
  35100. static readonly ANIMATIONTYPE_SIZE: number;
  35101. /**
  35102. * Relative Loop Mode
  35103. */
  35104. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  35105. /**
  35106. * Cycle Loop Mode
  35107. */
  35108. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  35109. /**
  35110. * Constant Loop Mode
  35111. */
  35112. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  35113. /** @hidden */
  35114. static _UniversalLerp(left: any, right: any, amount: number): any;
  35115. /**
  35116. * Parses an animation object and creates an animation
  35117. * @param parsedAnimation Parsed animation object
  35118. * @returns Animation object
  35119. */
  35120. static Parse(parsedAnimation: any): Animation;
  35121. /**
  35122. * Appends the serialized animations from the source animations
  35123. * @param source Source containing the animations
  35124. * @param destination Target to store the animations
  35125. */
  35126. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35127. /**
  35128. * Creates a new animation or an array of animations from a snippet saved in a remote file
  35129. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  35130. * @param url defines the url to load from
  35131. * @returns a promise that will resolve to the new animation or an array of animations
  35132. */
  35133. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  35134. /**
  35135. * Creates an animation or an array of animations from a snippet saved by the Inspector
  35136. * @param snippetId defines the snippet to load
  35137. * @returns a promise that will resolve to the new animation or a new array of animations
  35138. */
  35139. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  35140. }
  35141. }
  35142. declare module "babylonjs/Animations/animatable.interface" {
  35143. import { Nullable } from "babylonjs/types";
  35144. import { Animation } from "babylonjs/Animations/animation";
  35145. /**
  35146. * Interface containing an array of animations
  35147. */
  35148. export interface IAnimatable {
  35149. /**
  35150. * Array of animations
  35151. */
  35152. animations: Nullable<Array<Animation>>;
  35153. }
  35154. }
  35155. declare module "babylonjs/Misc/decorators" {
  35156. import { Nullable } from "babylonjs/types";
  35157. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35158. import { Scene } from "babylonjs/scene";
  35159. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  35160. import { FresnelParameters } from "babylonjs/Materials/fresnelParameters";
  35161. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  35162. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35163. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  35164. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35165. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35166. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35167. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35168. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35169. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35170. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35171. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35172. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35173. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35174. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35175. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35176. /**
  35177. * Decorator used to define property that can be serialized as reference to a camera
  35178. * @param sourceName defines the name of the property to decorate
  35179. */
  35180. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  35181. /**
  35182. * Class used to help serialization objects
  35183. */
  35184. export class SerializationHelper {
  35185. /** @hidden */
  35186. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  35187. /** @hidden */
  35188. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  35189. /** @hidden */
  35190. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  35191. /** @hidden */
  35192. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  35193. /**
  35194. * Appends the serialized animations from the source animations
  35195. * @param source Source containing the animations
  35196. * @param destination Target to store the animations
  35197. */
  35198. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  35199. /**
  35200. * Static function used to serialized a specific entity
  35201. * @param entity defines the entity to serialize
  35202. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  35203. * @returns a JSON compatible object representing the serialization of the entity
  35204. */
  35205. static Serialize<T>(entity: T, serializationObject?: any): any;
  35206. /**
  35207. * Creates a new entity from a serialization data object
  35208. * @param creationFunction defines a function used to instanciated the new entity
  35209. * @param source defines the source serialization data
  35210. * @param scene defines the hosting scene
  35211. * @param rootUrl defines the root url for resources
  35212. * @returns a new entity
  35213. */
  35214. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  35215. /**
  35216. * Clones an object
  35217. * @param creationFunction defines the function used to instanciate the new object
  35218. * @param source defines the source object
  35219. * @returns the cloned object
  35220. */
  35221. static Clone<T>(creationFunction: () => T, source: T): T;
  35222. /**
  35223. * Instanciates a new object based on a source one (some data will be shared between both object)
  35224. * @param creationFunction defines the function used to instanciate the new object
  35225. * @param source defines the source object
  35226. * @returns the new object
  35227. */
  35228. static Instanciate<T>(creationFunction: () => T, source: T): T;
  35229. }
  35230. }
  35231. declare module "babylonjs/Materials/Textures/baseTexture" {
  35232. import { Observable } from "babylonjs/Misc/observable";
  35233. import { Nullable } from "babylonjs/types";
  35234. import { Scene } from "babylonjs/scene";
  35235. import { Matrix } from "babylonjs/Maths/math.vector";
  35236. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35237. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  35238. import { ISize } from "babylonjs/Maths/math.size";
  35239. import "babylonjs/Misc/fileTools";
  35240. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35241. /**
  35242. * Base class of all the textures in babylon.
  35243. * It groups all the common properties the materials, post process, lights... might need
  35244. * in order to make a correct use of the texture.
  35245. */
  35246. export class BaseTexture implements IAnimatable {
  35247. /**
  35248. * Default anisotropic filtering level for the application.
  35249. * It is set to 4 as a good tradeoff between perf and quality.
  35250. */
  35251. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  35252. /**
  35253. * Gets or sets the unique id of the texture
  35254. */
  35255. uniqueId: number;
  35256. /**
  35257. * Define the name of the texture.
  35258. */
  35259. name: string;
  35260. /**
  35261. * Gets or sets an object used to store user defined information.
  35262. */
  35263. metadata: any;
  35264. /**
  35265. * For internal use only. Please do not use.
  35266. */
  35267. reservedDataStore: any;
  35268. private _hasAlpha;
  35269. /**
  35270. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  35271. */
  35272. set hasAlpha(value: boolean);
  35273. get hasAlpha(): boolean;
  35274. /**
  35275. * Defines if the alpha value should be determined via the rgb values.
  35276. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  35277. */
  35278. getAlphaFromRGB: boolean;
  35279. /**
  35280. * Intensity or strength of the texture.
  35281. * It is commonly used by materials to fine tune the intensity of the texture
  35282. */
  35283. level: number;
  35284. /**
  35285. * Define the UV chanel to use starting from 0 and defaulting to 0.
  35286. * This is part of the texture as textures usually maps to one uv set.
  35287. */
  35288. coordinatesIndex: number;
  35289. protected _coordinatesMode: number;
  35290. /**
  35291. * How a texture is mapped.
  35292. *
  35293. * | Value | Type | Description |
  35294. * | ----- | ----------------------------------- | ----------- |
  35295. * | 0 | EXPLICIT_MODE | |
  35296. * | 1 | SPHERICAL_MODE | |
  35297. * | 2 | PLANAR_MODE | |
  35298. * | 3 | CUBIC_MODE | |
  35299. * | 4 | PROJECTION_MODE | |
  35300. * | 5 | SKYBOX_MODE | |
  35301. * | 6 | INVCUBIC_MODE | |
  35302. * | 7 | EQUIRECTANGULAR_MODE | |
  35303. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  35304. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  35305. */
  35306. set coordinatesMode(value: number);
  35307. get coordinatesMode(): number;
  35308. private _wrapU;
  35309. /**
  35310. * | Value | Type | Description |
  35311. * | ----- | ------------------ | ----------- |
  35312. * | 0 | CLAMP_ADDRESSMODE | |
  35313. * | 1 | WRAP_ADDRESSMODE | |
  35314. * | 2 | MIRROR_ADDRESSMODE | |
  35315. */
  35316. get wrapU(): number;
  35317. set wrapU(value: number);
  35318. private _wrapV;
  35319. /**
  35320. * | Value | Type | Description |
  35321. * | ----- | ------------------ | ----------- |
  35322. * | 0 | CLAMP_ADDRESSMODE | |
  35323. * | 1 | WRAP_ADDRESSMODE | |
  35324. * | 2 | MIRROR_ADDRESSMODE | |
  35325. */
  35326. get wrapV(): number;
  35327. set wrapV(value: number);
  35328. /**
  35329. * | Value | Type | Description |
  35330. * | ----- | ------------------ | ----------- |
  35331. * | 0 | CLAMP_ADDRESSMODE | |
  35332. * | 1 | WRAP_ADDRESSMODE | |
  35333. * | 2 | MIRROR_ADDRESSMODE | |
  35334. */
  35335. wrapR: number;
  35336. /**
  35337. * With compliant hardware and browser (supporting anisotropic filtering)
  35338. * this defines the level of anisotropic filtering in the texture.
  35339. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  35340. */
  35341. anisotropicFilteringLevel: number;
  35342. /**
  35343. * Define if the texture is a cube texture or if false a 2d texture.
  35344. */
  35345. get isCube(): boolean;
  35346. set isCube(value: boolean);
  35347. /**
  35348. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  35349. */
  35350. get is3D(): boolean;
  35351. set is3D(value: boolean);
  35352. /**
  35353. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  35354. */
  35355. get is2DArray(): boolean;
  35356. set is2DArray(value: boolean);
  35357. private _gammaSpace;
  35358. /**
  35359. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  35360. * HDR texture are usually stored in linear space.
  35361. * This only impacts the PBR and Background materials
  35362. */
  35363. get gammaSpace(): boolean;
  35364. set gammaSpace(gamma: boolean);
  35365. /**
  35366. * Gets or sets whether or not the texture contains RGBD data.
  35367. */
  35368. get isRGBD(): boolean;
  35369. set isRGBD(value: boolean);
  35370. /**
  35371. * Is Z inverted in the texture (useful in a cube texture).
  35372. */
  35373. invertZ: boolean;
  35374. /**
  35375. * Are mip maps generated for this texture or not.
  35376. */
  35377. get noMipmap(): boolean;
  35378. /**
  35379. * @hidden
  35380. */
  35381. lodLevelInAlpha: boolean;
  35382. /**
  35383. * With prefiltered texture, defined the offset used during the prefiltering steps.
  35384. */
  35385. get lodGenerationOffset(): number;
  35386. set lodGenerationOffset(value: number);
  35387. /**
  35388. * With prefiltered texture, defined the scale used during the prefiltering steps.
  35389. */
  35390. get lodGenerationScale(): number;
  35391. set lodGenerationScale(value: number);
  35392. /**
  35393. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  35394. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  35395. * average roughness values.
  35396. */
  35397. get linearSpecularLOD(): boolean;
  35398. set linearSpecularLOD(value: boolean);
  35399. /**
  35400. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  35401. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  35402. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  35403. */
  35404. get irradianceTexture(): Nullable<BaseTexture>;
  35405. set irradianceTexture(value: Nullable<BaseTexture>);
  35406. /**
  35407. * Define if the texture is a render target.
  35408. */
  35409. isRenderTarget: boolean;
  35410. /**
  35411. * Define the unique id of the texture in the scene.
  35412. */
  35413. get uid(): string;
  35414. /** @hidden */
  35415. _prefiltered: boolean;
  35416. /**
  35417. * Return a string representation of the texture.
  35418. * @returns the texture as a string
  35419. */
  35420. toString(): string;
  35421. /**
  35422. * Get the class name of the texture.
  35423. * @returns "BaseTexture"
  35424. */
  35425. getClassName(): string;
  35426. /**
  35427. * Define the list of animation attached to the texture.
  35428. */
  35429. animations: import("babylonjs/Animations/animation").Animation[];
  35430. /**
  35431. * An event triggered when the texture is disposed.
  35432. */
  35433. onDisposeObservable: Observable<BaseTexture>;
  35434. private _onDisposeObserver;
  35435. /**
  35436. * Callback triggered when the texture has been disposed.
  35437. * Kept for back compatibility, you can use the onDisposeObservable instead.
  35438. */
  35439. set onDispose(callback: () => void);
  35440. /**
  35441. * Define the current state of the loading sequence when in delayed load mode.
  35442. */
  35443. delayLoadState: number;
  35444. protected _scene: Nullable<Scene>;
  35445. protected _engine: Nullable<ThinEngine>;
  35446. /** @hidden */
  35447. _texture: Nullable<InternalTexture>;
  35448. private _uid;
  35449. /**
  35450. * Define if the texture is preventinga material to render or not.
  35451. * If not and the texture is not ready, the engine will use a default black texture instead.
  35452. */
  35453. get isBlocking(): boolean;
  35454. /**
  35455. * Instantiates a new BaseTexture.
  35456. * Base class of all the textures in babylon.
  35457. * It groups all the common properties the materials, post process, lights... might need
  35458. * in order to make a correct use of the texture.
  35459. * @param sceneOrEngine Define the scene or engine the texture blongs to
  35460. */
  35461. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  35462. /**
  35463. * Get the scene the texture belongs to.
  35464. * @returns the scene or null if undefined
  35465. */
  35466. getScene(): Nullable<Scene>;
  35467. /** @hidden */
  35468. protected _getEngine(): Nullable<ThinEngine>;
  35469. /**
  35470. * Get the texture transform matrix used to offset tile the texture for istance.
  35471. * @returns the transformation matrix
  35472. */
  35473. getTextureMatrix(): Matrix;
  35474. /**
  35475. * Get the texture reflection matrix used to rotate/transform the reflection.
  35476. * @returns the reflection matrix
  35477. */
  35478. getReflectionTextureMatrix(): Matrix;
  35479. /**
  35480. * Get the underlying lower level texture from Babylon.
  35481. * @returns the insternal texture
  35482. */
  35483. getInternalTexture(): Nullable<InternalTexture>;
  35484. /**
  35485. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  35486. * @returns true if ready or not blocking
  35487. */
  35488. isReadyOrNotBlocking(): boolean;
  35489. /**
  35490. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  35491. * @returns true if fully ready
  35492. */
  35493. isReady(): boolean;
  35494. private _cachedSize;
  35495. /**
  35496. * Get the size of the texture.
  35497. * @returns the texture size.
  35498. */
  35499. getSize(): ISize;
  35500. /**
  35501. * Get the base size of the texture.
  35502. * It can be different from the size if the texture has been resized for POT for instance
  35503. * @returns the base size
  35504. */
  35505. getBaseSize(): ISize;
  35506. /**
  35507. * Update the sampling mode of the texture.
  35508. * Default is Trilinear mode.
  35509. *
  35510. * | Value | Type | Description |
  35511. * | ----- | ------------------ | ----------- |
  35512. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  35513. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  35514. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  35515. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  35516. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  35517. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  35518. * | 7 | NEAREST_LINEAR | |
  35519. * | 8 | NEAREST_NEAREST | |
  35520. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  35521. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  35522. * | 11 | LINEAR_LINEAR | |
  35523. * | 12 | LINEAR_NEAREST | |
  35524. *
  35525. * > _mag_: magnification filter (close to the viewer)
  35526. * > _min_: minification filter (far from the viewer)
  35527. * > _mip_: filter used between mip map levels
  35528. *@param samplingMode Define the new sampling mode of the texture
  35529. */
  35530. updateSamplingMode(samplingMode: number): void;
  35531. /**
  35532. * Scales the texture if is `canRescale()`
  35533. * @param ratio the resize factor we want to use to rescale
  35534. */
  35535. scale(ratio: number): void;
  35536. /**
  35537. * Get if the texture can rescale.
  35538. */
  35539. get canRescale(): boolean;
  35540. /** @hidden */
  35541. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  35542. /** @hidden */
  35543. _rebuild(): void;
  35544. /**
  35545. * Triggers the load sequence in delayed load mode.
  35546. */
  35547. delayLoad(): void;
  35548. /**
  35549. * Clones the texture.
  35550. * @returns the cloned texture
  35551. */
  35552. clone(): Nullable<BaseTexture>;
  35553. /**
  35554. * Get the texture underlying type (INT, FLOAT...)
  35555. */
  35556. get textureType(): number;
  35557. /**
  35558. * Get the texture underlying format (RGB, RGBA...)
  35559. */
  35560. get textureFormat(): number;
  35561. /**
  35562. * Indicates that textures need to be re-calculated for all materials
  35563. */
  35564. protected _markAllSubMeshesAsTexturesDirty(): void;
  35565. /**
  35566. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  35567. * This will returns an RGBA array buffer containing either in values (0-255) or
  35568. * float values (0-1) depending of the underlying buffer type.
  35569. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  35570. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  35571. * @param buffer defines a user defined buffer to fill with data (can be null)
  35572. * @returns The Array buffer containing the pixels data.
  35573. */
  35574. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  35575. /**
  35576. * Release and destroy the underlying lower level texture aka internalTexture.
  35577. */
  35578. releaseInternalTexture(): void;
  35579. /** @hidden */
  35580. get _lodTextureHigh(): Nullable<BaseTexture>;
  35581. /** @hidden */
  35582. get _lodTextureMid(): Nullable<BaseTexture>;
  35583. /** @hidden */
  35584. get _lodTextureLow(): Nullable<BaseTexture>;
  35585. /**
  35586. * Dispose the texture and release its associated resources.
  35587. */
  35588. dispose(): void;
  35589. /**
  35590. * Serialize the texture into a JSON representation that can be parsed later on.
  35591. * @returns the JSON representation of the texture
  35592. */
  35593. serialize(): any;
  35594. /**
  35595. * Helper function to be called back once a list of texture contains only ready textures.
  35596. * @param textures Define the list of textures to wait for
  35597. * @param callback Define the callback triggered once the entire list will be ready
  35598. */
  35599. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  35600. private static _isScene;
  35601. }
  35602. }
  35603. declare module "babylonjs/Materials/effect" {
  35604. import { Observable } from "babylonjs/Misc/observable";
  35605. import { Nullable } from "babylonjs/types";
  35606. import { IDisposable } from "babylonjs/scene";
  35607. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  35608. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  35609. import { IMatrixLike, IVector2Like, IVector3Like, IVector4Like, IColor3Like, IColor4Like } from "babylonjs/Maths/math.like";
  35610. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  35611. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  35612. import { Engine } from "babylonjs/Engines/engine";
  35613. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  35614. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  35615. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  35616. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  35617. /**
  35618. * Options to be used when creating an effect.
  35619. */
  35620. export interface IEffectCreationOptions {
  35621. /**
  35622. * Atrributes that will be used in the shader.
  35623. */
  35624. attributes: string[];
  35625. /**
  35626. * Uniform varible names that will be set in the shader.
  35627. */
  35628. uniformsNames: string[];
  35629. /**
  35630. * Uniform buffer variable names that will be set in the shader.
  35631. */
  35632. uniformBuffersNames: string[];
  35633. /**
  35634. * Sampler texture variable names that will be set in the shader.
  35635. */
  35636. samplers: string[];
  35637. /**
  35638. * Define statements that will be set in the shader.
  35639. */
  35640. defines: any;
  35641. /**
  35642. * Possible fallbacks for this effect to improve performance when needed.
  35643. */
  35644. fallbacks: Nullable<IEffectFallbacks>;
  35645. /**
  35646. * Callback that will be called when the shader is compiled.
  35647. */
  35648. onCompiled: Nullable<(effect: Effect) => void>;
  35649. /**
  35650. * Callback that will be called if an error occurs during shader compilation.
  35651. */
  35652. onError: Nullable<(effect: Effect, errors: string) => void>;
  35653. /**
  35654. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35655. */
  35656. indexParameters?: any;
  35657. /**
  35658. * Max number of lights that can be used in the shader.
  35659. */
  35660. maxSimultaneousLights?: number;
  35661. /**
  35662. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  35663. */
  35664. transformFeedbackVaryings?: Nullable<string[]>;
  35665. /**
  35666. * 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
  35667. */
  35668. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  35669. /**
  35670. * Is this effect rendering to several color attachments ?
  35671. */
  35672. multiTarget?: boolean;
  35673. }
  35674. /**
  35675. * Effect containing vertex and fragment shader that can be executed on an object.
  35676. */
  35677. export class Effect implements IDisposable {
  35678. /**
  35679. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  35680. */
  35681. static ShadersRepository: string;
  35682. /**
  35683. * Enable logging of the shader code when a compilation error occurs
  35684. */
  35685. static LogShaderCodeOnCompilationError: boolean;
  35686. /**
  35687. * Name of the effect.
  35688. */
  35689. name: any;
  35690. /**
  35691. * String container all the define statements that should be set on the shader.
  35692. */
  35693. defines: string;
  35694. /**
  35695. * Callback that will be called when the shader is compiled.
  35696. */
  35697. onCompiled: Nullable<(effect: Effect) => void>;
  35698. /**
  35699. * Callback that will be called if an error occurs during shader compilation.
  35700. */
  35701. onError: Nullable<(effect: Effect, errors: string) => void>;
  35702. /**
  35703. * Callback that will be called when effect is bound.
  35704. */
  35705. onBind: Nullable<(effect: Effect) => void>;
  35706. /**
  35707. * Unique ID of the effect.
  35708. */
  35709. uniqueId: number;
  35710. /**
  35711. * Observable that will be called when the shader is compiled.
  35712. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  35713. */
  35714. onCompileObservable: Observable<Effect>;
  35715. /**
  35716. * Observable that will be called if an error occurs during shader compilation.
  35717. */
  35718. onErrorObservable: Observable<Effect>;
  35719. /** @hidden */
  35720. _onBindObservable: Nullable<Observable<Effect>>;
  35721. /**
  35722. * @hidden
  35723. * Specifies if the effect was previously ready
  35724. */
  35725. _wasPreviouslyReady: boolean;
  35726. /**
  35727. * Observable that will be called when effect is bound.
  35728. */
  35729. get onBindObservable(): Observable<Effect>;
  35730. /** @hidden */
  35731. _bonesComputationForcedToCPU: boolean;
  35732. /** @hidden */
  35733. _multiTarget: boolean;
  35734. private static _uniqueIdSeed;
  35735. private _engine;
  35736. private _uniformBuffersNames;
  35737. private _uniformBuffersNamesList;
  35738. private _uniformsNames;
  35739. private _samplerList;
  35740. private _samplers;
  35741. private _isReady;
  35742. private _compilationError;
  35743. private _allFallbacksProcessed;
  35744. private _attributesNames;
  35745. private _attributes;
  35746. private _attributeLocationByName;
  35747. private _uniforms;
  35748. /**
  35749. * Key for the effect.
  35750. * @hidden
  35751. */
  35752. _key: string;
  35753. private _indexParameters;
  35754. private _fallbacks;
  35755. private _vertexSourceCode;
  35756. private _fragmentSourceCode;
  35757. private _vertexSourceCodeOverride;
  35758. private _fragmentSourceCodeOverride;
  35759. private _transformFeedbackVaryings;
  35760. /**
  35761. * Compiled shader to webGL program.
  35762. * @hidden
  35763. */
  35764. _pipelineContext: Nullable<IPipelineContext>;
  35765. private _valueCache;
  35766. private static _baseCache;
  35767. /**
  35768. * Instantiates an effect.
  35769. * An effect can be used to create/manage/execute vertex and fragment shaders.
  35770. * @param baseName Name of the effect.
  35771. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  35772. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  35773. * @param samplers List of sampler variables that will be passed to the shader.
  35774. * @param engine Engine to be used to render the effect
  35775. * @param defines Define statements to be added to the shader.
  35776. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  35777. * @param onCompiled Callback that will be called when the shader is compiled.
  35778. * @param onError Callback that will be called if an error occurs during shader compilation.
  35779. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  35780. */
  35781. 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);
  35782. private _useFinalCode;
  35783. /**
  35784. * Unique key for this effect
  35785. */
  35786. get key(): string;
  35787. /**
  35788. * If the effect has been compiled and prepared.
  35789. * @returns if the effect is compiled and prepared.
  35790. */
  35791. isReady(): boolean;
  35792. private _isReadyInternal;
  35793. /**
  35794. * The engine the effect was initialized with.
  35795. * @returns the engine.
  35796. */
  35797. getEngine(): Engine;
  35798. /**
  35799. * The pipeline context for this effect
  35800. * @returns the associated pipeline context
  35801. */
  35802. getPipelineContext(): Nullable<IPipelineContext>;
  35803. /**
  35804. * The set of names of attribute variables for the shader.
  35805. * @returns An array of attribute names.
  35806. */
  35807. getAttributesNames(): string[];
  35808. /**
  35809. * Returns the attribute at the given index.
  35810. * @param index The index of the attribute.
  35811. * @returns The location of the attribute.
  35812. */
  35813. getAttributeLocation(index: number): number;
  35814. /**
  35815. * Returns the attribute based on the name of the variable.
  35816. * @param name of the attribute to look up.
  35817. * @returns the attribute location.
  35818. */
  35819. getAttributeLocationByName(name: string): number;
  35820. /**
  35821. * The number of attributes.
  35822. * @returns the numnber of attributes.
  35823. */
  35824. getAttributesCount(): number;
  35825. /**
  35826. * Gets the index of a uniform variable.
  35827. * @param uniformName of the uniform to look up.
  35828. * @returns the index.
  35829. */
  35830. getUniformIndex(uniformName: string): number;
  35831. /**
  35832. * Returns the attribute based on the name of the variable.
  35833. * @param uniformName of the uniform to look up.
  35834. * @returns the location of the uniform.
  35835. */
  35836. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  35837. /**
  35838. * Returns an array of sampler variable names
  35839. * @returns The array of sampler variable names.
  35840. */
  35841. getSamplers(): string[];
  35842. /**
  35843. * Returns an array of uniform variable names
  35844. * @returns The array of uniform variable names.
  35845. */
  35846. getUniformNames(): string[];
  35847. /**
  35848. * Returns an array of uniform buffer variable names
  35849. * @returns The array of uniform buffer variable names.
  35850. */
  35851. getUniformBuffersNames(): string[];
  35852. /**
  35853. * Returns the index parameters used to create the effect
  35854. * @returns The index parameters object
  35855. */
  35856. getIndexParameters(): any;
  35857. /**
  35858. * The error from the last compilation.
  35859. * @returns the error string.
  35860. */
  35861. getCompilationError(): string;
  35862. /**
  35863. * Gets a boolean indicating that all fallbacks were used during compilation
  35864. * @returns true if all fallbacks were used
  35865. */
  35866. allFallbacksProcessed(): boolean;
  35867. /**
  35868. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  35869. * @param func The callback to be used.
  35870. */
  35871. executeWhenCompiled(func: (effect: Effect) => void): void;
  35872. private _checkIsReady;
  35873. private _loadShader;
  35874. /**
  35875. * Gets the vertex shader source code of this effect
  35876. */
  35877. get vertexSourceCode(): string;
  35878. /**
  35879. * Gets the fragment shader source code of this effect
  35880. */
  35881. get fragmentSourceCode(): string;
  35882. /**
  35883. * Recompiles the webGL program
  35884. * @param vertexSourceCode The source code for the vertex shader.
  35885. * @param fragmentSourceCode The source code for the fragment shader.
  35886. * @param onCompiled Callback called when completed.
  35887. * @param onError Callback called on error.
  35888. * @hidden
  35889. */
  35890. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  35891. /**
  35892. * Prepares the effect
  35893. * @hidden
  35894. */
  35895. _prepareEffect(): void;
  35896. private _getShaderCodeAndErrorLine;
  35897. private _processCompilationErrors;
  35898. /**
  35899. * Checks if the effect is supported. (Must be called after compilation)
  35900. */
  35901. get isSupported(): boolean;
  35902. /**
  35903. * Binds a texture to the engine to be used as output of the shader.
  35904. * @param channel Name of the output variable.
  35905. * @param texture Texture to bind.
  35906. * @hidden
  35907. */
  35908. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  35909. /**
  35910. * Sets a texture on the engine to be used in the shader.
  35911. * @param channel Name of the sampler variable.
  35912. * @param texture Texture to set.
  35913. */
  35914. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  35915. /**
  35916. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  35917. * @param channel Name of the sampler variable.
  35918. * @param texture Texture to set.
  35919. */
  35920. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  35921. /**
  35922. * Sets an array of textures on the engine to be used in the shader.
  35923. * @param channel Name of the variable.
  35924. * @param textures Textures to set.
  35925. */
  35926. setTextureArray(channel: string, textures: BaseTexture[]): void;
  35927. /**
  35928. * 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)
  35929. * @param channel Name of the sampler variable.
  35930. * @param postProcess Post process to get the input texture from.
  35931. */
  35932. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  35933. /**
  35934. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  35935. * 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)
  35936. * @param channel Name of the sampler variable.
  35937. * @param postProcess Post process to get the output texture from.
  35938. */
  35939. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  35940. /** @hidden */
  35941. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  35942. /** @hidden */
  35943. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  35944. /** @hidden */
  35945. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  35946. /** @hidden */
  35947. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  35948. /**
  35949. * Binds a buffer to a uniform.
  35950. * @param buffer Buffer to bind.
  35951. * @param name Name of the uniform variable to bind to.
  35952. */
  35953. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  35954. /**
  35955. * Binds block to a uniform.
  35956. * @param blockName Name of the block to bind.
  35957. * @param index Index to bind.
  35958. */
  35959. bindUniformBlock(blockName: string, index: number): void;
  35960. /**
  35961. * Sets an interger value on a uniform variable.
  35962. * @param uniformName Name of the variable.
  35963. * @param value Value to be set.
  35964. * @returns this effect.
  35965. */
  35966. setInt(uniformName: string, value: number): Effect;
  35967. /**
  35968. * Sets an int array on a uniform variable.
  35969. * @param uniformName Name of the variable.
  35970. * @param array array to be set.
  35971. * @returns this effect.
  35972. */
  35973. setIntArray(uniformName: string, array: Int32Array): Effect;
  35974. /**
  35975. * 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)
  35976. * @param uniformName Name of the variable.
  35977. * @param array array to be set.
  35978. * @returns this effect.
  35979. */
  35980. setIntArray2(uniformName: string, array: Int32Array): Effect;
  35981. /**
  35982. * 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)
  35983. * @param uniformName Name of the variable.
  35984. * @param array array to be set.
  35985. * @returns this effect.
  35986. */
  35987. setIntArray3(uniformName: string, array: Int32Array): Effect;
  35988. /**
  35989. * 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)
  35990. * @param uniformName Name of the variable.
  35991. * @param array array to be set.
  35992. * @returns this effect.
  35993. */
  35994. setIntArray4(uniformName: string, array: Int32Array): Effect;
  35995. /**
  35996. * Sets an float array on a uniform variable.
  35997. * @param uniformName Name of the variable.
  35998. * @param array array to be set.
  35999. * @returns this effect.
  36000. */
  36001. setFloatArray(uniformName: string, array: Float32Array): Effect;
  36002. /**
  36003. * 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)
  36004. * @param uniformName Name of the variable.
  36005. * @param array array to be set.
  36006. * @returns this effect.
  36007. */
  36008. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  36009. /**
  36010. * 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)
  36011. * @param uniformName Name of the variable.
  36012. * @param array array to be set.
  36013. * @returns this effect.
  36014. */
  36015. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  36016. /**
  36017. * 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)
  36018. * @param uniformName Name of the variable.
  36019. * @param array array to be set.
  36020. * @returns this effect.
  36021. */
  36022. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  36023. /**
  36024. * Sets an array on a uniform variable.
  36025. * @param uniformName Name of the variable.
  36026. * @param array array to be set.
  36027. * @returns this effect.
  36028. */
  36029. setArray(uniformName: string, array: number[]): Effect;
  36030. /**
  36031. * 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)
  36032. * @param uniformName Name of the variable.
  36033. * @param array array to be set.
  36034. * @returns this effect.
  36035. */
  36036. setArray2(uniformName: string, array: number[]): Effect;
  36037. /**
  36038. * 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)
  36039. * @param uniformName Name of the variable.
  36040. * @param array array to be set.
  36041. * @returns this effect.
  36042. */
  36043. setArray3(uniformName: string, array: number[]): Effect;
  36044. /**
  36045. * 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)
  36046. * @param uniformName Name of the variable.
  36047. * @param array array to be set.
  36048. * @returns this effect.
  36049. */
  36050. setArray4(uniformName: string, array: number[]): Effect;
  36051. /**
  36052. * Sets matrices on a uniform variable.
  36053. * @param uniformName Name of the variable.
  36054. * @param matrices matrices to be set.
  36055. * @returns this effect.
  36056. */
  36057. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  36058. /**
  36059. * Sets matrix on a uniform variable.
  36060. * @param uniformName Name of the variable.
  36061. * @param matrix matrix to be set.
  36062. * @returns this effect.
  36063. */
  36064. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  36065. /**
  36066. * 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)
  36067. * @param uniformName Name of the variable.
  36068. * @param matrix matrix to be set.
  36069. * @returns this effect.
  36070. */
  36071. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36072. /**
  36073. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  36074. * @param uniformName Name of the variable.
  36075. * @param matrix matrix to be set.
  36076. * @returns this effect.
  36077. */
  36078. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  36079. /**
  36080. * Sets a float on a uniform variable.
  36081. * @param uniformName Name of the variable.
  36082. * @param value value to be set.
  36083. * @returns this effect.
  36084. */
  36085. setFloat(uniformName: string, value: number): Effect;
  36086. /**
  36087. * Sets a boolean on a uniform variable.
  36088. * @param uniformName Name of the variable.
  36089. * @param bool value to be set.
  36090. * @returns this effect.
  36091. */
  36092. setBool(uniformName: string, bool: boolean): Effect;
  36093. /**
  36094. * Sets a Vector2 on a uniform variable.
  36095. * @param uniformName Name of the variable.
  36096. * @param vector2 vector2 to be set.
  36097. * @returns this effect.
  36098. */
  36099. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  36100. /**
  36101. * Sets a float2 on a uniform variable.
  36102. * @param uniformName Name of the variable.
  36103. * @param x First float in float2.
  36104. * @param y Second float in float2.
  36105. * @returns this effect.
  36106. */
  36107. setFloat2(uniformName: string, x: number, y: number): Effect;
  36108. /**
  36109. * Sets a Vector3 on a uniform variable.
  36110. * @param uniformName Name of the variable.
  36111. * @param vector3 Value to be set.
  36112. * @returns this effect.
  36113. */
  36114. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  36115. /**
  36116. * Sets a float3 on a uniform variable.
  36117. * @param uniformName Name of the variable.
  36118. * @param x First float in float3.
  36119. * @param y Second float in float3.
  36120. * @param z Third float in float3.
  36121. * @returns this effect.
  36122. */
  36123. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  36124. /**
  36125. * Sets a Vector4 on a uniform variable.
  36126. * @param uniformName Name of the variable.
  36127. * @param vector4 Value to be set.
  36128. * @returns this effect.
  36129. */
  36130. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  36131. /**
  36132. * Sets a float4 on a uniform variable.
  36133. * @param uniformName Name of the variable.
  36134. * @param x First float in float4.
  36135. * @param y Second float in float4.
  36136. * @param z Third float in float4.
  36137. * @param w Fourth float in float4.
  36138. * @returns this effect.
  36139. */
  36140. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  36141. /**
  36142. * Sets a Color3 on a uniform variable.
  36143. * @param uniformName Name of the variable.
  36144. * @param color3 Value to be set.
  36145. * @returns this effect.
  36146. */
  36147. setColor3(uniformName: string, color3: IColor3Like): Effect;
  36148. /**
  36149. * Sets a Color4 on a uniform variable.
  36150. * @param uniformName Name of the variable.
  36151. * @param color3 Value to be set.
  36152. * @param alpha Alpha value to be set.
  36153. * @returns this effect.
  36154. */
  36155. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  36156. /**
  36157. * Sets a Color4 on a uniform variable
  36158. * @param uniformName defines the name of the variable
  36159. * @param color4 defines the value to be set
  36160. * @returns this effect.
  36161. */
  36162. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  36163. /** Release all associated resources */
  36164. dispose(): void;
  36165. /**
  36166. * This function will add a new shader to the shader store
  36167. * @param name the name of the shader
  36168. * @param pixelShader optional pixel shader content
  36169. * @param vertexShader optional vertex shader content
  36170. */
  36171. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  36172. /**
  36173. * Store of each shader (The can be looked up using effect.key)
  36174. */
  36175. static ShadersStore: {
  36176. [key: string]: string;
  36177. };
  36178. /**
  36179. * Store of each included file for a shader (The can be looked up using effect.key)
  36180. */
  36181. static IncludesShadersStore: {
  36182. [key: string]: string;
  36183. };
  36184. /**
  36185. * Resets the cache of effects.
  36186. */
  36187. static ResetCache(): void;
  36188. }
  36189. }
  36190. declare module "babylonjs/Engines/engineCapabilities" {
  36191. /**
  36192. * Interface used to describe the capabilities of the engine relatively to the current browser
  36193. */
  36194. export interface EngineCapabilities {
  36195. /** Maximum textures units per fragment shader */
  36196. maxTexturesImageUnits: number;
  36197. /** Maximum texture units per vertex shader */
  36198. maxVertexTextureImageUnits: number;
  36199. /** Maximum textures units in the entire pipeline */
  36200. maxCombinedTexturesImageUnits: number;
  36201. /** Maximum texture size */
  36202. maxTextureSize: number;
  36203. /** Maximum texture samples */
  36204. maxSamples?: number;
  36205. /** Maximum cube texture size */
  36206. maxCubemapTextureSize: number;
  36207. /** Maximum render texture size */
  36208. maxRenderTextureSize: number;
  36209. /** Maximum number of vertex attributes */
  36210. maxVertexAttribs: number;
  36211. /** Maximum number of varyings */
  36212. maxVaryingVectors: number;
  36213. /** Maximum number of uniforms per vertex shader */
  36214. maxVertexUniformVectors: number;
  36215. /** Maximum number of uniforms per fragment shader */
  36216. maxFragmentUniformVectors: number;
  36217. /** Defines if standard derivates (dx/dy) are supported */
  36218. standardDerivatives: boolean;
  36219. /** Defines if s3tc texture compression is supported */
  36220. s3tc?: WEBGL_compressed_texture_s3tc;
  36221. /** Defines if pvrtc texture compression is supported */
  36222. pvrtc: any;
  36223. /** Defines if etc1 texture compression is supported */
  36224. etc1: any;
  36225. /** Defines if etc2 texture compression is supported */
  36226. etc2: any;
  36227. /** Defines if astc texture compression is supported */
  36228. astc: any;
  36229. /** Defines if bptc texture compression is supported */
  36230. bptc: any;
  36231. /** Defines if float textures are supported */
  36232. textureFloat: boolean;
  36233. /** Defines if vertex array objects are supported */
  36234. vertexArrayObject: boolean;
  36235. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  36236. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  36237. /** Gets the maximum level of anisotropy supported */
  36238. maxAnisotropy: number;
  36239. /** Defines if instancing is supported */
  36240. instancedArrays: boolean;
  36241. /** Defines if 32 bits indices are supported */
  36242. uintIndices: boolean;
  36243. /** Defines if high precision shaders are supported */
  36244. highPrecisionShaderSupported: boolean;
  36245. /** Defines if depth reading in the fragment shader is supported */
  36246. fragmentDepthSupported: boolean;
  36247. /** Defines if float texture linear filtering is supported*/
  36248. textureFloatLinearFiltering: boolean;
  36249. /** Defines if rendering to float textures is supported */
  36250. textureFloatRender: boolean;
  36251. /** Defines if half float textures are supported*/
  36252. textureHalfFloat: boolean;
  36253. /** Defines if half float texture linear filtering is supported*/
  36254. textureHalfFloatLinearFiltering: boolean;
  36255. /** Defines if rendering to half float textures is supported */
  36256. textureHalfFloatRender: boolean;
  36257. /** Defines if textureLOD shader command is supported */
  36258. textureLOD: boolean;
  36259. /** Defines if draw buffers extension is supported */
  36260. drawBuffersExtension: boolean;
  36261. /** Defines if depth textures are supported */
  36262. depthTextureExtension: boolean;
  36263. /** Defines if float color buffer are supported */
  36264. colorBufferFloat: boolean;
  36265. /** Gets disjoint timer query extension (null if not supported) */
  36266. timerQuery?: EXT_disjoint_timer_query;
  36267. /** Defines if timestamp can be used with timer query */
  36268. canUseTimestampForTimerQuery: boolean;
  36269. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  36270. multiview?: any;
  36271. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  36272. oculusMultiview?: any;
  36273. /** Function used to let the system compiles shaders in background */
  36274. parallelShaderCompile?: {
  36275. COMPLETION_STATUS_KHR: number;
  36276. };
  36277. /** Max number of texture samples for MSAA */
  36278. maxMSAASamples: number;
  36279. /** Defines if the blend min max extension is supported */
  36280. blendMinMax: boolean;
  36281. }
  36282. }
  36283. declare module "babylonjs/States/depthCullingState" {
  36284. import { Nullable } from "babylonjs/types";
  36285. /**
  36286. * @hidden
  36287. **/
  36288. export class DepthCullingState {
  36289. private _isDepthTestDirty;
  36290. private _isDepthMaskDirty;
  36291. private _isDepthFuncDirty;
  36292. private _isCullFaceDirty;
  36293. private _isCullDirty;
  36294. private _isZOffsetDirty;
  36295. private _isFrontFaceDirty;
  36296. private _depthTest;
  36297. private _depthMask;
  36298. private _depthFunc;
  36299. private _cull;
  36300. private _cullFace;
  36301. private _zOffset;
  36302. private _frontFace;
  36303. /**
  36304. * Initializes the state.
  36305. */
  36306. constructor();
  36307. get isDirty(): boolean;
  36308. get zOffset(): number;
  36309. set zOffset(value: number);
  36310. get cullFace(): Nullable<number>;
  36311. set cullFace(value: Nullable<number>);
  36312. get cull(): Nullable<boolean>;
  36313. set cull(value: Nullable<boolean>);
  36314. get depthFunc(): Nullable<number>;
  36315. set depthFunc(value: Nullable<number>);
  36316. get depthMask(): boolean;
  36317. set depthMask(value: boolean);
  36318. get depthTest(): boolean;
  36319. set depthTest(value: boolean);
  36320. get frontFace(): Nullable<number>;
  36321. set frontFace(value: Nullable<number>);
  36322. reset(): void;
  36323. apply(gl: WebGLRenderingContext): void;
  36324. }
  36325. }
  36326. declare module "babylonjs/States/stencilState" {
  36327. /**
  36328. * @hidden
  36329. **/
  36330. export class StencilState {
  36331. /** 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 */
  36332. static readonly ALWAYS: number;
  36333. /** Passed to stencilOperation to specify that stencil value must be kept */
  36334. static readonly KEEP: number;
  36335. /** Passed to stencilOperation to specify that stencil value must be replaced */
  36336. static readonly REPLACE: number;
  36337. private _isStencilTestDirty;
  36338. private _isStencilMaskDirty;
  36339. private _isStencilFuncDirty;
  36340. private _isStencilOpDirty;
  36341. private _stencilTest;
  36342. private _stencilMask;
  36343. private _stencilFunc;
  36344. private _stencilFuncRef;
  36345. private _stencilFuncMask;
  36346. private _stencilOpStencilFail;
  36347. private _stencilOpDepthFail;
  36348. private _stencilOpStencilDepthPass;
  36349. get isDirty(): boolean;
  36350. get stencilFunc(): number;
  36351. set stencilFunc(value: number);
  36352. get stencilFuncRef(): number;
  36353. set stencilFuncRef(value: number);
  36354. get stencilFuncMask(): number;
  36355. set stencilFuncMask(value: number);
  36356. get stencilOpStencilFail(): number;
  36357. set stencilOpStencilFail(value: number);
  36358. get stencilOpDepthFail(): number;
  36359. set stencilOpDepthFail(value: number);
  36360. get stencilOpStencilDepthPass(): number;
  36361. set stencilOpStencilDepthPass(value: number);
  36362. get stencilMask(): number;
  36363. set stencilMask(value: number);
  36364. get stencilTest(): boolean;
  36365. set stencilTest(value: boolean);
  36366. constructor();
  36367. reset(): void;
  36368. apply(gl: WebGLRenderingContext): void;
  36369. }
  36370. }
  36371. declare module "babylonjs/States/alphaCullingState" {
  36372. /**
  36373. * @hidden
  36374. **/
  36375. export class AlphaState {
  36376. private _isAlphaBlendDirty;
  36377. private _isBlendFunctionParametersDirty;
  36378. private _isBlendEquationParametersDirty;
  36379. private _isBlendConstantsDirty;
  36380. private _alphaBlend;
  36381. private _blendFunctionParameters;
  36382. private _blendEquationParameters;
  36383. private _blendConstants;
  36384. /**
  36385. * Initializes the state.
  36386. */
  36387. constructor();
  36388. get isDirty(): boolean;
  36389. get alphaBlend(): boolean;
  36390. set alphaBlend(value: boolean);
  36391. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  36392. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  36393. setAlphaEquationParameters(rgb: number, alpha: number): void;
  36394. reset(): void;
  36395. apply(gl: WebGLRenderingContext): void;
  36396. }
  36397. }
  36398. declare module "babylonjs/Engines/WebGL/webGL2ShaderProcessors" {
  36399. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36400. /** @hidden */
  36401. export class WebGL2ShaderProcessor implements IShaderProcessor {
  36402. attributeProcessor(attribute: string): string;
  36403. varyingProcessor(varying: string, isFragment: boolean): string;
  36404. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  36405. }
  36406. }
  36407. declare module "babylonjs/Engines/instancingAttributeInfo" {
  36408. /**
  36409. * Interface for attribute information associated with buffer instanciation
  36410. */
  36411. export interface InstancingAttributeInfo {
  36412. /**
  36413. * Name of the GLSL attribute
  36414. * if attribute index is not specified, this is used to retrieve the index from the effect
  36415. */
  36416. attributeName: string;
  36417. /**
  36418. * Index/offset of the attribute in the vertex shader
  36419. * if not specified, this will be computes from the name.
  36420. */
  36421. index?: number;
  36422. /**
  36423. * size of the attribute, 1, 2, 3 or 4
  36424. */
  36425. attributeSize: number;
  36426. /**
  36427. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  36428. */
  36429. offset: number;
  36430. /**
  36431. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  36432. * default to 1
  36433. */
  36434. divisor?: number;
  36435. /**
  36436. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  36437. * default is FLOAT
  36438. */
  36439. attributeType?: number;
  36440. /**
  36441. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  36442. */
  36443. normalized?: boolean;
  36444. }
  36445. }
  36446. declare module "babylonjs/Engines/Extensions/engine.videoTexture" {
  36447. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36448. import { Nullable } from "babylonjs/types";
  36449. module "babylonjs/Engines/thinEngine" {
  36450. interface ThinEngine {
  36451. /**
  36452. * Update a video texture
  36453. * @param texture defines the texture to update
  36454. * @param video defines the video element to use
  36455. * @param invertY defines if data must be stored with Y axis inverted
  36456. */
  36457. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  36458. }
  36459. }
  36460. }
  36461. declare module "babylonjs/Engines/Extensions/engine.dynamicTexture" {
  36462. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36463. import { Nullable } from "babylonjs/types";
  36464. module "babylonjs/Engines/thinEngine" {
  36465. interface ThinEngine {
  36466. /**
  36467. * Creates a dynamic texture
  36468. * @param width defines the width of the texture
  36469. * @param height defines the height of the texture
  36470. * @param generateMipMaps defines if the engine should generate the mip levels
  36471. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  36472. * @returns the dynamic texture inside an InternalTexture
  36473. */
  36474. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  36475. /**
  36476. * Update the content of a dynamic texture
  36477. * @param texture defines the texture to update
  36478. * @param canvas defines the canvas containing the source
  36479. * @param invertY defines if data must be stored with Y axis inverted
  36480. * @param premulAlpha defines if alpha is stored as premultiplied
  36481. * @param format defines the format of the data
  36482. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  36483. */
  36484. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  36485. }
  36486. }
  36487. }
  36488. declare module "babylonjs/Materials/Textures/videoTexture" {
  36489. import { Observable } from "babylonjs/Misc/observable";
  36490. import { Nullable } from "babylonjs/types";
  36491. import { Scene } from "babylonjs/scene";
  36492. import { Texture } from "babylonjs/Materials/Textures/texture";
  36493. import "babylonjs/Engines/Extensions/engine.videoTexture";
  36494. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  36495. /**
  36496. * Settings for finer control over video usage
  36497. */
  36498. export interface VideoTextureSettings {
  36499. /**
  36500. * Applies `autoplay` to video, if specified
  36501. */
  36502. autoPlay?: boolean;
  36503. /**
  36504. * Applies `loop` to video, if specified
  36505. */
  36506. loop?: boolean;
  36507. /**
  36508. * Automatically updates internal texture from video at every frame in the render loop
  36509. */
  36510. autoUpdateTexture: boolean;
  36511. /**
  36512. * Image src displayed during the video loading or until the user interacts with the video.
  36513. */
  36514. poster?: string;
  36515. }
  36516. /**
  36517. * If you want to display a video in your scene, this is the special texture for that.
  36518. * This special texture works similar to other textures, with the exception of a few parameters.
  36519. * @see https://doc.babylonjs.com/how_to/video_texture
  36520. */
  36521. export class VideoTexture extends Texture {
  36522. /**
  36523. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  36524. */
  36525. readonly autoUpdateTexture: boolean;
  36526. /**
  36527. * The video instance used by the texture internally
  36528. */
  36529. readonly video: HTMLVideoElement;
  36530. private _onUserActionRequestedObservable;
  36531. /**
  36532. * Event triggerd when a dom action is required by the user to play the video.
  36533. * This happens due to recent changes in browser policies preventing video to auto start.
  36534. */
  36535. get onUserActionRequestedObservable(): Observable<Texture>;
  36536. private _generateMipMaps;
  36537. private _stillImageCaptured;
  36538. private _displayingPosterTexture;
  36539. private _settings;
  36540. private _createInternalTextureOnEvent;
  36541. private _frameId;
  36542. private _currentSrc;
  36543. /**
  36544. * Creates a video texture.
  36545. * If you want to display a video in your scene, this is the special texture for that.
  36546. * This special texture works similar to other textures, with the exception of a few parameters.
  36547. * @see https://doc.babylonjs.com/how_to/video_texture
  36548. * @param name optional name, will detect from video source, if not defined
  36549. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  36550. * @param scene is obviously the current scene.
  36551. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  36552. * @param invertY is false by default but can be used to invert video on Y axis
  36553. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  36554. * @param settings allows finer control over video usage
  36555. */
  36556. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  36557. private _getName;
  36558. private _getVideo;
  36559. private _createInternalTexture;
  36560. private reset;
  36561. /**
  36562. * @hidden Internal method to initiate `update`.
  36563. */
  36564. _rebuild(): void;
  36565. /**
  36566. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  36567. */
  36568. update(): void;
  36569. /**
  36570. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  36571. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  36572. */
  36573. updateTexture(isVisible: boolean): void;
  36574. protected _updateInternalTexture: () => void;
  36575. /**
  36576. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  36577. * @param url New url.
  36578. */
  36579. updateURL(url: string): void;
  36580. /**
  36581. * Clones the texture.
  36582. * @returns the cloned texture
  36583. */
  36584. clone(): VideoTexture;
  36585. /**
  36586. * Dispose the texture and release its associated resources.
  36587. */
  36588. dispose(): void;
  36589. /**
  36590. * Creates a video texture straight from a stream.
  36591. * @param scene Define the scene the texture should be created in
  36592. * @param stream Define the stream the texture should be created from
  36593. * @returns The created video texture as a promise
  36594. */
  36595. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  36596. /**
  36597. * Creates a video texture straight from your WebCam video feed.
  36598. * @param scene Define the scene the texture should be created in
  36599. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36600. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36601. * @returns The created video texture as a promise
  36602. */
  36603. static CreateFromWebCamAsync(scene: Scene, constraints: {
  36604. minWidth: number;
  36605. maxWidth: number;
  36606. minHeight: number;
  36607. maxHeight: number;
  36608. deviceId: string;
  36609. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  36610. /**
  36611. * Creates a video texture straight from your WebCam video feed.
  36612. * @param scene Define the scene the texture should be created in
  36613. * @param onReady Define a callback to triggered once the texture will be ready
  36614. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  36615. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  36616. */
  36617. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  36618. minWidth: number;
  36619. maxWidth: number;
  36620. minHeight: number;
  36621. maxHeight: number;
  36622. deviceId: string;
  36623. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  36624. }
  36625. }
  36626. declare module "babylonjs/Engines/thinEngine" {
  36627. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  36628. import { Effect, IEffectCreationOptions } from "babylonjs/Materials/effect";
  36629. import { IShaderProcessor } from "babylonjs/Engines/Processors/iShaderProcessor";
  36630. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  36631. import { Nullable, DataArray, IndicesArray } from "babylonjs/types";
  36632. import { EngineCapabilities } from "babylonjs/Engines/engineCapabilities";
  36633. import { Observable } from "babylonjs/Misc/observable";
  36634. import { DepthCullingState } from "babylonjs/States/depthCullingState";
  36635. import { StencilState } from "babylonjs/States/stencilState";
  36636. import { AlphaState } from "babylonjs/States/alphaCullingState";
  36637. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  36638. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  36639. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  36640. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  36641. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  36642. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  36643. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  36644. import { InstancingAttributeInfo } from "babylonjs/Engines/instancingAttributeInfo";
  36645. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  36646. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  36647. import { IEffectFallbacks } from "babylonjs/Materials/iEffectFallbacks";
  36648. import { IWebRequest } from "babylonjs/Misc/interfaces/iWebRequest";
  36649. import { WebRequest } from "babylonjs/Misc/webRequest";
  36650. import { LoadFileError } from "babylonjs/Misc/fileTools";
  36651. /**
  36652. * Defines the interface used by objects working like Scene
  36653. * @hidden
  36654. */
  36655. export interface ISceneLike {
  36656. _addPendingData(data: any): void;
  36657. _removePendingData(data: any): void;
  36658. offlineProvider: IOfflineProvider;
  36659. }
  36660. /**
  36661. * Information about the current host
  36662. */
  36663. export interface HostInformation {
  36664. /**
  36665. * Defines if the current host is a mobile
  36666. */
  36667. isMobile: boolean;
  36668. }
  36669. /** Interface defining initialization parameters for Engine class */
  36670. export interface EngineOptions extends WebGLContextAttributes {
  36671. /**
  36672. * Defines if the engine should no exceed a specified device ratio
  36673. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  36674. */
  36675. limitDeviceRatio?: number;
  36676. /**
  36677. * Defines if webvr should be enabled automatically
  36678. * @see https://doc.babylonjs.com/how_to/webvr_camera
  36679. */
  36680. autoEnableWebVR?: boolean;
  36681. /**
  36682. * Defines if webgl2 should be turned off even if supported
  36683. * @see https://doc.babylonjs.com/features/webgl2
  36684. */
  36685. disableWebGL2Support?: boolean;
  36686. /**
  36687. * Defines if webaudio should be initialized as well
  36688. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  36689. */
  36690. audioEngine?: boolean;
  36691. /**
  36692. * Defines if animations should run using a deterministic lock step
  36693. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  36694. */
  36695. deterministicLockstep?: boolean;
  36696. /** Defines the maximum steps to use with deterministic lock step mode */
  36697. lockstepMaxSteps?: number;
  36698. /** Defines the seconds between each deterministic lock step */
  36699. timeStep?: number;
  36700. /**
  36701. * Defines that engine should ignore context lost events
  36702. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  36703. */
  36704. doNotHandleContextLost?: boolean;
  36705. /**
  36706. * Defines that engine should ignore modifying touch action attribute and style
  36707. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  36708. */
  36709. doNotHandleTouchAction?: boolean;
  36710. /**
  36711. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  36712. */
  36713. useHighPrecisionFloats?: boolean;
  36714. /**
  36715. * Make the canvas XR Compatible for XR sessions
  36716. */
  36717. xrCompatible?: boolean;
  36718. /**
  36719. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  36720. */
  36721. useHighPrecisionMatrix?: boolean;
  36722. /**
  36723. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  36724. */
  36725. failIfMajorPerformanceCaveat?: boolean;
  36726. }
  36727. /**
  36728. * The base engine class (root of all engines)
  36729. */
  36730. export class ThinEngine {
  36731. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  36732. static ExceptionList: ({
  36733. key: string;
  36734. capture: string;
  36735. captureConstraint: number;
  36736. targets: string[];
  36737. } | {
  36738. key: string;
  36739. capture: null;
  36740. captureConstraint: null;
  36741. targets: string[];
  36742. })[];
  36743. /** @hidden */
  36744. static _TextureLoaders: IInternalTextureLoader[];
  36745. /**
  36746. * Returns the current npm package of the sdk
  36747. */
  36748. static get NpmPackage(): string;
  36749. /**
  36750. * Returns the current version of the framework
  36751. */
  36752. static get Version(): string;
  36753. /**
  36754. * Returns a string describing the current engine
  36755. */
  36756. get description(): string;
  36757. /**
  36758. * Gets or sets the epsilon value used by collision engine
  36759. */
  36760. static CollisionsEpsilon: number;
  36761. /**
  36762. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  36763. */
  36764. static get ShadersRepository(): string;
  36765. static set ShadersRepository(value: string);
  36766. /** @hidden */
  36767. _shaderProcessor: IShaderProcessor;
  36768. /**
  36769. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  36770. */
  36771. forcePOTTextures: boolean;
  36772. /**
  36773. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  36774. */
  36775. isFullscreen: boolean;
  36776. /**
  36777. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  36778. */
  36779. cullBackFaces: boolean;
  36780. /**
  36781. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  36782. */
  36783. renderEvenInBackground: boolean;
  36784. /**
  36785. * Gets or sets a boolean indicating that cache can be kept between frames
  36786. */
  36787. preventCacheWipeBetweenFrames: boolean;
  36788. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  36789. validateShaderPrograms: boolean;
  36790. /**
  36791. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  36792. * This can provide greater z depth for distant objects.
  36793. */
  36794. useReverseDepthBuffer: boolean;
  36795. /**
  36796. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  36797. */
  36798. disableUniformBuffers: boolean;
  36799. /** @hidden */
  36800. _uniformBuffers: UniformBuffer[];
  36801. /**
  36802. * Gets a boolean indicating that the engine supports uniform buffers
  36803. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  36804. */
  36805. get supportsUniformBuffers(): boolean;
  36806. /** @hidden */
  36807. _gl: WebGLRenderingContext;
  36808. /** @hidden */
  36809. _webGLVersion: number;
  36810. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  36811. protected _windowIsBackground: boolean;
  36812. protected _creationOptions: EngineOptions;
  36813. protected _highPrecisionShadersAllowed: boolean;
  36814. /** @hidden */
  36815. get _shouldUseHighPrecisionShader(): boolean;
  36816. /**
  36817. * Gets a boolean indicating that only power of 2 textures are supported
  36818. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  36819. */
  36820. get needPOTTextures(): boolean;
  36821. /** @hidden */
  36822. _badOS: boolean;
  36823. /** @hidden */
  36824. _badDesktopOS: boolean;
  36825. private _hardwareScalingLevel;
  36826. /** @hidden */
  36827. _caps: EngineCapabilities;
  36828. private _isStencilEnable;
  36829. private _glVersion;
  36830. private _glRenderer;
  36831. private _glVendor;
  36832. /** @hidden */
  36833. _videoTextureSupported: boolean;
  36834. protected _renderingQueueLaunched: boolean;
  36835. protected _activeRenderLoops: (() => void)[];
  36836. /**
  36837. * Observable signaled when a context lost event is raised
  36838. */
  36839. onContextLostObservable: Observable<ThinEngine>;
  36840. /**
  36841. * Observable signaled when a context restored event is raised
  36842. */
  36843. onContextRestoredObservable: Observable<ThinEngine>;
  36844. private _onContextLost;
  36845. private _onContextRestored;
  36846. protected _contextWasLost: boolean;
  36847. /** @hidden */
  36848. _doNotHandleContextLost: boolean;
  36849. /**
  36850. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  36851. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  36852. */
  36853. get doNotHandleContextLost(): boolean;
  36854. set doNotHandleContextLost(value: boolean);
  36855. /**
  36856. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  36857. */
  36858. disableVertexArrayObjects: boolean;
  36859. /** @hidden */
  36860. protected _colorWrite: boolean;
  36861. /** @hidden */
  36862. protected _colorWriteChanged: boolean;
  36863. /** @hidden */
  36864. protected _depthCullingState: DepthCullingState;
  36865. /** @hidden */
  36866. protected _stencilState: StencilState;
  36867. /** @hidden */
  36868. _alphaState: AlphaState;
  36869. /** @hidden */
  36870. _alphaMode: number;
  36871. /** @hidden */
  36872. _alphaEquation: number;
  36873. /** @hidden */
  36874. _internalTexturesCache: InternalTexture[];
  36875. /** @hidden */
  36876. protected _activeChannel: number;
  36877. private _currentTextureChannel;
  36878. /** @hidden */
  36879. protected _boundTexturesCache: {
  36880. [key: string]: Nullable<InternalTexture>;
  36881. };
  36882. /** @hidden */
  36883. protected _currentEffect: Nullable<Effect>;
  36884. /** @hidden */
  36885. protected _currentProgram: Nullable<WebGLProgram>;
  36886. private _compiledEffects;
  36887. private _vertexAttribArraysEnabled;
  36888. /** @hidden */
  36889. protected _cachedViewport: Nullable<IViewportLike>;
  36890. private _cachedVertexArrayObject;
  36891. /** @hidden */
  36892. protected _cachedVertexBuffers: any;
  36893. /** @hidden */
  36894. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  36895. /** @hidden */
  36896. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  36897. /** @hidden */
  36898. _currentRenderTarget: Nullable<InternalTexture>;
  36899. private _uintIndicesCurrentlySet;
  36900. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  36901. /** @hidden */
  36902. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  36903. /** @hidden */
  36904. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  36905. private _currentBufferPointers;
  36906. private _currentInstanceLocations;
  36907. private _currentInstanceBuffers;
  36908. private _textureUnits;
  36909. /** @hidden */
  36910. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  36911. /** @hidden */
  36912. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  36913. /** @hidden */
  36914. _boundRenderFunction: any;
  36915. private _vaoRecordInProgress;
  36916. private _mustWipeVertexAttributes;
  36917. private _emptyTexture;
  36918. private _emptyCubeTexture;
  36919. private _emptyTexture3D;
  36920. private _emptyTexture2DArray;
  36921. /** @hidden */
  36922. _frameHandler: number;
  36923. private _nextFreeTextureSlots;
  36924. private _maxSimultaneousTextures;
  36925. private _activeRequests;
  36926. /** @hidden */
  36927. _transformTextureUrl: Nullable<(url: string) => string>;
  36928. /**
  36929. * Gets information about the current host
  36930. */
  36931. hostInformation: HostInformation;
  36932. protected get _supportsHardwareTextureRescaling(): boolean;
  36933. private _framebufferDimensionsObject;
  36934. /**
  36935. * sets the object from which width and height will be taken from when getting render width and height
  36936. * Will fallback to the gl object
  36937. * @param dimensions the framebuffer width and height that will be used.
  36938. */
  36939. set framebufferDimensionsObject(dimensions: Nullable<{
  36940. framebufferWidth: number;
  36941. framebufferHeight: number;
  36942. }>);
  36943. /**
  36944. * Gets the current viewport
  36945. */
  36946. get currentViewport(): Nullable<IViewportLike>;
  36947. /**
  36948. * Gets the default empty texture
  36949. */
  36950. get emptyTexture(): InternalTexture;
  36951. /**
  36952. * Gets the default empty 3D texture
  36953. */
  36954. get emptyTexture3D(): InternalTexture;
  36955. /**
  36956. * Gets the default empty 2D array texture
  36957. */
  36958. get emptyTexture2DArray(): InternalTexture;
  36959. /**
  36960. * Gets the default empty cube texture
  36961. */
  36962. get emptyCubeTexture(): InternalTexture;
  36963. /**
  36964. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  36965. */
  36966. readonly premultipliedAlpha: boolean;
  36967. /**
  36968. * Observable event triggered before each texture is initialized
  36969. */
  36970. onBeforeTextureInitObservable: Observable<import("babylonjs/Materials/Textures/texture").Texture>;
  36971. /**
  36972. * Creates a new engine
  36973. * @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
  36974. * @param antialias defines enable antialiasing (default: false)
  36975. * @param options defines further options to be sent to the getContext() function
  36976. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  36977. */
  36978. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  36979. private _rebuildInternalTextures;
  36980. private _rebuildEffects;
  36981. /**
  36982. * Gets a boolean indicating if all created effects are ready
  36983. * @returns true if all effects are ready
  36984. */
  36985. areAllEffectsReady(): boolean;
  36986. protected _rebuildBuffers(): void;
  36987. protected _initGLContext(): void;
  36988. /**
  36989. * Gets version of the current webGL context
  36990. */
  36991. get webGLVersion(): number;
  36992. /**
  36993. * Gets a string identifying the name of the class
  36994. * @returns "Engine" string
  36995. */
  36996. getClassName(): string;
  36997. /**
  36998. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  36999. */
  37000. get isStencilEnable(): boolean;
  37001. /** @hidden */
  37002. _prepareWorkingCanvas(): void;
  37003. /**
  37004. * Reset the texture cache to empty state
  37005. */
  37006. resetTextureCache(): void;
  37007. /**
  37008. * Gets an object containing information about the current webGL context
  37009. * @returns an object containing the vender, the renderer and the version of the current webGL context
  37010. */
  37011. getGlInfo(): {
  37012. vendor: string;
  37013. renderer: string;
  37014. version: string;
  37015. };
  37016. /**
  37017. * Defines the hardware scaling level.
  37018. * By default the hardware scaling level is computed from the window device ratio.
  37019. * 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.
  37020. * @param level defines the level to use
  37021. */
  37022. setHardwareScalingLevel(level: number): void;
  37023. /**
  37024. * Gets the current hardware scaling level.
  37025. * By default the hardware scaling level is computed from the window device ratio.
  37026. * 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.
  37027. * @returns a number indicating the current hardware scaling level
  37028. */
  37029. getHardwareScalingLevel(): number;
  37030. /**
  37031. * Gets the list of loaded textures
  37032. * @returns an array containing all loaded textures
  37033. */
  37034. getLoadedTexturesCache(): InternalTexture[];
  37035. /**
  37036. * Gets the object containing all engine capabilities
  37037. * @returns the EngineCapabilities object
  37038. */
  37039. getCaps(): EngineCapabilities;
  37040. /**
  37041. * stop executing a render loop function and remove it from the execution array
  37042. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  37043. */
  37044. stopRenderLoop(renderFunction?: () => void): void;
  37045. /** @hidden */
  37046. _renderLoop(): void;
  37047. /**
  37048. * Gets the HTML canvas attached with the current webGL context
  37049. * @returns a HTML canvas
  37050. */
  37051. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  37052. /**
  37053. * Gets host window
  37054. * @returns the host window object
  37055. */
  37056. getHostWindow(): Nullable<Window>;
  37057. /**
  37058. * Gets the current render width
  37059. * @param useScreen defines if screen size must be used (or the current render target if any)
  37060. * @returns a number defining the current render width
  37061. */
  37062. getRenderWidth(useScreen?: boolean): number;
  37063. /**
  37064. * Gets the current render height
  37065. * @param useScreen defines if screen size must be used (or the current render target if any)
  37066. * @returns a number defining the current render height
  37067. */
  37068. getRenderHeight(useScreen?: boolean): number;
  37069. /**
  37070. * Can be used to override the current requestAnimationFrame requester.
  37071. * @hidden
  37072. */
  37073. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  37074. /**
  37075. * Register and execute a render loop. The engine can have more than one render function
  37076. * @param renderFunction defines the function to continuously execute
  37077. */
  37078. runRenderLoop(renderFunction: () => void): void;
  37079. /**
  37080. * Clear the current render buffer or the current render target (if any is set up)
  37081. * @param color defines the color to use
  37082. * @param backBuffer defines if the back buffer must be cleared
  37083. * @param depth defines if the depth buffer must be cleared
  37084. * @param stencil defines if the stencil buffer must be cleared
  37085. */
  37086. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  37087. private _viewportCached;
  37088. /** @hidden */
  37089. _viewport(x: number, y: number, width: number, height: number): void;
  37090. /**
  37091. * Set the WebGL's viewport
  37092. * @param viewport defines the viewport element to be used
  37093. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  37094. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  37095. */
  37096. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  37097. /**
  37098. * Begin a new frame
  37099. */
  37100. beginFrame(): void;
  37101. /**
  37102. * Enf the current frame
  37103. */
  37104. endFrame(): void;
  37105. /**
  37106. * Resize the view according to the canvas' size
  37107. */
  37108. resize(): void;
  37109. /**
  37110. * Force a specific size of the canvas
  37111. * @param width defines the new canvas' width
  37112. * @param height defines the new canvas' height
  37113. * @returns true if the size was changed
  37114. */
  37115. setSize(width: number, height: number): boolean;
  37116. /**
  37117. * Binds the frame buffer to the specified texture.
  37118. * @param texture The texture to render to or null for the default canvas
  37119. * @param faceIndex The face of the texture to render to in case of cube texture
  37120. * @param requiredWidth The width of the target to render to
  37121. * @param requiredHeight The height of the target to render to
  37122. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  37123. * @param lodLevel defines the lod level to bind to the frame buffer
  37124. * @param layer defines the 2d array index to bind to frame buffer to
  37125. */
  37126. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  37127. /** @hidden */
  37128. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  37129. /**
  37130. * Unbind the current render target texture from the webGL context
  37131. * @param texture defines the render target texture to unbind
  37132. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  37133. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  37134. */
  37135. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  37136. /**
  37137. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  37138. */
  37139. flushFramebuffer(): void;
  37140. /**
  37141. * Unbind the current render target and bind the default framebuffer
  37142. */
  37143. restoreDefaultFramebuffer(): void;
  37144. /** @hidden */
  37145. protected _resetVertexBufferBinding(): void;
  37146. /**
  37147. * Creates a vertex buffer
  37148. * @param data the data for the vertex buffer
  37149. * @returns the new WebGL static buffer
  37150. */
  37151. createVertexBuffer(data: DataArray): DataBuffer;
  37152. private _createVertexBuffer;
  37153. /**
  37154. * Creates a dynamic vertex buffer
  37155. * @param data the data for the dynamic vertex buffer
  37156. * @returns the new WebGL dynamic buffer
  37157. */
  37158. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  37159. protected _resetIndexBufferBinding(): void;
  37160. /**
  37161. * Creates a new index buffer
  37162. * @param indices defines the content of the index buffer
  37163. * @param updatable defines if the index buffer must be updatable
  37164. * @returns a new webGL buffer
  37165. */
  37166. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  37167. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  37168. /**
  37169. * Bind a webGL buffer to the webGL context
  37170. * @param buffer defines the buffer to bind
  37171. */
  37172. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  37173. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  37174. private bindBuffer;
  37175. /**
  37176. * update the bound buffer with the given data
  37177. * @param data defines the data to update
  37178. */
  37179. updateArrayBuffer(data: Float32Array): void;
  37180. private _vertexAttribPointer;
  37181. /** @hidden */
  37182. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  37183. private _bindVertexBuffersAttributes;
  37184. /**
  37185. * Records a vertex array object
  37186. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37187. * @param vertexBuffers defines the list of vertex buffers to store
  37188. * @param indexBuffer defines the index buffer to store
  37189. * @param effect defines the effect to store
  37190. * @returns the new vertex array object
  37191. */
  37192. recordVertexArrayObject(vertexBuffers: {
  37193. [key: string]: VertexBuffer;
  37194. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  37195. /**
  37196. * Bind a specific vertex array object
  37197. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  37198. * @param vertexArrayObject defines the vertex array object to bind
  37199. * @param indexBuffer defines the index buffer to bind
  37200. */
  37201. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  37202. /**
  37203. * Bind webGl buffers directly to the webGL context
  37204. * @param vertexBuffer defines the vertex buffer to bind
  37205. * @param indexBuffer defines the index buffer to bind
  37206. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  37207. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  37208. * @param effect defines the effect associated with the vertex buffer
  37209. */
  37210. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  37211. private _unbindVertexArrayObject;
  37212. /**
  37213. * Bind a list of vertex buffers to the webGL context
  37214. * @param vertexBuffers defines the list of vertex buffers to bind
  37215. * @param indexBuffer defines the index buffer to bind
  37216. * @param effect defines the effect associated with the vertex buffers
  37217. */
  37218. bindBuffers(vertexBuffers: {
  37219. [key: string]: Nullable<VertexBuffer>;
  37220. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  37221. /**
  37222. * Unbind all instance attributes
  37223. */
  37224. unbindInstanceAttributes(): void;
  37225. /**
  37226. * Release and free the memory of a vertex array object
  37227. * @param vao defines the vertex array object to delete
  37228. */
  37229. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  37230. /** @hidden */
  37231. _releaseBuffer(buffer: DataBuffer): boolean;
  37232. protected _deleteBuffer(buffer: DataBuffer): void;
  37233. /**
  37234. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  37235. * @param instancesBuffer defines the webGL buffer to update and bind
  37236. * @param data defines the data to store in the buffer
  37237. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  37238. */
  37239. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  37240. /**
  37241. * Bind the content of a webGL buffer used with instantiation
  37242. * @param instancesBuffer defines the webGL buffer to bind
  37243. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  37244. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  37245. */
  37246. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  37247. /**
  37248. * Disable the instance attribute corresponding to the name in parameter
  37249. * @param name defines the name of the attribute to disable
  37250. */
  37251. disableInstanceAttributeByName(name: string): void;
  37252. /**
  37253. * Disable the instance attribute corresponding to the location in parameter
  37254. * @param attributeLocation defines the attribute location of the attribute to disable
  37255. */
  37256. disableInstanceAttribute(attributeLocation: number): void;
  37257. /**
  37258. * Disable the attribute corresponding to the location in parameter
  37259. * @param attributeLocation defines the attribute location of the attribute to disable
  37260. */
  37261. disableAttributeByIndex(attributeLocation: number): void;
  37262. /**
  37263. * Send a draw order
  37264. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37265. * @param indexStart defines the starting index
  37266. * @param indexCount defines the number of index to draw
  37267. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37268. */
  37269. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  37270. /**
  37271. * Draw a list of points
  37272. * @param verticesStart defines the index of first vertex to draw
  37273. * @param verticesCount defines the count of vertices to draw
  37274. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37275. */
  37276. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37277. /**
  37278. * Draw a list of unindexed primitives
  37279. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  37280. * @param verticesStart defines the index of first vertex to draw
  37281. * @param verticesCount defines the count of vertices to draw
  37282. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37283. */
  37284. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37285. /**
  37286. * Draw a list of indexed primitives
  37287. * @param fillMode defines the primitive to use
  37288. * @param indexStart defines the starting index
  37289. * @param indexCount defines the number of index to draw
  37290. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37291. */
  37292. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  37293. /**
  37294. * Draw a list of unindexed primitives
  37295. * @param fillMode defines the primitive to use
  37296. * @param verticesStart defines the index of first vertex to draw
  37297. * @param verticesCount defines the count of vertices to draw
  37298. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  37299. */
  37300. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  37301. private _drawMode;
  37302. /** @hidden */
  37303. protected _reportDrawCall(): void;
  37304. /** @hidden */
  37305. _releaseEffect(effect: Effect): void;
  37306. /** @hidden */
  37307. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  37308. /**
  37309. * Create a new effect (used to store vertex/fragment shaders)
  37310. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  37311. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  37312. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  37313. * @param samplers defines an array of string used to represent textures
  37314. * @param defines defines the string containing the defines to use to compile the shaders
  37315. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  37316. * @param onCompiled defines a function to call when the effect creation is successful
  37317. * @param onError defines a function to call when the effect creation has failed
  37318. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  37319. * @returns the new Effect
  37320. */
  37321. 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;
  37322. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  37323. private _compileShader;
  37324. private _compileRawShader;
  37325. /** @hidden */
  37326. _getShaderSource(shader: WebGLShader): Nullable<string>;
  37327. /**
  37328. * Directly creates a webGL program
  37329. * @param pipelineContext defines the pipeline context to attach to
  37330. * @param vertexCode defines the vertex shader code to use
  37331. * @param fragmentCode defines the fragment shader code to use
  37332. * @param context defines the webGL context to use (if not set, the current one will be used)
  37333. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37334. * @returns the new webGL program
  37335. */
  37336. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37337. /**
  37338. * Creates a webGL program
  37339. * @param pipelineContext defines the pipeline context to attach to
  37340. * @param vertexCode defines the vertex shader code to use
  37341. * @param fragmentCode defines the fragment shader code to use
  37342. * @param defines defines the string containing the defines to use to compile the shaders
  37343. * @param context defines the webGL context to use (if not set, the current one will be used)
  37344. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  37345. * @returns the new webGL program
  37346. */
  37347. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37348. /**
  37349. * Creates a new pipeline context
  37350. * @returns the new pipeline
  37351. */
  37352. createPipelineContext(): IPipelineContext;
  37353. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  37354. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  37355. /** @hidden */
  37356. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  37357. /** @hidden */
  37358. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  37359. /** @hidden */
  37360. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  37361. /**
  37362. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  37363. * @param pipelineContext defines the pipeline context to use
  37364. * @param uniformsNames defines the list of uniform names
  37365. * @returns an array of webGL uniform locations
  37366. */
  37367. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  37368. /**
  37369. * Gets the lsit of active attributes for a given webGL program
  37370. * @param pipelineContext defines the pipeline context to use
  37371. * @param attributesNames defines the list of attribute names to get
  37372. * @returns an array of indices indicating the offset of each attribute
  37373. */
  37374. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  37375. /**
  37376. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  37377. * @param effect defines the effect to activate
  37378. */
  37379. enableEffect(effect: Nullable<Effect>): void;
  37380. /**
  37381. * Set the value of an uniform to a number (int)
  37382. * @param uniform defines the webGL uniform location where to store the value
  37383. * @param value defines the int number to store
  37384. * @returns true if the value was set
  37385. */
  37386. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37387. /**
  37388. * Set the value of an uniform to an array of int32
  37389. * @param uniform defines the webGL uniform location where to store the value
  37390. * @param array defines the array of int32 to store
  37391. * @returns true if the value was set
  37392. */
  37393. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37394. /**
  37395. * Set the value of an uniform to an array of int32 (stored as vec2)
  37396. * @param uniform defines the webGL uniform location where to store the value
  37397. * @param array defines the array of int32 to store
  37398. * @returns true if the value was set
  37399. */
  37400. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37401. /**
  37402. * Set the value of an uniform to an array of int32 (stored as vec3)
  37403. * @param uniform defines the webGL uniform location where to store the value
  37404. * @param array defines the array of int32 to store
  37405. * @returns true if the value was set
  37406. */
  37407. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37408. /**
  37409. * Set the value of an uniform to an array of int32 (stored as vec4)
  37410. * @param uniform defines the webGL uniform location where to store the value
  37411. * @param array defines the array of int32 to store
  37412. * @returns true if the value was set
  37413. */
  37414. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  37415. /**
  37416. * Set the value of an uniform to an array of number
  37417. * @param uniform defines the webGL uniform location where to store the value
  37418. * @param array defines the array of number to store
  37419. * @returns true if the value was set
  37420. */
  37421. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37422. /**
  37423. * Set the value of an uniform to an array of number (stored as vec2)
  37424. * @param uniform defines the webGL uniform location where to store the value
  37425. * @param array defines the array of number to store
  37426. * @returns true if the value was set
  37427. */
  37428. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37429. /**
  37430. * Set the value of an uniform to an array of number (stored as vec3)
  37431. * @param uniform defines the webGL uniform location where to store the value
  37432. * @param array defines the array of number to store
  37433. * @returns true if the value was set
  37434. */
  37435. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37436. /**
  37437. * Set the value of an uniform to an array of number (stored as vec4)
  37438. * @param uniform defines the webGL uniform location where to store the value
  37439. * @param array defines the array of number to store
  37440. * @returns true if the value was set
  37441. */
  37442. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  37443. /**
  37444. * Set the value of an uniform to an array of float32 (stored as matrices)
  37445. * @param uniform defines the webGL uniform location where to store the value
  37446. * @param matrices defines the array of float32 to store
  37447. * @returns true if the value was set
  37448. */
  37449. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  37450. /**
  37451. * Set the value of an uniform to a matrix (3x3)
  37452. * @param uniform defines the webGL uniform location where to store the value
  37453. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  37454. * @returns true if the value was set
  37455. */
  37456. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37457. /**
  37458. * Set the value of an uniform to a matrix (2x2)
  37459. * @param uniform defines the webGL uniform location where to store the value
  37460. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  37461. * @returns true if the value was set
  37462. */
  37463. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  37464. /**
  37465. * Set the value of an uniform to a number (float)
  37466. * @param uniform defines the webGL uniform location where to store the value
  37467. * @param value defines the float number to store
  37468. * @returns true if the value was transfered
  37469. */
  37470. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  37471. /**
  37472. * Set the value of an uniform to a vec2
  37473. * @param uniform defines the webGL uniform location where to store the value
  37474. * @param x defines the 1st component of the value
  37475. * @param y defines the 2nd component of the value
  37476. * @returns true if the value was set
  37477. */
  37478. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  37479. /**
  37480. * Set the value of an uniform to a vec3
  37481. * @param uniform defines the webGL uniform location where to store the value
  37482. * @param x defines the 1st component of the value
  37483. * @param y defines the 2nd component of the value
  37484. * @param z defines the 3rd component of the value
  37485. * @returns true if the value was set
  37486. */
  37487. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  37488. /**
  37489. * Set the value of an uniform to a vec4
  37490. * @param uniform defines the webGL uniform location where to store the value
  37491. * @param x defines the 1st component of the value
  37492. * @param y defines the 2nd component of the value
  37493. * @param z defines the 3rd component of the value
  37494. * @param w defines the 4th component of the value
  37495. * @returns true if the value was set
  37496. */
  37497. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  37498. /**
  37499. * Apply all cached states (depth, culling, stencil and alpha)
  37500. */
  37501. applyStates(): void;
  37502. /**
  37503. * Enable or disable color writing
  37504. * @param enable defines the state to set
  37505. */
  37506. setColorWrite(enable: boolean): void;
  37507. /**
  37508. * Gets a boolean indicating if color writing is enabled
  37509. * @returns the current color writing state
  37510. */
  37511. getColorWrite(): boolean;
  37512. /**
  37513. * Gets the depth culling state manager
  37514. */
  37515. get depthCullingState(): DepthCullingState;
  37516. /**
  37517. * Gets the alpha state manager
  37518. */
  37519. get alphaState(): AlphaState;
  37520. /**
  37521. * Gets the stencil state manager
  37522. */
  37523. get stencilState(): StencilState;
  37524. /**
  37525. * Clears the list of texture accessible through engine.
  37526. * This can help preventing texture load conflict due to name collision.
  37527. */
  37528. clearInternalTexturesCache(): void;
  37529. /**
  37530. * Force the entire cache to be cleared
  37531. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  37532. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  37533. */
  37534. wipeCaches(bruteForce?: boolean): void;
  37535. /** @hidden */
  37536. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  37537. min: number;
  37538. mag: number;
  37539. };
  37540. /** @hidden */
  37541. _createTexture(): WebGLTexture;
  37542. /**
  37543. * Usually called from Texture.ts.
  37544. * Passed information to create a WebGLTexture
  37545. * @param url defines a value which contains one of the following:
  37546. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  37547. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  37548. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  37549. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  37550. * @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)
  37551. * @param scene needed for loading to the correct scene
  37552. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  37553. * @param onLoad optional callback to be called upon successful completion
  37554. * @param onError optional callback to be called upon failure
  37555. * @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
  37556. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  37557. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  37558. * @param forcedExtension defines the extension to use to pick the right loader
  37559. * @param mimeType defines an optional mime type
  37560. * @returns a InternalTexture for assignment back into BABYLON.Texture
  37561. */
  37562. 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;
  37563. /**
  37564. * Loads an image as an HTMLImageElement.
  37565. * @param input url string, ArrayBuffer, or Blob to load
  37566. * @param onLoad callback called when the image successfully loads
  37567. * @param onError callback called when the image fails to load
  37568. * @param offlineProvider offline provider for caching
  37569. * @param mimeType optional mime type
  37570. * @returns the HTMLImageElement of the loaded image
  37571. * @hidden
  37572. */
  37573. 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>;
  37574. /**
  37575. * @hidden
  37576. */
  37577. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  37578. private _unpackFlipYCached;
  37579. /**
  37580. * In case you are sharing the context with other applications, it might
  37581. * be interested to not cache the unpack flip y state to ensure a consistent
  37582. * value would be set.
  37583. */
  37584. enableUnpackFlipYCached: boolean;
  37585. /** @hidden */
  37586. _unpackFlipY(value: boolean): void;
  37587. /** @hidden */
  37588. _getUnpackAlignement(): number;
  37589. private _getTextureTarget;
  37590. /**
  37591. * Update the sampling mode of a given texture
  37592. * @param samplingMode defines the required sampling mode
  37593. * @param texture defines the texture to update
  37594. * @param generateMipMaps defines whether to generate mipmaps for the texture
  37595. */
  37596. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  37597. /**
  37598. * Update the sampling mode of a given texture
  37599. * @param texture defines the texture to update
  37600. * @param wrapU defines the texture wrap mode of the u coordinates
  37601. * @param wrapV defines the texture wrap mode of the v coordinates
  37602. * @param wrapR defines the texture wrap mode of the r coordinates
  37603. */
  37604. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  37605. /** @hidden */
  37606. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  37607. width: number;
  37608. height: number;
  37609. layers?: number;
  37610. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  37611. /** @hidden */
  37612. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37613. /** @hidden */
  37614. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  37615. /**
  37616. * Update a portion of an internal texture
  37617. * @param texture defines the texture to update
  37618. * @param imageData defines the data to store into the texture
  37619. * @param xOffset defines the x coordinates of the update rectangle
  37620. * @param yOffset defines the y coordinates of the update rectangle
  37621. * @param width defines the width of the update rectangle
  37622. * @param height defines the height of the update rectangle
  37623. * @param faceIndex defines the face index if texture is a cube (0 by default)
  37624. * @param lod defines the lod level to update (0 by default)
  37625. */
  37626. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  37627. /** @hidden */
  37628. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  37629. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  37630. private _prepareWebGLTexture;
  37631. /** @hidden */
  37632. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  37633. private _getDepthStencilBuffer;
  37634. /** @hidden */
  37635. _releaseFramebufferObjects(texture: InternalTexture): void;
  37636. /** @hidden */
  37637. _releaseTexture(texture: InternalTexture): void;
  37638. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  37639. protected _setProgram(program: WebGLProgram): void;
  37640. protected _boundUniforms: {
  37641. [key: number]: WebGLUniformLocation;
  37642. };
  37643. /**
  37644. * Binds an effect to the webGL context
  37645. * @param effect defines the effect to bind
  37646. */
  37647. bindSamplers(effect: Effect): void;
  37648. private _activateCurrentTexture;
  37649. /** @hidden */
  37650. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  37651. /** @hidden */
  37652. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  37653. /**
  37654. * Unbind all textures from the webGL context
  37655. */
  37656. unbindAllTextures(): void;
  37657. /**
  37658. * Sets a texture to the according uniform.
  37659. * @param channel The texture channel
  37660. * @param uniform The uniform to set
  37661. * @param texture The texture to apply
  37662. */
  37663. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  37664. private _bindSamplerUniformToChannel;
  37665. private _getTextureWrapMode;
  37666. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  37667. /**
  37668. * Sets an array of texture to the webGL context
  37669. * @param channel defines the channel where the texture array must be set
  37670. * @param uniform defines the associated uniform location
  37671. * @param textures defines the array of textures to bind
  37672. */
  37673. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  37674. /** @hidden */
  37675. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  37676. private _setTextureParameterFloat;
  37677. private _setTextureParameterInteger;
  37678. /**
  37679. * Unbind all vertex attributes from the webGL context
  37680. */
  37681. unbindAllAttributes(): void;
  37682. /**
  37683. * 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
  37684. */
  37685. releaseEffects(): void;
  37686. /**
  37687. * Dispose and release all associated resources
  37688. */
  37689. dispose(): void;
  37690. /**
  37691. * Attach a new callback raised when context lost event is fired
  37692. * @param callback defines the callback to call
  37693. */
  37694. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37695. /**
  37696. * Attach a new callback raised when context restored event is fired
  37697. * @param callback defines the callback to call
  37698. */
  37699. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  37700. /**
  37701. * Get the current error code of the webGL context
  37702. * @returns the error code
  37703. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  37704. */
  37705. getError(): number;
  37706. private _canRenderToFloatFramebuffer;
  37707. private _canRenderToHalfFloatFramebuffer;
  37708. private _canRenderToFramebuffer;
  37709. /** @hidden */
  37710. _getWebGLTextureType(type: number): number;
  37711. /** @hidden */
  37712. _getInternalFormat(format: number): number;
  37713. /** @hidden */
  37714. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  37715. /** @hidden */
  37716. _getRGBAMultiSampleBufferFormat(type: number): number;
  37717. /** @hidden */
  37718. _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;
  37719. /**
  37720. * Loads a file from a url
  37721. * @param url url to load
  37722. * @param onSuccess callback called when the file successfully loads
  37723. * @param onProgress callback called while file is loading (if the server supports this mode)
  37724. * @param offlineProvider defines the offline provider for caching
  37725. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  37726. * @param onError callback called when the file fails to load
  37727. * @returns a file request object
  37728. * @hidden
  37729. */
  37730. 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;
  37731. /**
  37732. * Reads pixels from the current frame buffer. Please note that this function can be slow
  37733. * @param x defines the x coordinate of the rectangle where pixels must be read
  37734. * @param y defines the y coordinate of the rectangle where pixels must be read
  37735. * @param width defines the width of the rectangle where pixels must be read
  37736. * @param height defines the height of the rectangle where pixels must be read
  37737. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  37738. * @returns a Uint8Array containing RGBA colors
  37739. */
  37740. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  37741. private static _IsSupported;
  37742. private static _HasMajorPerformanceCaveat;
  37743. /**
  37744. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37745. */
  37746. static get IsSupported(): boolean;
  37747. /**
  37748. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  37749. * @returns true if the engine can be created
  37750. * @ignorenaming
  37751. */
  37752. static isSupported(): boolean;
  37753. /**
  37754. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  37755. */
  37756. static get HasMajorPerformanceCaveat(): boolean;
  37757. /**
  37758. * Find the next highest power of two.
  37759. * @param x Number to start search from.
  37760. * @return Next highest power of two.
  37761. */
  37762. static CeilingPOT(x: number): number;
  37763. /**
  37764. * Find the next lowest power of two.
  37765. * @param x Number to start search from.
  37766. * @return Next lowest power of two.
  37767. */
  37768. static FloorPOT(x: number): number;
  37769. /**
  37770. * Find the nearest power of two.
  37771. * @param x Number to start search from.
  37772. * @return Next nearest power of two.
  37773. */
  37774. static NearestPOT(x: number): number;
  37775. /**
  37776. * Get the closest exponent of two
  37777. * @param value defines the value to approximate
  37778. * @param max defines the maximum value to return
  37779. * @param mode defines how to define the closest value
  37780. * @returns closest exponent of two of the given value
  37781. */
  37782. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  37783. /**
  37784. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  37785. * @param func - the function to be called
  37786. * @param requester - the object that will request the next frame. Falls back to window.
  37787. * @returns frame number
  37788. */
  37789. static QueueNewFrame(func: () => void, requester?: any): number;
  37790. /**
  37791. * Gets host document
  37792. * @returns the host document object
  37793. */
  37794. getHostDocument(): Nullable<Document>;
  37795. }
  37796. }
  37797. declare module "babylonjs/Maths/sphericalPolynomial" {
  37798. import { Vector3 } from "babylonjs/Maths/math.vector";
  37799. import { Color3 } from "babylonjs/Maths/math.color";
  37800. /**
  37801. * Class representing spherical harmonics coefficients to the 3rd degree
  37802. */
  37803. export class SphericalHarmonics {
  37804. /**
  37805. * Defines whether or not the harmonics have been prescaled for rendering.
  37806. */
  37807. preScaled: boolean;
  37808. /**
  37809. * The l0,0 coefficients of the spherical harmonics
  37810. */
  37811. l00: Vector3;
  37812. /**
  37813. * The l1,-1 coefficients of the spherical harmonics
  37814. */
  37815. l1_1: Vector3;
  37816. /**
  37817. * The l1,0 coefficients of the spherical harmonics
  37818. */
  37819. l10: Vector3;
  37820. /**
  37821. * The l1,1 coefficients of the spherical harmonics
  37822. */
  37823. l11: Vector3;
  37824. /**
  37825. * The l2,-2 coefficients of the spherical harmonics
  37826. */
  37827. l2_2: Vector3;
  37828. /**
  37829. * The l2,-1 coefficients of the spherical harmonics
  37830. */
  37831. l2_1: Vector3;
  37832. /**
  37833. * The l2,0 coefficients of the spherical harmonics
  37834. */
  37835. l20: Vector3;
  37836. /**
  37837. * The l2,1 coefficients of the spherical harmonics
  37838. */
  37839. l21: Vector3;
  37840. /**
  37841. * The l2,2 coefficients of the spherical harmonics
  37842. */
  37843. l22: Vector3;
  37844. /**
  37845. * Adds a light to the spherical harmonics
  37846. * @param direction the direction of the light
  37847. * @param color the color of the light
  37848. * @param deltaSolidAngle the delta solid angle of the light
  37849. */
  37850. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  37851. /**
  37852. * Scales the spherical harmonics by the given amount
  37853. * @param scale the amount to scale
  37854. */
  37855. scaleInPlace(scale: number): void;
  37856. /**
  37857. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  37858. *
  37859. * ```
  37860. * E_lm = A_l * L_lm
  37861. * ```
  37862. *
  37863. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  37864. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  37865. * the scaling factors are given in equation 9.
  37866. */
  37867. convertIncidentRadianceToIrradiance(): void;
  37868. /**
  37869. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  37870. *
  37871. * ```
  37872. * L = (1/pi) * E * rho
  37873. * ```
  37874. *
  37875. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  37876. */
  37877. convertIrradianceToLambertianRadiance(): void;
  37878. /**
  37879. * Integrates the reconstruction coefficients directly in to the SH preventing further
  37880. * required operations at run time.
  37881. *
  37882. * This is simply done by scaling back the SH with Ylm constants parameter.
  37883. * The trigonometric part being applied by the shader at run time.
  37884. */
  37885. preScaleForRendering(): void;
  37886. /**
  37887. * Constructs a spherical harmonics from an array.
  37888. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  37889. * @returns the spherical harmonics
  37890. */
  37891. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  37892. /**
  37893. * Gets the spherical harmonics from polynomial
  37894. * @param polynomial the spherical polynomial
  37895. * @returns the spherical harmonics
  37896. */
  37897. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  37898. }
  37899. /**
  37900. * Class representing spherical polynomial coefficients to the 3rd degree
  37901. */
  37902. export class SphericalPolynomial {
  37903. private _harmonics;
  37904. /**
  37905. * The spherical harmonics used to create the polynomials.
  37906. */
  37907. get preScaledHarmonics(): SphericalHarmonics;
  37908. /**
  37909. * The x coefficients of the spherical polynomial
  37910. */
  37911. x: Vector3;
  37912. /**
  37913. * The y coefficients of the spherical polynomial
  37914. */
  37915. y: Vector3;
  37916. /**
  37917. * The z coefficients of the spherical polynomial
  37918. */
  37919. z: Vector3;
  37920. /**
  37921. * The xx coefficients of the spherical polynomial
  37922. */
  37923. xx: Vector3;
  37924. /**
  37925. * The yy coefficients of the spherical polynomial
  37926. */
  37927. yy: Vector3;
  37928. /**
  37929. * The zz coefficients of the spherical polynomial
  37930. */
  37931. zz: Vector3;
  37932. /**
  37933. * The xy coefficients of the spherical polynomial
  37934. */
  37935. xy: Vector3;
  37936. /**
  37937. * The yz coefficients of the spherical polynomial
  37938. */
  37939. yz: Vector3;
  37940. /**
  37941. * The zx coefficients of the spherical polynomial
  37942. */
  37943. zx: Vector3;
  37944. /**
  37945. * Adds an ambient color to the spherical polynomial
  37946. * @param color the color to add
  37947. */
  37948. addAmbient(color: Color3): void;
  37949. /**
  37950. * Scales the spherical polynomial by the given amount
  37951. * @param scale the amount to scale
  37952. */
  37953. scaleInPlace(scale: number): void;
  37954. /**
  37955. * Gets the spherical polynomial from harmonics
  37956. * @param harmonics the spherical harmonics
  37957. * @returns the spherical polynomial
  37958. */
  37959. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  37960. /**
  37961. * Constructs a spherical polynomial from an array.
  37962. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  37963. * @returns the spherical polynomial
  37964. */
  37965. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  37966. }
  37967. }
  37968. declare module "babylonjs/Materials/Textures/internalTexture" {
  37969. import { Observable } from "babylonjs/Misc/observable";
  37970. import { Nullable, int } from "babylonjs/types";
  37971. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  37972. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  37973. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  37974. /**
  37975. * Defines the source of the internal texture
  37976. */
  37977. export enum InternalTextureSource {
  37978. /**
  37979. * The source of the texture data is unknown
  37980. */
  37981. Unknown = 0,
  37982. /**
  37983. * Texture data comes from an URL
  37984. */
  37985. Url = 1,
  37986. /**
  37987. * Texture data is only used for temporary storage
  37988. */
  37989. Temp = 2,
  37990. /**
  37991. * Texture data comes from raw data (ArrayBuffer)
  37992. */
  37993. Raw = 3,
  37994. /**
  37995. * Texture content is dynamic (video or dynamic texture)
  37996. */
  37997. Dynamic = 4,
  37998. /**
  37999. * Texture content is generated by rendering to it
  38000. */
  38001. RenderTarget = 5,
  38002. /**
  38003. * Texture content is part of a multi render target process
  38004. */
  38005. MultiRenderTarget = 6,
  38006. /**
  38007. * Texture data comes from a cube data file
  38008. */
  38009. Cube = 7,
  38010. /**
  38011. * Texture data comes from a raw cube data
  38012. */
  38013. CubeRaw = 8,
  38014. /**
  38015. * Texture data come from a prefiltered cube data file
  38016. */
  38017. CubePrefiltered = 9,
  38018. /**
  38019. * Texture content is raw 3D data
  38020. */
  38021. Raw3D = 10,
  38022. /**
  38023. * Texture content is raw 2D array data
  38024. */
  38025. Raw2DArray = 11,
  38026. /**
  38027. * Texture content is a depth texture
  38028. */
  38029. Depth = 12,
  38030. /**
  38031. * Texture data comes from a raw cube data encoded with RGBD
  38032. */
  38033. CubeRawRGBD = 13
  38034. }
  38035. /**
  38036. * Class used to store data associated with WebGL texture data for the engine
  38037. * This class should not be used directly
  38038. */
  38039. export class InternalTexture {
  38040. /** @hidden */
  38041. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  38042. /**
  38043. * Defines if the texture is ready
  38044. */
  38045. isReady: boolean;
  38046. /**
  38047. * Defines if the texture is a cube texture
  38048. */
  38049. isCube: boolean;
  38050. /**
  38051. * Defines if the texture contains 3D data
  38052. */
  38053. is3D: boolean;
  38054. /**
  38055. * Defines if the texture contains 2D array data
  38056. */
  38057. is2DArray: boolean;
  38058. /**
  38059. * Defines if the texture contains multiview data
  38060. */
  38061. isMultiview: boolean;
  38062. /**
  38063. * Gets the URL used to load this texture
  38064. */
  38065. url: string;
  38066. /**
  38067. * Gets the sampling mode of the texture
  38068. */
  38069. samplingMode: number;
  38070. /**
  38071. * Gets a boolean indicating if the texture needs mipmaps generation
  38072. */
  38073. generateMipMaps: boolean;
  38074. /**
  38075. * Gets the number of samples used by the texture (WebGL2+ only)
  38076. */
  38077. samples: number;
  38078. /**
  38079. * Gets the type of the texture (int, float...)
  38080. */
  38081. type: number;
  38082. /**
  38083. * Gets the format of the texture (RGB, RGBA...)
  38084. */
  38085. format: number;
  38086. /**
  38087. * Observable called when the texture is loaded
  38088. */
  38089. onLoadedObservable: Observable<InternalTexture>;
  38090. /**
  38091. * Gets the width of the texture
  38092. */
  38093. width: number;
  38094. /**
  38095. * Gets the height of the texture
  38096. */
  38097. height: number;
  38098. /**
  38099. * Gets the depth of the texture
  38100. */
  38101. depth: number;
  38102. /**
  38103. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  38104. */
  38105. baseWidth: number;
  38106. /**
  38107. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  38108. */
  38109. baseHeight: number;
  38110. /**
  38111. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  38112. */
  38113. baseDepth: number;
  38114. /**
  38115. * Gets a boolean indicating if the texture is inverted on Y axis
  38116. */
  38117. invertY: boolean;
  38118. /** @hidden */
  38119. _invertVScale: boolean;
  38120. /** @hidden */
  38121. _associatedChannel: number;
  38122. /** @hidden */
  38123. _source: InternalTextureSource;
  38124. /** @hidden */
  38125. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  38126. /** @hidden */
  38127. _bufferView: Nullable<ArrayBufferView>;
  38128. /** @hidden */
  38129. _bufferViewArray: Nullable<ArrayBufferView[]>;
  38130. /** @hidden */
  38131. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  38132. /** @hidden */
  38133. _size: number;
  38134. /** @hidden */
  38135. _extension: string;
  38136. /** @hidden */
  38137. _files: Nullable<string[]>;
  38138. /** @hidden */
  38139. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  38140. /** @hidden */
  38141. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  38142. /** @hidden */
  38143. _framebuffer: Nullable<WebGLFramebuffer>;
  38144. /** @hidden */
  38145. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  38146. /** @hidden */
  38147. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  38148. /** @hidden */
  38149. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  38150. /** @hidden */
  38151. _attachments: Nullable<number[]>;
  38152. /** @hidden */
  38153. _textureArray: Nullable<InternalTexture[]>;
  38154. /** @hidden */
  38155. _cachedCoordinatesMode: Nullable<number>;
  38156. /** @hidden */
  38157. _cachedWrapU: Nullable<number>;
  38158. /** @hidden */
  38159. _cachedWrapV: Nullable<number>;
  38160. /** @hidden */
  38161. _cachedWrapR: Nullable<number>;
  38162. /** @hidden */
  38163. _cachedAnisotropicFilteringLevel: Nullable<number>;
  38164. /** @hidden */
  38165. _isDisabled: boolean;
  38166. /** @hidden */
  38167. _compression: Nullable<string>;
  38168. /** @hidden */
  38169. _generateStencilBuffer: boolean;
  38170. /** @hidden */
  38171. _generateDepthBuffer: boolean;
  38172. /** @hidden */
  38173. _comparisonFunction: number;
  38174. /** @hidden */
  38175. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  38176. /** @hidden */
  38177. _lodGenerationScale: number;
  38178. /** @hidden */
  38179. _lodGenerationOffset: number;
  38180. /** @hidden */
  38181. _depthStencilTexture: Nullable<InternalTexture>;
  38182. /** @hidden */
  38183. _colorTextureArray: Nullable<WebGLTexture>;
  38184. /** @hidden */
  38185. _depthStencilTextureArray: Nullable<WebGLTexture>;
  38186. /** @hidden */
  38187. _lodTextureHigh: Nullable<BaseTexture>;
  38188. /** @hidden */
  38189. _lodTextureMid: Nullable<BaseTexture>;
  38190. /** @hidden */
  38191. _lodTextureLow: Nullable<BaseTexture>;
  38192. /** @hidden */
  38193. _isRGBD: boolean;
  38194. /** @hidden */
  38195. _linearSpecularLOD: boolean;
  38196. /** @hidden */
  38197. _irradianceTexture: Nullable<BaseTexture>;
  38198. /** @hidden */
  38199. _webGLTexture: Nullable<WebGLTexture>;
  38200. /** @hidden */
  38201. _references: number;
  38202. /** @hidden */
  38203. _gammaSpace: Nullable<boolean>;
  38204. private _engine;
  38205. /**
  38206. * Gets the Engine the texture belongs to.
  38207. * @returns The babylon engine
  38208. */
  38209. getEngine(): ThinEngine;
  38210. /**
  38211. * Gets the data source type of the texture
  38212. */
  38213. get source(): InternalTextureSource;
  38214. /**
  38215. * Creates a new InternalTexture
  38216. * @param engine defines the engine to use
  38217. * @param source defines the type of data that will be used
  38218. * @param delayAllocation if the texture allocation should be delayed (default: false)
  38219. */
  38220. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  38221. /**
  38222. * Increments the number of references (ie. the number of Texture that point to it)
  38223. */
  38224. incrementReferences(): void;
  38225. /**
  38226. * Change the size of the texture (not the size of the content)
  38227. * @param width defines the new width
  38228. * @param height defines the new height
  38229. * @param depth defines the new depth (1 by default)
  38230. */
  38231. updateSize(width: int, height: int, depth?: int): void;
  38232. /** @hidden */
  38233. _rebuild(): void;
  38234. /** @hidden */
  38235. _swapAndDie(target: InternalTexture): void;
  38236. /**
  38237. * Dispose the current allocated resources
  38238. */
  38239. dispose(): void;
  38240. }
  38241. }
  38242. declare module "babylonjs/Audio/analyser" {
  38243. import { Scene } from "babylonjs/scene";
  38244. /**
  38245. * Class used to work with sound analyzer using fast fourier transform (FFT)
  38246. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38247. */
  38248. export class Analyser {
  38249. /**
  38250. * Gets or sets the smoothing
  38251. * @ignorenaming
  38252. */
  38253. SMOOTHING: number;
  38254. /**
  38255. * Gets or sets the FFT table size
  38256. * @ignorenaming
  38257. */
  38258. FFT_SIZE: number;
  38259. /**
  38260. * Gets or sets the bar graph amplitude
  38261. * @ignorenaming
  38262. */
  38263. BARGRAPHAMPLITUDE: number;
  38264. /**
  38265. * Gets or sets the position of the debug canvas
  38266. * @ignorenaming
  38267. */
  38268. DEBUGCANVASPOS: {
  38269. x: number;
  38270. y: number;
  38271. };
  38272. /**
  38273. * Gets or sets the debug canvas size
  38274. * @ignorenaming
  38275. */
  38276. DEBUGCANVASSIZE: {
  38277. width: number;
  38278. height: number;
  38279. };
  38280. private _byteFreqs;
  38281. private _byteTime;
  38282. private _floatFreqs;
  38283. private _webAudioAnalyser;
  38284. private _debugCanvas;
  38285. private _debugCanvasContext;
  38286. private _scene;
  38287. private _registerFunc;
  38288. private _audioEngine;
  38289. /**
  38290. * Creates a new analyser
  38291. * @param scene defines hosting scene
  38292. */
  38293. constructor(scene: Scene);
  38294. /**
  38295. * Get the number of data values you will have to play with for the visualization
  38296. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  38297. * @returns a number
  38298. */
  38299. getFrequencyBinCount(): number;
  38300. /**
  38301. * Gets the current frequency data as a byte array
  38302. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38303. * @returns a Uint8Array
  38304. */
  38305. getByteFrequencyData(): Uint8Array;
  38306. /**
  38307. * Gets the current waveform as a byte array
  38308. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  38309. * @returns a Uint8Array
  38310. */
  38311. getByteTimeDomainData(): Uint8Array;
  38312. /**
  38313. * Gets the current frequency data as a float array
  38314. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  38315. * @returns a Float32Array
  38316. */
  38317. getFloatFrequencyData(): Float32Array;
  38318. /**
  38319. * Renders the debug canvas
  38320. */
  38321. drawDebugCanvas(): void;
  38322. /**
  38323. * Stops rendering the debug canvas and removes it
  38324. */
  38325. stopDebugCanvas(): void;
  38326. /**
  38327. * Connects two audio nodes
  38328. * @param inputAudioNode defines first node to connect
  38329. * @param outputAudioNode defines second node to connect
  38330. */
  38331. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  38332. /**
  38333. * Releases all associated resources
  38334. */
  38335. dispose(): void;
  38336. }
  38337. }
  38338. declare module "babylonjs/Audio/audioEngine" {
  38339. import { IDisposable } from "babylonjs/scene";
  38340. import { Analyser } from "babylonjs/Audio/analyser";
  38341. import { Nullable } from "babylonjs/types";
  38342. import { Observable } from "babylonjs/Misc/observable";
  38343. /**
  38344. * This represents an audio engine and it is responsible
  38345. * to play, synchronize and analyse sounds throughout the application.
  38346. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38347. */
  38348. export interface IAudioEngine extends IDisposable {
  38349. /**
  38350. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38351. */
  38352. readonly canUseWebAudio: boolean;
  38353. /**
  38354. * Gets the current AudioContext if available.
  38355. */
  38356. readonly audioContext: Nullable<AudioContext>;
  38357. /**
  38358. * The master gain node defines the global audio volume of your audio engine.
  38359. */
  38360. readonly masterGain: GainNode;
  38361. /**
  38362. * Gets whether or not mp3 are supported by your browser.
  38363. */
  38364. readonly isMP3supported: boolean;
  38365. /**
  38366. * Gets whether or not ogg are supported by your browser.
  38367. */
  38368. readonly isOGGsupported: boolean;
  38369. /**
  38370. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38371. * @ignoreNaming
  38372. */
  38373. WarnedWebAudioUnsupported: boolean;
  38374. /**
  38375. * Defines if the audio engine relies on a custom unlocked button.
  38376. * In this case, the embedded button will not be displayed.
  38377. */
  38378. useCustomUnlockedButton: boolean;
  38379. /**
  38380. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  38381. */
  38382. readonly unlocked: boolean;
  38383. /**
  38384. * Event raised when audio has been unlocked on the browser.
  38385. */
  38386. onAudioUnlockedObservable: Observable<AudioEngine>;
  38387. /**
  38388. * Event raised when audio has been locked on the browser.
  38389. */
  38390. onAudioLockedObservable: Observable<AudioEngine>;
  38391. /**
  38392. * Flags the audio engine in Locked state.
  38393. * This happens due to new browser policies preventing audio to autoplay.
  38394. */
  38395. lock(): void;
  38396. /**
  38397. * Unlocks the audio engine once a user action has been done on the dom.
  38398. * This is helpful to resume play once browser policies have been satisfied.
  38399. */
  38400. unlock(): void;
  38401. /**
  38402. * Gets the global volume sets on the master gain.
  38403. * @returns the global volume if set or -1 otherwise
  38404. */
  38405. getGlobalVolume(): number;
  38406. /**
  38407. * Sets the global volume of your experience (sets on the master gain).
  38408. * @param newVolume Defines the new global volume of the application
  38409. */
  38410. setGlobalVolume(newVolume: number): void;
  38411. /**
  38412. * Connect the audio engine to an audio analyser allowing some amazing
  38413. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38414. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38415. * @param analyser The analyser to connect to the engine
  38416. */
  38417. connectToAnalyser(analyser: Analyser): void;
  38418. }
  38419. /**
  38420. * This represents the default audio engine used in babylon.
  38421. * It is responsible to play, synchronize and analyse sounds throughout the application.
  38422. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  38423. */
  38424. export class AudioEngine implements IAudioEngine {
  38425. private _audioContext;
  38426. private _audioContextInitialized;
  38427. private _muteButton;
  38428. private _hostElement;
  38429. /**
  38430. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  38431. */
  38432. canUseWebAudio: boolean;
  38433. /**
  38434. * The master gain node defines the global audio volume of your audio engine.
  38435. */
  38436. masterGain: GainNode;
  38437. /**
  38438. * Defines if Babylon should emit a warning if WebAudio is not supported.
  38439. * @ignoreNaming
  38440. */
  38441. WarnedWebAudioUnsupported: boolean;
  38442. /**
  38443. * Gets whether or not mp3 are supported by your browser.
  38444. */
  38445. isMP3supported: boolean;
  38446. /**
  38447. * Gets whether or not ogg are supported by your browser.
  38448. */
  38449. isOGGsupported: boolean;
  38450. /**
  38451. * Gets whether audio has been unlocked on the device.
  38452. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  38453. * a user interaction has happened.
  38454. */
  38455. unlocked: boolean;
  38456. /**
  38457. * Defines if the audio engine relies on a custom unlocked button.
  38458. * In this case, the embedded button will not be displayed.
  38459. */
  38460. useCustomUnlockedButton: boolean;
  38461. /**
  38462. * Event raised when audio has been unlocked on the browser.
  38463. */
  38464. onAudioUnlockedObservable: Observable<AudioEngine>;
  38465. /**
  38466. * Event raised when audio has been locked on the browser.
  38467. */
  38468. onAudioLockedObservable: Observable<AudioEngine>;
  38469. /**
  38470. * Gets the current AudioContext if available.
  38471. */
  38472. get audioContext(): Nullable<AudioContext>;
  38473. private _connectedAnalyser;
  38474. /**
  38475. * Instantiates a new audio engine.
  38476. *
  38477. * There should be only one per page as some browsers restrict the number
  38478. * of audio contexts you can create.
  38479. * @param hostElement defines the host element where to display the mute icon if necessary
  38480. */
  38481. constructor(hostElement?: Nullable<HTMLElement>);
  38482. /**
  38483. * Flags the audio engine in Locked state.
  38484. * This happens due to new browser policies preventing audio to autoplay.
  38485. */
  38486. lock(): void;
  38487. /**
  38488. * Unlocks the audio engine once a user action has been done on the dom.
  38489. * This is helpful to resume play once browser policies have been satisfied.
  38490. */
  38491. unlock(): void;
  38492. private _resumeAudioContext;
  38493. private _initializeAudioContext;
  38494. private _tryToRun;
  38495. private _triggerRunningState;
  38496. private _triggerSuspendedState;
  38497. private _displayMuteButton;
  38498. private _moveButtonToTopLeft;
  38499. private _onResize;
  38500. private _hideMuteButton;
  38501. /**
  38502. * Destroy and release the resources associated with the audio ccontext.
  38503. */
  38504. dispose(): void;
  38505. /**
  38506. * Gets the global volume sets on the master gain.
  38507. * @returns the global volume if set or -1 otherwise
  38508. */
  38509. getGlobalVolume(): number;
  38510. /**
  38511. * Sets the global volume of your experience (sets on the master gain).
  38512. * @param newVolume Defines the new global volume of the application
  38513. */
  38514. setGlobalVolume(newVolume: number): void;
  38515. /**
  38516. * Connect the audio engine to an audio analyser allowing some amazing
  38517. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  38518. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  38519. * @param analyser The analyser to connect to the engine
  38520. */
  38521. connectToAnalyser(analyser: Analyser): void;
  38522. }
  38523. }
  38524. declare module "babylonjs/Loading/loadingScreen" {
  38525. /**
  38526. * Interface used to present a loading screen while loading a scene
  38527. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38528. */
  38529. export interface ILoadingScreen {
  38530. /**
  38531. * Function called to display the loading screen
  38532. */
  38533. displayLoadingUI: () => void;
  38534. /**
  38535. * Function called to hide the loading screen
  38536. */
  38537. hideLoadingUI: () => void;
  38538. /**
  38539. * Gets or sets the color to use for the background
  38540. */
  38541. loadingUIBackgroundColor: string;
  38542. /**
  38543. * Gets or sets the text to display while loading
  38544. */
  38545. loadingUIText: string;
  38546. }
  38547. /**
  38548. * Class used for the default loading screen
  38549. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  38550. */
  38551. export class DefaultLoadingScreen implements ILoadingScreen {
  38552. private _renderingCanvas;
  38553. private _loadingText;
  38554. private _loadingDivBackgroundColor;
  38555. private _loadingDiv;
  38556. private _loadingTextDiv;
  38557. /** Gets or sets the logo url to use for the default loading screen */
  38558. static DefaultLogoUrl: string;
  38559. /** Gets or sets the spinner url to use for the default loading screen */
  38560. static DefaultSpinnerUrl: string;
  38561. /**
  38562. * Creates a new default loading screen
  38563. * @param _renderingCanvas defines the canvas used to render the scene
  38564. * @param _loadingText defines the default text to display
  38565. * @param _loadingDivBackgroundColor defines the default background color
  38566. */
  38567. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  38568. /**
  38569. * Function called to display the loading screen
  38570. */
  38571. displayLoadingUI(): void;
  38572. /**
  38573. * Function called to hide the loading screen
  38574. */
  38575. hideLoadingUI(): void;
  38576. /**
  38577. * Gets or sets the text to display while loading
  38578. */
  38579. set loadingUIText(text: string);
  38580. get loadingUIText(): string;
  38581. /**
  38582. * Gets or sets the color to use for the background
  38583. */
  38584. get loadingUIBackgroundColor(): string;
  38585. set loadingUIBackgroundColor(color: string);
  38586. private _resizeLoadingUI;
  38587. }
  38588. }
  38589. declare module "babylonjs/Misc/customAnimationFrameRequester" {
  38590. /**
  38591. * Interface for any object that can request an animation frame
  38592. */
  38593. export interface ICustomAnimationFrameRequester {
  38594. /**
  38595. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  38596. */
  38597. renderFunction?: Function;
  38598. /**
  38599. * Called to request the next frame to render to
  38600. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  38601. */
  38602. requestAnimationFrame: Function;
  38603. /**
  38604. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  38605. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  38606. */
  38607. requestID?: number;
  38608. }
  38609. }
  38610. declare module "babylonjs/Misc/performanceMonitor" {
  38611. /**
  38612. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  38613. */
  38614. export class PerformanceMonitor {
  38615. private _enabled;
  38616. private _rollingFrameTime;
  38617. private _lastFrameTimeMs;
  38618. /**
  38619. * constructor
  38620. * @param frameSampleSize The number of samples required to saturate the sliding window
  38621. */
  38622. constructor(frameSampleSize?: number);
  38623. /**
  38624. * Samples current frame
  38625. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  38626. */
  38627. sampleFrame(timeMs?: number): void;
  38628. /**
  38629. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38630. */
  38631. get averageFrameTime(): number;
  38632. /**
  38633. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  38634. */
  38635. get averageFrameTimeVariance(): number;
  38636. /**
  38637. * Returns the frame time of the most recent frame
  38638. */
  38639. get instantaneousFrameTime(): number;
  38640. /**
  38641. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  38642. */
  38643. get averageFPS(): number;
  38644. /**
  38645. * Returns the average framerate in frames per second using the most recent frame time
  38646. */
  38647. get instantaneousFPS(): number;
  38648. /**
  38649. * Returns true if enough samples have been taken to completely fill the sliding window
  38650. */
  38651. get isSaturated(): boolean;
  38652. /**
  38653. * Enables contributions to the sliding window sample set
  38654. */
  38655. enable(): void;
  38656. /**
  38657. * Disables contributions to the sliding window sample set
  38658. * Samples will not be interpolated over the disabled period
  38659. */
  38660. disable(): void;
  38661. /**
  38662. * Returns true if sampling is enabled
  38663. */
  38664. get isEnabled(): boolean;
  38665. /**
  38666. * Resets performance monitor
  38667. */
  38668. reset(): void;
  38669. }
  38670. /**
  38671. * RollingAverage
  38672. *
  38673. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  38674. */
  38675. export class RollingAverage {
  38676. /**
  38677. * Current average
  38678. */
  38679. average: number;
  38680. /**
  38681. * Current variance
  38682. */
  38683. variance: number;
  38684. protected _samples: Array<number>;
  38685. protected _sampleCount: number;
  38686. protected _pos: number;
  38687. protected _m2: number;
  38688. /**
  38689. * constructor
  38690. * @param length The number of samples required to saturate the sliding window
  38691. */
  38692. constructor(length: number);
  38693. /**
  38694. * Adds a sample to the sample set
  38695. * @param v The sample value
  38696. */
  38697. add(v: number): void;
  38698. /**
  38699. * Returns previously added values or null if outside of history or outside the sliding window domain
  38700. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  38701. * @return Value previously recorded with add() or null if outside of range
  38702. */
  38703. history(i: number): number;
  38704. /**
  38705. * Returns true if enough samples have been taken to completely fill the sliding window
  38706. * @return true if sample-set saturated
  38707. */
  38708. isSaturated(): boolean;
  38709. /**
  38710. * Resets the rolling average (equivalent to 0 samples taken so far)
  38711. */
  38712. reset(): void;
  38713. /**
  38714. * Wraps a value around the sample range boundaries
  38715. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  38716. * @return Wrapped position in sample range
  38717. */
  38718. protected _wrapPosition(i: number): number;
  38719. }
  38720. }
  38721. declare module "babylonjs/Misc/perfCounter" {
  38722. /**
  38723. * This class is used to track a performance counter which is number based.
  38724. * The user has access to many properties which give statistics of different nature.
  38725. *
  38726. * The implementer can track two kinds of Performance Counter: time and count.
  38727. * 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.
  38728. * 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.
  38729. */
  38730. export class PerfCounter {
  38731. /**
  38732. * Gets or sets a global boolean to turn on and off all the counters
  38733. */
  38734. static Enabled: boolean;
  38735. /**
  38736. * Returns the smallest value ever
  38737. */
  38738. get min(): number;
  38739. /**
  38740. * Returns the biggest value ever
  38741. */
  38742. get max(): number;
  38743. /**
  38744. * Returns the average value since the performance counter is running
  38745. */
  38746. get average(): number;
  38747. /**
  38748. * Returns the average value of the last second the counter was monitored
  38749. */
  38750. get lastSecAverage(): number;
  38751. /**
  38752. * Returns the current value
  38753. */
  38754. get current(): number;
  38755. /**
  38756. * Gets the accumulated total
  38757. */
  38758. get total(): number;
  38759. /**
  38760. * Gets the total value count
  38761. */
  38762. get count(): number;
  38763. /**
  38764. * Creates a new counter
  38765. */
  38766. constructor();
  38767. /**
  38768. * Call this method to start monitoring a new frame.
  38769. * 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.
  38770. */
  38771. fetchNewFrame(): void;
  38772. /**
  38773. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  38774. * @param newCount the count value to add to the monitored count
  38775. * @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.
  38776. */
  38777. addCount(newCount: number, fetchResult: boolean): void;
  38778. /**
  38779. * Start monitoring this performance counter
  38780. */
  38781. beginMonitoring(): void;
  38782. /**
  38783. * Compute the time lapsed since the previous beginMonitoring() call.
  38784. * @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
  38785. */
  38786. endMonitoring(newFrame?: boolean): void;
  38787. private _fetchResult;
  38788. private _startMonitoringTime;
  38789. private _min;
  38790. private _max;
  38791. private _average;
  38792. private _current;
  38793. private _totalValueCount;
  38794. private _totalAccumulated;
  38795. private _lastSecAverage;
  38796. private _lastSecAccumulated;
  38797. private _lastSecTime;
  38798. private _lastSecValueCount;
  38799. }
  38800. }
  38801. declare module "babylonjs/Engines/Extensions/engine.readTexture" {
  38802. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38803. import { Nullable } from "babylonjs/types";
  38804. module "babylonjs/Engines/thinEngine" {
  38805. interface ThinEngine {
  38806. /** @hidden */
  38807. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  38808. }
  38809. }
  38810. }
  38811. declare module "babylonjs/Engines/engine" {
  38812. import { Observable } from "babylonjs/Misc/observable";
  38813. import { Nullable } from "babylonjs/types";
  38814. import { Scene } from "babylonjs/scene";
  38815. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  38816. import { IAudioEngine } from "babylonjs/Audio/audioEngine";
  38817. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  38818. import { ILoadingScreen } from "babylonjs/Loading/loadingScreen";
  38819. import { WebGLPipelineContext } from "babylonjs/Engines/WebGL/webGLPipelineContext";
  38820. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  38821. import { ICustomAnimationFrameRequester } from "babylonjs/Misc/customAnimationFrameRequester";
  38822. import { ThinEngine, EngineOptions } from "babylonjs/Engines/thinEngine";
  38823. import { IViewportLike, IColor4Like } from "babylonjs/Maths/math.like";
  38824. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  38825. import { PerformanceMonitor } from "babylonjs/Misc/performanceMonitor";
  38826. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  38827. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  38828. import "babylonjs/Engines/Extensions/engine.alpha";
  38829. import "babylonjs/Engines/Extensions/engine.readTexture";
  38830. import "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  38831. import { Material } from "babylonjs/Materials/material";
  38832. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  38833. /**
  38834. * Defines the interface used by display changed events
  38835. */
  38836. export interface IDisplayChangedEventArgs {
  38837. /** Gets the vrDisplay object (if any) */
  38838. vrDisplay: Nullable<any>;
  38839. /** Gets a boolean indicating if webVR is supported */
  38840. vrSupported: boolean;
  38841. }
  38842. /**
  38843. * Defines the interface used by objects containing a viewport (like a camera)
  38844. */
  38845. interface IViewportOwnerLike {
  38846. /**
  38847. * Gets or sets the viewport
  38848. */
  38849. viewport: IViewportLike;
  38850. }
  38851. /**
  38852. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  38853. */
  38854. export class Engine extends ThinEngine {
  38855. /** Defines that alpha blending is disabled */
  38856. static readonly ALPHA_DISABLE: number;
  38857. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  38858. static readonly ALPHA_ADD: number;
  38859. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  38860. static readonly ALPHA_COMBINE: number;
  38861. /** Defines that alpha blending to DEST - SRC * DEST */
  38862. static readonly ALPHA_SUBTRACT: number;
  38863. /** Defines that alpha blending to SRC * DEST */
  38864. static readonly ALPHA_MULTIPLY: number;
  38865. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  38866. static readonly ALPHA_MAXIMIZED: number;
  38867. /** Defines that alpha blending to SRC + DEST */
  38868. static readonly ALPHA_ONEONE: number;
  38869. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  38870. static readonly ALPHA_PREMULTIPLIED: number;
  38871. /**
  38872. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  38873. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  38874. */
  38875. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  38876. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  38877. static readonly ALPHA_INTERPOLATE: number;
  38878. /**
  38879. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  38880. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  38881. */
  38882. static readonly ALPHA_SCREENMODE: number;
  38883. /** Defines that the ressource is not delayed*/
  38884. static readonly DELAYLOADSTATE_NONE: number;
  38885. /** Defines that the ressource was successfully delay loaded */
  38886. static readonly DELAYLOADSTATE_LOADED: number;
  38887. /** Defines that the ressource is currently delay loading */
  38888. static readonly DELAYLOADSTATE_LOADING: number;
  38889. /** Defines that the ressource is delayed and has not started loading */
  38890. static readonly DELAYLOADSTATE_NOTLOADED: number;
  38891. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  38892. static readonly NEVER: number;
  38893. /** 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 */
  38894. static readonly ALWAYS: number;
  38895. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  38896. static readonly LESS: number;
  38897. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  38898. static readonly EQUAL: number;
  38899. /** 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 */
  38900. static readonly LEQUAL: number;
  38901. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  38902. static readonly GREATER: number;
  38903. /** 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 */
  38904. static readonly GEQUAL: number;
  38905. /** 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 */
  38906. static readonly NOTEQUAL: number;
  38907. /** Passed to stencilOperation to specify that stencil value must be kept */
  38908. static readonly KEEP: number;
  38909. /** Passed to stencilOperation to specify that stencil value must be replaced */
  38910. static readonly REPLACE: number;
  38911. /** Passed to stencilOperation to specify that stencil value must be incremented */
  38912. static readonly INCR: number;
  38913. /** Passed to stencilOperation to specify that stencil value must be decremented */
  38914. static readonly DECR: number;
  38915. /** Passed to stencilOperation to specify that stencil value must be inverted */
  38916. static readonly INVERT: number;
  38917. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  38918. static readonly INCR_WRAP: number;
  38919. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  38920. static readonly DECR_WRAP: number;
  38921. /** Texture is not repeating outside of 0..1 UVs */
  38922. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  38923. /** Texture is repeating outside of 0..1 UVs */
  38924. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  38925. /** Texture is repeating and mirrored */
  38926. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  38927. /** ALPHA */
  38928. static readonly TEXTUREFORMAT_ALPHA: number;
  38929. /** LUMINANCE */
  38930. static readonly TEXTUREFORMAT_LUMINANCE: number;
  38931. /** LUMINANCE_ALPHA */
  38932. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  38933. /** RGB */
  38934. static readonly TEXTUREFORMAT_RGB: number;
  38935. /** RGBA */
  38936. static readonly TEXTUREFORMAT_RGBA: number;
  38937. /** RED */
  38938. static readonly TEXTUREFORMAT_RED: number;
  38939. /** RED (2nd reference) */
  38940. static readonly TEXTUREFORMAT_R: number;
  38941. /** RG */
  38942. static readonly TEXTUREFORMAT_RG: number;
  38943. /** RED_INTEGER */
  38944. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  38945. /** RED_INTEGER (2nd reference) */
  38946. static readonly TEXTUREFORMAT_R_INTEGER: number;
  38947. /** RG_INTEGER */
  38948. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  38949. /** RGB_INTEGER */
  38950. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  38951. /** RGBA_INTEGER */
  38952. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  38953. /** UNSIGNED_BYTE */
  38954. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  38955. /** UNSIGNED_BYTE (2nd reference) */
  38956. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  38957. /** FLOAT */
  38958. static readonly TEXTURETYPE_FLOAT: number;
  38959. /** HALF_FLOAT */
  38960. static readonly TEXTURETYPE_HALF_FLOAT: number;
  38961. /** BYTE */
  38962. static readonly TEXTURETYPE_BYTE: number;
  38963. /** SHORT */
  38964. static readonly TEXTURETYPE_SHORT: number;
  38965. /** UNSIGNED_SHORT */
  38966. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  38967. /** INT */
  38968. static readonly TEXTURETYPE_INT: number;
  38969. /** UNSIGNED_INT */
  38970. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  38971. /** UNSIGNED_SHORT_4_4_4_4 */
  38972. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  38973. /** UNSIGNED_SHORT_5_5_5_1 */
  38974. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  38975. /** UNSIGNED_SHORT_5_6_5 */
  38976. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  38977. /** UNSIGNED_INT_2_10_10_10_REV */
  38978. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  38979. /** UNSIGNED_INT_24_8 */
  38980. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  38981. /** UNSIGNED_INT_10F_11F_11F_REV */
  38982. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  38983. /** UNSIGNED_INT_5_9_9_9_REV */
  38984. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  38985. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  38986. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  38987. /** nearest is mag = nearest and min = nearest and mip = linear */
  38988. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  38989. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38990. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  38991. /** Trilinear is mag = linear and min = linear and mip = linear */
  38992. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  38993. /** nearest is mag = nearest and min = nearest and mip = linear */
  38994. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  38995. /** Bilinear is mag = linear and min = linear and mip = nearest */
  38996. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  38997. /** Trilinear is mag = linear and min = linear and mip = linear */
  38998. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  38999. /** mag = nearest and min = nearest and mip = nearest */
  39000. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  39001. /** mag = nearest and min = linear and mip = nearest */
  39002. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  39003. /** mag = nearest and min = linear and mip = linear */
  39004. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  39005. /** mag = nearest and min = linear and mip = none */
  39006. static readonly TEXTURE_NEAREST_LINEAR: number;
  39007. /** mag = nearest and min = nearest and mip = none */
  39008. static readonly TEXTURE_NEAREST_NEAREST: number;
  39009. /** mag = linear and min = nearest and mip = nearest */
  39010. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  39011. /** mag = linear and min = nearest and mip = linear */
  39012. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  39013. /** mag = linear and min = linear and mip = none */
  39014. static readonly TEXTURE_LINEAR_LINEAR: number;
  39015. /** mag = linear and min = nearest and mip = none */
  39016. static readonly TEXTURE_LINEAR_NEAREST: number;
  39017. /** Explicit coordinates mode */
  39018. static readonly TEXTURE_EXPLICIT_MODE: number;
  39019. /** Spherical coordinates mode */
  39020. static readonly TEXTURE_SPHERICAL_MODE: number;
  39021. /** Planar coordinates mode */
  39022. static readonly TEXTURE_PLANAR_MODE: number;
  39023. /** Cubic coordinates mode */
  39024. static readonly TEXTURE_CUBIC_MODE: number;
  39025. /** Projection coordinates mode */
  39026. static readonly TEXTURE_PROJECTION_MODE: number;
  39027. /** Skybox coordinates mode */
  39028. static readonly TEXTURE_SKYBOX_MODE: number;
  39029. /** Inverse Cubic coordinates mode */
  39030. static readonly TEXTURE_INVCUBIC_MODE: number;
  39031. /** Equirectangular coordinates mode */
  39032. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  39033. /** Equirectangular Fixed coordinates mode */
  39034. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  39035. /** Equirectangular Fixed Mirrored coordinates mode */
  39036. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  39037. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  39038. static readonly SCALEMODE_FLOOR: number;
  39039. /** Defines that texture rescaling will look for the nearest power of 2 size */
  39040. static readonly SCALEMODE_NEAREST: number;
  39041. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  39042. static readonly SCALEMODE_CEILING: number;
  39043. /**
  39044. * Returns the current npm package of the sdk
  39045. */
  39046. static get NpmPackage(): string;
  39047. /**
  39048. * Returns the current version of the framework
  39049. */
  39050. static get Version(): string;
  39051. /** Gets the list of created engines */
  39052. static get Instances(): Engine[];
  39053. /**
  39054. * Gets the latest created engine
  39055. */
  39056. static get LastCreatedEngine(): Nullable<Engine>;
  39057. /**
  39058. * Gets the latest created scene
  39059. */
  39060. static get LastCreatedScene(): Nullable<Scene>;
  39061. /**
  39062. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  39063. * @param flag defines which part of the materials must be marked as dirty
  39064. * @param predicate defines a predicate used to filter which materials should be affected
  39065. */
  39066. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  39067. /**
  39068. * Method called to create the default loading screen.
  39069. * This can be overriden in your own app.
  39070. * @param canvas The rendering canvas element
  39071. * @returns The loading screen
  39072. */
  39073. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  39074. /**
  39075. * Method called to create the default rescale post process on each engine.
  39076. */
  39077. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  39078. /**
  39079. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  39080. **/
  39081. enableOfflineSupport: boolean;
  39082. /**
  39083. * 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)
  39084. **/
  39085. disableManifestCheck: boolean;
  39086. /**
  39087. * Gets the list of created scenes
  39088. */
  39089. scenes: Scene[];
  39090. /**
  39091. * Event raised when a new scene is created
  39092. */
  39093. onNewSceneAddedObservable: Observable<Scene>;
  39094. /**
  39095. * Gets the list of created postprocesses
  39096. */
  39097. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  39098. /**
  39099. * Gets a boolean indicating if the pointer is currently locked
  39100. */
  39101. isPointerLock: boolean;
  39102. /**
  39103. * Observable event triggered each time the rendering canvas is resized
  39104. */
  39105. onResizeObservable: Observable<Engine>;
  39106. /**
  39107. * Observable event triggered each time the canvas loses focus
  39108. */
  39109. onCanvasBlurObservable: Observable<Engine>;
  39110. /**
  39111. * Observable event triggered each time the canvas gains focus
  39112. */
  39113. onCanvasFocusObservable: Observable<Engine>;
  39114. /**
  39115. * Observable event triggered each time the canvas receives pointerout event
  39116. */
  39117. onCanvasPointerOutObservable: Observable<PointerEvent>;
  39118. /**
  39119. * Observable raised when the engine begins a new frame
  39120. */
  39121. onBeginFrameObservable: Observable<Engine>;
  39122. /**
  39123. * If set, will be used to request the next animation frame for the render loop
  39124. */
  39125. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  39126. /**
  39127. * Observable raised when the engine ends the current frame
  39128. */
  39129. onEndFrameObservable: Observable<Engine>;
  39130. /**
  39131. * Observable raised when the engine is about to compile a shader
  39132. */
  39133. onBeforeShaderCompilationObservable: Observable<Engine>;
  39134. /**
  39135. * Observable raised when the engine has jsut compiled a shader
  39136. */
  39137. onAfterShaderCompilationObservable: Observable<Engine>;
  39138. /**
  39139. * Gets the audio engine
  39140. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  39141. * @ignorenaming
  39142. */
  39143. static audioEngine: IAudioEngine;
  39144. /**
  39145. * Default AudioEngine factory responsible of creating the Audio Engine.
  39146. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  39147. */
  39148. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  39149. /**
  39150. * Default offline support factory responsible of creating a tool used to store data locally.
  39151. * By default, this will create a Database object if the workload has been embedded.
  39152. */
  39153. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  39154. private _loadingScreen;
  39155. private _pointerLockRequested;
  39156. private _rescalePostProcess;
  39157. private _deterministicLockstep;
  39158. private _lockstepMaxSteps;
  39159. private _timeStep;
  39160. protected get _supportsHardwareTextureRescaling(): boolean;
  39161. private _fps;
  39162. private _deltaTime;
  39163. /** @hidden */
  39164. _drawCalls: PerfCounter;
  39165. /** 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 */
  39166. canvasTabIndex: number;
  39167. /**
  39168. * Turn this value on if you want to pause FPS computation when in background
  39169. */
  39170. disablePerformanceMonitorInBackground: boolean;
  39171. private _performanceMonitor;
  39172. /**
  39173. * Gets the performance monitor attached to this engine
  39174. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  39175. */
  39176. get performanceMonitor(): PerformanceMonitor;
  39177. private _onFocus;
  39178. private _onBlur;
  39179. private _onCanvasPointerOut;
  39180. private _onCanvasBlur;
  39181. private _onCanvasFocus;
  39182. private _onFullscreenChange;
  39183. private _onPointerLockChange;
  39184. /**
  39185. * Gets the HTML element used to attach event listeners
  39186. * @returns a HTML element
  39187. */
  39188. getInputElement(): Nullable<HTMLElement>;
  39189. /**
  39190. * Creates a new engine
  39191. * @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
  39192. * @param antialias defines enable antialiasing (default: false)
  39193. * @param options defines further options to be sent to the getContext() function
  39194. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  39195. */
  39196. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  39197. /**
  39198. * Gets current aspect ratio
  39199. * @param viewportOwner defines the camera to use to get the aspect ratio
  39200. * @param useScreen defines if screen size must be used (or the current render target if any)
  39201. * @returns a number defining the aspect ratio
  39202. */
  39203. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  39204. /**
  39205. * Gets current screen aspect ratio
  39206. * @returns a number defining the aspect ratio
  39207. */
  39208. getScreenAspectRatio(): number;
  39209. /**
  39210. * Gets the client rect of the HTML canvas attached with the current webGL context
  39211. * @returns a client rectanglee
  39212. */
  39213. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  39214. /**
  39215. * Gets the client rect of the HTML element used for events
  39216. * @returns a client rectanglee
  39217. */
  39218. getInputElementClientRect(): Nullable<ClientRect>;
  39219. /**
  39220. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  39221. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39222. * @returns true if engine is in deterministic lock step mode
  39223. */
  39224. isDeterministicLockStep(): boolean;
  39225. /**
  39226. * Gets the max steps when engine is running in deterministic lock step
  39227. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  39228. * @returns the max steps
  39229. */
  39230. getLockstepMaxSteps(): number;
  39231. /**
  39232. * Returns the time in ms between steps when using deterministic lock step.
  39233. * @returns time step in (ms)
  39234. */
  39235. getTimeStep(): number;
  39236. /**
  39237. * Force the mipmap generation for the given render target texture
  39238. * @param texture defines the render target texture to use
  39239. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  39240. */
  39241. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  39242. /** States */
  39243. /**
  39244. * Set various states to the webGL context
  39245. * @param culling defines backface culling state
  39246. * @param zOffset defines the value to apply to zOffset (0 by default)
  39247. * @param force defines if states must be applied even if cache is up to date
  39248. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  39249. */
  39250. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  39251. /**
  39252. * Set the z offset to apply to current rendering
  39253. * @param value defines the offset to apply
  39254. */
  39255. setZOffset(value: number): void;
  39256. /**
  39257. * Gets the current value of the zOffset
  39258. * @returns the current zOffset state
  39259. */
  39260. getZOffset(): number;
  39261. /**
  39262. * Enable or disable depth buffering
  39263. * @param enable defines the state to set
  39264. */
  39265. setDepthBuffer(enable: boolean): void;
  39266. /**
  39267. * Gets a boolean indicating if depth writing is enabled
  39268. * @returns the current depth writing state
  39269. */
  39270. getDepthWrite(): boolean;
  39271. /**
  39272. * Enable or disable depth writing
  39273. * @param enable defines the state to set
  39274. */
  39275. setDepthWrite(enable: boolean): void;
  39276. /**
  39277. * Gets a boolean indicating if stencil buffer is enabled
  39278. * @returns the current stencil buffer state
  39279. */
  39280. getStencilBuffer(): boolean;
  39281. /**
  39282. * Enable or disable the stencil buffer
  39283. * @param enable defines if the stencil buffer must be enabled or disabled
  39284. */
  39285. setStencilBuffer(enable: boolean): void;
  39286. /**
  39287. * Gets the current stencil mask
  39288. * @returns a number defining the new stencil mask to use
  39289. */
  39290. getStencilMask(): number;
  39291. /**
  39292. * Sets the current stencil mask
  39293. * @param mask defines the new stencil mask to use
  39294. */
  39295. setStencilMask(mask: number): void;
  39296. /**
  39297. * Gets the current stencil function
  39298. * @returns a number defining the stencil function to use
  39299. */
  39300. getStencilFunction(): number;
  39301. /**
  39302. * Gets the current stencil reference value
  39303. * @returns a number defining the stencil reference value to use
  39304. */
  39305. getStencilFunctionReference(): number;
  39306. /**
  39307. * Gets the current stencil mask
  39308. * @returns a number defining the stencil mask to use
  39309. */
  39310. getStencilFunctionMask(): number;
  39311. /**
  39312. * Sets the current stencil function
  39313. * @param stencilFunc defines the new stencil function to use
  39314. */
  39315. setStencilFunction(stencilFunc: number): void;
  39316. /**
  39317. * Sets the current stencil reference
  39318. * @param reference defines the new stencil reference to use
  39319. */
  39320. setStencilFunctionReference(reference: number): void;
  39321. /**
  39322. * Sets the current stencil mask
  39323. * @param mask defines the new stencil mask to use
  39324. */
  39325. setStencilFunctionMask(mask: number): void;
  39326. /**
  39327. * Gets the current stencil operation when stencil fails
  39328. * @returns a number defining stencil operation to use when stencil fails
  39329. */
  39330. getStencilOperationFail(): number;
  39331. /**
  39332. * Gets the current stencil operation when depth fails
  39333. * @returns a number defining stencil operation to use when depth fails
  39334. */
  39335. getStencilOperationDepthFail(): number;
  39336. /**
  39337. * Gets the current stencil operation when stencil passes
  39338. * @returns a number defining stencil operation to use when stencil passes
  39339. */
  39340. getStencilOperationPass(): number;
  39341. /**
  39342. * Sets the stencil operation to use when stencil fails
  39343. * @param operation defines the stencil operation to use when stencil fails
  39344. */
  39345. setStencilOperationFail(operation: number): void;
  39346. /**
  39347. * Sets the stencil operation to use when depth fails
  39348. * @param operation defines the stencil operation to use when depth fails
  39349. */
  39350. setStencilOperationDepthFail(operation: number): void;
  39351. /**
  39352. * Sets the stencil operation to use when stencil passes
  39353. * @param operation defines the stencil operation to use when stencil passes
  39354. */
  39355. setStencilOperationPass(operation: number): void;
  39356. /**
  39357. * Sets a boolean indicating if the dithering state is enabled or disabled
  39358. * @param value defines the dithering state
  39359. */
  39360. setDitheringState(value: boolean): void;
  39361. /**
  39362. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  39363. * @param value defines the rasterizer state
  39364. */
  39365. setRasterizerState(value: boolean): void;
  39366. /**
  39367. * Gets the current depth function
  39368. * @returns a number defining the depth function
  39369. */
  39370. getDepthFunction(): Nullable<number>;
  39371. /**
  39372. * Sets the current depth function
  39373. * @param depthFunc defines the function to use
  39374. */
  39375. setDepthFunction(depthFunc: number): void;
  39376. /**
  39377. * Sets the current depth function to GREATER
  39378. */
  39379. setDepthFunctionToGreater(): void;
  39380. /**
  39381. * Sets the current depth function to GEQUAL
  39382. */
  39383. setDepthFunctionToGreaterOrEqual(): void;
  39384. /**
  39385. * Sets the current depth function to LESS
  39386. */
  39387. setDepthFunctionToLess(): void;
  39388. /**
  39389. * Sets the current depth function to LEQUAL
  39390. */
  39391. setDepthFunctionToLessOrEqual(): void;
  39392. private _cachedStencilBuffer;
  39393. private _cachedStencilFunction;
  39394. private _cachedStencilMask;
  39395. private _cachedStencilOperationPass;
  39396. private _cachedStencilOperationFail;
  39397. private _cachedStencilOperationDepthFail;
  39398. private _cachedStencilReference;
  39399. /**
  39400. * Caches the the state of the stencil buffer
  39401. */
  39402. cacheStencilState(): void;
  39403. /**
  39404. * Restores the state of the stencil buffer
  39405. */
  39406. restoreStencilState(): void;
  39407. /**
  39408. * Directly set the WebGL Viewport
  39409. * @param x defines the x coordinate of the viewport (in screen space)
  39410. * @param y defines the y coordinate of the viewport (in screen space)
  39411. * @param width defines the width of the viewport (in screen space)
  39412. * @param height defines the height of the viewport (in screen space)
  39413. * @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
  39414. */
  39415. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  39416. /**
  39417. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  39418. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39419. * @param y defines the y-coordinate of the corner of the clear rectangle
  39420. * @param width defines the width of the clear rectangle
  39421. * @param height defines the height of the clear rectangle
  39422. * @param clearColor defines the clear color
  39423. */
  39424. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  39425. /**
  39426. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  39427. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  39428. * @param y defines the y-coordinate of the corner of the clear rectangle
  39429. * @param width defines the width of the clear rectangle
  39430. * @param height defines the height of the clear rectangle
  39431. */
  39432. enableScissor(x: number, y: number, width: number, height: number): void;
  39433. /**
  39434. * Disable previously set scissor test rectangle
  39435. */
  39436. disableScissor(): void;
  39437. protected _reportDrawCall(): void;
  39438. /**
  39439. * Initializes a webVR display and starts listening to display change events
  39440. * The onVRDisplayChangedObservable will be notified upon these changes
  39441. * @returns The onVRDisplayChangedObservable
  39442. */
  39443. initWebVR(): Observable<IDisplayChangedEventArgs>;
  39444. /** @hidden */
  39445. _prepareVRComponent(): void;
  39446. /** @hidden */
  39447. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  39448. /** @hidden */
  39449. _submitVRFrame(): void;
  39450. /**
  39451. * Call this function to leave webVR mode
  39452. * Will do nothing if webVR is not supported or if there is no webVR device
  39453. * @see https://doc.babylonjs.com/how_to/webvr_camera
  39454. */
  39455. disableVR(): void;
  39456. /**
  39457. * Gets a boolean indicating that the system is in VR mode and is presenting
  39458. * @returns true if VR mode is engaged
  39459. */
  39460. isVRPresenting(): boolean;
  39461. /** @hidden */
  39462. _requestVRFrame(): void;
  39463. /** @hidden */
  39464. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  39465. /**
  39466. * Gets the source code of the vertex shader associated with a specific webGL program
  39467. * @param program defines the program to use
  39468. * @returns a string containing the source code of the vertex shader associated with the program
  39469. */
  39470. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  39471. /**
  39472. * Gets the source code of the fragment shader associated with a specific webGL program
  39473. * @param program defines the program to use
  39474. * @returns a string containing the source code of the fragment shader associated with the program
  39475. */
  39476. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  39477. /**
  39478. * Sets a depth stencil texture from a render target to the according uniform.
  39479. * @param channel The texture channel
  39480. * @param uniform The uniform to set
  39481. * @param texture The render target texture containing the depth stencil texture to apply
  39482. */
  39483. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  39484. /**
  39485. * Sets a texture to the webGL context from a postprocess
  39486. * @param channel defines the channel to use
  39487. * @param postProcess defines the source postprocess
  39488. */
  39489. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  39490. /**
  39491. * Binds the output of the passed in post process to the texture channel specified
  39492. * @param channel The channel the texture should be bound to
  39493. * @param postProcess The post process which's output should be bound
  39494. */
  39495. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  39496. protected _rebuildBuffers(): void;
  39497. /** @hidden */
  39498. _renderFrame(): void;
  39499. _renderLoop(): void;
  39500. /** @hidden */
  39501. _renderViews(): boolean;
  39502. /**
  39503. * Toggle full screen mode
  39504. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39505. */
  39506. switchFullscreen(requestPointerLock: boolean): void;
  39507. /**
  39508. * Enters full screen mode
  39509. * @param requestPointerLock defines if a pointer lock should be requested from the user
  39510. */
  39511. enterFullscreen(requestPointerLock: boolean): void;
  39512. /**
  39513. * Exits full screen mode
  39514. */
  39515. exitFullscreen(): void;
  39516. /**
  39517. * Enters Pointerlock mode
  39518. */
  39519. enterPointerlock(): void;
  39520. /**
  39521. * Exits Pointerlock mode
  39522. */
  39523. exitPointerlock(): void;
  39524. /**
  39525. * Begin a new frame
  39526. */
  39527. beginFrame(): void;
  39528. /**
  39529. * Enf the current frame
  39530. */
  39531. endFrame(): void;
  39532. resize(): void;
  39533. /**
  39534. * Force a specific size of the canvas
  39535. * @param width defines the new canvas' width
  39536. * @param height defines the new canvas' height
  39537. * @returns true if the size was changed
  39538. */
  39539. setSize(width: number, height: number): boolean;
  39540. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  39541. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39542. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  39543. _releaseTexture(texture: InternalTexture): void;
  39544. /**
  39545. * @hidden
  39546. * Rescales a texture
  39547. * @param source input texutre
  39548. * @param destination destination texture
  39549. * @param scene scene to use to render the resize
  39550. * @param internalFormat format to use when resizing
  39551. * @param onComplete callback to be called when resize has completed
  39552. */
  39553. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  39554. /**
  39555. * Gets the current framerate
  39556. * @returns a number representing the framerate
  39557. */
  39558. getFps(): number;
  39559. /**
  39560. * Gets the time spent between current and previous frame
  39561. * @returns a number representing the delta time in ms
  39562. */
  39563. getDeltaTime(): number;
  39564. private _measureFps;
  39565. /** @hidden */
  39566. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  39567. /**
  39568. * Updates the sample count of a render target texture
  39569. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  39570. * @param texture defines the texture to update
  39571. * @param samples defines the sample count to set
  39572. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  39573. */
  39574. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  39575. /**
  39576. * Updates a depth texture Comparison Mode and Function.
  39577. * If the comparison Function is equal to 0, the mode will be set to none.
  39578. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  39579. * @param texture The texture to set the comparison function for
  39580. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  39581. */
  39582. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  39583. /**
  39584. * Creates a webGL buffer to use with instanciation
  39585. * @param capacity defines the size of the buffer
  39586. * @returns the webGL buffer
  39587. */
  39588. createInstancesBuffer(capacity: number): DataBuffer;
  39589. /**
  39590. * Delete a webGL buffer used with instanciation
  39591. * @param buffer defines the webGL buffer to delete
  39592. */
  39593. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  39594. private _clientWaitAsync;
  39595. /** @hidden */
  39596. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  39597. dispose(): void;
  39598. private _disableTouchAction;
  39599. /**
  39600. * Display the loading screen
  39601. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39602. */
  39603. displayLoadingUI(): void;
  39604. /**
  39605. * Hide the loading screen
  39606. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39607. */
  39608. hideLoadingUI(): void;
  39609. /**
  39610. * Gets the current loading screen object
  39611. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39612. */
  39613. get loadingScreen(): ILoadingScreen;
  39614. /**
  39615. * Sets the current loading screen object
  39616. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39617. */
  39618. set loadingScreen(loadingScreen: ILoadingScreen);
  39619. /**
  39620. * Sets the current loading screen text
  39621. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39622. */
  39623. set loadingUIText(text: string);
  39624. /**
  39625. * Sets the current loading screen background color
  39626. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  39627. */
  39628. set loadingUIBackgroundColor(color: string);
  39629. /** Pointerlock and fullscreen */
  39630. /**
  39631. * Ask the browser to promote the current element to pointerlock mode
  39632. * @param element defines the DOM element to promote
  39633. */
  39634. static _RequestPointerlock(element: HTMLElement): void;
  39635. /**
  39636. * Asks the browser to exit pointerlock mode
  39637. */
  39638. static _ExitPointerlock(): void;
  39639. /**
  39640. * Ask the browser to promote the current element to fullscreen rendering mode
  39641. * @param element defines the DOM element to promote
  39642. */
  39643. static _RequestFullscreen(element: HTMLElement): void;
  39644. /**
  39645. * Asks the browser to exit fullscreen mode
  39646. */
  39647. static _ExitFullscreen(): void;
  39648. }
  39649. }
  39650. declare module "babylonjs/Engines/engineStore" {
  39651. import { Nullable } from "babylonjs/types";
  39652. import { Engine } from "babylonjs/Engines/engine";
  39653. import { Scene } from "babylonjs/scene";
  39654. /**
  39655. * The engine store class is responsible to hold all the instances of Engine and Scene created
  39656. * during the life time of the application.
  39657. */
  39658. export class EngineStore {
  39659. /** Gets the list of created engines */
  39660. static Instances: import("babylonjs/Engines/engine").Engine[];
  39661. /** @hidden */
  39662. static _LastCreatedScene: Nullable<Scene>;
  39663. /**
  39664. * Gets the latest created engine
  39665. */
  39666. static get LastCreatedEngine(): Nullable<Engine>;
  39667. /**
  39668. * Gets the latest created scene
  39669. */
  39670. static get LastCreatedScene(): Nullable<Scene>;
  39671. /**
  39672. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39673. * @ignorenaming
  39674. */
  39675. static UseFallbackTexture: boolean;
  39676. /**
  39677. * Texture content used if a texture cannot loaded
  39678. * @ignorenaming
  39679. */
  39680. static FallbackTexture: string;
  39681. }
  39682. }
  39683. declare module "babylonjs/Misc/promise" {
  39684. /**
  39685. * Helper class that provides a small promise polyfill
  39686. */
  39687. export class PromisePolyfill {
  39688. /**
  39689. * Static function used to check if the polyfill is required
  39690. * If this is the case then the function will inject the polyfill to window.Promise
  39691. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  39692. */
  39693. static Apply(force?: boolean): void;
  39694. }
  39695. }
  39696. declare module "babylonjs/Misc/interfaces/screenshotSize" {
  39697. /**
  39698. * Interface for screenshot methods with describe argument called `size` as object with options
  39699. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  39700. */
  39701. export interface IScreenshotSize {
  39702. /**
  39703. * number in pixels for canvas height
  39704. */
  39705. height?: number;
  39706. /**
  39707. * multiplier allowing render at a higher or lower resolution
  39708. * If value is defined then height and width will be ignored and taken from camera
  39709. */
  39710. precision?: number;
  39711. /**
  39712. * number in pixels for canvas width
  39713. */
  39714. width?: number;
  39715. }
  39716. }
  39717. declare module "babylonjs/Misc/tools" {
  39718. import { Nullable, float } from "babylonjs/types";
  39719. import { DomManagement } from "babylonjs/Misc/domManagement";
  39720. import { WebRequest } from "babylonjs/Misc/webRequest";
  39721. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  39722. import { ReadFileError } from "babylonjs/Misc/fileTools";
  39723. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  39724. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  39725. import { Camera } from "babylonjs/Cameras/camera";
  39726. import { Engine } from "babylonjs/Engines/engine";
  39727. interface IColor4Like {
  39728. r: float;
  39729. g: float;
  39730. b: float;
  39731. a: float;
  39732. }
  39733. /**
  39734. * Class containing a set of static utilities functions
  39735. */
  39736. export class Tools {
  39737. /**
  39738. * Gets or sets the base URL to use to load assets
  39739. */
  39740. static get BaseUrl(): string;
  39741. static set BaseUrl(value: string);
  39742. /**
  39743. * Enable/Disable Custom HTTP Request Headers globally.
  39744. * default = false
  39745. * @see CustomRequestHeaders
  39746. */
  39747. static UseCustomRequestHeaders: boolean;
  39748. /**
  39749. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  39750. * i.e. when loading files, where the server/service expects an Authorization header
  39751. */
  39752. static CustomRequestHeaders: {
  39753. [key: string]: string;
  39754. };
  39755. /**
  39756. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  39757. */
  39758. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  39759. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  39760. /**
  39761. * Default behaviour for cors in the application.
  39762. * It can be a string if the expected behavior is identical in the entire app.
  39763. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  39764. */
  39765. static get CorsBehavior(): string | ((url: string | string[]) => string);
  39766. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  39767. /**
  39768. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  39769. * @ignorenaming
  39770. */
  39771. static get UseFallbackTexture(): boolean;
  39772. static set UseFallbackTexture(value: boolean);
  39773. /**
  39774. * Use this object to register external classes like custom textures or material
  39775. * to allow the laoders to instantiate them
  39776. */
  39777. static get RegisteredExternalClasses(): {
  39778. [key: string]: Object;
  39779. };
  39780. static set RegisteredExternalClasses(classes: {
  39781. [key: string]: Object;
  39782. });
  39783. /**
  39784. * Texture content used if a texture cannot loaded
  39785. * @ignorenaming
  39786. */
  39787. static get fallbackTexture(): string;
  39788. static set fallbackTexture(value: string);
  39789. /**
  39790. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  39791. * @param u defines the coordinate on X axis
  39792. * @param v defines the coordinate on Y axis
  39793. * @param width defines the width of the source data
  39794. * @param height defines the height of the source data
  39795. * @param pixels defines the source byte array
  39796. * @param color defines the output color
  39797. */
  39798. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  39799. /**
  39800. * Interpolates between a and b via alpha
  39801. * @param a The lower value (returned when alpha = 0)
  39802. * @param b The upper value (returned when alpha = 1)
  39803. * @param alpha The interpolation-factor
  39804. * @return The mixed value
  39805. */
  39806. static Mix(a: number, b: number, alpha: number): number;
  39807. /**
  39808. * Tries to instantiate a new object from a given class name
  39809. * @param className defines the class name to instantiate
  39810. * @returns the new object or null if the system was not able to do the instantiation
  39811. */
  39812. static Instantiate(className: string): any;
  39813. /**
  39814. * Provides a slice function that will work even on IE
  39815. * @param data defines the array to slice
  39816. * @param start defines the start of the data (optional)
  39817. * @param end defines the end of the data (optional)
  39818. * @returns the new sliced array
  39819. */
  39820. static Slice<T>(data: T, start?: number, end?: number): T;
  39821. /**
  39822. * Polyfill for setImmediate
  39823. * @param action defines the action to execute after the current execution block
  39824. */
  39825. static SetImmediate(action: () => void): void;
  39826. /**
  39827. * Function indicating if a number is an exponent of 2
  39828. * @param value defines the value to test
  39829. * @returns true if the value is an exponent of 2
  39830. */
  39831. static IsExponentOfTwo(value: number): boolean;
  39832. private static _tmpFloatArray;
  39833. /**
  39834. * Returns the nearest 32-bit single precision float representation of a Number
  39835. * @param value A Number. If the parameter is of a different type, it will get converted
  39836. * to a number or to NaN if it cannot be converted
  39837. * @returns number
  39838. */
  39839. static FloatRound(value: number): number;
  39840. /**
  39841. * Extracts the filename from a path
  39842. * @param path defines the path to use
  39843. * @returns the filename
  39844. */
  39845. static GetFilename(path: string): string;
  39846. /**
  39847. * Extracts the "folder" part of a path (everything before the filename).
  39848. * @param uri The URI to extract the info from
  39849. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  39850. * @returns The "folder" part of the path
  39851. */
  39852. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  39853. /**
  39854. * Extracts text content from a DOM element hierarchy
  39855. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  39856. */
  39857. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  39858. /**
  39859. * Convert an angle in radians to degrees
  39860. * @param angle defines the angle to convert
  39861. * @returns the angle in degrees
  39862. */
  39863. static ToDegrees(angle: number): number;
  39864. /**
  39865. * Convert an angle in degrees to radians
  39866. * @param angle defines the angle to convert
  39867. * @returns the angle in radians
  39868. */
  39869. static ToRadians(angle: number): number;
  39870. /**
  39871. * Returns an array if obj is not an array
  39872. * @param obj defines the object to evaluate as an array
  39873. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  39874. * @returns either obj directly if obj is an array or a new array containing obj
  39875. */
  39876. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  39877. /**
  39878. * Gets the pointer prefix to use
  39879. * @param engine defines the engine we are finding the prefix for
  39880. * @returns "pointer" if touch is enabled. Else returns "mouse"
  39881. */
  39882. static GetPointerPrefix(engine: Engine): string;
  39883. /**
  39884. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  39885. * @param url define the url we are trying
  39886. * @param element define the dom element where to configure the cors policy
  39887. */
  39888. static SetCorsBehavior(url: string | string[], element: {
  39889. crossOrigin: string | null;
  39890. }): void;
  39891. /**
  39892. * Removes unwanted characters from an url
  39893. * @param url defines the url to clean
  39894. * @returns the cleaned url
  39895. */
  39896. static CleanUrl(url: string): string;
  39897. /**
  39898. * Gets or sets a function used to pre-process url before using them to load assets
  39899. */
  39900. static get PreprocessUrl(): (url: string) => string;
  39901. static set PreprocessUrl(processor: (url: string) => string);
  39902. /**
  39903. * Loads an image as an HTMLImageElement.
  39904. * @param input url string, ArrayBuffer, or Blob to load
  39905. * @param onLoad callback called when the image successfully loads
  39906. * @param onError callback called when the image fails to load
  39907. * @param offlineProvider offline provider for caching
  39908. * @param mimeType optional mime type
  39909. * @returns the HTMLImageElement of the loaded image
  39910. */
  39911. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  39912. /**
  39913. * Loads a file from a url
  39914. * @param url url string, ArrayBuffer, or Blob to load
  39915. * @param onSuccess callback called when the file successfully loads
  39916. * @param onProgress callback called while file is loading (if the server supports this mode)
  39917. * @param offlineProvider defines the offline provider for caching
  39918. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39919. * @param onError callback called when the file fails to load
  39920. * @returns a file request object
  39921. */
  39922. 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;
  39923. /**
  39924. * Loads a file from a url
  39925. * @param url the file url to load
  39926. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  39927. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  39928. */
  39929. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  39930. /**
  39931. * Load a script (identified by an url). When the url returns, the
  39932. * content of this file is added into a new script element, attached to the DOM (body element)
  39933. * @param scriptUrl defines the url of the script to laod
  39934. * @param onSuccess defines the callback called when the script is loaded
  39935. * @param onError defines the callback to call if an error occurs
  39936. * @param scriptId defines the id of the script element
  39937. */
  39938. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  39939. /**
  39940. * Load an asynchronous script (identified by an url). When the url returns, the
  39941. * content of this file is added into a new script element, attached to the DOM (body element)
  39942. * @param scriptUrl defines the url of the script to laod
  39943. * @param scriptId defines the id of the script element
  39944. * @returns a promise request object
  39945. */
  39946. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  39947. /**
  39948. * Loads a file from a blob
  39949. * @param fileToLoad defines the blob to use
  39950. * @param callback defines the callback to call when data is loaded
  39951. * @param progressCallback defines the callback to call during loading process
  39952. * @returns a file request object
  39953. */
  39954. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  39955. /**
  39956. * Reads a file from a File object
  39957. * @param file defines the file to load
  39958. * @param onSuccess defines the callback to call when data is loaded
  39959. * @param onProgress defines the callback to call during loading process
  39960. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  39961. * @param onError defines the callback to call when an error occurs
  39962. * @returns a file request object
  39963. */
  39964. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  39965. /**
  39966. * Creates a data url from a given string content
  39967. * @param content defines the content to convert
  39968. * @returns the new data url link
  39969. */
  39970. static FileAsURL(content: string): string;
  39971. /**
  39972. * Format the given number to a specific decimal format
  39973. * @param value defines the number to format
  39974. * @param decimals defines the number of decimals to use
  39975. * @returns the formatted string
  39976. */
  39977. static Format(value: number, decimals?: number): string;
  39978. /**
  39979. * Tries to copy an object by duplicating every property
  39980. * @param source defines the source object
  39981. * @param destination defines the target object
  39982. * @param doNotCopyList defines a list of properties to avoid
  39983. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  39984. */
  39985. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  39986. /**
  39987. * Gets a boolean indicating if the given object has no own property
  39988. * @param obj defines the object to test
  39989. * @returns true if object has no own property
  39990. */
  39991. static IsEmpty(obj: any): boolean;
  39992. /**
  39993. * Function used to register events at window level
  39994. * @param windowElement defines the Window object to use
  39995. * @param events defines the events to register
  39996. */
  39997. static RegisterTopRootEvents(windowElement: Window, events: {
  39998. name: string;
  39999. handler: Nullable<(e: FocusEvent) => any>;
  40000. }[]): void;
  40001. /**
  40002. * Function used to unregister events from window level
  40003. * @param windowElement defines the Window object to use
  40004. * @param events defines the events to unregister
  40005. */
  40006. static UnregisterTopRootEvents(windowElement: Window, events: {
  40007. name: string;
  40008. handler: Nullable<(e: FocusEvent) => any>;
  40009. }[]): void;
  40010. /**
  40011. * @ignore
  40012. */
  40013. static _ScreenshotCanvas: HTMLCanvasElement;
  40014. /**
  40015. * Dumps the current bound framebuffer
  40016. * @param width defines the rendering width
  40017. * @param height defines the rendering height
  40018. * @param engine defines the hosting engine
  40019. * @param successCallback defines the callback triggered once the data are available
  40020. * @param mimeType defines the mime type of the result
  40021. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  40022. */
  40023. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40024. /**
  40025. * Converts the canvas data to blob.
  40026. * This acts as a polyfill for browsers not supporting the to blob function.
  40027. * @param canvas Defines the canvas to extract the data from
  40028. * @param successCallback Defines the callback triggered once the data are available
  40029. * @param mimeType Defines the mime type of the result
  40030. */
  40031. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  40032. /**
  40033. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  40034. * @param successCallback defines the callback triggered once the data are available
  40035. * @param mimeType defines the mime type of the result
  40036. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  40037. */
  40038. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  40039. /**
  40040. * Downloads a blob in the browser
  40041. * @param blob defines the blob to download
  40042. * @param fileName defines the name of the downloaded file
  40043. */
  40044. static Download(blob: Blob, fileName: string): void;
  40045. /**
  40046. * Captures a screenshot of the current rendering
  40047. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40048. * @param engine defines the rendering engine
  40049. * @param camera defines the source camera
  40050. * @param size This parameter can be set to a single number or to an object with the
  40051. * following (optional) properties: precision, width, height. If a single number is passed,
  40052. * it will be used for both width and height. If an object is passed, the screenshot size
  40053. * will be derived from the parameters. The precision property is a multiplier allowing
  40054. * rendering at a higher or lower resolution
  40055. * @param successCallback defines the callback receives a single parameter which contains the
  40056. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40057. * src parameter of an <img> to display it
  40058. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40059. * Check your browser for supported MIME types
  40060. */
  40061. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  40062. /**
  40063. * Captures a screenshot of the current rendering
  40064. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40065. * @param engine defines the rendering engine
  40066. * @param camera defines the source camera
  40067. * @param size This parameter can be set to a single number or to an object with the
  40068. * following (optional) properties: precision, width, height. If a single number is passed,
  40069. * it will be used for both width and height. If an object is passed, the screenshot size
  40070. * will be derived from the parameters. The precision property is a multiplier allowing
  40071. * rendering at a higher or lower resolution
  40072. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  40073. * Check your browser for supported MIME types
  40074. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40075. * to the src parameter of an <img> to display it
  40076. */
  40077. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  40078. /**
  40079. * Generates an image screenshot from the specified camera.
  40080. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40081. * @param engine The engine to use for rendering
  40082. * @param camera The camera to use for rendering
  40083. * @param size This parameter can be set to a single number or to an object with the
  40084. * following (optional) properties: precision, width, height. If a single number is passed,
  40085. * it will be used for both width and height. If an object is passed, the screenshot size
  40086. * will be derived from the parameters. The precision property is a multiplier allowing
  40087. * rendering at a higher or lower resolution
  40088. * @param successCallback The callback receives a single parameter which contains the
  40089. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  40090. * src parameter of an <img> to display it
  40091. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40092. * Check your browser for supported MIME types
  40093. * @param samples Texture samples (default: 1)
  40094. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40095. * @param fileName A name for for the downloaded file.
  40096. */
  40097. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  40098. /**
  40099. * Generates an image screenshot from the specified camera.
  40100. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  40101. * @param engine The engine to use for rendering
  40102. * @param camera The camera to use for rendering
  40103. * @param size This parameter can be set to a single number or to an object with the
  40104. * following (optional) properties: precision, width, height. If a single number is passed,
  40105. * it will be used for both width and height. If an object is passed, the screenshot size
  40106. * will be derived from the parameters. The precision property is a multiplier allowing
  40107. * rendering at a higher or lower resolution
  40108. * @param mimeType The MIME type of the screenshot image (default: image/png).
  40109. * Check your browser for supported MIME types
  40110. * @param samples Texture samples (default: 1)
  40111. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  40112. * @param fileName A name for for the downloaded file.
  40113. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  40114. * to the src parameter of an <img> to display it
  40115. */
  40116. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  40117. /**
  40118. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  40119. * Be aware Math.random() could cause collisions, but:
  40120. * "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"
  40121. * @returns a pseudo random id
  40122. */
  40123. static RandomId(): string;
  40124. /**
  40125. * Test if the given uri is a base64 string
  40126. * @param uri The uri to test
  40127. * @return True if the uri is a base64 string or false otherwise
  40128. */
  40129. static IsBase64(uri: string): boolean;
  40130. /**
  40131. * Decode the given base64 uri.
  40132. * @param uri The uri to decode
  40133. * @return The decoded base64 data.
  40134. */
  40135. static DecodeBase64(uri: string): ArrayBuffer;
  40136. /**
  40137. * Gets the absolute url.
  40138. * @param url the input url
  40139. * @return the absolute url
  40140. */
  40141. static GetAbsoluteUrl(url: string): string;
  40142. /**
  40143. * No log
  40144. */
  40145. static readonly NoneLogLevel: number;
  40146. /**
  40147. * Only message logs
  40148. */
  40149. static readonly MessageLogLevel: number;
  40150. /**
  40151. * Only warning logs
  40152. */
  40153. static readonly WarningLogLevel: number;
  40154. /**
  40155. * Only error logs
  40156. */
  40157. static readonly ErrorLogLevel: number;
  40158. /**
  40159. * All logs
  40160. */
  40161. static readonly AllLogLevel: number;
  40162. /**
  40163. * Gets a value indicating the number of loading errors
  40164. * @ignorenaming
  40165. */
  40166. static get errorsCount(): number;
  40167. /**
  40168. * Callback called when a new log is added
  40169. */
  40170. static OnNewCacheEntry: (entry: string) => void;
  40171. /**
  40172. * Log a message to the console
  40173. * @param message defines the message to log
  40174. */
  40175. static Log(message: string): void;
  40176. /**
  40177. * Write a warning message to the console
  40178. * @param message defines the message to log
  40179. */
  40180. static Warn(message: string): void;
  40181. /**
  40182. * Write an error message to the console
  40183. * @param message defines the message to log
  40184. */
  40185. static Error(message: string): void;
  40186. /**
  40187. * Gets current log cache (list of logs)
  40188. */
  40189. static get LogCache(): string;
  40190. /**
  40191. * Clears the log cache
  40192. */
  40193. static ClearLogCache(): void;
  40194. /**
  40195. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  40196. */
  40197. static set LogLevels(level: number);
  40198. /**
  40199. * Checks if the window object exists
  40200. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  40201. */
  40202. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  40203. /**
  40204. * No performance log
  40205. */
  40206. static readonly PerformanceNoneLogLevel: number;
  40207. /**
  40208. * Use user marks to log performance
  40209. */
  40210. static readonly PerformanceUserMarkLogLevel: number;
  40211. /**
  40212. * Log performance to the console
  40213. */
  40214. static readonly PerformanceConsoleLogLevel: number;
  40215. private static _performance;
  40216. /**
  40217. * Sets the current performance log level
  40218. */
  40219. static set PerformanceLogLevel(level: number);
  40220. private static _StartPerformanceCounterDisabled;
  40221. private static _EndPerformanceCounterDisabled;
  40222. private static _StartUserMark;
  40223. private static _EndUserMark;
  40224. private static _StartPerformanceConsole;
  40225. private static _EndPerformanceConsole;
  40226. /**
  40227. * Starts a performance counter
  40228. */
  40229. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40230. /**
  40231. * Ends a specific performance coutner
  40232. */
  40233. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  40234. /**
  40235. * Gets either window.performance.now() if supported or Date.now() else
  40236. */
  40237. static get Now(): number;
  40238. /**
  40239. * This method will return the name of the class used to create the instance of the given object.
  40240. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  40241. * @param object the object to get the class name from
  40242. * @param isType defines if the object is actually a type
  40243. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  40244. */
  40245. static GetClassName(object: any, isType?: boolean): string;
  40246. /**
  40247. * Gets the first element of an array satisfying a given predicate
  40248. * @param array defines the array to browse
  40249. * @param predicate defines the predicate to use
  40250. * @returns null if not found or the element
  40251. */
  40252. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  40253. /**
  40254. * This method will return the name of the full name of the class, including its owning module (if any).
  40255. * 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).
  40256. * @param object the object to get the class name from
  40257. * @param isType defines if the object is actually a type
  40258. * @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.
  40259. * @ignorenaming
  40260. */
  40261. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  40262. /**
  40263. * Returns a promise that resolves after the given amount of time.
  40264. * @param delay Number of milliseconds to delay
  40265. * @returns Promise that resolves after the given amount of time
  40266. */
  40267. static DelayAsync(delay: number): Promise<void>;
  40268. /**
  40269. * Utility function to detect if the current user agent is Safari
  40270. * @returns whether or not the current user agent is safari
  40271. */
  40272. static IsSafari(): boolean;
  40273. }
  40274. /**
  40275. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  40276. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  40277. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  40278. * @param name The name of the class, case should be preserved
  40279. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  40280. */
  40281. export function className(name: string, module?: string): (target: Object) => void;
  40282. /**
  40283. * An implementation of a loop for asynchronous functions.
  40284. */
  40285. export class AsyncLoop {
  40286. /**
  40287. * Defines the number of iterations for the loop
  40288. */
  40289. iterations: number;
  40290. /**
  40291. * Defines the current index of the loop.
  40292. */
  40293. index: number;
  40294. private _done;
  40295. private _fn;
  40296. private _successCallback;
  40297. /**
  40298. * Constructor.
  40299. * @param iterations the number of iterations.
  40300. * @param func the function to run each iteration
  40301. * @param successCallback the callback that will be called upon succesful execution
  40302. * @param offset starting offset.
  40303. */
  40304. constructor(
  40305. /**
  40306. * Defines the number of iterations for the loop
  40307. */
  40308. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  40309. /**
  40310. * Execute the next iteration. Must be called after the last iteration was finished.
  40311. */
  40312. executeNext(): void;
  40313. /**
  40314. * Break the loop and run the success callback.
  40315. */
  40316. breakLoop(): void;
  40317. /**
  40318. * Create and run an async loop.
  40319. * @param iterations the number of iterations.
  40320. * @param fn the function to run each iteration
  40321. * @param successCallback the callback that will be called upon succesful execution
  40322. * @param offset starting offset.
  40323. * @returns the created async loop object
  40324. */
  40325. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  40326. /**
  40327. * A for-loop that will run a given number of iterations synchronous and the rest async.
  40328. * @param iterations total number of iterations
  40329. * @param syncedIterations number of synchronous iterations in each async iteration.
  40330. * @param fn the function to call each iteration.
  40331. * @param callback a success call back that will be called when iterating stops.
  40332. * @param breakFunction a break condition (optional)
  40333. * @param timeout timeout settings for the setTimeout function. default - 0.
  40334. * @returns the created async loop object
  40335. */
  40336. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  40337. }
  40338. }
  40339. declare module "babylonjs/Misc/stringDictionary" {
  40340. import { Nullable } from "babylonjs/types";
  40341. /**
  40342. * This class implement a typical dictionary using a string as key and the generic type T as value.
  40343. * The underlying implementation relies on an associative array to ensure the best performances.
  40344. * The value can be anything including 'null' but except 'undefined'
  40345. */
  40346. export class StringDictionary<T> {
  40347. /**
  40348. * This will clear this dictionary and copy the content from the 'source' one.
  40349. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  40350. * @param source the dictionary to take the content from and copy to this dictionary
  40351. */
  40352. copyFrom(source: StringDictionary<T>): void;
  40353. /**
  40354. * Get a value based from its key
  40355. * @param key the given key to get the matching value from
  40356. * @return the value if found, otherwise undefined is returned
  40357. */
  40358. get(key: string): T | undefined;
  40359. /**
  40360. * Get a value from its key or add it if it doesn't exist.
  40361. * This method will ensure you that a given key/data will be present in the dictionary.
  40362. * @param key the given key to get the matching value from
  40363. * @param factory the factory that will create the value if the key is not present in the dictionary.
  40364. * The factory will only be invoked if there's no data for the given key.
  40365. * @return the value corresponding to the key.
  40366. */
  40367. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  40368. /**
  40369. * Get a value from its key if present in the dictionary otherwise add it
  40370. * @param key the key to get the value from
  40371. * @param val if there's no such key/value pair in the dictionary add it with this value
  40372. * @return the value corresponding to the key
  40373. */
  40374. getOrAdd(key: string, val: T): T;
  40375. /**
  40376. * Check if there's a given key in the dictionary
  40377. * @param key the key to check for
  40378. * @return true if the key is present, false otherwise
  40379. */
  40380. contains(key: string): boolean;
  40381. /**
  40382. * Add a new key and its corresponding value
  40383. * @param key the key to add
  40384. * @param value the value corresponding to the key
  40385. * @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
  40386. */
  40387. add(key: string, value: T): boolean;
  40388. /**
  40389. * Update a specific value associated to a key
  40390. * @param key defines the key to use
  40391. * @param value defines the value to store
  40392. * @returns true if the value was updated (or false if the key was not found)
  40393. */
  40394. set(key: string, value: T): boolean;
  40395. /**
  40396. * Get the element of the given key and remove it from the dictionary
  40397. * @param key defines the key to search
  40398. * @returns the value associated with the key or null if not found
  40399. */
  40400. getAndRemove(key: string): Nullable<T>;
  40401. /**
  40402. * Remove a key/value from the dictionary.
  40403. * @param key the key to remove
  40404. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  40405. */
  40406. remove(key: string): boolean;
  40407. /**
  40408. * Clear the whole content of the dictionary
  40409. */
  40410. clear(): void;
  40411. /**
  40412. * Gets the current count
  40413. */
  40414. get count(): number;
  40415. /**
  40416. * Execute a callback on each key/val of the dictionary.
  40417. * Note that you can remove any element in this dictionary in the callback implementation
  40418. * @param callback the callback to execute on a given key/value pair
  40419. */
  40420. forEach(callback: (key: string, val: T) => void): void;
  40421. /**
  40422. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  40423. * If the callback returns null or undefined the method will iterate to the next key/value pair
  40424. * Note that you can remove any element in this dictionary in the callback implementation
  40425. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  40426. * @returns the first item
  40427. */
  40428. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  40429. private _count;
  40430. private _data;
  40431. }
  40432. }
  40433. declare module "babylonjs/Collisions/collisionCoordinator" {
  40434. import { Nullable } from "babylonjs/types";
  40435. import { Scene } from "babylonjs/scene";
  40436. import { Vector3 } from "babylonjs/Maths/math.vector";
  40437. import { Collider } from "babylonjs/Collisions/collider";
  40438. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40439. /** @hidden */
  40440. export interface ICollisionCoordinator {
  40441. createCollider(): Collider;
  40442. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40443. init(scene: Scene): void;
  40444. }
  40445. /** @hidden */
  40446. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  40447. private _scene;
  40448. private _scaledPosition;
  40449. private _scaledVelocity;
  40450. private _finalPosition;
  40451. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  40452. createCollider(): Collider;
  40453. init(scene: Scene): void;
  40454. private _collideWithWorld;
  40455. }
  40456. }
  40457. declare module "babylonjs/Inputs/scene.inputManager" {
  40458. import { Nullable } from "babylonjs/types";
  40459. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40460. import { Vector2 } from "babylonjs/Maths/math.vector";
  40461. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40462. import { Scene } from "babylonjs/scene";
  40463. /**
  40464. * Class used to manage all inputs for the scene.
  40465. */
  40466. export class InputManager {
  40467. /** The distance in pixel that you have to move to prevent some events */
  40468. static DragMovementThreshold: number;
  40469. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  40470. static LongPressDelay: number;
  40471. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  40472. static DoubleClickDelay: number;
  40473. /** If you need to check double click without raising a single click at first click, enable this flag */
  40474. static ExclusiveDoubleClickMode: boolean;
  40475. /** 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. */
  40476. private _alreadyAttached;
  40477. private _wheelEventName;
  40478. private _onPointerMove;
  40479. private _onPointerDown;
  40480. private _onPointerUp;
  40481. private _initClickEvent;
  40482. private _initActionManager;
  40483. private _delayedSimpleClick;
  40484. private _delayedSimpleClickTimeout;
  40485. private _previousDelayedSimpleClickTimeout;
  40486. private _meshPickProceed;
  40487. private _previousButtonPressed;
  40488. private _currentPickResult;
  40489. private _previousPickResult;
  40490. private _totalPointersPressed;
  40491. private _doubleClickOccured;
  40492. private _pointerOverMesh;
  40493. private _pickedDownMesh;
  40494. private _pickedUpMesh;
  40495. private _pointerX;
  40496. private _pointerY;
  40497. private _unTranslatedPointerX;
  40498. private _unTranslatedPointerY;
  40499. private _startingPointerPosition;
  40500. private _previousStartingPointerPosition;
  40501. private _startingPointerTime;
  40502. private _previousStartingPointerTime;
  40503. private _pointerCaptures;
  40504. private _meshUnderPointerId;
  40505. private _onKeyDown;
  40506. private _onKeyUp;
  40507. private _onCanvasFocusObserver;
  40508. private _onCanvasBlurObserver;
  40509. private _scene;
  40510. /**
  40511. * Creates a new InputManager
  40512. * @param scene defines the hosting scene
  40513. */
  40514. constructor(scene: Scene);
  40515. /**
  40516. * Gets the mesh that is currently under the pointer
  40517. */
  40518. get meshUnderPointer(): Nullable<AbstractMesh>;
  40519. /**
  40520. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  40521. * @param pointerId the pointer id to use
  40522. * @returns The mesh under this pointer id or null if not found
  40523. */
  40524. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  40525. /**
  40526. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  40527. */
  40528. get unTranslatedPointer(): Vector2;
  40529. /**
  40530. * Gets or sets the current on-screen X position of the pointer
  40531. */
  40532. get pointerX(): number;
  40533. set pointerX(value: number);
  40534. /**
  40535. * Gets or sets the current on-screen Y position of the pointer
  40536. */
  40537. get pointerY(): number;
  40538. set pointerY(value: number);
  40539. private _updatePointerPosition;
  40540. private _processPointerMove;
  40541. private _setRayOnPointerInfo;
  40542. private _checkPrePointerObservable;
  40543. /**
  40544. * Use this method to simulate a pointer move on a mesh
  40545. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40546. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40547. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40548. */
  40549. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40550. /**
  40551. * Use this method to simulate a pointer down on a mesh
  40552. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40553. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40554. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40555. */
  40556. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  40557. private _processPointerDown;
  40558. /** @hidden */
  40559. _isPointerSwiping(): boolean;
  40560. /**
  40561. * Use this method to simulate a pointer up on a mesh
  40562. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  40563. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  40564. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  40565. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  40566. */
  40567. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  40568. private _processPointerUp;
  40569. /**
  40570. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  40571. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  40572. * @returns true if the pointer was captured
  40573. */
  40574. isPointerCaptured(pointerId?: number): boolean;
  40575. /**
  40576. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  40577. * @param attachUp defines if you want to attach events to pointerup
  40578. * @param attachDown defines if you want to attach events to pointerdown
  40579. * @param attachMove defines if you want to attach events to pointermove
  40580. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  40581. */
  40582. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  40583. /**
  40584. * Detaches all event handlers
  40585. */
  40586. detachControl(): void;
  40587. /**
  40588. * Force the value of meshUnderPointer
  40589. * @param mesh defines the mesh to use
  40590. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  40591. */
  40592. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  40593. /**
  40594. * Gets the mesh under the pointer
  40595. * @returns a Mesh or null if no mesh is under the pointer
  40596. */
  40597. getPointerOverMesh(): Nullable<AbstractMesh>;
  40598. }
  40599. }
  40600. declare module "babylonjs/Animations/animationGroup" {
  40601. import { Animatable } from "babylonjs/Animations/animatable";
  40602. import { Animation } from "babylonjs/Animations/animation";
  40603. import { Scene, IDisposable } from "babylonjs/scene";
  40604. import { Observable } from "babylonjs/Misc/observable";
  40605. import { Nullable } from "babylonjs/types";
  40606. import "babylonjs/Animations/animatable";
  40607. /**
  40608. * This class defines the direct association between an animation and a target
  40609. */
  40610. export class TargetedAnimation {
  40611. /**
  40612. * Animation to perform
  40613. */
  40614. animation: Animation;
  40615. /**
  40616. * Target to animate
  40617. */
  40618. target: any;
  40619. /**
  40620. * Returns the string "TargetedAnimation"
  40621. * @returns "TargetedAnimation"
  40622. */
  40623. getClassName(): string;
  40624. /**
  40625. * Serialize the object
  40626. * @returns the JSON object representing the current entity
  40627. */
  40628. serialize(): any;
  40629. }
  40630. /**
  40631. * Use this class to create coordinated animations on multiple targets
  40632. */
  40633. export class AnimationGroup implements IDisposable {
  40634. /** The name of the animation group */
  40635. name: string;
  40636. private _scene;
  40637. private _targetedAnimations;
  40638. private _animatables;
  40639. private _from;
  40640. private _to;
  40641. private _isStarted;
  40642. private _isPaused;
  40643. private _speedRatio;
  40644. private _loopAnimation;
  40645. private _isAdditive;
  40646. /**
  40647. * Gets or sets the unique id of the node
  40648. */
  40649. uniqueId: number;
  40650. /**
  40651. * This observable will notify when one animation have ended
  40652. */
  40653. onAnimationEndObservable: Observable<TargetedAnimation>;
  40654. /**
  40655. * Observer raised when one animation loops
  40656. */
  40657. onAnimationLoopObservable: Observable<TargetedAnimation>;
  40658. /**
  40659. * Observer raised when all animations have looped
  40660. */
  40661. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  40662. /**
  40663. * This observable will notify when all animations have ended.
  40664. */
  40665. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  40666. /**
  40667. * This observable will notify when all animations have paused.
  40668. */
  40669. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  40670. /**
  40671. * This observable will notify when all animations are playing.
  40672. */
  40673. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  40674. /**
  40675. * Gets the first frame
  40676. */
  40677. get from(): number;
  40678. /**
  40679. * Gets the last frame
  40680. */
  40681. get to(): number;
  40682. /**
  40683. * Define if the animations are started
  40684. */
  40685. get isStarted(): boolean;
  40686. /**
  40687. * Gets a value indicating that the current group is playing
  40688. */
  40689. get isPlaying(): boolean;
  40690. /**
  40691. * Gets or sets the speed ratio to use for all animations
  40692. */
  40693. get speedRatio(): number;
  40694. /**
  40695. * Gets or sets the speed ratio to use for all animations
  40696. */
  40697. set speedRatio(value: number);
  40698. /**
  40699. * Gets or sets if all animations should loop or not
  40700. */
  40701. get loopAnimation(): boolean;
  40702. set loopAnimation(value: boolean);
  40703. /**
  40704. * Gets or sets if all animations should be evaluated additively
  40705. */
  40706. get isAdditive(): boolean;
  40707. set isAdditive(value: boolean);
  40708. /**
  40709. * Gets the targeted animations for this animation group
  40710. */
  40711. get targetedAnimations(): Array<TargetedAnimation>;
  40712. /**
  40713. * returning the list of animatables controlled by this animation group.
  40714. */
  40715. get animatables(): Array<Animatable>;
  40716. /**
  40717. * Gets the list of target animations
  40718. */
  40719. get children(): TargetedAnimation[];
  40720. /**
  40721. * Instantiates a new Animation Group.
  40722. * This helps managing several animations at once.
  40723. * @see https://doc.babylonjs.com/how_to/group
  40724. * @param name Defines the name of the group
  40725. * @param scene Defines the scene the group belongs to
  40726. */
  40727. constructor(
  40728. /** The name of the animation group */
  40729. name: string, scene?: Nullable<Scene>);
  40730. /**
  40731. * Add an animation (with its target) in the group
  40732. * @param animation defines the animation we want to add
  40733. * @param target defines the target of the animation
  40734. * @returns the TargetedAnimation object
  40735. */
  40736. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  40737. /**
  40738. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  40739. * It can add constant keys at begin or end
  40740. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  40741. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  40742. * @returns the animation group
  40743. */
  40744. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  40745. private _animationLoopCount;
  40746. private _animationLoopFlags;
  40747. private _processLoop;
  40748. /**
  40749. * Start all animations on given targets
  40750. * @param loop defines if animations must loop
  40751. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  40752. * @param from defines the from key (optional)
  40753. * @param to defines the to key (optional)
  40754. * @param isAdditive defines the additive state for the resulting animatables (optional)
  40755. * @returns the current animation group
  40756. */
  40757. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  40758. /**
  40759. * Pause all animations
  40760. * @returns the animation group
  40761. */
  40762. pause(): AnimationGroup;
  40763. /**
  40764. * Play all animations to initial state
  40765. * This function will start() the animations if they were not started or will restart() them if they were paused
  40766. * @param loop defines if animations must loop
  40767. * @returns the animation group
  40768. */
  40769. play(loop?: boolean): AnimationGroup;
  40770. /**
  40771. * Reset all animations to initial state
  40772. * @returns the animation group
  40773. */
  40774. reset(): AnimationGroup;
  40775. /**
  40776. * Restart animations from key 0
  40777. * @returns the animation group
  40778. */
  40779. restart(): AnimationGroup;
  40780. /**
  40781. * Stop all animations
  40782. * @returns the animation group
  40783. */
  40784. stop(): AnimationGroup;
  40785. /**
  40786. * Set animation weight for all animatables
  40787. * @param weight defines the weight to use
  40788. * @return the animationGroup
  40789. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40790. */
  40791. setWeightForAllAnimatables(weight: number): AnimationGroup;
  40792. /**
  40793. * Synchronize and normalize all animatables with a source animatable
  40794. * @param root defines the root animatable to synchronize with
  40795. * @return the animationGroup
  40796. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  40797. */
  40798. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  40799. /**
  40800. * Goes to a specific frame in this animation group
  40801. * @param frame the frame number to go to
  40802. * @return the animationGroup
  40803. */
  40804. goToFrame(frame: number): AnimationGroup;
  40805. /**
  40806. * Dispose all associated resources
  40807. */
  40808. dispose(): void;
  40809. private _checkAnimationGroupEnded;
  40810. /**
  40811. * Clone the current animation group and returns a copy
  40812. * @param newName defines the name of the new group
  40813. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  40814. * @returns the new aniamtion group
  40815. */
  40816. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  40817. /**
  40818. * Serializes the animationGroup to an object
  40819. * @returns Serialized object
  40820. */
  40821. serialize(): any;
  40822. /**
  40823. * Returns a new AnimationGroup object parsed from the source provided.
  40824. * @param parsedAnimationGroup defines the source
  40825. * @param scene defines the scene that will receive the animationGroup
  40826. * @returns a new AnimationGroup
  40827. */
  40828. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  40829. /**
  40830. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  40831. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  40832. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  40833. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  40834. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  40835. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  40836. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  40837. */
  40838. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  40839. /**
  40840. * Returns the string "AnimationGroup"
  40841. * @returns "AnimationGroup"
  40842. */
  40843. getClassName(): string;
  40844. /**
  40845. * Creates a detailled string about the object
  40846. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  40847. * @returns a string representing the object
  40848. */
  40849. toString(fullDetails?: boolean): string;
  40850. }
  40851. }
  40852. declare module "babylonjs/scene" {
  40853. import { Nullable } from "babylonjs/types";
  40854. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  40855. import { Observable } from "babylonjs/Misc/observable";
  40856. import { SmartArrayNoDuplicate, SmartArray, ISmartArrayLike } from "babylonjs/Misc/smartArray";
  40857. import { Vector2, Vector3, Matrix } from "babylonjs/Maths/math.vector";
  40858. import { Geometry } from "babylonjs/Meshes/geometry";
  40859. import { TransformNode } from "babylonjs/Meshes/transformNode";
  40860. import { SubMesh } from "babylonjs/Meshes/subMesh";
  40861. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  40862. import { Mesh } from "babylonjs/Meshes/mesh";
  40863. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  40864. import { Bone } from "babylonjs/Bones/bone";
  40865. import { Skeleton } from "babylonjs/Bones/skeleton";
  40866. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  40867. import { Camera } from "babylonjs/Cameras/camera";
  40868. import { AbstractScene } from "babylonjs/abstractScene";
  40869. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  40870. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  40871. import { Material } from "babylonjs/Materials/material";
  40872. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  40873. import { Effect } from "babylonjs/Materials/effect";
  40874. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  40875. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  40876. import { Light } from "babylonjs/Lights/light";
  40877. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  40878. import { ICollisionCoordinator } from "babylonjs/Collisions/collisionCoordinator";
  40879. import { PointerEventTypes, PointerInfoPre, PointerInfo } from "babylonjs/Events/pointerEvents";
  40880. import { KeyboardInfoPre, KeyboardInfo } from "babylonjs/Events/keyboardEvents";
  40881. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  40882. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  40883. import { RenderingGroupInfo, IRenderingManagerAutoClearSetup } from "babylonjs/Rendering/renderingManager";
  40884. import { ISceneComponent, ISceneSerializableComponent, Stage, SimpleStageAction, RenderTargetsStageAction, RenderTargetStageAction, MeshStageAction, EvaluateSubMeshStageAction, ActiveMeshStageAction, CameraStageAction, RenderingGroupStageAction, RenderingMeshStageAction, PointerMoveStageAction, PointerUpDownStageAction, CameraStageFrameBufferAction } from "babylonjs/sceneComponent";
  40885. import { Engine } from "babylonjs/Engines/engine";
  40886. import { Node } from "babylonjs/node";
  40887. import { MorphTarget } from "babylonjs/Morph/morphTarget";
  40888. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  40889. import { WebRequest } from "babylonjs/Misc/webRequest";
  40890. import { InputManager } from "babylonjs/Inputs/scene.inputManager";
  40891. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  40892. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  40893. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  40894. import { Plane } from "babylonjs/Maths/math.plane";
  40895. import { LoadFileError, RequestFileError, ReadFileError } from "babylonjs/Misc/fileTools";
  40896. import { IClipPlanesHolder } from "babylonjs/Misc/interfaces/iClipPlanesHolder";
  40897. import { Ray } from "babylonjs/Culling/ray";
  40898. import { TrianglePickingPredicate } from "babylonjs/Culling/ray";
  40899. import { Animation } from "babylonjs/Animations/animation";
  40900. import { Animatable } from "babylonjs/Animations/animatable";
  40901. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  40902. import { AnimationPropertiesOverride } from "babylonjs/Animations/animationPropertiesOverride";
  40903. import { Collider } from "babylonjs/Collisions/collider";
  40904. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  40905. /**
  40906. * Define an interface for all classes that will hold resources
  40907. */
  40908. export interface IDisposable {
  40909. /**
  40910. * Releases all held resources
  40911. */
  40912. dispose(): void;
  40913. }
  40914. /** Interface defining initialization parameters for Scene class */
  40915. export interface SceneOptions {
  40916. /**
  40917. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  40918. * It will improve performance when the number of geometries becomes important.
  40919. */
  40920. useGeometryUniqueIdsMap?: boolean;
  40921. /**
  40922. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  40923. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40924. */
  40925. useMaterialMeshMap?: boolean;
  40926. /**
  40927. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  40928. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  40929. */
  40930. useClonedMeshMap?: boolean;
  40931. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  40932. virtual?: boolean;
  40933. }
  40934. /**
  40935. * Represents a scene to be rendered by the engine.
  40936. * @see https://doc.babylonjs.com/features/scene
  40937. */
  40938. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  40939. /** The fog is deactivated */
  40940. static readonly FOGMODE_NONE: number;
  40941. /** The fog density is following an exponential function */
  40942. static readonly FOGMODE_EXP: number;
  40943. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  40944. static readonly FOGMODE_EXP2: number;
  40945. /** The fog density is following a linear function. */
  40946. static readonly FOGMODE_LINEAR: number;
  40947. /**
  40948. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  40949. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40950. */
  40951. static MinDeltaTime: number;
  40952. /**
  40953. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  40954. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  40955. */
  40956. static MaxDeltaTime: number;
  40957. /**
  40958. * Factory used to create the default material.
  40959. * @param name The name of the material to create
  40960. * @param scene The scene to create the material for
  40961. * @returns The default material
  40962. */
  40963. static DefaultMaterialFactory(scene: Scene): Material;
  40964. /**
  40965. * Factory used to create the a collision coordinator.
  40966. * @returns The collision coordinator
  40967. */
  40968. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  40969. /** @hidden */
  40970. _inputManager: InputManager;
  40971. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  40972. cameraToUseForPointers: Nullable<Camera>;
  40973. /** @hidden */
  40974. readonly _isScene: boolean;
  40975. /** @hidden */
  40976. _blockEntityCollection: boolean;
  40977. /**
  40978. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  40979. */
  40980. autoClear: boolean;
  40981. /**
  40982. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  40983. */
  40984. autoClearDepthAndStencil: boolean;
  40985. /**
  40986. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  40987. */
  40988. clearColor: Color4;
  40989. /**
  40990. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  40991. */
  40992. ambientColor: Color3;
  40993. /**
  40994. * This is use to store the default BRDF lookup for PBR materials in your scene.
  40995. * It should only be one of the following (if not the default embedded one):
  40996. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  40997. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  40998. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  40999. * The material properties need to be setup according to the type of texture in use.
  41000. */
  41001. environmentBRDFTexture: BaseTexture;
  41002. /**
  41003. * Texture used in all pbr material as the reflection texture.
  41004. * As in the majority of the scene they are the same (exception for multi room and so on),
  41005. * this is easier to reference from here than from all the materials.
  41006. */
  41007. get environmentTexture(): Nullable<BaseTexture>;
  41008. /**
  41009. * Texture used in all pbr material as the reflection texture.
  41010. * As in the majority of the scene they are the same (exception for multi room and so on),
  41011. * this is easier to set here than in all the materials.
  41012. */
  41013. set environmentTexture(value: Nullable<BaseTexture>);
  41014. /** @hidden */
  41015. protected _environmentIntensity: number;
  41016. /**
  41017. * Intensity of the environment in all pbr material.
  41018. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  41019. * As in the majority of the scene they are the same (exception for multi room and so on),
  41020. * this is easier to reference from here than from all the materials.
  41021. */
  41022. get environmentIntensity(): number;
  41023. /**
  41024. * Intensity of the environment in all pbr material.
  41025. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  41026. * As in the majority of the scene they are the same (exception for multi room and so on),
  41027. * this is easier to set here than in all the materials.
  41028. */
  41029. set environmentIntensity(value: number);
  41030. /** @hidden */
  41031. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  41032. /**
  41033. * Default image processing configuration used either in the rendering
  41034. * Forward main pass or through the imageProcessingPostProcess if present.
  41035. * As in the majority of the scene they are the same (exception for multi camera),
  41036. * this is easier to reference from here than from all the materials and post process.
  41037. *
  41038. * No setter as we it is a shared configuration, you can set the values instead.
  41039. */
  41040. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  41041. private _forceWireframe;
  41042. /**
  41043. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  41044. */
  41045. set forceWireframe(value: boolean);
  41046. get forceWireframe(): boolean;
  41047. private _skipFrustumClipping;
  41048. /**
  41049. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  41050. */
  41051. set skipFrustumClipping(value: boolean);
  41052. get skipFrustumClipping(): boolean;
  41053. private _forcePointsCloud;
  41054. /**
  41055. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  41056. */
  41057. set forcePointsCloud(value: boolean);
  41058. get forcePointsCloud(): boolean;
  41059. /**
  41060. * Gets or sets the active clipplane 1
  41061. */
  41062. clipPlane: Nullable<Plane>;
  41063. /**
  41064. * Gets or sets the active clipplane 2
  41065. */
  41066. clipPlane2: Nullable<Plane>;
  41067. /**
  41068. * Gets or sets the active clipplane 3
  41069. */
  41070. clipPlane3: Nullable<Plane>;
  41071. /**
  41072. * Gets or sets the active clipplane 4
  41073. */
  41074. clipPlane4: Nullable<Plane>;
  41075. /**
  41076. * Gets or sets the active clipplane 5
  41077. */
  41078. clipPlane5: Nullable<Plane>;
  41079. /**
  41080. * Gets or sets the active clipplane 6
  41081. */
  41082. clipPlane6: Nullable<Plane>;
  41083. /**
  41084. * Gets or sets a boolean indicating if animations are enabled
  41085. */
  41086. animationsEnabled: boolean;
  41087. private _animationPropertiesOverride;
  41088. /**
  41089. * Gets or sets the animation properties override
  41090. */
  41091. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  41092. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  41093. /**
  41094. * Gets or sets a boolean indicating if a constant deltatime has to be used
  41095. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  41096. */
  41097. useConstantAnimationDeltaTime: boolean;
  41098. /**
  41099. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  41100. * Please note that it requires to run a ray cast through the scene on every frame
  41101. */
  41102. constantlyUpdateMeshUnderPointer: boolean;
  41103. /**
  41104. * Defines the HTML cursor to use when hovering over interactive elements
  41105. */
  41106. hoverCursor: string;
  41107. /**
  41108. * Defines the HTML default cursor to use (empty by default)
  41109. */
  41110. defaultCursor: string;
  41111. /**
  41112. * Defines whether cursors are handled by the scene.
  41113. */
  41114. doNotHandleCursors: boolean;
  41115. /**
  41116. * This is used to call preventDefault() on pointer down
  41117. * in order to block unwanted artifacts like system double clicks
  41118. */
  41119. preventDefaultOnPointerDown: boolean;
  41120. /**
  41121. * This is used to call preventDefault() on pointer up
  41122. * in order to block unwanted artifacts like system double clicks
  41123. */
  41124. preventDefaultOnPointerUp: boolean;
  41125. /**
  41126. * Gets or sets user defined metadata
  41127. */
  41128. metadata: any;
  41129. /**
  41130. * For internal use only. Please do not use.
  41131. */
  41132. reservedDataStore: any;
  41133. /**
  41134. * Gets the name of the plugin used to load this scene (null by default)
  41135. */
  41136. loadingPluginName: string;
  41137. /**
  41138. * Use this array to add regular expressions used to disable offline support for specific urls
  41139. */
  41140. disableOfflineSupportExceptionRules: RegExp[];
  41141. /**
  41142. * An event triggered when the scene is disposed.
  41143. */
  41144. onDisposeObservable: Observable<Scene>;
  41145. private _onDisposeObserver;
  41146. /** Sets a function to be executed when this scene is disposed. */
  41147. set onDispose(callback: () => void);
  41148. /**
  41149. * An event triggered before rendering the scene (right after animations and physics)
  41150. */
  41151. onBeforeRenderObservable: Observable<Scene>;
  41152. private _onBeforeRenderObserver;
  41153. /** Sets a function to be executed before rendering this scene */
  41154. set beforeRender(callback: Nullable<() => void>);
  41155. /**
  41156. * An event triggered after rendering the scene
  41157. */
  41158. onAfterRenderObservable: Observable<Scene>;
  41159. /**
  41160. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  41161. */
  41162. onAfterRenderCameraObservable: Observable<Camera>;
  41163. private _onAfterRenderObserver;
  41164. /** Sets a function to be executed after rendering this scene */
  41165. set afterRender(callback: Nullable<() => void>);
  41166. /**
  41167. * An event triggered before animating the scene
  41168. */
  41169. onBeforeAnimationsObservable: Observable<Scene>;
  41170. /**
  41171. * An event triggered after animations processing
  41172. */
  41173. onAfterAnimationsObservable: Observable<Scene>;
  41174. /**
  41175. * An event triggered before draw calls are ready to be sent
  41176. */
  41177. onBeforeDrawPhaseObservable: Observable<Scene>;
  41178. /**
  41179. * An event triggered after draw calls have been sent
  41180. */
  41181. onAfterDrawPhaseObservable: Observable<Scene>;
  41182. /**
  41183. * An event triggered when the scene is ready
  41184. */
  41185. onReadyObservable: Observable<Scene>;
  41186. /**
  41187. * An event triggered before rendering a camera
  41188. */
  41189. onBeforeCameraRenderObservable: Observable<Camera>;
  41190. private _onBeforeCameraRenderObserver;
  41191. /** Sets a function to be executed before rendering a camera*/
  41192. set beforeCameraRender(callback: () => void);
  41193. /**
  41194. * An event triggered after rendering a camera
  41195. */
  41196. onAfterCameraRenderObservable: Observable<Camera>;
  41197. private _onAfterCameraRenderObserver;
  41198. /** Sets a function to be executed after rendering a camera*/
  41199. set afterCameraRender(callback: () => void);
  41200. /**
  41201. * An event triggered when active meshes evaluation is about to start
  41202. */
  41203. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  41204. /**
  41205. * An event triggered when active meshes evaluation is done
  41206. */
  41207. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  41208. /**
  41209. * An event triggered when particles rendering is about to start
  41210. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41211. */
  41212. onBeforeParticlesRenderingObservable: Observable<Scene>;
  41213. /**
  41214. * An event triggered when particles rendering is done
  41215. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  41216. */
  41217. onAfterParticlesRenderingObservable: Observable<Scene>;
  41218. /**
  41219. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  41220. */
  41221. onDataLoadedObservable: Observable<Scene>;
  41222. /**
  41223. * An event triggered when a camera is created
  41224. */
  41225. onNewCameraAddedObservable: Observable<Camera>;
  41226. /**
  41227. * An event triggered when a camera is removed
  41228. */
  41229. onCameraRemovedObservable: Observable<Camera>;
  41230. /**
  41231. * An event triggered when a light is created
  41232. */
  41233. onNewLightAddedObservable: Observable<Light>;
  41234. /**
  41235. * An event triggered when a light is removed
  41236. */
  41237. onLightRemovedObservable: Observable<Light>;
  41238. /**
  41239. * An event triggered when a geometry is created
  41240. */
  41241. onNewGeometryAddedObservable: Observable<Geometry>;
  41242. /**
  41243. * An event triggered when a geometry is removed
  41244. */
  41245. onGeometryRemovedObservable: Observable<Geometry>;
  41246. /**
  41247. * An event triggered when a transform node is created
  41248. */
  41249. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  41250. /**
  41251. * An event triggered when a transform node is removed
  41252. */
  41253. onTransformNodeRemovedObservable: Observable<TransformNode>;
  41254. /**
  41255. * An event triggered when a mesh is created
  41256. */
  41257. onNewMeshAddedObservable: Observable<AbstractMesh>;
  41258. /**
  41259. * An event triggered when a mesh is removed
  41260. */
  41261. onMeshRemovedObservable: Observable<AbstractMesh>;
  41262. /**
  41263. * An event triggered when a skeleton is created
  41264. */
  41265. onNewSkeletonAddedObservable: Observable<Skeleton>;
  41266. /**
  41267. * An event triggered when a skeleton is removed
  41268. */
  41269. onSkeletonRemovedObservable: Observable<Skeleton>;
  41270. /**
  41271. * An event triggered when a material is created
  41272. */
  41273. onNewMaterialAddedObservable: Observable<Material>;
  41274. /**
  41275. * An event triggered when a material is removed
  41276. */
  41277. onMaterialRemovedObservable: Observable<Material>;
  41278. /**
  41279. * An event triggered when a texture is created
  41280. */
  41281. onNewTextureAddedObservable: Observable<BaseTexture>;
  41282. /**
  41283. * An event triggered when a texture is removed
  41284. */
  41285. onTextureRemovedObservable: Observable<BaseTexture>;
  41286. /**
  41287. * An event triggered when render targets are about to be rendered
  41288. * Can happen multiple times per frame.
  41289. */
  41290. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  41291. /**
  41292. * An event triggered when render targets were rendered.
  41293. * Can happen multiple times per frame.
  41294. */
  41295. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  41296. /**
  41297. * An event triggered before calculating deterministic simulation step
  41298. */
  41299. onBeforeStepObservable: Observable<Scene>;
  41300. /**
  41301. * An event triggered after calculating deterministic simulation step
  41302. */
  41303. onAfterStepObservable: Observable<Scene>;
  41304. /**
  41305. * An event triggered when the activeCamera property is updated
  41306. */
  41307. onActiveCameraChanged: Observable<Scene>;
  41308. /**
  41309. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  41310. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41311. * 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)
  41312. */
  41313. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41314. /**
  41315. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  41316. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  41317. * 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)
  41318. */
  41319. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  41320. /**
  41321. * This Observable will when a mesh has been imported into the scene.
  41322. */
  41323. onMeshImportedObservable: Observable<AbstractMesh>;
  41324. /**
  41325. * This Observable will when an animation file has been imported into the scene.
  41326. */
  41327. onAnimationFileImportedObservable: Observable<Scene>;
  41328. /**
  41329. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  41330. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  41331. */
  41332. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  41333. /** @hidden */
  41334. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  41335. /**
  41336. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  41337. */
  41338. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  41339. /**
  41340. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  41341. */
  41342. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  41343. /**
  41344. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  41345. */
  41346. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  41347. /** Callback called when a pointer move is detected */
  41348. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41349. /** Callback called when a pointer down is detected */
  41350. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  41351. /** Callback called when a pointer up is detected */
  41352. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  41353. /** Callback called when a pointer pick is detected */
  41354. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  41355. /**
  41356. * 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).
  41357. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  41358. */
  41359. onPrePointerObservable: Observable<PointerInfoPre>;
  41360. /**
  41361. * Observable event triggered each time an input event is received from the rendering canvas
  41362. */
  41363. onPointerObservable: Observable<PointerInfo>;
  41364. /**
  41365. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  41366. */
  41367. get unTranslatedPointer(): Vector2;
  41368. /**
  41369. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  41370. */
  41371. static get DragMovementThreshold(): number;
  41372. static set DragMovementThreshold(value: number);
  41373. /**
  41374. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  41375. */
  41376. static get LongPressDelay(): number;
  41377. static set LongPressDelay(value: number);
  41378. /**
  41379. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  41380. */
  41381. static get DoubleClickDelay(): number;
  41382. static set DoubleClickDelay(value: number);
  41383. /** If you need to check double click without raising a single click at first click, enable this flag */
  41384. static get ExclusiveDoubleClickMode(): boolean;
  41385. static set ExclusiveDoubleClickMode(value: boolean);
  41386. /** @hidden */
  41387. _mirroredCameraPosition: Nullable<Vector3>;
  41388. /**
  41389. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  41390. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  41391. */
  41392. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  41393. /**
  41394. * Observable event triggered each time an keyboard event is received from the hosting window
  41395. */
  41396. onKeyboardObservable: Observable<KeyboardInfo>;
  41397. private _useRightHandedSystem;
  41398. /**
  41399. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  41400. */
  41401. set useRightHandedSystem(value: boolean);
  41402. get useRightHandedSystem(): boolean;
  41403. private _timeAccumulator;
  41404. private _currentStepId;
  41405. private _currentInternalStep;
  41406. /**
  41407. * Sets the step Id used by deterministic lock step
  41408. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41409. * @param newStepId defines the step Id
  41410. */
  41411. setStepId(newStepId: number): void;
  41412. /**
  41413. * Gets the step Id used by deterministic lock step
  41414. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41415. * @returns the step Id
  41416. */
  41417. getStepId(): number;
  41418. /**
  41419. * Gets the internal step used by deterministic lock step
  41420. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  41421. * @returns the internal step
  41422. */
  41423. getInternalStep(): number;
  41424. private _fogEnabled;
  41425. /**
  41426. * Gets or sets a boolean indicating if fog is enabled on this scene
  41427. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41428. * (Default is true)
  41429. */
  41430. set fogEnabled(value: boolean);
  41431. get fogEnabled(): boolean;
  41432. private _fogMode;
  41433. /**
  41434. * Gets or sets the fog mode to use
  41435. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41436. * | mode | value |
  41437. * | --- | --- |
  41438. * | FOGMODE_NONE | 0 |
  41439. * | FOGMODE_EXP | 1 |
  41440. * | FOGMODE_EXP2 | 2 |
  41441. * | FOGMODE_LINEAR | 3 |
  41442. */
  41443. set fogMode(value: number);
  41444. get fogMode(): number;
  41445. /**
  41446. * Gets or sets the fog color to use
  41447. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41448. * (Default is Color3(0.2, 0.2, 0.3))
  41449. */
  41450. fogColor: Color3;
  41451. /**
  41452. * Gets or sets the fog density to use
  41453. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41454. * (Default is 0.1)
  41455. */
  41456. fogDensity: number;
  41457. /**
  41458. * Gets or sets the fog start distance to use
  41459. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41460. * (Default is 0)
  41461. */
  41462. fogStart: number;
  41463. /**
  41464. * Gets or sets the fog end distance to use
  41465. * @see https://doc.babylonjs.com/babylon101/environment#fog
  41466. * (Default is 1000)
  41467. */
  41468. fogEnd: number;
  41469. /**
  41470. * Flag indicating that the frame buffer binding is handled by another component
  41471. */
  41472. prePass: boolean;
  41473. private _shadowsEnabled;
  41474. /**
  41475. * Gets or sets a boolean indicating if shadows are enabled on this scene
  41476. */
  41477. set shadowsEnabled(value: boolean);
  41478. get shadowsEnabled(): boolean;
  41479. private _lightsEnabled;
  41480. /**
  41481. * Gets or sets a boolean indicating if lights are enabled on this scene
  41482. */
  41483. set lightsEnabled(value: boolean);
  41484. get lightsEnabled(): boolean;
  41485. /** All of the active cameras added to this scene. */
  41486. activeCameras: Camera[];
  41487. /** @hidden */
  41488. _activeCamera: Nullable<Camera>;
  41489. /** Gets or sets the current active camera */
  41490. get activeCamera(): Nullable<Camera>;
  41491. set activeCamera(value: Nullable<Camera>);
  41492. private _defaultMaterial;
  41493. /** The default material used on meshes when no material is affected */
  41494. get defaultMaterial(): Material;
  41495. /** The default material used on meshes when no material is affected */
  41496. set defaultMaterial(value: Material);
  41497. private _texturesEnabled;
  41498. /**
  41499. * Gets or sets a boolean indicating if textures are enabled on this scene
  41500. */
  41501. set texturesEnabled(value: boolean);
  41502. get texturesEnabled(): boolean;
  41503. /**
  41504. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  41505. */
  41506. physicsEnabled: boolean;
  41507. /**
  41508. * Gets or sets a boolean indicating if particles are enabled on this scene
  41509. */
  41510. particlesEnabled: boolean;
  41511. /**
  41512. * Gets or sets a boolean indicating if sprites are enabled on this scene
  41513. */
  41514. spritesEnabled: boolean;
  41515. private _skeletonsEnabled;
  41516. /**
  41517. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  41518. */
  41519. set skeletonsEnabled(value: boolean);
  41520. get skeletonsEnabled(): boolean;
  41521. /**
  41522. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  41523. */
  41524. lensFlaresEnabled: boolean;
  41525. /**
  41526. * Gets or sets a boolean indicating if collisions are enabled on this scene
  41527. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41528. */
  41529. collisionsEnabled: boolean;
  41530. private _collisionCoordinator;
  41531. /** @hidden */
  41532. get collisionCoordinator(): ICollisionCoordinator;
  41533. /**
  41534. * Defines the gravity applied to this scene (used only for collisions)
  41535. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  41536. */
  41537. gravity: Vector3;
  41538. /**
  41539. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  41540. */
  41541. postProcessesEnabled: boolean;
  41542. /**
  41543. * Gets the current postprocess manager
  41544. */
  41545. postProcessManager: PostProcessManager;
  41546. /**
  41547. * Gets or sets a boolean indicating if render targets are enabled on this scene
  41548. */
  41549. renderTargetsEnabled: boolean;
  41550. /**
  41551. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  41552. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  41553. */
  41554. dumpNextRenderTargets: boolean;
  41555. /**
  41556. * The list of user defined render targets added to the scene
  41557. */
  41558. customRenderTargets: RenderTargetTexture[];
  41559. /**
  41560. * Defines if texture loading must be delayed
  41561. * If true, textures will only be loaded when they need to be rendered
  41562. */
  41563. useDelayedTextureLoading: boolean;
  41564. /**
  41565. * Gets the list of meshes imported to the scene through SceneLoader
  41566. */
  41567. importedMeshesFiles: String[];
  41568. /**
  41569. * Gets or sets a boolean indicating if probes are enabled on this scene
  41570. */
  41571. probesEnabled: boolean;
  41572. /**
  41573. * Gets or sets the current offline provider to use to store scene data
  41574. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  41575. */
  41576. offlineProvider: IOfflineProvider;
  41577. /**
  41578. * Gets or sets the action manager associated with the scene
  41579. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  41580. */
  41581. actionManager: AbstractActionManager;
  41582. private _meshesForIntersections;
  41583. /**
  41584. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  41585. */
  41586. proceduralTexturesEnabled: boolean;
  41587. private _engine;
  41588. private _totalVertices;
  41589. /** @hidden */
  41590. _activeIndices: PerfCounter;
  41591. /** @hidden */
  41592. _activeParticles: PerfCounter;
  41593. /** @hidden */
  41594. _activeBones: PerfCounter;
  41595. private _animationRatio;
  41596. /** @hidden */
  41597. _animationTimeLast: number;
  41598. /** @hidden */
  41599. _animationTime: number;
  41600. /**
  41601. * Gets or sets a general scale for animation speed
  41602. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  41603. */
  41604. animationTimeScale: number;
  41605. /** @hidden */
  41606. _cachedMaterial: Nullable<Material>;
  41607. /** @hidden */
  41608. _cachedEffect: Nullable<Effect>;
  41609. /** @hidden */
  41610. _cachedVisibility: Nullable<number>;
  41611. private _renderId;
  41612. private _frameId;
  41613. private _executeWhenReadyTimeoutId;
  41614. private _intermediateRendering;
  41615. private _viewUpdateFlag;
  41616. private _projectionUpdateFlag;
  41617. /** @hidden */
  41618. _toBeDisposed: Nullable<IDisposable>[];
  41619. private _activeRequests;
  41620. /** @hidden */
  41621. _pendingData: any[];
  41622. private _isDisposed;
  41623. /**
  41624. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  41625. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  41626. */
  41627. dispatchAllSubMeshesOfActiveMeshes: boolean;
  41628. private _activeMeshes;
  41629. private _processedMaterials;
  41630. private _renderTargets;
  41631. /** @hidden */
  41632. _activeParticleSystems: SmartArray<IParticleSystem>;
  41633. private _activeSkeletons;
  41634. private _softwareSkinnedMeshes;
  41635. private _renderingManager;
  41636. /** @hidden */
  41637. _activeAnimatables: import("babylonjs/Animations/animatable").Animatable[];
  41638. private _transformMatrix;
  41639. private _sceneUbo;
  41640. /** @hidden */
  41641. _viewMatrix: Matrix;
  41642. private _projectionMatrix;
  41643. /** @hidden */
  41644. _forcedViewPosition: Nullable<Vector3>;
  41645. /** @hidden */
  41646. _frustumPlanes: Plane[];
  41647. /**
  41648. * Gets the list of frustum planes (built from the active camera)
  41649. */
  41650. get frustumPlanes(): Plane[];
  41651. /**
  41652. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  41653. * This is useful if there are more lights that the maximum simulteanous authorized
  41654. */
  41655. requireLightSorting: boolean;
  41656. /** @hidden */
  41657. readonly useMaterialMeshMap: boolean;
  41658. /** @hidden */
  41659. readonly useClonedMeshMap: boolean;
  41660. private _externalData;
  41661. private _uid;
  41662. /**
  41663. * @hidden
  41664. * Backing store of defined scene components.
  41665. */
  41666. _components: ISceneComponent[];
  41667. /**
  41668. * @hidden
  41669. * Backing store of defined scene components.
  41670. */
  41671. _serializableComponents: ISceneSerializableComponent[];
  41672. /**
  41673. * List of components to register on the next registration step.
  41674. */
  41675. private _transientComponents;
  41676. /**
  41677. * Registers the transient components if needed.
  41678. */
  41679. private _registerTransientComponents;
  41680. /**
  41681. * @hidden
  41682. * Add a component to the scene.
  41683. * Note that the ccomponent could be registered on th next frame if this is called after
  41684. * the register component stage.
  41685. * @param component Defines the component to add to the scene
  41686. */
  41687. _addComponent(component: ISceneComponent): void;
  41688. /**
  41689. * @hidden
  41690. * Gets a component from the scene.
  41691. * @param name defines the name of the component to retrieve
  41692. * @returns the component or null if not present
  41693. */
  41694. _getComponent(name: string): Nullable<ISceneComponent>;
  41695. /**
  41696. * @hidden
  41697. * Defines the actions happening before camera updates.
  41698. */
  41699. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  41700. /**
  41701. * @hidden
  41702. * Defines the actions happening before clear the canvas.
  41703. */
  41704. _beforeClearStage: Stage<SimpleStageAction>;
  41705. /**
  41706. * @hidden
  41707. * Defines the actions when collecting render targets for the frame.
  41708. */
  41709. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41710. /**
  41711. * @hidden
  41712. * Defines the actions happening for one camera in the frame.
  41713. */
  41714. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  41715. /**
  41716. * @hidden
  41717. * Defines the actions happening during the per mesh ready checks.
  41718. */
  41719. _isReadyForMeshStage: Stage<MeshStageAction>;
  41720. /**
  41721. * @hidden
  41722. * Defines the actions happening before evaluate active mesh checks.
  41723. */
  41724. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  41725. /**
  41726. * @hidden
  41727. * Defines the actions happening during the evaluate sub mesh checks.
  41728. */
  41729. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  41730. /**
  41731. * @hidden
  41732. * Defines the actions happening during the active mesh stage.
  41733. */
  41734. _activeMeshStage: Stage<ActiveMeshStageAction>;
  41735. /**
  41736. * @hidden
  41737. * Defines the actions happening during the per camera render target step.
  41738. */
  41739. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  41740. /**
  41741. * @hidden
  41742. * Defines the actions happening just before the active camera is drawing.
  41743. */
  41744. _beforeCameraDrawStage: Stage<CameraStageAction>;
  41745. /**
  41746. * @hidden
  41747. * Defines the actions happening just before a render target is drawing.
  41748. */
  41749. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41750. /**
  41751. * @hidden
  41752. * Defines the actions happening just before a rendering group is drawing.
  41753. */
  41754. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41755. /**
  41756. * @hidden
  41757. * Defines the actions happening just before a mesh is drawing.
  41758. */
  41759. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41760. /**
  41761. * @hidden
  41762. * Defines the actions happening just after a mesh has been drawn.
  41763. */
  41764. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  41765. /**
  41766. * @hidden
  41767. * Defines the actions happening just after a rendering group has been drawn.
  41768. */
  41769. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  41770. /**
  41771. * @hidden
  41772. * Defines the actions happening just after the active camera has been drawn.
  41773. */
  41774. _afterCameraDrawStage: Stage<CameraStageAction>;
  41775. /**
  41776. * @hidden
  41777. * Defines the actions happening just after a render target has been drawn.
  41778. */
  41779. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  41780. /**
  41781. * @hidden
  41782. * Defines the actions happening just after rendering all cameras and computing intersections.
  41783. */
  41784. _afterRenderStage: Stage<SimpleStageAction>;
  41785. /**
  41786. * @hidden
  41787. * Defines the actions happening when a pointer move event happens.
  41788. */
  41789. _pointerMoveStage: Stage<PointerMoveStageAction>;
  41790. /**
  41791. * @hidden
  41792. * Defines the actions happening when a pointer down event happens.
  41793. */
  41794. _pointerDownStage: Stage<PointerUpDownStageAction>;
  41795. /**
  41796. * @hidden
  41797. * Defines the actions happening when a pointer up event happens.
  41798. */
  41799. _pointerUpStage: Stage<PointerUpDownStageAction>;
  41800. /**
  41801. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  41802. */
  41803. private geometriesByUniqueId;
  41804. /**
  41805. * Creates a new Scene
  41806. * @param engine defines the engine to use to render this scene
  41807. * @param options defines the scene options
  41808. */
  41809. constructor(engine: Engine, options?: SceneOptions);
  41810. /**
  41811. * Gets a string identifying the name of the class
  41812. * @returns "Scene" string
  41813. */
  41814. getClassName(): string;
  41815. private _defaultMeshCandidates;
  41816. /**
  41817. * @hidden
  41818. */
  41819. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  41820. private _defaultSubMeshCandidates;
  41821. /**
  41822. * @hidden
  41823. */
  41824. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  41825. /**
  41826. * Sets the default candidate providers for the scene.
  41827. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  41828. * and getCollidingSubMeshCandidates to their default function
  41829. */
  41830. setDefaultCandidateProviders(): void;
  41831. /**
  41832. * Gets the mesh that is currently under the pointer
  41833. */
  41834. get meshUnderPointer(): Nullable<AbstractMesh>;
  41835. /**
  41836. * Gets or sets the current on-screen X position of the pointer
  41837. */
  41838. get pointerX(): number;
  41839. set pointerX(value: number);
  41840. /**
  41841. * Gets or sets the current on-screen Y position of the pointer
  41842. */
  41843. get pointerY(): number;
  41844. set pointerY(value: number);
  41845. /**
  41846. * Gets the cached material (ie. the latest rendered one)
  41847. * @returns the cached material
  41848. */
  41849. getCachedMaterial(): Nullable<Material>;
  41850. /**
  41851. * Gets the cached effect (ie. the latest rendered one)
  41852. * @returns the cached effect
  41853. */
  41854. getCachedEffect(): Nullable<Effect>;
  41855. /**
  41856. * Gets the cached visibility state (ie. the latest rendered one)
  41857. * @returns the cached visibility state
  41858. */
  41859. getCachedVisibility(): Nullable<number>;
  41860. /**
  41861. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  41862. * @param material defines the current material
  41863. * @param effect defines the current effect
  41864. * @param visibility defines the current visibility state
  41865. * @returns true if one parameter is not cached
  41866. */
  41867. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  41868. /**
  41869. * Gets the engine associated with the scene
  41870. * @returns an Engine
  41871. */
  41872. getEngine(): Engine;
  41873. /**
  41874. * Gets the total number of vertices rendered per frame
  41875. * @returns the total number of vertices rendered per frame
  41876. */
  41877. getTotalVertices(): number;
  41878. /**
  41879. * Gets the performance counter for total vertices
  41880. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41881. */
  41882. get totalVerticesPerfCounter(): PerfCounter;
  41883. /**
  41884. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  41885. * @returns the total number of active indices rendered per frame
  41886. */
  41887. getActiveIndices(): number;
  41888. /**
  41889. * Gets the performance counter for active indices
  41890. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41891. */
  41892. get totalActiveIndicesPerfCounter(): PerfCounter;
  41893. /**
  41894. * Gets the total number of active particles rendered per frame
  41895. * @returns the total number of active particles rendered per frame
  41896. */
  41897. getActiveParticles(): number;
  41898. /**
  41899. * Gets the performance counter for active particles
  41900. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41901. */
  41902. get activeParticlesPerfCounter(): PerfCounter;
  41903. /**
  41904. * Gets the total number of active bones rendered per frame
  41905. * @returns the total number of active bones rendered per frame
  41906. */
  41907. getActiveBones(): number;
  41908. /**
  41909. * Gets the performance counter for active bones
  41910. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  41911. */
  41912. get activeBonesPerfCounter(): PerfCounter;
  41913. /**
  41914. * Gets the array of active meshes
  41915. * @returns an array of AbstractMesh
  41916. */
  41917. getActiveMeshes(): SmartArray<AbstractMesh>;
  41918. /**
  41919. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  41920. * @returns a number
  41921. */
  41922. getAnimationRatio(): number;
  41923. /**
  41924. * Gets an unique Id for the current render phase
  41925. * @returns a number
  41926. */
  41927. getRenderId(): number;
  41928. /**
  41929. * Gets an unique Id for the current frame
  41930. * @returns a number
  41931. */
  41932. getFrameId(): number;
  41933. /** Call this function if you want to manually increment the render Id*/
  41934. incrementRenderId(): void;
  41935. private _createUbo;
  41936. /**
  41937. * Use this method to simulate a pointer move on a mesh
  41938. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41939. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41940. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41941. * @returns the current scene
  41942. */
  41943. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41944. /**
  41945. * Use this method to simulate a pointer down on a mesh
  41946. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41947. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41948. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41949. * @returns the current scene
  41950. */
  41951. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  41952. /**
  41953. * Use this method to simulate a pointer up on a mesh
  41954. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  41955. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  41956. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  41957. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  41958. * @returns the current scene
  41959. */
  41960. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  41961. /**
  41962. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  41963. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  41964. * @returns true if the pointer was captured
  41965. */
  41966. isPointerCaptured(pointerId?: number): boolean;
  41967. /**
  41968. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  41969. * @param attachUp defines if you want to attach events to pointerup
  41970. * @param attachDown defines if you want to attach events to pointerdown
  41971. * @param attachMove defines if you want to attach events to pointermove
  41972. */
  41973. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  41974. /** Detaches all event handlers*/
  41975. detachControl(): void;
  41976. /**
  41977. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  41978. * Delay loaded resources are not taking in account
  41979. * @return true if all required resources are ready
  41980. */
  41981. isReady(): boolean;
  41982. /** Resets all cached information relative to material (including effect and visibility) */
  41983. resetCachedMaterial(): void;
  41984. /**
  41985. * Registers a function to be called before every frame render
  41986. * @param func defines the function to register
  41987. */
  41988. registerBeforeRender(func: () => void): void;
  41989. /**
  41990. * Unregisters a function called before every frame render
  41991. * @param func defines the function to unregister
  41992. */
  41993. unregisterBeforeRender(func: () => void): void;
  41994. /**
  41995. * Registers a function to be called after every frame render
  41996. * @param func defines the function to register
  41997. */
  41998. registerAfterRender(func: () => void): void;
  41999. /**
  42000. * Unregisters a function called after every frame render
  42001. * @param func defines the function to unregister
  42002. */
  42003. unregisterAfterRender(func: () => void): void;
  42004. private _executeOnceBeforeRender;
  42005. /**
  42006. * The provided function will run before render once and will be disposed afterwards.
  42007. * A timeout delay can be provided so that the function will be executed in N ms.
  42008. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  42009. * @param func The function to be executed.
  42010. * @param timeout optional delay in ms
  42011. */
  42012. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  42013. /** @hidden */
  42014. _addPendingData(data: any): void;
  42015. /** @hidden */
  42016. _removePendingData(data: any): void;
  42017. /**
  42018. * Returns the number of items waiting to be loaded
  42019. * @returns the number of items waiting to be loaded
  42020. */
  42021. getWaitingItemsCount(): number;
  42022. /**
  42023. * Returns a boolean indicating if the scene is still loading data
  42024. */
  42025. get isLoading(): boolean;
  42026. /**
  42027. * Registers a function to be executed when the scene is ready
  42028. * @param {Function} func - the function to be executed
  42029. */
  42030. executeWhenReady(func: () => void): void;
  42031. /**
  42032. * Returns a promise that resolves when the scene is ready
  42033. * @returns A promise that resolves when the scene is ready
  42034. */
  42035. whenReadyAsync(): Promise<void>;
  42036. /** @hidden */
  42037. _checkIsReady(): void;
  42038. /**
  42039. * Gets all animatable attached to the scene
  42040. */
  42041. get animatables(): Animatable[];
  42042. /**
  42043. * Resets the last animation time frame.
  42044. * Useful to override when animations start running when loading a scene for the first time.
  42045. */
  42046. resetLastAnimationTimeFrame(): void;
  42047. /**
  42048. * Gets the current view matrix
  42049. * @returns a Matrix
  42050. */
  42051. getViewMatrix(): Matrix;
  42052. /**
  42053. * Gets the current projection matrix
  42054. * @returns a Matrix
  42055. */
  42056. getProjectionMatrix(): Matrix;
  42057. /**
  42058. * Gets the current transform matrix
  42059. * @returns a Matrix made of View * Projection
  42060. */
  42061. getTransformMatrix(): Matrix;
  42062. /**
  42063. * Sets the current transform matrix
  42064. * @param viewL defines the View matrix to use
  42065. * @param projectionL defines the Projection matrix to use
  42066. * @param viewR defines the right View matrix to use (if provided)
  42067. * @param projectionR defines the right Projection matrix to use (if provided)
  42068. */
  42069. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  42070. /**
  42071. * Gets the uniform buffer used to store scene data
  42072. * @returns a UniformBuffer
  42073. */
  42074. getSceneUniformBuffer(): UniformBuffer;
  42075. /**
  42076. * Gets an unique (relatively to the current scene) Id
  42077. * @returns an unique number for the scene
  42078. */
  42079. getUniqueId(): number;
  42080. /**
  42081. * Add a mesh to the list of scene's meshes
  42082. * @param newMesh defines the mesh to add
  42083. * @param recursive if all child meshes should also be added to the scene
  42084. */
  42085. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  42086. /**
  42087. * Remove a mesh for the list of scene's meshes
  42088. * @param toRemove defines the mesh to remove
  42089. * @param recursive if all child meshes should also be removed from the scene
  42090. * @returns the index where the mesh was in the mesh list
  42091. */
  42092. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  42093. /**
  42094. * Add a transform node to the list of scene's transform nodes
  42095. * @param newTransformNode defines the transform node to add
  42096. */
  42097. addTransformNode(newTransformNode: TransformNode): void;
  42098. /**
  42099. * Remove a transform node for the list of scene's transform nodes
  42100. * @param toRemove defines the transform node to remove
  42101. * @returns the index where the transform node was in the transform node list
  42102. */
  42103. removeTransformNode(toRemove: TransformNode): number;
  42104. /**
  42105. * Remove a skeleton for the list of scene's skeletons
  42106. * @param toRemove defines the skeleton to remove
  42107. * @returns the index where the skeleton was in the skeleton list
  42108. */
  42109. removeSkeleton(toRemove: Skeleton): number;
  42110. /**
  42111. * Remove a morph target for the list of scene's morph targets
  42112. * @param toRemove defines the morph target to remove
  42113. * @returns the index where the morph target was in the morph target list
  42114. */
  42115. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  42116. /**
  42117. * Remove a light for the list of scene's lights
  42118. * @param toRemove defines the light to remove
  42119. * @returns the index where the light was in the light list
  42120. */
  42121. removeLight(toRemove: Light): number;
  42122. /**
  42123. * Remove a camera for the list of scene's cameras
  42124. * @param toRemove defines the camera to remove
  42125. * @returns the index where the camera was in the camera list
  42126. */
  42127. removeCamera(toRemove: Camera): number;
  42128. /**
  42129. * Remove a particle system for the list of scene's particle systems
  42130. * @param toRemove defines the particle system to remove
  42131. * @returns the index where the particle system was in the particle system list
  42132. */
  42133. removeParticleSystem(toRemove: IParticleSystem): number;
  42134. /**
  42135. * Remove a animation for the list of scene's animations
  42136. * @param toRemove defines the animation to remove
  42137. * @returns the index where the animation was in the animation list
  42138. */
  42139. removeAnimation(toRemove: Animation): number;
  42140. /**
  42141. * Will stop the animation of the given target
  42142. * @param target - the target
  42143. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  42144. * @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)
  42145. */
  42146. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  42147. /**
  42148. * Removes the given animation group from this scene.
  42149. * @param toRemove The animation group to remove
  42150. * @returns The index of the removed animation group
  42151. */
  42152. removeAnimationGroup(toRemove: AnimationGroup): number;
  42153. /**
  42154. * Removes the given multi-material from this scene.
  42155. * @param toRemove The multi-material to remove
  42156. * @returns The index of the removed multi-material
  42157. */
  42158. removeMultiMaterial(toRemove: MultiMaterial): number;
  42159. /**
  42160. * Removes the given material from this scene.
  42161. * @param toRemove The material to remove
  42162. * @returns The index of the removed material
  42163. */
  42164. removeMaterial(toRemove: Material): number;
  42165. /**
  42166. * Removes the given action manager from this scene.
  42167. * @param toRemove The action manager to remove
  42168. * @returns The index of the removed action manager
  42169. */
  42170. removeActionManager(toRemove: AbstractActionManager): number;
  42171. /**
  42172. * Removes the given texture from this scene.
  42173. * @param toRemove The texture to remove
  42174. * @returns The index of the removed texture
  42175. */
  42176. removeTexture(toRemove: BaseTexture): number;
  42177. /**
  42178. * Adds the given light to this scene
  42179. * @param newLight The light to add
  42180. */
  42181. addLight(newLight: Light): void;
  42182. /**
  42183. * Sorts the list list based on light priorities
  42184. */
  42185. sortLightsByPriority(): void;
  42186. /**
  42187. * Adds the given camera to this scene
  42188. * @param newCamera The camera to add
  42189. */
  42190. addCamera(newCamera: Camera): void;
  42191. /**
  42192. * Adds the given skeleton to this scene
  42193. * @param newSkeleton The skeleton to add
  42194. */
  42195. addSkeleton(newSkeleton: Skeleton): void;
  42196. /**
  42197. * Adds the given particle system to this scene
  42198. * @param newParticleSystem The particle system to add
  42199. */
  42200. addParticleSystem(newParticleSystem: IParticleSystem): void;
  42201. /**
  42202. * Adds the given animation to this scene
  42203. * @param newAnimation The animation to add
  42204. */
  42205. addAnimation(newAnimation: Animation): void;
  42206. /**
  42207. * Adds the given animation group to this scene.
  42208. * @param newAnimationGroup The animation group to add
  42209. */
  42210. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  42211. /**
  42212. * Adds the given multi-material to this scene
  42213. * @param newMultiMaterial The multi-material to add
  42214. */
  42215. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  42216. /**
  42217. * Adds the given material to this scene
  42218. * @param newMaterial The material to add
  42219. */
  42220. addMaterial(newMaterial: Material): void;
  42221. /**
  42222. * Adds the given morph target to this scene
  42223. * @param newMorphTargetManager The morph target to add
  42224. */
  42225. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  42226. /**
  42227. * Adds the given geometry to this scene
  42228. * @param newGeometry The geometry to add
  42229. */
  42230. addGeometry(newGeometry: Geometry): void;
  42231. /**
  42232. * Adds the given action manager to this scene
  42233. * @param newActionManager The action manager to add
  42234. */
  42235. addActionManager(newActionManager: AbstractActionManager): void;
  42236. /**
  42237. * Adds the given texture to this scene.
  42238. * @param newTexture The texture to add
  42239. */
  42240. addTexture(newTexture: BaseTexture): void;
  42241. /**
  42242. * Switch active camera
  42243. * @param newCamera defines the new active camera
  42244. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  42245. */
  42246. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  42247. /**
  42248. * sets the active camera of the scene using its ID
  42249. * @param id defines the camera's ID
  42250. * @return the new active camera or null if none found.
  42251. */
  42252. setActiveCameraByID(id: string): Nullable<Camera>;
  42253. /**
  42254. * sets the active camera of the scene using its name
  42255. * @param name defines the camera's name
  42256. * @returns the new active camera or null if none found.
  42257. */
  42258. setActiveCameraByName(name: string): Nullable<Camera>;
  42259. /**
  42260. * get an animation group using its name
  42261. * @param name defines the material's name
  42262. * @return the animation group or null if none found.
  42263. */
  42264. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  42265. /**
  42266. * Get a material using its unique id
  42267. * @param uniqueId defines the material's unique id
  42268. * @return the material or null if none found.
  42269. */
  42270. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  42271. /**
  42272. * get a material using its id
  42273. * @param id defines the material's ID
  42274. * @return the material or null if none found.
  42275. */
  42276. getMaterialByID(id: string): Nullable<Material>;
  42277. /**
  42278. * Gets a the last added material using a given id
  42279. * @param id defines the material's ID
  42280. * @return the last material with the given id or null if none found.
  42281. */
  42282. getLastMaterialByID(id: string): Nullable<Material>;
  42283. /**
  42284. * Gets a material using its name
  42285. * @param name defines the material's name
  42286. * @return the material or null if none found.
  42287. */
  42288. getMaterialByName(name: string): Nullable<Material>;
  42289. /**
  42290. * Get a texture using its unique id
  42291. * @param uniqueId defines the texture's unique id
  42292. * @return the texture or null if none found.
  42293. */
  42294. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  42295. /**
  42296. * Gets a camera using its id
  42297. * @param id defines the id to look for
  42298. * @returns the camera or null if not found
  42299. */
  42300. getCameraByID(id: string): Nullable<Camera>;
  42301. /**
  42302. * Gets a camera using its unique id
  42303. * @param uniqueId defines the unique id to look for
  42304. * @returns the camera or null if not found
  42305. */
  42306. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  42307. /**
  42308. * Gets a camera using its name
  42309. * @param name defines the camera's name
  42310. * @return the camera or null if none found.
  42311. */
  42312. getCameraByName(name: string): Nullable<Camera>;
  42313. /**
  42314. * Gets a bone using its id
  42315. * @param id defines the bone's id
  42316. * @return the bone or null if not found
  42317. */
  42318. getBoneByID(id: string): Nullable<Bone>;
  42319. /**
  42320. * Gets a bone using its id
  42321. * @param name defines the bone's name
  42322. * @return the bone or null if not found
  42323. */
  42324. getBoneByName(name: string): Nullable<Bone>;
  42325. /**
  42326. * Gets a light node using its name
  42327. * @param name defines the the light's name
  42328. * @return the light or null if none found.
  42329. */
  42330. getLightByName(name: string): Nullable<Light>;
  42331. /**
  42332. * Gets a light node using its id
  42333. * @param id defines the light's id
  42334. * @return the light or null if none found.
  42335. */
  42336. getLightByID(id: string): Nullable<Light>;
  42337. /**
  42338. * Gets a light node using its scene-generated unique ID
  42339. * @param uniqueId defines the light's unique id
  42340. * @return the light or null if none found.
  42341. */
  42342. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  42343. /**
  42344. * Gets a particle system by id
  42345. * @param id defines the particle system id
  42346. * @return the corresponding system or null if none found
  42347. */
  42348. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  42349. /**
  42350. * Gets a geometry using its ID
  42351. * @param id defines the geometry's id
  42352. * @return the geometry or null if none found.
  42353. */
  42354. getGeometryByID(id: string): Nullable<Geometry>;
  42355. private _getGeometryByUniqueID;
  42356. /**
  42357. * Add a new geometry to this scene
  42358. * @param geometry defines the geometry to be added to the scene.
  42359. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  42360. * @return a boolean defining if the geometry was added or not
  42361. */
  42362. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  42363. /**
  42364. * Removes an existing geometry
  42365. * @param geometry defines the geometry to be removed from the scene
  42366. * @return a boolean defining if the geometry was removed or not
  42367. */
  42368. removeGeometry(geometry: Geometry): boolean;
  42369. /**
  42370. * Gets the list of geometries attached to the scene
  42371. * @returns an array of Geometry
  42372. */
  42373. getGeometries(): Geometry[];
  42374. /**
  42375. * Gets the first added mesh found of a given ID
  42376. * @param id defines the id to search for
  42377. * @return the mesh found or null if not found at all
  42378. */
  42379. getMeshByID(id: string): Nullable<AbstractMesh>;
  42380. /**
  42381. * Gets a list of meshes using their id
  42382. * @param id defines the id to search for
  42383. * @returns a list of meshes
  42384. */
  42385. getMeshesByID(id: string): Array<AbstractMesh>;
  42386. /**
  42387. * Gets the first added transform node found of a given ID
  42388. * @param id defines the id to search for
  42389. * @return the found transform node or null if not found at all.
  42390. */
  42391. getTransformNodeByID(id: string): Nullable<TransformNode>;
  42392. /**
  42393. * Gets a transform node with its auto-generated unique id
  42394. * @param uniqueId efines the unique id to search for
  42395. * @return the found transform node or null if not found at all.
  42396. */
  42397. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  42398. /**
  42399. * Gets a list of transform nodes using their id
  42400. * @param id defines the id to search for
  42401. * @returns a list of transform nodes
  42402. */
  42403. getTransformNodesByID(id: string): Array<TransformNode>;
  42404. /**
  42405. * Gets a mesh with its auto-generated unique id
  42406. * @param uniqueId defines the unique id to search for
  42407. * @return the found mesh or null if not found at all.
  42408. */
  42409. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  42410. /**
  42411. * Gets a the last added mesh using a given id
  42412. * @param id defines the id to search for
  42413. * @return the found mesh or null if not found at all.
  42414. */
  42415. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  42416. /**
  42417. * Gets a the last added node (Mesh, Camera, Light) using a given id
  42418. * @param id defines the id to search for
  42419. * @return the found node or null if not found at all
  42420. */
  42421. getLastEntryByID(id: string): Nullable<Node>;
  42422. /**
  42423. * Gets a node (Mesh, Camera, Light) using a given id
  42424. * @param id defines the id to search for
  42425. * @return the found node or null if not found at all
  42426. */
  42427. getNodeByID(id: string): Nullable<Node>;
  42428. /**
  42429. * Gets a node (Mesh, Camera, Light) using a given name
  42430. * @param name defines the name to search for
  42431. * @return the found node or null if not found at all.
  42432. */
  42433. getNodeByName(name: string): Nullable<Node>;
  42434. /**
  42435. * Gets a mesh using a given name
  42436. * @param name defines the name to search for
  42437. * @return the found mesh or null if not found at all.
  42438. */
  42439. getMeshByName(name: string): Nullable<AbstractMesh>;
  42440. /**
  42441. * Gets a transform node using a given name
  42442. * @param name defines the name to search for
  42443. * @return the found transform node or null if not found at all.
  42444. */
  42445. getTransformNodeByName(name: string): Nullable<TransformNode>;
  42446. /**
  42447. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  42448. * @param id defines the id to search for
  42449. * @return the found skeleton or null if not found at all.
  42450. */
  42451. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  42452. /**
  42453. * Gets a skeleton using a given auto generated unique id
  42454. * @param uniqueId defines the unique id to search for
  42455. * @return the found skeleton or null if not found at all.
  42456. */
  42457. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  42458. /**
  42459. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  42460. * @param id defines the id to search for
  42461. * @return the found skeleton or null if not found at all.
  42462. */
  42463. getSkeletonById(id: string): Nullable<Skeleton>;
  42464. /**
  42465. * Gets a skeleton using a given name
  42466. * @param name defines the name to search for
  42467. * @return the found skeleton or null if not found at all.
  42468. */
  42469. getSkeletonByName(name: string): Nullable<Skeleton>;
  42470. /**
  42471. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  42472. * @param id defines the id to search for
  42473. * @return the found morph target manager or null if not found at all.
  42474. */
  42475. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  42476. /**
  42477. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  42478. * @param id defines the id to search for
  42479. * @return the found morph target or null if not found at all.
  42480. */
  42481. getMorphTargetById(id: string): Nullable<MorphTarget>;
  42482. /**
  42483. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  42484. * @param name defines the name to search for
  42485. * @return the found morph target or null if not found at all.
  42486. */
  42487. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  42488. /**
  42489. * Gets a post process using a given name (if many are found, this function will pick the first one)
  42490. * @param name defines the name to search for
  42491. * @return the found post process or null if not found at all.
  42492. */
  42493. getPostProcessByName(name: string): Nullable<PostProcess>;
  42494. /**
  42495. * Gets a boolean indicating if the given mesh is active
  42496. * @param mesh defines the mesh to look for
  42497. * @returns true if the mesh is in the active list
  42498. */
  42499. isActiveMesh(mesh: AbstractMesh): boolean;
  42500. /**
  42501. * Return a unique id as a string which can serve as an identifier for the scene
  42502. */
  42503. get uid(): string;
  42504. /**
  42505. * Add an externaly attached data from its key.
  42506. * This method call will fail and return false, if such key already exists.
  42507. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  42508. * @param key the unique key that identifies the data
  42509. * @param data the data object to associate to the key for this Engine instance
  42510. * @return true if no such key were already present and the data was added successfully, false otherwise
  42511. */
  42512. addExternalData<T>(key: string, data: T): boolean;
  42513. /**
  42514. * Get an externaly attached data from its key
  42515. * @param key the unique key that identifies the data
  42516. * @return the associated data, if present (can be null), or undefined if not present
  42517. */
  42518. getExternalData<T>(key: string): Nullable<T>;
  42519. /**
  42520. * Get an externaly attached data from its key, create it using a factory if it's not already present
  42521. * @param key the unique key that identifies the data
  42522. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  42523. * @return the associated data, can be null if the factory returned null.
  42524. */
  42525. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  42526. /**
  42527. * Remove an externaly attached data from the Engine instance
  42528. * @param key the unique key that identifies the data
  42529. * @return true if the data was successfully removed, false if it doesn't exist
  42530. */
  42531. removeExternalData(key: string): boolean;
  42532. private _evaluateSubMesh;
  42533. /**
  42534. * Clear the processed materials smart array preventing retention point in material dispose.
  42535. */
  42536. freeProcessedMaterials(): void;
  42537. private _preventFreeActiveMeshesAndRenderingGroups;
  42538. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  42539. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  42540. * when disposing several meshes in a row or a hierarchy of meshes.
  42541. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  42542. */
  42543. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  42544. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  42545. /**
  42546. * Clear the active meshes smart array preventing retention point in mesh dispose.
  42547. */
  42548. freeActiveMeshes(): void;
  42549. /**
  42550. * Clear the info related to rendering groups preventing retention points during dispose.
  42551. */
  42552. freeRenderingGroups(): void;
  42553. /** @hidden */
  42554. _isInIntermediateRendering(): boolean;
  42555. /**
  42556. * Lambda returning the list of potentially active meshes.
  42557. */
  42558. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  42559. /**
  42560. * Lambda returning the list of potentially active sub meshes.
  42561. */
  42562. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  42563. /**
  42564. * Lambda returning the list of potentially intersecting sub meshes.
  42565. */
  42566. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  42567. /**
  42568. * Lambda returning the list of potentially colliding sub meshes.
  42569. */
  42570. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  42571. private _activeMeshesFrozen;
  42572. private _skipEvaluateActiveMeshesCompletely;
  42573. /**
  42574. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  42575. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  42576. * @returns the current scene
  42577. */
  42578. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  42579. /**
  42580. * Use this function to restart evaluating active meshes on every frame
  42581. * @returns the current scene
  42582. */
  42583. unfreezeActiveMeshes(): Scene;
  42584. private _evaluateActiveMeshes;
  42585. private _activeMesh;
  42586. /**
  42587. * Update the transform matrix to update from the current active camera
  42588. * @param force defines a boolean used to force the update even if cache is up to date
  42589. */
  42590. updateTransformMatrix(force?: boolean): void;
  42591. private _bindFrameBuffer;
  42592. /** @hidden */
  42593. _allowPostProcessClearColor: boolean;
  42594. /** @hidden */
  42595. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  42596. private _processSubCameras;
  42597. private _checkIntersections;
  42598. /** @hidden */
  42599. _advancePhysicsEngineStep(step: number): void;
  42600. /**
  42601. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  42602. */
  42603. getDeterministicFrameTime: () => number;
  42604. /** @hidden */
  42605. _animate(): void;
  42606. /** Execute all animations (for a frame) */
  42607. animate(): void;
  42608. /**
  42609. * Render the scene
  42610. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  42611. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  42612. */
  42613. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  42614. /**
  42615. * Freeze all materials
  42616. * A frozen material will not be updatable but should be faster to render
  42617. */
  42618. freezeMaterials(): void;
  42619. /**
  42620. * Unfreeze all materials
  42621. * A frozen material will not be updatable but should be faster to render
  42622. */
  42623. unfreezeMaterials(): void;
  42624. /**
  42625. * Releases all held ressources
  42626. */
  42627. dispose(): void;
  42628. /**
  42629. * Gets if the scene is already disposed
  42630. */
  42631. get isDisposed(): boolean;
  42632. /**
  42633. * Call this function to reduce memory footprint of the scene.
  42634. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  42635. */
  42636. clearCachedVertexData(): void;
  42637. /**
  42638. * This function will remove the local cached buffer data from texture.
  42639. * It will save memory but will prevent the texture from being rebuilt
  42640. */
  42641. cleanCachedTextureBuffer(): void;
  42642. /**
  42643. * Get the world extend vectors with an optional filter
  42644. *
  42645. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  42646. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  42647. */
  42648. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  42649. min: Vector3;
  42650. max: Vector3;
  42651. };
  42652. /**
  42653. * Creates a ray that can be used to pick in the scene
  42654. * @param x defines the x coordinate of the origin (on-screen)
  42655. * @param y defines the y coordinate of the origin (on-screen)
  42656. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42657. * @param camera defines the camera to use for the picking
  42658. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42659. * @returns a Ray
  42660. */
  42661. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  42662. /**
  42663. * Creates a ray that can be used to pick in the scene
  42664. * @param x defines the x coordinate of the origin (on-screen)
  42665. * @param y defines the y coordinate of the origin (on-screen)
  42666. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  42667. * @param result defines the ray where to store the picking ray
  42668. * @param camera defines the camera to use for the picking
  42669. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  42670. * @returns the current scene
  42671. */
  42672. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  42673. /**
  42674. * Creates a ray that can be used to pick in the scene
  42675. * @param x defines the x coordinate of the origin (on-screen)
  42676. * @param y defines the y coordinate of the origin (on-screen)
  42677. * @param camera defines the camera to use for the picking
  42678. * @returns a Ray
  42679. */
  42680. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  42681. /**
  42682. * Creates a ray that can be used to pick in the scene
  42683. * @param x defines the x coordinate of the origin (on-screen)
  42684. * @param y defines the y coordinate of the origin (on-screen)
  42685. * @param result defines the ray where to store the picking ray
  42686. * @param camera defines the camera to use for the picking
  42687. * @returns the current scene
  42688. */
  42689. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  42690. /** Launch a ray to try to pick a mesh in the scene
  42691. * @param x position on screen
  42692. * @param y position on screen
  42693. * @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
  42694. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42695. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42696. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42697. * @returns a PickingInfo
  42698. */
  42699. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42700. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  42701. * @param x position on screen
  42702. * @param y position on screen
  42703. * @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
  42704. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42705. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42706. * @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)
  42707. */
  42708. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  42709. /** Use the given ray to pick a mesh in the scene
  42710. * @param ray The ray to use to pick meshes
  42711. * @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
  42712. * @param fastCheck defines if the first intersection will be used (and not the closest)
  42713. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42714. * @returns a PickingInfo
  42715. */
  42716. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  42717. /**
  42718. * Launch a ray to try to pick a mesh in the scene
  42719. * @param x X position on screen
  42720. * @param y Y position on screen
  42721. * @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
  42722. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  42723. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42724. * @returns an array of PickingInfo
  42725. */
  42726. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42727. /**
  42728. * Launch a ray to try to pick a mesh in the scene
  42729. * @param ray Ray to use
  42730. * @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
  42731. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  42732. * @returns an array of PickingInfo
  42733. */
  42734. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  42735. /**
  42736. * Force the value of meshUnderPointer
  42737. * @param mesh defines the mesh to use
  42738. * @param pointerId optional pointer id when using more than one pointer
  42739. */
  42740. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  42741. /**
  42742. * Gets the mesh under the pointer
  42743. * @returns a Mesh or null if no mesh is under the pointer
  42744. */
  42745. getPointerOverMesh(): Nullable<AbstractMesh>;
  42746. /** @hidden */
  42747. _rebuildGeometries(): void;
  42748. /** @hidden */
  42749. _rebuildTextures(): void;
  42750. private _getByTags;
  42751. /**
  42752. * Get a list of meshes by tags
  42753. * @param tagsQuery defines the tags query to use
  42754. * @param forEach defines a predicate used to filter results
  42755. * @returns an array of Mesh
  42756. */
  42757. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  42758. /**
  42759. * Get a list of cameras by tags
  42760. * @param tagsQuery defines the tags query to use
  42761. * @param forEach defines a predicate used to filter results
  42762. * @returns an array of Camera
  42763. */
  42764. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  42765. /**
  42766. * Get a list of lights by tags
  42767. * @param tagsQuery defines the tags query to use
  42768. * @param forEach defines a predicate used to filter results
  42769. * @returns an array of Light
  42770. */
  42771. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  42772. /**
  42773. * Get a list of materials by tags
  42774. * @param tagsQuery defines the tags query to use
  42775. * @param forEach defines a predicate used to filter results
  42776. * @returns an array of Material
  42777. */
  42778. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  42779. /**
  42780. * Get a list of transform nodes by tags
  42781. * @param tagsQuery defines the tags query to use
  42782. * @param forEach defines a predicate used to filter results
  42783. * @returns an array of TransformNode
  42784. */
  42785. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  42786. /**
  42787. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  42788. * This allowed control for front to back rendering or reversly depending of the special needs.
  42789. *
  42790. * @param renderingGroupId The rendering group id corresponding to its index
  42791. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  42792. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  42793. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  42794. */
  42795. 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;
  42796. /**
  42797. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  42798. *
  42799. * @param renderingGroupId The rendering group id corresponding to its index
  42800. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  42801. * @param depth Automatically clears depth between groups if true and autoClear is true.
  42802. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  42803. */
  42804. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  42805. /**
  42806. * Gets the current auto clear configuration for one rendering group of the rendering
  42807. * manager.
  42808. * @param index the rendering group index to get the information for
  42809. * @returns The auto clear setup for the requested rendering group
  42810. */
  42811. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  42812. private _blockMaterialDirtyMechanism;
  42813. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  42814. get blockMaterialDirtyMechanism(): boolean;
  42815. set blockMaterialDirtyMechanism(value: boolean);
  42816. /**
  42817. * Will flag all materials as dirty to trigger new shader compilation
  42818. * @param flag defines the flag used to specify which material part must be marked as dirty
  42819. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  42820. */
  42821. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  42822. /** @hidden */
  42823. _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;
  42824. /** @hidden */
  42825. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42826. /** @hidden */
  42827. _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;
  42828. /** @hidden */
  42829. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  42830. /** @hidden */
  42831. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  42832. /** @hidden */
  42833. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  42834. }
  42835. }
  42836. declare module "babylonjs/assetContainer" {
  42837. import { AbstractScene } from "babylonjs/abstractScene";
  42838. import { Scene } from "babylonjs/scene";
  42839. import { Mesh } from "babylonjs/Meshes/mesh";
  42840. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42841. import { Skeleton } from "babylonjs/Bones/skeleton";
  42842. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42843. import { Animatable } from "babylonjs/Animations/animatable";
  42844. import { Nullable } from "babylonjs/types";
  42845. import { Node } from "babylonjs/node";
  42846. /**
  42847. * Set of assets to keep when moving a scene into an asset container.
  42848. */
  42849. export class KeepAssets extends AbstractScene {
  42850. }
  42851. /**
  42852. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  42853. */
  42854. export class InstantiatedEntries {
  42855. /**
  42856. * List of new root nodes (eg. nodes with no parent)
  42857. */
  42858. rootNodes: TransformNode[];
  42859. /**
  42860. * List of new skeletons
  42861. */
  42862. skeletons: Skeleton[];
  42863. /**
  42864. * List of new animation groups
  42865. */
  42866. animationGroups: AnimationGroup[];
  42867. }
  42868. /**
  42869. * Container with a set of assets that can be added or removed from a scene.
  42870. */
  42871. export class AssetContainer extends AbstractScene {
  42872. private _wasAddedToScene;
  42873. /**
  42874. * The scene the AssetContainer belongs to.
  42875. */
  42876. scene: Scene;
  42877. /**
  42878. * Instantiates an AssetContainer.
  42879. * @param scene The scene the AssetContainer belongs to.
  42880. */
  42881. constructor(scene: Scene);
  42882. /**
  42883. * Instantiate or clone all meshes and add the new ones to the scene.
  42884. * Skeletons and animation groups will all be cloned
  42885. * @param nameFunction defines an optional function used to get new names for clones
  42886. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  42887. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  42888. */
  42889. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  42890. /**
  42891. * Adds all the assets from the container to the scene.
  42892. */
  42893. addAllToScene(): void;
  42894. /**
  42895. * Removes all the assets in the container from the scene
  42896. */
  42897. removeAllFromScene(): void;
  42898. /**
  42899. * Disposes all the assets in the container
  42900. */
  42901. dispose(): void;
  42902. private _moveAssets;
  42903. /**
  42904. * Removes all the assets contained in the scene and adds them to the container.
  42905. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  42906. */
  42907. moveAllFromScene(keepAssets?: KeepAssets): void;
  42908. /**
  42909. * 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.
  42910. * @returns the root mesh
  42911. */
  42912. createRootMesh(): Mesh;
  42913. /**
  42914. * Merge animations (direct and animation groups) from this asset container into a scene
  42915. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  42916. * @param animatables set of animatables to retarget to a node from the scene
  42917. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  42918. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  42919. */
  42920. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  42921. }
  42922. }
  42923. declare module "babylonjs/abstractScene" {
  42924. import { Scene } from "babylonjs/scene";
  42925. import { Nullable } from "babylonjs/types";
  42926. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  42927. import { TransformNode } from "babylonjs/Meshes/transformNode";
  42928. import { Geometry } from "babylonjs/Meshes/geometry";
  42929. import { Skeleton } from "babylonjs/Bones/skeleton";
  42930. import { MorphTargetManager } from "babylonjs/Morph/morphTargetManager";
  42931. import { AssetContainer } from "babylonjs/assetContainer";
  42932. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  42933. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  42934. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  42935. import { Material } from "babylonjs/Materials/material";
  42936. import { MultiMaterial } from "babylonjs/Materials/multiMaterial";
  42937. import { AbstractActionManager } from "babylonjs/Actions/abstractActionManager";
  42938. import { Camera } from "babylonjs/Cameras/camera";
  42939. import { Light } from "babylonjs/Lights/light";
  42940. import { Node } from "babylonjs/node";
  42941. import { Animation } from "babylonjs/Animations/animation";
  42942. /**
  42943. * Defines how the parser contract is defined.
  42944. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  42945. */
  42946. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  42947. /**
  42948. * Defines how the individual parser contract is defined.
  42949. * These parser can parse an individual asset
  42950. */
  42951. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  42952. /**
  42953. * Base class of the scene acting as a container for the different elements composing a scene.
  42954. * This class is dynamically extended by the different components of the scene increasing
  42955. * flexibility and reducing coupling
  42956. */
  42957. export abstract class AbstractScene {
  42958. /**
  42959. * Stores the list of available parsers in the application.
  42960. */
  42961. private static _BabylonFileParsers;
  42962. /**
  42963. * Stores the list of available individual parsers in the application.
  42964. */
  42965. private static _IndividualBabylonFileParsers;
  42966. /**
  42967. * Adds a parser in the list of available ones
  42968. * @param name Defines the name of the parser
  42969. * @param parser Defines the parser to add
  42970. */
  42971. static AddParser(name: string, parser: BabylonFileParser): void;
  42972. /**
  42973. * Gets a general parser from the list of avaialble ones
  42974. * @param name Defines the name of the parser
  42975. * @returns the requested parser or null
  42976. */
  42977. static GetParser(name: string): Nullable<BabylonFileParser>;
  42978. /**
  42979. * Adds n individual parser in the list of available ones
  42980. * @param name Defines the name of the parser
  42981. * @param parser Defines the parser to add
  42982. */
  42983. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  42984. /**
  42985. * Gets an individual parser from the list of avaialble ones
  42986. * @param name Defines the name of the parser
  42987. * @returns the requested parser or null
  42988. */
  42989. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  42990. /**
  42991. * Parser json data and populate both a scene and its associated container object
  42992. * @param jsonData Defines the data to parse
  42993. * @param scene Defines the scene to parse the data for
  42994. * @param container Defines the container attached to the parsing sequence
  42995. * @param rootUrl Defines the root url of the data
  42996. */
  42997. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  42998. /**
  42999. * Gets the list of root nodes (ie. nodes with no parent)
  43000. */
  43001. rootNodes: Node[];
  43002. /** All of the cameras added to this scene
  43003. * @see https://doc.babylonjs.com/babylon101/cameras
  43004. */
  43005. cameras: Camera[];
  43006. /**
  43007. * All of the lights added to this scene
  43008. * @see https://doc.babylonjs.com/babylon101/lights
  43009. */
  43010. lights: Light[];
  43011. /**
  43012. * All of the (abstract) meshes added to this scene
  43013. */
  43014. meshes: AbstractMesh[];
  43015. /**
  43016. * The list of skeletons added to the scene
  43017. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  43018. */
  43019. skeletons: Skeleton[];
  43020. /**
  43021. * All of the particle systems added to this scene
  43022. * @see https://doc.babylonjs.com/babylon101/particles
  43023. */
  43024. particleSystems: IParticleSystem[];
  43025. /**
  43026. * Gets a list of Animations associated with the scene
  43027. */
  43028. animations: Animation[];
  43029. /**
  43030. * All of the animation groups added to this scene
  43031. * @see https://doc.babylonjs.com/how_to/group
  43032. */
  43033. animationGroups: AnimationGroup[];
  43034. /**
  43035. * All of the multi-materials added to this scene
  43036. * @see https://doc.babylonjs.com/how_to/multi_materials
  43037. */
  43038. multiMaterials: MultiMaterial[];
  43039. /**
  43040. * All of the materials added to this scene
  43041. * In the context of a Scene, it is not supposed to be modified manually.
  43042. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  43043. * Note also that the order of the Material within the array is not significant and might change.
  43044. * @see https://doc.babylonjs.com/babylon101/materials
  43045. */
  43046. materials: Material[];
  43047. /**
  43048. * The list of morph target managers added to the scene
  43049. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  43050. */
  43051. morphTargetManagers: MorphTargetManager[];
  43052. /**
  43053. * The list of geometries used in the scene.
  43054. */
  43055. geometries: Geometry[];
  43056. /**
  43057. * All of the tranform nodes added to this scene
  43058. * In the context of a Scene, it is not supposed to be modified manually.
  43059. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  43060. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  43061. * @see https://doc.babylonjs.com/how_to/transformnode
  43062. */
  43063. transformNodes: TransformNode[];
  43064. /**
  43065. * ActionManagers available on the scene.
  43066. */
  43067. actionManagers: AbstractActionManager[];
  43068. /**
  43069. * Textures to keep.
  43070. */
  43071. textures: BaseTexture[];
  43072. /** @hidden */
  43073. protected _environmentTexture: Nullable<BaseTexture>;
  43074. /**
  43075. * Texture used in all pbr material as the reflection texture.
  43076. * As in the majority of the scene they are the same (exception for multi room and so on),
  43077. * this is easier to reference from here than from all the materials.
  43078. */
  43079. get environmentTexture(): Nullable<BaseTexture>;
  43080. set environmentTexture(value: Nullable<BaseTexture>);
  43081. /**
  43082. * The list of postprocesses added to the scene
  43083. */
  43084. postProcesses: import("babylonjs/PostProcesses/postProcess").PostProcess[];
  43085. /**
  43086. * @returns all meshes, lights, cameras, transformNodes and bones
  43087. */
  43088. getNodes(): Array<Node>;
  43089. }
  43090. }
  43091. declare module "babylonjs/Audio/sound" {
  43092. import { Observable } from "babylonjs/Misc/observable";
  43093. import { Vector3 } from "babylonjs/Maths/math.vector";
  43094. import { Nullable } from "babylonjs/types";
  43095. import { Scene } from "babylonjs/scene";
  43096. import { TransformNode } from "babylonjs/Meshes/transformNode";
  43097. /**
  43098. * Interface used to define options for Sound class
  43099. */
  43100. export interface ISoundOptions {
  43101. /**
  43102. * Does the sound autoplay once loaded.
  43103. */
  43104. autoplay?: boolean;
  43105. /**
  43106. * Does the sound loop after it finishes playing once.
  43107. */
  43108. loop?: boolean;
  43109. /**
  43110. * Sound's volume
  43111. */
  43112. volume?: number;
  43113. /**
  43114. * Is it a spatial sound?
  43115. */
  43116. spatialSound?: boolean;
  43117. /**
  43118. * Maximum distance to hear that sound
  43119. */
  43120. maxDistance?: number;
  43121. /**
  43122. * Uses user defined attenuation function
  43123. */
  43124. useCustomAttenuation?: boolean;
  43125. /**
  43126. * Define the roll off factor of spatial sounds.
  43127. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43128. */
  43129. rolloffFactor?: number;
  43130. /**
  43131. * Define the reference distance the sound should be heard perfectly.
  43132. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43133. */
  43134. refDistance?: number;
  43135. /**
  43136. * Define the distance attenuation model the sound will follow.
  43137. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43138. */
  43139. distanceModel?: string;
  43140. /**
  43141. * Defines the playback speed (1 by default)
  43142. */
  43143. playbackRate?: number;
  43144. /**
  43145. * Defines if the sound is from a streaming source
  43146. */
  43147. streaming?: boolean;
  43148. /**
  43149. * Defines an optional length (in seconds) inside the sound file
  43150. */
  43151. length?: number;
  43152. /**
  43153. * Defines an optional offset (in seconds) inside the sound file
  43154. */
  43155. offset?: number;
  43156. /**
  43157. * If true, URLs will not be required to state the audio file codec to use.
  43158. */
  43159. skipCodecCheck?: boolean;
  43160. }
  43161. /**
  43162. * Defines a sound that can be played in the application.
  43163. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  43164. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43165. */
  43166. export class Sound {
  43167. /**
  43168. * The name of the sound in the scene.
  43169. */
  43170. name: string;
  43171. /**
  43172. * Does the sound autoplay once loaded.
  43173. */
  43174. autoplay: boolean;
  43175. /**
  43176. * Does the sound loop after it finishes playing once.
  43177. */
  43178. loop: boolean;
  43179. /**
  43180. * Does the sound use a custom attenuation curve to simulate the falloff
  43181. * happening when the source gets further away from the camera.
  43182. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43183. */
  43184. useCustomAttenuation: boolean;
  43185. /**
  43186. * The sound track id this sound belongs to.
  43187. */
  43188. soundTrackId: number;
  43189. /**
  43190. * Is this sound currently played.
  43191. */
  43192. isPlaying: boolean;
  43193. /**
  43194. * Is this sound currently paused.
  43195. */
  43196. isPaused: boolean;
  43197. /**
  43198. * Does this sound enables spatial sound.
  43199. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43200. */
  43201. spatialSound: boolean;
  43202. /**
  43203. * Define the reference distance the sound should be heard perfectly.
  43204. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43205. */
  43206. refDistance: number;
  43207. /**
  43208. * Define the roll off factor of spatial sounds.
  43209. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43210. */
  43211. rolloffFactor: number;
  43212. /**
  43213. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  43214. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43215. */
  43216. maxDistance: number;
  43217. /**
  43218. * Define the distance attenuation model the sound will follow.
  43219. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43220. */
  43221. distanceModel: string;
  43222. /**
  43223. * @hidden
  43224. * Back Compat
  43225. **/
  43226. onended: () => any;
  43227. /**
  43228. * Gets or sets an object used to store user defined information for the sound.
  43229. */
  43230. metadata: any;
  43231. /**
  43232. * Observable event when the current playing sound finishes.
  43233. */
  43234. onEndedObservable: Observable<Sound>;
  43235. private _panningModel;
  43236. private _playbackRate;
  43237. private _streaming;
  43238. private _startTime;
  43239. private _startOffset;
  43240. private _position;
  43241. /** @hidden */
  43242. _positionInEmitterSpace: boolean;
  43243. private _localDirection;
  43244. private _volume;
  43245. private _isReadyToPlay;
  43246. private _isDirectional;
  43247. private _readyToPlayCallback;
  43248. private _audioBuffer;
  43249. private _soundSource;
  43250. private _streamingSource;
  43251. private _soundPanner;
  43252. private _soundGain;
  43253. private _inputAudioNode;
  43254. private _outputAudioNode;
  43255. private _coneInnerAngle;
  43256. private _coneOuterAngle;
  43257. private _coneOuterGain;
  43258. private _scene;
  43259. private _connectedTransformNode;
  43260. private _customAttenuationFunction;
  43261. private _registerFunc;
  43262. private _isOutputConnected;
  43263. private _htmlAudioElement;
  43264. private _urlType;
  43265. private _length?;
  43266. private _offset?;
  43267. /** @hidden */
  43268. static _SceneComponentInitialization: (scene: Scene) => void;
  43269. /**
  43270. * Create a sound and attach it to a scene
  43271. * @param name Name of your sound
  43272. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  43273. * @param scene defines the scene the sound belongs to
  43274. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  43275. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  43276. */
  43277. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  43278. /**
  43279. * Release the sound and its associated resources
  43280. */
  43281. dispose(): void;
  43282. /**
  43283. * Gets if the sounds is ready to be played or not.
  43284. * @returns true if ready, otherwise false
  43285. */
  43286. isReady(): boolean;
  43287. private _soundLoaded;
  43288. /**
  43289. * Sets the data of the sound from an audiobuffer
  43290. * @param audioBuffer The audioBuffer containing the data
  43291. */
  43292. setAudioBuffer(audioBuffer: AudioBuffer): void;
  43293. /**
  43294. * Updates the current sounds options such as maxdistance, loop...
  43295. * @param options A JSON object containing values named as the object properties
  43296. */
  43297. updateOptions(options: ISoundOptions): void;
  43298. private _createSpatialParameters;
  43299. private _updateSpatialParameters;
  43300. /**
  43301. * Switch the panning model to HRTF:
  43302. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43303. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43304. */
  43305. switchPanningModelToHRTF(): void;
  43306. /**
  43307. * Switch the panning model to Equal Power:
  43308. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43309. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43310. */
  43311. switchPanningModelToEqualPower(): void;
  43312. private _switchPanningModel;
  43313. /**
  43314. * Connect this sound to a sound track audio node like gain...
  43315. * @param soundTrackAudioNode the sound track audio node to connect to
  43316. */
  43317. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  43318. /**
  43319. * Transform this sound into a directional source
  43320. * @param coneInnerAngle Size of the inner cone in degree
  43321. * @param coneOuterAngle Size of the outer cone in degree
  43322. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  43323. */
  43324. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  43325. /**
  43326. * Gets or sets the inner angle for the directional cone.
  43327. */
  43328. get directionalConeInnerAngle(): number;
  43329. /**
  43330. * Gets or sets the inner angle for the directional cone.
  43331. */
  43332. set directionalConeInnerAngle(value: number);
  43333. /**
  43334. * Gets or sets the outer angle for the directional cone.
  43335. */
  43336. get directionalConeOuterAngle(): number;
  43337. /**
  43338. * Gets or sets the outer angle for the directional cone.
  43339. */
  43340. set directionalConeOuterAngle(value: number);
  43341. /**
  43342. * Sets the position of the emitter if spatial sound is enabled
  43343. * @param newPosition Defines the new posisiton
  43344. */
  43345. setPosition(newPosition: Vector3): void;
  43346. /**
  43347. * Sets the local direction of the emitter if spatial sound is enabled
  43348. * @param newLocalDirection Defines the new local direction
  43349. */
  43350. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  43351. private _updateDirection;
  43352. /** @hidden */
  43353. updateDistanceFromListener(): void;
  43354. /**
  43355. * Sets a new custom attenuation function for the sound.
  43356. * @param callback Defines the function used for the attenuation
  43357. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  43358. */
  43359. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  43360. /**
  43361. * Play the sound
  43362. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  43363. * @param offset (optional) Start the sound at a specific time in seconds
  43364. * @param length (optional) Sound duration (in seconds)
  43365. */
  43366. play(time?: number, offset?: number, length?: number): void;
  43367. private _onended;
  43368. /**
  43369. * Stop the sound
  43370. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  43371. */
  43372. stop(time?: number): void;
  43373. /**
  43374. * Put the sound in pause
  43375. */
  43376. pause(): void;
  43377. /**
  43378. * Sets a dedicated volume for this sounds
  43379. * @param newVolume Define the new volume of the sound
  43380. * @param time Define time for gradual change to new volume
  43381. */
  43382. setVolume(newVolume: number, time?: number): void;
  43383. /**
  43384. * Set the sound play back rate
  43385. * @param newPlaybackRate Define the playback rate the sound should be played at
  43386. */
  43387. setPlaybackRate(newPlaybackRate: number): void;
  43388. /**
  43389. * Gets the volume of the sound.
  43390. * @returns the volume of the sound
  43391. */
  43392. getVolume(): number;
  43393. /**
  43394. * Attach the sound to a dedicated mesh
  43395. * @param transformNode The transform node to connect the sound with
  43396. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43397. */
  43398. attachToMesh(transformNode: TransformNode): void;
  43399. /**
  43400. * Detach the sound from the previously attached mesh
  43401. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  43402. */
  43403. detachFromMesh(): void;
  43404. private _onRegisterAfterWorldMatrixUpdate;
  43405. /**
  43406. * Clone the current sound in the scene.
  43407. * @returns the new sound clone
  43408. */
  43409. clone(): Nullable<Sound>;
  43410. /**
  43411. * Gets the current underlying audio buffer containing the data
  43412. * @returns the audio buffer
  43413. */
  43414. getAudioBuffer(): Nullable<AudioBuffer>;
  43415. /**
  43416. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  43417. * @returns the source node
  43418. */
  43419. getSoundSource(): Nullable<AudioBufferSourceNode>;
  43420. /**
  43421. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  43422. * @returns the gain node
  43423. */
  43424. getSoundGain(): Nullable<GainNode>;
  43425. /**
  43426. * Serializes the Sound in a JSON representation
  43427. * @returns the JSON representation of the sound
  43428. */
  43429. serialize(): any;
  43430. /**
  43431. * Parse a JSON representation of a sound to innstantiate in a given scene
  43432. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  43433. * @param scene Define the scene the new parsed sound should be created in
  43434. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  43435. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  43436. * @returns the newly parsed sound
  43437. */
  43438. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  43439. }
  43440. }
  43441. declare module "babylonjs/Actions/directAudioActions" {
  43442. import { Action } from "babylonjs/Actions/action";
  43443. import { Condition } from "babylonjs/Actions/condition";
  43444. import { Sound } from "babylonjs/Audio/sound";
  43445. /**
  43446. * This defines an action helpful to play a defined sound on a triggered action.
  43447. */
  43448. export class PlaySoundAction extends Action {
  43449. private _sound;
  43450. /**
  43451. * Instantiate the action
  43452. * @param triggerOptions defines the trigger options
  43453. * @param sound defines the sound to play
  43454. * @param condition defines the trigger related conditions
  43455. */
  43456. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43457. /** @hidden */
  43458. _prepare(): void;
  43459. /**
  43460. * Execute the action and play the sound.
  43461. */
  43462. execute(): void;
  43463. /**
  43464. * Serializes the actions and its related information.
  43465. * @param parent defines the object to serialize in
  43466. * @returns the serialized object
  43467. */
  43468. serialize(parent: any): any;
  43469. }
  43470. /**
  43471. * This defines an action helpful to stop a defined sound on a triggered action.
  43472. */
  43473. export class StopSoundAction extends Action {
  43474. private _sound;
  43475. /**
  43476. * Instantiate the action
  43477. * @param triggerOptions defines the trigger options
  43478. * @param sound defines the sound to stop
  43479. * @param condition defines the trigger related conditions
  43480. */
  43481. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  43482. /** @hidden */
  43483. _prepare(): void;
  43484. /**
  43485. * Execute the action and stop the sound.
  43486. */
  43487. execute(): void;
  43488. /**
  43489. * Serializes the actions and its related information.
  43490. * @param parent defines the object to serialize in
  43491. * @returns the serialized object
  43492. */
  43493. serialize(parent: any): any;
  43494. }
  43495. }
  43496. declare module "babylonjs/Actions/interpolateValueAction" {
  43497. import { Action } from "babylonjs/Actions/action";
  43498. import { Condition } from "babylonjs/Actions/condition";
  43499. import { Observable } from "babylonjs/Misc/observable";
  43500. /**
  43501. * This defines an action responsible to change the value of a property
  43502. * by interpolating between its current value and the newly set one once triggered.
  43503. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  43504. */
  43505. export class InterpolateValueAction extends Action {
  43506. /**
  43507. * Defines the path of the property where the value should be interpolated
  43508. */
  43509. propertyPath: string;
  43510. /**
  43511. * Defines the target value at the end of the interpolation.
  43512. */
  43513. value: any;
  43514. /**
  43515. * Defines the time it will take for the property to interpolate to the value.
  43516. */
  43517. duration: number;
  43518. /**
  43519. * Defines if the other scene animations should be stopped when the action has been triggered
  43520. */
  43521. stopOtherAnimations?: boolean;
  43522. /**
  43523. * Defines a callback raised once the interpolation animation has been done.
  43524. */
  43525. onInterpolationDone?: () => void;
  43526. /**
  43527. * Observable triggered once the interpolation animation has been done.
  43528. */
  43529. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  43530. private _target;
  43531. private _effectiveTarget;
  43532. private _property;
  43533. /**
  43534. * Instantiate the action
  43535. * @param triggerOptions defines the trigger options
  43536. * @param target defines the object containing the value to interpolate
  43537. * @param propertyPath defines the path to the property in the target object
  43538. * @param value defines the target value at the end of the interpolation
  43539. * @param duration deines the time it will take for the property to interpolate to the value.
  43540. * @param condition defines the trigger related conditions
  43541. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  43542. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  43543. */
  43544. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  43545. /** @hidden */
  43546. _prepare(): void;
  43547. /**
  43548. * Execute the action starts the value interpolation.
  43549. */
  43550. execute(): void;
  43551. /**
  43552. * Serializes the actions and its related information.
  43553. * @param parent defines the object to serialize in
  43554. * @returns the serialized object
  43555. */
  43556. serialize(parent: any): any;
  43557. }
  43558. }
  43559. declare module "babylonjs/Actions/index" {
  43560. export * from "babylonjs/Actions/abstractActionManager";
  43561. export * from "babylonjs/Actions/action";
  43562. export * from "babylonjs/Actions/actionEvent";
  43563. export * from "babylonjs/Actions/actionManager";
  43564. export * from "babylonjs/Actions/condition";
  43565. export * from "babylonjs/Actions/directActions";
  43566. export * from "babylonjs/Actions/directAudioActions";
  43567. export * from "babylonjs/Actions/interpolateValueAction";
  43568. }
  43569. declare module "babylonjs/Animations/index" {
  43570. export * from "babylonjs/Animations/animatable";
  43571. export * from "babylonjs/Animations/animation";
  43572. export * from "babylonjs/Animations/animationGroup";
  43573. export * from "babylonjs/Animations/animationPropertiesOverride";
  43574. export * from "babylonjs/Animations/easing";
  43575. export * from "babylonjs/Animations/runtimeAnimation";
  43576. export * from "babylonjs/Animations/animationEvent";
  43577. export * from "babylonjs/Animations/animationGroup";
  43578. export * from "babylonjs/Animations/animationKey";
  43579. export * from "babylonjs/Animations/animationRange";
  43580. export * from "babylonjs/Animations/animatable.interface";
  43581. }
  43582. declare module "babylonjs/Audio/soundTrack" {
  43583. import { Sound } from "babylonjs/Audio/sound";
  43584. import { Analyser } from "babylonjs/Audio/analyser";
  43585. import { Scene } from "babylonjs/scene";
  43586. /**
  43587. * Options allowed during the creation of a sound track.
  43588. */
  43589. export interface ISoundTrackOptions {
  43590. /**
  43591. * The volume the sound track should take during creation
  43592. */
  43593. volume?: number;
  43594. /**
  43595. * Define if the sound track is the main sound track of the scene
  43596. */
  43597. mainTrack?: boolean;
  43598. }
  43599. /**
  43600. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  43601. * It will be also used in a future release to apply effects on a specific track.
  43602. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43603. */
  43604. export class SoundTrack {
  43605. /**
  43606. * The unique identifier of the sound track in the scene.
  43607. */
  43608. id: number;
  43609. /**
  43610. * The list of sounds included in the sound track.
  43611. */
  43612. soundCollection: Array<Sound>;
  43613. private _outputAudioNode;
  43614. private _scene;
  43615. private _connectedAnalyser;
  43616. private _options;
  43617. private _isInitialized;
  43618. /**
  43619. * Creates a new sound track.
  43620. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  43621. * @param scene Define the scene the sound track belongs to
  43622. * @param options
  43623. */
  43624. constructor(scene: Scene, options?: ISoundTrackOptions);
  43625. private _initializeSoundTrackAudioGraph;
  43626. /**
  43627. * Release the sound track and its associated resources
  43628. */
  43629. dispose(): void;
  43630. /**
  43631. * Adds a sound to this sound track
  43632. * @param sound define the cound to add
  43633. * @ignoreNaming
  43634. */
  43635. AddSound(sound: Sound): void;
  43636. /**
  43637. * Removes a sound to this sound track
  43638. * @param sound define the cound to remove
  43639. * @ignoreNaming
  43640. */
  43641. RemoveSound(sound: Sound): void;
  43642. /**
  43643. * Set a global volume for the full sound track.
  43644. * @param newVolume Define the new volume of the sound track
  43645. */
  43646. setVolume(newVolume: number): void;
  43647. /**
  43648. * Switch the panning model to HRTF:
  43649. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  43650. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43651. */
  43652. switchPanningModelToHRTF(): void;
  43653. /**
  43654. * Switch the panning model to Equal Power:
  43655. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  43656. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  43657. */
  43658. switchPanningModelToEqualPower(): void;
  43659. /**
  43660. * Connect the sound track to an audio analyser allowing some amazing
  43661. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  43662. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  43663. * @param analyser The analyser to connect to the engine
  43664. */
  43665. connectToAnalyser(analyser: Analyser): void;
  43666. }
  43667. }
  43668. declare module "babylonjs/Audio/audioSceneComponent" {
  43669. import { Sound } from "babylonjs/Audio/sound";
  43670. import { SoundTrack } from "babylonjs/Audio/soundTrack";
  43671. import { Nullable } from "babylonjs/types";
  43672. import { Vector3 } from "babylonjs/Maths/math.vector";
  43673. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  43674. import { Scene } from "babylonjs/scene";
  43675. import { AbstractScene } from "babylonjs/abstractScene";
  43676. import "babylonjs/Audio/audioEngine";
  43677. module "babylonjs/abstractScene" {
  43678. interface AbstractScene {
  43679. /**
  43680. * The list of sounds used in the scene.
  43681. */
  43682. sounds: Nullable<Array<Sound>>;
  43683. }
  43684. }
  43685. module "babylonjs/scene" {
  43686. interface Scene {
  43687. /**
  43688. * @hidden
  43689. * Backing field
  43690. */
  43691. _mainSoundTrack: SoundTrack;
  43692. /**
  43693. * The main sound track played by the scene.
  43694. * It cotains your primary collection of sounds.
  43695. */
  43696. mainSoundTrack: SoundTrack;
  43697. /**
  43698. * The list of sound tracks added to the scene
  43699. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43700. */
  43701. soundTracks: Nullable<Array<SoundTrack>>;
  43702. /**
  43703. * Gets a sound using a given name
  43704. * @param name defines the name to search for
  43705. * @return the found sound or null if not found at all.
  43706. */
  43707. getSoundByName(name: string): Nullable<Sound>;
  43708. /**
  43709. * Gets or sets if audio support is enabled
  43710. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43711. */
  43712. audioEnabled: boolean;
  43713. /**
  43714. * Gets or sets if audio will be output to headphones
  43715. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43716. */
  43717. headphone: boolean;
  43718. /**
  43719. * Gets or sets custom audio listener position provider
  43720. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  43721. */
  43722. audioListenerPositionProvider: Nullable<() => Vector3>;
  43723. /**
  43724. * Gets or sets a refresh rate when using 3D audio positioning
  43725. */
  43726. audioPositioningRefreshRate: number;
  43727. }
  43728. }
  43729. /**
  43730. * Defines the sound scene component responsible to manage any sounds
  43731. * in a given scene.
  43732. */
  43733. export class AudioSceneComponent implements ISceneSerializableComponent {
  43734. private static _CameraDirectionLH;
  43735. private static _CameraDirectionRH;
  43736. /**
  43737. * The component name helpfull to identify the component in the list of scene components.
  43738. */
  43739. readonly name: string;
  43740. /**
  43741. * The scene the component belongs to.
  43742. */
  43743. scene: Scene;
  43744. private _audioEnabled;
  43745. /**
  43746. * Gets whether audio is enabled or not.
  43747. * Please use related enable/disable method to switch state.
  43748. */
  43749. get audioEnabled(): boolean;
  43750. private _headphone;
  43751. /**
  43752. * Gets whether audio is outputing to headphone or not.
  43753. * Please use the according Switch methods to change output.
  43754. */
  43755. get headphone(): boolean;
  43756. /**
  43757. * Gets or sets a refresh rate when using 3D audio positioning
  43758. */
  43759. audioPositioningRefreshRate: number;
  43760. private _audioListenerPositionProvider;
  43761. /**
  43762. * Gets the current audio listener position provider
  43763. */
  43764. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  43765. /**
  43766. * Sets a custom listener position for all sounds in the scene
  43767. * By default, this is the position of the first active camera
  43768. */
  43769. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  43770. /**
  43771. * Creates a new instance of the component for the given scene
  43772. * @param scene Defines the scene to register the component in
  43773. */
  43774. constructor(scene: Scene);
  43775. /**
  43776. * Registers the component in a given scene
  43777. */
  43778. register(): void;
  43779. /**
  43780. * Rebuilds the elements related to this component in case of
  43781. * context lost for instance.
  43782. */
  43783. rebuild(): void;
  43784. /**
  43785. * Serializes the component data to the specified json object
  43786. * @param serializationObject The object to serialize to
  43787. */
  43788. serialize(serializationObject: any): void;
  43789. /**
  43790. * Adds all the elements from the container to the scene
  43791. * @param container the container holding the elements
  43792. */
  43793. addFromContainer(container: AbstractScene): void;
  43794. /**
  43795. * Removes all the elements in the container from the scene
  43796. * @param container contains the elements to remove
  43797. * @param dispose if the removed element should be disposed (default: false)
  43798. */
  43799. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  43800. /**
  43801. * Disposes the component and the associated ressources.
  43802. */
  43803. dispose(): void;
  43804. /**
  43805. * Disables audio in the associated scene.
  43806. */
  43807. disableAudio(): void;
  43808. /**
  43809. * Enables audio in the associated scene.
  43810. */
  43811. enableAudio(): void;
  43812. /**
  43813. * Switch audio to headphone output.
  43814. */
  43815. switchAudioModeForHeadphones(): void;
  43816. /**
  43817. * Switch audio to normal speakers.
  43818. */
  43819. switchAudioModeForNormalSpeakers(): void;
  43820. private _cachedCameraDirection;
  43821. private _cachedCameraPosition;
  43822. private _lastCheck;
  43823. private _afterRender;
  43824. }
  43825. }
  43826. declare module "babylonjs/Audio/weightedsound" {
  43827. import { Sound } from "babylonjs/Audio/sound";
  43828. /**
  43829. * Wraps one or more Sound objects and selects one with random weight for playback.
  43830. */
  43831. export class WeightedSound {
  43832. /** When true a Sound will be selected and played when the current playing Sound completes. */
  43833. loop: boolean;
  43834. private _coneInnerAngle;
  43835. private _coneOuterAngle;
  43836. private _volume;
  43837. /** A Sound is currently playing. */
  43838. isPlaying: boolean;
  43839. /** A Sound is currently paused. */
  43840. isPaused: boolean;
  43841. private _sounds;
  43842. private _weights;
  43843. private _currentIndex?;
  43844. /**
  43845. * Creates a new WeightedSound from the list of sounds given.
  43846. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  43847. * @param sounds Array of Sounds that will be selected from.
  43848. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  43849. */
  43850. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  43851. /**
  43852. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  43853. */
  43854. get directionalConeInnerAngle(): number;
  43855. /**
  43856. * The size of cone in degress for a directional sound in which there will be no attenuation.
  43857. */
  43858. set directionalConeInnerAngle(value: number);
  43859. /**
  43860. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43861. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43862. */
  43863. get directionalConeOuterAngle(): number;
  43864. /**
  43865. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  43866. * Listener angles between innerAngle and outerAngle will falloff linearly.
  43867. */
  43868. set directionalConeOuterAngle(value: number);
  43869. /**
  43870. * Playback volume.
  43871. */
  43872. get volume(): number;
  43873. /**
  43874. * Playback volume.
  43875. */
  43876. set volume(value: number);
  43877. private _onended;
  43878. /**
  43879. * Suspend playback
  43880. */
  43881. pause(): void;
  43882. /**
  43883. * Stop playback
  43884. */
  43885. stop(): void;
  43886. /**
  43887. * Start playback.
  43888. * @param startOffset Position the clip head at a specific time in seconds.
  43889. */
  43890. play(startOffset?: number): void;
  43891. }
  43892. }
  43893. declare module "babylonjs/Audio/index" {
  43894. export * from "babylonjs/Audio/analyser";
  43895. export * from "babylonjs/Audio/audioEngine";
  43896. export * from "babylonjs/Audio/audioSceneComponent";
  43897. export * from "babylonjs/Audio/sound";
  43898. export * from "babylonjs/Audio/soundTrack";
  43899. export * from "babylonjs/Audio/weightedsound";
  43900. }
  43901. declare module "babylonjs/Behaviors/Cameras/bouncingBehavior" {
  43902. import { Behavior } from "babylonjs/Behaviors/behavior";
  43903. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43904. import { BackEase } from "babylonjs/Animations/easing";
  43905. /**
  43906. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  43907. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  43908. */
  43909. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  43910. /**
  43911. * Gets the name of the behavior.
  43912. */
  43913. get name(): string;
  43914. /**
  43915. * The easing function used by animations
  43916. */
  43917. static EasingFunction: BackEase;
  43918. /**
  43919. * The easing mode used by animations
  43920. */
  43921. static EasingMode: number;
  43922. /**
  43923. * The duration of the animation, in milliseconds
  43924. */
  43925. transitionDuration: number;
  43926. /**
  43927. * Length of the distance animated by the transition when lower radius is reached
  43928. */
  43929. lowerRadiusTransitionRange: number;
  43930. /**
  43931. * Length of the distance animated by the transition when upper radius is reached
  43932. */
  43933. upperRadiusTransitionRange: number;
  43934. private _autoTransitionRange;
  43935. /**
  43936. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43937. */
  43938. get autoTransitionRange(): boolean;
  43939. /**
  43940. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  43941. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  43942. */
  43943. set autoTransitionRange(value: boolean);
  43944. private _attachedCamera;
  43945. private _onAfterCheckInputsObserver;
  43946. private _onMeshTargetChangedObserver;
  43947. /**
  43948. * Initializes the behavior.
  43949. */
  43950. init(): void;
  43951. /**
  43952. * Attaches the behavior to its arc rotate camera.
  43953. * @param camera Defines the camera to attach the behavior to
  43954. */
  43955. attach(camera: ArcRotateCamera): void;
  43956. /**
  43957. * Detaches the behavior from its current arc rotate camera.
  43958. */
  43959. detach(): void;
  43960. private _radiusIsAnimating;
  43961. private _radiusBounceTransition;
  43962. private _animatables;
  43963. private _cachedWheelPrecision;
  43964. /**
  43965. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  43966. * @param radiusLimit The limit to check against.
  43967. * @return Bool to indicate if at limit.
  43968. */
  43969. private _isRadiusAtLimit;
  43970. /**
  43971. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  43972. * @param radiusDelta The delta by which to animate to. Can be negative.
  43973. */
  43974. private _applyBoundRadiusAnimation;
  43975. /**
  43976. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  43977. */
  43978. protected _clearAnimationLocks(): void;
  43979. /**
  43980. * Stops and removes all animations that have been applied to the camera
  43981. */
  43982. stopAllAnimations(): void;
  43983. }
  43984. }
  43985. declare module "babylonjs/Behaviors/Cameras/framingBehavior" {
  43986. import { Behavior } from "babylonjs/Behaviors/behavior";
  43987. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  43988. import { ExponentialEase } from "babylonjs/Animations/easing";
  43989. import { Nullable } from "babylonjs/types";
  43990. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  43991. import { Vector3 } from "babylonjs/Maths/math.vector";
  43992. /**
  43993. * 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.
  43994. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  43995. */
  43996. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  43997. /**
  43998. * Gets the name of the behavior.
  43999. */
  44000. get name(): string;
  44001. private _mode;
  44002. private _radiusScale;
  44003. private _positionScale;
  44004. private _defaultElevation;
  44005. private _elevationReturnTime;
  44006. private _elevationReturnWaitTime;
  44007. private _zoomStopsAnimation;
  44008. private _framingTime;
  44009. /**
  44010. * The easing function used by animations
  44011. */
  44012. static EasingFunction: ExponentialEase;
  44013. /**
  44014. * The easing mode used by animations
  44015. */
  44016. static EasingMode: number;
  44017. /**
  44018. * Sets the current mode used by the behavior
  44019. */
  44020. set mode(mode: number);
  44021. /**
  44022. * Gets current mode used by the behavior.
  44023. */
  44024. get mode(): number;
  44025. /**
  44026. * Sets the scale applied to the radius (1 by default)
  44027. */
  44028. set radiusScale(radius: number);
  44029. /**
  44030. * Gets the scale applied to the radius
  44031. */
  44032. get radiusScale(): number;
  44033. /**
  44034. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  44035. */
  44036. set positionScale(scale: number);
  44037. /**
  44038. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  44039. */
  44040. get positionScale(): number;
  44041. /**
  44042. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  44043. * behaviour is triggered, in radians.
  44044. */
  44045. set defaultElevation(elevation: number);
  44046. /**
  44047. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  44048. * behaviour is triggered, in radians.
  44049. */
  44050. get defaultElevation(): number;
  44051. /**
  44052. * Sets the time (in milliseconds) taken to return to the default beta position.
  44053. * Negative value indicates camera should not return to default.
  44054. */
  44055. set elevationReturnTime(speed: number);
  44056. /**
  44057. * Gets the time (in milliseconds) taken to return to the default beta position.
  44058. * Negative value indicates camera should not return to default.
  44059. */
  44060. get elevationReturnTime(): number;
  44061. /**
  44062. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44063. */
  44064. set elevationReturnWaitTime(time: number);
  44065. /**
  44066. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  44067. */
  44068. get elevationReturnWaitTime(): number;
  44069. /**
  44070. * Sets the flag that indicates if user zooming should stop animation.
  44071. */
  44072. set zoomStopsAnimation(flag: boolean);
  44073. /**
  44074. * Gets the flag that indicates if user zooming should stop animation.
  44075. */
  44076. get zoomStopsAnimation(): boolean;
  44077. /**
  44078. * Sets the transition time when framing the mesh, in milliseconds
  44079. */
  44080. set framingTime(time: number);
  44081. /**
  44082. * Gets the transition time when framing the mesh, in milliseconds
  44083. */
  44084. get framingTime(): number;
  44085. /**
  44086. * Define if the behavior should automatically change the configured
  44087. * camera limits and sensibilities.
  44088. */
  44089. autoCorrectCameraLimitsAndSensibility: boolean;
  44090. private _onPrePointerObservableObserver;
  44091. private _onAfterCheckInputsObserver;
  44092. private _onMeshTargetChangedObserver;
  44093. private _attachedCamera;
  44094. private _isPointerDown;
  44095. private _lastInteractionTime;
  44096. /**
  44097. * Initializes the behavior.
  44098. */
  44099. init(): void;
  44100. /**
  44101. * Attaches the behavior to its arc rotate camera.
  44102. * @param camera Defines the camera to attach the behavior to
  44103. */
  44104. attach(camera: ArcRotateCamera): void;
  44105. /**
  44106. * Detaches the behavior from its current arc rotate camera.
  44107. */
  44108. detach(): void;
  44109. private _animatables;
  44110. private _betaIsAnimating;
  44111. private _betaTransition;
  44112. private _radiusTransition;
  44113. private _vectorTransition;
  44114. /**
  44115. * Targets the given mesh and updates zoom level accordingly.
  44116. * @param mesh The mesh to target.
  44117. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44118. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44119. */
  44120. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44121. /**
  44122. * Targets the given mesh with its children and updates zoom level accordingly.
  44123. * @param mesh The mesh to target.
  44124. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44125. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44126. */
  44127. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44128. /**
  44129. * Targets the given meshes with their children and updates zoom level accordingly.
  44130. * @param meshes The mesh to target.
  44131. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44132. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44133. */
  44134. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44135. /**
  44136. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  44137. * @param minimumWorld Determines the smaller position of the bounding box extend
  44138. * @param maximumWorld Determines the bigger position of the bounding box extend
  44139. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  44140. * @param onAnimationEnd Callback triggered at the end of the framing animation
  44141. */
  44142. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  44143. /**
  44144. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  44145. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  44146. * frustum width.
  44147. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  44148. * to fully enclose the mesh in the viewing frustum.
  44149. */
  44150. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  44151. /**
  44152. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  44153. * is automatically returned to its default position (expected to be above ground plane).
  44154. */
  44155. private _maintainCameraAboveGround;
  44156. /**
  44157. * Returns the frustum slope based on the canvas ratio and camera FOV
  44158. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  44159. */
  44160. private _getFrustumSlope;
  44161. /**
  44162. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  44163. */
  44164. private _clearAnimationLocks;
  44165. /**
  44166. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  44167. */
  44168. private _applyUserInteraction;
  44169. /**
  44170. * Stops and removes all animations that have been applied to the camera
  44171. */
  44172. stopAllAnimations(): void;
  44173. /**
  44174. * Gets a value indicating if the user is moving the camera
  44175. */
  44176. get isUserIsMoving(): boolean;
  44177. /**
  44178. * The camera can move all the way towards the mesh.
  44179. */
  44180. static IgnoreBoundsSizeMode: number;
  44181. /**
  44182. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  44183. */
  44184. static FitFrustumSidesMode: number;
  44185. }
  44186. }
  44187. declare module "babylonjs/Cameras/Inputs/BaseCameraPointersInput" {
  44188. import { Nullable } from "babylonjs/types";
  44189. import { Camera } from "babylonjs/Cameras/camera";
  44190. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44191. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44192. /**
  44193. * Base class for Camera Pointer Inputs.
  44194. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  44195. * for example usage.
  44196. */
  44197. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  44198. /**
  44199. * Defines the camera the input is attached to.
  44200. */
  44201. abstract camera: Camera;
  44202. /**
  44203. * Whether keyboard modifier keys are pressed at time of last mouse event.
  44204. */
  44205. protected _altKey: boolean;
  44206. protected _ctrlKey: boolean;
  44207. protected _metaKey: boolean;
  44208. protected _shiftKey: boolean;
  44209. /**
  44210. * Which mouse buttons were pressed at time of last mouse event.
  44211. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  44212. */
  44213. protected _buttonsPressed: number;
  44214. /**
  44215. * Defines the buttons associated with the input to handle camera move.
  44216. */
  44217. buttons: number[];
  44218. /**
  44219. * Attach the input controls to a specific dom element to get the input from.
  44220. * @param element Defines the element the controls should be listened from
  44221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44222. */
  44223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44224. /**
  44225. * Detach the current controls from the specified dom element.
  44226. * @param element Defines the element to stop listening the inputs from
  44227. */
  44228. detachControl(element: Nullable<HTMLElement>): void;
  44229. /**
  44230. * Gets the class name of the current input.
  44231. * @returns the class name
  44232. */
  44233. getClassName(): string;
  44234. /**
  44235. * Get the friendly name associated with the input class.
  44236. * @returns the input friendly name
  44237. */
  44238. getSimpleName(): string;
  44239. /**
  44240. * Called on pointer POINTERDOUBLETAP event.
  44241. * Override this method to provide functionality on POINTERDOUBLETAP event.
  44242. */
  44243. protected onDoubleTap(type: string): void;
  44244. /**
  44245. * Called on pointer POINTERMOVE event if only a single touch is active.
  44246. * Override this method to provide functionality.
  44247. */
  44248. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44249. /**
  44250. * Called on pointer POINTERMOVE event if multiple touches are active.
  44251. * Override this method to provide functionality.
  44252. */
  44253. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44254. /**
  44255. * Called on JS contextmenu event.
  44256. * Override this method to provide functionality.
  44257. */
  44258. protected onContextMenu(evt: PointerEvent): void;
  44259. /**
  44260. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44261. * press.
  44262. * Override this method to provide functionality.
  44263. */
  44264. protected onButtonDown(evt: PointerEvent): void;
  44265. /**
  44266. * Called each time a new POINTERUP event occurs. Ie, for each button
  44267. * release.
  44268. * Override this method to provide functionality.
  44269. */
  44270. protected onButtonUp(evt: PointerEvent): void;
  44271. /**
  44272. * Called when window becomes inactive.
  44273. * Override this method to provide functionality.
  44274. */
  44275. protected onLostFocus(): void;
  44276. private _pointerInput;
  44277. private _observer;
  44278. private _onLostFocus;
  44279. private pointA;
  44280. private pointB;
  44281. }
  44282. }
  44283. declare module "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput" {
  44284. import { Nullable } from "babylonjs/types";
  44285. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44286. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  44287. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  44288. /**
  44289. * Manage the pointers inputs to control an arc rotate camera.
  44290. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44291. */
  44292. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  44293. /**
  44294. * Defines the camera the input is attached to.
  44295. */
  44296. camera: ArcRotateCamera;
  44297. /**
  44298. * Gets the class name of the current input.
  44299. * @returns the class name
  44300. */
  44301. getClassName(): string;
  44302. /**
  44303. * Defines the buttons associated with the input to handle camera move.
  44304. */
  44305. buttons: number[];
  44306. /**
  44307. * Defines the pointer angular sensibility along the X axis or how fast is
  44308. * the camera rotating.
  44309. */
  44310. angularSensibilityX: number;
  44311. /**
  44312. * Defines the pointer angular sensibility along the Y axis or how fast is
  44313. * the camera rotating.
  44314. */
  44315. angularSensibilityY: number;
  44316. /**
  44317. * Defines the pointer pinch precision or how fast is the camera zooming.
  44318. */
  44319. pinchPrecision: number;
  44320. /**
  44321. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  44322. * from 0.
  44323. * It defines the percentage of current camera.radius to use as delta when
  44324. * pinch zoom is used.
  44325. */
  44326. pinchDeltaPercentage: number;
  44327. /**
  44328. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44329. * that any object in the plane at the camera's target point will scale
  44330. * perfectly with finger motion.
  44331. * Overrides pinchDeltaPercentage and pinchPrecision.
  44332. */
  44333. useNaturalPinchZoom: boolean;
  44334. /**
  44335. * Defines the pointer panning sensibility or how fast is the camera moving.
  44336. */
  44337. panningSensibility: number;
  44338. /**
  44339. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  44340. */
  44341. multiTouchPanning: boolean;
  44342. /**
  44343. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  44344. * zoom (pinch) through multitouch.
  44345. */
  44346. multiTouchPanAndZoom: boolean;
  44347. /**
  44348. * Revers pinch action direction.
  44349. */
  44350. pinchInwards: boolean;
  44351. private _isPanClick;
  44352. private _twoFingerActivityCount;
  44353. private _isPinching;
  44354. /**
  44355. * Called on pointer POINTERMOVE event if only a single touch is active.
  44356. */
  44357. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  44358. /**
  44359. * Called on pointer POINTERDOUBLETAP event.
  44360. */
  44361. protected onDoubleTap(type: string): void;
  44362. /**
  44363. * Called on pointer POINTERMOVE event if multiple touches are active.
  44364. */
  44365. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  44366. /**
  44367. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  44368. * press.
  44369. */
  44370. protected onButtonDown(evt: PointerEvent): void;
  44371. /**
  44372. * Called each time a new POINTERUP event occurs. Ie, for each button
  44373. * release.
  44374. */
  44375. protected onButtonUp(evt: PointerEvent): void;
  44376. /**
  44377. * Called when window becomes inactive.
  44378. */
  44379. protected onLostFocus(): void;
  44380. }
  44381. }
  44382. declare module "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput" {
  44383. import { Nullable } from "babylonjs/types";
  44384. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44385. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44386. /**
  44387. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  44388. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44389. */
  44390. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  44391. /**
  44392. * Defines the camera the input is attached to.
  44393. */
  44394. camera: ArcRotateCamera;
  44395. /**
  44396. * Defines the list of key codes associated with the up action (increase alpha)
  44397. */
  44398. keysUp: number[];
  44399. /**
  44400. * Defines the list of key codes associated with the down action (decrease alpha)
  44401. */
  44402. keysDown: number[];
  44403. /**
  44404. * Defines the list of key codes associated with the left action (increase beta)
  44405. */
  44406. keysLeft: number[];
  44407. /**
  44408. * Defines the list of key codes associated with the right action (decrease beta)
  44409. */
  44410. keysRight: number[];
  44411. /**
  44412. * Defines the list of key codes associated with the reset action.
  44413. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  44414. */
  44415. keysReset: number[];
  44416. /**
  44417. * Defines the panning sensibility of the inputs.
  44418. * (How fast is the camera panning)
  44419. */
  44420. panningSensibility: number;
  44421. /**
  44422. * Defines the zooming sensibility of the inputs.
  44423. * (How fast is the camera zooming)
  44424. */
  44425. zoomingSensibility: number;
  44426. /**
  44427. * Defines whether maintaining the alt key down switch the movement mode from
  44428. * orientation to zoom.
  44429. */
  44430. useAltToZoom: boolean;
  44431. /**
  44432. * Rotation speed of the camera
  44433. */
  44434. angularSpeed: number;
  44435. private _keys;
  44436. private _ctrlPressed;
  44437. private _altPressed;
  44438. private _onCanvasBlurObserver;
  44439. private _onKeyboardObserver;
  44440. private _engine;
  44441. private _scene;
  44442. /**
  44443. * Attach the input controls to a specific dom element to get the input from.
  44444. * @param element Defines the element the controls should be listened from
  44445. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44446. */
  44447. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44448. /**
  44449. * Detach the current controls from the specified dom element.
  44450. * @param element Defines the element to stop listening the inputs from
  44451. */
  44452. detachControl(element: Nullable<HTMLElement>): void;
  44453. /**
  44454. * Update the current camera state depending on the inputs that have been used this frame.
  44455. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  44456. */
  44457. checkInputs(): void;
  44458. /**
  44459. * Gets the class name of the current intput.
  44460. * @returns the class name
  44461. */
  44462. getClassName(): string;
  44463. /**
  44464. * Get the friendly name associated with the input class.
  44465. * @returns the input friendly name
  44466. */
  44467. getSimpleName(): string;
  44468. }
  44469. }
  44470. declare module "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput" {
  44471. import { Nullable } from "babylonjs/types";
  44472. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44473. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  44474. /**
  44475. * Manage the mouse wheel inputs to control an arc rotate camera.
  44476. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44477. */
  44478. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  44479. /**
  44480. * Defines the camera the input is attached to.
  44481. */
  44482. camera: ArcRotateCamera;
  44483. /**
  44484. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44485. */
  44486. wheelPrecision: number;
  44487. /**
  44488. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  44489. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  44490. */
  44491. wheelDeltaPercentage: number;
  44492. private _wheel;
  44493. private _observer;
  44494. private computeDeltaFromMouseWheelLegacyEvent;
  44495. /**
  44496. * Attach the input controls to a specific dom element to get the input from.
  44497. * @param element Defines the element the controls should be listened from
  44498. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44499. */
  44500. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  44501. /**
  44502. * Detach the current controls from the specified dom element.
  44503. * @param element Defines the element to stop listening the inputs from
  44504. */
  44505. detachControl(element: Nullable<HTMLElement>): void;
  44506. /**
  44507. * Gets the class name of the current intput.
  44508. * @returns the class name
  44509. */
  44510. getClassName(): string;
  44511. /**
  44512. * Get the friendly name associated with the input class.
  44513. * @returns the input friendly name
  44514. */
  44515. getSimpleName(): string;
  44516. }
  44517. }
  44518. declare module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  44519. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44520. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  44521. /**
  44522. * Default Inputs manager for the ArcRotateCamera.
  44523. * It groups all the default supported inputs for ease of use.
  44524. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  44525. */
  44526. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  44527. /**
  44528. * Instantiates a new ArcRotateCameraInputsManager.
  44529. * @param camera Defines the camera the inputs belong to
  44530. */
  44531. constructor(camera: ArcRotateCamera);
  44532. /**
  44533. * Add mouse wheel input support to the input manager.
  44534. * @returns the current input manager
  44535. */
  44536. addMouseWheel(): ArcRotateCameraInputsManager;
  44537. /**
  44538. * Add pointers input support to the input manager.
  44539. * @returns the current input manager
  44540. */
  44541. addPointers(): ArcRotateCameraInputsManager;
  44542. /**
  44543. * Add keyboard input support to the input manager.
  44544. * @returns the current input manager
  44545. */
  44546. addKeyboard(): ArcRotateCameraInputsManager;
  44547. }
  44548. }
  44549. declare module "babylonjs/Cameras/arcRotateCamera" {
  44550. import { Observable } from "babylonjs/Misc/observable";
  44551. import { Nullable } from "babylonjs/types";
  44552. import { Scene } from "babylonjs/scene";
  44553. import { Matrix, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  44554. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  44555. import { AutoRotationBehavior } from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  44556. import { BouncingBehavior } from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  44557. import { FramingBehavior } from "babylonjs/Behaviors/Cameras/framingBehavior";
  44558. import { Camera } from "babylonjs/Cameras/camera";
  44559. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  44560. import { ArcRotateCameraInputsManager } from "babylonjs/Cameras/arcRotateCameraInputsManager";
  44561. import { Collider } from "babylonjs/Collisions/collider";
  44562. /**
  44563. * This represents an orbital type of camera.
  44564. *
  44565. * 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.
  44566. * 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.
  44567. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  44568. */
  44569. export class ArcRotateCamera extends TargetCamera {
  44570. /**
  44571. * Defines the rotation angle of the camera along the longitudinal axis.
  44572. */
  44573. alpha: number;
  44574. /**
  44575. * Defines the rotation angle of the camera along the latitudinal axis.
  44576. */
  44577. beta: number;
  44578. /**
  44579. * Defines the radius of the camera from it s target point.
  44580. */
  44581. radius: number;
  44582. protected _target: Vector3;
  44583. protected _targetHost: Nullable<AbstractMesh>;
  44584. /**
  44585. * Defines the target point of the camera.
  44586. * The camera looks towards it form the radius distance.
  44587. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  44588. */
  44589. get target(): Vector3;
  44590. set target(value: Vector3);
  44591. /**
  44592. * Define the current local position of the camera in the scene
  44593. */
  44594. get position(): Vector3;
  44595. set position(newPosition: Vector3);
  44596. protected _upToYMatrix: Matrix;
  44597. protected _YToUpMatrix: Matrix;
  44598. /**
  44599. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  44600. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  44601. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  44602. */
  44603. set upVector(vec: Vector3);
  44604. get upVector(): Vector3;
  44605. /**
  44606. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  44607. */
  44608. setMatUp(): void;
  44609. /**
  44610. * Current inertia value on the longitudinal axis.
  44611. * The bigger this number the longer it will take for the camera to stop.
  44612. */
  44613. inertialAlphaOffset: number;
  44614. /**
  44615. * Current inertia value on the latitudinal axis.
  44616. * The bigger this number the longer it will take for the camera to stop.
  44617. */
  44618. inertialBetaOffset: number;
  44619. /**
  44620. * Current inertia value on the radius axis.
  44621. * The bigger this number the longer it will take for the camera to stop.
  44622. */
  44623. inertialRadiusOffset: number;
  44624. /**
  44625. * Minimum allowed angle on the longitudinal axis.
  44626. * This can help limiting how the Camera is able to move in the scene.
  44627. */
  44628. lowerAlphaLimit: Nullable<number>;
  44629. /**
  44630. * Maximum allowed angle on the longitudinal axis.
  44631. * This can help limiting how the Camera is able to move in the scene.
  44632. */
  44633. upperAlphaLimit: Nullable<number>;
  44634. /**
  44635. * Minimum allowed angle on the latitudinal axis.
  44636. * This can help limiting how the Camera is able to move in the scene.
  44637. */
  44638. lowerBetaLimit: number;
  44639. /**
  44640. * Maximum allowed angle on the latitudinal axis.
  44641. * This can help limiting how the Camera is able to move in the scene.
  44642. */
  44643. upperBetaLimit: number;
  44644. /**
  44645. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  44646. * This can help limiting how the Camera is able to move in the scene.
  44647. */
  44648. lowerRadiusLimit: Nullable<number>;
  44649. /**
  44650. * Maximum allowed distance of the camera to the target (The camera can not get further).
  44651. * This can help limiting how the Camera is able to move in the scene.
  44652. */
  44653. upperRadiusLimit: Nullable<number>;
  44654. /**
  44655. * Defines the current inertia value used during panning of the camera along the X axis.
  44656. */
  44657. inertialPanningX: number;
  44658. /**
  44659. * Defines the current inertia value used during panning of the camera along the Y axis.
  44660. */
  44661. inertialPanningY: number;
  44662. /**
  44663. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  44664. * Basically if your fingers moves away from more than this distance you will be considered
  44665. * in pinch mode.
  44666. */
  44667. pinchToPanMaxDistance: number;
  44668. /**
  44669. * Defines the maximum distance the camera can pan.
  44670. * This could help keeping the cammera always in your scene.
  44671. */
  44672. panningDistanceLimit: Nullable<number>;
  44673. /**
  44674. * Defines the target of the camera before paning.
  44675. */
  44676. panningOriginTarget: Vector3;
  44677. /**
  44678. * Defines the value of the inertia used during panning.
  44679. * 0 would mean stop inertia and one would mean no decelleration at all.
  44680. */
  44681. panningInertia: number;
  44682. /**
  44683. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  44684. */
  44685. get angularSensibilityX(): number;
  44686. set angularSensibilityX(value: number);
  44687. /**
  44688. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  44689. */
  44690. get angularSensibilityY(): number;
  44691. set angularSensibilityY(value: number);
  44692. /**
  44693. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  44694. */
  44695. get pinchPrecision(): number;
  44696. set pinchPrecision(value: number);
  44697. /**
  44698. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  44699. * It will be used instead of pinchDeltaPrecision if different from 0.
  44700. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44701. */
  44702. get pinchDeltaPercentage(): number;
  44703. set pinchDeltaPercentage(value: number);
  44704. /**
  44705. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  44706. * and pinch delta percentage.
  44707. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  44708. * that any object in the plane at the camera's target point will scale
  44709. * perfectly with finger motion.
  44710. */
  44711. get useNaturalPinchZoom(): boolean;
  44712. set useNaturalPinchZoom(value: boolean);
  44713. /**
  44714. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  44715. */
  44716. get panningSensibility(): number;
  44717. set panningSensibility(value: number);
  44718. /**
  44719. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  44720. */
  44721. get keysUp(): number[];
  44722. set keysUp(value: number[]);
  44723. /**
  44724. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  44725. */
  44726. get keysDown(): number[];
  44727. set keysDown(value: number[]);
  44728. /**
  44729. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  44730. */
  44731. get keysLeft(): number[];
  44732. set keysLeft(value: number[]);
  44733. /**
  44734. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  44735. */
  44736. get keysRight(): number[];
  44737. set keysRight(value: number[]);
  44738. /**
  44739. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  44740. */
  44741. get wheelPrecision(): number;
  44742. set wheelPrecision(value: number);
  44743. /**
  44744. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  44745. * It will be used instead of pinchDeltaPrecision if different from 0.
  44746. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  44747. */
  44748. get wheelDeltaPercentage(): number;
  44749. set wheelDeltaPercentage(value: number);
  44750. /**
  44751. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  44752. */
  44753. zoomOnFactor: number;
  44754. /**
  44755. * Defines a screen offset for the camera position.
  44756. */
  44757. targetScreenOffset: Vector2;
  44758. /**
  44759. * Allows the camera to be completely reversed.
  44760. * If false the camera can not arrive upside down.
  44761. */
  44762. allowUpsideDown: boolean;
  44763. /**
  44764. * Define if double tap/click is used to restore the previously saved state of the camera.
  44765. */
  44766. useInputToRestoreState: boolean;
  44767. /** @hidden */
  44768. _viewMatrix: Matrix;
  44769. /** @hidden */
  44770. _useCtrlForPanning: boolean;
  44771. /** @hidden */
  44772. _panningMouseButton: number;
  44773. /**
  44774. * Defines the input associated to the camera.
  44775. */
  44776. inputs: ArcRotateCameraInputsManager;
  44777. /** @hidden */
  44778. _reset: () => void;
  44779. /**
  44780. * Defines the allowed panning axis.
  44781. */
  44782. panningAxis: Vector3;
  44783. protected _localDirection: Vector3;
  44784. protected _transformedDirection: Vector3;
  44785. private _bouncingBehavior;
  44786. /**
  44787. * Gets the bouncing behavior of the camera if it has been enabled.
  44788. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44789. */
  44790. get bouncingBehavior(): Nullable<BouncingBehavior>;
  44791. /**
  44792. * Defines if the bouncing behavior of the camera is enabled on the camera.
  44793. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  44794. */
  44795. get useBouncingBehavior(): boolean;
  44796. set useBouncingBehavior(value: boolean);
  44797. private _framingBehavior;
  44798. /**
  44799. * Gets the framing behavior of the camera if it has been enabled.
  44800. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44801. */
  44802. get framingBehavior(): Nullable<FramingBehavior>;
  44803. /**
  44804. * Defines if the framing behavior of the camera is enabled on the camera.
  44805. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  44806. */
  44807. get useFramingBehavior(): boolean;
  44808. set useFramingBehavior(value: boolean);
  44809. private _autoRotationBehavior;
  44810. /**
  44811. * Gets the auto rotation behavior of the camera if it has been enabled.
  44812. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44813. */
  44814. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  44815. /**
  44816. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  44817. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44818. */
  44819. get useAutoRotationBehavior(): boolean;
  44820. set useAutoRotationBehavior(value: boolean);
  44821. /**
  44822. * Observable triggered when the mesh target has been changed on the camera.
  44823. */
  44824. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  44825. /**
  44826. * Event raised when the camera is colliding with a mesh.
  44827. */
  44828. onCollide: (collidedMesh: AbstractMesh) => void;
  44829. /**
  44830. * Defines whether the camera should check collision with the objects oh the scene.
  44831. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  44832. */
  44833. checkCollisions: boolean;
  44834. /**
  44835. * Defines the collision radius of the camera.
  44836. * This simulates a sphere around the camera.
  44837. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  44838. */
  44839. collisionRadius: Vector3;
  44840. protected _collider: Collider;
  44841. protected _previousPosition: Vector3;
  44842. protected _collisionVelocity: Vector3;
  44843. protected _newPosition: Vector3;
  44844. protected _previousAlpha: number;
  44845. protected _previousBeta: number;
  44846. protected _previousRadius: number;
  44847. protected _collisionTriggered: boolean;
  44848. protected _targetBoundingCenter: Nullable<Vector3>;
  44849. private _computationVector;
  44850. /**
  44851. * Instantiates a new ArcRotateCamera in a given scene
  44852. * @param name Defines the name of the camera
  44853. * @param alpha Defines the camera rotation along the logitudinal axis
  44854. * @param beta Defines the camera rotation along the latitudinal axis
  44855. * @param radius Defines the camera distance from its target
  44856. * @param target Defines the camera target
  44857. * @param scene Defines the scene the camera belongs to
  44858. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  44859. */
  44860. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  44861. /** @hidden */
  44862. _initCache(): void;
  44863. /** @hidden */
  44864. _updateCache(ignoreParentClass?: boolean): void;
  44865. protected _getTargetPosition(): Vector3;
  44866. private _storedAlpha;
  44867. private _storedBeta;
  44868. private _storedRadius;
  44869. private _storedTarget;
  44870. private _storedTargetScreenOffset;
  44871. /**
  44872. * Stores the current state of the camera (alpha, beta, radius and target)
  44873. * @returns the camera itself
  44874. */
  44875. storeState(): Camera;
  44876. /**
  44877. * @hidden
  44878. * Restored camera state. You must call storeState() first
  44879. */
  44880. _restoreStateValues(): boolean;
  44881. /** @hidden */
  44882. _isSynchronizedViewMatrix(): boolean;
  44883. /**
  44884. * Attached controls to the current camera.
  44885. * @param element Defines the element the controls should be listened from
  44886. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  44887. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  44888. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  44889. */
  44890. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  44891. /**
  44892. * Detach the current controls from the camera.
  44893. * The camera will stop reacting to inputs.
  44894. * @param element Defines the element to stop listening the inputs from
  44895. */
  44896. detachControl(element: HTMLElement): void;
  44897. /** @hidden */
  44898. _checkInputs(): void;
  44899. protected _checkLimits(): void;
  44900. /**
  44901. * Rebuilds angles (alpha, beta) and radius from the give position and target
  44902. */
  44903. rebuildAnglesAndRadius(): void;
  44904. /**
  44905. * Use a position to define the current camera related information like alpha, beta and radius
  44906. * @param position Defines the position to set the camera at
  44907. */
  44908. setPosition(position: Vector3): void;
  44909. /**
  44910. * Defines the target the camera should look at.
  44911. * This will automatically adapt alpha beta and radius to fit within the new target.
  44912. * @param target Defines the new target as a Vector or a mesh
  44913. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  44914. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  44915. */
  44916. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  44917. /** @hidden */
  44918. _getViewMatrix(): Matrix;
  44919. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  44920. /**
  44921. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  44922. * @param meshes Defines the mesh to zoom on
  44923. * @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)
  44924. */
  44925. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  44926. /**
  44927. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  44928. * The target will be changed but the radius
  44929. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  44930. * @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)
  44931. */
  44932. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  44933. min: Vector3;
  44934. max: Vector3;
  44935. distance: number;
  44936. }, doNotUpdateMaxZ?: boolean): void;
  44937. /**
  44938. * @override
  44939. * Override Camera.createRigCamera
  44940. */
  44941. createRigCamera(name: string, cameraIndex: number): Camera;
  44942. /**
  44943. * @hidden
  44944. * @override
  44945. * Override Camera._updateRigCameras
  44946. */
  44947. _updateRigCameras(): void;
  44948. /**
  44949. * Destroy the camera and release the current resources hold by it.
  44950. */
  44951. dispose(): void;
  44952. /**
  44953. * Gets the current object class name.
  44954. * @return the class name
  44955. */
  44956. getClassName(): string;
  44957. }
  44958. }
  44959. declare module "babylonjs/Behaviors/Cameras/autoRotationBehavior" {
  44960. import { Behavior } from "babylonjs/Behaviors/behavior";
  44961. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  44962. /**
  44963. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  44964. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  44965. */
  44966. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  44967. /**
  44968. * Gets the name of the behavior.
  44969. */
  44970. get name(): string;
  44971. private _zoomStopsAnimation;
  44972. private _idleRotationSpeed;
  44973. private _idleRotationWaitTime;
  44974. private _idleRotationSpinupTime;
  44975. /**
  44976. * Sets the flag that indicates if user zooming should stop animation.
  44977. */
  44978. set zoomStopsAnimation(flag: boolean);
  44979. /**
  44980. * Gets the flag that indicates if user zooming should stop animation.
  44981. */
  44982. get zoomStopsAnimation(): boolean;
  44983. /**
  44984. * Sets the default speed at which the camera rotates around the model.
  44985. */
  44986. set idleRotationSpeed(speed: number);
  44987. /**
  44988. * Gets the default speed at which the camera rotates around the model.
  44989. */
  44990. get idleRotationSpeed(): number;
  44991. /**
  44992. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  44993. */
  44994. set idleRotationWaitTime(time: number);
  44995. /**
  44996. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  44997. */
  44998. get idleRotationWaitTime(): number;
  44999. /**
  45000. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  45001. */
  45002. set idleRotationSpinupTime(time: number);
  45003. /**
  45004. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  45005. */
  45006. get idleRotationSpinupTime(): number;
  45007. /**
  45008. * Gets a value indicating if the camera is currently rotating because of this behavior
  45009. */
  45010. get rotationInProgress(): boolean;
  45011. private _onPrePointerObservableObserver;
  45012. private _onAfterCheckInputsObserver;
  45013. private _attachedCamera;
  45014. private _isPointerDown;
  45015. private _lastFrameTime;
  45016. private _lastInteractionTime;
  45017. private _cameraRotationSpeed;
  45018. /**
  45019. * Initializes the behavior.
  45020. */
  45021. init(): void;
  45022. /**
  45023. * Attaches the behavior to its arc rotate camera.
  45024. * @param camera Defines the camera to attach the behavior to
  45025. */
  45026. attach(camera: ArcRotateCamera): void;
  45027. /**
  45028. * Detaches the behavior from its current arc rotate camera.
  45029. */
  45030. detach(): void;
  45031. /**
  45032. * Returns true if user is scrolling.
  45033. * @return true if user is scrolling.
  45034. */
  45035. private _userIsZooming;
  45036. private _lastFrameRadius;
  45037. private _shouldAnimationStopForInteraction;
  45038. /**
  45039. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  45040. */
  45041. private _applyUserInteraction;
  45042. private _userIsMoving;
  45043. }
  45044. }
  45045. declare module "babylonjs/Behaviors/Cameras/index" {
  45046. export * from "babylonjs/Behaviors/Cameras/autoRotationBehavior";
  45047. export * from "babylonjs/Behaviors/Cameras/bouncingBehavior";
  45048. export * from "babylonjs/Behaviors/Cameras/framingBehavior";
  45049. }
  45050. declare module "babylonjs/Behaviors/Meshes/attachToBoxBehavior" {
  45051. import { Mesh } from "babylonjs/Meshes/mesh";
  45052. import { TransformNode } from "babylonjs/Meshes/transformNode";
  45053. import { Behavior } from "babylonjs/Behaviors/behavior";
  45054. /**
  45055. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  45056. */
  45057. export class AttachToBoxBehavior implements Behavior<Mesh> {
  45058. private ui;
  45059. /**
  45060. * The name of the behavior
  45061. */
  45062. name: string;
  45063. /**
  45064. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  45065. */
  45066. distanceAwayFromFace: number;
  45067. /**
  45068. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  45069. */
  45070. distanceAwayFromBottomOfFace: number;
  45071. private _faceVectors;
  45072. private _target;
  45073. private _scene;
  45074. private _onRenderObserver;
  45075. private _tmpMatrix;
  45076. private _tmpVector;
  45077. /**
  45078. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  45079. * @param ui The transform node that should be attched to the mesh
  45080. */
  45081. constructor(ui: TransformNode);
  45082. /**
  45083. * Initializes the behavior
  45084. */
  45085. init(): void;
  45086. private _closestFace;
  45087. private _zeroVector;
  45088. private _lookAtTmpMatrix;
  45089. private _lookAtToRef;
  45090. /**
  45091. * Attaches the AttachToBoxBehavior to the passed in mesh
  45092. * @param target The mesh that the specified node will be attached to
  45093. */
  45094. attach(target: Mesh): void;
  45095. /**
  45096. * Detaches the behavior from the mesh
  45097. */
  45098. detach(): void;
  45099. }
  45100. }
  45101. declare module "babylonjs/Behaviors/Meshes/fadeInOutBehavior" {
  45102. import { Behavior } from "babylonjs/Behaviors/behavior";
  45103. import { Mesh } from "babylonjs/Meshes/mesh";
  45104. /**
  45105. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  45106. */
  45107. export class FadeInOutBehavior implements Behavior<Mesh> {
  45108. /**
  45109. * Time in milliseconds to delay before fading in (Default: 0)
  45110. */
  45111. delay: number;
  45112. /**
  45113. * Time in milliseconds for the mesh to fade in (Default: 300)
  45114. */
  45115. fadeInTime: number;
  45116. private _millisecondsPerFrame;
  45117. private _hovered;
  45118. private _hoverValue;
  45119. private _ownerNode;
  45120. /**
  45121. * Instatiates the FadeInOutBehavior
  45122. */
  45123. constructor();
  45124. /**
  45125. * The name of the behavior
  45126. */
  45127. get name(): string;
  45128. /**
  45129. * Initializes the behavior
  45130. */
  45131. init(): void;
  45132. /**
  45133. * Attaches the fade behavior on the passed in mesh
  45134. * @param ownerNode The mesh that will be faded in/out once attached
  45135. */
  45136. attach(ownerNode: Mesh): void;
  45137. /**
  45138. * Detaches the behavior from the mesh
  45139. */
  45140. detach(): void;
  45141. /**
  45142. * Triggers the mesh to begin fading in or out
  45143. * @param value if the object should fade in or out (true to fade in)
  45144. */
  45145. fadeIn(value: boolean): void;
  45146. private _update;
  45147. private _setAllVisibility;
  45148. }
  45149. }
  45150. declare module "babylonjs/Misc/pivotTools" {
  45151. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45152. /**
  45153. * Class containing a set of static utilities functions for managing Pivots
  45154. * @hidden
  45155. */
  45156. export class PivotTools {
  45157. private static _PivotCached;
  45158. private static _OldPivotPoint;
  45159. private static _PivotTranslation;
  45160. private static _PivotTmpVector;
  45161. private static _PivotPostMultiplyPivotMatrix;
  45162. /** @hidden */
  45163. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  45164. /** @hidden */
  45165. static _RestorePivotPoint(mesh: AbstractMesh): void;
  45166. }
  45167. }
  45168. declare module "babylonjs/Meshes/Builders/planeBuilder" {
  45169. import { Scene } from "babylonjs/scene";
  45170. import { Vector4 } from "babylonjs/Maths/math.vector";
  45171. import { Mesh } from "babylonjs/Meshes/mesh";
  45172. import { Nullable } from "babylonjs/types";
  45173. import { Plane } from "babylonjs/Maths/math.plane";
  45174. /**
  45175. * Class containing static functions to help procedurally build meshes
  45176. */
  45177. export class PlaneBuilder {
  45178. /**
  45179. * Creates a plane mesh
  45180. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  45181. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  45182. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  45183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  45184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  45185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  45186. * @param name defines the name of the mesh
  45187. * @param options defines the options used to create the mesh
  45188. * @param scene defines the hosting scene
  45189. * @returns the plane mesh
  45190. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  45191. */
  45192. static CreatePlane(name: string, options: {
  45193. size?: number;
  45194. width?: number;
  45195. height?: number;
  45196. sideOrientation?: number;
  45197. frontUVs?: Vector4;
  45198. backUVs?: Vector4;
  45199. updatable?: boolean;
  45200. sourcePlane?: Plane;
  45201. }, scene?: Nullable<Scene>): Mesh;
  45202. }
  45203. }
  45204. declare module "babylonjs/Behaviors/Meshes/pointerDragBehavior" {
  45205. import { Behavior } from "babylonjs/Behaviors/behavior";
  45206. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45207. import { Observable } from "babylonjs/Misc/observable";
  45208. import { Vector3 } from "babylonjs/Maths/math.vector";
  45209. import { Ray } from "babylonjs/Culling/ray";
  45210. import "babylonjs/Meshes/Builders/planeBuilder";
  45211. /**
  45212. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  45213. */
  45214. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  45215. private static _AnyMouseID;
  45216. /**
  45217. * Abstract mesh the behavior is set on
  45218. */
  45219. attachedNode: AbstractMesh;
  45220. private _dragPlane;
  45221. private _scene;
  45222. private _pointerObserver;
  45223. private _beforeRenderObserver;
  45224. private static _planeScene;
  45225. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  45226. /**
  45227. * 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)
  45228. */
  45229. maxDragAngle: number;
  45230. /**
  45231. * @hidden
  45232. */
  45233. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  45234. /**
  45235. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45236. */
  45237. currentDraggingPointerID: number;
  45238. /**
  45239. * The last position where the pointer hit the drag plane in world space
  45240. */
  45241. lastDragPosition: Vector3;
  45242. /**
  45243. * If the behavior is currently in a dragging state
  45244. */
  45245. dragging: boolean;
  45246. /**
  45247. * 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)
  45248. */
  45249. dragDeltaRatio: number;
  45250. /**
  45251. * If the drag plane orientation should be updated during the dragging (Default: true)
  45252. */
  45253. updateDragPlane: boolean;
  45254. private _debugMode;
  45255. private _moving;
  45256. /**
  45257. * Fires each time the attached mesh is dragged with the pointer
  45258. * * delta between last drag position and current drag position in world space
  45259. * * dragDistance along the drag axis
  45260. * * dragPlaneNormal normal of the current drag plane used during the drag
  45261. * * dragPlanePoint in world space where the drag intersects the drag plane
  45262. */
  45263. onDragObservable: Observable<{
  45264. delta: Vector3;
  45265. dragPlanePoint: Vector3;
  45266. dragPlaneNormal: Vector3;
  45267. dragDistance: number;
  45268. pointerId: number;
  45269. }>;
  45270. /**
  45271. * Fires each time a drag begins (eg. mouse down on mesh)
  45272. */
  45273. onDragStartObservable: Observable<{
  45274. dragPlanePoint: Vector3;
  45275. pointerId: number;
  45276. }>;
  45277. /**
  45278. * Fires each time a drag ends (eg. mouse release after drag)
  45279. */
  45280. onDragEndObservable: Observable<{
  45281. dragPlanePoint: Vector3;
  45282. pointerId: number;
  45283. }>;
  45284. /**
  45285. * If the attached mesh should be moved when dragged
  45286. */
  45287. moveAttached: boolean;
  45288. /**
  45289. * If the drag behavior will react to drag events (Default: true)
  45290. */
  45291. enabled: boolean;
  45292. /**
  45293. * If pointer events should start and release the drag (Default: true)
  45294. */
  45295. startAndReleaseDragOnPointerEvents: boolean;
  45296. /**
  45297. * If camera controls should be detached during the drag
  45298. */
  45299. detachCameraControls: boolean;
  45300. /**
  45301. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  45302. */
  45303. useObjectOrientationForDragging: boolean;
  45304. private _options;
  45305. /**
  45306. * Gets the options used by the behavior
  45307. */
  45308. get options(): {
  45309. dragAxis?: Vector3;
  45310. dragPlaneNormal?: Vector3;
  45311. };
  45312. /**
  45313. * Sets the options used by the behavior
  45314. */
  45315. set options(options: {
  45316. dragAxis?: Vector3;
  45317. dragPlaneNormal?: Vector3;
  45318. });
  45319. /**
  45320. * Creates a pointer drag behavior that can be attached to a mesh
  45321. * @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)
  45322. */
  45323. constructor(options?: {
  45324. dragAxis?: Vector3;
  45325. dragPlaneNormal?: Vector3;
  45326. });
  45327. /**
  45328. * Predicate to determine if it is valid to move the object to a new position when it is moved
  45329. */
  45330. validateDrag: (targetPosition: Vector3) => boolean;
  45331. /**
  45332. * The name of the behavior
  45333. */
  45334. get name(): string;
  45335. /**
  45336. * Initializes the behavior
  45337. */
  45338. init(): void;
  45339. private _tmpVector;
  45340. private _alternatePickedPoint;
  45341. private _worldDragAxis;
  45342. private _targetPosition;
  45343. private _attachedElement;
  45344. /**
  45345. * Attaches the drag behavior the passed in mesh
  45346. * @param ownerNode The mesh that will be dragged around once attached
  45347. * @param predicate Predicate to use for pick filtering
  45348. */
  45349. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  45350. /**
  45351. * Force relase the drag action by code.
  45352. */
  45353. releaseDrag(): void;
  45354. private _startDragRay;
  45355. private _lastPointerRay;
  45356. /**
  45357. * Simulates the start of a pointer drag event on the behavior
  45358. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  45359. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  45360. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  45361. */
  45362. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45363. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  45364. private _dragDelta;
  45365. protected _moveDrag(ray: Ray): void;
  45366. private _pickWithRayOnDragPlane;
  45367. private _pointA;
  45368. private _pointC;
  45369. private _localAxis;
  45370. private _lookAt;
  45371. private _updateDragPlanePosition;
  45372. /**
  45373. * Detaches the behavior from the mesh
  45374. */
  45375. detach(): void;
  45376. }
  45377. }
  45378. declare module "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior" {
  45379. import { Mesh } from "babylonjs/Meshes/mesh";
  45380. import { Behavior } from "babylonjs/Behaviors/behavior";
  45381. /**
  45382. * A behavior that when attached to a mesh will allow the mesh to be scaled
  45383. */
  45384. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  45385. private _dragBehaviorA;
  45386. private _dragBehaviorB;
  45387. private _startDistance;
  45388. private _initialScale;
  45389. private _targetScale;
  45390. private _ownerNode;
  45391. private _sceneRenderObserver;
  45392. /**
  45393. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  45394. */
  45395. constructor();
  45396. /**
  45397. * The name of the behavior
  45398. */
  45399. get name(): string;
  45400. /**
  45401. * Initializes the behavior
  45402. */
  45403. init(): void;
  45404. private _getCurrentDistance;
  45405. /**
  45406. * Attaches the scale behavior the passed in mesh
  45407. * @param ownerNode The mesh that will be scaled around once attached
  45408. */
  45409. attach(ownerNode: Mesh): void;
  45410. /**
  45411. * Detaches the behavior from the mesh
  45412. */
  45413. detach(): void;
  45414. }
  45415. }
  45416. declare module "babylonjs/Behaviors/Meshes/sixDofDragBehavior" {
  45417. import { Behavior } from "babylonjs/Behaviors/behavior";
  45418. import { Mesh } from "babylonjs/Meshes/mesh";
  45419. import { Observable } from "babylonjs/Misc/observable";
  45420. /**
  45421. * 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
  45422. */
  45423. export class SixDofDragBehavior implements Behavior<Mesh> {
  45424. private static _virtualScene;
  45425. private _ownerNode;
  45426. private _sceneRenderObserver;
  45427. private _scene;
  45428. private _targetPosition;
  45429. private _virtualOriginMesh;
  45430. private _virtualDragMesh;
  45431. private _pointerObserver;
  45432. private _moving;
  45433. private _startingOrientation;
  45434. private _attachedElement;
  45435. /**
  45436. * 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)
  45437. */
  45438. private zDragFactor;
  45439. /**
  45440. * If the object should rotate to face the drag origin
  45441. */
  45442. rotateDraggedObject: boolean;
  45443. /**
  45444. * If the behavior is currently in a dragging state
  45445. */
  45446. dragging: boolean;
  45447. /**
  45448. * 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)
  45449. */
  45450. dragDeltaRatio: number;
  45451. /**
  45452. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  45453. */
  45454. currentDraggingPointerID: number;
  45455. /**
  45456. * If camera controls should be detached during the drag
  45457. */
  45458. detachCameraControls: boolean;
  45459. /**
  45460. * Fires each time a drag starts
  45461. */
  45462. onDragStartObservable: Observable<{}>;
  45463. /**
  45464. * Fires each time a drag ends (eg. mouse release after drag)
  45465. */
  45466. onDragEndObservable: Observable<{}>;
  45467. /**
  45468. * 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
  45469. */
  45470. constructor();
  45471. /**
  45472. * The name of the behavior
  45473. */
  45474. get name(): string;
  45475. /**
  45476. * Initializes the behavior
  45477. */
  45478. init(): void;
  45479. /**
  45480. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  45481. */
  45482. private get _pointerCamera();
  45483. /**
  45484. * Attaches the scale behavior the passed in mesh
  45485. * @param ownerNode The mesh that will be scaled around once attached
  45486. */
  45487. attach(ownerNode: Mesh): void;
  45488. /**
  45489. * Detaches the behavior from the mesh
  45490. */
  45491. detach(): void;
  45492. }
  45493. }
  45494. declare module "babylonjs/Behaviors/Meshes/index" {
  45495. export * from "babylonjs/Behaviors/Meshes/attachToBoxBehavior";
  45496. export * from "babylonjs/Behaviors/Meshes/fadeInOutBehavior";
  45497. export * from "babylonjs/Behaviors/Meshes/multiPointerScaleBehavior";
  45498. export * from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  45499. export * from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  45500. }
  45501. declare module "babylonjs/Behaviors/index" {
  45502. export * from "babylonjs/Behaviors/behavior";
  45503. export * from "babylonjs/Behaviors/Cameras/index";
  45504. export * from "babylonjs/Behaviors/Meshes/index";
  45505. }
  45506. declare module "babylonjs/Bones/boneIKController" {
  45507. import { Bone } from "babylonjs/Bones/bone";
  45508. import { Vector3 } from "babylonjs/Maths/math.vector";
  45509. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45510. import { Nullable } from "babylonjs/types";
  45511. /**
  45512. * Class used to apply inverse kinematics to bones
  45513. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  45514. */
  45515. export class BoneIKController {
  45516. private static _tmpVecs;
  45517. private static _tmpQuat;
  45518. private static _tmpMats;
  45519. /**
  45520. * Gets or sets the target mesh
  45521. */
  45522. targetMesh: AbstractMesh;
  45523. /** Gets or sets the mesh used as pole */
  45524. poleTargetMesh: AbstractMesh;
  45525. /**
  45526. * Gets or sets the bone used as pole
  45527. */
  45528. poleTargetBone: Nullable<Bone>;
  45529. /**
  45530. * Gets or sets the target position
  45531. */
  45532. targetPosition: Vector3;
  45533. /**
  45534. * Gets or sets the pole target position
  45535. */
  45536. poleTargetPosition: Vector3;
  45537. /**
  45538. * Gets or sets the pole target local offset
  45539. */
  45540. poleTargetLocalOffset: Vector3;
  45541. /**
  45542. * Gets or sets the pole angle
  45543. */
  45544. poleAngle: number;
  45545. /**
  45546. * Gets or sets the mesh associated with the controller
  45547. */
  45548. mesh: AbstractMesh;
  45549. /**
  45550. * 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)
  45551. */
  45552. slerpAmount: number;
  45553. private _bone1Quat;
  45554. private _bone1Mat;
  45555. private _bone2Ang;
  45556. private _bone1;
  45557. private _bone2;
  45558. private _bone1Length;
  45559. private _bone2Length;
  45560. private _maxAngle;
  45561. private _maxReach;
  45562. private _rightHandedSystem;
  45563. private _bendAxis;
  45564. private _slerping;
  45565. private _adjustRoll;
  45566. /**
  45567. * Gets or sets maximum allowed angle
  45568. */
  45569. get maxAngle(): number;
  45570. set maxAngle(value: number);
  45571. /**
  45572. * Creates a new BoneIKController
  45573. * @param mesh defines the mesh to control
  45574. * @param bone defines the bone to control
  45575. * @param options defines options to set up the controller
  45576. */
  45577. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  45578. targetMesh?: AbstractMesh;
  45579. poleTargetMesh?: AbstractMesh;
  45580. poleTargetBone?: Bone;
  45581. poleTargetLocalOffset?: Vector3;
  45582. poleAngle?: number;
  45583. bendAxis?: Vector3;
  45584. maxAngle?: number;
  45585. slerpAmount?: number;
  45586. });
  45587. private _setMaxAngle;
  45588. /**
  45589. * Force the controller to update the bones
  45590. */
  45591. update(): void;
  45592. }
  45593. }
  45594. declare module "babylonjs/Bones/boneLookController" {
  45595. import { Vector3 } from "babylonjs/Maths/math.vector";
  45596. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45597. import { Bone } from "babylonjs/Bones/bone";
  45598. import { Space } from "babylonjs/Maths/math.axis";
  45599. /**
  45600. * Class used to make a bone look toward a point in space
  45601. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  45602. */
  45603. export class BoneLookController {
  45604. private static _tmpVecs;
  45605. private static _tmpQuat;
  45606. private static _tmpMats;
  45607. /**
  45608. * The target Vector3 that the bone will look at
  45609. */
  45610. target: Vector3;
  45611. /**
  45612. * The mesh that the bone is attached to
  45613. */
  45614. mesh: AbstractMesh;
  45615. /**
  45616. * The bone that will be looking to the target
  45617. */
  45618. bone: Bone;
  45619. /**
  45620. * The up axis of the coordinate system that is used when the bone is rotated
  45621. */
  45622. upAxis: Vector3;
  45623. /**
  45624. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  45625. */
  45626. upAxisSpace: Space;
  45627. /**
  45628. * Used to make an adjustment to the yaw of the bone
  45629. */
  45630. adjustYaw: number;
  45631. /**
  45632. * Used to make an adjustment to the pitch of the bone
  45633. */
  45634. adjustPitch: number;
  45635. /**
  45636. * Used to make an adjustment to the roll of the bone
  45637. */
  45638. adjustRoll: number;
  45639. /**
  45640. * 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)
  45641. */
  45642. slerpAmount: number;
  45643. private _minYaw;
  45644. private _maxYaw;
  45645. private _minPitch;
  45646. private _maxPitch;
  45647. private _minYawSin;
  45648. private _minYawCos;
  45649. private _maxYawSin;
  45650. private _maxYawCos;
  45651. private _midYawConstraint;
  45652. private _minPitchTan;
  45653. private _maxPitchTan;
  45654. private _boneQuat;
  45655. private _slerping;
  45656. private _transformYawPitch;
  45657. private _transformYawPitchInv;
  45658. private _firstFrameSkipped;
  45659. private _yawRange;
  45660. private _fowardAxis;
  45661. /**
  45662. * Gets or sets the minimum yaw angle that the bone can look to
  45663. */
  45664. get minYaw(): number;
  45665. set minYaw(value: number);
  45666. /**
  45667. * Gets or sets the maximum yaw angle that the bone can look to
  45668. */
  45669. get maxYaw(): number;
  45670. set maxYaw(value: number);
  45671. /**
  45672. * Gets or sets the minimum pitch angle that the bone can look to
  45673. */
  45674. get minPitch(): number;
  45675. set minPitch(value: number);
  45676. /**
  45677. * Gets or sets the maximum pitch angle that the bone can look to
  45678. */
  45679. get maxPitch(): number;
  45680. set maxPitch(value: number);
  45681. /**
  45682. * Create a BoneLookController
  45683. * @param mesh the mesh that the bone belongs to
  45684. * @param bone the bone that will be looking to the target
  45685. * @param target the target Vector3 to look at
  45686. * @param options optional settings:
  45687. * * maxYaw: the maximum angle the bone will yaw to
  45688. * * minYaw: the minimum angle the bone will yaw to
  45689. * * maxPitch: the maximum angle the bone will pitch to
  45690. * * minPitch: the minimum angle the bone will yaw to
  45691. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  45692. * * upAxis: the up axis of the coordinate system
  45693. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  45694. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  45695. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  45696. * * adjustYaw: used to make an adjustment to the yaw of the bone
  45697. * * adjustPitch: used to make an adjustment to the pitch of the bone
  45698. * * adjustRoll: used to make an adjustment to the roll of the bone
  45699. **/
  45700. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  45701. maxYaw?: number;
  45702. minYaw?: number;
  45703. maxPitch?: number;
  45704. minPitch?: number;
  45705. slerpAmount?: number;
  45706. upAxis?: Vector3;
  45707. upAxisSpace?: Space;
  45708. yawAxis?: Vector3;
  45709. pitchAxis?: Vector3;
  45710. adjustYaw?: number;
  45711. adjustPitch?: number;
  45712. adjustRoll?: number;
  45713. });
  45714. /**
  45715. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  45716. */
  45717. update(): void;
  45718. private _getAngleDiff;
  45719. private _getAngleBetween;
  45720. private _isAngleBetween;
  45721. }
  45722. }
  45723. declare module "babylonjs/Bones/index" {
  45724. export * from "babylonjs/Bones/bone";
  45725. export * from "babylonjs/Bones/boneIKController";
  45726. export * from "babylonjs/Bones/boneLookController";
  45727. export * from "babylonjs/Bones/skeleton";
  45728. }
  45729. declare module "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput" {
  45730. import { Nullable } from "babylonjs/types";
  45731. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45732. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45733. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  45734. /**
  45735. * Manage the gamepad inputs to control an arc rotate camera.
  45736. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45737. */
  45738. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  45739. /**
  45740. * Defines the camera the input is attached to.
  45741. */
  45742. camera: ArcRotateCamera;
  45743. /**
  45744. * Defines the gamepad the input is gathering event from.
  45745. */
  45746. gamepad: Nullable<Gamepad>;
  45747. /**
  45748. * Defines the gamepad rotation sensiblity.
  45749. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  45750. */
  45751. gamepadRotationSensibility: number;
  45752. /**
  45753. * Defines the gamepad move sensiblity.
  45754. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  45755. */
  45756. gamepadMoveSensibility: number;
  45757. private _yAxisScale;
  45758. /**
  45759. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  45760. */
  45761. get invertYAxis(): boolean;
  45762. set invertYAxis(value: boolean);
  45763. private _onGamepadConnectedObserver;
  45764. private _onGamepadDisconnectedObserver;
  45765. /**
  45766. * Attach the input controls to a specific dom element to get the input from.
  45767. * @param element Defines the element the controls should be listened from
  45768. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45769. */
  45770. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45771. /**
  45772. * Detach the current controls from the specified dom element.
  45773. * @param element Defines the element to stop listening the inputs from
  45774. */
  45775. detachControl(element: Nullable<HTMLElement>): void;
  45776. /**
  45777. * Update the current camera state depending on the inputs that have been used this frame.
  45778. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45779. */
  45780. checkInputs(): void;
  45781. /**
  45782. * Gets the class name of the current intput.
  45783. * @returns the class name
  45784. */
  45785. getClassName(): string;
  45786. /**
  45787. * Get the friendly name associated with the input class.
  45788. * @returns the input friendly name
  45789. */
  45790. getSimpleName(): string;
  45791. }
  45792. }
  45793. declare module "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput" {
  45794. import { Nullable } from "babylonjs/types";
  45795. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  45796. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45797. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  45798. interface ArcRotateCameraInputsManager {
  45799. /**
  45800. * Add orientation input support to the input manager.
  45801. * @returns the current input manager
  45802. */
  45803. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  45804. }
  45805. }
  45806. /**
  45807. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  45808. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45809. */
  45810. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  45811. /**
  45812. * Defines the camera the input is attached to.
  45813. */
  45814. camera: ArcRotateCamera;
  45815. /**
  45816. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  45817. */
  45818. alphaCorrection: number;
  45819. /**
  45820. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  45821. */
  45822. gammaCorrection: number;
  45823. private _alpha;
  45824. private _gamma;
  45825. private _dirty;
  45826. private _deviceOrientationHandler;
  45827. /**
  45828. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  45829. */
  45830. constructor();
  45831. /**
  45832. * Attach the input controls to a specific dom element to get the input from.
  45833. * @param element Defines the element the controls should be listened from
  45834. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  45835. */
  45836. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45837. /** @hidden */
  45838. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  45839. /**
  45840. * Update the current camera state depending on the inputs that have been used this frame.
  45841. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  45842. */
  45843. checkInputs(): void;
  45844. /**
  45845. * Detach the current controls from the specified dom element.
  45846. * @param element Defines the element to stop listening the inputs from
  45847. */
  45848. detachControl(element: Nullable<HTMLElement>): void;
  45849. /**
  45850. * Gets the class name of the current intput.
  45851. * @returns the class name
  45852. */
  45853. getClassName(): string;
  45854. /**
  45855. * Get the friendly name associated with the input class.
  45856. * @returns the input friendly name
  45857. */
  45858. getSimpleName(): string;
  45859. }
  45860. }
  45861. declare module "babylonjs/Cameras/Inputs/flyCameraMouseInput" {
  45862. import { Nullable } from "babylonjs/types";
  45863. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  45864. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45865. /**
  45866. * Listen to mouse events to control the camera.
  45867. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45868. */
  45869. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  45870. /**
  45871. * Defines the camera the input is attached to.
  45872. */
  45873. camera: FlyCamera;
  45874. /**
  45875. * Defines if touch is enabled. (Default is true.)
  45876. */
  45877. touchEnabled: boolean;
  45878. /**
  45879. * Defines the buttons associated with the input to handle camera rotation.
  45880. */
  45881. buttons: number[];
  45882. /**
  45883. * Assign buttons for Yaw control.
  45884. */
  45885. buttonsYaw: number[];
  45886. /**
  45887. * Assign buttons for Pitch control.
  45888. */
  45889. buttonsPitch: number[];
  45890. /**
  45891. * Assign buttons for Roll control.
  45892. */
  45893. buttonsRoll: number[];
  45894. /**
  45895. * Detect if any button is being pressed while mouse is moved.
  45896. * -1 = Mouse locked.
  45897. * 0 = Left button.
  45898. * 1 = Middle Button.
  45899. * 2 = Right Button.
  45900. */
  45901. activeButton: number;
  45902. /**
  45903. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  45904. * Higher values reduce its sensitivity.
  45905. */
  45906. angularSensibility: number;
  45907. private _observer;
  45908. private _rollObserver;
  45909. private previousPosition;
  45910. private noPreventDefault;
  45911. private element;
  45912. /**
  45913. * Listen to mouse events to control the camera.
  45914. * @param touchEnabled Define if touch is enabled. (Default is true.)
  45915. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45916. */
  45917. constructor(touchEnabled?: boolean);
  45918. /**
  45919. * Attach the mouse control to the HTML DOM element.
  45920. * @param element Defines the element that listens to the input events.
  45921. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  45922. */
  45923. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  45924. /**
  45925. * Detach the current controls from the specified dom element.
  45926. * @param element Defines the element to stop listening the inputs from
  45927. */
  45928. detachControl(element: Nullable<HTMLElement>): void;
  45929. /**
  45930. * Gets the class name of the current input.
  45931. * @returns the class name.
  45932. */
  45933. getClassName(): string;
  45934. /**
  45935. * Get the friendly name associated with the input class.
  45936. * @returns the input's friendly name.
  45937. */
  45938. getSimpleName(): string;
  45939. private _pointerInput;
  45940. private _onMouseMove;
  45941. /**
  45942. * Rotate camera by mouse offset.
  45943. */
  45944. private rotateCamera;
  45945. }
  45946. }
  45947. declare module "babylonjs/Cameras/flyCameraInputsManager" {
  45948. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  45949. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  45950. /**
  45951. * Default Inputs manager for the FlyCamera.
  45952. * It groups all the default supported inputs for ease of use.
  45953. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  45954. */
  45955. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  45956. /**
  45957. * Instantiates a new FlyCameraInputsManager.
  45958. * @param camera Defines the camera the inputs belong to.
  45959. */
  45960. constructor(camera: FlyCamera);
  45961. /**
  45962. * Add keyboard input support to the input manager.
  45963. * @returns the new FlyCameraKeyboardMoveInput().
  45964. */
  45965. addKeyboard(): FlyCameraInputsManager;
  45966. /**
  45967. * Add mouse input support to the input manager.
  45968. * @param touchEnabled Enable touch screen support.
  45969. * @returns the new FlyCameraMouseInput().
  45970. */
  45971. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  45972. }
  45973. }
  45974. declare module "babylonjs/Cameras/flyCamera" {
  45975. import { Scene } from "babylonjs/scene";
  45976. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  45977. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  45978. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  45979. import { FlyCameraInputsManager } from "babylonjs/Cameras/flyCameraInputsManager";
  45980. /**
  45981. * This is a flying camera, designed for 3D movement and rotation in all directions,
  45982. * such as in a 3D Space Shooter or a Flight Simulator.
  45983. */
  45984. export class FlyCamera extends TargetCamera {
  45985. /**
  45986. * Define the collision ellipsoid of the camera.
  45987. * This is helpful for simulating a camera body, like a player's body.
  45988. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  45989. */
  45990. ellipsoid: Vector3;
  45991. /**
  45992. * Define an offset for the position of the ellipsoid around the camera.
  45993. * This can be helpful if the camera is attached away from the player's body center,
  45994. * such as at its head.
  45995. */
  45996. ellipsoidOffset: Vector3;
  45997. /**
  45998. * Enable or disable collisions of the camera with the rest of the scene objects.
  45999. */
  46000. checkCollisions: boolean;
  46001. /**
  46002. * Enable or disable gravity on the camera.
  46003. */
  46004. applyGravity: boolean;
  46005. /**
  46006. * Define the current direction the camera is moving to.
  46007. */
  46008. cameraDirection: Vector3;
  46009. /**
  46010. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  46011. * This overrides and empties cameraRotation.
  46012. */
  46013. rotationQuaternion: Quaternion;
  46014. /**
  46015. * Track Roll to maintain the wanted Rolling when looking around.
  46016. */
  46017. _trackRoll: number;
  46018. /**
  46019. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  46020. */
  46021. rollCorrect: number;
  46022. /**
  46023. * Mimic a banked turn, Rolling the camera when Yawing.
  46024. * It's recommended to use rollCorrect = 10 for faster banking correction.
  46025. */
  46026. bankedTurn: boolean;
  46027. /**
  46028. * Limit in radians for how much Roll banking will add. (Default: 90°)
  46029. */
  46030. bankedTurnLimit: number;
  46031. /**
  46032. * Value of 0 disables the banked Roll.
  46033. * Value of 1 is equal to the Yaw angle in radians.
  46034. */
  46035. bankedTurnMultiplier: number;
  46036. /**
  46037. * The inputs manager loads all the input sources, such as keyboard and mouse.
  46038. */
  46039. inputs: FlyCameraInputsManager;
  46040. /**
  46041. * Gets the input sensibility for mouse input.
  46042. * Higher values reduce sensitivity.
  46043. */
  46044. get angularSensibility(): number;
  46045. /**
  46046. * Sets the input sensibility for a mouse input.
  46047. * Higher values reduce sensitivity.
  46048. */
  46049. set angularSensibility(value: number);
  46050. /**
  46051. * Get the keys for camera movement forward.
  46052. */
  46053. get keysForward(): number[];
  46054. /**
  46055. * Set the keys for camera movement forward.
  46056. */
  46057. set keysForward(value: number[]);
  46058. /**
  46059. * Get the keys for camera movement backward.
  46060. */
  46061. get keysBackward(): number[];
  46062. set keysBackward(value: number[]);
  46063. /**
  46064. * Get the keys for camera movement up.
  46065. */
  46066. get keysUp(): number[];
  46067. /**
  46068. * Set the keys for camera movement up.
  46069. */
  46070. set keysUp(value: number[]);
  46071. /**
  46072. * Get the keys for camera movement down.
  46073. */
  46074. get keysDown(): number[];
  46075. /**
  46076. * Set the keys for camera movement down.
  46077. */
  46078. set keysDown(value: number[]);
  46079. /**
  46080. * Get the keys for camera movement left.
  46081. */
  46082. get keysLeft(): number[];
  46083. /**
  46084. * Set the keys for camera movement left.
  46085. */
  46086. set keysLeft(value: number[]);
  46087. /**
  46088. * Set the keys for camera movement right.
  46089. */
  46090. get keysRight(): number[];
  46091. /**
  46092. * Set the keys for camera movement right.
  46093. */
  46094. set keysRight(value: number[]);
  46095. /**
  46096. * Event raised when the camera collides with a mesh in the scene.
  46097. */
  46098. onCollide: (collidedMesh: AbstractMesh) => void;
  46099. private _collider;
  46100. private _needMoveForGravity;
  46101. private _oldPosition;
  46102. private _diffPosition;
  46103. private _newPosition;
  46104. /** @hidden */
  46105. _localDirection: Vector3;
  46106. /** @hidden */
  46107. _transformedDirection: Vector3;
  46108. /**
  46109. * Instantiates a FlyCamera.
  46110. * This is a flying camera, designed for 3D movement and rotation in all directions,
  46111. * such as in a 3D Space Shooter or a Flight Simulator.
  46112. * @param name Define the name of the camera in the scene.
  46113. * @param position Define the starting position of the camera in the scene.
  46114. * @param scene Define the scene the camera belongs to.
  46115. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  46116. */
  46117. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  46118. /**
  46119. * Attach a control to the HTML DOM element.
  46120. * @param element Defines the element that listens to the input events.
  46121. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  46122. */
  46123. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46124. /**
  46125. * Detach a control from the HTML DOM element.
  46126. * The camera will stop reacting to that input.
  46127. * @param element Defines the element that listens to the input events.
  46128. */
  46129. detachControl(element: HTMLElement): void;
  46130. private _collisionMask;
  46131. /**
  46132. * Get the mask that the camera ignores in collision events.
  46133. */
  46134. get collisionMask(): number;
  46135. /**
  46136. * Set the mask that the camera ignores in collision events.
  46137. */
  46138. set collisionMask(mask: number);
  46139. /** @hidden */
  46140. _collideWithWorld(displacement: Vector3): void;
  46141. /** @hidden */
  46142. private _onCollisionPositionChange;
  46143. /** @hidden */
  46144. _checkInputs(): void;
  46145. /** @hidden */
  46146. _decideIfNeedsToMove(): boolean;
  46147. /** @hidden */
  46148. _updatePosition(): void;
  46149. /**
  46150. * Restore the Roll to its target value at the rate specified.
  46151. * @param rate - Higher means slower restoring.
  46152. * @hidden
  46153. */
  46154. restoreRoll(rate: number): void;
  46155. /**
  46156. * Destroy the camera and release the current resources held by it.
  46157. */
  46158. dispose(): void;
  46159. /**
  46160. * Get the current object class name.
  46161. * @returns the class name.
  46162. */
  46163. getClassName(): string;
  46164. }
  46165. }
  46166. declare module "babylonjs/Cameras/Inputs/flyCameraKeyboardInput" {
  46167. import { Nullable } from "babylonjs/types";
  46168. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46169. import { FlyCamera } from "babylonjs/Cameras/flyCamera";
  46170. /**
  46171. * Listen to keyboard events to control the camera.
  46172. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46173. */
  46174. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  46175. /**
  46176. * Defines the camera the input is attached to.
  46177. */
  46178. camera: FlyCamera;
  46179. /**
  46180. * The list of keyboard keys used to control the forward move of the camera.
  46181. */
  46182. keysForward: number[];
  46183. /**
  46184. * The list of keyboard keys used to control the backward move of the camera.
  46185. */
  46186. keysBackward: number[];
  46187. /**
  46188. * The list of keyboard keys used to control the forward move of the camera.
  46189. */
  46190. keysUp: number[];
  46191. /**
  46192. * The list of keyboard keys used to control the backward move of the camera.
  46193. */
  46194. keysDown: number[];
  46195. /**
  46196. * The list of keyboard keys used to control the right strafe move of the camera.
  46197. */
  46198. keysRight: number[];
  46199. /**
  46200. * The list of keyboard keys used to control the left strafe move of the camera.
  46201. */
  46202. keysLeft: number[];
  46203. private _keys;
  46204. private _onCanvasBlurObserver;
  46205. private _onKeyboardObserver;
  46206. private _engine;
  46207. private _scene;
  46208. /**
  46209. * Attach the input controls to a specific dom element to get the input from.
  46210. * @param element Defines the element the controls should be listened from
  46211. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46212. */
  46213. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46214. /**
  46215. * Detach the current controls from the specified dom element.
  46216. * @param element Defines the element to stop listening the inputs from
  46217. */
  46218. detachControl(element: Nullable<HTMLElement>): void;
  46219. /**
  46220. * Gets the class name of the current intput.
  46221. * @returns the class name
  46222. */
  46223. getClassName(): string;
  46224. /** @hidden */
  46225. _onLostFocus(e: FocusEvent): void;
  46226. /**
  46227. * Get the friendly name associated with the input class.
  46228. * @returns the input friendly name
  46229. */
  46230. getSimpleName(): string;
  46231. /**
  46232. * Update the current camera state depending on the inputs that have been used this frame.
  46233. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46234. */
  46235. checkInputs(): void;
  46236. }
  46237. }
  46238. declare module "babylonjs/Cameras/Inputs/followCameraMouseWheelInput" {
  46239. import { Nullable } from "babylonjs/types";
  46240. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46241. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46242. /**
  46243. * Manage the mouse wheel inputs to control a follow camera.
  46244. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46245. */
  46246. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  46247. /**
  46248. * Defines the camera the input is attached to.
  46249. */
  46250. camera: FollowCamera;
  46251. /**
  46252. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  46253. */
  46254. axisControlRadius: boolean;
  46255. /**
  46256. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  46257. */
  46258. axisControlHeight: boolean;
  46259. /**
  46260. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  46261. */
  46262. axisControlRotation: boolean;
  46263. /**
  46264. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  46265. * relation to mouseWheel events.
  46266. */
  46267. wheelPrecision: number;
  46268. /**
  46269. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  46270. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  46271. */
  46272. wheelDeltaPercentage: number;
  46273. private _wheel;
  46274. private _observer;
  46275. /**
  46276. * Attach the input controls to a specific dom element to get the input from.
  46277. * @param element Defines the element the controls should be listened from
  46278. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46279. */
  46280. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46281. /**
  46282. * Detach the current controls from the specified dom element.
  46283. * @param element Defines the element to stop listening the inputs from
  46284. */
  46285. detachControl(element: Nullable<HTMLElement>): void;
  46286. /**
  46287. * Gets the class name of the current intput.
  46288. * @returns the class name
  46289. */
  46290. getClassName(): string;
  46291. /**
  46292. * Get the friendly name associated with the input class.
  46293. * @returns the input friendly name
  46294. */
  46295. getSimpleName(): string;
  46296. }
  46297. }
  46298. declare module "babylonjs/Cameras/Inputs/followCameraPointersInput" {
  46299. import { Nullable } from "babylonjs/types";
  46300. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46301. import { BaseCameraPointersInput } from "babylonjs/Cameras/Inputs/BaseCameraPointersInput";
  46302. import { PointerTouch } from "babylonjs/Events/pointerEvents";
  46303. /**
  46304. * Manage the pointers inputs to control an follow camera.
  46305. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46306. */
  46307. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  46308. /**
  46309. * Defines the camera the input is attached to.
  46310. */
  46311. camera: FollowCamera;
  46312. /**
  46313. * Gets the class name of the current input.
  46314. * @returns the class name
  46315. */
  46316. getClassName(): string;
  46317. /**
  46318. * Defines the pointer angular sensibility along the X axis or how fast is
  46319. * the camera rotating.
  46320. * A negative number will reverse the axis direction.
  46321. */
  46322. angularSensibilityX: number;
  46323. /**
  46324. * Defines the pointer angular sensibility along the Y axis or how fast is
  46325. * the camera rotating.
  46326. * A negative number will reverse the axis direction.
  46327. */
  46328. angularSensibilityY: number;
  46329. /**
  46330. * Defines the pointer pinch precision or how fast is the camera zooming.
  46331. * A negative number will reverse the axis direction.
  46332. */
  46333. pinchPrecision: number;
  46334. /**
  46335. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  46336. * from 0.
  46337. * It defines the percentage of current camera.radius to use as delta when
  46338. * pinch zoom is used.
  46339. */
  46340. pinchDeltaPercentage: number;
  46341. /**
  46342. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  46343. */
  46344. axisXControlRadius: boolean;
  46345. /**
  46346. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  46347. */
  46348. axisXControlHeight: boolean;
  46349. /**
  46350. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  46351. */
  46352. axisXControlRotation: boolean;
  46353. /**
  46354. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  46355. */
  46356. axisYControlRadius: boolean;
  46357. /**
  46358. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  46359. */
  46360. axisYControlHeight: boolean;
  46361. /**
  46362. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  46363. */
  46364. axisYControlRotation: boolean;
  46365. /**
  46366. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  46367. */
  46368. axisPinchControlRadius: boolean;
  46369. /**
  46370. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  46371. */
  46372. axisPinchControlHeight: boolean;
  46373. /**
  46374. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  46375. */
  46376. axisPinchControlRotation: boolean;
  46377. /**
  46378. * Log error messages if basic misconfiguration has occurred.
  46379. */
  46380. warningEnable: boolean;
  46381. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  46382. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  46383. private _warningCounter;
  46384. private _warning;
  46385. }
  46386. }
  46387. declare module "babylonjs/Cameras/followCameraInputsManager" {
  46388. import { CameraInputsManager } from "babylonjs/Cameras/cameraInputsManager";
  46389. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46390. /**
  46391. * Default Inputs manager for the FollowCamera.
  46392. * It groups all the default supported inputs for ease of use.
  46393. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46394. */
  46395. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  46396. /**
  46397. * Instantiates a new FollowCameraInputsManager.
  46398. * @param camera Defines the camera the inputs belong to
  46399. */
  46400. constructor(camera: FollowCamera);
  46401. /**
  46402. * Add keyboard input support to the input manager.
  46403. * @returns the current input manager
  46404. */
  46405. addKeyboard(): FollowCameraInputsManager;
  46406. /**
  46407. * Add mouse wheel input support to the input manager.
  46408. * @returns the current input manager
  46409. */
  46410. addMouseWheel(): FollowCameraInputsManager;
  46411. /**
  46412. * Add pointers input support to the input manager.
  46413. * @returns the current input manager
  46414. */
  46415. addPointers(): FollowCameraInputsManager;
  46416. /**
  46417. * Add orientation input support to the input manager.
  46418. * @returns the current input manager
  46419. */
  46420. addVRDeviceOrientation(): FollowCameraInputsManager;
  46421. }
  46422. }
  46423. declare module "babylonjs/Cameras/followCamera" {
  46424. import { Nullable } from "babylonjs/types";
  46425. import { TargetCamera } from "babylonjs/Cameras/targetCamera";
  46426. import { Scene } from "babylonjs/scene";
  46427. import { Vector3 } from "babylonjs/Maths/math.vector";
  46428. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  46429. import { FollowCameraInputsManager } from "babylonjs/Cameras/followCameraInputsManager";
  46430. /**
  46431. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  46432. * an arc rotate version arcFollowCamera are available.
  46433. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46434. */
  46435. export class FollowCamera extends TargetCamera {
  46436. /**
  46437. * Distance the follow camera should follow an object at
  46438. */
  46439. radius: number;
  46440. /**
  46441. * Minimum allowed distance of the camera to the axis of rotation
  46442. * (The camera can not get closer).
  46443. * This can help limiting how the Camera is able to move in the scene.
  46444. */
  46445. lowerRadiusLimit: Nullable<number>;
  46446. /**
  46447. * Maximum allowed distance of the camera to the axis of rotation
  46448. * (The camera can not get further).
  46449. * This can help limiting how the Camera is able to move in the scene.
  46450. */
  46451. upperRadiusLimit: Nullable<number>;
  46452. /**
  46453. * Define a rotation offset between the camera and the object it follows
  46454. */
  46455. rotationOffset: number;
  46456. /**
  46457. * Minimum allowed angle to camera position relative to target object.
  46458. * This can help limiting how the Camera is able to move in the scene.
  46459. */
  46460. lowerRotationOffsetLimit: Nullable<number>;
  46461. /**
  46462. * Maximum allowed angle to camera position relative to target object.
  46463. * This can help limiting how the Camera is able to move in the scene.
  46464. */
  46465. upperRotationOffsetLimit: Nullable<number>;
  46466. /**
  46467. * Define a height offset between the camera and the object it follows.
  46468. * It can help following an object from the top (like a car chaing a plane)
  46469. */
  46470. heightOffset: number;
  46471. /**
  46472. * Minimum allowed height of camera position relative to target object.
  46473. * This can help limiting how the Camera is able to move in the scene.
  46474. */
  46475. lowerHeightOffsetLimit: Nullable<number>;
  46476. /**
  46477. * Maximum allowed height of camera position relative to target object.
  46478. * This can help limiting how the Camera is able to move in the scene.
  46479. */
  46480. upperHeightOffsetLimit: Nullable<number>;
  46481. /**
  46482. * Define how fast the camera can accelerate to follow it s target.
  46483. */
  46484. cameraAcceleration: number;
  46485. /**
  46486. * Define the speed limit of the camera following an object.
  46487. */
  46488. maxCameraSpeed: number;
  46489. /**
  46490. * Define the target of the camera.
  46491. */
  46492. lockedTarget: Nullable<AbstractMesh>;
  46493. /**
  46494. * Defines the input associated with the camera.
  46495. */
  46496. inputs: FollowCameraInputsManager;
  46497. /**
  46498. * Instantiates the follow camera.
  46499. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46500. * @param name Define the name of the camera in the scene
  46501. * @param position Define the position of the camera
  46502. * @param scene Define the scene the camera belong to
  46503. * @param lockedTarget Define the target of the camera
  46504. */
  46505. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  46506. private _follow;
  46507. /**
  46508. * Attached controls to the current camera.
  46509. * @param element Defines the element the controls should be listened from
  46510. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46511. */
  46512. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46513. /**
  46514. * Detach the current controls from the camera.
  46515. * The camera will stop reacting to inputs.
  46516. * @param element Defines the element to stop listening the inputs from
  46517. */
  46518. detachControl(element: HTMLElement): void;
  46519. /** @hidden */
  46520. _checkInputs(): void;
  46521. private _checkLimits;
  46522. /**
  46523. * Gets the camera class name.
  46524. * @returns the class name
  46525. */
  46526. getClassName(): string;
  46527. }
  46528. /**
  46529. * Arc Rotate version of the follow camera.
  46530. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  46531. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46532. */
  46533. export class ArcFollowCamera extends TargetCamera {
  46534. /** The longitudinal angle of the camera */
  46535. alpha: number;
  46536. /** The latitudinal angle of the camera */
  46537. beta: number;
  46538. /** The radius of the camera from its target */
  46539. radius: number;
  46540. private _cartesianCoordinates;
  46541. /** Define the camera target (the mesh it should follow) */
  46542. private _meshTarget;
  46543. /**
  46544. * Instantiates a new ArcFollowCamera
  46545. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  46546. * @param name Define the name of the camera
  46547. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  46548. * @param beta Define the rotation angle of the camera around the elevation axis
  46549. * @param radius Define the radius of the camera from its target point
  46550. * @param target Define the target of the camera
  46551. * @param scene Define the scene the camera belongs to
  46552. */
  46553. constructor(name: string,
  46554. /** The longitudinal angle of the camera */
  46555. alpha: number,
  46556. /** The latitudinal angle of the camera */
  46557. beta: number,
  46558. /** The radius of the camera from its target */
  46559. radius: number,
  46560. /** Define the camera target (the mesh it should follow) */
  46561. target: Nullable<AbstractMesh>, scene: Scene);
  46562. private _follow;
  46563. /** @hidden */
  46564. _checkInputs(): void;
  46565. /**
  46566. * Returns the class name of the object.
  46567. * It is mostly used internally for serialization purposes.
  46568. */
  46569. getClassName(): string;
  46570. }
  46571. }
  46572. declare module "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput" {
  46573. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46574. import { FollowCamera } from "babylonjs/Cameras/followCamera";
  46575. import { Nullable } from "babylonjs/types";
  46576. /**
  46577. * Manage the keyboard inputs to control the movement of a follow camera.
  46578. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46579. */
  46580. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  46581. /**
  46582. * Defines the camera the input is attached to.
  46583. */
  46584. camera: FollowCamera;
  46585. /**
  46586. * Defines the list of key codes associated with the up action (increase heightOffset)
  46587. */
  46588. keysHeightOffsetIncr: number[];
  46589. /**
  46590. * Defines the list of key codes associated with the down action (decrease heightOffset)
  46591. */
  46592. keysHeightOffsetDecr: number[];
  46593. /**
  46594. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  46595. */
  46596. keysHeightOffsetModifierAlt: boolean;
  46597. /**
  46598. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  46599. */
  46600. keysHeightOffsetModifierCtrl: boolean;
  46601. /**
  46602. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  46603. */
  46604. keysHeightOffsetModifierShift: boolean;
  46605. /**
  46606. * Defines the list of key codes associated with the left action (increase rotationOffset)
  46607. */
  46608. keysRotationOffsetIncr: number[];
  46609. /**
  46610. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  46611. */
  46612. keysRotationOffsetDecr: number[];
  46613. /**
  46614. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  46615. */
  46616. keysRotationOffsetModifierAlt: boolean;
  46617. /**
  46618. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  46619. */
  46620. keysRotationOffsetModifierCtrl: boolean;
  46621. /**
  46622. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  46623. */
  46624. keysRotationOffsetModifierShift: boolean;
  46625. /**
  46626. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  46627. */
  46628. keysRadiusIncr: number[];
  46629. /**
  46630. * Defines the list of key codes associated with the zoom-out action (increase radius)
  46631. */
  46632. keysRadiusDecr: number[];
  46633. /**
  46634. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  46635. */
  46636. keysRadiusModifierAlt: boolean;
  46637. /**
  46638. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  46639. */
  46640. keysRadiusModifierCtrl: boolean;
  46641. /**
  46642. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  46643. */
  46644. keysRadiusModifierShift: boolean;
  46645. /**
  46646. * Defines the rate of change of heightOffset.
  46647. */
  46648. heightSensibility: number;
  46649. /**
  46650. * Defines the rate of change of rotationOffset.
  46651. */
  46652. rotationSensibility: number;
  46653. /**
  46654. * Defines the rate of change of radius.
  46655. */
  46656. radiusSensibility: number;
  46657. private _keys;
  46658. private _ctrlPressed;
  46659. private _altPressed;
  46660. private _shiftPressed;
  46661. private _onCanvasBlurObserver;
  46662. private _onKeyboardObserver;
  46663. private _engine;
  46664. private _scene;
  46665. /**
  46666. * Attach the input controls to a specific dom element to get the input from.
  46667. * @param element Defines the element the controls should be listened from
  46668. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46669. */
  46670. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46671. /**
  46672. * Detach the current controls from the specified dom element.
  46673. * @param element Defines the element to stop listening the inputs from
  46674. */
  46675. detachControl(element: Nullable<HTMLElement>): void;
  46676. /**
  46677. * Update the current camera state depending on the inputs that have been used this frame.
  46678. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46679. */
  46680. checkInputs(): void;
  46681. /**
  46682. * Gets the class name of the current input.
  46683. * @returns the class name
  46684. */
  46685. getClassName(): string;
  46686. /**
  46687. * Get the friendly name associated with the input class.
  46688. * @returns the input friendly name
  46689. */
  46690. getSimpleName(): string;
  46691. /**
  46692. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46693. * allow modification of the heightOffset value.
  46694. */
  46695. private _modifierHeightOffset;
  46696. /**
  46697. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46698. * allow modification of the rotationOffset value.
  46699. */
  46700. private _modifierRotationOffset;
  46701. /**
  46702. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  46703. * allow modification of the radius value.
  46704. */
  46705. private _modifierRadius;
  46706. }
  46707. }
  46708. declare module "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput" {
  46709. import { Nullable } from "babylonjs/types";
  46710. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46711. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46712. import { Observable } from "babylonjs/Misc/observable";
  46713. module "babylonjs/Cameras/freeCameraInputsManager" {
  46714. interface FreeCameraInputsManager {
  46715. /**
  46716. * @hidden
  46717. */
  46718. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  46719. /**
  46720. * Add orientation input support to the input manager.
  46721. * @returns the current input manager
  46722. */
  46723. addDeviceOrientation(): FreeCameraInputsManager;
  46724. }
  46725. }
  46726. /**
  46727. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  46728. * Screen rotation is taken into account.
  46729. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46730. */
  46731. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  46732. private _camera;
  46733. private _screenOrientationAngle;
  46734. private _constantTranform;
  46735. private _screenQuaternion;
  46736. private _alpha;
  46737. private _beta;
  46738. private _gamma;
  46739. /**
  46740. * Can be used to detect if a device orientation sensor is available on a device
  46741. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  46742. * @returns a promise that will resolve on orientation change
  46743. */
  46744. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  46745. /**
  46746. * @hidden
  46747. */
  46748. _onDeviceOrientationChangedObservable: Observable<void>;
  46749. /**
  46750. * Instantiates a new input
  46751. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46752. */
  46753. constructor();
  46754. /**
  46755. * Define the camera controlled by the input.
  46756. */
  46757. get camera(): FreeCamera;
  46758. set camera(camera: FreeCamera);
  46759. /**
  46760. * Attach the input controls to a specific dom element to get the input from.
  46761. * @param element Defines the element the controls should be listened from
  46762. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46763. */
  46764. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46765. private _orientationChanged;
  46766. private _deviceOrientation;
  46767. /**
  46768. * Detach the current controls from the specified dom element.
  46769. * @param element Defines the element to stop listening the inputs from
  46770. */
  46771. detachControl(element: Nullable<HTMLElement>): void;
  46772. /**
  46773. * Update the current camera state depending on the inputs that have been used this frame.
  46774. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46775. */
  46776. checkInputs(): void;
  46777. /**
  46778. * Gets the class name of the current intput.
  46779. * @returns the class name
  46780. */
  46781. getClassName(): string;
  46782. /**
  46783. * Get the friendly name associated with the input class.
  46784. * @returns the input friendly name
  46785. */
  46786. getSimpleName(): string;
  46787. }
  46788. }
  46789. declare module "babylonjs/Cameras/Inputs/freeCameraGamepadInput" {
  46790. import { Nullable } from "babylonjs/types";
  46791. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  46792. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  46793. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  46794. /**
  46795. * Manage the gamepad inputs to control a free camera.
  46796. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  46797. */
  46798. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  46799. /**
  46800. * Define the camera the input is attached to.
  46801. */
  46802. camera: FreeCamera;
  46803. /**
  46804. * Define the Gamepad controlling the input
  46805. */
  46806. gamepad: Nullable<Gamepad>;
  46807. /**
  46808. * Defines the gamepad rotation sensiblity.
  46809. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  46810. */
  46811. gamepadAngularSensibility: number;
  46812. /**
  46813. * Defines the gamepad move sensiblity.
  46814. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  46815. */
  46816. gamepadMoveSensibility: number;
  46817. private _yAxisScale;
  46818. /**
  46819. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  46820. */
  46821. get invertYAxis(): boolean;
  46822. set invertYAxis(value: boolean);
  46823. private _onGamepadConnectedObserver;
  46824. private _onGamepadDisconnectedObserver;
  46825. private _cameraTransform;
  46826. private _deltaTransform;
  46827. private _vector3;
  46828. private _vector2;
  46829. /**
  46830. * Attach the input controls to a specific dom element to get the input from.
  46831. * @param element Defines the element the controls should be listened from
  46832. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  46833. */
  46834. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  46835. /**
  46836. * Detach the current controls from the specified dom element.
  46837. * @param element Defines the element to stop listening the inputs from
  46838. */
  46839. detachControl(element: Nullable<HTMLElement>): void;
  46840. /**
  46841. * Update the current camera state depending on the inputs that have been used this frame.
  46842. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  46843. */
  46844. checkInputs(): void;
  46845. /**
  46846. * Gets the class name of the current intput.
  46847. * @returns the class name
  46848. */
  46849. getClassName(): string;
  46850. /**
  46851. * Get the friendly name associated with the input class.
  46852. * @returns the input friendly name
  46853. */
  46854. getSimpleName(): string;
  46855. }
  46856. }
  46857. declare module "babylonjs/Misc/virtualJoystick" {
  46858. import { Nullable } from "babylonjs/types";
  46859. import { Vector3 } from "babylonjs/Maths/math.vector";
  46860. /**
  46861. * Defines the potential axis of a Joystick
  46862. */
  46863. export enum JoystickAxis {
  46864. /** X axis */
  46865. X = 0,
  46866. /** Y axis */
  46867. Y = 1,
  46868. /** Z axis */
  46869. Z = 2
  46870. }
  46871. /**
  46872. * Represents the different customization options available
  46873. * for VirtualJoystick
  46874. */
  46875. interface VirtualJoystickCustomizations {
  46876. /**
  46877. * Size of the joystick's puck
  46878. */
  46879. puckSize: number;
  46880. /**
  46881. * Size of the joystick's container
  46882. */
  46883. containerSize: number;
  46884. /**
  46885. * Color of the joystick && puck
  46886. */
  46887. color: string;
  46888. /**
  46889. * Image URL for the joystick's puck
  46890. */
  46891. puckImage?: string;
  46892. /**
  46893. * Image URL for the joystick's container
  46894. */
  46895. containerImage?: string;
  46896. /**
  46897. * Defines the unmoving position of the joystick container
  46898. */
  46899. position?: {
  46900. x: number;
  46901. y: number;
  46902. };
  46903. /**
  46904. * Defines whether or not the joystick container is always visible
  46905. */
  46906. alwaysVisible: boolean;
  46907. /**
  46908. * Defines whether or not to limit the movement of the puck to the joystick's container
  46909. */
  46910. limitToContainer: boolean;
  46911. }
  46912. /**
  46913. * Class used to define virtual joystick (used in touch mode)
  46914. */
  46915. export class VirtualJoystick {
  46916. /**
  46917. * Gets or sets a boolean indicating that left and right values must be inverted
  46918. */
  46919. reverseLeftRight: boolean;
  46920. /**
  46921. * Gets or sets a boolean indicating that up and down values must be inverted
  46922. */
  46923. reverseUpDown: boolean;
  46924. /**
  46925. * Gets the offset value for the position (ie. the change of the position value)
  46926. */
  46927. deltaPosition: Vector3;
  46928. /**
  46929. * Gets a boolean indicating if the virtual joystick was pressed
  46930. */
  46931. pressed: boolean;
  46932. /**
  46933. * Canvas the virtual joystick will render onto, default z-index of this is 5
  46934. */
  46935. static Canvas: Nullable<HTMLCanvasElement>;
  46936. /**
  46937. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  46938. */
  46939. limitToContainer: boolean;
  46940. private static _globalJoystickIndex;
  46941. private static _alwaysVisibleSticks;
  46942. private static vjCanvasContext;
  46943. private static vjCanvasWidth;
  46944. private static vjCanvasHeight;
  46945. private static halfWidth;
  46946. private static _GetDefaultOptions;
  46947. private _action;
  46948. private _axisTargetedByLeftAndRight;
  46949. private _axisTargetedByUpAndDown;
  46950. private _joystickSensibility;
  46951. private _inversedSensibility;
  46952. private _joystickPointerID;
  46953. private _joystickColor;
  46954. private _joystickPointerPos;
  46955. private _joystickPreviousPointerPos;
  46956. private _joystickPointerStartPos;
  46957. private _deltaJoystickVector;
  46958. private _leftJoystick;
  46959. private _touches;
  46960. private _joystickPosition;
  46961. private _alwaysVisible;
  46962. private _puckImage;
  46963. private _containerImage;
  46964. private _joystickPuckSize;
  46965. private _joystickContainerSize;
  46966. private _clearPuckSize;
  46967. private _clearContainerSize;
  46968. private _clearPuckSizeOffset;
  46969. private _clearContainerSizeOffset;
  46970. private _onPointerDownHandlerRef;
  46971. private _onPointerMoveHandlerRef;
  46972. private _onPointerUpHandlerRef;
  46973. private _onResize;
  46974. /**
  46975. * Creates a new virtual joystick
  46976. * @param leftJoystick defines that the joystick is for left hand (false by default)
  46977. * @param customizations Defines the options we want to customize the VirtualJoystick
  46978. */
  46979. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  46980. /**
  46981. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  46982. * @param newJoystickSensibility defines the new sensibility
  46983. */
  46984. setJoystickSensibility(newJoystickSensibility: number): void;
  46985. private _onPointerDown;
  46986. private _onPointerMove;
  46987. private _onPointerUp;
  46988. /**
  46989. * Change the color of the virtual joystick
  46990. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  46991. */
  46992. setJoystickColor(newColor: string): void;
  46993. /**
  46994. * Size of the joystick's container
  46995. */
  46996. set containerSize(newSize: number);
  46997. get containerSize(): number;
  46998. /**
  46999. * Size of the joystick's puck
  47000. */
  47001. set puckSize(newSize: number);
  47002. get puckSize(): number;
  47003. /**
  47004. * Clears the set position of the joystick
  47005. */
  47006. clearPosition(): void;
  47007. /**
  47008. * Defines whether or not the joystick container is always visible
  47009. */
  47010. set alwaysVisible(value: boolean);
  47011. get alwaysVisible(): boolean;
  47012. /**
  47013. * Sets the constant position of the Joystick container
  47014. * @param x X axis coordinate
  47015. * @param y Y axis coordinate
  47016. */
  47017. setPosition(x: number, y: number): void;
  47018. /**
  47019. * Defines a callback to call when the joystick is touched
  47020. * @param action defines the callback
  47021. */
  47022. setActionOnTouch(action: () => any): void;
  47023. /**
  47024. * Defines which axis you'd like to control for left & right
  47025. * @param axis defines the axis to use
  47026. */
  47027. setAxisForLeftRight(axis: JoystickAxis): void;
  47028. /**
  47029. * Defines which axis you'd like to control for up & down
  47030. * @param axis defines the axis to use
  47031. */
  47032. setAxisForUpDown(axis: JoystickAxis): void;
  47033. /**
  47034. * Clears the canvas from the previous puck / container draw
  47035. */
  47036. private _clearPreviousDraw;
  47037. /**
  47038. * Loads `urlPath` to be used for the container's image
  47039. * @param urlPath defines the urlPath of an image to use
  47040. */
  47041. setContainerImage(urlPath: string): void;
  47042. /**
  47043. * Loads `urlPath` to be used for the puck's image
  47044. * @param urlPath defines the urlPath of an image to use
  47045. */
  47046. setPuckImage(urlPath: string): void;
  47047. /**
  47048. * Draws the Virtual Joystick's container
  47049. */
  47050. private _drawContainer;
  47051. /**
  47052. * Draws the Virtual Joystick's puck
  47053. */
  47054. private _drawPuck;
  47055. private _drawVirtualJoystick;
  47056. /**
  47057. * Release internal HTML canvas
  47058. */
  47059. releaseCanvas(): void;
  47060. }
  47061. }
  47062. declare module "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput" {
  47063. import { VirtualJoystick } from "babylonjs/Misc/virtualJoystick";
  47064. import { Nullable } from "babylonjs/types";
  47065. import { ICameraInput } from "babylonjs/Cameras/cameraInputsManager";
  47066. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47067. module "babylonjs/Cameras/freeCameraInputsManager" {
  47068. interface FreeCameraInputsManager {
  47069. /**
  47070. * Add virtual joystick input support to the input manager.
  47071. * @returns the current input manager
  47072. */
  47073. addVirtualJoystick(): FreeCameraInputsManager;
  47074. }
  47075. }
  47076. /**
  47077. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  47078. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  47079. */
  47080. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  47081. /**
  47082. * Defines the camera the input is attached to.
  47083. */
  47084. camera: FreeCamera;
  47085. private _leftjoystick;
  47086. private _rightjoystick;
  47087. /**
  47088. * Gets the left stick of the virtual joystick.
  47089. * @returns The virtual Joystick
  47090. */
  47091. getLeftJoystick(): VirtualJoystick;
  47092. /**
  47093. * Gets the right stick of the virtual joystick.
  47094. * @returns The virtual Joystick
  47095. */
  47096. getRightJoystick(): VirtualJoystick;
  47097. /**
  47098. * Update the current camera state depending on the inputs that have been used this frame.
  47099. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  47100. */
  47101. checkInputs(): void;
  47102. /**
  47103. * Attach the input controls to a specific dom element to get the input from.
  47104. * @param element Defines the element the controls should be listened from
  47105. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  47106. */
  47107. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  47108. /**
  47109. * Detach the current controls from the specified dom element.
  47110. * @param element Defines the element to stop listening the inputs from
  47111. */
  47112. detachControl(element: Nullable<HTMLElement>): void;
  47113. /**
  47114. * Gets the class name of the current intput.
  47115. * @returns the class name
  47116. */
  47117. getClassName(): string;
  47118. /**
  47119. * Get the friendly name associated with the input class.
  47120. * @returns the input friendly name
  47121. */
  47122. getSimpleName(): string;
  47123. }
  47124. }
  47125. declare module "babylonjs/Cameras/Inputs/index" {
  47126. export * from "babylonjs/Cameras/Inputs/arcRotateCameraGamepadInput";
  47127. export * from "babylonjs/Cameras/Inputs/arcRotateCameraKeyboardMoveInput";
  47128. export * from "babylonjs/Cameras/Inputs/arcRotateCameraMouseWheelInput";
  47129. export * from "babylonjs/Cameras/Inputs/arcRotateCameraPointersInput";
  47130. export * from "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  47131. export * from "babylonjs/Cameras/Inputs/flyCameraKeyboardInput";
  47132. export * from "babylonjs/Cameras/Inputs/flyCameraMouseInput";
  47133. export * from "babylonjs/Cameras/Inputs/followCameraKeyboardMoveInput";
  47134. export * from "babylonjs/Cameras/Inputs/followCameraMouseWheelInput";
  47135. export * from "babylonjs/Cameras/Inputs/followCameraPointersInput";
  47136. export * from "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47137. export * from "babylonjs/Cameras/Inputs/freeCameraGamepadInput";
  47138. export * from "babylonjs/Cameras/Inputs/freeCameraKeyboardMoveInput";
  47139. export * from "babylonjs/Cameras/Inputs/freeCameraMouseInput";
  47140. export * from "babylonjs/Cameras/Inputs/freeCameraTouchInput";
  47141. export * from "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  47142. }
  47143. declare module "babylonjs/Cameras/touchCamera" {
  47144. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47145. import { Scene } from "babylonjs/scene";
  47146. import { Vector3 } from "babylonjs/Maths/math.vector";
  47147. /**
  47148. * This represents a FPS type of camera controlled by touch.
  47149. * This is like a universal camera minus the Gamepad controls.
  47150. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47151. */
  47152. export class TouchCamera extends FreeCamera {
  47153. /**
  47154. * Defines the touch sensibility for rotation.
  47155. * The higher the faster.
  47156. */
  47157. get touchAngularSensibility(): number;
  47158. set touchAngularSensibility(value: number);
  47159. /**
  47160. * Defines the touch sensibility for move.
  47161. * The higher the faster.
  47162. */
  47163. get touchMoveSensibility(): number;
  47164. set touchMoveSensibility(value: number);
  47165. /**
  47166. * Instantiates a new touch camera.
  47167. * This represents a FPS type of camera controlled by touch.
  47168. * This is like a universal camera minus the Gamepad controls.
  47169. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47170. * @param name Define the name of the camera in the scene
  47171. * @param position Define the start position of the camera in the scene
  47172. * @param scene Define the scene the camera belongs to
  47173. */
  47174. constructor(name: string, position: Vector3, scene: Scene);
  47175. /**
  47176. * Gets the current object class name.
  47177. * @return the class name
  47178. */
  47179. getClassName(): string;
  47180. /** @hidden */
  47181. _setupInputs(): void;
  47182. }
  47183. }
  47184. declare module "babylonjs/Cameras/deviceOrientationCamera" {
  47185. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  47186. import { Scene } from "babylonjs/scene";
  47187. import { Vector3 } from "babylonjs/Maths/math.vector";
  47188. import "babylonjs/Cameras/Inputs/freeCameraDeviceOrientationInput";
  47189. import { Axis } from "babylonjs/Maths/math.axis";
  47190. /**
  47191. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  47192. * being tilted forward or back and left or right.
  47193. */
  47194. export class DeviceOrientationCamera extends FreeCamera {
  47195. private _initialQuaternion;
  47196. private _quaternionCache;
  47197. private _tmpDragQuaternion;
  47198. private _disablePointerInputWhenUsingDeviceOrientation;
  47199. /**
  47200. * Creates a new device orientation camera
  47201. * @param name The name of the camera
  47202. * @param position The start position camera
  47203. * @param scene The scene the camera belongs to
  47204. */
  47205. constructor(name: string, position: Vector3, scene: Scene);
  47206. /**
  47207. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  47208. */
  47209. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  47210. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  47211. private _dragFactor;
  47212. /**
  47213. * Enabled turning on the y axis when the orientation sensor is active
  47214. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  47215. */
  47216. enableHorizontalDragging(dragFactor?: number): void;
  47217. /**
  47218. * Gets the current instance class name ("DeviceOrientationCamera").
  47219. * This helps avoiding instanceof at run time.
  47220. * @returns the class name
  47221. */
  47222. getClassName(): string;
  47223. /**
  47224. * @hidden
  47225. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  47226. */
  47227. _checkInputs(): void;
  47228. /**
  47229. * Reset the camera to its default orientation on the specified axis only.
  47230. * @param axis The axis to reset
  47231. */
  47232. resetToCurrentRotation(axis?: Axis): void;
  47233. }
  47234. }
  47235. declare module "babylonjs/Gamepads/xboxGamepad" {
  47236. import { Observable } from "babylonjs/Misc/observable";
  47237. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47238. /**
  47239. * Defines supported buttons for XBox360 compatible gamepads
  47240. */
  47241. export enum Xbox360Button {
  47242. /** A */
  47243. A = 0,
  47244. /** B */
  47245. B = 1,
  47246. /** X */
  47247. X = 2,
  47248. /** Y */
  47249. Y = 3,
  47250. /** Left button */
  47251. LB = 4,
  47252. /** Right button */
  47253. RB = 5,
  47254. /** Back */
  47255. Back = 8,
  47256. /** Start */
  47257. Start = 9,
  47258. /** Left stick */
  47259. LeftStick = 10,
  47260. /** Right stick */
  47261. RightStick = 11
  47262. }
  47263. /** Defines values for XBox360 DPad */
  47264. export enum Xbox360Dpad {
  47265. /** Up */
  47266. Up = 12,
  47267. /** Down */
  47268. Down = 13,
  47269. /** Left */
  47270. Left = 14,
  47271. /** Right */
  47272. Right = 15
  47273. }
  47274. /**
  47275. * Defines a XBox360 gamepad
  47276. */
  47277. export class Xbox360Pad extends Gamepad {
  47278. private _leftTrigger;
  47279. private _rightTrigger;
  47280. private _onlefttriggerchanged;
  47281. private _onrighttriggerchanged;
  47282. private _onbuttondown;
  47283. private _onbuttonup;
  47284. private _ondpaddown;
  47285. private _ondpadup;
  47286. /** Observable raised when a button is pressed */
  47287. onButtonDownObservable: Observable<Xbox360Button>;
  47288. /** Observable raised when a button is released */
  47289. onButtonUpObservable: Observable<Xbox360Button>;
  47290. /** Observable raised when a pad is pressed */
  47291. onPadDownObservable: Observable<Xbox360Dpad>;
  47292. /** Observable raised when a pad is released */
  47293. onPadUpObservable: Observable<Xbox360Dpad>;
  47294. private _buttonA;
  47295. private _buttonB;
  47296. private _buttonX;
  47297. private _buttonY;
  47298. private _buttonBack;
  47299. private _buttonStart;
  47300. private _buttonLB;
  47301. private _buttonRB;
  47302. private _buttonLeftStick;
  47303. private _buttonRightStick;
  47304. private _dPadUp;
  47305. private _dPadDown;
  47306. private _dPadLeft;
  47307. private _dPadRight;
  47308. private _isXboxOnePad;
  47309. /**
  47310. * Creates a new XBox360 gamepad object
  47311. * @param id defines the id of this gamepad
  47312. * @param index defines its index
  47313. * @param gamepad defines the internal HTML gamepad object
  47314. * @param xboxOne defines if it is a XBox One gamepad
  47315. */
  47316. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  47317. /**
  47318. * Defines the callback to call when left trigger is pressed
  47319. * @param callback defines the callback to use
  47320. */
  47321. onlefttriggerchanged(callback: (value: number) => void): void;
  47322. /**
  47323. * Defines the callback to call when right trigger is pressed
  47324. * @param callback defines the callback to use
  47325. */
  47326. onrighttriggerchanged(callback: (value: number) => void): void;
  47327. /**
  47328. * Gets the left trigger value
  47329. */
  47330. get leftTrigger(): number;
  47331. /**
  47332. * Sets the left trigger value
  47333. */
  47334. set leftTrigger(newValue: number);
  47335. /**
  47336. * Gets the right trigger value
  47337. */
  47338. get rightTrigger(): number;
  47339. /**
  47340. * Sets the right trigger value
  47341. */
  47342. set rightTrigger(newValue: number);
  47343. /**
  47344. * Defines the callback to call when a button is pressed
  47345. * @param callback defines the callback to use
  47346. */
  47347. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  47348. /**
  47349. * Defines the callback to call when a button is released
  47350. * @param callback defines the callback to use
  47351. */
  47352. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  47353. /**
  47354. * Defines the callback to call when a pad is pressed
  47355. * @param callback defines the callback to use
  47356. */
  47357. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  47358. /**
  47359. * Defines the callback to call when a pad is released
  47360. * @param callback defines the callback to use
  47361. */
  47362. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  47363. private _setButtonValue;
  47364. private _setDPadValue;
  47365. /**
  47366. * Gets the value of the `A` button
  47367. */
  47368. get buttonA(): number;
  47369. /**
  47370. * Sets the value of the `A` button
  47371. */
  47372. set buttonA(value: number);
  47373. /**
  47374. * Gets the value of the `B` button
  47375. */
  47376. get buttonB(): number;
  47377. /**
  47378. * Sets the value of the `B` button
  47379. */
  47380. set buttonB(value: number);
  47381. /**
  47382. * Gets the value of the `X` button
  47383. */
  47384. get buttonX(): number;
  47385. /**
  47386. * Sets the value of the `X` button
  47387. */
  47388. set buttonX(value: number);
  47389. /**
  47390. * Gets the value of the `Y` button
  47391. */
  47392. get buttonY(): number;
  47393. /**
  47394. * Sets the value of the `Y` button
  47395. */
  47396. set buttonY(value: number);
  47397. /**
  47398. * Gets the value of the `Start` button
  47399. */
  47400. get buttonStart(): number;
  47401. /**
  47402. * Sets the value of the `Start` button
  47403. */
  47404. set buttonStart(value: number);
  47405. /**
  47406. * Gets the value of the `Back` button
  47407. */
  47408. get buttonBack(): number;
  47409. /**
  47410. * Sets the value of the `Back` button
  47411. */
  47412. set buttonBack(value: number);
  47413. /**
  47414. * Gets the value of the `Left` button
  47415. */
  47416. get buttonLB(): number;
  47417. /**
  47418. * Sets the value of the `Left` button
  47419. */
  47420. set buttonLB(value: number);
  47421. /**
  47422. * Gets the value of the `Right` button
  47423. */
  47424. get buttonRB(): number;
  47425. /**
  47426. * Sets the value of the `Right` button
  47427. */
  47428. set buttonRB(value: number);
  47429. /**
  47430. * Gets the value of the Left joystick
  47431. */
  47432. get buttonLeftStick(): number;
  47433. /**
  47434. * Sets the value of the Left joystick
  47435. */
  47436. set buttonLeftStick(value: number);
  47437. /**
  47438. * Gets the value of the Right joystick
  47439. */
  47440. get buttonRightStick(): number;
  47441. /**
  47442. * Sets the value of the Right joystick
  47443. */
  47444. set buttonRightStick(value: number);
  47445. /**
  47446. * Gets the value of D-pad up
  47447. */
  47448. get dPadUp(): number;
  47449. /**
  47450. * Sets the value of D-pad up
  47451. */
  47452. set dPadUp(value: number);
  47453. /**
  47454. * Gets the value of D-pad down
  47455. */
  47456. get dPadDown(): number;
  47457. /**
  47458. * Sets the value of D-pad down
  47459. */
  47460. set dPadDown(value: number);
  47461. /**
  47462. * Gets the value of D-pad left
  47463. */
  47464. get dPadLeft(): number;
  47465. /**
  47466. * Sets the value of D-pad left
  47467. */
  47468. set dPadLeft(value: number);
  47469. /**
  47470. * Gets the value of D-pad right
  47471. */
  47472. get dPadRight(): number;
  47473. /**
  47474. * Sets the value of D-pad right
  47475. */
  47476. set dPadRight(value: number);
  47477. /**
  47478. * Force the gamepad to synchronize with device values
  47479. */
  47480. update(): void;
  47481. /**
  47482. * Disposes the gamepad
  47483. */
  47484. dispose(): void;
  47485. }
  47486. }
  47487. declare module "babylonjs/Gamepads/dualShockGamepad" {
  47488. import { Observable } from "babylonjs/Misc/observable";
  47489. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47490. /**
  47491. * Defines supported buttons for DualShock compatible gamepads
  47492. */
  47493. export enum DualShockButton {
  47494. /** Cross */
  47495. Cross = 0,
  47496. /** Circle */
  47497. Circle = 1,
  47498. /** Square */
  47499. Square = 2,
  47500. /** Triangle */
  47501. Triangle = 3,
  47502. /** L1 */
  47503. L1 = 4,
  47504. /** R1 */
  47505. R1 = 5,
  47506. /** Share */
  47507. Share = 8,
  47508. /** Options */
  47509. Options = 9,
  47510. /** Left stick */
  47511. LeftStick = 10,
  47512. /** Right stick */
  47513. RightStick = 11
  47514. }
  47515. /** Defines values for DualShock DPad */
  47516. export enum DualShockDpad {
  47517. /** Up */
  47518. Up = 12,
  47519. /** Down */
  47520. Down = 13,
  47521. /** Left */
  47522. Left = 14,
  47523. /** Right */
  47524. Right = 15
  47525. }
  47526. /**
  47527. * Defines a DualShock gamepad
  47528. */
  47529. export class DualShockPad extends Gamepad {
  47530. private _leftTrigger;
  47531. private _rightTrigger;
  47532. private _onlefttriggerchanged;
  47533. private _onrighttriggerchanged;
  47534. private _onbuttondown;
  47535. private _onbuttonup;
  47536. private _ondpaddown;
  47537. private _ondpadup;
  47538. /** Observable raised when a button is pressed */
  47539. onButtonDownObservable: Observable<DualShockButton>;
  47540. /** Observable raised when a button is released */
  47541. onButtonUpObservable: Observable<DualShockButton>;
  47542. /** Observable raised when a pad is pressed */
  47543. onPadDownObservable: Observable<DualShockDpad>;
  47544. /** Observable raised when a pad is released */
  47545. onPadUpObservable: Observable<DualShockDpad>;
  47546. private _buttonCross;
  47547. private _buttonCircle;
  47548. private _buttonSquare;
  47549. private _buttonTriangle;
  47550. private _buttonShare;
  47551. private _buttonOptions;
  47552. private _buttonL1;
  47553. private _buttonR1;
  47554. private _buttonLeftStick;
  47555. private _buttonRightStick;
  47556. private _dPadUp;
  47557. private _dPadDown;
  47558. private _dPadLeft;
  47559. private _dPadRight;
  47560. /**
  47561. * Creates a new DualShock gamepad object
  47562. * @param id defines the id of this gamepad
  47563. * @param index defines its index
  47564. * @param gamepad defines the internal HTML gamepad object
  47565. */
  47566. constructor(id: string, index: number, gamepad: any);
  47567. /**
  47568. * Defines the callback to call when left trigger is pressed
  47569. * @param callback defines the callback to use
  47570. */
  47571. onlefttriggerchanged(callback: (value: number) => void): void;
  47572. /**
  47573. * Defines the callback to call when right trigger is pressed
  47574. * @param callback defines the callback to use
  47575. */
  47576. onrighttriggerchanged(callback: (value: number) => void): void;
  47577. /**
  47578. * Gets the left trigger value
  47579. */
  47580. get leftTrigger(): number;
  47581. /**
  47582. * Sets the left trigger value
  47583. */
  47584. set leftTrigger(newValue: number);
  47585. /**
  47586. * Gets the right trigger value
  47587. */
  47588. get rightTrigger(): number;
  47589. /**
  47590. * Sets the right trigger value
  47591. */
  47592. set rightTrigger(newValue: number);
  47593. /**
  47594. * Defines the callback to call when a button is pressed
  47595. * @param callback defines the callback to use
  47596. */
  47597. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  47598. /**
  47599. * Defines the callback to call when a button is released
  47600. * @param callback defines the callback to use
  47601. */
  47602. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  47603. /**
  47604. * Defines the callback to call when a pad is pressed
  47605. * @param callback defines the callback to use
  47606. */
  47607. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  47608. /**
  47609. * Defines the callback to call when a pad is released
  47610. * @param callback defines the callback to use
  47611. */
  47612. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  47613. private _setButtonValue;
  47614. private _setDPadValue;
  47615. /**
  47616. * Gets the value of the `Cross` button
  47617. */
  47618. get buttonCross(): number;
  47619. /**
  47620. * Sets the value of the `Cross` button
  47621. */
  47622. set buttonCross(value: number);
  47623. /**
  47624. * Gets the value of the `Circle` button
  47625. */
  47626. get buttonCircle(): number;
  47627. /**
  47628. * Sets the value of the `Circle` button
  47629. */
  47630. set buttonCircle(value: number);
  47631. /**
  47632. * Gets the value of the `Square` button
  47633. */
  47634. get buttonSquare(): number;
  47635. /**
  47636. * Sets the value of the `Square` button
  47637. */
  47638. set buttonSquare(value: number);
  47639. /**
  47640. * Gets the value of the `Triangle` button
  47641. */
  47642. get buttonTriangle(): number;
  47643. /**
  47644. * Sets the value of the `Triangle` button
  47645. */
  47646. set buttonTriangle(value: number);
  47647. /**
  47648. * Gets the value of the `Options` button
  47649. */
  47650. get buttonOptions(): number;
  47651. /**
  47652. * Sets the value of the `Options` button
  47653. */
  47654. set buttonOptions(value: number);
  47655. /**
  47656. * Gets the value of the `Share` button
  47657. */
  47658. get buttonShare(): number;
  47659. /**
  47660. * Sets the value of the `Share` button
  47661. */
  47662. set buttonShare(value: number);
  47663. /**
  47664. * Gets the value of the `L1` button
  47665. */
  47666. get buttonL1(): number;
  47667. /**
  47668. * Sets the value of the `L1` button
  47669. */
  47670. set buttonL1(value: number);
  47671. /**
  47672. * Gets the value of the `R1` button
  47673. */
  47674. get buttonR1(): number;
  47675. /**
  47676. * Sets the value of the `R1` button
  47677. */
  47678. set buttonR1(value: number);
  47679. /**
  47680. * Gets the value of the Left joystick
  47681. */
  47682. get buttonLeftStick(): number;
  47683. /**
  47684. * Sets the value of the Left joystick
  47685. */
  47686. set buttonLeftStick(value: number);
  47687. /**
  47688. * Gets the value of the Right joystick
  47689. */
  47690. get buttonRightStick(): number;
  47691. /**
  47692. * Sets the value of the Right joystick
  47693. */
  47694. set buttonRightStick(value: number);
  47695. /**
  47696. * Gets the value of D-pad up
  47697. */
  47698. get dPadUp(): number;
  47699. /**
  47700. * Sets the value of D-pad up
  47701. */
  47702. set dPadUp(value: number);
  47703. /**
  47704. * Gets the value of D-pad down
  47705. */
  47706. get dPadDown(): number;
  47707. /**
  47708. * Sets the value of D-pad down
  47709. */
  47710. set dPadDown(value: number);
  47711. /**
  47712. * Gets the value of D-pad left
  47713. */
  47714. get dPadLeft(): number;
  47715. /**
  47716. * Sets the value of D-pad left
  47717. */
  47718. set dPadLeft(value: number);
  47719. /**
  47720. * Gets the value of D-pad right
  47721. */
  47722. get dPadRight(): number;
  47723. /**
  47724. * Sets the value of D-pad right
  47725. */
  47726. set dPadRight(value: number);
  47727. /**
  47728. * Force the gamepad to synchronize with device values
  47729. */
  47730. update(): void;
  47731. /**
  47732. * Disposes the gamepad
  47733. */
  47734. dispose(): void;
  47735. }
  47736. }
  47737. declare module "babylonjs/Gamepads/gamepadManager" {
  47738. import { Observable } from "babylonjs/Misc/observable";
  47739. import { Nullable } from "babylonjs/types";
  47740. import { Scene } from "babylonjs/scene";
  47741. import { Gamepad } from "babylonjs/Gamepads/gamepad";
  47742. /**
  47743. * Manager for handling gamepads
  47744. */
  47745. export class GamepadManager {
  47746. private _scene?;
  47747. private _babylonGamepads;
  47748. private _oneGamepadConnected;
  47749. /** @hidden */
  47750. _isMonitoring: boolean;
  47751. private _gamepadEventSupported;
  47752. private _gamepadSupport?;
  47753. /**
  47754. * observable to be triggered when the gamepad controller has been connected
  47755. */
  47756. onGamepadConnectedObservable: Observable<Gamepad>;
  47757. /**
  47758. * observable to be triggered when the gamepad controller has been disconnected
  47759. */
  47760. onGamepadDisconnectedObservable: Observable<Gamepad>;
  47761. private _onGamepadConnectedEvent;
  47762. private _onGamepadDisconnectedEvent;
  47763. /**
  47764. * Initializes the gamepad manager
  47765. * @param _scene BabylonJS scene
  47766. */
  47767. constructor(_scene?: Scene | undefined);
  47768. /**
  47769. * The gamepads in the game pad manager
  47770. */
  47771. get gamepads(): Gamepad[];
  47772. /**
  47773. * Get the gamepad controllers based on type
  47774. * @param type The type of gamepad controller
  47775. * @returns Nullable gamepad
  47776. */
  47777. getGamepadByType(type?: number): Nullable<Gamepad>;
  47778. /**
  47779. * Disposes the gamepad manager
  47780. */
  47781. dispose(): void;
  47782. private _addNewGamepad;
  47783. private _startMonitoringGamepads;
  47784. private _stopMonitoringGamepads;
  47785. /** @hidden */
  47786. _checkGamepadsStatus(): void;
  47787. private _updateGamepadObjects;
  47788. }
  47789. }
  47790. declare module "babylonjs/Gamepads/gamepadSceneComponent" {
  47791. import { Nullable } from "babylonjs/types";
  47792. import { Scene } from "babylonjs/scene";
  47793. import { ISceneComponent } from "babylonjs/sceneComponent";
  47794. import { GamepadManager } from "babylonjs/Gamepads/gamepadManager";
  47795. module "babylonjs/scene" {
  47796. interface Scene {
  47797. /** @hidden */
  47798. _gamepadManager: Nullable<GamepadManager>;
  47799. /**
  47800. * Gets the gamepad manager associated with the scene
  47801. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  47802. */
  47803. gamepadManager: GamepadManager;
  47804. }
  47805. }
  47806. module "babylonjs/Cameras/freeCameraInputsManager" {
  47807. /**
  47808. * Interface representing a free camera inputs manager
  47809. */
  47810. interface FreeCameraInputsManager {
  47811. /**
  47812. * Adds gamepad input support to the FreeCameraInputsManager.
  47813. * @returns the FreeCameraInputsManager
  47814. */
  47815. addGamepad(): FreeCameraInputsManager;
  47816. }
  47817. }
  47818. module "babylonjs/Cameras/arcRotateCameraInputsManager" {
  47819. /**
  47820. * Interface representing an arc rotate camera inputs manager
  47821. */
  47822. interface ArcRotateCameraInputsManager {
  47823. /**
  47824. * Adds gamepad input support to the ArcRotateCamera InputManager.
  47825. * @returns the camera inputs manager
  47826. */
  47827. addGamepad(): ArcRotateCameraInputsManager;
  47828. }
  47829. }
  47830. /**
  47831. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  47832. */
  47833. export class GamepadSystemSceneComponent implements ISceneComponent {
  47834. /**
  47835. * The component name helpfull to identify the component in the list of scene components.
  47836. */
  47837. readonly name: string;
  47838. /**
  47839. * The scene the component belongs to.
  47840. */
  47841. scene: Scene;
  47842. /**
  47843. * Creates a new instance of the component for the given scene
  47844. * @param scene Defines the scene to register the component in
  47845. */
  47846. constructor(scene: Scene);
  47847. /**
  47848. * Registers the component in a given scene
  47849. */
  47850. register(): void;
  47851. /**
  47852. * Rebuilds the elements related to this component in case of
  47853. * context lost for instance.
  47854. */
  47855. rebuild(): void;
  47856. /**
  47857. * Disposes the component and the associated ressources
  47858. */
  47859. dispose(): void;
  47860. private _beforeCameraUpdate;
  47861. }
  47862. }
  47863. declare module "babylonjs/Cameras/universalCamera" {
  47864. import { TouchCamera } from "babylonjs/Cameras/touchCamera";
  47865. import { Scene } from "babylonjs/scene";
  47866. import { Vector3 } from "babylonjs/Maths/math.vector";
  47867. import "babylonjs/Gamepads/gamepadSceneComponent";
  47868. /**
  47869. * 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,
  47870. * which still works and will still be found in many Playgrounds.
  47871. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47872. */
  47873. export class UniversalCamera extends TouchCamera {
  47874. /**
  47875. * Defines the gamepad rotation sensiblity.
  47876. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  47877. */
  47878. get gamepadAngularSensibility(): number;
  47879. set gamepadAngularSensibility(value: number);
  47880. /**
  47881. * Defines the gamepad move sensiblity.
  47882. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  47883. */
  47884. get gamepadMoveSensibility(): number;
  47885. set gamepadMoveSensibility(value: number);
  47886. /**
  47887. * 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,
  47888. * which still works and will still be found in many Playgrounds.
  47889. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47890. * @param name Define the name of the camera in the scene
  47891. * @param position Define the start position of the camera in the scene
  47892. * @param scene Define the scene the camera belongs to
  47893. */
  47894. constructor(name: string, position: Vector3, scene: Scene);
  47895. /**
  47896. * Gets the current object class name.
  47897. * @return the class name
  47898. */
  47899. getClassName(): string;
  47900. }
  47901. }
  47902. declare module "babylonjs/Cameras/gamepadCamera" {
  47903. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  47904. import { Scene } from "babylonjs/scene";
  47905. import { Vector3 } from "babylonjs/Maths/math.vector";
  47906. /**
  47907. * This represents a FPS type of camera. This is only here for back compat purpose.
  47908. * Please use the UniversalCamera instead as both are identical.
  47909. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47910. */
  47911. export class GamepadCamera extends UniversalCamera {
  47912. /**
  47913. * Instantiates a new Gamepad Camera
  47914. * This represents a FPS type of camera. This is only here for back compat purpose.
  47915. * Please use the UniversalCamera instead as both are identical.
  47916. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  47917. * @param name Define the name of the camera in the scene
  47918. * @param position Define the start position of the camera in the scene
  47919. * @param scene Define the scene the camera belongs to
  47920. */
  47921. constructor(name: string, position: Vector3, scene: Scene);
  47922. /**
  47923. * Gets the current object class name.
  47924. * @return the class name
  47925. */
  47926. getClassName(): string;
  47927. }
  47928. }
  47929. declare module "babylonjs/Shaders/pass.fragment" {
  47930. /** @hidden */
  47931. export var passPixelShader: {
  47932. name: string;
  47933. shader: string;
  47934. };
  47935. }
  47936. declare module "babylonjs/Shaders/passCube.fragment" {
  47937. /** @hidden */
  47938. export var passCubePixelShader: {
  47939. name: string;
  47940. shader: string;
  47941. };
  47942. }
  47943. declare module "babylonjs/PostProcesses/passPostProcess" {
  47944. import { Nullable } from "babylonjs/types";
  47945. import { Camera } from "babylonjs/Cameras/camera";
  47946. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  47947. import { Engine } from "babylonjs/Engines/engine";
  47948. import "babylonjs/Shaders/pass.fragment";
  47949. import "babylonjs/Shaders/passCube.fragment";
  47950. import { Scene } from "babylonjs/scene";
  47951. /**
  47952. * PassPostProcess which produces an output the same as it's input
  47953. */
  47954. export class PassPostProcess extends PostProcess {
  47955. /**
  47956. * Gets a string identifying the name of the class
  47957. * @returns "PassPostProcess" string
  47958. */
  47959. getClassName(): string;
  47960. /**
  47961. * Creates the PassPostProcess
  47962. * @param name The name of the effect.
  47963. * @param options The required width/height ratio to downsize to before computing the render pass.
  47964. * @param camera The camera to apply the render pass to.
  47965. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  47966. * @param engine The engine which the post process will be applied. (default: current engine)
  47967. * @param reusable If the post process can be reused on the same frame. (default: false)
  47968. * @param textureType The type of texture to be used when performing the post processing.
  47969. * @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)
  47970. */
  47971. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  47972. /** @hidden */
  47973. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  47974. }
  47975. /**
  47976. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  47977. */
  47978. export class PassCubePostProcess extends PostProcess {
  47979. private _face;
  47980. /**
  47981. * Gets or sets the cube face to display.
  47982. * * 0 is +X
  47983. * * 1 is -X
  47984. * * 2 is +Y
  47985. * * 3 is -Y
  47986. * * 4 is +Z
  47987. * * 5 is -Z
  47988. */
  47989. get face(): number;
  47990. set face(value: number);
  47991. /**
  47992. * Gets a string identifying the name of the class
  47993. * @returns "PassCubePostProcess" string
  47994. */
  47995. getClassName(): string;
  47996. /**
  47997. * Creates the PassCubePostProcess
  47998. * @param name The name of the effect.
  47999. * @param options The required width/height ratio to downsize to before computing the render pass.
  48000. * @param camera The camera to apply the render pass to.
  48001. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  48002. * @param engine The engine which the post process will be applied. (default: current engine)
  48003. * @param reusable If the post process can be reused on the same frame. (default: false)
  48004. * @param textureType The type of texture to be used when performing the post processing.
  48005. * @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)
  48006. */
  48007. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  48008. /** @hidden */
  48009. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  48010. }
  48011. }
  48012. declare module "babylonjs/Shaders/anaglyph.fragment" {
  48013. /** @hidden */
  48014. export var anaglyphPixelShader: {
  48015. name: string;
  48016. shader: string;
  48017. };
  48018. }
  48019. declare module "babylonjs/PostProcesses/anaglyphPostProcess" {
  48020. import { Engine } from "babylonjs/Engines/engine";
  48021. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  48022. import { Camera } from "babylonjs/Cameras/camera";
  48023. import "babylonjs/Shaders/anaglyph.fragment";
  48024. /**
  48025. * Postprocess used to generate anaglyphic rendering
  48026. */
  48027. export class AnaglyphPostProcess extends PostProcess {
  48028. private _passedProcess;
  48029. /**
  48030. * Gets a string identifying the name of the class
  48031. * @returns "AnaglyphPostProcess" string
  48032. */
  48033. getClassName(): string;
  48034. /**
  48035. * Creates a new AnaglyphPostProcess
  48036. * @param name defines postprocess name
  48037. * @param options defines creation options or target ratio scale
  48038. * @param rigCameras defines cameras using this postprocess
  48039. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  48040. * @param engine defines hosting engine
  48041. * @param reusable defines if the postprocess will be reused multiple times per frame
  48042. */
  48043. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  48044. }
  48045. }
  48046. declare module "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode" { }
  48047. declare module "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera" {
  48048. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48049. import { Scene } from "babylonjs/scene";
  48050. import { Vector3 } from "babylonjs/Maths/math.vector";
  48051. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48052. /**
  48053. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  48054. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48055. */
  48056. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  48057. /**
  48058. * Creates a new AnaglyphArcRotateCamera
  48059. * @param name defines camera name
  48060. * @param alpha defines alpha angle (in radians)
  48061. * @param beta defines beta angle (in radians)
  48062. * @param radius defines radius
  48063. * @param target defines camera target
  48064. * @param interaxialDistance defines distance between each color axis
  48065. * @param scene defines the hosting scene
  48066. */
  48067. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  48068. /**
  48069. * Gets camera class name
  48070. * @returns AnaglyphArcRotateCamera
  48071. */
  48072. getClassName(): string;
  48073. }
  48074. }
  48075. declare module "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera" {
  48076. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48077. import { Scene } from "babylonjs/scene";
  48078. import { Vector3 } from "babylonjs/Maths/math.vector";
  48079. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48080. /**
  48081. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  48082. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48083. */
  48084. export class AnaglyphFreeCamera extends FreeCamera {
  48085. /**
  48086. * Creates a new AnaglyphFreeCamera
  48087. * @param name defines camera name
  48088. * @param position defines initial position
  48089. * @param interaxialDistance defines distance between each color axis
  48090. * @param scene defines the hosting scene
  48091. */
  48092. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48093. /**
  48094. * Gets camera class name
  48095. * @returns AnaglyphFreeCamera
  48096. */
  48097. getClassName(): string;
  48098. }
  48099. }
  48100. declare module "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera" {
  48101. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48102. import { Scene } from "babylonjs/scene";
  48103. import { Vector3 } from "babylonjs/Maths/math.vector";
  48104. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48105. /**
  48106. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  48107. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48108. */
  48109. export class AnaglyphGamepadCamera extends GamepadCamera {
  48110. /**
  48111. * Creates a new AnaglyphGamepadCamera
  48112. * @param name defines camera name
  48113. * @param position defines initial position
  48114. * @param interaxialDistance defines distance between each color axis
  48115. * @param scene defines the hosting scene
  48116. */
  48117. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48118. /**
  48119. * Gets camera class name
  48120. * @returns AnaglyphGamepadCamera
  48121. */
  48122. getClassName(): string;
  48123. }
  48124. }
  48125. declare module "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera" {
  48126. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48127. import { Scene } from "babylonjs/scene";
  48128. import { Vector3 } from "babylonjs/Maths/math.vector";
  48129. import "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  48130. /**
  48131. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  48132. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  48133. */
  48134. export class AnaglyphUniversalCamera extends UniversalCamera {
  48135. /**
  48136. * Creates a new AnaglyphUniversalCamera
  48137. * @param name defines camera name
  48138. * @param position defines initial position
  48139. * @param interaxialDistance defines distance between each color axis
  48140. * @param scene defines the hosting scene
  48141. */
  48142. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  48143. /**
  48144. * Gets camera class name
  48145. * @returns AnaglyphUniversalCamera
  48146. */
  48147. getClassName(): string;
  48148. }
  48149. }
  48150. declare module "babylonjs/Cameras/RigModes/stereoscopicRigMode" { }
  48151. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera" {
  48152. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48153. import { Scene } from "babylonjs/scene";
  48154. import { Vector3 } from "babylonjs/Maths/math.vector";
  48155. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48156. /**
  48157. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  48158. * @see https://doc.babylonjs.com/features/cameras
  48159. */
  48160. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  48161. /**
  48162. * Creates a new StereoscopicArcRotateCamera
  48163. * @param name defines camera name
  48164. * @param alpha defines alpha angle (in radians)
  48165. * @param beta defines beta angle (in radians)
  48166. * @param radius defines radius
  48167. * @param target defines camera target
  48168. * @param interaxialDistance defines distance between each color axis
  48169. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48170. * @param scene defines the hosting scene
  48171. */
  48172. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48173. /**
  48174. * Gets camera class name
  48175. * @returns StereoscopicArcRotateCamera
  48176. */
  48177. getClassName(): string;
  48178. }
  48179. }
  48180. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera" {
  48181. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48182. import { Scene } from "babylonjs/scene";
  48183. import { Vector3 } from "babylonjs/Maths/math.vector";
  48184. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48185. /**
  48186. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  48187. * @see https://doc.babylonjs.com/features/cameras
  48188. */
  48189. export class StereoscopicFreeCamera extends FreeCamera {
  48190. /**
  48191. * Creates a new StereoscopicFreeCamera
  48192. * @param name defines camera name
  48193. * @param position defines initial position
  48194. * @param interaxialDistance defines distance between each color axis
  48195. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48196. * @param scene defines the hosting scene
  48197. */
  48198. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48199. /**
  48200. * Gets camera class name
  48201. * @returns StereoscopicFreeCamera
  48202. */
  48203. getClassName(): string;
  48204. }
  48205. }
  48206. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera" {
  48207. import { GamepadCamera } from "babylonjs/Cameras/gamepadCamera";
  48208. import { Scene } from "babylonjs/scene";
  48209. import { Vector3 } from "babylonjs/Maths/math.vector";
  48210. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48211. /**
  48212. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  48213. * @see https://doc.babylonjs.com/features/cameras
  48214. */
  48215. export class StereoscopicGamepadCamera extends GamepadCamera {
  48216. /**
  48217. * Creates a new StereoscopicGamepadCamera
  48218. * @param name defines camera name
  48219. * @param position defines initial position
  48220. * @param interaxialDistance defines distance between each color axis
  48221. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48222. * @param scene defines the hosting scene
  48223. */
  48224. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48225. /**
  48226. * Gets camera class name
  48227. * @returns StereoscopicGamepadCamera
  48228. */
  48229. getClassName(): string;
  48230. }
  48231. }
  48232. declare module "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera" {
  48233. import { UniversalCamera } from "babylonjs/Cameras/universalCamera";
  48234. import { Scene } from "babylonjs/scene";
  48235. import { Vector3 } from "babylonjs/Maths/math.vector";
  48236. import "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  48237. /**
  48238. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  48239. * @see https://doc.babylonjs.com/features/cameras
  48240. */
  48241. export class StereoscopicUniversalCamera extends UniversalCamera {
  48242. /**
  48243. * Creates a new StereoscopicUniversalCamera
  48244. * @param name defines camera name
  48245. * @param position defines initial position
  48246. * @param interaxialDistance defines distance between each color axis
  48247. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  48248. * @param scene defines the hosting scene
  48249. */
  48250. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  48251. /**
  48252. * Gets camera class name
  48253. * @returns StereoscopicUniversalCamera
  48254. */
  48255. getClassName(): string;
  48256. }
  48257. }
  48258. declare module "babylonjs/Cameras/Stereoscopic/index" {
  48259. export * from "babylonjs/Cameras/Stereoscopic/anaglyphArcRotateCamera";
  48260. export * from "babylonjs/Cameras/Stereoscopic/anaglyphFreeCamera";
  48261. export * from "babylonjs/Cameras/Stereoscopic/anaglyphGamepadCamera";
  48262. export * from "babylonjs/Cameras/Stereoscopic/anaglyphUniversalCamera";
  48263. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicArcRotateCamera";
  48264. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicFreeCamera";
  48265. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicGamepadCamera";
  48266. export * from "babylonjs/Cameras/Stereoscopic/stereoscopicUniversalCamera";
  48267. }
  48268. declare module "babylonjs/Cameras/virtualJoysticksCamera" {
  48269. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  48270. import { Scene } from "babylonjs/scene";
  48271. import { Vector3 } from "babylonjs/Maths/math.vector";
  48272. import "babylonjs/Cameras/Inputs/freeCameraVirtualJoystickInput";
  48273. /**
  48274. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  48275. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48276. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48277. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48278. */
  48279. export class VirtualJoysticksCamera extends FreeCamera {
  48280. /**
  48281. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  48282. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  48283. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  48284. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  48285. * @param name Define the name of the camera in the scene
  48286. * @param position Define the start position of the camera in the scene
  48287. * @param scene Define the scene the camera belongs to
  48288. */
  48289. constructor(name: string, position: Vector3, scene: Scene);
  48290. /**
  48291. * Gets the current object class name.
  48292. * @return the class name
  48293. */
  48294. getClassName(): string;
  48295. }
  48296. }
  48297. declare module "babylonjs/Cameras/VR/vrCameraMetrics" {
  48298. import { Matrix } from "babylonjs/Maths/math.vector";
  48299. /**
  48300. * This represents all the required metrics to create a VR camera.
  48301. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  48302. */
  48303. export class VRCameraMetrics {
  48304. /**
  48305. * Define the horizontal resolution off the screen.
  48306. */
  48307. hResolution: number;
  48308. /**
  48309. * Define the vertical resolution off the screen.
  48310. */
  48311. vResolution: number;
  48312. /**
  48313. * Define the horizontal screen size.
  48314. */
  48315. hScreenSize: number;
  48316. /**
  48317. * Define the vertical screen size.
  48318. */
  48319. vScreenSize: number;
  48320. /**
  48321. * Define the vertical screen center position.
  48322. */
  48323. vScreenCenter: number;
  48324. /**
  48325. * Define the distance of the eyes to the screen.
  48326. */
  48327. eyeToScreenDistance: number;
  48328. /**
  48329. * Define the distance between both lenses
  48330. */
  48331. lensSeparationDistance: number;
  48332. /**
  48333. * Define the distance between both viewer's eyes.
  48334. */
  48335. interpupillaryDistance: number;
  48336. /**
  48337. * Define the distortion factor of the VR postprocess.
  48338. * Please, touch with care.
  48339. */
  48340. distortionK: number[];
  48341. /**
  48342. * Define the chromatic aberration correction factors for the VR post process.
  48343. */
  48344. chromaAbCorrection: number[];
  48345. /**
  48346. * Define the scale factor of the post process.
  48347. * The smaller the better but the slower.
  48348. */
  48349. postProcessScaleFactor: number;
  48350. /**
  48351. * Define an offset for the lens center.
  48352. */
  48353. lensCenterOffset: number;
  48354. /**
  48355. * Define if the current vr camera should compensate the distortion of the lense or not.
  48356. */
  48357. compensateDistortion: boolean;
  48358. /**
  48359. * Defines if multiview should be enabled when rendering (Default: false)
  48360. */
  48361. multiviewEnabled: boolean;
  48362. /**
  48363. * Gets the rendering aspect ratio based on the provided resolutions.
  48364. */
  48365. get aspectRatio(): number;
  48366. /**
  48367. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  48368. */
  48369. get aspectRatioFov(): number;
  48370. /**
  48371. * @hidden
  48372. */
  48373. get leftHMatrix(): Matrix;
  48374. /**
  48375. * @hidden
  48376. */
  48377. get rightHMatrix(): Matrix;
  48378. /**
  48379. * @hidden
  48380. */
  48381. get leftPreViewMatrix(): Matrix;
  48382. /**
  48383. * @hidden
  48384. */
  48385. get rightPreViewMatrix(): Matrix;
  48386. /**
  48387. * Get the default VRMetrics based on the most generic setup.
  48388. * @returns the default vr metrics
  48389. */
  48390. static GetDefault(): VRCameraMetrics;
  48391. }
  48392. }
  48393. declare module "babylonjs/Shaders/vrDistortionCorrection.fragment" {
  48394. /** @hidden */
  48395. export var vrDistortionCorrectionPixelShader: {
  48396. name: string;
  48397. shader: string;
  48398. };
  48399. }
  48400. declare module "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess" {
  48401. import { Camera } from "babylonjs/Cameras/camera";
  48402. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48403. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  48404. import "babylonjs/Shaders/vrDistortionCorrection.fragment";
  48405. /**
  48406. * VRDistortionCorrectionPostProcess used for mobile VR
  48407. */
  48408. export class VRDistortionCorrectionPostProcess extends PostProcess {
  48409. private _isRightEye;
  48410. private _distortionFactors;
  48411. private _postProcessScaleFactor;
  48412. private _lensCenterOffset;
  48413. private _scaleIn;
  48414. private _scaleFactor;
  48415. private _lensCenter;
  48416. /**
  48417. * Gets a string identifying the name of the class
  48418. * @returns "VRDistortionCorrectionPostProcess" string
  48419. */
  48420. getClassName(): string;
  48421. /**
  48422. * Initializes the VRDistortionCorrectionPostProcess
  48423. * @param name The name of the effect.
  48424. * @param camera The camera to apply the render pass to.
  48425. * @param isRightEye If this is for the right eye distortion
  48426. * @param vrMetrics All the required metrics for the VR camera
  48427. */
  48428. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  48429. }
  48430. }
  48431. declare module "babylonjs/Cameras/RigModes/vrRigMode" { }
  48432. declare module "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera" {
  48433. import { ArcRotateCamera } from "babylonjs/Cameras/arcRotateCamera";
  48434. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48435. import { Scene } from "babylonjs/scene";
  48436. import { Vector3 } from "babylonjs/Maths/math.vector";
  48437. import "babylonjs/Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput";
  48438. import "babylonjs/Cameras/RigModes/vrRigMode";
  48439. /**
  48440. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  48441. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48442. */
  48443. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  48444. /**
  48445. * Creates a new VRDeviceOrientationArcRotateCamera
  48446. * @param name defines camera name
  48447. * @param alpha defines the camera rotation along the logitudinal axis
  48448. * @param beta defines the camera rotation along the latitudinal axis
  48449. * @param radius defines the camera distance from its target
  48450. * @param target defines the camera target
  48451. * @param scene defines the scene the camera belongs to
  48452. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48453. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48454. */
  48455. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48456. /**
  48457. * Gets camera class name
  48458. * @returns VRDeviceOrientationArcRotateCamera
  48459. */
  48460. getClassName(): string;
  48461. }
  48462. }
  48463. declare module "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera" {
  48464. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  48465. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48466. import { Scene } from "babylonjs/scene";
  48467. import { Vector3 } from "babylonjs/Maths/math.vector";
  48468. import "babylonjs/Cameras/RigModes/vrRigMode";
  48469. /**
  48470. * Camera used to simulate VR rendering (based on FreeCamera)
  48471. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48472. */
  48473. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  48474. /**
  48475. * Creates a new VRDeviceOrientationFreeCamera
  48476. * @param name defines camera name
  48477. * @param position defines the start position of the camera
  48478. * @param scene defines the scene the camera belongs to
  48479. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48480. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48481. */
  48482. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48483. /**
  48484. * Gets camera class name
  48485. * @returns VRDeviceOrientationFreeCamera
  48486. */
  48487. getClassName(): string;
  48488. }
  48489. }
  48490. declare module "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera" {
  48491. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  48492. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  48493. import { Scene } from "babylonjs/scene";
  48494. import { Vector3 } from "babylonjs/Maths/math.vector";
  48495. import "babylonjs/Gamepads/gamepadSceneComponent";
  48496. /**
  48497. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  48498. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  48499. */
  48500. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  48501. /**
  48502. * Creates a new VRDeviceOrientationGamepadCamera
  48503. * @param name defines camera name
  48504. * @param position defines the start position of the camera
  48505. * @param scene defines the scene the camera belongs to
  48506. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  48507. * @param vrCameraMetrics defines the vr metrics associated to the camera
  48508. */
  48509. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  48510. /**
  48511. * Gets camera class name
  48512. * @returns VRDeviceOrientationGamepadCamera
  48513. */
  48514. getClassName(): string;
  48515. }
  48516. }
  48517. declare module "babylonjs/Materials/Textures/dynamicTexture" {
  48518. import { Scene } from "babylonjs/scene";
  48519. import { Texture } from "babylonjs/Materials/Textures/texture";
  48520. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  48521. /**
  48522. * A class extending Texture allowing drawing on a texture
  48523. * @see https://doc.babylonjs.com/how_to/dynamictexture
  48524. */
  48525. export class DynamicTexture extends Texture {
  48526. private _generateMipMaps;
  48527. private _canvas;
  48528. private _context;
  48529. /**
  48530. * Creates a DynamicTexture
  48531. * @param name defines the name of the texture
  48532. * @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
  48533. * @param scene defines the scene where you want the texture
  48534. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  48535. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  48536. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  48537. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  48538. */
  48539. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  48540. /**
  48541. * Get the current class name of the texture useful for serialization or dynamic coding.
  48542. * @returns "DynamicTexture"
  48543. */
  48544. getClassName(): string;
  48545. /**
  48546. * Gets the current state of canRescale
  48547. */
  48548. get canRescale(): boolean;
  48549. private _recreate;
  48550. /**
  48551. * Scales the texture
  48552. * @param ratio the scale factor to apply to both width and height
  48553. */
  48554. scale(ratio: number): void;
  48555. /**
  48556. * Resizes the texture
  48557. * @param width the new width
  48558. * @param height the new height
  48559. */
  48560. scaleTo(width: number, height: number): void;
  48561. /**
  48562. * Gets the context of the canvas used by the texture
  48563. * @returns the canvas context of the dynamic texture
  48564. */
  48565. getContext(): CanvasRenderingContext2D;
  48566. /**
  48567. * Clears the texture
  48568. */
  48569. clear(): void;
  48570. /**
  48571. * Updates the texture
  48572. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48573. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  48574. */
  48575. update(invertY?: boolean, premulAlpha?: boolean): void;
  48576. /**
  48577. * Draws text onto the texture
  48578. * @param text defines the text to be drawn
  48579. * @param x defines the placement of the text from the left
  48580. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  48581. * @param font defines the font to be used with font-style, font-size, font-name
  48582. * @param color defines the color used for the text
  48583. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  48584. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  48585. * @param update defines whether texture is immediately update (default is true)
  48586. */
  48587. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  48588. /**
  48589. * Clones the texture
  48590. * @returns the clone of the texture.
  48591. */
  48592. clone(): DynamicTexture;
  48593. /**
  48594. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  48595. * @returns a serialized dynamic texture object
  48596. */
  48597. serialize(): any;
  48598. private _IsCanvasElement;
  48599. /** @hidden */
  48600. _rebuild(): void;
  48601. }
  48602. }
  48603. declare module "babylonjs/Meshes/Builders/groundBuilder" {
  48604. import { Scene } from "babylonjs/scene";
  48605. import { Color3 } from "babylonjs/Maths/math.color";
  48606. import { Mesh } from "babylonjs/Meshes/mesh";
  48607. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  48608. import { Nullable } from "babylonjs/types";
  48609. /**
  48610. * Class containing static functions to help procedurally build meshes
  48611. */
  48612. export class GroundBuilder {
  48613. /**
  48614. * Creates a ground mesh
  48615. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  48616. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  48617. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  48618. * @param name defines the name of the mesh
  48619. * @param options defines the options used to create the mesh
  48620. * @param scene defines the hosting scene
  48621. * @returns the ground mesh
  48622. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  48623. */
  48624. static CreateGround(name: string, options: {
  48625. width?: number;
  48626. height?: number;
  48627. subdivisions?: number;
  48628. subdivisionsX?: number;
  48629. subdivisionsY?: number;
  48630. updatable?: boolean;
  48631. }, scene: any): Mesh;
  48632. /**
  48633. * Creates a tiled ground mesh
  48634. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  48635. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  48636. * * 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
  48637. * * 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
  48638. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48639. * @param name defines the name of the mesh
  48640. * @param options defines the options used to create the mesh
  48641. * @param scene defines the hosting scene
  48642. * @returns the tiled ground mesh
  48643. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  48644. */
  48645. static CreateTiledGround(name: string, options: {
  48646. xmin: number;
  48647. zmin: number;
  48648. xmax: number;
  48649. zmax: number;
  48650. subdivisions?: {
  48651. w: number;
  48652. h: number;
  48653. };
  48654. precision?: {
  48655. w: number;
  48656. h: number;
  48657. };
  48658. updatable?: boolean;
  48659. }, scene?: Nullable<Scene>): Mesh;
  48660. /**
  48661. * Creates a ground mesh from a height map
  48662. * * The parameter `url` sets the URL of the height map image resource.
  48663. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  48664. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  48665. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  48666. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  48667. * * 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.
  48668. * * 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).
  48669. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  48670. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48671. * @param name defines the name of the mesh
  48672. * @param url defines the url to the height map
  48673. * @param options defines the options used to create the mesh
  48674. * @param scene defines the hosting scene
  48675. * @returns the ground mesh
  48676. * @see https://doc.babylonjs.com/babylon101/height_map
  48677. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  48678. */
  48679. static CreateGroundFromHeightMap(name: string, url: string, options: {
  48680. width?: number;
  48681. height?: number;
  48682. subdivisions?: number;
  48683. minHeight?: number;
  48684. maxHeight?: number;
  48685. colorFilter?: Color3;
  48686. alphaFilter?: number;
  48687. updatable?: boolean;
  48688. onReady?: (mesh: GroundMesh) => void;
  48689. }, scene?: Nullable<Scene>): GroundMesh;
  48690. }
  48691. }
  48692. declare module "babylonjs/Meshes/Builders/torusBuilder" {
  48693. import { Vector4 } from "babylonjs/Maths/math.vector";
  48694. import { Mesh } from "babylonjs/Meshes/mesh";
  48695. /**
  48696. * Class containing static functions to help procedurally build meshes
  48697. */
  48698. export class TorusBuilder {
  48699. /**
  48700. * Creates a torus mesh
  48701. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  48702. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  48703. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  48704. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48705. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48706. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48707. * @param name defines the name of the mesh
  48708. * @param options defines the options used to create the mesh
  48709. * @param scene defines the hosting scene
  48710. * @returns the torus mesh
  48711. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  48712. */
  48713. static CreateTorus(name: string, options: {
  48714. diameter?: number;
  48715. thickness?: number;
  48716. tessellation?: number;
  48717. updatable?: boolean;
  48718. sideOrientation?: number;
  48719. frontUVs?: Vector4;
  48720. backUVs?: Vector4;
  48721. }, scene: any): Mesh;
  48722. }
  48723. }
  48724. declare module "babylonjs/Meshes/Builders/cylinderBuilder" {
  48725. import { Vector4 } from "babylonjs/Maths/math.vector";
  48726. import { Color4 } from "babylonjs/Maths/math.color";
  48727. import { Mesh } from "babylonjs/Meshes/mesh";
  48728. /**
  48729. * Class containing static functions to help procedurally build meshes
  48730. */
  48731. export class CylinderBuilder {
  48732. /**
  48733. * Creates a cylinder or a cone mesh
  48734. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  48735. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  48736. * * 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.
  48737. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  48738. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  48739. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  48740. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  48741. * * 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).
  48742. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  48743. * * 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).
  48744. * * 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
  48745. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  48746. * * 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
  48747. * * 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.
  48748. * * If `enclose` is false, a ring surface is one element.
  48749. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  48750. * * 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
  48751. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  48752. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  48753. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  48754. * @param name defines the name of the mesh
  48755. * @param options defines the options used to create the mesh
  48756. * @param scene defines the hosting scene
  48757. * @returns the cylinder mesh
  48758. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  48759. */
  48760. static CreateCylinder(name: string, options: {
  48761. height?: number;
  48762. diameterTop?: number;
  48763. diameterBottom?: number;
  48764. diameter?: number;
  48765. tessellation?: number;
  48766. subdivisions?: number;
  48767. arc?: number;
  48768. faceColors?: Color4[];
  48769. faceUV?: Vector4[];
  48770. updatable?: boolean;
  48771. hasRings?: boolean;
  48772. enclose?: boolean;
  48773. cap?: number;
  48774. sideOrientation?: number;
  48775. frontUVs?: Vector4;
  48776. backUVs?: Vector4;
  48777. }, scene: any): Mesh;
  48778. }
  48779. }
  48780. declare module "babylonjs/XR/webXRTypes" {
  48781. import { Nullable } from "babylonjs/types";
  48782. import { IDisposable } from "babylonjs/scene";
  48783. /**
  48784. * States of the webXR experience
  48785. */
  48786. export enum WebXRState {
  48787. /**
  48788. * Transitioning to being in XR mode
  48789. */
  48790. ENTERING_XR = 0,
  48791. /**
  48792. * Transitioning to non XR mode
  48793. */
  48794. EXITING_XR = 1,
  48795. /**
  48796. * In XR mode and presenting
  48797. */
  48798. IN_XR = 2,
  48799. /**
  48800. * Not entered XR mode
  48801. */
  48802. NOT_IN_XR = 3
  48803. }
  48804. /**
  48805. * Abstraction of the XR render target
  48806. */
  48807. export interface WebXRRenderTarget extends IDisposable {
  48808. /**
  48809. * xrpresent context of the canvas which can be used to display/mirror xr content
  48810. */
  48811. canvasContext: WebGLRenderingContext;
  48812. /**
  48813. * xr layer for the canvas
  48814. */
  48815. xrLayer: Nullable<XRWebGLLayer>;
  48816. /**
  48817. * Initializes the xr layer for the session
  48818. * @param xrSession xr session
  48819. * @returns a promise that will resolve once the XR Layer has been created
  48820. */
  48821. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48822. }
  48823. }
  48824. declare module "babylonjs/XR/webXRManagedOutputCanvas" {
  48825. import { Nullable } from "babylonjs/types";
  48826. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  48827. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48828. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  48829. import { Observable } from "babylonjs/Misc/observable";
  48830. /**
  48831. * COnfiguration object for WebXR output canvas
  48832. */
  48833. export class WebXRManagedOutputCanvasOptions {
  48834. /**
  48835. * An optional canvas in case you wish to create it yourself and provide it here.
  48836. * If not provided, a new canvas will be created
  48837. */
  48838. canvasElement?: HTMLCanvasElement;
  48839. /**
  48840. * Options for this XR Layer output
  48841. */
  48842. canvasOptions?: XRWebGLLayerOptions;
  48843. /**
  48844. * CSS styling for a newly created canvas (if not provided)
  48845. */
  48846. newCanvasCssStyle?: string;
  48847. /**
  48848. * Get the default values of the configuration object
  48849. * @param engine defines the engine to use (can be null)
  48850. * @returns default values of this configuration object
  48851. */
  48852. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  48853. }
  48854. /**
  48855. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  48856. */
  48857. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  48858. private _options;
  48859. private _canvas;
  48860. private _engine;
  48861. private _originalCanvasSize;
  48862. /**
  48863. * Rendering context of the canvas which can be used to display/mirror xr content
  48864. */
  48865. canvasContext: WebGLRenderingContext;
  48866. /**
  48867. * xr layer for the canvas
  48868. */
  48869. xrLayer: Nullable<XRWebGLLayer>;
  48870. /**
  48871. * Obseervers registered here will be triggered when the xr layer was initialized
  48872. */
  48873. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  48874. /**
  48875. * Initializes the canvas to be added/removed upon entering/exiting xr
  48876. * @param _xrSessionManager The XR Session manager
  48877. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  48878. */
  48879. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  48880. /**
  48881. * Disposes of the object
  48882. */
  48883. dispose(): void;
  48884. /**
  48885. * Initializes the xr layer for the session
  48886. * @param xrSession xr session
  48887. * @returns a promise that will resolve once the XR Layer has been created
  48888. */
  48889. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  48890. private _addCanvas;
  48891. private _removeCanvas;
  48892. private _setCanvasSize;
  48893. private _setManagedOutputCanvas;
  48894. }
  48895. }
  48896. declare module "babylonjs/XR/webXRSessionManager" {
  48897. import { Observable } from "babylonjs/Misc/observable";
  48898. import { Nullable } from "babylonjs/types";
  48899. import { IDisposable, Scene } from "babylonjs/scene";
  48900. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  48901. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  48902. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  48903. /**
  48904. * Manages an XRSession to work with Babylon's engine
  48905. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  48906. */
  48907. export class WebXRSessionManager implements IDisposable {
  48908. /** The scene which the session should be created for */
  48909. scene: Scene;
  48910. private _referenceSpace;
  48911. private _rttProvider;
  48912. private _sessionEnded;
  48913. private _xrNavigator;
  48914. private baseLayer;
  48915. /**
  48916. * The base reference space from which the session started. good if you want to reset your
  48917. * reference space
  48918. */
  48919. baseReferenceSpace: XRReferenceSpace;
  48920. /**
  48921. * Current XR frame
  48922. */
  48923. currentFrame: Nullable<XRFrame>;
  48924. /** WebXR timestamp updated every frame */
  48925. currentTimestamp: number;
  48926. /**
  48927. * Used just in case of a failure to initialize an immersive session.
  48928. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  48929. */
  48930. defaultHeightCompensation: number;
  48931. /**
  48932. * Fires every time a new xrFrame arrives which can be used to update the camera
  48933. */
  48934. onXRFrameObservable: Observable<XRFrame>;
  48935. /**
  48936. * Fires when the reference space changed
  48937. */
  48938. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  48939. /**
  48940. * Fires when the xr session is ended either by the device or manually done
  48941. */
  48942. onXRSessionEnded: Observable<any>;
  48943. /**
  48944. * Fires when the xr session is ended either by the device or manually done
  48945. */
  48946. onXRSessionInit: Observable<XRSession>;
  48947. /**
  48948. * Underlying xr session
  48949. */
  48950. session: XRSession;
  48951. /**
  48952. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  48953. * or get the offset the player is currently at.
  48954. */
  48955. viewerReferenceSpace: XRReferenceSpace;
  48956. /**
  48957. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  48958. * @param scene The scene which the session should be created for
  48959. */
  48960. constructor(
  48961. /** The scene which the session should be created for */
  48962. scene: Scene);
  48963. /**
  48964. * The current reference space used in this session. This reference space can constantly change!
  48965. * It is mainly used to offset the camera's position.
  48966. */
  48967. get referenceSpace(): XRReferenceSpace;
  48968. /**
  48969. * Set a new reference space and triggers the observable
  48970. */
  48971. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  48972. /**
  48973. * Disposes of the session manager
  48974. */
  48975. dispose(): void;
  48976. /**
  48977. * Stops the xrSession and restores the render loop
  48978. * @returns Promise which resolves after it exits XR
  48979. */
  48980. exitXRAsync(): Promise<void>;
  48981. /**
  48982. * Gets the correct render target texture to be rendered this frame for this eye
  48983. * @param eye the eye for which to get the render target
  48984. * @returns the render target for the specified eye
  48985. */
  48986. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  48987. /**
  48988. * Creates a WebXRRenderTarget object for the XR session
  48989. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  48990. * @param options optional options to provide when creating a new render target
  48991. * @returns a WebXR render target to which the session can render
  48992. */
  48993. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  48994. /**
  48995. * Initializes the manager
  48996. * After initialization enterXR can be called to start an XR session
  48997. * @returns Promise which resolves after it is initialized
  48998. */
  48999. initializeAsync(): Promise<void>;
  49000. /**
  49001. * Initializes an xr session
  49002. * @param xrSessionMode mode to initialize
  49003. * @param xrSessionInit defines optional and required values to pass to the session builder
  49004. * @returns a promise which will resolve once the session has been initialized
  49005. */
  49006. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  49007. /**
  49008. * Checks if a session would be supported for the creation options specified
  49009. * @param sessionMode session mode to check if supported eg. immersive-vr
  49010. * @returns A Promise that resolves to true if supported and false if not
  49011. */
  49012. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49013. /**
  49014. * Resets the reference space to the one started the session
  49015. */
  49016. resetReferenceSpace(): void;
  49017. /**
  49018. * Starts rendering to the xr layer
  49019. */
  49020. runXRRenderLoop(): void;
  49021. /**
  49022. * Sets the reference space on the xr session
  49023. * @param referenceSpaceType space to set
  49024. * @returns a promise that will resolve once the reference space has been set
  49025. */
  49026. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  49027. /**
  49028. * Updates the render state of the session
  49029. * @param state state to set
  49030. * @returns a promise that resolves once the render state has been updated
  49031. */
  49032. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  49033. /**
  49034. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  49035. * @param sessionMode defines the session to test
  49036. * @returns a promise with boolean as final value
  49037. */
  49038. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  49039. private _createRenderTargetTexture;
  49040. }
  49041. }
  49042. declare module "babylonjs/XR/webXRCamera" {
  49043. import { Vector3 } from "babylonjs/Maths/math.vector";
  49044. import { Scene } from "babylonjs/scene";
  49045. import { Camera } from "babylonjs/Cameras/camera";
  49046. import { FreeCamera } from "babylonjs/Cameras/freeCamera";
  49047. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49048. import { Observable } from "babylonjs/Misc/observable";
  49049. /**
  49050. * WebXR Camera which holds the views for the xrSession
  49051. * @see https://doc.babylonjs.com/how_to/webxr_camera
  49052. */
  49053. export class WebXRCamera extends FreeCamera {
  49054. private _xrSessionManager;
  49055. private _firstFrame;
  49056. private _referenceQuaternion;
  49057. private _referencedPosition;
  49058. private _xrInvPositionCache;
  49059. private _xrInvQuaternionCache;
  49060. /**
  49061. * Observable raised before camera teleportation
  49062. */
  49063. onBeforeCameraTeleport: Observable<Vector3>;
  49064. /**
  49065. * Observable raised after camera teleportation
  49066. */
  49067. onAfterCameraTeleport: Observable<Vector3>;
  49068. /**
  49069. * Should position compensation execute on first frame.
  49070. * This is used when copying the position from a native (non XR) camera
  49071. */
  49072. compensateOnFirstFrame: boolean;
  49073. /**
  49074. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  49075. * @param name the name of the camera
  49076. * @param scene the scene to add the camera to
  49077. * @param _xrSessionManager a constructed xr session manager
  49078. */
  49079. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  49080. /**
  49081. * Return the user's height, unrelated to the current ground.
  49082. * This will be the y position of this camera, when ground level is 0.
  49083. */
  49084. get realWorldHeight(): number;
  49085. /** @hidden */
  49086. _updateForDualEyeDebugging(): void;
  49087. /**
  49088. * Sets this camera's transformation based on a non-vr camera
  49089. * @param otherCamera the non-vr camera to copy the transformation from
  49090. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  49091. */
  49092. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  49093. /**
  49094. * Gets the current instance class name ("WebXRCamera").
  49095. * @returns the class name
  49096. */
  49097. getClassName(): string;
  49098. private _rotate180;
  49099. private _updateFromXRSession;
  49100. private _updateNumberOfRigCameras;
  49101. private _updateReferenceSpace;
  49102. private _updateReferenceSpaceOffset;
  49103. }
  49104. }
  49105. declare module "babylonjs/XR/webXRFeaturesManager" {
  49106. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49107. import { IDisposable } from "babylonjs/scene";
  49108. /**
  49109. * Defining the interface required for a (webxr) feature
  49110. */
  49111. export interface IWebXRFeature extends IDisposable {
  49112. /**
  49113. * Is this feature attached
  49114. */
  49115. attached: boolean;
  49116. /**
  49117. * Should auto-attach be disabled?
  49118. */
  49119. disableAutoAttach: boolean;
  49120. /**
  49121. * Attach the feature to the session
  49122. * Will usually be called by the features manager
  49123. *
  49124. * @param force should attachment be forced (even when already attached)
  49125. * @returns true if successful.
  49126. */
  49127. attach(force?: boolean): boolean;
  49128. /**
  49129. * Detach the feature from the session
  49130. * Will usually be called by the features manager
  49131. *
  49132. * @returns true if successful.
  49133. */
  49134. detach(): boolean;
  49135. /**
  49136. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  49137. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  49138. *
  49139. * @returns whether or not the feature is compatible in this environment
  49140. */
  49141. isCompatible(): boolean;
  49142. /**
  49143. * Was this feature disposed;
  49144. */
  49145. isDisposed: boolean;
  49146. /**
  49147. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  49148. */
  49149. xrNativeFeatureName?: string;
  49150. /**
  49151. * A list of (Babylon WebXR) features this feature depends on
  49152. */
  49153. dependsOn?: string[];
  49154. }
  49155. /**
  49156. * A list of the currently available features without referencing them
  49157. */
  49158. export class WebXRFeatureName {
  49159. /**
  49160. * The name of the anchor system feature
  49161. */
  49162. static readonly ANCHOR_SYSTEM: string;
  49163. /**
  49164. * The name of the background remover feature
  49165. */
  49166. static readonly BACKGROUND_REMOVER: string;
  49167. /**
  49168. * The name of the hit test feature
  49169. */
  49170. static readonly HIT_TEST: string;
  49171. /**
  49172. * physics impostors for xr controllers feature
  49173. */
  49174. static readonly PHYSICS_CONTROLLERS: string;
  49175. /**
  49176. * The name of the plane detection feature
  49177. */
  49178. static readonly PLANE_DETECTION: string;
  49179. /**
  49180. * The name of the pointer selection feature
  49181. */
  49182. static readonly POINTER_SELECTION: string;
  49183. /**
  49184. * The name of the teleportation feature
  49185. */
  49186. static readonly TELEPORTATION: string;
  49187. /**
  49188. * The name of the feature points feature.
  49189. */
  49190. static readonly FEATURE_POINTS: string;
  49191. /**
  49192. * The name of the hand tracking feature.
  49193. */
  49194. static readonly HAND_TRACKING: string;
  49195. }
  49196. /**
  49197. * Defining the constructor of a feature. Used to register the modules.
  49198. */
  49199. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  49200. /**
  49201. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  49202. * It is mainly used in AR sessions.
  49203. *
  49204. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  49205. */
  49206. export class WebXRFeaturesManager implements IDisposable {
  49207. private _xrSessionManager;
  49208. private static readonly _AvailableFeatures;
  49209. private _features;
  49210. /**
  49211. * constructs a new features manages.
  49212. *
  49213. * @param _xrSessionManager an instance of WebXRSessionManager
  49214. */
  49215. constructor(_xrSessionManager: WebXRSessionManager);
  49216. /**
  49217. * Used to register a module. After calling this function a developer can use this feature in the scene.
  49218. * Mainly used internally.
  49219. *
  49220. * @param featureName the name of the feature to register
  49221. * @param constructorFunction the function used to construct the module
  49222. * @param version the (babylon) version of the module
  49223. * @param stable is that a stable version of this module
  49224. */
  49225. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  49226. /**
  49227. * Returns a constructor of a specific feature.
  49228. *
  49229. * @param featureName the name of the feature to construct
  49230. * @param version the version of the feature to load
  49231. * @param xrSessionManager the xrSessionManager. Used to construct the module
  49232. * @param options optional options provided to the module.
  49233. * @returns a function that, when called, will return a new instance of this feature
  49234. */
  49235. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  49236. /**
  49237. * Can be used to return the list of features currently registered
  49238. *
  49239. * @returns an Array of available features
  49240. */
  49241. static GetAvailableFeatures(): string[];
  49242. /**
  49243. * Gets the versions available for a specific feature
  49244. * @param featureName the name of the feature
  49245. * @returns an array with the available versions
  49246. */
  49247. static GetAvailableVersions(featureName: string): string[];
  49248. /**
  49249. * Return the latest unstable version of this feature
  49250. * @param featureName the name of the feature to search
  49251. * @returns the version number. if not found will return -1
  49252. */
  49253. static GetLatestVersionOfFeature(featureName: string): number;
  49254. /**
  49255. * Return the latest stable version of this feature
  49256. * @param featureName the name of the feature to search
  49257. * @returns the version number. if not found will return -1
  49258. */
  49259. static GetStableVersionOfFeature(featureName: string): number;
  49260. /**
  49261. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  49262. * Can be used during a session to start a feature
  49263. * @param featureName the name of feature to attach
  49264. */
  49265. attachFeature(featureName: string): void;
  49266. /**
  49267. * Can be used inside a session or when the session ends to detach a specific feature
  49268. * @param featureName the name of the feature to detach
  49269. */
  49270. detachFeature(featureName: string): void;
  49271. /**
  49272. * Used to disable an already-enabled feature
  49273. * The feature will be disposed and will be recreated once enabled.
  49274. * @param featureName the feature to disable
  49275. * @returns true if disable was successful
  49276. */
  49277. disableFeature(featureName: string | {
  49278. Name: string;
  49279. }): boolean;
  49280. /**
  49281. * dispose this features manager
  49282. */
  49283. dispose(): void;
  49284. /**
  49285. * 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.
  49286. * 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.
  49287. *
  49288. * @param featureName the name of the feature to load or the class of the feature
  49289. * @param version optional version to load. if not provided the latest version will be enabled
  49290. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  49291. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  49292. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  49293. * @returns a new constructed feature or throws an error if feature not found.
  49294. */
  49295. enableFeature(featureName: string | {
  49296. Name: string;
  49297. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  49298. /**
  49299. * get the implementation of an enabled feature.
  49300. * @param featureName the name of the feature to load
  49301. * @returns the feature class, if found
  49302. */
  49303. getEnabledFeature(featureName: string): IWebXRFeature;
  49304. /**
  49305. * Get the list of enabled features
  49306. * @returns an array of enabled features
  49307. */
  49308. getEnabledFeatures(): string[];
  49309. /**
  49310. * This function will exten the session creation configuration object with enabled features.
  49311. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  49312. * according to the defined "required" variable, provided during enableFeature call
  49313. * @param xrSessionInit the xr Session init object to extend
  49314. *
  49315. * @returns an extended XRSessionInit object
  49316. */
  49317. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  49318. }
  49319. }
  49320. declare module "babylonjs/XR/webXRExperienceHelper" {
  49321. import { Observable } from "babylonjs/Misc/observable";
  49322. import { IDisposable, Scene } from "babylonjs/scene";
  49323. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  49324. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  49325. import { WebXRState, WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  49326. import { WebXRFeaturesManager } from "babylonjs/XR/webXRFeaturesManager";
  49327. /**
  49328. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  49329. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  49330. */
  49331. export class WebXRExperienceHelper implements IDisposable {
  49332. private scene;
  49333. private _nonVRCamera;
  49334. private _originalSceneAutoClear;
  49335. private _supported;
  49336. /**
  49337. * Camera used to render xr content
  49338. */
  49339. camera: WebXRCamera;
  49340. /** A features manager for this xr session */
  49341. featuresManager: WebXRFeaturesManager;
  49342. /**
  49343. * Observers registered here will be triggered after the camera's initial transformation is set
  49344. * This can be used to set a different ground level or an extra rotation.
  49345. *
  49346. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  49347. * to the position set after this observable is done executing.
  49348. */
  49349. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  49350. /**
  49351. * Fires when the state of the experience helper has changed
  49352. */
  49353. onStateChangedObservable: Observable<WebXRState>;
  49354. /** Session manager used to keep track of xr session */
  49355. sessionManager: WebXRSessionManager;
  49356. /**
  49357. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  49358. */
  49359. state: WebXRState;
  49360. /**
  49361. * Creates a WebXRExperienceHelper
  49362. * @param scene The scene the helper should be created in
  49363. */
  49364. private constructor();
  49365. /**
  49366. * Creates the experience helper
  49367. * @param scene the scene to attach the experience helper to
  49368. * @returns a promise for the experience helper
  49369. */
  49370. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  49371. /**
  49372. * Disposes of the experience helper
  49373. */
  49374. dispose(): void;
  49375. /**
  49376. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  49377. * @param sessionMode options for the XR session
  49378. * @param referenceSpaceType frame of reference of the XR session
  49379. * @param renderTarget the output canvas that will be used to enter XR mode
  49380. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  49381. * @returns promise that resolves after xr mode has entered
  49382. */
  49383. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  49384. /**
  49385. * Exits XR mode and returns the scene to its original state
  49386. * @returns promise that resolves after xr mode has exited
  49387. */
  49388. exitXRAsync(): Promise<void>;
  49389. private _nonXRToXRCamera;
  49390. private _setState;
  49391. }
  49392. }
  49393. declare module "babylonjs/XR/motionController/webXRControllerComponent" {
  49394. import { IMinimalMotionControllerObject, MotionControllerComponentType } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  49395. import { Observable } from "babylonjs/Misc/observable";
  49396. import { IDisposable } from "babylonjs/scene";
  49397. /**
  49398. * X-Y values for axes in WebXR
  49399. */
  49400. export interface IWebXRMotionControllerAxesValue {
  49401. /**
  49402. * The value of the x axis
  49403. */
  49404. x: number;
  49405. /**
  49406. * The value of the y-axis
  49407. */
  49408. y: number;
  49409. }
  49410. /**
  49411. * changed / previous values for the values of this component
  49412. */
  49413. export interface IWebXRMotionControllerComponentChangesValues<T> {
  49414. /**
  49415. * current (this frame) value
  49416. */
  49417. current: T;
  49418. /**
  49419. * previous (last change) value
  49420. */
  49421. previous: T;
  49422. }
  49423. /**
  49424. * Represents changes in the component between current frame and last values recorded
  49425. */
  49426. export interface IWebXRMotionControllerComponentChanges {
  49427. /**
  49428. * will be populated with previous and current values if axes changed
  49429. */
  49430. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  49431. /**
  49432. * will be populated with previous and current values if pressed changed
  49433. */
  49434. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49435. /**
  49436. * will be populated with previous and current values if touched changed
  49437. */
  49438. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  49439. /**
  49440. * will be populated with previous and current values if value changed
  49441. */
  49442. value?: IWebXRMotionControllerComponentChangesValues<number>;
  49443. }
  49444. /**
  49445. * This class represents a single component (for example button or thumbstick) of a motion controller
  49446. */
  49447. export class WebXRControllerComponent implements IDisposable {
  49448. /**
  49449. * the id of this component
  49450. */
  49451. id: string;
  49452. /**
  49453. * the type of the component
  49454. */
  49455. type: MotionControllerComponentType;
  49456. private _buttonIndex;
  49457. private _axesIndices;
  49458. private _axes;
  49459. private _changes;
  49460. private _currentValue;
  49461. private _hasChanges;
  49462. private _pressed;
  49463. private _touched;
  49464. /**
  49465. * button component type
  49466. */
  49467. static BUTTON_TYPE: MotionControllerComponentType;
  49468. /**
  49469. * squeeze component type
  49470. */
  49471. static SQUEEZE_TYPE: MotionControllerComponentType;
  49472. /**
  49473. * Thumbstick component type
  49474. */
  49475. static THUMBSTICK_TYPE: MotionControllerComponentType;
  49476. /**
  49477. * Touchpad component type
  49478. */
  49479. static TOUCHPAD_TYPE: MotionControllerComponentType;
  49480. /**
  49481. * trigger component type
  49482. */
  49483. static TRIGGER_TYPE: MotionControllerComponentType;
  49484. /**
  49485. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  49486. * the axes data changes
  49487. */
  49488. onAxisValueChangedObservable: Observable<{
  49489. x: number;
  49490. y: number;
  49491. }>;
  49492. /**
  49493. * Observers registered here will be triggered when the state of a button changes
  49494. * State change is either pressed / touched / value
  49495. */
  49496. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  49497. /**
  49498. * Creates a new component for a motion controller.
  49499. * It is created by the motion controller itself
  49500. *
  49501. * @param id the id of this component
  49502. * @param type the type of the component
  49503. * @param _buttonIndex index in the buttons array of the gamepad
  49504. * @param _axesIndices indices of the values in the axes array of the gamepad
  49505. */
  49506. constructor(
  49507. /**
  49508. * the id of this component
  49509. */
  49510. id: string,
  49511. /**
  49512. * the type of the component
  49513. */
  49514. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  49515. /**
  49516. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  49517. */
  49518. get axes(): IWebXRMotionControllerAxesValue;
  49519. /**
  49520. * Get the changes. Elements will be populated only if they changed with their previous and current value
  49521. */
  49522. get changes(): IWebXRMotionControllerComponentChanges;
  49523. /**
  49524. * Return whether or not the component changed the last frame
  49525. */
  49526. get hasChanges(): boolean;
  49527. /**
  49528. * is the button currently pressed
  49529. */
  49530. get pressed(): boolean;
  49531. /**
  49532. * is the button currently touched
  49533. */
  49534. get touched(): boolean;
  49535. /**
  49536. * Get the current value of this component
  49537. */
  49538. get value(): number;
  49539. /**
  49540. * Dispose this component
  49541. */
  49542. dispose(): void;
  49543. /**
  49544. * Are there axes correlating to this component
  49545. * @return true is axes data is available
  49546. */
  49547. isAxes(): boolean;
  49548. /**
  49549. * Is this component a button (hence - pressable)
  49550. * @returns true if can be pressed
  49551. */
  49552. isButton(): boolean;
  49553. /**
  49554. * update this component using the gamepad object it is in. Called on every frame
  49555. * @param nativeController the native gamepad controller object
  49556. */
  49557. update(nativeController: IMinimalMotionControllerObject): void;
  49558. }
  49559. }
  49560. declare module "babylonjs/Loading/sceneLoader" {
  49561. import { Observable } from "babylonjs/Misc/observable";
  49562. import { Nullable } from "babylonjs/types";
  49563. import { Scene } from "babylonjs/scene";
  49564. import { Engine } from "babylonjs/Engines/engine";
  49565. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49566. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  49567. import { AssetContainer } from "babylonjs/assetContainer";
  49568. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  49569. import { Skeleton } from "babylonjs/Bones/skeleton";
  49570. import { IFileRequest } from "babylonjs/Misc/fileRequest";
  49571. import { WebRequest } from "babylonjs/Misc/webRequest";
  49572. /**
  49573. * Interface used to represent data loading progression
  49574. */
  49575. export interface ISceneLoaderProgressEvent {
  49576. /**
  49577. * Defines if data length to load can be evaluated
  49578. */
  49579. readonly lengthComputable: boolean;
  49580. /**
  49581. * Defines the loaded data length
  49582. */
  49583. readonly loaded: number;
  49584. /**
  49585. * Defines the data length to load
  49586. */
  49587. readonly total: number;
  49588. }
  49589. /**
  49590. * Interface used by SceneLoader plugins to define supported file extensions
  49591. */
  49592. export interface ISceneLoaderPluginExtensions {
  49593. /**
  49594. * Defines the list of supported extensions
  49595. */
  49596. [extension: string]: {
  49597. isBinary: boolean;
  49598. };
  49599. }
  49600. /**
  49601. * Interface used by SceneLoader plugin factory
  49602. */
  49603. export interface ISceneLoaderPluginFactory {
  49604. /**
  49605. * Defines the name of the factory
  49606. */
  49607. name: string;
  49608. /**
  49609. * Function called to create a new plugin
  49610. * @return the new plugin
  49611. */
  49612. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  49613. /**
  49614. * The callback that returns true if the data can be directly loaded.
  49615. * @param data string containing the file data
  49616. * @returns if the data can be loaded directly
  49617. */
  49618. canDirectLoad?(data: string): boolean;
  49619. }
  49620. /**
  49621. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  49622. */
  49623. export interface ISceneLoaderPluginBase {
  49624. /**
  49625. * The friendly name of this plugin.
  49626. */
  49627. name: string;
  49628. /**
  49629. * The file extensions supported by this plugin.
  49630. */
  49631. extensions: string | ISceneLoaderPluginExtensions;
  49632. /**
  49633. * The callback called when loading from a url.
  49634. * @param scene scene loading this url
  49635. * @param url url to load
  49636. * @param onSuccess callback called when the file successfully loads
  49637. * @param onProgress callback called while file is loading (if the server supports this mode)
  49638. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  49639. * @param onError callback called when the file fails to load
  49640. * @returns a file request object
  49641. */
  49642. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49643. /**
  49644. * The callback called when loading from a file object.
  49645. * @param scene scene loading this file
  49646. * @param file defines the file to load
  49647. * @param onSuccess defines the callback to call when data is loaded
  49648. * @param onProgress defines the callback to call during loading process
  49649. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  49650. * @param onError defines the callback to call when an error occurs
  49651. * @returns a file request object
  49652. */
  49653. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  49654. /**
  49655. * The callback that returns true if the data can be directly loaded.
  49656. * @param data string containing the file data
  49657. * @returns if the data can be loaded directly
  49658. */
  49659. canDirectLoad?(data: string): boolean;
  49660. /**
  49661. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  49662. * @param scene scene loading this data
  49663. * @param data string containing the data
  49664. * @returns data to pass to the plugin
  49665. */
  49666. directLoad?(scene: Scene, data: string): any;
  49667. /**
  49668. * The callback that allows custom handling of the root url based on the response url.
  49669. * @param rootUrl the original root url
  49670. * @param responseURL the response url if available
  49671. * @returns the new root url
  49672. */
  49673. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  49674. }
  49675. /**
  49676. * Interface used to define a SceneLoader plugin
  49677. */
  49678. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  49679. /**
  49680. * Import meshes into a scene.
  49681. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49682. * @param scene The scene to import into
  49683. * @param data The data to import
  49684. * @param rootUrl The root url for scene and resources
  49685. * @param meshes The meshes array to import into
  49686. * @param particleSystems The particle systems array to import into
  49687. * @param skeletons The skeletons array to import into
  49688. * @param onError The callback when import fails
  49689. * @returns True if successful or false otherwise
  49690. */
  49691. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  49692. /**
  49693. * Load into a scene.
  49694. * @param scene The scene to load into
  49695. * @param data The data to import
  49696. * @param rootUrl The root url for scene and resources
  49697. * @param onError The callback when import fails
  49698. * @returns True if successful or false otherwise
  49699. */
  49700. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  49701. /**
  49702. * Load into an asset container.
  49703. * @param scene The scene to load into
  49704. * @param data The data to import
  49705. * @param rootUrl The root url for scene and resources
  49706. * @param onError The callback when import fails
  49707. * @returns The loaded asset container
  49708. */
  49709. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  49710. }
  49711. /**
  49712. * Interface used to define an async SceneLoader plugin
  49713. */
  49714. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  49715. /**
  49716. * Import meshes into a scene.
  49717. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49718. * @param scene The scene to import into
  49719. * @param data The data to import
  49720. * @param rootUrl The root url for scene and resources
  49721. * @param onProgress The callback when the load progresses
  49722. * @param fileName Defines the name of the file to load
  49723. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  49724. */
  49725. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  49726. meshes: AbstractMesh[];
  49727. particleSystems: IParticleSystem[];
  49728. skeletons: Skeleton[];
  49729. animationGroups: AnimationGroup[];
  49730. }>;
  49731. /**
  49732. * Load into a scene.
  49733. * @param scene The scene to load into
  49734. * @param data The data to import
  49735. * @param rootUrl The root url for scene and resources
  49736. * @param onProgress The callback when the load progresses
  49737. * @param fileName Defines the name of the file to load
  49738. * @returns Nothing
  49739. */
  49740. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  49741. /**
  49742. * Load into an asset container.
  49743. * @param scene The scene to load into
  49744. * @param data The data to import
  49745. * @param rootUrl The root url for scene and resources
  49746. * @param onProgress The callback when the load progresses
  49747. * @param fileName Defines the name of the file to load
  49748. * @returns The loaded asset container
  49749. */
  49750. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  49751. }
  49752. /**
  49753. * Mode that determines how to handle old animation groups before loading new ones.
  49754. */
  49755. export enum SceneLoaderAnimationGroupLoadingMode {
  49756. /**
  49757. * Reset all old animations to initial state then dispose them.
  49758. */
  49759. Clean = 0,
  49760. /**
  49761. * Stop all old animations.
  49762. */
  49763. Stop = 1,
  49764. /**
  49765. * Restart old animations from first frame.
  49766. */
  49767. Sync = 2,
  49768. /**
  49769. * Old animations remains untouched.
  49770. */
  49771. NoSync = 3
  49772. }
  49773. /**
  49774. * Defines a plugin registered by the SceneLoader
  49775. */
  49776. interface IRegisteredPlugin {
  49777. /**
  49778. * Defines the plugin to use
  49779. */
  49780. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49781. /**
  49782. * Defines if the plugin supports binary data
  49783. */
  49784. isBinary: boolean;
  49785. }
  49786. /**
  49787. * Class used to load scene from various file formats using registered plugins
  49788. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  49789. */
  49790. export class SceneLoader {
  49791. /**
  49792. * No logging while loading
  49793. */
  49794. static readonly NO_LOGGING: number;
  49795. /**
  49796. * Minimal logging while loading
  49797. */
  49798. static readonly MINIMAL_LOGGING: number;
  49799. /**
  49800. * Summary logging while loading
  49801. */
  49802. static readonly SUMMARY_LOGGING: number;
  49803. /**
  49804. * Detailled logging while loading
  49805. */
  49806. static readonly DETAILED_LOGGING: number;
  49807. /**
  49808. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49809. */
  49810. static get ForceFullSceneLoadingForIncremental(): boolean;
  49811. static set ForceFullSceneLoadingForIncremental(value: boolean);
  49812. /**
  49813. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49814. */
  49815. static get ShowLoadingScreen(): boolean;
  49816. static set ShowLoadingScreen(value: boolean);
  49817. /**
  49818. * Defines the current logging level (while loading the scene)
  49819. * @ignorenaming
  49820. */
  49821. static get loggingLevel(): number;
  49822. static set loggingLevel(value: number);
  49823. /**
  49824. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49825. */
  49826. static get CleanBoneMatrixWeights(): boolean;
  49827. static set CleanBoneMatrixWeights(value: boolean);
  49828. /**
  49829. * Event raised when a plugin is used to load a scene
  49830. */
  49831. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  49832. private static _registeredPlugins;
  49833. private static _showingLoadingScreen;
  49834. /**
  49835. * Gets the default plugin (used to load Babylon files)
  49836. * @returns the .babylon plugin
  49837. */
  49838. static GetDefaultPlugin(): IRegisteredPlugin;
  49839. private static _GetPluginForExtension;
  49840. private static _GetPluginForDirectLoad;
  49841. private static _GetPluginForFilename;
  49842. private static _GetDirectLoad;
  49843. private static _LoadData;
  49844. private static _GetFileInfo;
  49845. /**
  49846. * Gets a plugin that can load the given extension
  49847. * @param extension defines the extension to load
  49848. * @returns a plugin or null if none works
  49849. */
  49850. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  49851. /**
  49852. * Gets a boolean indicating that the given extension can be loaded
  49853. * @param extension defines the extension to load
  49854. * @returns true if the extension is supported
  49855. */
  49856. static IsPluginForExtensionAvailable(extension: string): boolean;
  49857. /**
  49858. * Adds a new plugin to the list of registered plugins
  49859. * @param plugin defines the plugin to add
  49860. */
  49861. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  49862. /**
  49863. * Import meshes into a scene
  49864. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49865. * @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)
  49866. * @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)
  49867. * @param scene the instance of BABYLON.Scene to append to
  49868. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  49869. * @param onProgress a callback with a progress event for each file being loaded
  49870. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49871. * @param pluginExtension the extension used to determine the plugin
  49872. * @returns The loaded plugin
  49873. */
  49874. 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>;
  49875. /**
  49876. * Import meshes into a scene
  49877. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  49878. * @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)
  49879. * @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)
  49880. * @param scene the instance of BABYLON.Scene to append to
  49881. * @param onProgress a callback with a progress event for each file being loaded
  49882. * @param pluginExtension the extension used to determine the plugin
  49883. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  49884. */
  49885. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  49886. meshes: AbstractMesh[];
  49887. particleSystems: IParticleSystem[];
  49888. skeletons: Skeleton[];
  49889. animationGroups: AnimationGroup[];
  49890. }>;
  49891. /**
  49892. * Load a scene
  49893. * @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)
  49894. * @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)
  49895. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49896. * @param onSuccess a callback with the scene when import succeeds
  49897. * @param onProgress a callback with a progress event for each file being loaded
  49898. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49899. * @param pluginExtension the extension used to determine the plugin
  49900. * @returns The loaded plugin
  49901. */
  49902. 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>;
  49903. /**
  49904. * Load a scene
  49905. * @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)
  49906. * @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)
  49907. * @param engine is the instance of BABYLON.Engine to use to create the scene
  49908. * @param onProgress a callback with a progress event for each file being loaded
  49909. * @param pluginExtension the extension used to determine the plugin
  49910. * @returns The loaded scene
  49911. */
  49912. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49913. /**
  49914. * Append a scene
  49915. * @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)
  49916. * @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)
  49917. * @param scene is the instance of BABYLON.Scene to append to
  49918. * @param onSuccess a callback with the scene when import succeeds
  49919. * @param onProgress a callback with a progress event for each file being loaded
  49920. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49921. * @param pluginExtension the extension used to determine the plugin
  49922. * @returns The loaded plugin
  49923. */
  49924. 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>;
  49925. /**
  49926. * Append a scene
  49927. * @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)
  49928. * @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)
  49929. * @param scene is the instance of BABYLON.Scene to append to
  49930. * @param onProgress a callback with a progress event for each file being loaded
  49931. * @param pluginExtension the extension used to determine the plugin
  49932. * @returns The given scene
  49933. */
  49934. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  49935. /**
  49936. * Load a scene into an asset container
  49937. * @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)
  49938. * @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)
  49939. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49940. * @param onSuccess a callback with the scene when import succeeds
  49941. * @param onProgress a callback with a progress event for each file being loaded
  49942. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49943. * @param pluginExtension the extension used to determine the plugin
  49944. * @returns The loaded plugin
  49945. */
  49946. 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>;
  49947. /**
  49948. * Load a scene into an asset container
  49949. * @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)
  49950. * @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)
  49951. * @param scene is the instance of Scene to append to
  49952. * @param onProgress a callback with a progress event for each file being loaded
  49953. * @param pluginExtension the extension used to determine the plugin
  49954. * @returns The loaded asset container
  49955. */
  49956. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  49957. /**
  49958. * Import animations from a file into a scene
  49959. * @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)
  49960. * @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)
  49961. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49962. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49963. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49964. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49965. * @param onSuccess a callback with the scene when import succeeds
  49966. * @param onProgress a callback with a progress event for each file being loaded
  49967. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49968. * @param pluginExtension the extension used to determine the plugin
  49969. */
  49970. 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;
  49971. /**
  49972. * Import animations from a file into a scene
  49973. * @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)
  49974. * @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)
  49975. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49976. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  49977. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  49978. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  49979. * @param onSuccess a callback with the scene when import succeeds
  49980. * @param onProgress a callback with a progress event for each file being loaded
  49981. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49982. * @param pluginExtension the extension used to determine the plugin
  49983. * @returns the updated scene with imported animations
  49984. */
  49985. 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>;
  49986. }
  49987. }
  49988. declare module "babylonjs/XR/motionController/webXRAbstractMotionController" {
  49989. import { IDisposable, Scene } from "babylonjs/scene";
  49990. import { WebXRControllerComponent } from "babylonjs/XR/motionController/webXRControllerComponent";
  49991. import { Observable } from "babylonjs/Misc/observable";
  49992. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  49993. import { Nullable } from "babylonjs/types";
  49994. /**
  49995. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  49996. */
  49997. export type MotionControllerHandedness = "none" | "left" | "right";
  49998. /**
  49999. * The type of components available in motion controllers.
  50000. * This is not the name of the component.
  50001. */
  50002. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  50003. /**
  50004. * The state of a controller component
  50005. */
  50006. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  50007. /**
  50008. * The schema of motion controller layout.
  50009. * No object will be initialized using this interface
  50010. * This is used just to define the profile.
  50011. */
  50012. export interface IMotionControllerLayout {
  50013. /**
  50014. * Path to load the assets. Usually relative to the base path
  50015. */
  50016. assetPath: string;
  50017. /**
  50018. * Available components (unsorted)
  50019. */
  50020. components: {
  50021. /**
  50022. * A map of component Ids
  50023. */
  50024. [componentId: string]: {
  50025. /**
  50026. * The type of input the component outputs
  50027. */
  50028. type: MotionControllerComponentType;
  50029. /**
  50030. * The indices of this component in the gamepad object
  50031. */
  50032. gamepadIndices: {
  50033. /**
  50034. * Index of button
  50035. */
  50036. button?: number;
  50037. /**
  50038. * If available, index of x-axis
  50039. */
  50040. xAxis?: number;
  50041. /**
  50042. * If available, index of y-axis
  50043. */
  50044. yAxis?: number;
  50045. };
  50046. /**
  50047. * The mesh's root node name
  50048. */
  50049. rootNodeName: string;
  50050. /**
  50051. * Animation definitions for this model
  50052. */
  50053. visualResponses: {
  50054. [stateKey: string]: {
  50055. /**
  50056. * What property will be animated
  50057. */
  50058. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  50059. /**
  50060. * What states influence this visual response
  50061. */
  50062. states: MotionControllerComponentStateType[];
  50063. /**
  50064. * Type of animation - movement or visibility
  50065. */
  50066. valueNodeProperty: "transform" | "visibility";
  50067. /**
  50068. * Base node name to move. Its position will be calculated according to the min and max nodes
  50069. */
  50070. valueNodeName?: string;
  50071. /**
  50072. * Minimum movement node
  50073. */
  50074. minNodeName?: string;
  50075. /**
  50076. * Max movement node
  50077. */
  50078. maxNodeName?: string;
  50079. };
  50080. };
  50081. /**
  50082. * If touch enabled, what is the name of node to display user feedback
  50083. */
  50084. touchPointNodeName?: string;
  50085. };
  50086. };
  50087. /**
  50088. * Is it xr standard mapping or not
  50089. */
  50090. gamepadMapping: "" | "xr-standard";
  50091. /**
  50092. * Base root node of this entire model
  50093. */
  50094. rootNodeName: string;
  50095. /**
  50096. * Defines the main button component id
  50097. */
  50098. selectComponentId: string;
  50099. }
  50100. /**
  50101. * A definition for the layout map in the input profile
  50102. */
  50103. export interface IMotionControllerLayoutMap {
  50104. /**
  50105. * Layouts with handedness type as a key
  50106. */
  50107. [handedness: string]: IMotionControllerLayout;
  50108. }
  50109. /**
  50110. * The XR Input profile schema
  50111. * Profiles can be found here:
  50112. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  50113. */
  50114. export interface IMotionControllerProfile {
  50115. /**
  50116. * fallback profiles for this profileId
  50117. */
  50118. fallbackProfileIds: string[];
  50119. /**
  50120. * The layout map, with handedness as key
  50121. */
  50122. layouts: IMotionControllerLayoutMap;
  50123. /**
  50124. * The id of this profile
  50125. * correlates to the profile(s) in the xrInput.profiles array
  50126. */
  50127. profileId: string;
  50128. }
  50129. /**
  50130. * A helper-interface for the 3 meshes needed for controller button animation
  50131. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  50132. */
  50133. export interface IMotionControllerButtonMeshMap {
  50134. /**
  50135. * the mesh that defines the pressed value mesh position.
  50136. * This is used to find the max-position of this button
  50137. */
  50138. pressedMesh: AbstractMesh;
  50139. /**
  50140. * the mesh that defines the unpressed value mesh position.
  50141. * This is used to find the min (or initial) position of this button
  50142. */
  50143. unpressedMesh: AbstractMesh;
  50144. /**
  50145. * The mesh that will be changed when value changes
  50146. */
  50147. valueMesh: AbstractMesh;
  50148. }
  50149. /**
  50150. * A helper-interface for the 3 meshes needed for controller axis animation.
  50151. * This will be expanded when touchpad animations are fully supported
  50152. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  50153. */
  50154. export interface IMotionControllerMeshMap {
  50155. /**
  50156. * the mesh that defines the maximum value mesh position.
  50157. */
  50158. maxMesh?: AbstractMesh;
  50159. /**
  50160. * the mesh that defines the minimum value mesh position.
  50161. */
  50162. minMesh?: AbstractMesh;
  50163. /**
  50164. * The mesh that will be changed when axis value changes
  50165. */
  50166. valueMesh?: AbstractMesh;
  50167. }
  50168. /**
  50169. * The elements needed for change-detection of the gamepad objects in motion controllers
  50170. */
  50171. export interface IMinimalMotionControllerObject {
  50172. /**
  50173. * Available axes of this controller
  50174. */
  50175. axes: number[];
  50176. /**
  50177. * An array of available buttons
  50178. */
  50179. buttons: Array<{
  50180. /**
  50181. * Value of the button/trigger
  50182. */
  50183. value: number;
  50184. /**
  50185. * If the button/trigger is currently touched
  50186. */
  50187. touched: boolean;
  50188. /**
  50189. * If the button/trigger is currently pressed
  50190. */
  50191. pressed: boolean;
  50192. }>;
  50193. /**
  50194. * EXPERIMENTAL haptic support.
  50195. */
  50196. hapticActuators?: Array<{
  50197. pulse: (value: number, duration: number) => Promise<boolean>;
  50198. }>;
  50199. }
  50200. /**
  50201. * An Abstract Motion controller
  50202. * This class receives an xrInput and a profile layout and uses those to initialize the components
  50203. * Each component has an observable to check for changes in value and state
  50204. */
  50205. export abstract class WebXRAbstractMotionController implements IDisposable {
  50206. protected scene: Scene;
  50207. protected layout: IMotionControllerLayout;
  50208. /**
  50209. * The gamepad object correlating to this controller
  50210. */
  50211. gamepadObject: IMinimalMotionControllerObject;
  50212. /**
  50213. * handedness (left/right/none) of this controller
  50214. */
  50215. handedness: MotionControllerHandedness;
  50216. private _initComponent;
  50217. private _modelReady;
  50218. /**
  50219. * A map of components (WebXRControllerComponent) in this motion controller
  50220. * Components have a ComponentType and can also have both button and axis definitions
  50221. */
  50222. readonly components: {
  50223. [id: string]: WebXRControllerComponent;
  50224. };
  50225. /**
  50226. * Disable the model's animation. Can be set at any time.
  50227. */
  50228. disableAnimation: boolean;
  50229. /**
  50230. * Observers registered here will be triggered when the model of this controller is done loading
  50231. */
  50232. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  50233. /**
  50234. * The profile id of this motion controller
  50235. */
  50236. abstract profileId: string;
  50237. /**
  50238. * The root mesh of the model. It is null if the model was not yet initialized
  50239. */
  50240. rootMesh: Nullable<AbstractMesh>;
  50241. /**
  50242. * constructs a new abstract motion controller
  50243. * @param scene the scene to which the model of the controller will be added
  50244. * @param layout The profile layout to load
  50245. * @param gamepadObject The gamepad object correlating to this controller
  50246. * @param handedness handedness (left/right/none) of this controller
  50247. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  50248. */
  50249. constructor(scene: Scene, layout: IMotionControllerLayout,
  50250. /**
  50251. * The gamepad object correlating to this controller
  50252. */
  50253. gamepadObject: IMinimalMotionControllerObject,
  50254. /**
  50255. * handedness (left/right/none) of this controller
  50256. */
  50257. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  50258. /**
  50259. * Dispose this controller, the model mesh and all its components
  50260. */
  50261. dispose(): void;
  50262. /**
  50263. * Returns all components of specific type
  50264. * @param type the type to search for
  50265. * @return an array of components with this type
  50266. */
  50267. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  50268. /**
  50269. * get a component based an its component id as defined in layout.components
  50270. * @param id the id of the component
  50271. * @returns the component correlates to the id or undefined if not found
  50272. */
  50273. getComponent(id: string): WebXRControllerComponent;
  50274. /**
  50275. * Get the list of components available in this motion controller
  50276. * @returns an array of strings correlating to available components
  50277. */
  50278. getComponentIds(): string[];
  50279. /**
  50280. * Get the first component of specific type
  50281. * @param type type of component to find
  50282. * @return a controller component or null if not found
  50283. */
  50284. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  50285. /**
  50286. * Get the main (Select) component of this controller as defined in the layout
  50287. * @returns the main component of this controller
  50288. */
  50289. getMainComponent(): WebXRControllerComponent;
  50290. /**
  50291. * Loads the model correlating to this controller
  50292. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  50293. * @returns A promise fulfilled with the result of the model loading
  50294. */
  50295. loadModel(): Promise<boolean>;
  50296. /**
  50297. * Update this model using the current XRFrame
  50298. * @param xrFrame the current xr frame to use and update the model
  50299. */
  50300. updateFromXRFrame(xrFrame: XRFrame): void;
  50301. /**
  50302. * Backwards compatibility due to a deeply-integrated typo
  50303. */
  50304. get handness(): XREye;
  50305. /**
  50306. * Pulse (vibrate) this controller
  50307. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  50308. * Consecutive calls to this function will cancel the last pulse call
  50309. *
  50310. * @param value the strength of the pulse in 0.0...1.0 range
  50311. * @param duration Duration of the pulse in milliseconds
  50312. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  50313. * @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
  50314. */
  50315. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  50316. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50317. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  50318. /**
  50319. * Moves the axis on the controller mesh based on its current state
  50320. * @param axis the index of the axis
  50321. * @param axisValue the value of the axis which determines the meshes new position
  50322. * @hidden
  50323. */
  50324. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  50325. /**
  50326. * Update the model itself with the current frame data
  50327. * @param xrFrame the frame to use for updating the model mesh
  50328. */
  50329. protected updateModel(xrFrame: XRFrame): void;
  50330. /**
  50331. * Get the filename and path for this controller's model
  50332. * @returns a map of filename and path
  50333. */
  50334. protected abstract _getFilenameAndPath(): {
  50335. filename: string;
  50336. path: string;
  50337. };
  50338. /**
  50339. * This function is called before the mesh is loaded. It checks for loading constraints.
  50340. * For example, this function can check if the GLB loader is available
  50341. * If this function returns false, the generic controller will be loaded instead
  50342. * @returns Is the client ready to load the mesh
  50343. */
  50344. protected abstract _getModelLoadingConstraints(): boolean;
  50345. /**
  50346. * This function will be called after the model was successfully loaded and can be used
  50347. * for mesh transformations before it is available for the user
  50348. * @param meshes the loaded meshes
  50349. */
  50350. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  50351. /**
  50352. * Set the root mesh for this controller. Important for the WebXR controller class
  50353. * @param meshes the loaded meshes
  50354. */
  50355. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  50356. /**
  50357. * A function executed each frame that updates the mesh (if needed)
  50358. * @param xrFrame the current xrFrame
  50359. */
  50360. protected abstract _updateModel(xrFrame: XRFrame): void;
  50361. private _getGenericFilenameAndPath;
  50362. private _getGenericParentMesh;
  50363. }
  50364. }
  50365. declare module "babylonjs/XR/motionController/webXRGenericMotionController" {
  50366. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50367. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50368. import { Scene } from "babylonjs/scene";
  50369. /**
  50370. * A generic trigger-only motion controller for WebXR
  50371. */
  50372. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  50373. /**
  50374. * Static version of the profile id of this controller
  50375. */
  50376. static ProfileId: string;
  50377. profileId: string;
  50378. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  50379. protected _getFilenameAndPath(): {
  50380. filename: string;
  50381. path: string;
  50382. };
  50383. protected _getModelLoadingConstraints(): boolean;
  50384. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  50385. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50386. protected _updateModel(): void;
  50387. }
  50388. }
  50389. declare module "babylonjs/Meshes/Builders/sphereBuilder" {
  50390. import { Vector4 } from "babylonjs/Maths/math.vector";
  50391. import { Mesh } from "babylonjs/Meshes/mesh";
  50392. import { Scene } from "babylonjs/scene";
  50393. import { Nullable } from "babylonjs/types";
  50394. /**
  50395. * Class containing static functions to help procedurally build meshes
  50396. */
  50397. export class SphereBuilder {
  50398. /**
  50399. * Creates a sphere mesh
  50400. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  50401. * * 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`)
  50402. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  50403. * * 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
  50404. * * 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)
  50405. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  50406. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  50407. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  50408. * @param name defines the name of the mesh
  50409. * @param options defines the options used to create the mesh
  50410. * @param scene defines the hosting scene
  50411. * @returns the sphere mesh
  50412. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  50413. */
  50414. static CreateSphere(name: string, options: {
  50415. segments?: number;
  50416. diameter?: number;
  50417. diameterX?: number;
  50418. diameterY?: number;
  50419. diameterZ?: number;
  50420. arc?: number;
  50421. slice?: number;
  50422. sideOrientation?: number;
  50423. frontUVs?: Vector4;
  50424. backUVs?: Vector4;
  50425. updatable?: boolean;
  50426. }, scene?: Nullable<Scene>): Mesh;
  50427. }
  50428. }
  50429. declare module "babylonjs/XR/motionController/webXRProfiledMotionController" {
  50430. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50431. import { WebXRAbstractMotionController, IMotionControllerProfile } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50432. import { Scene } from "babylonjs/scene";
  50433. /**
  50434. * A profiled motion controller has its profile loaded from an online repository.
  50435. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  50436. */
  50437. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  50438. private _repositoryUrl;
  50439. private _buttonMeshMapping;
  50440. private _touchDots;
  50441. /**
  50442. * The profile ID of this controller. Will be populated when the controller initializes.
  50443. */
  50444. profileId: string;
  50445. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  50446. dispose(): void;
  50447. protected _getFilenameAndPath(): {
  50448. filename: string;
  50449. path: string;
  50450. };
  50451. protected _getModelLoadingConstraints(): boolean;
  50452. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  50453. protected _setRootMesh(meshes: AbstractMesh[]): void;
  50454. protected _updateModel(_xrFrame: XRFrame): void;
  50455. }
  50456. }
  50457. declare module "babylonjs/XR/motionController/webXRMotionControllerManager" {
  50458. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50459. import { Scene } from "babylonjs/scene";
  50460. /**
  50461. * A construction function type to create a new controller based on an xrInput object
  50462. */
  50463. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  50464. /**
  50465. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  50466. *
  50467. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  50468. * it should be replaced with auto-loaded controllers.
  50469. *
  50470. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  50471. */
  50472. export class WebXRMotionControllerManager {
  50473. private static _AvailableControllers;
  50474. private static _Fallbacks;
  50475. private static _ProfileLoadingPromises;
  50476. private static _ProfilesList;
  50477. /**
  50478. * The base URL of the online controller repository. Can be changed at any time.
  50479. */
  50480. static BaseRepositoryUrl: string;
  50481. /**
  50482. * Which repository gets priority - local or online
  50483. */
  50484. static PrioritizeOnlineRepository: boolean;
  50485. /**
  50486. * Use the online repository, or use only locally-defined controllers
  50487. */
  50488. static UseOnlineRepository: boolean;
  50489. /**
  50490. * Clear the cache used for profile loading and reload when requested again
  50491. */
  50492. static ClearProfilesCache(): void;
  50493. /**
  50494. * Register the default fallbacks.
  50495. * This function is called automatically when this file is imported.
  50496. */
  50497. static DefaultFallbacks(): void;
  50498. /**
  50499. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  50500. * @param profileId the profile to which a fallback needs to be found
  50501. * @return an array with corresponding fallback profiles
  50502. */
  50503. static FindFallbackWithProfileId(profileId: string): string[];
  50504. /**
  50505. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  50506. * The order of search:
  50507. *
  50508. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  50509. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  50510. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  50511. * 4) return the generic trigger controller if none were found
  50512. *
  50513. * @param xrInput the xrInput to which a new controller is initialized
  50514. * @param scene the scene to which the model will be added
  50515. * @param forceProfile force a certain profile for this controller
  50516. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  50517. */
  50518. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  50519. /**
  50520. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  50521. *
  50522. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  50523. *
  50524. * @param type the profile type to register
  50525. * @param constructFunction the function to be called when loading this profile
  50526. */
  50527. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  50528. /**
  50529. * Register a fallback to a specific profile.
  50530. * @param profileId the profileId that will receive the fallbacks
  50531. * @param fallbacks A list of fallback profiles
  50532. */
  50533. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  50534. /**
  50535. * Will update the list of profiles available in the repository
  50536. * @return a promise that resolves to a map of profiles available online
  50537. */
  50538. static UpdateProfilesList(): Promise<{
  50539. [profile: string]: string;
  50540. }>;
  50541. private static _LoadProfileFromRepository;
  50542. private static _LoadProfilesFromAvailableControllers;
  50543. }
  50544. }
  50545. declare module "babylonjs/XR/webXRInputSource" {
  50546. import { Observable } from "babylonjs/Misc/observable";
  50547. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50548. import { Ray } from "babylonjs/Culling/ray";
  50549. import { Scene } from "babylonjs/scene";
  50550. import { WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  50551. /**
  50552. * Configuration options for the WebXR controller creation
  50553. */
  50554. export interface IWebXRControllerOptions {
  50555. /**
  50556. * Should the controller mesh be animated when a user interacts with it
  50557. * The pressed buttons / thumbstick and touchpad animations will be disabled
  50558. */
  50559. disableMotionControllerAnimation?: boolean;
  50560. /**
  50561. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  50562. */
  50563. doNotLoadControllerMesh?: boolean;
  50564. /**
  50565. * Force a specific controller type for this controller.
  50566. * This can be used when creating your own profile or when testing different controllers
  50567. */
  50568. forceControllerProfile?: string;
  50569. /**
  50570. * Defines a rendering group ID for meshes that will be loaded.
  50571. * This is for the default controllers only.
  50572. */
  50573. renderingGroupId?: number;
  50574. }
  50575. /**
  50576. * Represents an XR controller
  50577. */
  50578. export class WebXRInputSource {
  50579. private _scene;
  50580. /** The underlying input source for the controller */
  50581. inputSource: XRInputSource;
  50582. private _options;
  50583. private _tmpVector;
  50584. private _uniqueId;
  50585. private _disposed;
  50586. /**
  50587. * 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
  50588. */
  50589. grip?: AbstractMesh;
  50590. /**
  50591. * If available, this is the gamepad object related to this controller.
  50592. * Using this object it is possible to get click events and trackpad changes of the
  50593. * webxr controller that is currently being used.
  50594. */
  50595. motionController?: WebXRAbstractMotionController;
  50596. /**
  50597. * Event that fires when the controller is removed/disposed.
  50598. * The object provided as event data is this controller, after associated assets were disposed.
  50599. * uniqueId is still available.
  50600. */
  50601. onDisposeObservable: Observable<WebXRInputSource>;
  50602. /**
  50603. * Will be triggered when the mesh associated with the motion controller is done loading.
  50604. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  50605. * A shortened version of controller -> motion controller -> on mesh loaded.
  50606. */
  50607. onMeshLoadedObservable: Observable<AbstractMesh>;
  50608. /**
  50609. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  50610. */
  50611. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  50612. /**
  50613. * Pointer which can be used to select objects or attach a visible laser to
  50614. */
  50615. pointer: AbstractMesh;
  50616. /**
  50617. * Creates the input source object
  50618. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  50619. * @param _scene the scene which the controller should be associated to
  50620. * @param inputSource the underlying input source for the controller
  50621. * @param _options options for this controller creation
  50622. */
  50623. constructor(_scene: Scene,
  50624. /** The underlying input source for the controller */
  50625. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  50626. /**
  50627. * Get this controllers unique id
  50628. */
  50629. get uniqueId(): string;
  50630. /**
  50631. * Disposes of the object
  50632. */
  50633. dispose(): void;
  50634. /**
  50635. * Gets a world space ray coming from the pointer or grip
  50636. * @param result the resulting ray
  50637. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  50638. */
  50639. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  50640. /**
  50641. * Updates the controller pose based on the given XRFrame
  50642. * @param xrFrame xr frame to update the pose with
  50643. * @param referenceSpace reference space to use
  50644. */
  50645. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  50646. }
  50647. }
  50648. declare module "babylonjs/XR/webXRInput" {
  50649. import { Observable } from "babylonjs/Misc/observable";
  50650. import { IDisposable } from "babylonjs/scene";
  50651. import { WebXRInputSource, IWebXRControllerOptions } from "babylonjs/XR/webXRInputSource";
  50652. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50653. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50654. /**
  50655. * The schema for initialization options of the XR Input class
  50656. */
  50657. export interface IWebXRInputOptions {
  50658. /**
  50659. * If set to true no model will be automatically loaded
  50660. */
  50661. doNotLoadControllerMeshes?: boolean;
  50662. /**
  50663. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  50664. * If not found, the xr input profile data will be used.
  50665. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  50666. */
  50667. forceInputProfile?: string;
  50668. /**
  50669. * Do not send a request to the controller repository to load the profile.
  50670. *
  50671. * Instead, use the controllers available in babylon itself.
  50672. */
  50673. disableOnlineControllerRepository?: boolean;
  50674. /**
  50675. * A custom URL for the controllers repository
  50676. */
  50677. customControllersRepositoryURL?: string;
  50678. /**
  50679. * Should the controller model's components not move according to the user input
  50680. */
  50681. disableControllerAnimation?: boolean;
  50682. /**
  50683. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  50684. */
  50685. controllerOptions?: IWebXRControllerOptions;
  50686. }
  50687. /**
  50688. * XR input used to track XR inputs such as controllers/rays
  50689. */
  50690. export class WebXRInput implements IDisposable {
  50691. /**
  50692. * the xr session manager for this session
  50693. */
  50694. xrSessionManager: WebXRSessionManager;
  50695. /**
  50696. * the WebXR camera for this session. Mainly used for teleportation
  50697. */
  50698. xrCamera: WebXRCamera;
  50699. private readonly options;
  50700. /**
  50701. * XR controllers being tracked
  50702. */
  50703. controllers: Array<WebXRInputSource>;
  50704. private _frameObserver;
  50705. private _sessionEndedObserver;
  50706. private _sessionInitObserver;
  50707. /**
  50708. * Event when a controller has been connected/added
  50709. */
  50710. onControllerAddedObservable: Observable<WebXRInputSource>;
  50711. /**
  50712. * Event when a controller has been removed/disconnected
  50713. */
  50714. onControllerRemovedObservable: Observable<WebXRInputSource>;
  50715. /**
  50716. * Initializes the WebXRInput
  50717. * @param xrSessionManager the xr session manager for this session
  50718. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  50719. * @param options = initialization options for this xr input
  50720. */
  50721. constructor(
  50722. /**
  50723. * the xr session manager for this session
  50724. */
  50725. xrSessionManager: WebXRSessionManager,
  50726. /**
  50727. * the WebXR camera for this session. Mainly used for teleportation
  50728. */
  50729. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  50730. private _onInputSourcesChange;
  50731. private _addAndRemoveControllers;
  50732. /**
  50733. * Disposes of the object
  50734. */
  50735. dispose(): void;
  50736. }
  50737. }
  50738. declare module "babylonjs/XR/features/WebXRAbstractFeature" {
  50739. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  50740. import { Observable, EventState } from "babylonjs/Misc/observable";
  50741. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50742. /**
  50743. * This is the base class for all WebXR features.
  50744. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  50745. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  50746. */
  50747. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  50748. protected _xrSessionManager: WebXRSessionManager;
  50749. private _attached;
  50750. private _removeOnDetach;
  50751. /**
  50752. * Is this feature disposed?
  50753. */
  50754. isDisposed: boolean;
  50755. /**
  50756. * Should auto-attach be disabled?
  50757. */
  50758. disableAutoAttach: boolean;
  50759. /**
  50760. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  50761. */
  50762. xrNativeFeatureName: string;
  50763. /**
  50764. * Construct a new (abstract) WebXR feature
  50765. * @param _xrSessionManager the xr session manager for this feature
  50766. */
  50767. constructor(_xrSessionManager: WebXRSessionManager);
  50768. /**
  50769. * Is this feature attached
  50770. */
  50771. get attached(): boolean;
  50772. /**
  50773. * attach this feature
  50774. *
  50775. * @param force should attachment be forced (even when already attached)
  50776. * @returns true if successful, false is failed or already attached
  50777. */
  50778. attach(force?: boolean): boolean;
  50779. /**
  50780. * detach this feature.
  50781. *
  50782. * @returns true if successful, false if failed or already detached
  50783. */
  50784. detach(): boolean;
  50785. /**
  50786. * Dispose this feature and all of the resources attached
  50787. */
  50788. dispose(): void;
  50789. /**
  50790. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  50791. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  50792. *
  50793. * @returns whether or not the feature is compatible in this environment
  50794. */
  50795. isCompatible(): boolean;
  50796. /**
  50797. * This is used to register callbacks that will automatically be removed when detach is called.
  50798. * @param observable the observable to which the observer will be attached
  50799. * @param callback the callback to register
  50800. */
  50801. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  50802. /**
  50803. * Code in this function will be executed on each xrFrame received from the browser.
  50804. * This function will not execute after the feature is detached.
  50805. * @param _xrFrame the current frame
  50806. */
  50807. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  50808. }
  50809. }
  50810. declare module "babylonjs/Rendering/utilityLayerRenderer" {
  50811. import { IDisposable, Scene } from "babylonjs/scene";
  50812. import { Nullable } from "babylonjs/types";
  50813. import { Observable } from "babylonjs/Misc/observable";
  50814. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50815. import { HemisphericLight } from "babylonjs/Lights/hemisphericLight";
  50816. import { Camera } from "babylonjs/Cameras/camera";
  50817. /**
  50818. * Renders a layer on top of an existing scene
  50819. */
  50820. export class UtilityLayerRenderer implements IDisposable {
  50821. /** the original scene that will be rendered on top of */
  50822. originalScene: Scene;
  50823. private _pointerCaptures;
  50824. private _lastPointerEvents;
  50825. private static _DefaultUtilityLayer;
  50826. private static _DefaultKeepDepthUtilityLayer;
  50827. private _sharedGizmoLight;
  50828. private _renderCamera;
  50829. /**
  50830. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  50831. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  50832. * @returns the camera that is used when rendering the utility layer
  50833. */
  50834. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  50835. /**
  50836. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  50837. * @param cam the camera that should be used when rendering the utility layer
  50838. */
  50839. setRenderCamera(cam: Nullable<Camera>): void;
  50840. /**
  50841. * @hidden
  50842. * Light which used by gizmos to get light shading
  50843. */
  50844. _getSharedGizmoLight(): HemisphericLight;
  50845. /**
  50846. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  50847. */
  50848. pickUtilitySceneFirst: boolean;
  50849. /**
  50850. * 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)
  50851. */
  50852. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  50853. /**
  50854. * 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)
  50855. */
  50856. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  50857. /**
  50858. * The scene that is rendered on top of the original scene
  50859. */
  50860. utilityLayerScene: Scene;
  50861. /**
  50862. * If the utility layer should automatically be rendered on top of existing scene
  50863. */
  50864. shouldRender: boolean;
  50865. /**
  50866. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  50867. */
  50868. onlyCheckPointerDownEvents: boolean;
  50869. /**
  50870. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  50871. */
  50872. processAllEvents: boolean;
  50873. /**
  50874. * Observable raised when the pointer move from the utility layer scene to the main scene
  50875. */
  50876. onPointerOutObservable: Observable<number>;
  50877. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  50878. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  50879. private _afterRenderObserver;
  50880. private _sceneDisposeObserver;
  50881. private _originalPointerObserver;
  50882. /**
  50883. * Instantiates a UtilityLayerRenderer
  50884. * @param originalScene the original scene that will be rendered on top of
  50885. * @param handleEvents boolean indicating if the utility layer should handle events
  50886. */
  50887. constructor(
  50888. /** the original scene that will be rendered on top of */
  50889. originalScene: Scene, handleEvents?: boolean);
  50890. private _notifyObservers;
  50891. /**
  50892. * Renders the utility layers scene on top of the original scene
  50893. */
  50894. render(): void;
  50895. /**
  50896. * Disposes of the renderer
  50897. */
  50898. dispose(): void;
  50899. private _updateCamera;
  50900. }
  50901. }
  50902. declare module "babylonjs/XR/features/WebXRControllerPointerSelection" {
  50903. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  50904. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  50905. import { WebXRInput } from "babylonjs/XR/webXRInput";
  50906. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  50907. import { Scene } from "babylonjs/scene";
  50908. import { Nullable } from "babylonjs/types";
  50909. import { Color3 } from "babylonjs/Maths/math.color";
  50910. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  50911. import { WebXRCamera } from "babylonjs/XR/webXRCamera";
  50912. /**
  50913. * Options interface for the pointer selection module
  50914. */
  50915. export interface IWebXRControllerPointerSelectionOptions {
  50916. /**
  50917. * if provided, this scene will be used to render meshes.
  50918. */
  50919. customUtilityLayerScene?: Scene;
  50920. /**
  50921. * 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)
  50922. * If not disabled, the last picked point will be used to execute a pointer up event
  50923. * If disabled, pointer up event will be triggered right after the pointer down event.
  50924. * Used in screen and gaze target ray mode only
  50925. */
  50926. disablePointerUpOnTouchOut: boolean;
  50927. /**
  50928. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  50929. */
  50930. forceGazeMode: boolean;
  50931. /**
  50932. * 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
  50933. * to start a new countdown to the pointer down event.
  50934. * Defaults to 1.
  50935. */
  50936. gazeModePointerMovedFactor?: number;
  50937. /**
  50938. * Different button type to use instead of the main component
  50939. */
  50940. overrideButtonId?: string;
  50941. /**
  50942. * use this rendering group id for the meshes (optional)
  50943. */
  50944. renderingGroupId?: number;
  50945. /**
  50946. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  50947. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  50948. * 3000 means 3 seconds between pointing at something and selecting it
  50949. */
  50950. timeToSelect?: number;
  50951. /**
  50952. * Should meshes created here be added to a utility layer or the main scene
  50953. */
  50954. useUtilityLayer?: boolean;
  50955. /**
  50956. * Optional WebXR camera to be used for gaze selection
  50957. */
  50958. gazeCamera?: WebXRCamera;
  50959. /**
  50960. * the xr input to use with this pointer selection
  50961. */
  50962. xrInput: WebXRInput;
  50963. }
  50964. /**
  50965. * A module that will enable pointer selection for motion controllers of XR Input Sources
  50966. */
  50967. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  50968. private readonly _options;
  50969. private static _idCounter;
  50970. private _attachController;
  50971. private _controllers;
  50972. private _scene;
  50973. private _tmpVectorForPickCompare;
  50974. /**
  50975. * The module's name
  50976. */
  50977. static readonly Name: string;
  50978. /**
  50979. * The (Babylon) version of this module.
  50980. * This is an integer representing the implementation version.
  50981. * This number does not correspond to the WebXR specs version
  50982. */
  50983. static readonly Version: number;
  50984. /**
  50985. * Disable lighting on the laser pointer (so it will always be visible)
  50986. */
  50987. disablePointerLighting: boolean;
  50988. /**
  50989. * Disable lighting on the selection mesh (so it will always be visible)
  50990. */
  50991. disableSelectionMeshLighting: boolean;
  50992. /**
  50993. * Should the laser pointer be displayed
  50994. */
  50995. displayLaserPointer: boolean;
  50996. /**
  50997. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  50998. */
  50999. displaySelectionMesh: boolean;
  51000. /**
  51001. * This color will be set to the laser pointer when selection is triggered
  51002. */
  51003. laserPointerPickedColor: Color3;
  51004. /**
  51005. * Default color of the laser pointer
  51006. */
  51007. laserPointerDefaultColor: Color3;
  51008. /**
  51009. * default color of the selection ring
  51010. */
  51011. selectionMeshDefaultColor: Color3;
  51012. /**
  51013. * This color will be applied to the selection ring when selection is triggered
  51014. */
  51015. selectionMeshPickedColor: Color3;
  51016. /**
  51017. * Optional filter to be used for ray selection. This predicate shares behavior with
  51018. * scene.pointerMovePredicate which takes priority if it is also assigned.
  51019. */
  51020. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51021. /**
  51022. * constructs a new background remover module
  51023. * @param _xrSessionManager the session manager for this module
  51024. * @param _options read-only options to be used in this module
  51025. */
  51026. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  51027. /**
  51028. * attach this feature
  51029. * Will usually be called by the features manager
  51030. *
  51031. * @returns true if successful.
  51032. */
  51033. attach(): boolean;
  51034. /**
  51035. * detach this feature.
  51036. * Will usually be called by the features manager
  51037. *
  51038. * @returns true if successful.
  51039. */
  51040. detach(): boolean;
  51041. /**
  51042. * Will get the mesh under a specific pointer.
  51043. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  51044. * @param controllerId the controllerId to check
  51045. * @returns The mesh under pointer or null if no mesh is under the pointer
  51046. */
  51047. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  51048. /**
  51049. * Get the xr controller that correlates to the pointer id in the pointer event
  51050. *
  51051. * @param id the pointer id to search for
  51052. * @returns the controller that correlates to this id or null if not found
  51053. */
  51054. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  51055. protected _onXRFrame(_xrFrame: XRFrame): void;
  51056. private _attachGazeMode;
  51057. private _attachScreenRayMode;
  51058. private _attachTrackedPointerRayMode;
  51059. private _convertNormalToDirectionOfRay;
  51060. private _detachController;
  51061. private _generateNewMeshPair;
  51062. private _pickingMoved;
  51063. private _updatePointerDistance;
  51064. /** @hidden */
  51065. get lasterPointerDefaultColor(): Color3;
  51066. }
  51067. }
  51068. declare module "babylonjs/XR/webXREnterExitUI" {
  51069. import { Nullable } from "babylonjs/types";
  51070. import { Observable } from "babylonjs/Misc/observable";
  51071. import { IDisposable, Scene } from "babylonjs/scene";
  51072. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51073. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51074. /**
  51075. * Button which can be used to enter a different mode of XR
  51076. */
  51077. export class WebXREnterExitUIButton {
  51078. /** button element */
  51079. element: HTMLElement;
  51080. /** XR initialization options for the button */
  51081. sessionMode: XRSessionMode;
  51082. /** Reference space type */
  51083. referenceSpaceType: XRReferenceSpaceType;
  51084. /**
  51085. * Creates a WebXREnterExitUIButton
  51086. * @param element button element
  51087. * @param sessionMode XR initialization session mode
  51088. * @param referenceSpaceType the type of reference space to be used
  51089. */
  51090. constructor(
  51091. /** button element */
  51092. element: HTMLElement,
  51093. /** XR initialization options for the button */
  51094. sessionMode: XRSessionMode,
  51095. /** Reference space type */
  51096. referenceSpaceType: XRReferenceSpaceType);
  51097. /**
  51098. * Extendable function which can be used to update the button's visuals when the state changes
  51099. * @param activeButton the current active button in the UI
  51100. */
  51101. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  51102. }
  51103. /**
  51104. * Options to create the webXR UI
  51105. */
  51106. export class WebXREnterExitUIOptions {
  51107. /**
  51108. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  51109. */
  51110. customButtons?: Array<WebXREnterExitUIButton>;
  51111. /**
  51112. * A reference space type to use when creating the default button.
  51113. * Default is local-floor
  51114. */
  51115. referenceSpaceType?: XRReferenceSpaceType;
  51116. /**
  51117. * Context to enter xr with
  51118. */
  51119. renderTarget?: Nullable<WebXRRenderTarget>;
  51120. /**
  51121. * A session mode to use when creating the default button.
  51122. * Default is immersive-vr
  51123. */
  51124. sessionMode?: XRSessionMode;
  51125. /**
  51126. * A list of optional features to init the session with
  51127. */
  51128. optionalFeatures?: string[];
  51129. /**
  51130. * A list of optional features to init the session with
  51131. */
  51132. requiredFeatures?: string[];
  51133. }
  51134. /**
  51135. * UI to allow the user to enter/exit XR mode
  51136. */
  51137. export class WebXREnterExitUI implements IDisposable {
  51138. private scene;
  51139. /** version of the options passed to this UI */
  51140. options: WebXREnterExitUIOptions;
  51141. private _activeButton;
  51142. private _buttons;
  51143. /**
  51144. * The HTML Div Element to which buttons are added.
  51145. */
  51146. readonly overlay: HTMLDivElement;
  51147. /**
  51148. * Fired every time the active button is changed.
  51149. *
  51150. * When xr is entered via a button that launches xr that button will be the callback parameter
  51151. *
  51152. * When exiting xr the callback parameter will be null)
  51153. */
  51154. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  51155. /**
  51156. *
  51157. * @param scene babylon scene object to use
  51158. * @param options (read-only) version of the options passed to this UI
  51159. */
  51160. private constructor();
  51161. /**
  51162. * Creates UI to allow the user to enter/exit XR mode
  51163. * @param scene the scene to add the ui to
  51164. * @param helper the xr experience helper to enter/exit xr with
  51165. * @param options options to configure the UI
  51166. * @returns the created ui
  51167. */
  51168. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  51169. /**
  51170. * Disposes of the XR UI component
  51171. */
  51172. dispose(): void;
  51173. private _updateButtons;
  51174. }
  51175. }
  51176. declare module "babylonjs/Meshes/Builders/linesBuilder" {
  51177. import { Vector3 } from "babylonjs/Maths/math.vector";
  51178. import { Color4 } from "babylonjs/Maths/math.color";
  51179. import { Nullable } from "babylonjs/types";
  51180. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  51181. import { Scene } from "babylonjs/scene";
  51182. /**
  51183. * Class containing static functions to help procedurally build meshes
  51184. */
  51185. export class LinesBuilder {
  51186. /**
  51187. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  51188. * * 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
  51189. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  51190. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  51191. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  51192. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  51193. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51194. * * 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
  51195. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  51196. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51197. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  51198. * @param name defines the name of the new line system
  51199. * @param options defines the options used to create the line system
  51200. * @param scene defines the hosting scene
  51201. * @returns a new line system mesh
  51202. */
  51203. static CreateLineSystem(name: string, options: {
  51204. lines: Vector3[][];
  51205. updatable?: boolean;
  51206. instance?: Nullable<LinesMesh>;
  51207. colors?: Nullable<Color4[][]>;
  51208. useVertexAlpha?: boolean;
  51209. }, scene: Nullable<Scene>): LinesMesh;
  51210. /**
  51211. * Creates a line mesh
  51212. * 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
  51213. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51214. * * The parameter `points` is an array successive Vector3
  51215. * * 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
  51216. * * The optional parameter `colors` is an array of successive Color4, one per line point
  51217. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  51218. * * When updating an instance, remember that only point positions can change, not the number of points
  51219. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51220. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  51221. * @param name defines the name of the new line system
  51222. * @param options defines the options used to create the line system
  51223. * @param scene defines the hosting scene
  51224. * @returns a new line mesh
  51225. */
  51226. static CreateLines(name: string, options: {
  51227. points: Vector3[];
  51228. updatable?: boolean;
  51229. instance?: Nullable<LinesMesh>;
  51230. colors?: Color4[];
  51231. useVertexAlpha?: boolean;
  51232. }, scene?: Nullable<Scene>): LinesMesh;
  51233. /**
  51234. * Creates a dashed line mesh
  51235. * * 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
  51236. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  51237. * * The parameter `points` is an array successive Vector3
  51238. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  51239. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  51240. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  51241. * * 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
  51242. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  51243. * * When updating an instance, remember that only point positions can change, not the number of points
  51244. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  51245. * @param name defines the name of the mesh
  51246. * @param options defines the options used to create the mesh
  51247. * @param scene defines the hosting scene
  51248. * @returns the dashed line mesh
  51249. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  51250. */
  51251. static CreateDashedLines(name: string, options: {
  51252. points: Vector3[];
  51253. dashSize?: number;
  51254. gapSize?: number;
  51255. dashNb?: number;
  51256. updatable?: boolean;
  51257. instance?: LinesMesh;
  51258. useVertexAlpha?: boolean;
  51259. }, scene?: Nullable<Scene>): LinesMesh;
  51260. }
  51261. }
  51262. declare module "babylonjs/Misc/timer" {
  51263. import { Observable, Observer } from "babylonjs/Misc/observable";
  51264. import { Nullable } from "babylonjs/types";
  51265. import { IDisposable } from "babylonjs/scene";
  51266. /**
  51267. * Construction options for a timer
  51268. */
  51269. export interface ITimerOptions<T> {
  51270. /**
  51271. * Time-to-end
  51272. */
  51273. timeout: number;
  51274. /**
  51275. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  51276. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  51277. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  51278. */
  51279. contextObservable: Observable<T>;
  51280. /**
  51281. * Optional parameters when adding an observer to the observable
  51282. */
  51283. observableParameters?: {
  51284. mask?: number;
  51285. insertFirst?: boolean;
  51286. scope?: any;
  51287. };
  51288. /**
  51289. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  51290. */
  51291. breakCondition?: (data?: ITimerData<T>) => boolean;
  51292. /**
  51293. * Will be triggered when the time condition has met
  51294. */
  51295. onEnded?: (data: ITimerData<any>) => void;
  51296. /**
  51297. * Will be triggered when the break condition has met (prematurely ended)
  51298. */
  51299. onAborted?: (data: ITimerData<any>) => void;
  51300. /**
  51301. * Optional function to execute on each tick (or count)
  51302. */
  51303. onTick?: (data: ITimerData<any>) => void;
  51304. }
  51305. /**
  51306. * An interface defining the data sent by the timer
  51307. */
  51308. export interface ITimerData<T> {
  51309. /**
  51310. * When did it start
  51311. */
  51312. startTime: number;
  51313. /**
  51314. * Time now
  51315. */
  51316. currentTime: number;
  51317. /**
  51318. * Time passed since started
  51319. */
  51320. deltaTime: number;
  51321. /**
  51322. * How much is completed, in [0.0...1.0].
  51323. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  51324. */
  51325. completeRate: number;
  51326. /**
  51327. * What the registered observable sent in the last count
  51328. */
  51329. payload: T;
  51330. }
  51331. /**
  51332. * The current state of the timer
  51333. */
  51334. export enum TimerState {
  51335. /**
  51336. * Timer initialized, not yet started
  51337. */
  51338. INIT = 0,
  51339. /**
  51340. * Timer started and counting
  51341. */
  51342. STARTED = 1,
  51343. /**
  51344. * Timer ended (whether aborted or time reached)
  51345. */
  51346. ENDED = 2
  51347. }
  51348. /**
  51349. * A simple version of the timer. Will take options and start the timer immediately after calling it
  51350. *
  51351. * @param options options with which to initialize this timer
  51352. */
  51353. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  51354. /**
  51355. * An advanced implementation of a timer class
  51356. */
  51357. export class AdvancedTimer<T = any> implements IDisposable {
  51358. /**
  51359. * Will notify each time the timer calculates the remaining time
  51360. */
  51361. onEachCountObservable: Observable<ITimerData<T>>;
  51362. /**
  51363. * Will trigger when the timer was aborted due to the break condition
  51364. */
  51365. onTimerAbortedObservable: Observable<ITimerData<T>>;
  51366. /**
  51367. * Will trigger when the timer ended successfully
  51368. */
  51369. onTimerEndedObservable: Observable<ITimerData<T>>;
  51370. /**
  51371. * Will trigger when the timer state has changed
  51372. */
  51373. onStateChangedObservable: Observable<TimerState>;
  51374. private _observer;
  51375. private _contextObservable;
  51376. private _observableParameters;
  51377. private _startTime;
  51378. private _timer;
  51379. private _state;
  51380. private _breakCondition;
  51381. private _timeToEnd;
  51382. private _breakOnNextTick;
  51383. /**
  51384. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  51385. * @param options construction options for this advanced timer
  51386. */
  51387. constructor(options: ITimerOptions<T>);
  51388. /**
  51389. * set a breaking condition for this timer. Default is to never break during count
  51390. * @param predicate the new break condition. Returns true to break, false otherwise
  51391. */
  51392. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  51393. /**
  51394. * Reset ALL associated observables in this advanced timer
  51395. */
  51396. clearObservables(): void;
  51397. /**
  51398. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  51399. *
  51400. * @param timeToEnd how much time to measure until timer ended
  51401. */
  51402. start(timeToEnd?: number): void;
  51403. /**
  51404. * Will force a stop on the next tick.
  51405. */
  51406. stop(): void;
  51407. /**
  51408. * Dispose this timer, clearing all resources
  51409. */
  51410. dispose(): void;
  51411. private _setState;
  51412. private _tick;
  51413. private _stop;
  51414. }
  51415. }
  51416. declare module "babylonjs/XR/features/WebXRControllerTeleportation" {
  51417. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  51418. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  51419. import { Nullable } from "babylonjs/types";
  51420. import { WebXRInput } from "babylonjs/XR/webXRInput";
  51421. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51422. import { Vector3 } from "babylonjs/Maths/math.vector";
  51423. import { Material } from "babylonjs/Materials/material";
  51424. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  51425. import { Scene } from "babylonjs/scene";
  51426. /**
  51427. * The options container for the teleportation module
  51428. */
  51429. export interface IWebXRTeleportationOptions {
  51430. /**
  51431. * if provided, this scene will be used to render meshes.
  51432. */
  51433. customUtilityLayerScene?: Scene;
  51434. /**
  51435. * Values to configure the default target mesh
  51436. */
  51437. defaultTargetMeshOptions?: {
  51438. /**
  51439. * Fill color of the teleportation area
  51440. */
  51441. teleportationFillColor?: string;
  51442. /**
  51443. * Border color for the teleportation area
  51444. */
  51445. teleportationBorderColor?: string;
  51446. /**
  51447. * Disable the mesh's animation sequence
  51448. */
  51449. disableAnimation?: boolean;
  51450. /**
  51451. * Disable lighting on the material or the ring and arrow
  51452. */
  51453. disableLighting?: boolean;
  51454. /**
  51455. * Override the default material of the torus and arrow
  51456. */
  51457. torusArrowMaterial?: Material;
  51458. };
  51459. /**
  51460. * A list of meshes to use as floor meshes.
  51461. * Meshes can be added and removed after initializing the feature using the
  51462. * addFloorMesh and removeFloorMesh functions
  51463. * If empty, rotation will still work
  51464. */
  51465. floorMeshes?: AbstractMesh[];
  51466. /**
  51467. * use this rendering group id for the meshes (optional)
  51468. */
  51469. renderingGroupId?: number;
  51470. /**
  51471. * Should teleportation move only to snap points
  51472. */
  51473. snapPointsOnly?: boolean;
  51474. /**
  51475. * An array of points to which the teleportation will snap to.
  51476. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  51477. */
  51478. snapPositions?: Vector3[];
  51479. /**
  51480. * How close should the teleportation ray be in order to snap to position.
  51481. * Default to 0.8 units (meters)
  51482. */
  51483. snapToPositionRadius?: number;
  51484. /**
  51485. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  51486. * If you want to support rotation, make sure your mesh has a direction indicator.
  51487. *
  51488. * When left untouched, the default mesh will be initialized.
  51489. */
  51490. teleportationTargetMesh?: AbstractMesh;
  51491. /**
  51492. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  51493. */
  51494. timeToTeleport?: number;
  51495. /**
  51496. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  51497. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  51498. */
  51499. useMainComponentOnly?: boolean;
  51500. /**
  51501. * Should meshes created here be added to a utility layer or the main scene
  51502. */
  51503. useUtilityLayer?: boolean;
  51504. /**
  51505. * Babylon XR Input class for controller
  51506. */
  51507. xrInput: WebXRInput;
  51508. /**
  51509. * Meshes that the teleportation ray cannot go through
  51510. */
  51511. pickBlockerMeshes?: AbstractMesh[];
  51512. }
  51513. /**
  51514. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  51515. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  51516. * the input of the attached controllers.
  51517. */
  51518. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  51519. private _options;
  51520. private _controllers;
  51521. private _currentTeleportationControllerId;
  51522. private _floorMeshes;
  51523. private _quadraticBezierCurve;
  51524. private _selectionFeature;
  51525. private _snapToPositions;
  51526. private _snappedToPoint;
  51527. private _teleportationRingMaterial?;
  51528. private _tmpRay;
  51529. private _tmpVector;
  51530. private _tmpQuaternion;
  51531. /**
  51532. * The module's name
  51533. */
  51534. static readonly Name: string;
  51535. /**
  51536. * The (Babylon) version of this module.
  51537. * This is an integer representing the implementation version.
  51538. * This number does not correspond to the webxr specs version
  51539. */
  51540. static readonly Version: number;
  51541. /**
  51542. * Is movement backwards enabled
  51543. */
  51544. backwardsMovementEnabled: boolean;
  51545. /**
  51546. * Distance to travel when moving backwards
  51547. */
  51548. backwardsTeleportationDistance: number;
  51549. /**
  51550. * The distance from the user to the inspection point in the direction of the controller
  51551. * A higher number will allow the user to move further
  51552. * defaults to 5 (meters, in xr units)
  51553. */
  51554. parabolicCheckRadius: number;
  51555. /**
  51556. * Should the module support parabolic ray on top of direct ray
  51557. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  51558. * Very helpful when moving between floors / different heights
  51559. */
  51560. parabolicRayEnabled: boolean;
  51561. /**
  51562. * How much rotation should be applied when rotating right and left
  51563. */
  51564. rotationAngle: number;
  51565. /**
  51566. * Is rotation enabled when moving forward?
  51567. * Disabling this feature will prevent the user from deciding the direction when teleporting
  51568. */
  51569. rotationEnabled: boolean;
  51570. /**
  51571. * constructs a new anchor system
  51572. * @param _xrSessionManager an instance of WebXRSessionManager
  51573. * @param _options configuration object for this feature
  51574. */
  51575. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  51576. /**
  51577. * Get the snapPointsOnly flag
  51578. */
  51579. get snapPointsOnly(): boolean;
  51580. /**
  51581. * Sets the snapPointsOnly flag
  51582. * @param snapToPoints should teleportation be exclusively to snap points
  51583. */
  51584. set snapPointsOnly(snapToPoints: boolean);
  51585. /**
  51586. * Add a new mesh to the floor meshes array
  51587. * @param mesh the mesh to use as floor mesh
  51588. */
  51589. addFloorMesh(mesh: AbstractMesh): void;
  51590. /**
  51591. * Add a new snap-to point to fix teleportation to this position
  51592. * @param newSnapPoint The new Snap-To point
  51593. */
  51594. addSnapPoint(newSnapPoint: Vector3): void;
  51595. attach(): boolean;
  51596. detach(): boolean;
  51597. dispose(): void;
  51598. /**
  51599. * Remove a mesh from the floor meshes array
  51600. * @param mesh the mesh to remove
  51601. */
  51602. removeFloorMesh(mesh: AbstractMesh): void;
  51603. /**
  51604. * Remove a mesh from the floor meshes array using its name
  51605. * @param name the mesh name to remove
  51606. */
  51607. removeFloorMeshByName(name: string): void;
  51608. /**
  51609. * 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
  51610. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  51611. * @returns was the point found and removed or not
  51612. */
  51613. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  51614. /**
  51615. * This function sets a selection feature that will be disabled when
  51616. * the forward ray is shown and will be reattached when hidden.
  51617. * This is used to remove the selection rays when moving.
  51618. * @param selectionFeature the feature to disable when forward movement is enabled
  51619. */
  51620. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  51621. protected _onXRFrame(_xrFrame: XRFrame): void;
  51622. private _attachController;
  51623. private _createDefaultTargetMesh;
  51624. private _detachController;
  51625. private _findClosestSnapPointWithRadius;
  51626. private _setTargetMeshPosition;
  51627. private _setTargetMeshVisibility;
  51628. private _showParabolicPath;
  51629. private _teleportForward;
  51630. }
  51631. }
  51632. declare module "babylonjs/XR/webXRDefaultExperience" {
  51633. import { WebXRExperienceHelper } from "babylonjs/XR/webXRExperienceHelper";
  51634. import { Scene } from "babylonjs/scene";
  51635. import { WebXRInput, IWebXRInputOptions } from "babylonjs/XR/webXRInput";
  51636. import { WebXRControllerPointerSelection } from "babylonjs/XR/features/WebXRControllerPointerSelection";
  51637. import { WebXRRenderTarget } from "babylonjs/XR/webXRTypes";
  51638. import { WebXREnterExitUI, WebXREnterExitUIOptions } from "babylonjs/XR/webXREnterExitUI";
  51639. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51640. import { WebXRManagedOutputCanvasOptions } from "babylonjs/XR/webXRManagedOutputCanvas";
  51641. import { WebXRMotionControllerTeleportation } from "babylonjs/XR/features/WebXRControllerTeleportation";
  51642. /**
  51643. * Options for the default xr helper
  51644. */
  51645. export class WebXRDefaultExperienceOptions {
  51646. /**
  51647. * Enable or disable default UI to enter XR
  51648. */
  51649. disableDefaultUI?: boolean;
  51650. /**
  51651. * Should teleportation not initialize. defaults to false.
  51652. */
  51653. disableTeleportation?: boolean;
  51654. /**
  51655. * Floor meshes that will be used for teleport
  51656. */
  51657. floorMeshes?: Array<AbstractMesh>;
  51658. /**
  51659. * If set to true, the first frame will not be used to reset position
  51660. * The first frame is mainly used when copying transformation from the old camera
  51661. * Mainly used in AR
  51662. */
  51663. ignoreNativeCameraTransformation?: boolean;
  51664. /**
  51665. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  51666. */
  51667. inputOptions?: IWebXRInputOptions;
  51668. /**
  51669. * optional configuration for the output canvas
  51670. */
  51671. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  51672. /**
  51673. * optional UI options. This can be used among other to change session mode and reference space type
  51674. */
  51675. uiOptions?: WebXREnterExitUIOptions;
  51676. /**
  51677. * When loading teleportation and pointer select, use stable versions instead of latest.
  51678. */
  51679. useStablePlugins?: boolean;
  51680. /**
  51681. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  51682. */
  51683. renderingGroupId?: number;
  51684. /**
  51685. * A list of optional features to init the session with
  51686. * If set to true, all features we support will be added
  51687. */
  51688. optionalFeatures?: boolean | string[];
  51689. }
  51690. /**
  51691. * Default experience which provides a similar setup to the previous webVRExperience
  51692. */
  51693. export class WebXRDefaultExperience {
  51694. /**
  51695. * Base experience
  51696. */
  51697. baseExperience: WebXRExperienceHelper;
  51698. /**
  51699. * Enables ui for entering/exiting xr
  51700. */
  51701. enterExitUI: WebXREnterExitUI;
  51702. /**
  51703. * Input experience extension
  51704. */
  51705. input: WebXRInput;
  51706. /**
  51707. * Enables laser pointer and selection
  51708. */
  51709. pointerSelection: WebXRControllerPointerSelection;
  51710. /**
  51711. * Default target xr should render to
  51712. */
  51713. renderTarget: WebXRRenderTarget;
  51714. /**
  51715. * Enables teleportation
  51716. */
  51717. teleportation: WebXRMotionControllerTeleportation;
  51718. private constructor();
  51719. /**
  51720. * Creates the default xr experience
  51721. * @param scene scene
  51722. * @param options options for basic configuration
  51723. * @returns resulting WebXRDefaultExperience
  51724. */
  51725. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  51726. /**
  51727. * DIsposes of the experience helper
  51728. */
  51729. dispose(): void;
  51730. }
  51731. }
  51732. declare module "babylonjs/Cameras/VR/vrExperienceHelper" {
  51733. import { Observable } from "babylonjs/Misc/observable";
  51734. import { Nullable } from "babylonjs/types";
  51735. import { Camera } from "babylonjs/Cameras/camera";
  51736. import { DeviceOrientationCamera } from "babylonjs/Cameras/deviceOrientationCamera";
  51737. import { VRDeviceOrientationFreeCamera } from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  51738. import { WebVROptions, WebVRFreeCamera } from "babylonjs/Cameras/VR/webVRCamera";
  51739. import { Scene } from "babylonjs/scene";
  51740. import { Vector3 } from "babylonjs/Maths/math.vector";
  51741. import { Color3 } from "babylonjs/Maths/math.color";
  51742. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  51743. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  51744. import { Mesh } from "babylonjs/Meshes/mesh";
  51745. import { PickingInfo } from "babylonjs/Collisions/pickingInfo";
  51746. import { EasingFunction } from "babylonjs/Animations/easing";
  51747. import { VRCameraMetrics } from "babylonjs/Cameras/VR/vrCameraMetrics";
  51748. import "babylonjs/Meshes/Builders/groundBuilder";
  51749. import "babylonjs/Meshes/Builders/torusBuilder";
  51750. import "babylonjs/Meshes/Builders/cylinderBuilder";
  51751. import "babylonjs/Gamepads/gamepadSceneComponent";
  51752. import "babylonjs/Animations/animatable";
  51753. import { WebXRDefaultExperience } from "babylonjs/XR/webXRDefaultExperience";
  51754. /**
  51755. * Options to modify the vr teleportation behavior.
  51756. */
  51757. export interface VRTeleportationOptions {
  51758. /**
  51759. * The name of the mesh which should be used as the teleportation floor. (default: null)
  51760. */
  51761. floorMeshName?: string;
  51762. /**
  51763. * A list of meshes to be used as the teleportation floor. (default: empty)
  51764. */
  51765. floorMeshes?: Mesh[];
  51766. /**
  51767. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  51768. */
  51769. teleportationMode?: number;
  51770. /**
  51771. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  51772. */
  51773. teleportationTime?: number;
  51774. /**
  51775. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  51776. */
  51777. teleportationSpeed?: number;
  51778. /**
  51779. * The easing function used in the animation or null for Linear. (default CircleEase)
  51780. */
  51781. easingFunction?: EasingFunction;
  51782. }
  51783. /**
  51784. * Options to modify the vr experience helper's behavior.
  51785. */
  51786. export interface VRExperienceHelperOptions extends WebVROptions {
  51787. /**
  51788. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  51789. */
  51790. createDeviceOrientationCamera?: boolean;
  51791. /**
  51792. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  51793. */
  51794. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  51795. /**
  51796. * Uses the main button on the controller to toggle the laser casted. (default: true)
  51797. */
  51798. laserToggle?: boolean;
  51799. /**
  51800. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  51801. */
  51802. floorMeshes?: Mesh[];
  51803. /**
  51804. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  51805. */
  51806. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  51807. /**
  51808. * Defines if WebXR should be used instead of WebVR (if available)
  51809. */
  51810. useXR?: boolean;
  51811. }
  51812. /**
  51813. * Event containing information after VR has been entered
  51814. */
  51815. export class OnAfterEnteringVRObservableEvent {
  51816. /**
  51817. * If entering vr was successful
  51818. */
  51819. success: boolean;
  51820. }
  51821. /**
  51822. * Helps to quickly add VR support to an existing scene.
  51823. * See https://doc.babylonjs.com/how_to/webvr_helper
  51824. */
  51825. export class VRExperienceHelper {
  51826. /** Options to modify the vr experience helper's behavior. */
  51827. webVROptions: VRExperienceHelperOptions;
  51828. private _scene;
  51829. private _position;
  51830. private _btnVR;
  51831. private _btnVRDisplayed;
  51832. private _webVRsupported;
  51833. private _webVRready;
  51834. private _webVRrequesting;
  51835. private _webVRpresenting;
  51836. private _hasEnteredVR;
  51837. private _fullscreenVRpresenting;
  51838. private _inputElement;
  51839. private _webVRCamera;
  51840. private _vrDeviceOrientationCamera;
  51841. private _deviceOrientationCamera;
  51842. private _existingCamera;
  51843. private _onKeyDown;
  51844. private _onVrDisplayPresentChange;
  51845. private _onVRDisplayChanged;
  51846. private _onVRRequestPresentStart;
  51847. private _onVRRequestPresentComplete;
  51848. /**
  51849. * 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)
  51850. */
  51851. enableGazeEvenWhenNoPointerLock: boolean;
  51852. /**
  51853. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  51854. */
  51855. exitVROnDoubleTap: boolean;
  51856. /**
  51857. * Observable raised right before entering VR.
  51858. */
  51859. onEnteringVRObservable: Observable<VRExperienceHelper>;
  51860. /**
  51861. * Observable raised when entering VR has completed.
  51862. */
  51863. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  51864. /**
  51865. * Observable raised when exiting VR.
  51866. */
  51867. onExitingVRObservable: Observable<VRExperienceHelper>;
  51868. /**
  51869. * Observable raised when controller mesh is loaded.
  51870. */
  51871. onControllerMeshLoadedObservable: Observable<WebVRController>;
  51872. /** Return this.onEnteringVRObservable
  51873. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  51874. */
  51875. get onEnteringVR(): Observable<VRExperienceHelper>;
  51876. /** Return this.onExitingVRObservable
  51877. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  51878. */
  51879. get onExitingVR(): Observable<VRExperienceHelper>;
  51880. /** Return this.onControllerMeshLoadedObservable
  51881. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  51882. */
  51883. get onControllerMeshLoaded(): Observable<WebVRController>;
  51884. private _rayLength;
  51885. private _useCustomVRButton;
  51886. private _teleportationRequested;
  51887. private _teleportActive;
  51888. private _floorMeshName;
  51889. private _floorMeshesCollection;
  51890. private _teleportationMode;
  51891. private _teleportationTime;
  51892. private _teleportationSpeed;
  51893. private _teleportationEasing;
  51894. private _rotationAllowed;
  51895. private _teleportBackwardsVector;
  51896. private _teleportationTarget;
  51897. private _isDefaultTeleportationTarget;
  51898. private _postProcessMove;
  51899. private _teleportationFillColor;
  51900. private _teleportationBorderColor;
  51901. private _rotationAngle;
  51902. private _haloCenter;
  51903. private _cameraGazer;
  51904. private _padSensibilityUp;
  51905. private _padSensibilityDown;
  51906. private _leftController;
  51907. private _rightController;
  51908. private _gazeColor;
  51909. private _laserColor;
  51910. private _pickedLaserColor;
  51911. private _pickedGazeColor;
  51912. /**
  51913. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  51914. */
  51915. onNewMeshSelected: Observable<AbstractMesh>;
  51916. /**
  51917. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  51918. * This observable will provide the mesh and the controller used to select the mesh
  51919. */
  51920. onMeshSelectedWithController: Observable<{
  51921. mesh: AbstractMesh;
  51922. controller: WebVRController;
  51923. }>;
  51924. /**
  51925. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  51926. */
  51927. onNewMeshPicked: Observable<PickingInfo>;
  51928. private _circleEase;
  51929. /**
  51930. * Observable raised before camera teleportation
  51931. */
  51932. onBeforeCameraTeleport: Observable<Vector3>;
  51933. /**
  51934. * Observable raised after camera teleportation
  51935. */
  51936. onAfterCameraTeleport: Observable<Vector3>;
  51937. /**
  51938. * Observable raised when current selected mesh gets unselected
  51939. */
  51940. onSelectedMeshUnselected: Observable<AbstractMesh>;
  51941. private _raySelectionPredicate;
  51942. /**
  51943. * To be optionaly changed by user to define custom ray selection
  51944. */
  51945. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  51946. /**
  51947. * To be optionaly changed by user to define custom selection logic (after ray selection)
  51948. */
  51949. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  51950. /**
  51951. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  51952. */
  51953. teleportationEnabled: boolean;
  51954. private _defaultHeight;
  51955. private _teleportationInitialized;
  51956. private _interactionsEnabled;
  51957. private _interactionsRequested;
  51958. private _displayGaze;
  51959. private _displayLaserPointer;
  51960. /**
  51961. * The mesh used to display where the user is going to teleport.
  51962. */
  51963. get teleportationTarget(): Mesh;
  51964. /**
  51965. * Sets the mesh to be used to display where the user is going to teleport.
  51966. */
  51967. set teleportationTarget(value: Mesh);
  51968. /**
  51969. * 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
  51970. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  51971. * See https://doc.babylonjs.com/resources/baking_transformations
  51972. */
  51973. get gazeTrackerMesh(): Mesh;
  51974. set gazeTrackerMesh(value: Mesh);
  51975. /**
  51976. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  51977. */
  51978. updateGazeTrackerScale: boolean;
  51979. /**
  51980. * If the gaze trackers color should be updated when selecting meshes
  51981. */
  51982. updateGazeTrackerColor: boolean;
  51983. /**
  51984. * If the controller laser color should be updated when selecting meshes
  51985. */
  51986. updateControllerLaserColor: boolean;
  51987. /**
  51988. * The gaze tracking mesh corresponding to the left controller
  51989. */
  51990. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  51991. /**
  51992. * The gaze tracking mesh corresponding to the right controller
  51993. */
  51994. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  51995. /**
  51996. * If the ray of the gaze should be displayed.
  51997. */
  51998. get displayGaze(): boolean;
  51999. /**
  52000. * Sets if the ray of the gaze should be displayed.
  52001. */
  52002. set displayGaze(value: boolean);
  52003. /**
  52004. * If the ray of the LaserPointer should be displayed.
  52005. */
  52006. get displayLaserPointer(): boolean;
  52007. /**
  52008. * Sets if the ray of the LaserPointer should be displayed.
  52009. */
  52010. set displayLaserPointer(value: boolean);
  52011. /**
  52012. * The deviceOrientationCamera used as the camera when not in VR.
  52013. */
  52014. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  52015. /**
  52016. * Based on the current WebVR support, returns the current VR camera used.
  52017. */
  52018. get currentVRCamera(): Nullable<Camera>;
  52019. /**
  52020. * The webVRCamera which is used when in VR.
  52021. */
  52022. get webVRCamera(): WebVRFreeCamera;
  52023. /**
  52024. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  52025. */
  52026. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  52027. /**
  52028. * The html button that is used to trigger entering into VR.
  52029. */
  52030. get vrButton(): Nullable<HTMLButtonElement>;
  52031. private get _teleportationRequestInitiated();
  52032. /**
  52033. * Defines whether or not Pointer lock should be requested when switching to
  52034. * full screen.
  52035. */
  52036. requestPointerLockOnFullScreen: boolean;
  52037. /**
  52038. * If asking to force XR, this will be populated with the default xr experience
  52039. */
  52040. xr: WebXRDefaultExperience;
  52041. /**
  52042. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  52043. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  52044. */
  52045. xrTestDone: boolean;
  52046. /**
  52047. * Instantiates a VRExperienceHelper.
  52048. * Helps to quickly add VR support to an existing scene.
  52049. * @param scene The scene the VRExperienceHelper belongs to.
  52050. * @param webVROptions Options to modify the vr experience helper's behavior.
  52051. */
  52052. constructor(scene: Scene,
  52053. /** Options to modify the vr experience helper's behavior. */
  52054. webVROptions?: VRExperienceHelperOptions);
  52055. private completeVRInit;
  52056. private _onDefaultMeshLoaded;
  52057. private _onResize;
  52058. private _onFullscreenChange;
  52059. /**
  52060. * Gets a value indicating if we are currently in VR mode.
  52061. */
  52062. get isInVRMode(): boolean;
  52063. private onVrDisplayPresentChange;
  52064. private onVRDisplayChanged;
  52065. private moveButtonToBottomRight;
  52066. private displayVRButton;
  52067. private updateButtonVisibility;
  52068. private _cachedAngularSensibility;
  52069. /**
  52070. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  52071. * Otherwise, will use the fullscreen API.
  52072. */
  52073. enterVR(): void;
  52074. /**
  52075. * Attempt to exit VR, or fullscreen.
  52076. */
  52077. exitVR(): void;
  52078. /**
  52079. * The position of the vr experience helper.
  52080. */
  52081. get position(): Vector3;
  52082. /**
  52083. * Sets the position of the vr experience helper.
  52084. */
  52085. set position(value: Vector3);
  52086. /**
  52087. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  52088. */
  52089. enableInteractions(): void;
  52090. private get _noControllerIsActive();
  52091. private beforeRender;
  52092. private _isTeleportationFloor;
  52093. /**
  52094. * Adds a floor mesh to be used for teleportation.
  52095. * @param floorMesh the mesh to be used for teleportation.
  52096. */
  52097. addFloorMesh(floorMesh: Mesh): void;
  52098. /**
  52099. * Removes a floor mesh from being used for teleportation.
  52100. * @param floorMesh the mesh to be removed.
  52101. */
  52102. removeFloorMesh(floorMesh: Mesh): void;
  52103. /**
  52104. * Enables interactions and teleportation using the VR controllers and gaze.
  52105. * @param vrTeleportationOptions options to modify teleportation behavior.
  52106. */
  52107. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  52108. private _onNewGamepadConnected;
  52109. private _tryEnableInteractionOnController;
  52110. private _onNewGamepadDisconnected;
  52111. private _enableInteractionOnController;
  52112. private _checkTeleportWithRay;
  52113. private _checkRotate;
  52114. private _checkTeleportBackwards;
  52115. private _enableTeleportationOnController;
  52116. private _createTeleportationCircles;
  52117. private _displayTeleportationTarget;
  52118. private _hideTeleportationTarget;
  52119. private _rotateCamera;
  52120. private _moveTeleportationSelectorTo;
  52121. private _workingVector;
  52122. private _workingQuaternion;
  52123. private _workingMatrix;
  52124. /**
  52125. * Time Constant Teleportation Mode
  52126. */
  52127. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  52128. /**
  52129. * Speed Constant Teleportation Mode
  52130. */
  52131. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  52132. /**
  52133. * Teleports the users feet to the desired location
  52134. * @param location The location where the user's feet should be placed
  52135. */
  52136. teleportCamera(location: Vector3): void;
  52137. private _convertNormalToDirectionOfRay;
  52138. private _castRayAndSelectObject;
  52139. private _notifySelectedMeshUnselected;
  52140. /**
  52141. * Permanently set new colors for the laser pointer
  52142. * @param color the new laser color
  52143. * @param pickedColor the new laser color when picked mesh detected
  52144. */
  52145. setLaserColor(color: Color3, pickedColor?: Color3): void;
  52146. /**
  52147. * Set lighting enabled / disabled on the laser pointer of both controllers
  52148. * @param enabled should the lighting be enabled on the laser pointer
  52149. */
  52150. setLaserLightingState(enabled?: boolean): void;
  52151. /**
  52152. * Permanently set new colors for the gaze pointer
  52153. * @param color the new gaze color
  52154. * @param pickedColor the new gaze color when picked mesh detected
  52155. */
  52156. setGazeColor(color: Color3, pickedColor?: Color3): void;
  52157. /**
  52158. * Sets the color of the laser ray from the vr controllers.
  52159. * @param color new color for the ray.
  52160. */
  52161. changeLaserColor(color: Color3): void;
  52162. /**
  52163. * Sets the color of the ray from the vr headsets gaze.
  52164. * @param color new color for the ray.
  52165. */
  52166. changeGazeColor(color: Color3): void;
  52167. /**
  52168. * Exits VR and disposes of the vr experience helper
  52169. */
  52170. dispose(): void;
  52171. /**
  52172. * Gets the name of the VRExperienceHelper class
  52173. * @returns "VRExperienceHelper"
  52174. */
  52175. getClassName(): string;
  52176. }
  52177. }
  52178. declare module "babylonjs/Cameras/VR/index" {
  52179. export * from "babylonjs/Cameras/VR/vrCameraMetrics";
  52180. export * from "babylonjs/Cameras/VR/vrDeviceOrientationArcRotateCamera";
  52181. export * from "babylonjs/Cameras/VR/vrDeviceOrientationFreeCamera";
  52182. export * from "babylonjs/Cameras/VR/vrDeviceOrientationGamepadCamera";
  52183. export * from "babylonjs/Cameras/VR/vrExperienceHelper";
  52184. export * from "babylonjs/Cameras/VR/webVRCamera";
  52185. }
  52186. declare module "babylonjs/Cameras/RigModes/index" {
  52187. export * from "babylonjs/Cameras/RigModes/stereoscopicAnaglyphRigMode";
  52188. export * from "babylonjs/Cameras/RigModes/stereoscopicRigMode";
  52189. export * from "babylonjs/Cameras/RigModes/vrRigMode";
  52190. export * from "babylonjs/Cameras/RigModes/webVRRigMode";
  52191. }
  52192. declare module "babylonjs/Cameras/index" {
  52193. export * from "babylonjs/Cameras/Inputs/index";
  52194. export * from "babylonjs/Cameras/cameraInputsManager";
  52195. export * from "babylonjs/Cameras/camera";
  52196. export * from "babylonjs/Cameras/targetCamera";
  52197. export * from "babylonjs/Cameras/freeCamera";
  52198. export * from "babylonjs/Cameras/freeCameraInputsManager";
  52199. export * from "babylonjs/Cameras/touchCamera";
  52200. export * from "babylonjs/Cameras/arcRotateCamera";
  52201. export * from "babylonjs/Cameras/arcRotateCameraInputsManager";
  52202. export * from "babylonjs/Cameras/deviceOrientationCamera";
  52203. export * from "babylonjs/Cameras/flyCamera";
  52204. export * from "babylonjs/Cameras/flyCameraInputsManager";
  52205. export * from "babylonjs/Cameras/followCamera";
  52206. export * from "babylonjs/Cameras/followCameraInputsManager";
  52207. export * from "babylonjs/Cameras/gamepadCamera";
  52208. export * from "babylonjs/Cameras/Stereoscopic/index";
  52209. export * from "babylonjs/Cameras/universalCamera";
  52210. export * from "babylonjs/Cameras/virtualJoysticksCamera";
  52211. export * from "babylonjs/Cameras/VR/index";
  52212. export * from "babylonjs/Cameras/RigModes/index";
  52213. }
  52214. declare module "babylonjs/Collisions/index" {
  52215. export * from "babylonjs/Collisions/collider";
  52216. export * from "babylonjs/Collisions/collisionCoordinator";
  52217. export * from "babylonjs/Collisions/pickingInfo";
  52218. export * from "babylonjs/Collisions/intersectionInfo";
  52219. export * from "babylonjs/Collisions/meshCollisionData";
  52220. }
  52221. declare module "babylonjs/Culling/Octrees/octreeBlock" {
  52222. import { SmartArrayNoDuplicate } from "babylonjs/Misc/smartArray";
  52223. import { Vector3 } from "babylonjs/Maths/math.vector";
  52224. import { Ray } from "babylonjs/Culling/ray";
  52225. import { Plane } from "babylonjs/Maths/math.plane";
  52226. /**
  52227. * Contains an array of blocks representing the octree
  52228. */
  52229. export interface IOctreeContainer<T> {
  52230. /**
  52231. * Blocks within the octree
  52232. */
  52233. blocks: Array<OctreeBlock<T>>;
  52234. }
  52235. /**
  52236. * Class used to store a cell in an octree
  52237. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52238. */
  52239. export class OctreeBlock<T> {
  52240. /**
  52241. * Gets the content of the current block
  52242. */
  52243. entries: T[];
  52244. /**
  52245. * Gets the list of block children
  52246. */
  52247. blocks: Array<OctreeBlock<T>>;
  52248. private _depth;
  52249. private _maxDepth;
  52250. private _capacity;
  52251. private _minPoint;
  52252. private _maxPoint;
  52253. private _boundingVectors;
  52254. private _creationFunc;
  52255. /**
  52256. * Creates a new block
  52257. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  52258. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  52259. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52260. * @param depth defines the current depth of this block in the octree
  52261. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  52262. * @param creationFunc defines a callback to call when an element is added to the block
  52263. */
  52264. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  52265. /**
  52266. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  52267. */
  52268. get capacity(): number;
  52269. /**
  52270. * Gets the minimum vector (in world space) of the block's bounding box
  52271. */
  52272. get minPoint(): Vector3;
  52273. /**
  52274. * Gets the maximum vector (in world space) of the block's bounding box
  52275. */
  52276. get maxPoint(): Vector3;
  52277. /**
  52278. * Add a new element to this block
  52279. * @param entry defines the element to add
  52280. */
  52281. addEntry(entry: T): void;
  52282. /**
  52283. * Remove an element from this block
  52284. * @param entry defines the element to remove
  52285. */
  52286. removeEntry(entry: T): void;
  52287. /**
  52288. * Add an array of elements to this block
  52289. * @param entries defines the array of elements to add
  52290. */
  52291. addEntries(entries: T[]): void;
  52292. /**
  52293. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  52294. * @param frustumPlanes defines the frustum planes to test
  52295. * @param selection defines the array to store current content if selection is positive
  52296. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52297. */
  52298. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52299. /**
  52300. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  52301. * @param sphereCenter defines the bounding sphere center
  52302. * @param sphereRadius defines the bounding sphere radius
  52303. * @param selection defines the array to store current content if selection is positive
  52304. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52305. */
  52306. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  52307. /**
  52308. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  52309. * @param ray defines the ray to test with
  52310. * @param selection defines the array to store current content if selection is positive
  52311. */
  52312. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  52313. /**
  52314. * Subdivide the content into child blocks (this block will then be empty)
  52315. */
  52316. createInnerBlocks(): void;
  52317. /**
  52318. * @hidden
  52319. */
  52320. 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;
  52321. }
  52322. }
  52323. declare module "babylonjs/Culling/Octrees/octree" {
  52324. import { SmartArray } from "babylonjs/Misc/smartArray";
  52325. import { Vector3 } from "babylonjs/Maths/math.vector";
  52326. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52327. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52328. import { Ray } from "babylonjs/Culling/ray";
  52329. import { OctreeBlock } from "babylonjs/Culling/Octrees/octreeBlock";
  52330. import { Plane } from "babylonjs/Maths/math.plane";
  52331. /**
  52332. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  52333. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52334. */
  52335. export class Octree<T> {
  52336. /** 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.) */
  52337. maxDepth: number;
  52338. /**
  52339. * Blocks within the octree containing objects
  52340. */
  52341. blocks: Array<OctreeBlock<T>>;
  52342. /**
  52343. * Content stored in the octree
  52344. */
  52345. dynamicContent: T[];
  52346. private _maxBlockCapacity;
  52347. private _selectionContent;
  52348. private _creationFunc;
  52349. /**
  52350. * Creates a octree
  52351. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52352. * @param creationFunc function to be used to instatiate the octree
  52353. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  52354. * @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.)
  52355. */
  52356. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  52357. /** 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.) */
  52358. maxDepth?: number);
  52359. /**
  52360. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  52361. * @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);
  52362. * @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);
  52363. * @param entries meshes to be added to the octree blocks
  52364. */
  52365. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  52366. /**
  52367. * Adds a mesh to the octree
  52368. * @param entry Mesh to add to the octree
  52369. */
  52370. addMesh(entry: T): void;
  52371. /**
  52372. * Remove an element from the octree
  52373. * @param entry defines the element to remove
  52374. */
  52375. removeMesh(entry: T): void;
  52376. /**
  52377. * Selects an array of meshes within the frustum
  52378. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  52379. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  52380. * @returns array of meshes within the frustum
  52381. */
  52382. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  52383. /**
  52384. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  52385. * @param sphereCenter defines the bounding sphere center
  52386. * @param sphereRadius defines the bounding sphere radius
  52387. * @param allowDuplicate defines if the selection array can contains duplicated entries
  52388. * @returns an array of objects that intersect the sphere
  52389. */
  52390. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  52391. /**
  52392. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  52393. * @param ray defines the ray to test with
  52394. * @returns array of intersected objects
  52395. */
  52396. intersectsRay(ray: Ray): SmartArray<T>;
  52397. /**
  52398. * Adds a mesh into the octree block if it intersects the block
  52399. */
  52400. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  52401. /**
  52402. * Adds a submesh into the octree block if it intersects the block
  52403. */
  52404. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  52405. }
  52406. }
  52407. declare module "babylonjs/Culling/Octrees/octreeSceneComponent" {
  52408. import { ISmartArrayLike } from "babylonjs/Misc/smartArray";
  52409. import { Scene } from "babylonjs/scene";
  52410. import { SubMesh } from "babylonjs/Meshes/subMesh";
  52411. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52412. import { Ray } from "babylonjs/Culling/ray";
  52413. import { Octree } from "babylonjs/Culling/Octrees/octree";
  52414. import { Collider } from "babylonjs/Collisions/collider";
  52415. module "babylonjs/scene" {
  52416. interface Scene {
  52417. /**
  52418. * @hidden
  52419. * Backing Filed
  52420. */
  52421. _selectionOctree: Octree<AbstractMesh>;
  52422. /**
  52423. * Gets the octree used to boost mesh selection (picking)
  52424. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52425. */
  52426. selectionOctree: Octree<AbstractMesh>;
  52427. /**
  52428. * Creates or updates the octree used to boost selection (picking)
  52429. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52430. * @param maxCapacity defines the maximum capacity per leaf
  52431. * @param maxDepth defines the maximum depth of the octree
  52432. * @returns an octree of AbstractMesh
  52433. */
  52434. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  52435. }
  52436. }
  52437. module "babylonjs/Meshes/abstractMesh" {
  52438. interface AbstractMesh {
  52439. /**
  52440. * @hidden
  52441. * Backing Field
  52442. */
  52443. _submeshesOctree: Octree<SubMesh>;
  52444. /**
  52445. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  52446. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  52447. * @param maxCapacity defines the maximum size of each block (64 by default)
  52448. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  52449. * @returns the new octree
  52450. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  52451. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  52452. */
  52453. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  52454. }
  52455. }
  52456. /**
  52457. * Defines the octree scene component responsible to manage any octrees
  52458. * in a given scene.
  52459. */
  52460. export class OctreeSceneComponent {
  52461. /**
  52462. * The component name help to identify the component in the list of scene components.
  52463. */
  52464. readonly name: string;
  52465. /**
  52466. * The scene the component belongs to.
  52467. */
  52468. scene: Scene;
  52469. /**
  52470. * Indicates if the meshes have been checked to make sure they are isEnabled()
  52471. */
  52472. readonly checksIsEnabled: boolean;
  52473. /**
  52474. * Creates a new instance of the component for the given scene
  52475. * @param scene Defines the scene to register the component in
  52476. */
  52477. constructor(scene: Scene);
  52478. /**
  52479. * Registers the component in a given scene
  52480. */
  52481. register(): void;
  52482. /**
  52483. * Return the list of active meshes
  52484. * @returns the list of active meshes
  52485. */
  52486. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  52487. /**
  52488. * Return the list of active sub meshes
  52489. * @param mesh The mesh to get the candidates sub meshes from
  52490. * @returns the list of active sub meshes
  52491. */
  52492. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  52493. private _tempRay;
  52494. /**
  52495. * Return the list of sub meshes intersecting with a given local ray
  52496. * @param mesh defines the mesh to find the submesh for
  52497. * @param localRay defines the ray in local space
  52498. * @returns the list of intersecting sub meshes
  52499. */
  52500. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  52501. /**
  52502. * Return the list of sub meshes colliding with a collider
  52503. * @param mesh defines the mesh to find the submesh for
  52504. * @param collider defines the collider to evaluate the collision against
  52505. * @returns the list of colliding sub meshes
  52506. */
  52507. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  52508. /**
  52509. * Rebuilds the elements related to this component in case of
  52510. * context lost for instance.
  52511. */
  52512. rebuild(): void;
  52513. /**
  52514. * Disposes the component and the associated ressources.
  52515. */
  52516. dispose(): void;
  52517. }
  52518. }
  52519. declare module "babylonjs/Culling/Octrees/index" {
  52520. export * from "babylonjs/Culling/Octrees/octree";
  52521. export * from "babylonjs/Culling/Octrees/octreeBlock";
  52522. export * from "babylonjs/Culling/Octrees/octreeSceneComponent";
  52523. }
  52524. declare module "babylonjs/Culling/index" {
  52525. export * from "babylonjs/Culling/boundingBox";
  52526. export * from "babylonjs/Culling/boundingInfo";
  52527. export * from "babylonjs/Culling/boundingSphere";
  52528. export * from "babylonjs/Culling/Octrees/index";
  52529. export * from "babylonjs/Culling/ray";
  52530. }
  52531. declare module "babylonjs/Gizmos/gizmo" {
  52532. import { Nullable } from "babylonjs/types";
  52533. import { IDisposable } from "babylonjs/scene";
  52534. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52535. import { Mesh } from "babylonjs/Meshes/mesh";
  52536. import { Node } from "babylonjs/node";
  52537. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52538. /**
  52539. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  52540. */
  52541. export class Gizmo implements IDisposable {
  52542. /** The utility layer the gizmo will be added to */
  52543. gizmoLayer: UtilityLayerRenderer;
  52544. /**
  52545. * The root mesh of the gizmo
  52546. */
  52547. _rootMesh: Mesh;
  52548. private _attachedMesh;
  52549. private _attachedNode;
  52550. /**
  52551. * Ratio for the scale of the gizmo (Default: 1)
  52552. */
  52553. protected _scaleRatio: number;
  52554. /**
  52555. * boolean updated by pointermove when a gizmo mesh is hovered
  52556. */
  52557. protected _isHovered: boolean;
  52558. /**
  52559. * Ratio for the scale of the gizmo (Default: 1)
  52560. */
  52561. set scaleRatio(value: number);
  52562. get scaleRatio(): number;
  52563. /**
  52564. * True when the mouse pointer is hovered a gizmo mesh
  52565. */
  52566. get isHovered(): boolean;
  52567. /**
  52568. * If a custom mesh has been set (Default: false)
  52569. */
  52570. protected _customMeshSet: boolean;
  52571. /**
  52572. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  52573. * * When set, interactions will be enabled
  52574. */
  52575. get attachedMesh(): Nullable<AbstractMesh>;
  52576. set attachedMesh(value: Nullable<AbstractMesh>);
  52577. /**
  52578. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  52579. * * When set, interactions will be enabled
  52580. */
  52581. get attachedNode(): Nullable<Node>;
  52582. set attachedNode(value: Nullable<Node>);
  52583. /**
  52584. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  52585. * @param mesh The mesh to replace the default mesh of the gizmo
  52586. */
  52587. setCustomMesh(mesh: Mesh): void;
  52588. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  52589. /**
  52590. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  52591. */
  52592. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52593. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52594. /**
  52595. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  52596. */
  52597. updateGizmoPositionToMatchAttachedMesh: boolean;
  52598. /**
  52599. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  52600. */
  52601. updateScale: boolean;
  52602. protected _interactionsEnabled: boolean;
  52603. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52604. private _beforeRenderObserver;
  52605. private _tempQuaternion;
  52606. private _tempVector;
  52607. private _tempVector2;
  52608. private _tempMatrix1;
  52609. private _tempMatrix2;
  52610. private _rightHandtoLeftHandMatrix;
  52611. /**
  52612. * Creates a gizmo
  52613. * @param gizmoLayer The utility layer the gizmo will be added to
  52614. */
  52615. constructor(
  52616. /** The utility layer the gizmo will be added to */
  52617. gizmoLayer?: UtilityLayerRenderer);
  52618. /**
  52619. * Updates the gizmo to match the attached mesh's position/rotation
  52620. */
  52621. protected _update(): void;
  52622. /**
  52623. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  52624. * @param value Node, TransformNode or mesh
  52625. */
  52626. protected _matrixChanged(): void;
  52627. /**
  52628. * Disposes of the gizmo
  52629. */
  52630. dispose(): void;
  52631. }
  52632. }
  52633. declare module "babylonjs/Gizmos/planeDragGizmo" {
  52634. import { Observable } from "babylonjs/Misc/observable";
  52635. import { Nullable } from "babylonjs/types";
  52636. import { Vector3 } from "babylonjs/Maths/math.vector";
  52637. import { Color3 } from "babylonjs/Maths/math.color";
  52638. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52639. import { Node } from "babylonjs/node";
  52640. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52641. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52642. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52643. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52644. import { Scene } from "babylonjs/scene";
  52645. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52646. /**
  52647. * Single plane drag gizmo
  52648. */
  52649. export class PlaneDragGizmo extends Gizmo {
  52650. /**
  52651. * Drag behavior responsible for the gizmos dragging interactions
  52652. */
  52653. dragBehavior: PointerDragBehavior;
  52654. private _pointerObserver;
  52655. /**
  52656. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52657. */
  52658. snapDistance: number;
  52659. /**
  52660. * Event that fires each time the gizmo snaps to a new location.
  52661. * * snapDistance is the the change in distance
  52662. */
  52663. onSnapObservable: Observable<{
  52664. snapDistance: number;
  52665. }>;
  52666. private _plane;
  52667. private _coloredMaterial;
  52668. private _hoverMaterial;
  52669. private _isEnabled;
  52670. private _parent;
  52671. /** @hidden */
  52672. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  52673. /** @hidden */
  52674. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52675. /**
  52676. * Creates a PlaneDragGizmo
  52677. * @param gizmoLayer The utility layer the gizmo will be added to
  52678. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  52679. * @param color The color of the gizmo
  52680. */
  52681. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  52682. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52683. /**
  52684. * If the gizmo is enabled
  52685. */
  52686. set isEnabled(value: boolean);
  52687. get isEnabled(): boolean;
  52688. /**
  52689. * Disposes of the gizmo
  52690. */
  52691. dispose(): void;
  52692. }
  52693. }
  52694. declare module "babylonjs/Gizmos/positionGizmo" {
  52695. import { Observable } from "babylonjs/Misc/observable";
  52696. import { Nullable } from "babylonjs/types";
  52697. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  52698. import { Node } from "babylonjs/node";
  52699. import { Mesh } from "babylonjs/Meshes/mesh";
  52700. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52701. import { AxisDragGizmo } from "babylonjs/Gizmos/axisDragGizmo";
  52702. import { PlaneDragGizmo } from "babylonjs/Gizmos/planeDragGizmo";
  52703. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52704. /**
  52705. * Gizmo that enables dragging a mesh along 3 axis
  52706. */
  52707. export class PositionGizmo extends Gizmo {
  52708. /**
  52709. * Internal gizmo used for interactions on the x axis
  52710. */
  52711. xGizmo: AxisDragGizmo;
  52712. /**
  52713. * Internal gizmo used for interactions on the y axis
  52714. */
  52715. yGizmo: AxisDragGizmo;
  52716. /**
  52717. * Internal gizmo used for interactions on the z axis
  52718. */
  52719. zGizmo: AxisDragGizmo;
  52720. /**
  52721. * Internal gizmo used for interactions on the yz plane
  52722. */
  52723. xPlaneGizmo: PlaneDragGizmo;
  52724. /**
  52725. * Internal gizmo used for interactions on the xz plane
  52726. */
  52727. yPlaneGizmo: PlaneDragGizmo;
  52728. /**
  52729. * Internal gizmo used for interactions on the xy plane
  52730. */
  52731. zPlaneGizmo: PlaneDragGizmo;
  52732. /**
  52733. * private variables
  52734. */
  52735. private _meshAttached;
  52736. private _nodeAttached;
  52737. private _snapDistance;
  52738. /** Fires an event when any of it's sub gizmos are dragged */
  52739. onDragStartObservable: Observable<unknown>;
  52740. /** Fires an event when any of it's sub gizmos are released from dragging */
  52741. onDragEndObservable: Observable<unknown>;
  52742. /**
  52743. * If set to true, planar drag is enabled
  52744. */
  52745. private _planarGizmoEnabled;
  52746. get attachedMesh(): Nullable<AbstractMesh>;
  52747. set attachedMesh(mesh: Nullable<AbstractMesh>);
  52748. get attachedNode(): Nullable<Node>;
  52749. set attachedNode(node: Nullable<Node>);
  52750. /**
  52751. * True when the mouse pointer is hovering a gizmo mesh
  52752. */
  52753. get isHovered(): boolean;
  52754. /**
  52755. * Creates a PositionGizmo
  52756. * @param gizmoLayer The utility layer the gizmo will be added to
  52757. @param thickness display gizmo axis thickness
  52758. */
  52759. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  52760. /**
  52761. * If the planar drag gizmo is enabled
  52762. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  52763. */
  52764. set planarGizmoEnabled(value: boolean);
  52765. get planarGizmoEnabled(): boolean;
  52766. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  52767. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  52768. /**
  52769. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52770. */
  52771. set snapDistance(value: number);
  52772. get snapDistance(): number;
  52773. /**
  52774. * Ratio for the scale of the gizmo (Default: 1)
  52775. */
  52776. set scaleRatio(value: number);
  52777. get scaleRatio(): number;
  52778. /**
  52779. * Disposes of the gizmo
  52780. */
  52781. dispose(): void;
  52782. /**
  52783. * CustomMeshes are not supported by this gizmo
  52784. * @param mesh The mesh to replace the default mesh of the gizmo
  52785. */
  52786. setCustomMesh(mesh: Mesh): void;
  52787. }
  52788. }
  52789. declare module "babylonjs/Gizmos/axisDragGizmo" {
  52790. import { Observable } from "babylonjs/Misc/observable";
  52791. import { Nullable } from "babylonjs/types";
  52792. import { Vector3 } from "babylonjs/Maths/math.vector";
  52793. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52794. import { Node } from "babylonjs/node";
  52795. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  52796. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  52797. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  52798. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  52799. import { Scene } from "babylonjs/scene";
  52800. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  52801. import { Color3 } from "babylonjs/Maths/math.color";
  52802. /**
  52803. * Single axis drag gizmo
  52804. */
  52805. export class AxisDragGizmo extends Gizmo {
  52806. /**
  52807. * Drag behavior responsible for the gizmos dragging interactions
  52808. */
  52809. dragBehavior: PointerDragBehavior;
  52810. private _pointerObserver;
  52811. /**
  52812. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  52813. */
  52814. snapDistance: number;
  52815. /**
  52816. * Event that fires each time the gizmo snaps to a new location.
  52817. * * snapDistance is the the change in distance
  52818. */
  52819. onSnapObservable: Observable<{
  52820. snapDistance: number;
  52821. }>;
  52822. private _isEnabled;
  52823. private _parent;
  52824. private _arrow;
  52825. private _coloredMaterial;
  52826. private _hoverMaterial;
  52827. /** @hidden */
  52828. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  52829. /** @hidden */
  52830. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  52831. /**
  52832. * Creates an AxisDragGizmo
  52833. * @param gizmoLayer The utility layer the gizmo will be added to
  52834. * @param dragAxis The axis which the gizmo will be able to drag on
  52835. * @param color The color of the gizmo
  52836. * @param thickness display gizmo axis thickness
  52837. */
  52838. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  52839. protected _attachedNodeChanged(value: Nullable<Node>): void;
  52840. /**
  52841. * If the gizmo is enabled
  52842. */
  52843. set isEnabled(value: boolean);
  52844. get isEnabled(): boolean;
  52845. /**
  52846. * Disposes of the gizmo
  52847. */
  52848. dispose(): void;
  52849. }
  52850. }
  52851. declare module "babylonjs/Debug/axesViewer" {
  52852. import { Vector3 } from "babylonjs/Maths/math.vector";
  52853. import { Nullable } from "babylonjs/types";
  52854. import { Scene } from "babylonjs/scene";
  52855. import { TransformNode } from "babylonjs/Meshes/transformNode";
  52856. /**
  52857. * The Axes viewer will show 3 axes in a specific point in space
  52858. */
  52859. export class AxesViewer {
  52860. private _xAxis;
  52861. private _yAxis;
  52862. private _zAxis;
  52863. private _scaleLinesFactor;
  52864. private _instanced;
  52865. /**
  52866. * Gets the hosting scene
  52867. */
  52868. scene: Nullable<Scene>;
  52869. /**
  52870. * Gets or sets a number used to scale line length
  52871. */
  52872. scaleLines: number;
  52873. /** Gets the node hierarchy used to render x-axis */
  52874. get xAxis(): TransformNode;
  52875. /** Gets the node hierarchy used to render y-axis */
  52876. get yAxis(): TransformNode;
  52877. /** Gets the node hierarchy used to render z-axis */
  52878. get zAxis(): TransformNode;
  52879. /**
  52880. * Creates a new AxesViewer
  52881. * @param scene defines the hosting scene
  52882. * @param scaleLines defines a number used to scale line length (1 by default)
  52883. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  52884. * @param xAxis defines the node hierarchy used to render the x-axis
  52885. * @param yAxis defines the node hierarchy used to render the y-axis
  52886. * @param zAxis defines the node hierarchy used to render the z-axis
  52887. */
  52888. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  52889. /**
  52890. * Force the viewer to update
  52891. * @param position defines the position of the viewer
  52892. * @param xaxis defines the x axis of the viewer
  52893. * @param yaxis defines the y axis of the viewer
  52894. * @param zaxis defines the z axis of the viewer
  52895. */
  52896. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  52897. /**
  52898. * Creates an instance of this axes viewer.
  52899. * @returns a new axes viewer with instanced meshes
  52900. */
  52901. createInstance(): AxesViewer;
  52902. /** Releases resources */
  52903. dispose(): void;
  52904. private static _SetRenderingGroupId;
  52905. }
  52906. }
  52907. declare module "babylonjs/Debug/boneAxesViewer" {
  52908. import { Nullable } from "babylonjs/types";
  52909. import { AxesViewer } from "babylonjs/Debug/axesViewer";
  52910. import { Vector3 } from "babylonjs/Maths/math.vector";
  52911. import { Mesh } from "babylonjs/Meshes/mesh";
  52912. import { Bone } from "babylonjs/Bones/bone";
  52913. import { Scene } from "babylonjs/scene";
  52914. /**
  52915. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  52916. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  52917. */
  52918. export class BoneAxesViewer extends AxesViewer {
  52919. /**
  52920. * Gets or sets the target mesh where to display the axes viewer
  52921. */
  52922. mesh: Nullable<Mesh>;
  52923. /**
  52924. * Gets or sets the target bone where to display the axes viewer
  52925. */
  52926. bone: Nullable<Bone>;
  52927. /** Gets current position */
  52928. pos: Vector3;
  52929. /** Gets direction of X axis */
  52930. xaxis: Vector3;
  52931. /** Gets direction of Y axis */
  52932. yaxis: Vector3;
  52933. /** Gets direction of Z axis */
  52934. zaxis: Vector3;
  52935. /**
  52936. * Creates a new BoneAxesViewer
  52937. * @param scene defines the hosting scene
  52938. * @param bone defines the target bone
  52939. * @param mesh defines the target mesh
  52940. * @param scaleLines defines a scaling factor for line length (1 by default)
  52941. */
  52942. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  52943. /**
  52944. * Force the viewer to update
  52945. */
  52946. update(): void;
  52947. /** Releases resources */
  52948. dispose(): void;
  52949. }
  52950. }
  52951. declare module "babylonjs/Debug/debugLayer" {
  52952. import { Scene } from "babylonjs/scene";
  52953. /**
  52954. * Interface used to define scene explorer extensibility option
  52955. */
  52956. export interface IExplorerExtensibilityOption {
  52957. /**
  52958. * Define the option label
  52959. */
  52960. label: string;
  52961. /**
  52962. * Defines the action to execute on click
  52963. */
  52964. action: (entity: any) => void;
  52965. }
  52966. /**
  52967. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  52968. */
  52969. export interface IExplorerExtensibilityGroup {
  52970. /**
  52971. * Defines a predicate to test if a given type mut be extended
  52972. */
  52973. predicate: (entity: any) => boolean;
  52974. /**
  52975. * Gets the list of options added to a type
  52976. */
  52977. entries: IExplorerExtensibilityOption[];
  52978. }
  52979. /**
  52980. * Interface used to define the options to use to create the Inspector
  52981. */
  52982. export interface IInspectorOptions {
  52983. /**
  52984. * Display in overlay mode (default: false)
  52985. */
  52986. overlay?: boolean;
  52987. /**
  52988. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  52989. */
  52990. globalRoot?: HTMLElement;
  52991. /**
  52992. * Display the Scene explorer
  52993. */
  52994. showExplorer?: boolean;
  52995. /**
  52996. * Display the property inspector
  52997. */
  52998. showInspector?: boolean;
  52999. /**
  53000. * Display in embed mode (both panes on the right)
  53001. */
  53002. embedMode?: boolean;
  53003. /**
  53004. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  53005. */
  53006. handleResize?: boolean;
  53007. /**
  53008. * Allow the panes to popup (default: true)
  53009. */
  53010. enablePopup?: boolean;
  53011. /**
  53012. * Allow the panes to be closed by users (default: true)
  53013. */
  53014. enableClose?: boolean;
  53015. /**
  53016. * Optional list of extensibility entries
  53017. */
  53018. explorerExtensibility?: IExplorerExtensibilityGroup[];
  53019. /**
  53020. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  53021. */
  53022. inspectorURL?: string;
  53023. /**
  53024. * Optional initial tab (default to DebugLayerTab.Properties)
  53025. */
  53026. initialTab?: DebugLayerTab;
  53027. }
  53028. module "babylonjs/scene" {
  53029. interface Scene {
  53030. /**
  53031. * @hidden
  53032. * Backing field
  53033. */
  53034. _debugLayer: DebugLayer;
  53035. /**
  53036. * Gets the debug layer (aka Inspector) associated with the scene
  53037. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53038. */
  53039. debugLayer: DebugLayer;
  53040. }
  53041. }
  53042. /**
  53043. * Enum of inspector action tab
  53044. */
  53045. export enum DebugLayerTab {
  53046. /**
  53047. * Properties tag (default)
  53048. */
  53049. Properties = 0,
  53050. /**
  53051. * Debug tab
  53052. */
  53053. Debug = 1,
  53054. /**
  53055. * Statistics tab
  53056. */
  53057. Statistics = 2,
  53058. /**
  53059. * Tools tab
  53060. */
  53061. Tools = 3,
  53062. /**
  53063. * Settings tab
  53064. */
  53065. Settings = 4
  53066. }
  53067. /**
  53068. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53069. * what is happening in your scene
  53070. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53071. */
  53072. export class DebugLayer {
  53073. /**
  53074. * Define the url to get the inspector script from.
  53075. * By default it uses the babylonjs CDN.
  53076. * @ignoreNaming
  53077. */
  53078. static InspectorURL: string;
  53079. private _scene;
  53080. private BJSINSPECTOR;
  53081. private _onPropertyChangedObservable?;
  53082. /**
  53083. * Observable triggered when a property is changed through the inspector.
  53084. */
  53085. get onPropertyChangedObservable(): any;
  53086. /**
  53087. * Instantiates a new debug layer.
  53088. * The debug layer (aka Inspector) is the go to tool in order to better understand
  53089. * what is happening in your scene
  53090. * @see https://doc.babylonjs.com/features/playground_debuglayer
  53091. * @param scene Defines the scene to inspect
  53092. */
  53093. constructor(scene: Scene);
  53094. /** Creates the inspector window. */
  53095. private _createInspector;
  53096. /**
  53097. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  53098. * @param entity defines the entity to select
  53099. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  53100. */
  53101. select(entity: any, lineContainerTitles?: string | string[]): void;
  53102. /** Get the inspector from bundle or global */
  53103. private _getGlobalInspector;
  53104. /**
  53105. * Get if the inspector is visible or not.
  53106. * @returns true if visible otherwise, false
  53107. */
  53108. isVisible(): boolean;
  53109. /**
  53110. * Hide the inspector and close its window.
  53111. */
  53112. hide(): void;
  53113. /**
  53114. * Update the scene in the inspector
  53115. */
  53116. setAsActiveScene(): void;
  53117. /**
  53118. * Launch the debugLayer.
  53119. * @param config Define the configuration of the inspector
  53120. * @return a promise fulfilled when the debug layer is visible
  53121. */
  53122. show(config?: IInspectorOptions): Promise<DebugLayer>;
  53123. }
  53124. }
  53125. declare module "babylonjs/Meshes/Builders/boxBuilder" {
  53126. import { Nullable } from "babylonjs/types";
  53127. import { Scene } from "babylonjs/scene";
  53128. import { Vector4 } from "babylonjs/Maths/math.vector";
  53129. import { Color4 } from "babylonjs/Maths/math.color";
  53130. import { Mesh } from "babylonjs/Meshes/mesh";
  53131. /**
  53132. * Class containing static functions to help procedurally build meshes
  53133. */
  53134. export class BoxBuilder {
  53135. /**
  53136. * Creates a box mesh
  53137. * * The parameter `size` sets the size (float) of each box side (default 1)
  53138. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  53139. * * 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)
  53140. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  53141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53144. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  53145. * @param name defines the name of the mesh
  53146. * @param options defines the options used to create the mesh
  53147. * @param scene defines the hosting scene
  53148. * @returns the box mesh
  53149. */
  53150. static CreateBox(name: string, options: {
  53151. size?: number;
  53152. width?: number;
  53153. height?: number;
  53154. depth?: number;
  53155. faceUV?: Vector4[];
  53156. faceColors?: Color4[];
  53157. sideOrientation?: number;
  53158. frontUVs?: Vector4;
  53159. backUVs?: Vector4;
  53160. wrap?: boolean;
  53161. topBaseAt?: number;
  53162. bottomBaseAt?: number;
  53163. updatable?: boolean;
  53164. }, scene?: Nullable<Scene>): Mesh;
  53165. }
  53166. }
  53167. declare module "babylonjs/Debug/physicsViewer" {
  53168. import { Nullable } from "babylonjs/types";
  53169. import { Scene } from "babylonjs/scene";
  53170. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53171. import { Mesh } from "babylonjs/Meshes/mesh";
  53172. import { IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  53173. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  53174. /**
  53175. * Used to show the physics impostor around the specific mesh
  53176. */
  53177. export class PhysicsViewer {
  53178. /** @hidden */
  53179. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  53180. /** @hidden */
  53181. protected _meshes: Array<Nullable<AbstractMesh>>;
  53182. /** @hidden */
  53183. protected _scene: Nullable<Scene>;
  53184. /** @hidden */
  53185. protected _numMeshes: number;
  53186. /** @hidden */
  53187. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  53188. private _renderFunction;
  53189. private _utilityLayer;
  53190. private _debugBoxMesh;
  53191. private _debugSphereMesh;
  53192. private _debugCylinderMesh;
  53193. private _debugMaterial;
  53194. private _debugMeshMeshes;
  53195. /**
  53196. * Creates a new PhysicsViewer
  53197. * @param scene defines the hosting scene
  53198. */
  53199. constructor(scene: Scene);
  53200. /** @hidden */
  53201. protected _updateDebugMeshes(): void;
  53202. /**
  53203. * Renders a specified physic impostor
  53204. * @param impostor defines the impostor to render
  53205. * @param targetMesh defines the mesh represented by the impostor
  53206. * @returns the new debug mesh used to render the impostor
  53207. */
  53208. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  53209. /**
  53210. * Hides a specified physic impostor
  53211. * @param impostor defines the impostor to hide
  53212. */
  53213. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  53214. private _getDebugMaterial;
  53215. private _getDebugBoxMesh;
  53216. private _getDebugSphereMesh;
  53217. private _getDebugCylinderMesh;
  53218. private _getDebugMeshMesh;
  53219. private _getDebugMesh;
  53220. /** Releases all resources */
  53221. dispose(): void;
  53222. }
  53223. }
  53224. declare module "babylonjs/Debug/rayHelper" {
  53225. import { Nullable } from "babylonjs/types";
  53226. import { Ray } from "babylonjs/Culling/ray";
  53227. import { Vector3 } from "babylonjs/Maths/math.vector";
  53228. import { Color3 } from "babylonjs/Maths/math.color";
  53229. import { Scene } from "babylonjs/scene";
  53230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53231. import "babylonjs/Meshes/Builders/linesBuilder";
  53232. /**
  53233. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53234. * in order to better appreciate the issue one might have.
  53235. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53236. */
  53237. export class RayHelper {
  53238. /**
  53239. * Defines the ray we are currently tryin to visualize.
  53240. */
  53241. ray: Nullable<Ray>;
  53242. private _renderPoints;
  53243. private _renderLine;
  53244. private _renderFunction;
  53245. private _scene;
  53246. private _onAfterRenderObserver;
  53247. private _onAfterStepObserver;
  53248. private _attachedToMesh;
  53249. private _meshSpaceDirection;
  53250. private _meshSpaceOrigin;
  53251. /**
  53252. * Helper function to create a colored helper in a scene in one line.
  53253. * @param ray Defines the ray we are currently tryin to visualize
  53254. * @param scene Defines the scene the ray is used in
  53255. * @param color Defines the color we want to see the ray in
  53256. * @returns The newly created ray helper.
  53257. */
  53258. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  53259. /**
  53260. * Instantiate a new ray helper.
  53261. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  53262. * in order to better appreciate the issue one might have.
  53263. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  53264. * @param ray Defines the ray we are currently tryin to visualize
  53265. */
  53266. constructor(ray: Ray);
  53267. /**
  53268. * Shows the ray we are willing to debug.
  53269. * @param scene Defines the scene the ray needs to be rendered in
  53270. * @param color Defines the color the ray needs to be rendered in
  53271. */
  53272. show(scene: Scene, color?: Color3): void;
  53273. /**
  53274. * Hides the ray we are debugging.
  53275. */
  53276. hide(): void;
  53277. private _render;
  53278. /**
  53279. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  53280. * @param mesh Defines the mesh we want the helper attached to
  53281. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  53282. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  53283. * @param length Defines the length of the ray
  53284. */
  53285. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  53286. /**
  53287. * Detach the ray helper from the mesh it has previously been attached to.
  53288. */
  53289. detachFromMesh(): void;
  53290. private _updateToMesh;
  53291. /**
  53292. * Dispose the helper and release its associated resources.
  53293. */
  53294. dispose(): void;
  53295. }
  53296. }
  53297. declare module "babylonjs/Debug/ISkeletonViewer" {
  53298. import { Skeleton } from "babylonjs/Bones/skeleton";
  53299. import { Color3 } from "babylonjs/Maths/math.color";
  53300. /**
  53301. * Defines the options associated with the creation of a SkeletonViewer.
  53302. */
  53303. export interface ISkeletonViewerOptions {
  53304. /** Should the system pause animations before building the Viewer? */
  53305. pauseAnimations: boolean;
  53306. /** Should the system return the skeleton to rest before building? */
  53307. returnToRest: boolean;
  53308. /** public Display Mode of the Viewer */
  53309. displayMode: number;
  53310. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53311. displayOptions: ISkeletonViewerDisplayOptions;
  53312. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  53313. computeBonesUsingShaders: boolean;
  53314. /** Flag ignore non weighted bones */
  53315. useAllBones: boolean;
  53316. }
  53317. /**
  53318. * Defines how to display the various bone meshes for the viewer.
  53319. */
  53320. export interface ISkeletonViewerDisplayOptions {
  53321. /** How far down to start tapering the bone spurs */
  53322. midStep?: number;
  53323. /** How big is the midStep? */
  53324. midStepFactor?: number;
  53325. /** Base for the Sphere Size */
  53326. sphereBaseSize?: number;
  53327. /** The ratio of the sphere to the longest bone in units */
  53328. sphereScaleUnit?: number;
  53329. /** Ratio for the Sphere Size */
  53330. sphereFactor?: number;
  53331. /** Whether a spur should attach its far end to the child bone position */
  53332. spurFollowsChild?: boolean;
  53333. /** Whether to show local axes or not */
  53334. showLocalAxes?: boolean;
  53335. /** Length of each local axis */
  53336. localAxesSize?: number;
  53337. }
  53338. /**
  53339. * Defines the constructor options for the BoneWeight Shader.
  53340. */
  53341. export interface IBoneWeightShaderOptions {
  53342. /** Skeleton to Map */
  53343. skeleton: Skeleton;
  53344. /** Colors for Uninfluenced bones */
  53345. colorBase?: Color3;
  53346. /** Colors for 0.0-0.25 Weight bones */
  53347. colorZero?: Color3;
  53348. /** Color for 0.25-0.5 Weight Influence */
  53349. colorQuarter?: Color3;
  53350. /** Color for 0.5-0.75 Weight Influence */
  53351. colorHalf?: Color3;
  53352. /** Color for 0.75-1 Weight Influence */
  53353. colorFull?: Color3;
  53354. /** Color for Zero Weight Influence */
  53355. targetBoneIndex?: number;
  53356. }
  53357. /**
  53358. * Simple structure of the gradient steps for the Color Map.
  53359. */
  53360. export interface ISkeletonMapShaderColorMapKnot {
  53361. /** Color of the Knot */
  53362. color: Color3;
  53363. /** Location of the Knot */
  53364. location: number;
  53365. }
  53366. /**
  53367. * Defines the constructor options for the SkeletonMap Shader.
  53368. */
  53369. export interface ISkeletonMapShaderOptions {
  53370. /** Skeleton to Map */
  53371. skeleton: Skeleton;
  53372. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  53373. colorMap?: ISkeletonMapShaderColorMapKnot[];
  53374. }
  53375. }
  53376. declare module "babylonjs/Meshes/Builders/ribbonBuilder" {
  53377. import { Nullable } from "babylonjs/types";
  53378. import { Scene } from "babylonjs/scene";
  53379. import { Vector3, Vector2, Vector4 } from "babylonjs/Maths/math.vector";
  53380. import { Color4 } from "babylonjs/Maths/math.color";
  53381. import { Mesh } from "babylonjs/Meshes/mesh";
  53382. /**
  53383. * Class containing static functions to help procedurally build meshes
  53384. */
  53385. export class RibbonBuilder {
  53386. /**
  53387. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  53388. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  53389. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  53390. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  53391. * * 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
  53392. * * 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
  53393. * * 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
  53394. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53395. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53396. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53397. * * 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
  53398. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  53399. * * 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
  53400. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  53401. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53402. * @param name defines the name of the mesh
  53403. * @param options defines the options used to create the mesh
  53404. * @param scene defines the hosting scene
  53405. * @returns the ribbon mesh
  53406. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  53407. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53408. */
  53409. static CreateRibbon(name: string, options: {
  53410. pathArray: Vector3[][];
  53411. closeArray?: boolean;
  53412. closePath?: boolean;
  53413. offset?: number;
  53414. updatable?: boolean;
  53415. sideOrientation?: number;
  53416. frontUVs?: Vector4;
  53417. backUVs?: Vector4;
  53418. instance?: Mesh;
  53419. invertUV?: boolean;
  53420. uvs?: Vector2[];
  53421. colors?: Color4[];
  53422. }, scene?: Nullable<Scene>): Mesh;
  53423. }
  53424. }
  53425. declare module "babylonjs/Meshes/Builders/shapeBuilder" {
  53426. import { Nullable } from "babylonjs/types";
  53427. import { Scene } from "babylonjs/scene";
  53428. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  53429. import { Mesh } from "babylonjs/Meshes/mesh";
  53430. /**
  53431. * Class containing static functions to help procedurally build meshes
  53432. */
  53433. export class ShapeBuilder {
  53434. /**
  53435. * 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.
  53436. * * 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.
  53437. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53438. * * 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.
  53439. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  53440. * * 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
  53441. * * 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
  53442. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  53443. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53444. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53445. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  53446. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  53447. * @param name defines the name of the mesh
  53448. * @param options defines the options used to create the mesh
  53449. * @param scene defines the hosting scene
  53450. * @returns the extruded shape mesh
  53451. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53452. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53453. */
  53454. static ExtrudeShape(name: string, options: {
  53455. shape: Vector3[];
  53456. path: Vector3[];
  53457. scale?: number;
  53458. rotation?: number;
  53459. cap?: number;
  53460. updatable?: boolean;
  53461. sideOrientation?: number;
  53462. frontUVs?: Vector4;
  53463. backUVs?: Vector4;
  53464. instance?: Mesh;
  53465. invertUV?: boolean;
  53466. }, scene?: Nullable<Scene>): Mesh;
  53467. /**
  53468. * Creates an custom extruded shape mesh.
  53469. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  53470. * * 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.
  53471. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  53472. * * 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
  53473. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  53474. * * 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
  53475. * * It must returns a float value that will be the scale value applied to the shape on each path point
  53476. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  53477. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  53478. * * 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
  53479. * * 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
  53480. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  53481. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  53482. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  53483. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  53484. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  53485. * @param name defines the name of the mesh
  53486. * @param options defines the options used to create the mesh
  53487. * @param scene defines the hosting scene
  53488. * @returns the custom extruded shape mesh
  53489. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  53490. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  53491. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  53492. */
  53493. static ExtrudeShapeCustom(name: string, options: {
  53494. shape: Vector3[];
  53495. path: Vector3[];
  53496. scaleFunction?: any;
  53497. rotationFunction?: any;
  53498. ribbonCloseArray?: boolean;
  53499. ribbonClosePath?: boolean;
  53500. cap?: number;
  53501. updatable?: boolean;
  53502. sideOrientation?: number;
  53503. frontUVs?: Vector4;
  53504. backUVs?: Vector4;
  53505. instance?: Mesh;
  53506. invertUV?: boolean;
  53507. }, scene?: Nullable<Scene>): Mesh;
  53508. private static _ExtrudeShapeGeneric;
  53509. }
  53510. }
  53511. declare module "babylonjs/Debug/skeletonViewer" {
  53512. import { Color3 } from "babylonjs/Maths/math.color";
  53513. import { Scene } from "babylonjs/scene";
  53514. import { Nullable } from "babylonjs/types";
  53515. import { Skeleton } from "babylonjs/Bones/skeleton";
  53516. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  53517. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  53518. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  53519. import { ShaderMaterial } from "babylonjs/Materials/shaderMaterial";
  53520. import { ISkeletonViewerOptions, IBoneWeightShaderOptions, ISkeletonMapShaderOptions } from "babylonjs/Debug/ISkeletonViewer";
  53521. /**
  53522. * Class used to render a debug view of a given skeleton
  53523. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  53524. */
  53525. export class SkeletonViewer {
  53526. /** defines the skeleton to render */
  53527. skeleton: Skeleton;
  53528. /** defines the mesh attached to the skeleton */
  53529. mesh: AbstractMesh;
  53530. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53531. autoUpdateBonesMatrices: boolean;
  53532. /** defines the rendering group id to use with the viewer */
  53533. renderingGroupId: number;
  53534. /** is the options for the viewer */
  53535. options: Partial<ISkeletonViewerOptions>;
  53536. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  53537. static readonly DISPLAY_LINES: number;
  53538. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  53539. static readonly DISPLAY_SPHERES: number;
  53540. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  53541. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  53542. /** public static method to create a BoneWeight Shader
  53543. * @param options The constructor options
  53544. * @param scene The scene that the shader is scoped to
  53545. * @returns The created ShaderMaterial
  53546. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  53547. */
  53548. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  53549. /** public static method to create a BoneWeight Shader
  53550. * @param options The constructor options
  53551. * @param scene The scene that the shader is scoped to
  53552. * @returns The created ShaderMaterial
  53553. */
  53554. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  53555. /** private static method to create a BoneWeight Shader
  53556. * @param size The size of the buffer to create (usually the bone count)
  53557. * @param colorMap The gradient data to generate
  53558. * @param scene The scene that the shader is scoped to
  53559. * @returns an Array of floats from the color gradient values
  53560. */
  53561. private static _CreateBoneMapColorBuffer;
  53562. /** If SkeletonViewer scene scope. */
  53563. private _scene;
  53564. /** Gets or sets the color used to render the skeleton */
  53565. color: Color3;
  53566. /** Array of the points of the skeleton fo the line view. */
  53567. private _debugLines;
  53568. /** The SkeletonViewers Mesh. */
  53569. private _debugMesh;
  53570. /** The local axes Meshes. */
  53571. private _localAxes;
  53572. /** If SkeletonViewer is enabled. */
  53573. private _isEnabled;
  53574. /** If SkeletonViewer is ready. */
  53575. private _ready;
  53576. /** SkeletonViewer render observable. */
  53577. private _obs;
  53578. /** The Utility Layer to render the gizmos in. */
  53579. private _utilityLayer;
  53580. private _boneIndices;
  53581. /** Gets the Scene. */
  53582. get scene(): Scene;
  53583. /** Gets the utilityLayer. */
  53584. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  53585. /** Checks Ready Status. */
  53586. get isReady(): Boolean;
  53587. /** Sets Ready Status. */
  53588. set ready(value: boolean);
  53589. /** Gets the debugMesh */
  53590. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  53591. /** Sets the debugMesh */
  53592. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  53593. /** Gets the displayMode */
  53594. get displayMode(): number;
  53595. /** Sets the displayMode */
  53596. set displayMode(value: number);
  53597. /**
  53598. * Creates a new SkeletonViewer
  53599. * @param skeleton defines the skeleton to render
  53600. * @param mesh defines the mesh attached to the skeleton
  53601. * @param scene defines the hosting scene
  53602. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  53603. * @param renderingGroupId defines the rendering group id to use with the viewer
  53604. * @param options All of the extra constructor options for the SkeletonViewer
  53605. */
  53606. constructor(
  53607. /** defines the skeleton to render */
  53608. skeleton: Skeleton,
  53609. /** defines the mesh attached to the skeleton */
  53610. mesh: AbstractMesh,
  53611. /** The Scene scope*/
  53612. scene: Scene,
  53613. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  53614. autoUpdateBonesMatrices?: boolean,
  53615. /** defines the rendering group id to use with the viewer */
  53616. renderingGroupId?: number,
  53617. /** is the options for the viewer */
  53618. options?: Partial<ISkeletonViewerOptions>);
  53619. /** The Dynamic bindings for the update functions */
  53620. private _bindObs;
  53621. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  53622. update(): void;
  53623. /** Gets or sets a boolean indicating if the viewer is enabled */
  53624. set isEnabled(value: boolean);
  53625. get isEnabled(): boolean;
  53626. private _getBonePosition;
  53627. private _getLinesForBonesWithLength;
  53628. private _getLinesForBonesNoLength;
  53629. /** function to revert the mesh and scene back to the initial state. */
  53630. private _revert;
  53631. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  53632. private _getAbsoluteBindPoseToRef;
  53633. /** function to build and bind sphere joint points and spur bone representations. */
  53634. private _buildSpheresAndSpurs;
  53635. private _buildLocalAxes;
  53636. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  53637. private _displayLinesUpdate;
  53638. /** Changes the displayMode of the skeleton viewer
  53639. * @param mode The displayMode numerical value
  53640. */
  53641. changeDisplayMode(mode: number): void;
  53642. /** Sets a display option of the skeleton viewer
  53643. *
  53644. * | Option | Type | Default | Description |
  53645. * | ---------------- | ------- | ------- | ----------- |
  53646. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53647. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53648. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53649. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  53650. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  53651. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  53652. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  53653. *
  53654. * @param option String of the option name
  53655. * @param value The numerical option value
  53656. */
  53657. changeDisplayOptions(option: string, value: number): void;
  53658. /** Release associated resources */
  53659. dispose(): void;
  53660. }
  53661. }
  53662. declare module "babylonjs/Debug/index" {
  53663. export * from "babylonjs/Debug/axesViewer";
  53664. export * from "babylonjs/Debug/boneAxesViewer";
  53665. export * from "babylonjs/Debug/debugLayer";
  53666. export * from "babylonjs/Debug/physicsViewer";
  53667. export * from "babylonjs/Debug/rayHelper";
  53668. export * from "babylonjs/Debug/skeletonViewer";
  53669. export * from "babylonjs/Debug/ISkeletonViewer";
  53670. }
  53671. declare module "babylonjs/DeviceInput/InputDevices/deviceEnums" {
  53672. /**
  53673. * Enum for Device Types
  53674. */
  53675. export enum DeviceType {
  53676. /** Generic */
  53677. Generic = 0,
  53678. /** Keyboard */
  53679. Keyboard = 1,
  53680. /** Mouse */
  53681. Mouse = 2,
  53682. /** Touch Pointers */
  53683. Touch = 3,
  53684. /** PS4 Dual Shock */
  53685. DualShock = 4,
  53686. /** Xbox */
  53687. Xbox = 5,
  53688. /** Switch Controller */
  53689. Switch = 6
  53690. }
  53691. /**
  53692. * Enum for All Pointers (Touch/Mouse)
  53693. */
  53694. export enum PointerInput {
  53695. /** Horizontal Axis */
  53696. Horizontal = 0,
  53697. /** Vertical Axis */
  53698. Vertical = 1,
  53699. /** Left Click or Touch */
  53700. LeftClick = 2,
  53701. /** Middle Click */
  53702. MiddleClick = 3,
  53703. /** Right Click */
  53704. RightClick = 4,
  53705. /** Browser Back */
  53706. BrowserBack = 5,
  53707. /** Browser Forward */
  53708. BrowserForward = 6
  53709. }
  53710. /**
  53711. * Enum for Dual Shock Gamepad
  53712. */
  53713. export enum DualShockInput {
  53714. /** Cross */
  53715. Cross = 0,
  53716. /** Circle */
  53717. Circle = 1,
  53718. /** Square */
  53719. Square = 2,
  53720. /** Triangle */
  53721. Triangle = 3,
  53722. /** L1 */
  53723. L1 = 4,
  53724. /** R1 */
  53725. R1 = 5,
  53726. /** L2 */
  53727. L2 = 6,
  53728. /** R2 */
  53729. R2 = 7,
  53730. /** Share */
  53731. Share = 8,
  53732. /** Options */
  53733. Options = 9,
  53734. /** L3 */
  53735. L3 = 10,
  53736. /** R3 */
  53737. R3 = 11,
  53738. /** DPadUp */
  53739. DPadUp = 12,
  53740. /** DPadDown */
  53741. DPadDown = 13,
  53742. /** DPadLeft */
  53743. DPadLeft = 14,
  53744. /** DRight */
  53745. DPadRight = 15,
  53746. /** Home */
  53747. Home = 16,
  53748. /** TouchPad */
  53749. TouchPad = 17,
  53750. /** LStickXAxis */
  53751. LStickXAxis = 18,
  53752. /** LStickYAxis */
  53753. LStickYAxis = 19,
  53754. /** RStickXAxis */
  53755. RStickXAxis = 20,
  53756. /** RStickYAxis */
  53757. RStickYAxis = 21
  53758. }
  53759. /**
  53760. * Enum for Xbox Gamepad
  53761. */
  53762. export enum XboxInput {
  53763. /** A */
  53764. A = 0,
  53765. /** B */
  53766. B = 1,
  53767. /** X */
  53768. X = 2,
  53769. /** Y */
  53770. Y = 3,
  53771. /** LB */
  53772. LB = 4,
  53773. /** RB */
  53774. RB = 5,
  53775. /** LT */
  53776. LT = 6,
  53777. /** RT */
  53778. RT = 7,
  53779. /** Back */
  53780. Back = 8,
  53781. /** Start */
  53782. Start = 9,
  53783. /** LS */
  53784. LS = 10,
  53785. /** RS */
  53786. RS = 11,
  53787. /** DPadUp */
  53788. DPadUp = 12,
  53789. /** DPadDown */
  53790. DPadDown = 13,
  53791. /** DPadLeft */
  53792. DPadLeft = 14,
  53793. /** DRight */
  53794. DPadRight = 15,
  53795. /** Home */
  53796. Home = 16,
  53797. /** LStickXAxis */
  53798. LStickXAxis = 17,
  53799. /** LStickYAxis */
  53800. LStickYAxis = 18,
  53801. /** RStickXAxis */
  53802. RStickXAxis = 19,
  53803. /** RStickYAxis */
  53804. RStickYAxis = 20
  53805. }
  53806. /**
  53807. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  53808. */
  53809. export enum SwitchInput {
  53810. /** B */
  53811. B = 0,
  53812. /** A */
  53813. A = 1,
  53814. /** Y */
  53815. Y = 2,
  53816. /** X */
  53817. X = 3,
  53818. /** L */
  53819. L = 4,
  53820. /** R */
  53821. R = 5,
  53822. /** ZL */
  53823. ZL = 6,
  53824. /** ZR */
  53825. ZR = 7,
  53826. /** Minus */
  53827. Minus = 8,
  53828. /** Plus */
  53829. Plus = 9,
  53830. /** LS */
  53831. LS = 10,
  53832. /** RS */
  53833. RS = 11,
  53834. /** DPadUp */
  53835. DPadUp = 12,
  53836. /** DPadDown */
  53837. DPadDown = 13,
  53838. /** DPadLeft */
  53839. DPadLeft = 14,
  53840. /** DRight */
  53841. DPadRight = 15,
  53842. /** Home */
  53843. Home = 16,
  53844. /** Capture */
  53845. Capture = 17,
  53846. /** LStickXAxis */
  53847. LStickXAxis = 18,
  53848. /** LStickYAxis */
  53849. LStickYAxis = 19,
  53850. /** RStickXAxis */
  53851. RStickXAxis = 20,
  53852. /** RStickYAxis */
  53853. RStickYAxis = 21
  53854. }
  53855. }
  53856. declare module "babylonjs/DeviceInput/deviceInputSystem" {
  53857. import { Engine } from "babylonjs/Engines/engine";
  53858. import { IDisposable } from "babylonjs/scene";
  53859. import { Nullable } from "babylonjs/types";
  53860. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53861. /**
  53862. * This class will take all inputs from Keyboard, Pointer, and
  53863. * any Gamepads and provide a polling system that all devices
  53864. * will use. This class assumes that there will only be one
  53865. * pointer device and one keyboard.
  53866. */
  53867. export class DeviceInputSystem implements IDisposable {
  53868. /**
  53869. * Callback to be triggered when a device is connected
  53870. */
  53871. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53872. /**
  53873. * Callback to be triggered when a device is disconnected
  53874. */
  53875. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  53876. /**
  53877. * Callback to be triggered when event driven input is updated
  53878. */
  53879. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  53880. private _inputs;
  53881. private _gamepads;
  53882. private _keyboardActive;
  53883. private _pointerActive;
  53884. private _elementToAttachTo;
  53885. private _keyboardDownEvent;
  53886. private _keyboardUpEvent;
  53887. private _pointerMoveEvent;
  53888. private _pointerDownEvent;
  53889. private _pointerUpEvent;
  53890. private _gamepadConnectedEvent;
  53891. private _gamepadDisconnectedEvent;
  53892. private static _MAX_KEYCODES;
  53893. private static _MAX_POINTER_INPUTS;
  53894. private constructor();
  53895. /**
  53896. * Creates a new DeviceInputSystem instance
  53897. * @param engine Engine to pull input element from
  53898. * @returns The new instance
  53899. */
  53900. static Create(engine: Engine): DeviceInputSystem;
  53901. /**
  53902. * Checks for current device input value, given an id and input index
  53903. * @param deviceName Id of connected device
  53904. * @param inputIndex Index of device input
  53905. * @returns Current value of input
  53906. */
  53907. /**
  53908. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  53909. * @param deviceType Enum specifiying device type
  53910. * @param deviceSlot "Slot" or index that device is referenced in
  53911. * @param inputIndex Id of input to be checked
  53912. * @returns Current value of input
  53913. */
  53914. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  53915. /**
  53916. * Dispose of all the eventlisteners
  53917. */
  53918. dispose(): void;
  53919. /**
  53920. * Add device and inputs to device array
  53921. * @param deviceType Enum specifiying device type
  53922. * @param deviceSlot "Slot" or index that device is referenced in
  53923. * @param numberOfInputs Number of input entries to create for given device
  53924. */
  53925. private _registerDevice;
  53926. /**
  53927. * Given a specific device name, remove that device from the device map
  53928. * @param deviceType Enum specifiying device type
  53929. * @param deviceSlot "Slot" or index that device is referenced in
  53930. */
  53931. private _unregisterDevice;
  53932. /**
  53933. * Handle all actions that come from keyboard interaction
  53934. */
  53935. private _handleKeyActions;
  53936. /**
  53937. * Handle all actions that come from pointer interaction
  53938. */
  53939. private _handlePointerActions;
  53940. /**
  53941. * Handle all actions that come from gamepad interaction
  53942. */
  53943. private _handleGamepadActions;
  53944. /**
  53945. * Update all non-event based devices with each frame
  53946. * @param deviceType Enum specifiying device type
  53947. * @param deviceSlot "Slot" or index that device is referenced in
  53948. * @param inputIndex Id of input to be checked
  53949. */
  53950. private _updateDevice;
  53951. /**
  53952. * Gets DeviceType from the device name
  53953. * @param deviceName Name of Device from DeviceInputSystem
  53954. * @returns DeviceType enum value
  53955. */
  53956. private _getGamepadDeviceType;
  53957. }
  53958. }
  53959. declare module "babylonjs/DeviceInput/InputDevices/deviceTypes" {
  53960. import { DeviceType, PointerInput, DualShockInput, XboxInput, SwitchInput } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53961. /**
  53962. * Type to handle enforcement of inputs
  53963. */
  53964. 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;
  53965. }
  53966. declare module "babylonjs/DeviceInput/InputDevices/deviceSourceManager" {
  53967. import { DeviceInputSystem } from "babylonjs/DeviceInput/deviceInputSystem";
  53968. import { Engine } from "babylonjs/Engines/engine";
  53969. import { IDisposable } from "babylonjs/scene";
  53970. import { DeviceType } from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  53971. import { Nullable } from "babylonjs/types";
  53972. import { Observable } from "babylonjs/Misc/observable";
  53973. import { DeviceInput } from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  53974. /**
  53975. * Class that handles all input for a specific device
  53976. */
  53977. export class DeviceSource<T extends DeviceType> {
  53978. /** Type of device */
  53979. readonly deviceType: DeviceType;
  53980. /** "Slot" or index that device is referenced in */
  53981. readonly deviceSlot: number;
  53982. /**
  53983. * Observable to handle device input changes per device
  53984. */
  53985. readonly onInputChangedObservable: Observable<{
  53986. inputIndex: DeviceInput<T>;
  53987. previousState: Nullable<number>;
  53988. currentState: Nullable<number>;
  53989. }>;
  53990. private readonly _deviceInputSystem;
  53991. /**
  53992. * Default Constructor
  53993. * @param deviceInputSystem Reference to DeviceInputSystem
  53994. * @param deviceType Type of device
  53995. * @param deviceSlot "Slot" or index that device is referenced in
  53996. */
  53997. constructor(deviceInputSystem: DeviceInputSystem,
  53998. /** Type of device */
  53999. deviceType: DeviceType,
  54000. /** "Slot" or index that device is referenced in */
  54001. deviceSlot?: number);
  54002. /**
  54003. * Get input for specific input
  54004. * @param inputIndex index of specific input on device
  54005. * @returns Input value from DeviceInputSystem
  54006. */
  54007. getInput(inputIndex: DeviceInput<T>): number;
  54008. }
  54009. /**
  54010. * Class to keep track of devices
  54011. */
  54012. export class DeviceSourceManager implements IDisposable {
  54013. /**
  54014. * Observable to be triggered when before a device is connected
  54015. */
  54016. readonly onBeforeDeviceConnectedObservable: Observable<{
  54017. deviceType: DeviceType;
  54018. deviceSlot: number;
  54019. }>;
  54020. /**
  54021. * Observable to be triggered when before a device is disconnected
  54022. */
  54023. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  54024. deviceType: DeviceType;
  54025. deviceSlot: number;
  54026. }>;
  54027. /**
  54028. * Observable to be triggered when after a device is connected
  54029. */
  54030. readonly onAfterDeviceConnectedObservable: Observable<{
  54031. deviceType: DeviceType;
  54032. deviceSlot: number;
  54033. }>;
  54034. /**
  54035. * Observable to be triggered when after a device is disconnected
  54036. */
  54037. readonly onAfterDeviceDisconnectedObservable: Observable<{
  54038. deviceType: DeviceType;
  54039. deviceSlot: number;
  54040. }>;
  54041. private readonly _devices;
  54042. private readonly _firstDevice;
  54043. private readonly _deviceInputSystem;
  54044. /**
  54045. * Default Constructor
  54046. * @param engine engine to pull input element from
  54047. */
  54048. constructor(engine: Engine);
  54049. /**
  54050. * Gets a DeviceSource, given a type and slot
  54051. * @param deviceType Enum specifying device type
  54052. * @param deviceSlot "Slot" or index that device is referenced in
  54053. * @returns DeviceSource object
  54054. */
  54055. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  54056. /**
  54057. * Gets an array of DeviceSource objects for a given device type
  54058. * @param deviceType Enum specifying device type
  54059. * @returns Array of DeviceSource objects
  54060. */
  54061. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  54062. /**
  54063. * Dispose of DeviceInputSystem and other parts
  54064. */
  54065. dispose(): void;
  54066. /**
  54067. * Function to add device name to device list
  54068. * @param deviceType Enum specifying device type
  54069. * @param deviceSlot "Slot" or index that device is referenced in
  54070. */
  54071. private _addDevice;
  54072. /**
  54073. * Function to remove device name to device list
  54074. * @param deviceType Enum specifying device type
  54075. * @param deviceSlot "Slot" or index that device is referenced in
  54076. */
  54077. private _removeDevice;
  54078. /**
  54079. * Updates array storing first connected device of each type
  54080. * @param type Type of Device
  54081. */
  54082. private _updateFirstDevices;
  54083. }
  54084. }
  54085. declare module "babylonjs/DeviceInput/index" {
  54086. export * from "babylonjs/DeviceInput/deviceInputSystem";
  54087. export * from "babylonjs/DeviceInput/InputDevices/deviceEnums";
  54088. export * from "babylonjs/DeviceInput/InputDevices/deviceTypes";
  54089. import "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  54090. export * from "babylonjs/DeviceInput/InputDevices/deviceSourceManager";
  54091. }
  54092. declare module "babylonjs/Engines/nullEngine" {
  54093. import { Nullable, FloatArray, IndicesArray } from "babylonjs/types";
  54094. import { Engine } from "babylonjs/Engines/engine";
  54095. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  54096. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  54097. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54098. import { Effect } from "babylonjs/Materials/effect";
  54099. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  54100. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54101. import { IColor4Like, IViewportLike } from "babylonjs/Maths/math.like";
  54102. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  54103. /**
  54104. * Options to create the null engine
  54105. */
  54106. export class NullEngineOptions {
  54107. /**
  54108. * Render width (Default: 512)
  54109. */
  54110. renderWidth: number;
  54111. /**
  54112. * Render height (Default: 256)
  54113. */
  54114. renderHeight: number;
  54115. /**
  54116. * Texture size (Default: 512)
  54117. */
  54118. textureSize: number;
  54119. /**
  54120. * If delta time between frames should be constant
  54121. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54122. */
  54123. deterministicLockstep: boolean;
  54124. /**
  54125. * Maximum about of steps between frames (Default: 4)
  54126. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54127. */
  54128. lockstepMaxSteps: number;
  54129. /**
  54130. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  54131. */
  54132. useHighPrecisionMatrix?: boolean;
  54133. }
  54134. /**
  54135. * The null engine class provides support for headless version of babylon.js.
  54136. * This can be used in server side scenario or for testing purposes
  54137. */
  54138. export class NullEngine extends Engine {
  54139. private _options;
  54140. /**
  54141. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  54142. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54143. * @returns true if engine is in deterministic lock step mode
  54144. */
  54145. isDeterministicLockStep(): boolean;
  54146. /**
  54147. * Gets the max steps when engine is running in deterministic lock step
  54148. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  54149. * @returns the max steps
  54150. */
  54151. getLockstepMaxSteps(): number;
  54152. /**
  54153. * Gets the current hardware scaling level.
  54154. * By default the hardware scaling level is computed from the window device ratio.
  54155. * 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.
  54156. * @returns a number indicating the current hardware scaling level
  54157. */
  54158. getHardwareScalingLevel(): number;
  54159. constructor(options?: NullEngineOptions);
  54160. /**
  54161. * Creates a vertex buffer
  54162. * @param vertices the data for the vertex buffer
  54163. * @returns the new WebGL static buffer
  54164. */
  54165. createVertexBuffer(vertices: FloatArray): DataBuffer;
  54166. /**
  54167. * Creates a new index buffer
  54168. * @param indices defines the content of the index buffer
  54169. * @param updatable defines if the index buffer must be updatable
  54170. * @returns a new webGL buffer
  54171. */
  54172. createIndexBuffer(indices: IndicesArray): DataBuffer;
  54173. /**
  54174. * Clear the current render buffer or the current render target (if any is set up)
  54175. * @param color defines the color to use
  54176. * @param backBuffer defines if the back buffer must be cleared
  54177. * @param depth defines if the depth buffer must be cleared
  54178. * @param stencil defines if the stencil buffer must be cleared
  54179. */
  54180. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  54181. /**
  54182. * Gets the current render width
  54183. * @param useScreen defines if screen size must be used (or the current render target if any)
  54184. * @returns a number defining the current render width
  54185. */
  54186. getRenderWidth(useScreen?: boolean): number;
  54187. /**
  54188. * Gets the current render height
  54189. * @param useScreen defines if screen size must be used (or the current render target if any)
  54190. * @returns a number defining the current render height
  54191. */
  54192. getRenderHeight(useScreen?: boolean): number;
  54193. /**
  54194. * Set the WebGL's viewport
  54195. * @param viewport defines the viewport element to be used
  54196. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  54197. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  54198. */
  54199. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  54200. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  54201. /**
  54202. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  54203. * @param pipelineContext defines the pipeline context to use
  54204. * @param uniformsNames defines the list of uniform names
  54205. * @returns an array of webGL uniform locations
  54206. */
  54207. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  54208. /**
  54209. * Gets the lsit of active attributes for a given webGL program
  54210. * @param pipelineContext defines the pipeline context to use
  54211. * @param attributesNames defines the list of attribute names to get
  54212. * @returns an array of indices indicating the offset of each attribute
  54213. */
  54214. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  54215. /**
  54216. * Binds an effect to the webGL context
  54217. * @param effect defines the effect to bind
  54218. */
  54219. bindSamplers(effect: Effect): void;
  54220. /**
  54221. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  54222. * @param effect defines the effect to activate
  54223. */
  54224. enableEffect(effect: Effect): void;
  54225. /**
  54226. * Set various states to the webGL context
  54227. * @param culling defines backface culling state
  54228. * @param zOffset defines the value to apply to zOffset (0 by default)
  54229. * @param force defines if states must be applied even if cache is up to date
  54230. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  54231. */
  54232. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  54233. /**
  54234. * Set the value of an uniform to an array of int32
  54235. * @param uniform defines the webGL uniform location where to store the value
  54236. * @param array defines the array of int32 to store
  54237. * @returns true if value was set
  54238. */
  54239. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54240. /**
  54241. * Set the value of an uniform to an array of int32 (stored as vec2)
  54242. * @param uniform defines the webGL uniform location where to store the value
  54243. * @param array defines the array of int32 to store
  54244. * @returns true if value was set
  54245. */
  54246. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54247. /**
  54248. * Set the value of an uniform to an array of int32 (stored as vec3)
  54249. * @param uniform defines the webGL uniform location where to store the value
  54250. * @param array defines the array of int32 to store
  54251. * @returns true if value was set
  54252. */
  54253. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54254. /**
  54255. * Set the value of an uniform to an array of int32 (stored as vec4)
  54256. * @param uniform defines the webGL uniform location where to store the value
  54257. * @param array defines the array of int32 to store
  54258. * @returns true if value was set
  54259. */
  54260. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  54261. /**
  54262. * Set the value of an uniform to an array of float32
  54263. * @param uniform defines the webGL uniform location where to store the value
  54264. * @param array defines the array of float32 to store
  54265. * @returns true if value was set
  54266. */
  54267. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54268. /**
  54269. * Set the value of an uniform to an array of float32 (stored as vec2)
  54270. * @param uniform defines the webGL uniform location where to store the value
  54271. * @param array defines the array of float32 to store
  54272. * @returns true if value was set
  54273. */
  54274. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54275. /**
  54276. * Set the value of an uniform to an array of float32 (stored as vec3)
  54277. * @param uniform defines the webGL uniform location where to store the value
  54278. * @param array defines the array of float32 to store
  54279. * @returns true if value was set
  54280. */
  54281. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54282. /**
  54283. * Set the value of an uniform to an array of float32 (stored as vec4)
  54284. * @param uniform defines the webGL uniform location where to store the value
  54285. * @param array defines the array of float32 to store
  54286. * @returns true if value was set
  54287. */
  54288. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  54289. /**
  54290. * Set the value of an uniform to an array of number
  54291. * @param uniform defines the webGL uniform location where to store the value
  54292. * @param array defines the array of number to store
  54293. * @returns true if value was set
  54294. */
  54295. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  54296. /**
  54297. * Set the value of an uniform to an array of number (stored as vec2)
  54298. * @param uniform defines the webGL uniform location where to store the value
  54299. * @param array defines the array of number to store
  54300. * @returns true if value was set
  54301. */
  54302. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  54303. /**
  54304. * Set the value of an uniform to an array of number (stored as vec3)
  54305. * @param uniform defines the webGL uniform location where to store the value
  54306. * @param array defines the array of number to store
  54307. * @returns true if value was set
  54308. */
  54309. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  54310. /**
  54311. * Set the value of an uniform to an array of number (stored as vec4)
  54312. * @param uniform defines the webGL uniform location where to store the value
  54313. * @param array defines the array of number to store
  54314. * @returns true if value was set
  54315. */
  54316. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  54317. /**
  54318. * Set the value of an uniform to an array of float32 (stored as matrices)
  54319. * @param uniform defines the webGL uniform location where to store the value
  54320. * @param matrices defines the array of float32 to store
  54321. * @returns true if value was set
  54322. */
  54323. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  54324. /**
  54325. * Set the value of an uniform to a matrix (3x3)
  54326. * @param uniform defines the webGL uniform location where to store the value
  54327. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  54328. * @returns true if value was set
  54329. */
  54330. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54331. /**
  54332. * Set the value of an uniform to a matrix (2x2)
  54333. * @param uniform defines the webGL uniform location where to store the value
  54334. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  54335. * @returns true if value was set
  54336. */
  54337. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  54338. /**
  54339. * Set the value of an uniform to a number (float)
  54340. * @param uniform defines the webGL uniform location where to store the value
  54341. * @param value defines the float number to store
  54342. * @returns true if value was set
  54343. */
  54344. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  54345. /**
  54346. * Set the value of an uniform to a vec2
  54347. * @param uniform defines the webGL uniform location where to store the value
  54348. * @param x defines the 1st component of the value
  54349. * @param y defines the 2nd component of the value
  54350. * @returns true if value was set
  54351. */
  54352. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  54353. /**
  54354. * Set the value of an uniform to a vec3
  54355. * @param uniform defines the webGL uniform location where to store the value
  54356. * @param x defines the 1st component of the value
  54357. * @param y defines the 2nd component of the value
  54358. * @param z defines the 3rd component of the value
  54359. * @returns true if value was set
  54360. */
  54361. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  54362. /**
  54363. * Set the value of an uniform to a boolean
  54364. * @param uniform defines the webGL uniform location where to store the value
  54365. * @param bool defines the boolean to store
  54366. * @returns true if value was set
  54367. */
  54368. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  54369. /**
  54370. * Set the value of an uniform to a vec4
  54371. * @param uniform defines the webGL uniform location where to store the value
  54372. * @param x defines the 1st component of the value
  54373. * @param y defines the 2nd component of the value
  54374. * @param z defines the 3rd component of the value
  54375. * @param w defines the 4th component of the value
  54376. * @returns true if value was set
  54377. */
  54378. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  54379. /**
  54380. * Sets the current alpha mode
  54381. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  54382. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  54383. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  54384. */
  54385. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  54386. /**
  54387. * Bind webGl buffers directly to the webGL context
  54388. * @param vertexBuffers defines the vertex buffer to bind
  54389. * @param indexBuffer defines the index buffer to bind
  54390. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  54391. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  54392. * @param effect defines the effect associated with the vertex buffer
  54393. */
  54394. bindBuffers(vertexBuffers: {
  54395. [key: string]: VertexBuffer;
  54396. }, indexBuffer: DataBuffer, effect: Effect): void;
  54397. /**
  54398. * Force the entire cache to be cleared
  54399. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  54400. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  54401. */
  54402. wipeCaches(bruteForce?: boolean): void;
  54403. /**
  54404. * Send a draw order
  54405. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  54406. * @param indexStart defines the starting index
  54407. * @param indexCount defines the number of index to draw
  54408. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54409. */
  54410. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  54411. /**
  54412. * Draw a list of indexed primitives
  54413. * @param fillMode defines the primitive to use
  54414. * @param indexStart defines the starting index
  54415. * @param indexCount defines the number of index to draw
  54416. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54417. */
  54418. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  54419. /**
  54420. * Draw a list of unindexed primitives
  54421. * @param fillMode defines the primitive to use
  54422. * @param verticesStart defines the index of first vertex to draw
  54423. * @param verticesCount defines the count of vertices to draw
  54424. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  54425. */
  54426. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  54427. /** @hidden */
  54428. _createTexture(): WebGLTexture;
  54429. /** @hidden */
  54430. _releaseTexture(texture: InternalTexture): void;
  54431. /**
  54432. * Usually called from Texture.ts.
  54433. * Passed information to create a WebGLTexture
  54434. * @param urlArg defines a value which contains one of the following:
  54435. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  54436. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  54437. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  54438. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  54439. * @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)
  54440. * @param scene needed for loading to the correct scene
  54441. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  54442. * @param onLoad optional callback to be called upon successful completion
  54443. * @param onError optional callback to be called upon failure
  54444. * @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
  54445. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  54446. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  54447. * @param forcedExtension defines the extension to use to pick the right loader
  54448. * @param mimeType defines an optional mime type
  54449. * @returns a InternalTexture for assignment back into BABYLON.Texture
  54450. */
  54451. 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;
  54452. /**
  54453. * Creates a new render target texture
  54454. * @param size defines the size of the texture
  54455. * @param options defines the options used to create the texture
  54456. * @returns a new render target texture stored in an InternalTexture
  54457. */
  54458. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  54459. /**
  54460. * Update the sampling mode of a given texture
  54461. * @param samplingMode defines the required sampling mode
  54462. * @param texture defines the texture to update
  54463. */
  54464. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  54465. /**
  54466. * Binds the frame buffer to the specified texture.
  54467. * @param texture The texture to render to or null for the default canvas
  54468. * @param faceIndex The face of the texture to render to in case of cube texture
  54469. * @param requiredWidth The width of the target to render to
  54470. * @param requiredHeight The height of the target to render to
  54471. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  54472. * @param lodLevel defines le lod level to bind to the frame buffer
  54473. */
  54474. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  54475. /**
  54476. * Unbind the current render target texture from the webGL context
  54477. * @param texture defines the render target texture to unbind
  54478. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  54479. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  54480. */
  54481. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  54482. /**
  54483. * Creates a dynamic vertex buffer
  54484. * @param vertices the data for the dynamic vertex buffer
  54485. * @returns the new WebGL dynamic buffer
  54486. */
  54487. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  54488. /**
  54489. * Update the content of a dynamic texture
  54490. * @param texture defines the texture to update
  54491. * @param canvas defines the canvas containing the source
  54492. * @param invertY defines if data must be stored with Y axis inverted
  54493. * @param premulAlpha defines if alpha is stored as premultiplied
  54494. * @param format defines the format of the data
  54495. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  54496. */
  54497. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  54498. /**
  54499. * Gets a boolean indicating if all created effects are ready
  54500. * @returns true if all effects are ready
  54501. */
  54502. areAllEffectsReady(): boolean;
  54503. /**
  54504. * @hidden
  54505. * Get the current error code of the webGL context
  54506. * @returns the error code
  54507. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  54508. */
  54509. getError(): number;
  54510. /** @hidden */
  54511. _getUnpackAlignement(): number;
  54512. /** @hidden */
  54513. _unpackFlipY(value: boolean): void;
  54514. /**
  54515. * Update a dynamic index buffer
  54516. * @param indexBuffer defines the target index buffer
  54517. * @param indices defines the data to update
  54518. * @param offset defines the offset in the target index buffer where update should start
  54519. */
  54520. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  54521. /**
  54522. * Updates a dynamic vertex buffer.
  54523. * @param vertexBuffer the vertex buffer to update
  54524. * @param vertices the data used to update the vertex buffer
  54525. * @param byteOffset the byte offset of the data (optional)
  54526. * @param byteLength the byte length of the data (optional)
  54527. */
  54528. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  54529. /** @hidden */
  54530. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  54531. /** @hidden */
  54532. _bindTexture(channel: number, texture: InternalTexture): void;
  54533. protected _deleteBuffer(buffer: WebGLBuffer): void;
  54534. /**
  54535. * 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
  54536. */
  54537. releaseEffects(): void;
  54538. displayLoadingUI(): void;
  54539. hideLoadingUI(): void;
  54540. /** @hidden */
  54541. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54542. /** @hidden */
  54543. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54544. /** @hidden */
  54545. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  54546. /** @hidden */
  54547. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  54548. }
  54549. }
  54550. declare module "babylonjs/Instrumentation/timeToken" {
  54551. import { Nullable } from "babylonjs/types";
  54552. /**
  54553. * @hidden
  54554. **/
  54555. export class _TimeToken {
  54556. _startTimeQuery: Nullable<WebGLQuery>;
  54557. _endTimeQuery: Nullable<WebGLQuery>;
  54558. _timeElapsedQuery: Nullable<WebGLQuery>;
  54559. _timeElapsedQueryEnded: boolean;
  54560. }
  54561. }
  54562. declare module "babylonjs/Engines/Extensions/engine.occlusionQuery" {
  54563. import { Nullable, int } from "babylonjs/types";
  54564. import { _TimeToken } from "babylonjs/Instrumentation/timeToken";
  54565. /** @hidden */
  54566. export class _OcclusionDataStorage {
  54567. /** @hidden */
  54568. occlusionInternalRetryCounter: number;
  54569. /** @hidden */
  54570. isOcclusionQueryInProgress: boolean;
  54571. /** @hidden */
  54572. isOccluded: boolean;
  54573. /** @hidden */
  54574. occlusionRetryCount: number;
  54575. /** @hidden */
  54576. occlusionType: number;
  54577. /** @hidden */
  54578. occlusionQueryAlgorithmType: number;
  54579. }
  54580. module "babylonjs/Engines/engine" {
  54581. interface Engine {
  54582. /**
  54583. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  54584. * @return the new query
  54585. */
  54586. createQuery(): WebGLQuery;
  54587. /**
  54588. * Delete and release a webGL query
  54589. * @param query defines the query to delete
  54590. * @return the current engine
  54591. */
  54592. deleteQuery(query: WebGLQuery): Engine;
  54593. /**
  54594. * Check if a given query has resolved and got its value
  54595. * @param query defines the query to check
  54596. * @returns true if the query got its value
  54597. */
  54598. isQueryResultAvailable(query: WebGLQuery): boolean;
  54599. /**
  54600. * Gets the value of a given query
  54601. * @param query defines the query to check
  54602. * @returns the value of the query
  54603. */
  54604. getQueryResult(query: WebGLQuery): number;
  54605. /**
  54606. * Initiates an occlusion query
  54607. * @param algorithmType defines the algorithm to use
  54608. * @param query defines the query to use
  54609. * @returns the current engine
  54610. * @see https://doc.babylonjs.com/features/occlusionquery
  54611. */
  54612. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  54613. /**
  54614. * Ends an occlusion query
  54615. * @see https://doc.babylonjs.com/features/occlusionquery
  54616. * @param algorithmType defines the algorithm to use
  54617. * @returns the current engine
  54618. */
  54619. endOcclusionQuery(algorithmType: number): Engine;
  54620. /**
  54621. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  54622. * Please note that only one query can be issued at a time
  54623. * @returns a time token used to track the time span
  54624. */
  54625. startTimeQuery(): Nullable<_TimeToken>;
  54626. /**
  54627. * Ends a time query
  54628. * @param token defines the token used to measure the time span
  54629. * @returns the time spent (in ns)
  54630. */
  54631. endTimeQuery(token: _TimeToken): int;
  54632. /** @hidden */
  54633. _currentNonTimestampToken: Nullable<_TimeToken>;
  54634. /** @hidden */
  54635. _createTimeQuery(): WebGLQuery;
  54636. /** @hidden */
  54637. _deleteTimeQuery(query: WebGLQuery): void;
  54638. /** @hidden */
  54639. _getGlAlgorithmType(algorithmType: number): number;
  54640. /** @hidden */
  54641. _getTimeQueryResult(query: WebGLQuery): any;
  54642. /** @hidden */
  54643. _getTimeQueryAvailability(query: WebGLQuery): any;
  54644. }
  54645. }
  54646. module "babylonjs/Meshes/abstractMesh" {
  54647. interface AbstractMesh {
  54648. /**
  54649. * Backing filed
  54650. * @hidden
  54651. */
  54652. __occlusionDataStorage: _OcclusionDataStorage;
  54653. /**
  54654. * Access property
  54655. * @hidden
  54656. */
  54657. _occlusionDataStorage: _OcclusionDataStorage;
  54658. /**
  54659. * 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.
  54660. * The default value is -1 which means don't break the query and wait till the result
  54661. * @see https://doc.babylonjs.com/features/occlusionquery
  54662. */
  54663. occlusionRetryCount: number;
  54664. /**
  54665. * 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:
  54666. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  54667. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  54668. * * 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.
  54669. * @see https://doc.babylonjs.com/features/occlusionquery
  54670. */
  54671. occlusionType: number;
  54672. /**
  54673. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  54674. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  54675. * * 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.
  54676. * @see https://doc.babylonjs.com/features/occlusionquery
  54677. */
  54678. occlusionQueryAlgorithmType: number;
  54679. /**
  54680. * 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
  54681. * @see https://doc.babylonjs.com/features/occlusionquery
  54682. */
  54683. isOccluded: boolean;
  54684. /**
  54685. * Flag to check the progress status of the query
  54686. * @see https://doc.babylonjs.com/features/occlusionquery
  54687. */
  54688. isOcclusionQueryInProgress: boolean;
  54689. }
  54690. }
  54691. }
  54692. declare module "babylonjs/Engines/Extensions/engine.transformFeedback" {
  54693. import { Nullable } from "babylonjs/types";
  54694. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  54695. /** @hidden */
  54696. export var _forceTransformFeedbackToBundle: boolean;
  54697. module "babylonjs/Engines/engine" {
  54698. interface Engine {
  54699. /**
  54700. * Creates a webGL transform feedback object
  54701. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  54702. * @returns the webGL transform feedback object
  54703. */
  54704. createTransformFeedback(): WebGLTransformFeedback;
  54705. /**
  54706. * Delete a webGL transform feedback object
  54707. * @param value defines the webGL transform feedback object to delete
  54708. */
  54709. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  54710. /**
  54711. * Bind a webGL transform feedback object to the webgl context
  54712. * @param value defines the webGL transform feedback object to bind
  54713. */
  54714. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  54715. /**
  54716. * Begins a transform feedback operation
  54717. * @param usePoints defines if points or triangles must be used
  54718. */
  54719. beginTransformFeedback(usePoints: boolean): void;
  54720. /**
  54721. * Ends a transform feedback operation
  54722. */
  54723. endTransformFeedback(): void;
  54724. /**
  54725. * Specify the varyings to use with transform feedback
  54726. * @param program defines the associated webGL program
  54727. * @param value defines the list of strings representing the varying names
  54728. */
  54729. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  54730. /**
  54731. * Bind a webGL buffer for a transform feedback operation
  54732. * @param value defines the webGL buffer to bind
  54733. */
  54734. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  54735. }
  54736. }
  54737. }
  54738. declare module "babylonjs/Engines/Extensions/engine.views" {
  54739. import { Camera } from "babylonjs/Cameras/camera";
  54740. import { Nullable } from "babylonjs/types";
  54741. /**
  54742. * Class used to define an additional view for the engine
  54743. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54744. */
  54745. export class EngineView {
  54746. /** Defines the canvas where to render the view */
  54747. target: HTMLCanvasElement;
  54748. /** Defines an optional camera used to render the view (will use active camera else) */
  54749. camera?: Camera;
  54750. }
  54751. module "babylonjs/Engines/engine" {
  54752. interface Engine {
  54753. /**
  54754. * Gets or sets the HTML element to use for attaching events
  54755. */
  54756. inputElement: Nullable<HTMLElement>;
  54757. /**
  54758. * Gets the current engine view
  54759. * @see https://doc.babylonjs.com/how_to/multi_canvases
  54760. */
  54761. activeView: Nullable<EngineView>;
  54762. /** Gets or sets the list of views */
  54763. views: EngineView[];
  54764. /**
  54765. * Register a new child canvas
  54766. * @param canvas defines the canvas to register
  54767. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  54768. * @returns the associated view
  54769. */
  54770. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  54771. /**
  54772. * Remove a registered child canvas
  54773. * @param canvas defines the canvas to remove
  54774. * @returns the current engine
  54775. */
  54776. unRegisterView(canvas: HTMLCanvasElement): Engine;
  54777. }
  54778. }
  54779. }
  54780. declare module "babylonjs/Engines/Extensions/engine.textureSelector" {
  54781. import { Nullable } from "babylonjs/types";
  54782. module "babylonjs/Engines/engine" {
  54783. interface Engine {
  54784. /** @hidden */
  54785. _excludedCompressedTextures: string[];
  54786. /** @hidden */
  54787. _textureFormatInUse: string;
  54788. /**
  54789. * Gets the list of texture formats supported
  54790. */
  54791. readonly texturesSupported: Array<string>;
  54792. /**
  54793. * Gets the texture format in use
  54794. */
  54795. readonly textureFormatInUse: Nullable<string>;
  54796. /**
  54797. * Set the compressed texture extensions or file names to skip.
  54798. *
  54799. * @param skippedFiles defines the list of those texture files you want to skip
  54800. * Example: [".dds", ".env", "myfile.png"]
  54801. */
  54802. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  54803. /**
  54804. * Set the compressed texture format to use, based on the formats you have, and the formats
  54805. * supported by the hardware / browser.
  54806. *
  54807. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  54808. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  54809. * to API arguments needed to compressed textures. This puts the burden on the container
  54810. * generator to house the arcane code for determining these for current & future formats.
  54811. *
  54812. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  54813. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  54814. *
  54815. * Note: The result of this call is not taken into account when a texture is base64.
  54816. *
  54817. * @param formatsAvailable defines the list of those format families you have created
  54818. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  54819. *
  54820. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  54821. * @returns The extension selected.
  54822. */
  54823. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  54824. }
  54825. }
  54826. }
  54827. declare module "babylonjs/Engines/Extensions/index" {
  54828. export * from "babylonjs/Engines/Extensions/engine.alpha";
  54829. export * from "babylonjs/Engines/Extensions/engine.occlusionQuery";
  54830. export * from "babylonjs/Engines/Extensions/engine.transformFeedback";
  54831. export * from "babylonjs/Engines/Extensions/engine.multiview";
  54832. export * from "babylonjs/Engines/Extensions/engine.rawTexture";
  54833. export * from "babylonjs/Engines/Extensions/engine.dynamicTexture";
  54834. export * from "babylonjs/Engines/Extensions/engine.videoTexture";
  54835. export * from "babylonjs/Engines/Extensions/engine.multiRender";
  54836. export * from "babylonjs/Engines/Extensions/engine.cubeTexture";
  54837. export * from "babylonjs/Engines/Extensions/engine.renderTarget";
  54838. export * from "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54839. export * from "babylonjs/Engines/Extensions/engine.webVR";
  54840. export * from "babylonjs/Engines/Extensions/engine.uniformBuffer";
  54841. export * from "babylonjs/Engines/Extensions/engine.dynamicBuffer";
  54842. export * from "babylonjs/Engines/Extensions/engine.views";
  54843. export * from "babylonjs/Engines/Extensions/engine.readTexture";
  54844. import "babylonjs/Engines/Extensions/engine.textureSelector";
  54845. export * from "babylonjs/Engines/Extensions/engine.textureSelector";
  54846. }
  54847. declare module "babylonjs/Misc/HighDynamicRange/panoramaToCubemap" {
  54848. import { Nullable } from "babylonjs/types";
  54849. /**
  54850. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  54851. */
  54852. export interface CubeMapInfo {
  54853. /**
  54854. * The pixel array for the front face.
  54855. * This is stored in format, left to right, up to down format.
  54856. */
  54857. front: Nullable<ArrayBufferView>;
  54858. /**
  54859. * The pixel array for the back face.
  54860. * This is stored in format, left to right, up to down format.
  54861. */
  54862. back: Nullable<ArrayBufferView>;
  54863. /**
  54864. * The pixel array for the left face.
  54865. * This is stored in format, left to right, up to down format.
  54866. */
  54867. left: Nullable<ArrayBufferView>;
  54868. /**
  54869. * The pixel array for the right face.
  54870. * This is stored in format, left to right, up to down format.
  54871. */
  54872. right: Nullable<ArrayBufferView>;
  54873. /**
  54874. * The pixel array for the up face.
  54875. * This is stored in format, left to right, up to down format.
  54876. */
  54877. up: Nullable<ArrayBufferView>;
  54878. /**
  54879. * The pixel array for the down face.
  54880. * This is stored in format, left to right, up to down format.
  54881. */
  54882. down: Nullable<ArrayBufferView>;
  54883. /**
  54884. * The size of the cubemap stored.
  54885. *
  54886. * Each faces will be size * size pixels.
  54887. */
  54888. size: number;
  54889. /**
  54890. * The format of the texture.
  54891. *
  54892. * RGBA, RGB.
  54893. */
  54894. format: number;
  54895. /**
  54896. * The type of the texture data.
  54897. *
  54898. * UNSIGNED_INT, FLOAT.
  54899. */
  54900. type: number;
  54901. /**
  54902. * Specifies whether the texture is in gamma space.
  54903. */
  54904. gammaSpace: boolean;
  54905. }
  54906. /**
  54907. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  54908. */
  54909. export class PanoramaToCubeMapTools {
  54910. private static FACE_LEFT;
  54911. private static FACE_RIGHT;
  54912. private static FACE_FRONT;
  54913. private static FACE_BACK;
  54914. private static FACE_DOWN;
  54915. private static FACE_UP;
  54916. /**
  54917. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  54918. *
  54919. * @param float32Array The source data.
  54920. * @param inputWidth The width of the input panorama.
  54921. * @param inputHeight The height of the input panorama.
  54922. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  54923. * @return The cubemap data
  54924. */
  54925. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  54926. private static CreateCubemapTexture;
  54927. private static CalcProjectionSpherical;
  54928. }
  54929. }
  54930. declare module "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial" {
  54931. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54932. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54933. import { Nullable } from "babylonjs/types";
  54934. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  54935. /**
  54936. * Helper class dealing with the extraction of spherical polynomial dataArray
  54937. * from a cube map.
  54938. */
  54939. export class CubeMapToSphericalPolynomialTools {
  54940. private static FileFaces;
  54941. /**
  54942. * Converts a texture to the according Spherical Polynomial data.
  54943. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54944. *
  54945. * @param texture The texture to extract the information from.
  54946. * @return The Spherical Polynomial data.
  54947. */
  54948. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  54949. /**
  54950. * Converts a cubemap to the according Spherical Polynomial data.
  54951. * This extracts the first 3 orders only as they are the only one used in the lighting.
  54952. *
  54953. * @param cubeInfo The Cube map to extract the information from.
  54954. * @return The Spherical Polynomial data.
  54955. */
  54956. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  54957. }
  54958. }
  54959. declare module "babylonjs/Materials/Textures/baseTexture.polynomial" {
  54960. import { Nullable } from "babylonjs/types";
  54961. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54962. module "babylonjs/Materials/Textures/baseTexture" {
  54963. interface BaseTexture {
  54964. /**
  54965. * Get the polynomial representation of the texture data.
  54966. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  54967. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  54968. */
  54969. sphericalPolynomial: Nullable<SphericalPolynomial>;
  54970. }
  54971. }
  54972. }
  54973. declare module "babylonjs/Shaders/rgbdEncode.fragment" {
  54974. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54975. /** @hidden */
  54976. export var rgbdEncodePixelShader: {
  54977. name: string;
  54978. shader: string;
  54979. };
  54980. }
  54981. declare module "babylonjs/Shaders/rgbdDecode.fragment" {
  54982. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  54983. /** @hidden */
  54984. export var rgbdDecodePixelShader: {
  54985. name: string;
  54986. shader: string;
  54987. };
  54988. }
  54989. declare module "babylonjs/Misc/environmentTextureTools" {
  54990. import { Nullable } from "babylonjs/types";
  54991. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  54992. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  54993. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  54994. import "babylonjs/Engines/Extensions/engine.renderTargetCube";
  54995. import "babylonjs/Engines/Extensions/engine.readTexture";
  54996. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  54997. import "babylonjs/Shaders/rgbdEncode.fragment";
  54998. import "babylonjs/Shaders/rgbdDecode.fragment";
  54999. /**
  55000. * Raw texture data and descriptor sufficient for WebGL texture upload
  55001. */
  55002. export interface EnvironmentTextureInfo {
  55003. /**
  55004. * Version of the environment map
  55005. */
  55006. version: number;
  55007. /**
  55008. * Width of image
  55009. */
  55010. width: number;
  55011. /**
  55012. * Irradiance information stored in the file.
  55013. */
  55014. irradiance: any;
  55015. /**
  55016. * Specular information stored in the file.
  55017. */
  55018. specular: any;
  55019. }
  55020. /**
  55021. * Defines One Image in the file. It requires only the position in the file
  55022. * as well as the length.
  55023. */
  55024. interface BufferImageData {
  55025. /**
  55026. * Length of the image data.
  55027. */
  55028. length: number;
  55029. /**
  55030. * Position of the data from the null terminator delimiting the end of the JSON.
  55031. */
  55032. position: number;
  55033. }
  55034. /**
  55035. * Defines the specular data enclosed in the file.
  55036. * This corresponds to the version 1 of the data.
  55037. */
  55038. export interface EnvironmentTextureSpecularInfoV1 {
  55039. /**
  55040. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  55041. */
  55042. specularDataPosition?: number;
  55043. /**
  55044. * This contains all the images data needed to reconstruct the cubemap.
  55045. */
  55046. mipmaps: Array<BufferImageData>;
  55047. /**
  55048. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  55049. */
  55050. lodGenerationScale: number;
  55051. }
  55052. /**
  55053. * Sets of helpers addressing the serialization and deserialization of environment texture
  55054. * stored in a BabylonJS env file.
  55055. * Those files are usually stored as .env files.
  55056. */
  55057. export class EnvironmentTextureTools {
  55058. /**
  55059. * Magic number identifying the env file.
  55060. */
  55061. private static _MagicBytes;
  55062. /**
  55063. * Gets the environment info from an env file.
  55064. * @param data The array buffer containing the .env bytes.
  55065. * @returns the environment file info (the json header) if successfully parsed.
  55066. */
  55067. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  55068. /**
  55069. * Creates an environment texture from a loaded cube texture.
  55070. * @param texture defines the cube texture to convert in env file
  55071. * @return a promise containing the environment data if succesfull.
  55072. */
  55073. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  55074. /**
  55075. * Creates a JSON representation of the spherical data.
  55076. * @param texture defines the texture containing the polynomials
  55077. * @return the JSON representation of the spherical info
  55078. */
  55079. private static _CreateEnvTextureIrradiance;
  55080. /**
  55081. * Creates the ArrayBufferViews used for initializing environment texture image data.
  55082. * @param data the image data
  55083. * @param info parameters that determine what views will be created for accessing the underlying buffer
  55084. * @return the views described by info providing access to the underlying buffer
  55085. */
  55086. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  55087. /**
  55088. * Uploads the texture info contained in the env file to the GPU.
  55089. * @param texture defines the internal texture to upload to
  55090. * @param data defines the data to load
  55091. * @param info defines the texture info retrieved through the GetEnvInfo method
  55092. * @returns a promise
  55093. */
  55094. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  55095. private static _OnImageReadyAsync;
  55096. /**
  55097. * Uploads the levels of image data to the GPU.
  55098. * @param texture defines the internal texture to upload to
  55099. * @param imageData defines the array buffer views of image data [mipmap][face]
  55100. * @returns a promise
  55101. */
  55102. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  55103. /**
  55104. * Uploads spherical polynomials information to the texture.
  55105. * @param texture defines the texture we are trying to upload the information to
  55106. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  55107. */
  55108. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  55109. /** @hidden */
  55110. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  55111. }
  55112. }
  55113. declare module "babylonjs/Engines/Processors/shaderCodeInliner" {
  55114. /**
  55115. * Class used to inline functions in shader code
  55116. */
  55117. export class ShaderCodeInliner {
  55118. private static readonly _RegexpFindFunctionNameAndType;
  55119. private _sourceCode;
  55120. private _functionDescr;
  55121. private _numMaxIterations;
  55122. /** Gets or sets the token used to mark the functions to inline */
  55123. inlineToken: string;
  55124. /** Gets or sets the debug mode */
  55125. debug: boolean;
  55126. /** Gets the code after the inlining process */
  55127. get code(): string;
  55128. /**
  55129. * Initializes the inliner
  55130. * @param sourceCode shader code source to inline
  55131. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  55132. */
  55133. constructor(sourceCode: string, numMaxIterations?: number);
  55134. /**
  55135. * Start the processing of the shader code
  55136. */
  55137. processCode(): void;
  55138. private _collectFunctions;
  55139. private _processInlining;
  55140. private _extractBetweenMarkers;
  55141. private _skipWhitespaces;
  55142. private _removeComments;
  55143. private _replaceFunctionCallsByCode;
  55144. private _findBackward;
  55145. private _escapeRegExp;
  55146. private _replaceNames;
  55147. }
  55148. }
  55149. declare module "babylonjs/Engines/nativeEngine" {
  55150. import { Nullable, IndicesArray, DataArray } from "babylonjs/types";
  55151. import { Engine } from "babylonjs/Engines/engine";
  55152. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  55153. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  55154. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  55155. import { Effect } from "babylonjs/Materials/effect";
  55156. import { DataBuffer } from "babylonjs/Meshes/dataBuffer";
  55157. import { Matrix, Viewport, Color3 } from "babylonjs/Maths/math";
  55158. import { IColor4Like } from "babylonjs/Maths/math.like";
  55159. import { Scene } from "babylonjs/scene";
  55160. import { RenderTargetCreationOptions } from "babylonjs/Materials/Textures/renderTargetCreationOptions";
  55161. import { IPipelineContext } from "babylonjs/Engines/IPipelineContext";
  55162. import { ISceneLike } from "babylonjs/Engines/thinEngine";
  55163. /**
  55164. * Container for accessors for natively-stored mesh data buffers.
  55165. */
  55166. class NativeDataBuffer extends DataBuffer {
  55167. /**
  55168. * Accessor value used to identify/retrieve a natively-stored index buffer.
  55169. */
  55170. nativeIndexBuffer?: any;
  55171. /**
  55172. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  55173. */
  55174. nativeVertexBuffer?: any;
  55175. }
  55176. /** @hidden */
  55177. class NativeTexture extends InternalTexture {
  55178. getInternalTexture(): InternalTexture;
  55179. getViewCount(): number;
  55180. }
  55181. /** @hidden */
  55182. export class NativeEngine extends Engine {
  55183. private readonly _native;
  55184. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  55185. private readonly INVALID_HANDLE;
  55186. private _boundBuffersVertexArray;
  55187. private _currentDepthTest;
  55188. getHardwareScalingLevel(): number;
  55189. constructor();
  55190. dispose(): void;
  55191. /**
  55192. * Can be used to override the current requestAnimationFrame requester.
  55193. * @hidden
  55194. */
  55195. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  55196. /**
  55197. * Override default engine behavior.
  55198. * @param color
  55199. * @param backBuffer
  55200. * @param depth
  55201. * @param stencil
  55202. */
  55203. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  55204. /**
  55205. * Gets host document
  55206. * @returns the host document object
  55207. */
  55208. getHostDocument(): Nullable<Document>;
  55209. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  55210. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  55211. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  55212. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  55213. [key: string]: VertexBuffer;
  55214. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55215. bindBuffers(vertexBuffers: {
  55216. [key: string]: VertexBuffer;
  55217. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  55218. recordVertexArrayObject(vertexBuffers: {
  55219. [key: string]: VertexBuffer;
  55220. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  55221. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55222. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  55223. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  55224. /**
  55225. * Draw a list of indexed primitives
  55226. * @param fillMode defines the primitive to use
  55227. * @param indexStart defines the starting index
  55228. * @param indexCount defines the number of index to draw
  55229. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55230. */
  55231. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  55232. /**
  55233. * Draw a list of unindexed primitives
  55234. * @param fillMode defines the primitive to use
  55235. * @param verticesStart defines the index of first vertex to draw
  55236. * @param verticesCount defines the count of vertices to draw
  55237. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  55238. */
  55239. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  55240. createPipelineContext(): IPipelineContext;
  55241. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  55242. /** @hidden */
  55243. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  55244. /** @hidden */
  55245. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  55246. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55247. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  55248. protected _setProgram(program: WebGLProgram): void;
  55249. _releaseEffect(effect: Effect): void;
  55250. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  55251. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  55252. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  55253. bindSamplers(effect: Effect): void;
  55254. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  55255. getRenderWidth(useScreen?: boolean): number;
  55256. getRenderHeight(useScreen?: boolean): number;
  55257. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  55258. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  55259. /**
  55260. * Set the z offset to apply to current rendering
  55261. * @param value defines the offset to apply
  55262. */
  55263. setZOffset(value: number): void;
  55264. /**
  55265. * Gets the current value of the zOffset
  55266. * @returns the current zOffset state
  55267. */
  55268. getZOffset(): number;
  55269. /**
  55270. * Enable or disable depth buffering
  55271. * @param enable defines the state to set
  55272. */
  55273. setDepthBuffer(enable: boolean): void;
  55274. /**
  55275. * Gets a boolean indicating if depth writing is enabled
  55276. * @returns the current depth writing state
  55277. */
  55278. getDepthWrite(): boolean;
  55279. setDepthFunctionToGreater(): void;
  55280. setDepthFunctionToGreaterOrEqual(): void;
  55281. setDepthFunctionToLess(): void;
  55282. setDepthFunctionToLessOrEqual(): void;
  55283. /**
  55284. * Enable or disable depth writing
  55285. * @param enable defines the state to set
  55286. */
  55287. setDepthWrite(enable: boolean): void;
  55288. /**
  55289. * Enable or disable color writing
  55290. * @param enable defines the state to set
  55291. */
  55292. setColorWrite(enable: boolean): void;
  55293. /**
  55294. * Gets a boolean indicating if color writing is enabled
  55295. * @returns the current color writing state
  55296. */
  55297. getColorWrite(): boolean;
  55298. /**
  55299. * Sets alpha constants used by some alpha blending modes
  55300. * @param r defines the red component
  55301. * @param g defines the green component
  55302. * @param b defines the blue component
  55303. * @param a defines the alpha component
  55304. */
  55305. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  55306. /**
  55307. * Sets the current alpha mode
  55308. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  55309. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  55310. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55311. */
  55312. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  55313. /**
  55314. * Gets the current alpha mode
  55315. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  55316. * @returns the current alpha mode
  55317. */
  55318. getAlphaMode(): number;
  55319. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  55320. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55321. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55322. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55323. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  55324. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55325. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55326. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55327. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  55328. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  55329. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  55330. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  55331. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  55332. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  55333. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55334. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  55335. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  55336. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  55337. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  55338. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  55339. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  55340. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  55341. wipeCaches(bruteForce?: boolean): void;
  55342. _createTexture(): WebGLTexture;
  55343. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  55344. /**
  55345. * Usually called from Texture.ts.
  55346. * Passed information to create a WebGLTexture
  55347. * @param url defines a value which contains one of the following:
  55348. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  55349. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  55350. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  55351. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  55352. * @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)
  55353. * @param scene needed for loading to the correct scene
  55354. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  55355. * @param onLoad optional callback to be called upon successful completion
  55356. * @param onError optional callback to be called upon failure
  55357. * @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
  55358. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  55359. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  55360. * @param forcedExtension defines the extension to use to pick the right loader
  55361. * @param mimeType defines an optional mime type
  55362. * @returns a InternalTexture for assignment back into BABYLON.Texture
  55363. */
  55364. 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;
  55365. /**
  55366. * Creates a cube texture
  55367. * @param rootUrl defines the url where the files to load is located
  55368. * @param scene defines the current scene
  55369. * @param files defines the list of files to load (1 per face)
  55370. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  55371. * @param onLoad defines an optional callback raised when the texture is loaded
  55372. * @param onError defines an optional callback raised if there is an issue to load the texture
  55373. * @param format defines the format of the data
  55374. * @param forcedExtension defines the extension to use to pick the right loader
  55375. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  55376. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55377. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55378. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  55379. * @returns the cube texture as an InternalTexture
  55380. */
  55381. 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;
  55382. createRenderTargetTexture(size: number | {
  55383. width: number;
  55384. height: number;
  55385. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  55386. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  55387. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  55388. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  55389. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  55390. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  55391. /**
  55392. * Updates a dynamic vertex buffer.
  55393. * @param vertexBuffer the vertex buffer to update
  55394. * @param data the data used to update the vertex buffer
  55395. * @param byteOffset the byte offset of the data (optional)
  55396. * @param byteLength the byte length of the data (optional)
  55397. */
  55398. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  55399. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  55400. private _updateAnisotropicLevel;
  55401. private _getAddressMode;
  55402. /** @hidden */
  55403. _bindTexture(channel: number, texture: InternalTexture): void;
  55404. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  55405. releaseEffects(): void;
  55406. /** @hidden */
  55407. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55408. /** @hidden */
  55409. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55410. /** @hidden */
  55411. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  55412. /** @hidden */
  55413. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  55414. private _getNativeSamplingMode;
  55415. private _getNativeTextureFormat;
  55416. private _getNativeAlphaMode;
  55417. private _getNativeAttribType;
  55418. }
  55419. }
  55420. declare module "babylonjs/Engines/index" {
  55421. export * from "babylonjs/Engines/constants";
  55422. export * from "babylonjs/Engines/engineCapabilities";
  55423. export * from "babylonjs/Engines/instancingAttributeInfo";
  55424. export * from "babylonjs/Engines/thinEngine";
  55425. export * from "babylonjs/Engines/engine";
  55426. export * from "babylonjs/Engines/engineStore";
  55427. export * from "babylonjs/Engines/nullEngine";
  55428. export * from "babylonjs/Engines/Extensions/index";
  55429. export * from "babylonjs/Engines/IPipelineContext";
  55430. export * from "babylonjs/Engines/WebGL/webGLPipelineContext";
  55431. export * from "babylonjs/Engines/WebGL/webGL2ShaderProcessors";
  55432. export * from "babylonjs/Engines/nativeEngine";
  55433. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  55434. export * from "babylonjs/Engines/performanceConfigurator";
  55435. }
  55436. declare module "babylonjs/Events/clipboardEvents" {
  55437. /**
  55438. * Gather the list of clipboard event types as constants.
  55439. */
  55440. export class ClipboardEventTypes {
  55441. /**
  55442. * The clipboard event is fired when a copy command is active (pressed).
  55443. */
  55444. static readonly COPY: number;
  55445. /**
  55446. * The clipboard event is fired when a cut command is active (pressed).
  55447. */
  55448. static readonly CUT: number;
  55449. /**
  55450. * The clipboard event is fired when a paste command is active (pressed).
  55451. */
  55452. static readonly PASTE: number;
  55453. }
  55454. /**
  55455. * This class is used to store clipboard related info for the onClipboardObservable event.
  55456. */
  55457. export class ClipboardInfo {
  55458. /**
  55459. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55460. */
  55461. type: number;
  55462. /**
  55463. * Defines the related dom event
  55464. */
  55465. event: ClipboardEvent;
  55466. /**
  55467. *Creates an instance of ClipboardInfo.
  55468. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  55469. * @param event Defines the related dom event
  55470. */
  55471. constructor(
  55472. /**
  55473. * Defines the type of event (BABYLON.ClipboardEventTypes)
  55474. */
  55475. type: number,
  55476. /**
  55477. * Defines the related dom event
  55478. */
  55479. event: ClipboardEvent);
  55480. /**
  55481. * Get the clipboard event's type from the keycode.
  55482. * @param keyCode Defines the keyCode for the current keyboard event.
  55483. * @return {number}
  55484. */
  55485. static GetTypeFromCharacter(keyCode: number): number;
  55486. }
  55487. }
  55488. declare module "babylonjs/Events/index" {
  55489. export * from "babylonjs/Events/keyboardEvents";
  55490. export * from "babylonjs/Events/pointerEvents";
  55491. export * from "babylonjs/Events/clipboardEvents";
  55492. }
  55493. declare module "babylonjs/Gamepads/Controllers/daydreamController" {
  55494. import { Scene } from "babylonjs/scene";
  55495. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55496. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55497. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55498. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55499. /**
  55500. * Google Daydream controller
  55501. */
  55502. export class DaydreamController extends WebVRController {
  55503. /**
  55504. * Base Url for the controller model.
  55505. */
  55506. static MODEL_BASE_URL: string;
  55507. /**
  55508. * File name for the controller model.
  55509. */
  55510. static MODEL_FILENAME: string;
  55511. /**
  55512. * Gamepad Id prefix used to identify Daydream Controller.
  55513. */
  55514. static readonly GAMEPAD_ID_PREFIX: string;
  55515. /**
  55516. * Creates a new DaydreamController from a gamepad
  55517. * @param vrGamepad the gamepad that the controller should be created from
  55518. */
  55519. constructor(vrGamepad: any);
  55520. /**
  55521. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55522. * @param scene scene in which to add meshes
  55523. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55524. */
  55525. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55526. /**
  55527. * Called once for each button that changed state since the last frame
  55528. * @param buttonIdx Which button index changed
  55529. * @param state New state of the button
  55530. * @param changes Which properties on the state changed since last frame
  55531. */
  55532. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55533. }
  55534. }
  55535. declare module "babylonjs/Gamepads/Controllers/gearVRController" {
  55536. import { Scene } from "babylonjs/scene";
  55537. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55538. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55539. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55540. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55541. /**
  55542. * Gear VR Controller
  55543. */
  55544. export class GearVRController extends WebVRController {
  55545. /**
  55546. * Base Url for the controller model.
  55547. */
  55548. static MODEL_BASE_URL: string;
  55549. /**
  55550. * File name for the controller model.
  55551. */
  55552. static MODEL_FILENAME: string;
  55553. /**
  55554. * Gamepad Id prefix used to identify this controller.
  55555. */
  55556. static readonly GAMEPAD_ID_PREFIX: string;
  55557. private readonly _buttonIndexToObservableNameMap;
  55558. /**
  55559. * Creates a new GearVRController from a gamepad
  55560. * @param vrGamepad the gamepad that the controller should be created from
  55561. */
  55562. constructor(vrGamepad: any);
  55563. /**
  55564. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55565. * @param scene scene in which to add meshes
  55566. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55567. */
  55568. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55569. /**
  55570. * Called once for each button that changed state since the last frame
  55571. * @param buttonIdx Which button index changed
  55572. * @param state New state of the button
  55573. * @param changes Which properties on the state changed since last frame
  55574. */
  55575. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55576. }
  55577. }
  55578. declare module "babylonjs/Gamepads/Controllers/genericController" {
  55579. import { Scene } from "babylonjs/scene";
  55580. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55581. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55582. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55583. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55584. /**
  55585. * Generic Controller
  55586. */
  55587. export class GenericController extends WebVRController {
  55588. /**
  55589. * Base Url for the controller model.
  55590. */
  55591. static readonly MODEL_BASE_URL: string;
  55592. /**
  55593. * File name for the controller model.
  55594. */
  55595. static readonly MODEL_FILENAME: string;
  55596. /**
  55597. * Creates a new GenericController from a gamepad
  55598. * @param vrGamepad the gamepad that the controller should be created from
  55599. */
  55600. constructor(vrGamepad: any);
  55601. /**
  55602. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55603. * @param scene scene in which to add meshes
  55604. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55605. */
  55606. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55607. /**
  55608. * Called once for each button that changed state since the last frame
  55609. * @param buttonIdx Which button index changed
  55610. * @param state New state of the button
  55611. * @param changes Which properties on the state changed since last frame
  55612. */
  55613. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55614. }
  55615. }
  55616. declare module "babylonjs/Gamepads/Controllers/oculusTouchController" {
  55617. import { Observable } from "babylonjs/Misc/observable";
  55618. import { Scene } from "babylonjs/scene";
  55619. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55620. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55621. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55622. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55623. /**
  55624. * Oculus Touch Controller
  55625. */
  55626. export class OculusTouchController extends WebVRController {
  55627. /**
  55628. * Base Url for the controller model.
  55629. */
  55630. static MODEL_BASE_URL: string;
  55631. /**
  55632. * File name for the left controller model.
  55633. */
  55634. static MODEL_LEFT_FILENAME: string;
  55635. /**
  55636. * File name for the right controller model.
  55637. */
  55638. static MODEL_RIGHT_FILENAME: string;
  55639. /**
  55640. * Base Url for the Quest controller model.
  55641. */
  55642. static QUEST_MODEL_BASE_URL: string;
  55643. /**
  55644. * @hidden
  55645. * If the controllers are running on a device that needs the updated Quest controller models
  55646. */
  55647. static _IsQuest: boolean;
  55648. /**
  55649. * Fired when the secondary trigger on this controller is modified
  55650. */
  55651. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  55652. /**
  55653. * Fired when the thumb rest on this controller is modified
  55654. */
  55655. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  55656. /**
  55657. * Creates a new OculusTouchController from a gamepad
  55658. * @param vrGamepad the gamepad that the controller should be created from
  55659. */
  55660. constructor(vrGamepad: any);
  55661. /**
  55662. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55663. * @param scene scene in which to add meshes
  55664. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55665. */
  55666. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55667. /**
  55668. * Fired when the A button on this controller is modified
  55669. */
  55670. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55671. /**
  55672. * Fired when the B button on this controller is modified
  55673. */
  55674. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55675. /**
  55676. * Fired when the X button on this controller is modified
  55677. */
  55678. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55679. /**
  55680. * Fired when the Y button on this controller is modified
  55681. */
  55682. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55683. /**
  55684. * Called once for each button that changed state since the last frame
  55685. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  55686. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  55687. * 2) secondary trigger (same)
  55688. * 3) A (right) X (left), touch, pressed = value
  55689. * 4) B / Y
  55690. * 5) thumb rest
  55691. * @param buttonIdx Which button index changed
  55692. * @param state New state of the button
  55693. * @param changes Which properties on the state changed since last frame
  55694. */
  55695. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55696. }
  55697. }
  55698. declare module "babylonjs/Gamepads/Controllers/viveController" {
  55699. import { Scene } from "babylonjs/scene";
  55700. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55701. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55702. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55703. import { GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55704. import { Observable } from "babylonjs/Misc/observable";
  55705. /**
  55706. * Vive Controller
  55707. */
  55708. export class ViveController extends WebVRController {
  55709. /**
  55710. * Base Url for the controller model.
  55711. */
  55712. static MODEL_BASE_URL: string;
  55713. /**
  55714. * File name for the controller model.
  55715. */
  55716. static MODEL_FILENAME: string;
  55717. /**
  55718. * Creates a new ViveController from a gamepad
  55719. * @param vrGamepad the gamepad that the controller should be created from
  55720. */
  55721. constructor(vrGamepad: any);
  55722. /**
  55723. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55724. * @param scene scene in which to add meshes
  55725. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55726. */
  55727. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  55728. /**
  55729. * Fired when the left button on this controller is modified
  55730. */
  55731. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55732. /**
  55733. * Fired when the right button on this controller is modified
  55734. */
  55735. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55736. /**
  55737. * Fired when the menu button on this controller is modified
  55738. */
  55739. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55740. /**
  55741. * Called once for each button that changed state since the last frame
  55742. * Vive mapping:
  55743. * 0: touchpad
  55744. * 1: trigger
  55745. * 2: left AND right buttons
  55746. * 3: menu button
  55747. * @param buttonIdx Which button index changed
  55748. * @param state New state of the button
  55749. * @param changes Which properties on the state changed since last frame
  55750. */
  55751. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55752. }
  55753. }
  55754. declare module "babylonjs/Gamepads/Controllers/windowsMotionController" {
  55755. import { Observable } from "babylonjs/Misc/observable";
  55756. import { Scene } from "babylonjs/scene";
  55757. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  55758. import { Ray } from "babylonjs/Culling/ray";
  55759. import { WebVRController } from "babylonjs/Gamepads/Controllers/webVRController";
  55760. import { ExtendedGamepadButton } from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55761. import { StickValues, GamepadButtonChanges } from "babylonjs/Gamepads/gamepad";
  55762. /**
  55763. * Defines the WindowsMotionController object that the state of the windows motion controller
  55764. */
  55765. export class WindowsMotionController extends WebVRController {
  55766. /**
  55767. * The base url used to load the left and right controller models
  55768. */
  55769. static MODEL_BASE_URL: string;
  55770. /**
  55771. * The name of the left controller model file
  55772. */
  55773. static MODEL_LEFT_FILENAME: string;
  55774. /**
  55775. * The name of the right controller model file
  55776. */
  55777. static MODEL_RIGHT_FILENAME: string;
  55778. /**
  55779. * The controller name prefix for this controller type
  55780. */
  55781. static readonly GAMEPAD_ID_PREFIX: string;
  55782. /**
  55783. * The controller id pattern for this controller type
  55784. */
  55785. private static readonly GAMEPAD_ID_PATTERN;
  55786. private _loadedMeshInfo;
  55787. protected readonly _mapping: {
  55788. buttons: string[];
  55789. buttonMeshNames: {
  55790. trigger: string;
  55791. menu: string;
  55792. grip: string;
  55793. thumbstick: string;
  55794. trackpad: string;
  55795. };
  55796. buttonObservableNames: {
  55797. trigger: string;
  55798. menu: string;
  55799. grip: string;
  55800. thumbstick: string;
  55801. trackpad: string;
  55802. };
  55803. axisMeshNames: string[];
  55804. pointingPoseMeshName: string;
  55805. };
  55806. /**
  55807. * Fired when the trackpad on this controller is clicked
  55808. */
  55809. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55810. /**
  55811. * Fired when the trackpad on this controller is modified
  55812. */
  55813. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55814. /**
  55815. * The current x and y values of this controller's trackpad
  55816. */
  55817. trackpad: StickValues;
  55818. /**
  55819. * Creates a new WindowsMotionController from a gamepad
  55820. * @param vrGamepad the gamepad that the controller should be created from
  55821. */
  55822. constructor(vrGamepad: any);
  55823. /**
  55824. * Fired when the trigger on this controller is modified
  55825. */
  55826. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55827. /**
  55828. * Fired when the menu button on this controller is modified
  55829. */
  55830. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55831. /**
  55832. * Fired when the grip button on this controller is modified
  55833. */
  55834. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55835. /**
  55836. * Fired when the thumbstick button on this controller is modified
  55837. */
  55838. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55839. /**
  55840. * Fired when the touchpad button on this controller is modified
  55841. */
  55842. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55843. /**
  55844. * Fired when the touchpad values on this controller are modified
  55845. */
  55846. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  55847. protected _updateTrackpad(): void;
  55848. /**
  55849. * Called once per frame by the engine.
  55850. */
  55851. update(): void;
  55852. /**
  55853. * Called once for each button that changed state since the last frame
  55854. * @param buttonIdx Which button index changed
  55855. * @param state New state of the button
  55856. * @param changes Which properties on the state changed since last frame
  55857. */
  55858. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  55859. /**
  55860. * Moves the buttons on the controller mesh based on their current state
  55861. * @param buttonName the name of the button to move
  55862. * @param buttonValue the value of the button which determines the buttons new position
  55863. */
  55864. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  55865. /**
  55866. * Moves the axis on the controller mesh based on its current state
  55867. * @param axis the index of the axis
  55868. * @param axisValue the value of the axis which determines the meshes new position
  55869. * @hidden
  55870. */
  55871. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  55872. /**
  55873. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  55874. * @param scene scene in which to add meshes
  55875. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  55876. */
  55877. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  55878. /**
  55879. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  55880. * can be transformed by button presses and axes values, based on this._mapping.
  55881. *
  55882. * @param scene scene in which the meshes exist
  55883. * @param meshes list of meshes that make up the controller model to process
  55884. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  55885. */
  55886. private processModel;
  55887. private createMeshInfo;
  55888. /**
  55889. * Gets the ray of the controller in the direction the controller is pointing
  55890. * @param length the length the resulting ray should be
  55891. * @returns a ray in the direction the controller is pointing
  55892. */
  55893. getForwardRay(length?: number): Ray;
  55894. /**
  55895. * Disposes of the controller
  55896. */
  55897. dispose(): void;
  55898. }
  55899. /**
  55900. * This class represents a new windows motion controller in XR.
  55901. */
  55902. export class XRWindowsMotionController extends WindowsMotionController {
  55903. /**
  55904. * Changing the original WIndowsMotionController mapping to fir the new mapping
  55905. */
  55906. protected readonly _mapping: {
  55907. buttons: string[];
  55908. buttonMeshNames: {
  55909. trigger: string;
  55910. menu: string;
  55911. grip: string;
  55912. thumbstick: string;
  55913. trackpad: string;
  55914. };
  55915. buttonObservableNames: {
  55916. trigger: string;
  55917. menu: string;
  55918. grip: string;
  55919. thumbstick: string;
  55920. trackpad: string;
  55921. };
  55922. axisMeshNames: string[];
  55923. pointingPoseMeshName: string;
  55924. };
  55925. /**
  55926. * Construct a new XR-Based windows motion controller
  55927. *
  55928. * @param gamepadInfo the gamepad object from the browser
  55929. */
  55930. constructor(gamepadInfo: any);
  55931. /**
  55932. * holds the thumbstick values (X,Y)
  55933. */
  55934. thumbstickValues: StickValues;
  55935. /**
  55936. * Fired when the thumbstick on this controller is clicked
  55937. */
  55938. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  55939. /**
  55940. * Fired when the thumbstick on this controller is modified
  55941. */
  55942. onThumbstickValuesChangedObservable: Observable<StickValues>;
  55943. /**
  55944. * Fired when the touchpad button on this controller is modified
  55945. */
  55946. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  55947. /**
  55948. * Fired when the touchpad values on this controller are modified
  55949. */
  55950. onTrackpadValuesChangedObservable: Observable<StickValues>;
  55951. /**
  55952. * Fired when the thumbstick button on this controller is modified
  55953. * here to prevent breaking changes
  55954. */
  55955. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  55956. /**
  55957. * updating the thumbstick(!) and not the trackpad.
  55958. * This is named this way due to the difference between WebVR and XR and to avoid
  55959. * changing the parent class.
  55960. */
  55961. protected _updateTrackpad(): void;
  55962. /**
  55963. * Disposes the class with joy
  55964. */
  55965. dispose(): void;
  55966. }
  55967. }
  55968. declare module "babylonjs/Gamepads/Controllers/index" {
  55969. export * from "babylonjs/Gamepads/Controllers/daydreamController";
  55970. export * from "babylonjs/Gamepads/Controllers/gearVRController";
  55971. export * from "babylonjs/Gamepads/Controllers/genericController";
  55972. export * from "babylonjs/Gamepads/Controllers/oculusTouchController";
  55973. export * from "babylonjs/Gamepads/Controllers/poseEnabledController";
  55974. export * from "babylonjs/Gamepads/Controllers/viveController";
  55975. export * from "babylonjs/Gamepads/Controllers/webVRController";
  55976. export * from "babylonjs/Gamepads/Controllers/windowsMotionController";
  55977. }
  55978. declare module "babylonjs/Gamepads/index" {
  55979. export * from "babylonjs/Gamepads/Controllers/index";
  55980. export * from "babylonjs/Gamepads/gamepad";
  55981. export * from "babylonjs/Gamepads/gamepadManager";
  55982. export * from "babylonjs/Gamepads/gamepadSceneComponent";
  55983. export * from "babylonjs/Gamepads/xboxGamepad";
  55984. export * from "babylonjs/Gamepads/dualShockGamepad";
  55985. }
  55986. declare module "babylonjs/Meshes/Builders/polyhedronBuilder" {
  55987. import { Scene } from "babylonjs/scene";
  55988. import { Vector4 } from "babylonjs/Maths/math.vector";
  55989. import { Color4 } from "babylonjs/Maths/math.color";
  55990. import { Mesh } from "babylonjs/Meshes/mesh";
  55991. import { Nullable } from "babylonjs/types";
  55992. /**
  55993. * Class containing static functions to help procedurally build meshes
  55994. */
  55995. export class PolyhedronBuilder {
  55996. /**
  55997. * Creates a polyhedron mesh
  55998. * * 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
  55999. * * The parameter `size` (positive float, default 1) sets the polygon size
  56000. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  56001. * * 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`
  56002. * * 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
  56003. * * 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)`)
  56004. * * 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
  56005. * * 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
  56006. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  56007. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  56008. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  56009. * @param name defines the name of the mesh
  56010. * @param options defines the options used to create the mesh
  56011. * @param scene defines the hosting scene
  56012. * @returns the polyhedron mesh
  56013. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  56014. */
  56015. static CreatePolyhedron(name: string, options: {
  56016. type?: number;
  56017. size?: number;
  56018. sizeX?: number;
  56019. sizeY?: number;
  56020. sizeZ?: number;
  56021. custom?: any;
  56022. faceUV?: Vector4[];
  56023. faceColors?: Color4[];
  56024. flat?: boolean;
  56025. updatable?: boolean;
  56026. sideOrientation?: number;
  56027. frontUVs?: Vector4;
  56028. backUVs?: Vector4;
  56029. }, scene?: Nullable<Scene>): Mesh;
  56030. }
  56031. }
  56032. declare module "babylonjs/Gizmos/scaleGizmo" {
  56033. import { Observable } from "babylonjs/Misc/observable";
  56034. import { Nullable } from "babylonjs/types";
  56035. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56036. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56037. import { AxisScaleGizmo } from "babylonjs/Gizmos/axisScaleGizmo";
  56038. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56039. import { Node } from "babylonjs/node";
  56040. /**
  56041. * Gizmo that enables scaling a mesh along 3 axis
  56042. */
  56043. export class ScaleGizmo extends Gizmo {
  56044. /**
  56045. * Internal gizmo used for interactions on the x axis
  56046. */
  56047. xGizmo: AxisScaleGizmo;
  56048. /**
  56049. * Internal gizmo used for interactions on the y axis
  56050. */
  56051. yGizmo: AxisScaleGizmo;
  56052. /**
  56053. * Internal gizmo used for interactions on the z axis
  56054. */
  56055. zGizmo: AxisScaleGizmo;
  56056. /**
  56057. * Internal gizmo used to scale all axis equally
  56058. */
  56059. uniformScaleGizmo: AxisScaleGizmo;
  56060. private _meshAttached;
  56061. private _nodeAttached;
  56062. private _snapDistance;
  56063. private _uniformScalingMesh;
  56064. private _octahedron;
  56065. private _sensitivity;
  56066. /** Fires an event when any of it's sub gizmos are dragged */
  56067. onDragStartObservable: Observable<unknown>;
  56068. /** Fires an event when any of it's sub gizmos are released from dragging */
  56069. onDragEndObservable: Observable<unknown>;
  56070. get attachedMesh(): Nullable<AbstractMesh>;
  56071. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56072. get attachedNode(): Nullable<Node>;
  56073. set attachedNode(node: Nullable<Node>);
  56074. /**
  56075. * True when the mouse pointer is hovering a gizmo mesh
  56076. */
  56077. get isHovered(): boolean;
  56078. /**
  56079. * Creates a ScaleGizmo
  56080. * @param gizmoLayer The utility layer the gizmo will be added to
  56081. * @param thickness display gizmo axis thickness
  56082. */
  56083. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  56084. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56085. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56086. /**
  56087. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56088. */
  56089. set snapDistance(value: number);
  56090. get snapDistance(): number;
  56091. /**
  56092. * Ratio for the scale of the gizmo (Default: 1)
  56093. */
  56094. set scaleRatio(value: number);
  56095. get scaleRatio(): number;
  56096. /**
  56097. * Sensitivity factor for dragging (Default: 1)
  56098. */
  56099. set sensitivity(value: number);
  56100. get sensitivity(): number;
  56101. /**
  56102. * Disposes of the gizmo
  56103. */
  56104. dispose(): void;
  56105. }
  56106. }
  56107. declare module "babylonjs/Gizmos/axisScaleGizmo" {
  56108. import { Observable } from "babylonjs/Misc/observable";
  56109. import { Nullable } from "babylonjs/types";
  56110. import { Vector3 } from "babylonjs/Maths/math.vector";
  56111. import { Node } from "babylonjs/node";
  56112. import { Mesh } from "babylonjs/Meshes/mesh";
  56113. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56114. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56115. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56116. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56117. import { Color3 } from "babylonjs/Maths/math.color";
  56118. /**
  56119. * Single axis scale gizmo
  56120. */
  56121. export class AxisScaleGizmo extends Gizmo {
  56122. /**
  56123. * Drag behavior responsible for the gizmos dragging interactions
  56124. */
  56125. dragBehavior: PointerDragBehavior;
  56126. private _pointerObserver;
  56127. /**
  56128. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56129. */
  56130. snapDistance: number;
  56131. /**
  56132. * Event that fires each time the gizmo snaps to a new location.
  56133. * * snapDistance is the the change in distance
  56134. */
  56135. onSnapObservable: Observable<{
  56136. snapDistance: number;
  56137. }>;
  56138. /**
  56139. * If the scaling operation should be done on all axis (default: false)
  56140. */
  56141. uniformScaling: boolean;
  56142. /**
  56143. * Custom sensitivity value for the drag strength
  56144. */
  56145. sensitivity: number;
  56146. private _isEnabled;
  56147. private _parent;
  56148. private _arrow;
  56149. private _coloredMaterial;
  56150. private _hoverMaterial;
  56151. /**
  56152. * Creates an AxisScaleGizmo
  56153. * @param gizmoLayer The utility layer the gizmo will be added to
  56154. * @param dragAxis The axis which the gizmo will be able to scale on
  56155. * @param color The color of the gizmo
  56156. * @param thickness display gizmo axis thickness
  56157. */
  56158. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  56159. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56160. /**
  56161. * If the gizmo is enabled
  56162. */
  56163. set isEnabled(value: boolean);
  56164. get isEnabled(): boolean;
  56165. /**
  56166. * Disposes of the gizmo
  56167. */
  56168. dispose(): void;
  56169. /**
  56170. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  56171. * @param mesh The mesh to replace the default mesh of the gizmo
  56172. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  56173. */
  56174. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  56175. }
  56176. }
  56177. declare module "babylonjs/Gizmos/boundingBoxGizmo" {
  56178. import { Observable } from "babylonjs/Misc/observable";
  56179. import { Nullable } from "babylonjs/types";
  56180. import { Vector3 } from "babylonjs/Maths/math.vector";
  56181. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56182. import { Mesh } from "babylonjs/Meshes/mesh";
  56183. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56184. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56185. import { Color3 } from "babylonjs/Maths/math.color";
  56186. import "babylonjs/Meshes/Builders/boxBuilder";
  56187. /**
  56188. * Bounding box gizmo
  56189. */
  56190. export class BoundingBoxGizmo extends Gizmo {
  56191. private _lineBoundingBox;
  56192. private _rotateSpheresParent;
  56193. private _scaleBoxesParent;
  56194. private _boundingDimensions;
  56195. private _renderObserver;
  56196. private _pointerObserver;
  56197. private _scaleDragSpeed;
  56198. private _tmpQuaternion;
  56199. private _tmpVector;
  56200. private _tmpRotationMatrix;
  56201. /**
  56202. * 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)
  56203. */
  56204. ignoreChildren: boolean;
  56205. /**
  56206. * 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)
  56207. */
  56208. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  56209. /**
  56210. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  56211. */
  56212. rotationSphereSize: number;
  56213. /**
  56214. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  56215. */
  56216. scaleBoxSize: number;
  56217. /**
  56218. * 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)
  56219. */
  56220. fixedDragMeshScreenSize: boolean;
  56221. /**
  56222. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  56223. */
  56224. fixedDragMeshScreenSizeDistanceFactor: number;
  56225. /**
  56226. * Fired when a rotation sphere or scale box is dragged
  56227. */
  56228. onDragStartObservable: Observable<{}>;
  56229. /**
  56230. * Fired when a scale box is dragged
  56231. */
  56232. onScaleBoxDragObservable: Observable<{}>;
  56233. /**
  56234. * Fired when a scale box drag is ended
  56235. */
  56236. onScaleBoxDragEndObservable: Observable<{}>;
  56237. /**
  56238. * Fired when a rotation sphere is dragged
  56239. */
  56240. onRotationSphereDragObservable: Observable<{}>;
  56241. /**
  56242. * Fired when a rotation sphere drag is ended
  56243. */
  56244. onRotationSphereDragEndObservable: Observable<{}>;
  56245. /**
  56246. * 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)
  56247. */
  56248. scalePivot: Nullable<Vector3>;
  56249. /**
  56250. * Mesh used as a pivot to rotate the attached node
  56251. */
  56252. private _anchorMesh;
  56253. private _existingMeshScale;
  56254. private _dragMesh;
  56255. private pointerDragBehavior;
  56256. private coloredMaterial;
  56257. private hoverColoredMaterial;
  56258. /**
  56259. * Sets the color of the bounding box gizmo
  56260. * @param color the color to set
  56261. */
  56262. setColor(color: Color3): void;
  56263. /**
  56264. * Creates an BoundingBoxGizmo
  56265. * @param gizmoLayer The utility layer the gizmo will be added to
  56266. * @param color The color of the gizmo
  56267. */
  56268. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  56269. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  56270. private _selectNode;
  56271. /**
  56272. * Updates the bounding box information for the Gizmo
  56273. */
  56274. updateBoundingBox(): void;
  56275. private _updateRotationSpheres;
  56276. private _updateScaleBoxes;
  56277. /**
  56278. * Enables rotation on the specified axis and disables rotation on the others
  56279. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  56280. */
  56281. setEnabledRotationAxis(axis: string): void;
  56282. /**
  56283. * Enables/disables scaling
  56284. * @param enable if scaling should be enabled
  56285. * @param homogeneousScaling defines if scaling should only be homogeneous
  56286. */
  56287. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  56288. private _updateDummy;
  56289. /**
  56290. * Enables a pointer drag behavior on the bounding box of the gizmo
  56291. */
  56292. enableDragBehavior(): void;
  56293. /**
  56294. * Disposes of the gizmo
  56295. */
  56296. dispose(): void;
  56297. /**
  56298. * 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)
  56299. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  56300. * @returns the bounding box mesh with the passed in mesh as a child
  56301. */
  56302. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  56303. /**
  56304. * CustomMeshes are not supported by this gizmo
  56305. * @param mesh The mesh to replace the default mesh of the gizmo
  56306. */
  56307. setCustomMesh(mesh: Mesh): void;
  56308. }
  56309. }
  56310. declare module "babylonjs/Gizmos/planeRotationGizmo" {
  56311. import { Observable } from "babylonjs/Misc/observable";
  56312. import { Nullable } from "babylonjs/types";
  56313. import { Vector3 } from "babylonjs/Maths/math.vector";
  56314. import { Color3 } from "babylonjs/Maths/math.color";
  56315. import { Node } from "babylonjs/node";
  56316. import { PointerDragBehavior } from "babylonjs/Behaviors/Meshes/pointerDragBehavior";
  56317. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56318. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56319. import "babylonjs/Meshes/Builders/linesBuilder";
  56320. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56321. /**
  56322. * Single plane rotation gizmo
  56323. */
  56324. export class PlaneRotationGizmo extends Gizmo {
  56325. /**
  56326. * Drag behavior responsible for the gizmos dragging interactions
  56327. */
  56328. dragBehavior: PointerDragBehavior;
  56329. private _pointerObserver;
  56330. /**
  56331. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  56332. */
  56333. snapDistance: number;
  56334. /**
  56335. * Event that fires each time the gizmo snaps to a new location.
  56336. * * snapDistance is the the change in distance
  56337. */
  56338. onSnapObservable: Observable<{
  56339. snapDistance: number;
  56340. }>;
  56341. private _isEnabled;
  56342. private _parent;
  56343. /**
  56344. * Creates a PlaneRotationGizmo
  56345. * @param gizmoLayer The utility layer the gizmo will be added to
  56346. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  56347. * @param color The color of the gizmo
  56348. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56349. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56350. * @param thickness display gizmo axis thickness
  56351. */
  56352. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  56353. protected _attachedNodeChanged(value: Nullable<Node>): void;
  56354. /**
  56355. * If the gizmo is enabled
  56356. */
  56357. set isEnabled(value: boolean);
  56358. get isEnabled(): boolean;
  56359. /**
  56360. * Disposes of the gizmo
  56361. */
  56362. dispose(): void;
  56363. }
  56364. }
  56365. declare module "babylonjs/Gizmos/rotationGizmo" {
  56366. import { Observable } from "babylonjs/Misc/observable";
  56367. import { Nullable } from "babylonjs/types";
  56368. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56369. import { Mesh } from "babylonjs/Meshes/mesh";
  56370. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56371. import { PlaneRotationGizmo } from "babylonjs/Gizmos/planeRotationGizmo";
  56372. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56373. import { Node } from "babylonjs/node";
  56374. /**
  56375. * Gizmo that enables rotating a mesh along 3 axis
  56376. */
  56377. export class RotationGizmo extends Gizmo {
  56378. /**
  56379. * Internal gizmo used for interactions on the x axis
  56380. */
  56381. xGizmo: PlaneRotationGizmo;
  56382. /**
  56383. * Internal gizmo used for interactions on the y axis
  56384. */
  56385. yGizmo: PlaneRotationGizmo;
  56386. /**
  56387. * Internal gizmo used for interactions on the z axis
  56388. */
  56389. zGizmo: PlaneRotationGizmo;
  56390. /** Fires an event when any of it's sub gizmos are dragged */
  56391. onDragStartObservable: Observable<unknown>;
  56392. /** Fires an event when any of it's sub gizmos are released from dragging */
  56393. onDragEndObservable: Observable<unknown>;
  56394. private _meshAttached;
  56395. private _nodeAttached;
  56396. get attachedMesh(): Nullable<AbstractMesh>;
  56397. set attachedMesh(mesh: Nullable<AbstractMesh>);
  56398. get attachedNode(): Nullable<Node>;
  56399. set attachedNode(node: Nullable<Node>);
  56400. /**
  56401. * True when the mouse pointer is hovering a gizmo mesh
  56402. */
  56403. get isHovered(): boolean;
  56404. /**
  56405. * Creates a RotationGizmo
  56406. * @param gizmoLayer The utility layer the gizmo will be added to
  56407. * @param tessellation Amount of tessellation to be used when creating rotation circles
  56408. * @param useEulerRotation Use and update Euler angle instead of quaternion
  56409. * @param thickness display gizmo axis thickness
  56410. */
  56411. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  56412. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  56413. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  56414. /**
  56415. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  56416. */
  56417. set snapDistance(value: number);
  56418. get snapDistance(): number;
  56419. /**
  56420. * Ratio for the scale of the gizmo (Default: 1)
  56421. */
  56422. set scaleRatio(value: number);
  56423. get scaleRatio(): number;
  56424. /**
  56425. * Disposes of the gizmo
  56426. */
  56427. dispose(): void;
  56428. /**
  56429. * CustomMeshes are not supported by this gizmo
  56430. * @param mesh The mesh to replace the default mesh of the gizmo
  56431. */
  56432. setCustomMesh(mesh: Mesh): void;
  56433. }
  56434. }
  56435. declare module "babylonjs/Gizmos/gizmoManager" {
  56436. import { Observable } from "babylonjs/Misc/observable";
  56437. import { Nullable } from "babylonjs/types";
  56438. import { Scene, IDisposable } from "babylonjs/scene";
  56439. import { Node } from "babylonjs/node";
  56440. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56441. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56442. import { SixDofDragBehavior } from "babylonjs/Behaviors/Meshes/sixDofDragBehavior";
  56443. import { RotationGizmo } from "babylonjs/Gizmos/rotationGizmo";
  56444. import { PositionGizmo } from "babylonjs/Gizmos/positionGizmo";
  56445. import { ScaleGizmo } from "babylonjs/Gizmos/scaleGizmo";
  56446. import { BoundingBoxGizmo } from "babylonjs/Gizmos/boundingBoxGizmo";
  56447. /**
  56448. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  56449. */
  56450. export class GizmoManager implements IDisposable {
  56451. private scene;
  56452. /**
  56453. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  56454. */
  56455. gizmos: {
  56456. positionGizmo: Nullable<PositionGizmo>;
  56457. rotationGizmo: Nullable<RotationGizmo>;
  56458. scaleGizmo: Nullable<ScaleGizmo>;
  56459. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  56460. };
  56461. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  56462. clearGizmoOnEmptyPointerEvent: boolean;
  56463. /** Fires an event when the manager is attached to a mesh */
  56464. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  56465. /** Fires an event when the manager is attached to a node */
  56466. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  56467. private _gizmosEnabled;
  56468. private _pointerObserver;
  56469. private _attachedMesh;
  56470. private _attachedNode;
  56471. private _boundingBoxColor;
  56472. private _defaultUtilityLayer;
  56473. private _defaultKeepDepthUtilityLayer;
  56474. private _thickness;
  56475. /**
  56476. * When bounding box gizmo is enabled, this can be used to track drag/end events
  56477. */
  56478. boundingBoxDragBehavior: SixDofDragBehavior;
  56479. /**
  56480. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  56481. */
  56482. attachableMeshes: Nullable<Array<AbstractMesh>>;
  56483. /**
  56484. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  56485. */
  56486. attachableNodes: Nullable<Array<Node>>;
  56487. /**
  56488. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  56489. */
  56490. usePointerToAttachGizmos: boolean;
  56491. /**
  56492. * Utility layer that the bounding box gizmo belongs to
  56493. */
  56494. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  56495. /**
  56496. * Utility layer that all gizmos besides bounding box belong to
  56497. */
  56498. get utilityLayer(): UtilityLayerRenderer;
  56499. /**
  56500. * True when the mouse pointer is hovering a gizmo mesh
  56501. */
  56502. get isHovered(): boolean;
  56503. /**
  56504. * Instatiates a gizmo manager
  56505. * @param scene the scene to overlay the gizmos on top of
  56506. * @param thickness display gizmo axis thickness
  56507. */
  56508. constructor(scene: Scene, thickness?: number);
  56509. /**
  56510. * Attaches a set of gizmos to the specified mesh
  56511. * @param mesh The mesh the gizmo's should be attached to
  56512. */
  56513. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  56514. /**
  56515. * Attaches a set of gizmos to the specified node
  56516. * @param node The node the gizmo's should be attached to
  56517. */
  56518. attachToNode(node: Nullable<Node>): void;
  56519. /**
  56520. * If the position gizmo is enabled
  56521. */
  56522. set positionGizmoEnabled(value: boolean);
  56523. get positionGizmoEnabled(): boolean;
  56524. /**
  56525. * If the rotation gizmo is enabled
  56526. */
  56527. set rotationGizmoEnabled(value: boolean);
  56528. get rotationGizmoEnabled(): boolean;
  56529. /**
  56530. * If the scale gizmo is enabled
  56531. */
  56532. set scaleGizmoEnabled(value: boolean);
  56533. get scaleGizmoEnabled(): boolean;
  56534. /**
  56535. * If the boundingBox gizmo is enabled
  56536. */
  56537. set boundingBoxGizmoEnabled(value: boolean);
  56538. get boundingBoxGizmoEnabled(): boolean;
  56539. /**
  56540. * Disposes of the gizmo manager
  56541. */
  56542. dispose(): void;
  56543. }
  56544. }
  56545. declare module "babylonjs/Lights/directionalLight" {
  56546. import { Camera } from "babylonjs/Cameras/camera";
  56547. import { Scene } from "babylonjs/scene";
  56548. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56549. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56550. import { Light } from "babylonjs/Lights/light";
  56551. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56552. import { Effect } from "babylonjs/Materials/effect";
  56553. /**
  56554. * A directional light is defined by a direction (what a surprise!).
  56555. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  56556. * 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.
  56557. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56558. */
  56559. export class DirectionalLight extends ShadowLight {
  56560. private _shadowFrustumSize;
  56561. /**
  56562. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  56563. */
  56564. get shadowFrustumSize(): number;
  56565. /**
  56566. * Specifies a fix frustum size for the shadow generation.
  56567. */
  56568. set shadowFrustumSize(value: number);
  56569. private _shadowOrthoScale;
  56570. /**
  56571. * Gets the shadow projection scale against the optimal computed one.
  56572. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56573. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56574. */
  56575. get shadowOrthoScale(): number;
  56576. /**
  56577. * Sets the shadow projection scale against the optimal computed one.
  56578. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  56579. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  56580. */
  56581. set shadowOrthoScale(value: number);
  56582. /**
  56583. * Automatically compute the projection matrix to best fit (including all the casters)
  56584. * on each frame.
  56585. */
  56586. autoUpdateExtends: boolean;
  56587. /**
  56588. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  56589. * on each frame. autoUpdateExtends must be set to true for this to work
  56590. */
  56591. autoCalcShadowZBounds: boolean;
  56592. private _orthoLeft;
  56593. private _orthoRight;
  56594. private _orthoTop;
  56595. private _orthoBottom;
  56596. /**
  56597. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  56598. * The directional light is emitted from everywhere in the given direction.
  56599. * It can cast shadows.
  56600. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56601. * @param name The friendly name of the light
  56602. * @param direction The direction of the light
  56603. * @param scene The scene the light belongs to
  56604. */
  56605. constructor(name: string, direction: Vector3, scene: Scene);
  56606. /**
  56607. * Returns the string "DirectionalLight".
  56608. * @return The class name
  56609. */
  56610. getClassName(): string;
  56611. /**
  56612. * Returns the integer 1.
  56613. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56614. */
  56615. getTypeID(): number;
  56616. /**
  56617. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  56618. * Returns the DirectionalLight Shadow projection matrix.
  56619. */
  56620. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56621. /**
  56622. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  56623. * Returns the DirectionalLight Shadow projection matrix.
  56624. */
  56625. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  56626. /**
  56627. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  56628. * Returns the DirectionalLight Shadow projection matrix.
  56629. */
  56630. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56631. protected _buildUniformLayout(): void;
  56632. /**
  56633. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  56634. * @param effect The effect to update
  56635. * @param lightIndex The index of the light in the effect to update
  56636. * @returns The directional light
  56637. */
  56638. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  56639. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  56640. /**
  56641. * Gets the minZ used for shadow according to both the scene and the light.
  56642. *
  56643. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56644. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56645. * @param activeCamera The camera we are returning the min for
  56646. * @returns the depth min z
  56647. */
  56648. getDepthMinZ(activeCamera: Camera): number;
  56649. /**
  56650. * Gets the maxZ used for shadow according to both the scene and the light.
  56651. *
  56652. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  56653. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  56654. * @param activeCamera The camera we are returning the max for
  56655. * @returns the depth max z
  56656. */
  56657. getDepthMaxZ(activeCamera: Camera): number;
  56658. /**
  56659. * Prepares the list of defines specific to the light type.
  56660. * @param defines the list of defines
  56661. * @param lightIndex defines the index of the light for the effect
  56662. */
  56663. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56664. }
  56665. }
  56666. declare module "babylonjs/Meshes/Builders/hemisphereBuilder" {
  56667. import { Mesh } from "babylonjs/Meshes/mesh";
  56668. /**
  56669. * Class containing static functions to help procedurally build meshes
  56670. */
  56671. export class HemisphereBuilder {
  56672. /**
  56673. * Creates a hemisphere mesh
  56674. * @param name defines the name of the mesh
  56675. * @param options defines the options used to create the mesh
  56676. * @param scene defines the hosting scene
  56677. * @returns the hemisphere mesh
  56678. */
  56679. static CreateHemisphere(name: string, options: {
  56680. segments?: number;
  56681. diameter?: number;
  56682. sideOrientation?: number;
  56683. }, scene: any): Mesh;
  56684. }
  56685. }
  56686. declare module "babylonjs/Lights/spotLight" {
  56687. import { Nullable } from "babylonjs/types";
  56688. import { Scene } from "babylonjs/scene";
  56689. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  56690. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  56691. import { Effect } from "babylonjs/Materials/effect";
  56692. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  56693. import { Light } from "babylonjs/Lights/light";
  56694. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  56695. /**
  56696. * A spot light is defined by a position, a direction, an angle, and an exponent.
  56697. * These values define a cone of light starting from the position, emitting toward the direction.
  56698. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  56699. * and the exponent defines the speed of the decay of the light with distance (reach).
  56700. * Documentation: https://doc.babylonjs.com/babylon101/lights
  56701. */
  56702. export class SpotLight extends ShadowLight {
  56703. private _angle;
  56704. private _innerAngle;
  56705. private _cosHalfAngle;
  56706. private _lightAngleScale;
  56707. private _lightAngleOffset;
  56708. /**
  56709. * Gets the cone angle of the spot light in Radians.
  56710. */
  56711. get angle(): number;
  56712. /**
  56713. * Sets the cone angle of the spot light in Radians.
  56714. */
  56715. set angle(value: number);
  56716. /**
  56717. * Only used in gltf falloff mode, this defines the angle where
  56718. * the directional falloff will start before cutting at angle which could be seen
  56719. * as outer angle.
  56720. */
  56721. get innerAngle(): number;
  56722. /**
  56723. * Only used in gltf falloff mode, this defines the angle where
  56724. * the directional falloff will start before cutting at angle which could be seen
  56725. * as outer angle.
  56726. */
  56727. set innerAngle(value: number);
  56728. private _shadowAngleScale;
  56729. /**
  56730. * Allows scaling the angle of the light for shadow generation only.
  56731. */
  56732. get shadowAngleScale(): number;
  56733. /**
  56734. * Allows scaling the angle of the light for shadow generation only.
  56735. */
  56736. set shadowAngleScale(value: number);
  56737. /**
  56738. * The light decay speed with the distance from the emission spot.
  56739. */
  56740. exponent: number;
  56741. private _projectionTextureMatrix;
  56742. /**
  56743. * Allows reading the projecton texture
  56744. */
  56745. get projectionTextureMatrix(): Matrix;
  56746. protected _projectionTextureLightNear: number;
  56747. /**
  56748. * Gets the near clip of the Spotlight for texture projection.
  56749. */
  56750. get projectionTextureLightNear(): number;
  56751. /**
  56752. * Sets the near clip of the Spotlight for texture projection.
  56753. */
  56754. set projectionTextureLightNear(value: number);
  56755. protected _projectionTextureLightFar: number;
  56756. /**
  56757. * Gets the far clip of the Spotlight for texture projection.
  56758. */
  56759. get projectionTextureLightFar(): number;
  56760. /**
  56761. * Sets the far clip of the Spotlight for texture projection.
  56762. */
  56763. set projectionTextureLightFar(value: number);
  56764. protected _projectionTextureUpDirection: Vector3;
  56765. /**
  56766. * Gets the Up vector of the Spotlight for texture projection.
  56767. */
  56768. get projectionTextureUpDirection(): Vector3;
  56769. /**
  56770. * Sets the Up vector of the Spotlight for texture projection.
  56771. */
  56772. set projectionTextureUpDirection(value: Vector3);
  56773. private _projectionTexture;
  56774. /**
  56775. * Gets the projection texture of the light.
  56776. */
  56777. get projectionTexture(): Nullable<BaseTexture>;
  56778. /**
  56779. * Sets the projection texture of the light.
  56780. */
  56781. set projectionTexture(value: Nullable<BaseTexture>);
  56782. private _projectionTextureViewLightDirty;
  56783. private _projectionTextureProjectionLightDirty;
  56784. private _projectionTextureDirty;
  56785. private _projectionTextureViewTargetVector;
  56786. private _projectionTextureViewLightMatrix;
  56787. private _projectionTextureProjectionLightMatrix;
  56788. private _projectionTextureScalingMatrix;
  56789. /**
  56790. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  56791. * It can cast shadows.
  56792. * Documentation : https://doc.babylonjs.com/babylon101/lights
  56793. * @param name The light friendly name
  56794. * @param position The position of the spot light in the scene
  56795. * @param direction The direction of the light in the scene
  56796. * @param angle The cone angle of the light in Radians
  56797. * @param exponent The light decay speed with the distance from the emission spot
  56798. * @param scene The scene the lights belongs to
  56799. */
  56800. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  56801. /**
  56802. * Returns the string "SpotLight".
  56803. * @returns the class name
  56804. */
  56805. getClassName(): string;
  56806. /**
  56807. * Returns the integer 2.
  56808. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  56809. */
  56810. getTypeID(): number;
  56811. /**
  56812. * Overrides the direction setter to recompute the projection texture view light Matrix.
  56813. */
  56814. protected _setDirection(value: Vector3): void;
  56815. /**
  56816. * Overrides the position setter to recompute the projection texture view light Matrix.
  56817. */
  56818. protected _setPosition(value: Vector3): void;
  56819. /**
  56820. * 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.
  56821. * Returns the SpotLight.
  56822. */
  56823. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  56824. protected _computeProjectionTextureViewLightMatrix(): void;
  56825. protected _computeProjectionTextureProjectionLightMatrix(): void;
  56826. /**
  56827. * Main function for light texture projection matrix computing.
  56828. */
  56829. protected _computeProjectionTextureMatrix(): void;
  56830. protected _buildUniformLayout(): void;
  56831. private _computeAngleValues;
  56832. /**
  56833. * Sets the passed Effect "effect" with the Light textures.
  56834. * @param effect The effect to update
  56835. * @param lightIndex The index of the light in the effect to update
  56836. * @returns The light
  56837. */
  56838. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  56839. /**
  56840. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  56841. * @param effect The effect to update
  56842. * @param lightIndex The index of the light in the effect to update
  56843. * @returns The spot light
  56844. */
  56845. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  56846. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  56847. /**
  56848. * Disposes the light and the associated resources.
  56849. */
  56850. dispose(): void;
  56851. /**
  56852. * Prepares the list of defines specific to the light type.
  56853. * @param defines the list of defines
  56854. * @param lightIndex defines the index of the light for the effect
  56855. */
  56856. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  56857. }
  56858. }
  56859. declare module "babylonjs/Gizmos/lightGizmo" {
  56860. import { Nullable } from "babylonjs/types";
  56861. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56862. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56863. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56864. import { Light } from "babylonjs/Lights/light";
  56865. import { Observable } from "babylonjs/Misc/observable";
  56866. /**
  56867. * Gizmo that enables viewing a light
  56868. */
  56869. export class LightGizmo extends Gizmo {
  56870. private _lightMesh;
  56871. private _material;
  56872. private _cachedPosition;
  56873. private _cachedForward;
  56874. private _attachedMeshParent;
  56875. private _pointerObserver;
  56876. /**
  56877. * Event that fires each time the gizmo is clicked
  56878. */
  56879. onClickedObservable: Observable<Light>;
  56880. /**
  56881. * Creates a LightGizmo
  56882. * @param gizmoLayer The utility layer the gizmo will be added to
  56883. */
  56884. constructor(gizmoLayer?: UtilityLayerRenderer);
  56885. private _light;
  56886. /**
  56887. * The light that the gizmo is attached to
  56888. */
  56889. set light(light: Nullable<Light>);
  56890. get light(): Nullable<Light>;
  56891. /**
  56892. * Gets the material used to render the light gizmo
  56893. */
  56894. get material(): StandardMaterial;
  56895. /**
  56896. * @hidden
  56897. * Updates the gizmo to match the attached mesh's position/rotation
  56898. */
  56899. protected _update(): void;
  56900. private static _Scale;
  56901. /**
  56902. * Creates the lines for a light mesh
  56903. */
  56904. private static _CreateLightLines;
  56905. /**
  56906. * Disposes of the light gizmo
  56907. */
  56908. dispose(): void;
  56909. private static _CreateHemisphericLightMesh;
  56910. private static _CreatePointLightMesh;
  56911. private static _CreateSpotLightMesh;
  56912. private static _CreateDirectionalLightMesh;
  56913. }
  56914. }
  56915. declare module "babylonjs/Gizmos/cameraGizmo" {
  56916. import { Nullable } from "babylonjs/types";
  56917. import { Gizmo } from "babylonjs/Gizmos/gizmo";
  56918. import { UtilityLayerRenderer } from "babylonjs/Rendering/utilityLayerRenderer";
  56919. import { StandardMaterial } from "babylonjs/Materials/standardMaterial";
  56920. import { Camera } from "babylonjs/Cameras/camera";
  56921. import { Observable } from "babylonjs/Misc/observable";
  56922. /**
  56923. * Gizmo that enables viewing a camera
  56924. */
  56925. export class CameraGizmo extends Gizmo {
  56926. private _cameraMesh;
  56927. private _cameraLinesMesh;
  56928. private _material;
  56929. private _pointerObserver;
  56930. /**
  56931. * Event that fires each time the gizmo is clicked
  56932. */
  56933. onClickedObservable: Observable<Camera>;
  56934. /**
  56935. * Creates a CameraGizmo
  56936. * @param gizmoLayer The utility layer the gizmo will be added to
  56937. */
  56938. constructor(gizmoLayer?: UtilityLayerRenderer);
  56939. private _camera;
  56940. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  56941. get displayFrustum(): boolean;
  56942. set displayFrustum(value: boolean);
  56943. /**
  56944. * The camera that the gizmo is attached to
  56945. */
  56946. set camera(camera: Nullable<Camera>);
  56947. get camera(): Nullable<Camera>;
  56948. /**
  56949. * Gets the material used to render the camera gizmo
  56950. */
  56951. get material(): StandardMaterial;
  56952. /**
  56953. * @hidden
  56954. * Updates the gizmo to match the attached mesh's position/rotation
  56955. */
  56956. protected _update(): void;
  56957. private static _Scale;
  56958. private _invProjection;
  56959. /**
  56960. * Disposes of the camera gizmo
  56961. */
  56962. dispose(): void;
  56963. private static _CreateCameraMesh;
  56964. private static _CreateCameraFrustum;
  56965. }
  56966. }
  56967. declare module "babylonjs/Gizmos/index" {
  56968. export * from "babylonjs/Gizmos/axisDragGizmo";
  56969. export * from "babylonjs/Gizmos/axisScaleGizmo";
  56970. export * from "babylonjs/Gizmos/boundingBoxGizmo";
  56971. export * from "babylonjs/Gizmos/gizmo";
  56972. export * from "babylonjs/Gizmos/gizmoManager";
  56973. export * from "babylonjs/Gizmos/planeRotationGizmo";
  56974. export * from "babylonjs/Gizmos/positionGizmo";
  56975. export * from "babylonjs/Gizmos/rotationGizmo";
  56976. export * from "babylonjs/Gizmos/scaleGizmo";
  56977. export * from "babylonjs/Gizmos/lightGizmo";
  56978. export * from "babylonjs/Gizmos/cameraGizmo";
  56979. export * from "babylonjs/Gizmos/planeDragGizmo";
  56980. }
  56981. declare module "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration" {
  56982. /** @hidden */
  56983. export var backgroundFragmentDeclaration: {
  56984. name: string;
  56985. shader: string;
  56986. };
  56987. }
  56988. declare module "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration" {
  56989. /** @hidden */
  56990. export var backgroundUboDeclaration: {
  56991. name: string;
  56992. shader: string;
  56993. };
  56994. }
  56995. declare module "babylonjs/Shaders/background.fragment" {
  56996. import "babylonjs/Shaders/ShadersInclude/backgroundFragmentDeclaration";
  56997. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  56998. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  56999. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  57000. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57001. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57002. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57003. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  57004. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  57005. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  57006. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  57007. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  57008. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  57009. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  57010. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  57011. /** @hidden */
  57012. export var backgroundPixelShader: {
  57013. name: string;
  57014. shader: string;
  57015. };
  57016. }
  57017. declare module "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration" {
  57018. /** @hidden */
  57019. export var backgroundVertexDeclaration: {
  57020. name: string;
  57021. shader: string;
  57022. };
  57023. }
  57024. declare module "babylonjs/Shaders/background.vertex" {
  57025. import "babylonjs/Shaders/ShadersInclude/backgroundVertexDeclaration";
  57026. import "babylonjs/Shaders/ShadersInclude/backgroundUboDeclaration";
  57027. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  57028. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  57029. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  57030. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  57031. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  57032. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  57033. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  57034. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  57035. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  57036. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  57037. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  57038. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  57039. /** @hidden */
  57040. export var backgroundVertexShader: {
  57041. name: string;
  57042. shader: string;
  57043. };
  57044. }
  57045. declare module "babylonjs/Materials/Background/backgroundMaterial" {
  57046. import { Nullable, int, float } from "babylonjs/types";
  57047. import { Scene } from "babylonjs/scene";
  57048. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  57049. import { SubMesh } from "babylonjs/Meshes/subMesh";
  57050. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57051. import { Mesh } from "babylonjs/Meshes/mesh";
  57052. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  57053. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  57054. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  57055. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57056. import { IShadowLight } from "babylonjs/Lights/shadowLight";
  57057. import { Color3 } from "babylonjs/Maths/math.color";
  57058. import "babylonjs/Shaders/background.fragment";
  57059. import "babylonjs/Shaders/background.vertex";
  57060. /**
  57061. * Background material used to create an efficient environement around your scene.
  57062. */
  57063. export class BackgroundMaterial extends PushMaterial {
  57064. /**
  57065. * Standard reflectance value at parallel view angle.
  57066. */
  57067. static StandardReflectance0: number;
  57068. /**
  57069. * Standard reflectance value at grazing angle.
  57070. */
  57071. static StandardReflectance90: number;
  57072. protected _primaryColor: Color3;
  57073. /**
  57074. * Key light Color (multiply against the environement texture)
  57075. */
  57076. primaryColor: Color3;
  57077. protected __perceptualColor: Nullable<Color3>;
  57078. /**
  57079. * Experimental Internal Use Only.
  57080. *
  57081. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  57082. * This acts as a helper to set the primary color to a more "human friendly" value.
  57083. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  57084. * output color as close as possible from the chosen value.
  57085. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  57086. * part of lighting setup.)
  57087. */
  57088. get _perceptualColor(): Nullable<Color3>;
  57089. set _perceptualColor(value: Nullable<Color3>);
  57090. protected _primaryColorShadowLevel: float;
  57091. /**
  57092. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  57093. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  57094. */
  57095. get primaryColorShadowLevel(): float;
  57096. set primaryColorShadowLevel(value: float);
  57097. protected _primaryColorHighlightLevel: float;
  57098. /**
  57099. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  57100. * The primary color is used at the level chosen to define what the white area would look.
  57101. */
  57102. get primaryColorHighlightLevel(): float;
  57103. set primaryColorHighlightLevel(value: float);
  57104. protected _reflectionTexture: Nullable<BaseTexture>;
  57105. /**
  57106. * Reflection Texture used in the material.
  57107. * Should be author in a specific way for the best result (refer to the documentation).
  57108. */
  57109. reflectionTexture: Nullable<BaseTexture>;
  57110. protected _reflectionBlur: float;
  57111. /**
  57112. * Reflection Texture level of blur.
  57113. *
  57114. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  57115. * texture twice.
  57116. */
  57117. reflectionBlur: float;
  57118. protected _diffuseTexture: Nullable<BaseTexture>;
  57119. /**
  57120. * Diffuse Texture used in the material.
  57121. * Should be author in a specific way for the best result (refer to the documentation).
  57122. */
  57123. diffuseTexture: Nullable<BaseTexture>;
  57124. protected _shadowLights: Nullable<IShadowLight[]>;
  57125. /**
  57126. * Specify the list of lights casting shadow on the material.
  57127. * All scene shadow lights will be included if null.
  57128. */
  57129. shadowLights: Nullable<IShadowLight[]>;
  57130. protected _shadowLevel: float;
  57131. /**
  57132. * Helps adjusting the shadow to a softer level if required.
  57133. * 0 means black shadows and 1 means no shadows.
  57134. */
  57135. shadowLevel: float;
  57136. protected _sceneCenter: Vector3;
  57137. /**
  57138. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  57139. * It is usually zero but might be interesting to modify according to your setup.
  57140. */
  57141. sceneCenter: Vector3;
  57142. protected _opacityFresnel: boolean;
  57143. /**
  57144. * This helps specifying that the material is falling off to the sky box at grazing angle.
  57145. * This helps ensuring a nice transition when the camera goes under the ground.
  57146. */
  57147. opacityFresnel: boolean;
  57148. protected _reflectionFresnel: boolean;
  57149. /**
  57150. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  57151. * This helps adding a mirror texture on the ground.
  57152. */
  57153. reflectionFresnel: boolean;
  57154. protected _reflectionFalloffDistance: number;
  57155. /**
  57156. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  57157. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  57158. */
  57159. reflectionFalloffDistance: number;
  57160. protected _reflectionAmount: number;
  57161. /**
  57162. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  57163. */
  57164. reflectionAmount: number;
  57165. protected _reflectionReflectance0: number;
  57166. /**
  57167. * This specifies the weight of the reflection at grazing angle.
  57168. */
  57169. reflectionReflectance0: number;
  57170. protected _reflectionReflectance90: number;
  57171. /**
  57172. * This specifies the weight of the reflection at a perpendicular point of view.
  57173. */
  57174. reflectionReflectance90: number;
  57175. /**
  57176. * Sets the reflection reflectance fresnel values according to the default standard
  57177. * empirically know to work well :-)
  57178. */
  57179. set reflectionStandardFresnelWeight(value: number);
  57180. protected _useRGBColor: boolean;
  57181. /**
  57182. * Helps to directly use the maps channels instead of their level.
  57183. */
  57184. useRGBColor: boolean;
  57185. protected _enableNoise: boolean;
  57186. /**
  57187. * This helps reducing the banding effect that could occur on the background.
  57188. */
  57189. enableNoise: boolean;
  57190. /**
  57191. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57192. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  57193. * Recommended to be keep at 1.0 except for special cases.
  57194. */
  57195. get fovMultiplier(): number;
  57196. set fovMultiplier(value: number);
  57197. private _fovMultiplier;
  57198. /**
  57199. * Enable the FOV adjustment feature controlled by fovMultiplier.
  57200. */
  57201. useEquirectangularFOV: boolean;
  57202. private _maxSimultaneousLights;
  57203. /**
  57204. * Number of Simultaneous lights allowed on the material.
  57205. */
  57206. maxSimultaneousLights: int;
  57207. private _shadowOnly;
  57208. /**
  57209. * Make the material only render shadows
  57210. */
  57211. shadowOnly: boolean;
  57212. /**
  57213. * Default configuration related to image processing available in the Background Material.
  57214. */
  57215. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  57216. /**
  57217. * Keep track of the image processing observer to allow dispose and replace.
  57218. */
  57219. private _imageProcessingObserver;
  57220. /**
  57221. * Attaches a new image processing configuration to the PBR Material.
  57222. * @param configuration (if null the scene configuration will be use)
  57223. */
  57224. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  57225. /**
  57226. * Gets the image processing configuration used either in this material.
  57227. */
  57228. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  57229. /**
  57230. * Sets the Default image processing configuration used either in the this material.
  57231. *
  57232. * If sets to null, the scene one is in use.
  57233. */
  57234. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  57235. /**
  57236. * Gets wether the color curves effect is enabled.
  57237. */
  57238. get cameraColorCurvesEnabled(): boolean;
  57239. /**
  57240. * Sets wether the color curves effect is enabled.
  57241. */
  57242. set cameraColorCurvesEnabled(value: boolean);
  57243. /**
  57244. * Gets wether the color grading effect is enabled.
  57245. */
  57246. get cameraColorGradingEnabled(): boolean;
  57247. /**
  57248. * Gets wether the color grading effect is enabled.
  57249. */
  57250. set cameraColorGradingEnabled(value: boolean);
  57251. /**
  57252. * Gets wether tonemapping is enabled or not.
  57253. */
  57254. get cameraToneMappingEnabled(): boolean;
  57255. /**
  57256. * Sets wether tonemapping is enabled or not
  57257. */
  57258. set cameraToneMappingEnabled(value: boolean);
  57259. /**
  57260. * The camera exposure used on this material.
  57261. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57262. * This corresponds to a photographic exposure.
  57263. */
  57264. get cameraExposure(): float;
  57265. /**
  57266. * The camera exposure used on this material.
  57267. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  57268. * This corresponds to a photographic exposure.
  57269. */
  57270. set cameraExposure(value: float);
  57271. /**
  57272. * Gets The camera contrast used on this material.
  57273. */
  57274. get cameraContrast(): float;
  57275. /**
  57276. * Sets The camera contrast used on this material.
  57277. */
  57278. set cameraContrast(value: float);
  57279. /**
  57280. * Gets the Color Grading 2D Lookup Texture.
  57281. */
  57282. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  57283. /**
  57284. * Sets the Color Grading 2D Lookup Texture.
  57285. */
  57286. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  57287. /**
  57288. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57289. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57290. * 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;
  57291. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57292. */
  57293. get cameraColorCurves(): Nullable<ColorCurves>;
  57294. /**
  57295. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  57296. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  57297. * 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;
  57298. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  57299. */
  57300. set cameraColorCurves(value: Nullable<ColorCurves>);
  57301. /**
  57302. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  57303. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  57304. */
  57305. switchToBGR: boolean;
  57306. private _renderTargets;
  57307. private _reflectionControls;
  57308. private _white;
  57309. private _primaryShadowColor;
  57310. private _primaryHighlightColor;
  57311. /**
  57312. * Instantiates a Background Material in the given scene
  57313. * @param name The friendly name of the material
  57314. * @param scene The scene to add the material to
  57315. */
  57316. constructor(name: string, scene: Scene);
  57317. /**
  57318. * Gets a boolean indicating that current material needs to register RTT
  57319. */
  57320. get hasRenderTargetTextures(): boolean;
  57321. /**
  57322. * The entire material has been created in order to prevent overdraw.
  57323. * @returns false
  57324. */
  57325. needAlphaTesting(): boolean;
  57326. /**
  57327. * The entire material has been created in order to prevent overdraw.
  57328. * @returns true if blending is enable
  57329. */
  57330. needAlphaBlending(): boolean;
  57331. /**
  57332. * Checks wether the material is ready to be rendered for a given mesh.
  57333. * @param mesh The mesh to render
  57334. * @param subMesh The submesh to check against
  57335. * @param useInstances Specify wether or not the material is used with instances
  57336. * @returns true if all the dependencies are ready (Textures, Effects...)
  57337. */
  57338. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  57339. /**
  57340. * Compute the primary color according to the chosen perceptual color.
  57341. */
  57342. private _computePrimaryColorFromPerceptualColor;
  57343. /**
  57344. * Compute the highlights and shadow colors according to their chosen levels.
  57345. */
  57346. private _computePrimaryColors;
  57347. /**
  57348. * Build the uniform buffer used in the material.
  57349. */
  57350. buildUniformLayout(): void;
  57351. /**
  57352. * Unbind the material.
  57353. */
  57354. unbind(): void;
  57355. /**
  57356. * Bind only the world matrix to the material.
  57357. * @param world The world matrix to bind.
  57358. */
  57359. bindOnlyWorldMatrix(world: Matrix): void;
  57360. /**
  57361. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  57362. * @param world The world matrix to bind.
  57363. * @param subMesh The submesh to bind for.
  57364. */
  57365. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  57366. /**
  57367. * Checks to see if a texture is used in the material.
  57368. * @param texture - Base texture to use.
  57369. * @returns - Boolean specifying if a texture is used in the material.
  57370. */
  57371. hasTexture(texture: BaseTexture): boolean;
  57372. /**
  57373. * Dispose the material.
  57374. * @param forceDisposeEffect Force disposal of the associated effect.
  57375. * @param forceDisposeTextures Force disposal of the associated textures.
  57376. */
  57377. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  57378. /**
  57379. * Clones the material.
  57380. * @param name The cloned name.
  57381. * @returns The cloned material.
  57382. */
  57383. clone(name: string): BackgroundMaterial;
  57384. /**
  57385. * Serializes the current material to its JSON representation.
  57386. * @returns The JSON representation.
  57387. */
  57388. serialize(): any;
  57389. /**
  57390. * Gets the class name of the material
  57391. * @returns "BackgroundMaterial"
  57392. */
  57393. getClassName(): string;
  57394. /**
  57395. * Parse a JSON input to create back a background material.
  57396. * @param source The JSON data to parse
  57397. * @param scene The scene to create the parsed material in
  57398. * @param rootUrl The root url of the assets the material depends upon
  57399. * @returns the instantiated BackgroundMaterial.
  57400. */
  57401. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  57402. }
  57403. }
  57404. declare module "babylonjs/Helpers/environmentHelper" {
  57405. import { Observable } from "babylonjs/Misc/observable";
  57406. import { Nullable } from "babylonjs/types";
  57407. import { Scene } from "babylonjs/scene";
  57408. import { Vector3 } from "babylonjs/Maths/math.vector";
  57409. import { Color3 } from "babylonjs/Maths/math.color";
  57410. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  57411. import { Mesh } from "babylonjs/Meshes/mesh";
  57412. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57413. import { MirrorTexture } from "babylonjs/Materials/Textures/mirrorTexture";
  57414. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57415. import "babylonjs/Meshes/Builders/planeBuilder";
  57416. import "babylonjs/Meshes/Builders/boxBuilder";
  57417. /**
  57418. * Represents the different options available during the creation of
  57419. * a Environment helper.
  57420. *
  57421. * This can control the default ground, skybox and image processing setup of your scene.
  57422. */
  57423. export interface IEnvironmentHelperOptions {
  57424. /**
  57425. * Specifies whether or not to create a ground.
  57426. * True by default.
  57427. */
  57428. createGround: boolean;
  57429. /**
  57430. * Specifies the ground size.
  57431. * 15 by default.
  57432. */
  57433. groundSize: number;
  57434. /**
  57435. * The texture used on the ground for the main color.
  57436. * Comes from the BabylonJS CDN by default.
  57437. *
  57438. * Remarks: Can be either a texture or a url.
  57439. */
  57440. groundTexture: string | BaseTexture;
  57441. /**
  57442. * The color mixed in the ground texture by default.
  57443. * BabylonJS clearColor by default.
  57444. */
  57445. groundColor: Color3;
  57446. /**
  57447. * Specifies the ground opacity.
  57448. * 1 by default.
  57449. */
  57450. groundOpacity: number;
  57451. /**
  57452. * Enables the ground to receive shadows.
  57453. * True by default.
  57454. */
  57455. enableGroundShadow: boolean;
  57456. /**
  57457. * Helps preventing the shadow to be fully black on the ground.
  57458. * 0.5 by default.
  57459. */
  57460. groundShadowLevel: number;
  57461. /**
  57462. * Creates a mirror texture attach to the ground.
  57463. * false by default.
  57464. */
  57465. enableGroundMirror: boolean;
  57466. /**
  57467. * Specifies the ground mirror size ratio.
  57468. * 0.3 by default as the default kernel is 64.
  57469. */
  57470. groundMirrorSizeRatio: number;
  57471. /**
  57472. * Specifies the ground mirror blur kernel size.
  57473. * 64 by default.
  57474. */
  57475. groundMirrorBlurKernel: number;
  57476. /**
  57477. * Specifies the ground mirror visibility amount.
  57478. * 1 by default
  57479. */
  57480. groundMirrorAmount: number;
  57481. /**
  57482. * Specifies the ground mirror reflectance weight.
  57483. * This uses the standard weight of the background material to setup the fresnel effect
  57484. * of the mirror.
  57485. * 1 by default.
  57486. */
  57487. groundMirrorFresnelWeight: number;
  57488. /**
  57489. * Specifies the ground mirror Falloff distance.
  57490. * This can helps reducing the size of the reflection.
  57491. * 0 by Default.
  57492. */
  57493. groundMirrorFallOffDistance: number;
  57494. /**
  57495. * Specifies the ground mirror texture type.
  57496. * Unsigned Int by Default.
  57497. */
  57498. groundMirrorTextureType: number;
  57499. /**
  57500. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  57501. * the shown objects.
  57502. */
  57503. groundYBias: number;
  57504. /**
  57505. * Specifies whether or not to create a skybox.
  57506. * True by default.
  57507. */
  57508. createSkybox: boolean;
  57509. /**
  57510. * Specifies the skybox size.
  57511. * 20 by default.
  57512. */
  57513. skyboxSize: number;
  57514. /**
  57515. * The texture used on the skybox for the main color.
  57516. * Comes from the BabylonJS CDN by default.
  57517. *
  57518. * Remarks: Can be either a texture or a url.
  57519. */
  57520. skyboxTexture: string | BaseTexture;
  57521. /**
  57522. * The color mixed in the skybox texture by default.
  57523. * BabylonJS clearColor by default.
  57524. */
  57525. skyboxColor: Color3;
  57526. /**
  57527. * The background rotation around the Y axis of the scene.
  57528. * This helps aligning the key lights of your scene with the background.
  57529. * 0 by default.
  57530. */
  57531. backgroundYRotation: number;
  57532. /**
  57533. * Compute automatically the size of the elements to best fit with the scene.
  57534. */
  57535. sizeAuto: boolean;
  57536. /**
  57537. * Default position of the rootMesh if autoSize is not true.
  57538. */
  57539. rootPosition: Vector3;
  57540. /**
  57541. * Sets up the image processing in the scene.
  57542. * true by default.
  57543. */
  57544. setupImageProcessing: boolean;
  57545. /**
  57546. * The texture used as your environment texture in the scene.
  57547. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  57548. *
  57549. * Remarks: Can be either a texture or a url.
  57550. */
  57551. environmentTexture: string | BaseTexture;
  57552. /**
  57553. * The value of the exposure to apply to the scene.
  57554. * 0.6 by default if setupImageProcessing is true.
  57555. */
  57556. cameraExposure: number;
  57557. /**
  57558. * The value of the contrast to apply to the scene.
  57559. * 1.6 by default if setupImageProcessing is true.
  57560. */
  57561. cameraContrast: number;
  57562. /**
  57563. * Specifies whether or not tonemapping should be enabled in the scene.
  57564. * true by default if setupImageProcessing is true.
  57565. */
  57566. toneMappingEnabled: boolean;
  57567. }
  57568. /**
  57569. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  57570. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  57571. * It also helps with the default setup of your imageProcessing configuration.
  57572. */
  57573. export class EnvironmentHelper {
  57574. /**
  57575. * Default ground texture URL.
  57576. */
  57577. private static _groundTextureCDNUrl;
  57578. /**
  57579. * Default skybox texture URL.
  57580. */
  57581. private static _skyboxTextureCDNUrl;
  57582. /**
  57583. * Default environment texture URL.
  57584. */
  57585. private static _environmentTextureCDNUrl;
  57586. /**
  57587. * Creates the default options for the helper.
  57588. */
  57589. private static _getDefaultOptions;
  57590. private _rootMesh;
  57591. /**
  57592. * Gets the root mesh created by the helper.
  57593. */
  57594. get rootMesh(): Mesh;
  57595. private _skybox;
  57596. /**
  57597. * Gets the skybox created by the helper.
  57598. */
  57599. get skybox(): Nullable<Mesh>;
  57600. private _skyboxTexture;
  57601. /**
  57602. * Gets the skybox texture created by the helper.
  57603. */
  57604. get skyboxTexture(): Nullable<BaseTexture>;
  57605. private _skyboxMaterial;
  57606. /**
  57607. * Gets the skybox material created by the helper.
  57608. */
  57609. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  57610. private _ground;
  57611. /**
  57612. * Gets the ground mesh created by the helper.
  57613. */
  57614. get ground(): Nullable<Mesh>;
  57615. private _groundTexture;
  57616. /**
  57617. * Gets the ground texture created by the helper.
  57618. */
  57619. get groundTexture(): Nullable<BaseTexture>;
  57620. private _groundMirror;
  57621. /**
  57622. * Gets the ground mirror created by the helper.
  57623. */
  57624. get groundMirror(): Nullable<MirrorTexture>;
  57625. /**
  57626. * Gets the ground mirror render list to helps pushing the meshes
  57627. * you wish in the ground reflection.
  57628. */
  57629. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  57630. private _groundMaterial;
  57631. /**
  57632. * Gets the ground material created by the helper.
  57633. */
  57634. get groundMaterial(): Nullable<BackgroundMaterial>;
  57635. /**
  57636. * Stores the creation options.
  57637. */
  57638. private readonly _scene;
  57639. private _options;
  57640. /**
  57641. * This observable will be notified with any error during the creation of the environment,
  57642. * mainly texture creation errors.
  57643. */
  57644. onErrorObservable: Observable<{
  57645. message?: string;
  57646. exception?: any;
  57647. }>;
  57648. /**
  57649. * constructor
  57650. * @param options Defines the options we want to customize the helper
  57651. * @param scene The scene to add the material to
  57652. */
  57653. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  57654. /**
  57655. * Updates the background according to the new options
  57656. * @param options
  57657. */
  57658. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  57659. /**
  57660. * Sets the primary color of all the available elements.
  57661. * @param color the main color to affect to the ground and the background
  57662. */
  57663. setMainColor(color: Color3): void;
  57664. /**
  57665. * Setup the image processing according to the specified options.
  57666. */
  57667. private _setupImageProcessing;
  57668. /**
  57669. * Setup the environment texture according to the specified options.
  57670. */
  57671. private _setupEnvironmentTexture;
  57672. /**
  57673. * Setup the background according to the specified options.
  57674. */
  57675. private _setupBackground;
  57676. /**
  57677. * Get the scene sizes according to the setup.
  57678. */
  57679. private _getSceneSize;
  57680. /**
  57681. * Setup the ground according to the specified options.
  57682. */
  57683. private _setupGround;
  57684. /**
  57685. * Setup the ground material according to the specified options.
  57686. */
  57687. private _setupGroundMaterial;
  57688. /**
  57689. * Setup the ground diffuse texture according to the specified options.
  57690. */
  57691. private _setupGroundDiffuseTexture;
  57692. /**
  57693. * Setup the ground mirror texture according to the specified options.
  57694. */
  57695. private _setupGroundMirrorTexture;
  57696. /**
  57697. * Setup the ground to receive the mirror texture.
  57698. */
  57699. private _setupMirrorInGroundMaterial;
  57700. /**
  57701. * Setup the skybox according to the specified options.
  57702. */
  57703. private _setupSkybox;
  57704. /**
  57705. * Setup the skybox material according to the specified options.
  57706. */
  57707. private _setupSkyboxMaterial;
  57708. /**
  57709. * Setup the skybox reflection texture according to the specified options.
  57710. */
  57711. private _setupSkyboxReflectionTexture;
  57712. private _errorHandler;
  57713. /**
  57714. * Dispose all the elements created by the Helper.
  57715. */
  57716. dispose(): void;
  57717. }
  57718. }
  57719. declare module "babylonjs/Helpers/textureDome" {
  57720. import { Scene } from "babylonjs/scene";
  57721. import { TransformNode } from "babylonjs/Meshes/transformNode";
  57722. import { Mesh } from "babylonjs/Meshes/mesh";
  57723. import { Texture } from "babylonjs/Materials/Textures/texture";
  57724. import { BackgroundMaterial } from "babylonjs/Materials/Background/backgroundMaterial";
  57725. import "babylonjs/Meshes/Builders/sphereBuilder";
  57726. import { Nullable } from "babylonjs/types";
  57727. import { Observable } from "babylonjs/Misc/observable";
  57728. /**
  57729. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  57730. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  57731. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57732. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57733. */
  57734. export abstract class TextureDome<T extends Texture> extends TransformNode {
  57735. protected onError: Nullable<(message?: string, exception?: any) => void>;
  57736. /**
  57737. * Define the source as a Monoscopic panoramic 360/180.
  57738. */
  57739. static readonly MODE_MONOSCOPIC: number;
  57740. /**
  57741. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  57742. */
  57743. static readonly MODE_TOPBOTTOM: number;
  57744. /**
  57745. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  57746. */
  57747. static readonly MODE_SIDEBYSIDE: number;
  57748. private _halfDome;
  57749. protected _useDirectMapping: boolean;
  57750. /**
  57751. * The texture being displayed on the sphere
  57752. */
  57753. protected _texture: T;
  57754. /**
  57755. * Gets the texture being displayed on the sphere
  57756. */
  57757. get texture(): T;
  57758. /**
  57759. * Sets the texture being displayed on the sphere
  57760. */
  57761. set texture(newTexture: T);
  57762. /**
  57763. * The skybox material
  57764. */
  57765. protected _material: BackgroundMaterial;
  57766. /**
  57767. * The surface used for the dome
  57768. */
  57769. protected _mesh: Mesh;
  57770. /**
  57771. * Gets the mesh used for the dome.
  57772. */
  57773. get mesh(): Mesh;
  57774. /**
  57775. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  57776. */
  57777. private _halfDomeMask;
  57778. /**
  57779. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  57780. * Also see the options.resolution property.
  57781. */
  57782. get fovMultiplier(): number;
  57783. set fovMultiplier(value: number);
  57784. protected _textureMode: number;
  57785. /**
  57786. * Gets or set the current texture mode for the texture. It can be:
  57787. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57788. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57789. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57790. */
  57791. get textureMode(): number;
  57792. /**
  57793. * Sets the current texture mode for the texture. It can be:
  57794. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57795. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57796. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57797. */
  57798. set textureMode(value: number);
  57799. /**
  57800. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  57801. */
  57802. get halfDome(): boolean;
  57803. /**
  57804. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  57805. */
  57806. set halfDome(enabled: boolean);
  57807. /**
  57808. * Oberserver used in Stereoscopic VR Mode.
  57809. */
  57810. private _onBeforeCameraRenderObserver;
  57811. /**
  57812. * Observable raised when an error occured while loading the 360 image
  57813. */
  57814. onLoadErrorObservable: Observable<string>;
  57815. /**
  57816. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  57817. * @param name Element's name, child elements will append suffixes for their own names.
  57818. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  57819. * @param options An object containing optional or exposed sub element properties
  57820. */
  57821. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  57822. resolution?: number;
  57823. clickToPlay?: boolean;
  57824. autoPlay?: boolean;
  57825. loop?: boolean;
  57826. size?: number;
  57827. poster?: string;
  57828. faceForward?: boolean;
  57829. useDirectMapping?: boolean;
  57830. halfDomeMode?: boolean;
  57831. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  57832. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  57833. protected _changeTextureMode(value: number): void;
  57834. /**
  57835. * Releases resources associated with this node.
  57836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  57837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  57838. */
  57839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  57840. }
  57841. }
  57842. declare module "babylonjs/Helpers/photoDome" {
  57843. import { Scene } from "babylonjs/scene";
  57844. import { Texture } from "babylonjs/Materials/Textures/texture";
  57845. import { TextureDome } from "babylonjs/Helpers/textureDome";
  57846. /**
  57847. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  57848. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  57849. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  57850. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  57851. */
  57852. export class PhotoDome extends TextureDome<Texture> {
  57853. /**
  57854. * Define the image as a Monoscopic panoramic 360 image.
  57855. */
  57856. static readonly MODE_MONOSCOPIC: number;
  57857. /**
  57858. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  57859. */
  57860. static readonly MODE_TOPBOTTOM: number;
  57861. /**
  57862. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  57863. */
  57864. static readonly MODE_SIDEBYSIDE: number;
  57865. /**
  57866. * Gets or sets the texture being displayed on the sphere
  57867. */
  57868. get photoTexture(): Texture;
  57869. /**
  57870. * sets the texture being displayed on the sphere
  57871. */
  57872. set photoTexture(value: Texture);
  57873. /**
  57874. * Gets the current video mode for the video. It can be:
  57875. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57876. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57877. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57878. */
  57879. get imageMode(): number;
  57880. /**
  57881. * Sets the current video mode for the video. It can be:
  57882. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  57883. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  57884. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  57885. */
  57886. set imageMode(value: number);
  57887. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  57888. }
  57889. }
  57890. declare module "babylonjs/Misc/rgbdTextureTools" {
  57891. import "babylonjs/Shaders/rgbdDecode.fragment";
  57892. import "babylonjs/Engines/Extensions/engine.renderTarget";
  57893. import { Texture } from "babylonjs/Materials/Textures/texture";
  57894. /**
  57895. * Class used to host RGBD texture specific utilities
  57896. */
  57897. export class RGBDTextureTools {
  57898. /**
  57899. * Expand the RGBD Texture from RGBD to Half Float if possible.
  57900. * @param texture the texture to expand.
  57901. */
  57902. static ExpandRGBDTexture(texture: Texture): void;
  57903. }
  57904. }
  57905. declare module "babylonjs/Misc/brdfTextureTools" {
  57906. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57907. import { Scene } from "babylonjs/scene";
  57908. /**
  57909. * Class used to host texture specific utilities
  57910. */
  57911. export class BRDFTextureTools {
  57912. /**
  57913. * Prevents texture cache collision
  57914. */
  57915. private static _instanceNumber;
  57916. /**
  57917. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  57918. * @param scene defines the hosting scene
  57919. * @returns the environment BRDF texture
  57920. */
  57921. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  57922. private static _environmentBRDFBase64Texture;
  57923. }
  57924. }
  57925. declare module "babylonjs/Materials/PBR/pbrClearCoatConfiguration" {
  57926. import { Nullable } from "babylonjs/types";
  57927. import { Color3 } from "babylonjs/Maths/math.color";
  57928. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  57929. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  57930. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  57931. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  57932. import { Engine } from "babylonjs/Engines/engine";
  57933. import { Scene } from "babylonjs/scene";
  57934. /**
  57935. * @hidden
  57936. */
  57937. export interface IMaterialClearCoatDefines {
  57938. CLEARCOAT: boolean;
  57939. CLEARCOAT_DEFAULTIOR: boolean;
  57940. CLEARCOAT_TEXTURE: boolean;
  57941. CLEARCOAT_TEXTUREDIRECTUV: number;
  57942. CLEARCOAT_BUMP: boolean;
  57943. CLEARCOAT_BUMPDIRECTUV: number;
  57944. CLEARCOAT_REMAP_F0: boolean;
  57945. CLEARCOAT_TINT: boolean;
  57946. CLEARCOAT_TINT_TEXTURE: boolean;
  57947. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  57948. /** @hidden */
  57949. _areTexturesDirty: boolean;
  57950. }
  57951. /**
  57952. * Define the code related to the clear coat parameters of the pbr material.
  57953. */
  57954. export class PBRClearCoatConfiguration {
  57955. /**
  57956. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57957. * The default fits with a polyurethane material.
  57958. */
  57959. private static readonly _DefaultIndexOfRefraction;
  57960. private _isEnabled;
  57961. /**
  57962. * Defines if the clear coat is enabled in the material.
  57963. */
  57964. isEnabled: boolean;
  57965. /**
  57966. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  57967. */
  57968. intensity: number;
  57969. /**
  57970. * Defines the clear coat layer roughness.
  57971. */
  57972. roughness: number;
  57973. private _indexOfRefraction;
  57974. /**
  57975. * Defines the index of refraction of the clear coat.
  57976. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  57977. * The default fits with a polyurethane material.
  57978. * Changing the default value is more performance intensive.
  57979. */
  57980. indexOfRefraction: number;
  57981. private _texture;
  57982. /**
  57983. * Stores the clear coat values in a texture.
  57984. */
  57985. texture: Nullable<BaseTexture>;
  57986. private _remapF0OnInterfaceChange;
  57987. /**
  57988. * Defines if the F0 value should be remapped to account for the interface change in the material.
  57989. */
  57990. remapF0OnInterfaceChange: boolean;
  57991. private _bumpTexture;
  57992. /**
  57993. * Define the clear coat specific bump texture.
  57994. */
  57995. bumpTexture: Nullable<BaseTexture>;
  57996. private _isTintEnabled;
  57997. /**
  57998. * Defines if the clear coat tint is enabled in the material.
  57999. */
  58000. isTintEnabled: boolean;
  58001. /**
  58002. * Defines the clear coat tint of the material.
  58003. * This is only use if tint is enabled
  58004. */
  58005. tintColor: Color3;
  58006. /**
  58007. * Defines the distance at which the tint color should be found in the
  58008. * clear coat media.
  58009. * This is only use if tint is enabled
  58010. */
  58011. tintColorAtDistance: number;
  58012. /**
  58013. * Defines the clear coat layer thickness.
  58014. * This is only use if tint is enabled
  58015. */
  58016. tintThickness: number;
  58017. private _tintTexture;
  58018. /**
  58019. * Stores the clear tint values in a texture.
  58020. * rgb is tint
  58021. * a is a thickness factor
  58022. */
  58023. tintTexture: Nullable<BaseTexture>;
  58024. /** @hidden */
  58025. private _internalMarkAllSubMeshesAsTexturesDirty;
  58026. /** @hidden */
  58027. _markAllSubMeshesAsTexturesDirty(): void;
  58028. /**
  58029. * Instantiate a new istance of clear coat configuration.
  58030. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58031. */
  58032. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58033. /**
  58034. * Gets wehter the submesh is ready to be used or not.
  58035. * @param defines the list of "defines" to update.
  58036. * @param scene defines the scene the material belongs to.
  58037. * @param engine defines the engine the material belongs to.
  58038. * @param disableBumpMap defines wether the material disables bump or not.
  58039. * @returns - boolean indicating that the submesh is ready or not.
  58040. */
  58041. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  58042. /**
  58043. * Checks to see if a texture is used in the material.
  58044. * @param defines the list of "defines" to update.
  58045. * @param scene defines the scene to the material belongs to.
  58046. */
  58047. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  58048. /**
  58049. * Binds the material data.
  58050. * @param uniformBuffer defines the Uniform buffer to fill in.
  58051. * @param scene defines the scene the material belongs to.
  58052. * @param engine defines the engine the material belongs to.
  58053. * @param disableBumpMap defines wether the material disables bump or not.
  58054. * @param isFrozen defines wether the material is frozen or not.
  58055. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  58056. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  58057. */
  58058. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  58059. /**
  58060. * Checks to see if a texture is used in the material.
  58061. * @param texture - Base texture to use.
  58062. * @returns - Boolean specifying if a texture is used in the material.
  58063. */
  58064. hasTexture(texture: BaseTexture): boolean;
  58065. /**
  58066. * Returns an array of the actively used textures.
  58067. * @param activeTextures Array of BaseTextures
  58068. */
  58069. getActiveTextures(activeTextures: BaseTexture[]): void;
  58070. /**
  58071. * Returns the animatable textures.
  58072. * @param animatables Array of animatable textures.
  58073. */
  58074. getAnimatables(animatables: IAnimatable[]): void;
  58075. /**
  58076. * Disposes the resources of the material.
  58077. * @param forceDisposeTextures - Forces the disposal of all textures.
  58078. */
  58079. dispose(forceDisposeTextures?: boolean): void;
  58080. /**
  58081. * Get the current class name of the texture useful for serialization or dynamic coding.
  58082. * @returns "PBRClearCoatConfiguration"
  58083. */
  58084. getClassName(): string;
  58085. /**
  58086. * Add fallbacks to the effect fallbacks list.
  58087. * @param defines defines the Base texture to use.
  58088. * @param fallbacks defines the current fallback list.
  58089. * @param currentRank defines the current fallback rank.
  58090. * @returns the new fallback rank.
  58091. */
  58092. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58093. /**
  58094. * Add the required uniforms to the current list.
  58095. * @param uniforms defines the current uniform list.
  58096. */
  58097. static AddUniforms(uniforms: string[]): void;
  58098. /**
  58099. * Add the required samplers to the current list.
  58100. * @param samplers defines the current sampler list.
  58101. */
  58102. static AddSamplers(samplers: string[]): void;
  58103. /**
  58104. * Add the required uniforms to the current buffer.
  58105. * @param uniformBuffer defines the current uniform buffer.
  58106. */
  58107. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58108. /**
  58109. * Makes a duplicate of the current configuration into another one.
  58110. * @param clearCoatConfiguration define the config where to copy the info
  58111. */
  58112. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  58113. /**
  58114. * Serializes this clear coat configuration.
  58115. * @returns - An object with the serialized config.
  58116. */
  58117. serialize(): any;
  58118. /**
  58119. * Parses a anisotropy Configuration from a serialized object.
  58120. * @param source - Serialized object.
  58121. * @param scene Defines the scene we are parsing for
  58122. * @param rootUrl Defines the rootUrl to load from
  58123. */
  58124. parse(source: any, scene: Scene, rootUrl: string): void;
  58125. }
  58126. }
  58127. declare module "babylonjs/Materials/PBR/pbrAnisotropicConfiguration" {
  58128. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58129. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  58130. import { Vector2 } from "babylonjs/Maths/math.vector";
  58131. import { Scene } from "babylonjs/scene";
  58132. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58133. import { Nullable } from "babylonjs/types";
  58134. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58135. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58136. /**
  58137. * @hidden
  58138. */
  58139. export interface IMaterialAnisotropicDefines {
  58140. ANISOTROPIC: boolean;
  58141. ANISOTROPIC_TEXTURE: boolean;
  58142. ANISOTROPIC_TEXTUREDIRECTUV: number;
  58143. MAINUV1: boolean;
  58144. _areTexturesDirty: boolean;
  58145. _needUVs: boolean;
  58146. }
  58147. /**
  58148. * Define the code related to the anisotropic parameters of the pbr material.
  58149. */
  58150. export class PBRAnisotropicConfiguration {
  58151. private _isEnabled;
  58152. /**
  58153. * Defines if the anisotropy is enabled in the material.
  58154. */
  58155. isEnabled: boolean;
  58156. /**
  58157. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  58158. */
  58159. intensity: number;
  58160. /**
  58161. * Defines if the effect is along the tangents, bitangents or in between.
  58162. * By default, the effect is "strectching" the highlights along the tangents.
  58163. */
  58164. direction: Vector2;
  58165. private _texture;
  58166. /**
  58167. * Stores the anisotropy values in a texture.
  58168. * rg is direction (like normal from -1 to 1)
  58169. * b is a intensity
  58170. */
  58171. texture: Nullable<BaseTexture>;
  58172. /** @hidden */
  58173. private _internalMarkAllSubMeshesAsTexturesDirty;
  58174. /** @hidden */
  58175. _markAllSubMeshesAsTexturesDirty(): void;
  58176. /**
  58177. * Instantiate a new istance of anisotropy configuration.
  58178. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58179. */
  58180. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58181. /**
  58182. * Specifies that the submesh is ready to be used.
  58183. * @param defines the list of "defines" to update.
  58184. * @param scene defines the scene the material belongs to.
  58185. * @returns - boolean indicating that the submesh is ready or not.
  58186. */
  58187. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  58188. /**
  58189. * Checks to see if a texture is used in the material.
  58190. * @param defines the list of "defines" to update.
  58191. * @param mesh the mesh we are preparing the defines for.
  58192. * @param scene defines the scene the material belongs to.
  58193. */
  58194. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  58195. /**
  58196. * Binds the material data.
  58197. * @param uniformBuffer defines the Uniform buffer to fill in.
  58198. * @param scene defines the scene the material belongs to.
  58199. * @param isFrozen defines wether the material is frozen or not.
  58200. */
  58201. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58202. /**
  58203. * Checks to see if a texture is used in the material.
  58204. * @param texture - Base texture to use.
  58205. * @returns - Boolean specifying if a texture is used in the material.
  58206. */
  58207. hasTexture(texture: BaseTexture): boolean;
  58208. /**
  58209. * Returns an array of the actively used textures.
  58210. * @param activeTextures Array of BaseTextures
  58211. */
  58212. getActiveTextures(activeTextures: BaseTexture[]): void;
  58213. /**
  58214. * Returns the animatable textures.
  58215. * @param animatables Array of animatable textures.
  58216. */
  58217. getAnimatables(animatables: IAnimatable[]): void;
  58218. /**
  58219. * Disposes the resources of the material.
  58220. * @param forceDisposeTextures - Forces the disposal of all textures.
  58221. */
  58222. dispose(forceDisposeTextures?: boolean): void;
  58223. /**
  58224. * Get the current class name of the texture useful for serialization or dynamic coding.
  58225. * @returns "PBRAnisotropicConfiguration"
  58226. */
  58227. getClassName(): string;
  58228. /**
  58229. * Add fallbacks to the effect fallbacks list.
  58230. * @param defines defines the Base texture to use.
  58231. * @param fallbacks defines the current fallback list.
  58232. * @param currentRank defines the current fallback rank.
  58233. * @returns the new fallback rank.
  58234. */
  58235. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58236. /**
  58237. * Add the required uniforms to the current list.
  58238. * @param uniforms defines the current uniform list.
  58239. */
  58240. static AddUniforms(uniforms: string[]): void;
  58241. /**
  58242. * Add the required uniforms to the current buffer.
  58243. * @param uniformBuffer defines the current uniform buffer.
  58244. */
  58245. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58246. /**
  58247. * Add the required samplers to the current list.
  58248. * @param samplers defines the current sampler list.
  58249. */
  58250. static AddSamplers(samplers: string[]): void;
  58251. /**
  58252. * Makes a duplicate of the current configuration into another one.
  58253. * @param anisotropicConfiguration define the config where to copy the info
  58254. */
  58255. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  58256. /**
  58257. * Serializes this anisotropy configuration.
  58258. * @returns - An object with the serialized config.
  58259. */
  58260. serialize(): any;
  58261. /**
  58262. * Parses a anisotropy Configuration from a serialized object.
  58263. * @param source - Serialized object.
  58264. * @param scene Defines the scene we are parsing for
  58265. * @param rootUrl Defines the rootUrl to load from
  58266. */
  58267. parse(source: any, scene: Scene, rootUrl: string): void;
  58268. }
  58269. }
  58270. declare module "babylonjs/Materials/PBR/pbrBRDFConfiguration" {
  58271. import { Scene } from "babylonjs/scene";
  58272. /**
  58273. * @hidden
  58274. */
  58275. export interface IMaterialBRDFDefines {
  58276. BRDF_V_HEIGHT_CORRELATED: boolean;
  58277. MS_BRDF_ENERGY_CONSERVATION: boolean;
  58278. SPHERICAL_HARMONICS: boolean;
  58279. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  58280. /** @hidden */
  58281. _areMiscDirty: boolean;
  58282. }
  58283. /**
  58284. * Define the code related to the BRDF parameters of the pbr material.
  58285. */
  58286. export class PBRBRDFConfiguration {
  58287. /**
  58288. * Default value used for the energy conservation.
  58289. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58290. */
  58291. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  58292. /**
  58293. * Default value used for the Smith Visibility Height Correlated mode.
  58294. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  58295. */
  58296. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  58297. /**
  58298. * Default value used for the IBL diffuse part.
  58299. * This can help switching back to the polynomials mode globally which is a tiny bit
  58300. * less GPU intensive at the drawback of a lower quality.
  58301. */
  58302. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  58303. /**
  58304. * Default value used for activating energy conservation for the specular workflow.
  58305. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58306. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58307. */
  58308. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  58309. private _useEnergyConservation;
  58310. /**
  58311. * Defines if the material uses energy conservation.
  58312. */
  58313. useEnergyConservation: boolean;
  58314. private _useSmithVisibilityHeightCorrelated;
  58315. /**
  58316. * LEGACY Mode set to false
  58317. * Defines if the material uses height smith correlated visibility term.
  58318. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  58319. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  58320. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  58321. * Not relying on height correlated will also disable energy conservation.
  58322. */
  58323. useSmithVisibilityHeightCorrelated: boolean;
  58324. private _useSphericalHarmonics;
  58325. /**
  58326. * LEGACY Mode set to false
  58327. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  58328. * diffuse part of the IBL.
  58329. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  58330. * to the ground truth.
  58331. */
  58332. useSphericalHarmonics: boolean;
  58333. private _useSpecularGlossinessInputEnergyConservation;
  58334. /**
  58335. * Defines if the material uses energy conservation, when the specular workflow is active.
  58336. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  58337. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  58338. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  58339. */
  58340. useSpecularGlossinessInputEnergyConservation: boolean;
  58341. /** @hidden */
  58342. private _internalMarkAllSubMeshesAsMiscDirty;
  58343. /** @hidden */
  58344. _markAllSubMeshesAsMiscDirty(): void;
  58345. /**
  58346. * Instantiate a new istance of clear coat configuration.
  58347. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  58348. */
  58349. constructor(markAllSubMeshesAsMiscDirty: () => void);
  58350. /**
  58351. * Checks to see if a texture is used in the material.
  58352. * @param defines the list of "defines" to update.
  58353. */
  58354. prepareDefines(defines: IMaterialBRDFDefines): void;
  58355. /**
  58356. * Get the current class name of the texture useful for serialization or dynamic coding.
  58357. * @returns "PBRClearCoatConfiguration"
  58358. */
  58359. getClassName(): string;
  58360. /**
  58361. * Makes a duplicate of the current configuration into another one.
  58362. * @param brdfConfiguration define the config where to copy the info
  58363. */
  58364. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  58365. /**
  58366. * Serializes this BRDF configuration.
  58367. * @returns - An object with the serialized config.
  58368. */
  58369. serialize(): any;
  58370. /**
  58371. * Parses a anisotropy Configuration from a serialized object.
  58372. * @param source - Serialized object.
  58373. * @param scene Defines the scene we are parsing for
  58374. * @param rootUrl Defines the rootUrl to load from
  58375. */
  58376. parse(source: any, scene: Scene, rootUrl: string): void;
  58377. }
  58378. }
  58379. declare module "babylonjs/Materials/PBR/pbrSheenConfiguration" {
  58380. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58381. import { Color3 } from "babylonjs/Maths/math.color";
  58382. import { Scene } from "babylonjs/scene";
  58383. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58384. import { Nullable } from "babylonjs/types";
  58385. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58386. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58387. /**
  58388. * @hidden
  58389. */
  58390. export interface IMaterialSheenDefines {
  58391. SHEEN: boolean;
  58392. SHEEN_TEXTURE: boolean;
  58393. SHEEN_TEXTUREDIRECTUV: number;
  58394. SHEEN_LINKWITHALBEDO: boolean;
  58395. SHEEN_ROUGHNESS: boolean;
  58396. SHEEN_ALBEDOSCALING: boolean;
  58397. /** @hidden */
  58398. _areTexturesDirty: boolean;
  58399. }
  58400. /**
  58401. * Define the code related to the Sheen parameters of the pbr material.
  58402. */
  58403. export class PBRSheenConfiguration {
  58404. private _isEnabled;
  58405. /**
  58406. * Defines if the material uses sheen.
  58407. */
  58408. isEnabled: boolean;
  58409. private _linkSheenWithAlbedo;
  58410. /**
  58411. * Defines if the sheen is linked to the sheen color.
  58412. */
  58413. linkSheenWithAlbedo: boolean;
  58414. /**
  58415. * Defines the sheen intensity.
  58416. */
  58417. intensity: number;
  58418. /**
  58419. * Defines the sheen color.
  58420. */
  58421. color: Color3;
  58422. private _texture;
  58423. /**
  58424. * Stores the sheen tint values in a texture.
  58425. * rgb is tint
  58426. * a is a intensity or roughness if roughness has been defined
  58427. */
  58428. texture: Nullable<BaseTexture>;
  58429. private _roughness;
  58430. /**
  58431. * Defines the sheen roughness.
  58432. * It is not taken into account if linkSheenWithAlbedo is true.
  58433. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  58434. */
  58435. roughness: Nullable<number>;
  58436. private _albedoScaling;
  58437. /**
  58438. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  58439. * It allows the strength of the sheen effect to not depend on the base color of the material,
  58440. * making it easier to setup and tweak the effect
  58441. */
  58442. albedoScaling: boolean;
  58443. /** @hidden */
  58444. private _internalMarkAllSubMeshesAsTexturesDirty;
  58445. /** @hidden */
  58446. _markAllSubMeshesAsTexturesDirty(): void;
  58447. /**
  58448. * Instantiate a new istance of clear coat configuration.
  58449. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58450. */
  58451. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  58452. /**
  58453. * Specifies that the submesh is ready to be used.
  58454. * @param defines the list of "defines" to update.
  58455. * @param scene defines the scene the material belongs to.
  58456. * @returns - boolean indicating that the submesh is ready or not.
  58457. */
  58458. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  58459. /**
  58460. * Checks to see if a texture is used in the material.
  58461. * @param defines the list of "defines" to update.
  58462. * @param scene defines the scene the material belongs to.
  58463. */
  58464. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  58465. /**
  58466. * Binds the material data.
  58467. * @param uniformBuffer defines the Uniform buffer to fill in.
  58468. * @param scene defines the scene the material belongs to.
  58469. * @param isFrozen defines wether the material is frozen or not.
  58470. */
  58471. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  58472. /**
  58473. * Checks to see if a texture is used in the material.
  58474. * @param texture - Base texture to use.
  58475. * @returns - Boolean specifying if a texture is used in the material.
  58476. */
  58477. hasTexture(texture: BaseTexture): boolean;
  58478. /**
  58479. * Returns an array of the actively used textures.
  58480. * @param activeTextures Array of BaseTextures
  58481. */
  58482. getActiveTextures(activeTextures: BaseTexture[]): void;
  58483. /**
  58484. * Returns the animatable textures.
  58485. * @param animatables Array of animatable textures.
  58486. */
  58487. getAnimatables(animatables: IAnimatable[]): void;
  58488. /**
  58489. * Disposes the resources of the material.
  58490. * @param forceDisposeTextures - Forces the disposal of all textures.
  58491. */
  58492. dispose(forceDisposeTextures?: boolean): void;
  58493. /**
  58494. * Get the current class name of the texture useful for serialization or dynamic coding.
  58495. * @returns "PBRSheenConfiguration"
  58496. */
  58497. getClassName(): string;
  58498. /**
  58499. * Add fallbacks to the effect fallbacks list.
  58500. * @param defines defines the Base texture to use.
  58501. * @param fallbacks defines the current fallback list.
  58502. * @param currentRank defines the current fallback rank.
  58503. * @returns the new fallback rank.
  58504. */
  58505. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58506. /**
  58507. * Add the required uniforms to the current list.
  58508. * @param uniforms defines the current uniform list.
  58509. */
  58510. static AddUniforms(uniforms: string[]): void;
  58511. /**
  58512. * Add the required uniforms to the current buffer.
  58513. * @param uniformBuffer defines the current uniform buffer.
  58514. */
  58515. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58516. /**
  58517. * Add the required samplers to the current list.
  58518. * @param samplers defines the current sampler list.
  58519. */
  58520. static AddSamplers(samplers: string[]): void;
  58521. /**
  58522. * Makes a duplicate of the current configuration into another one.
  58523. * @param sheenConfiguration define the config where to copy the info
  58524. */
  58525. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  58526. /**
  58527. * Serializes this BRDF configuration.
  58528. * @returns - An object with the serialized config.
  58529. */
  58530. serialize(): any;
  58531. /**
  58532. * Parses a anisotropy Configuration from a serialized object.
  58533. * @param source - Serialized object.
  58534. * @param scene Defines the scene we are parsing for
  58535. * @param rootUrl Defines the rootUrl to load from
  58536. */
  58537. parse(source: any, scene: Scene, rootUrl: string): void;
  58538. }
  58539. }
  58540. declare module "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration" {
  58541. import { Nullable } from "babylonjs/types";
  58542. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  58543. import { Color3 } from "babylonjs/Maths/math.color";
  58544. import { SmartArray } from "babylonjs/Misc/smartArray";
  58545. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  58546. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  58547. import { Effect } from "babylonjs/Materials/effect";
  58548. import { UniformBuffer } from "babylonjs/Materials/uniformBuffer";
  58549. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  58550. import { Engine } from "babylonjs/Engines/engine";
  58551. import { Scene } from "babylonjs/scene";
  58552. /**
  58553. * @hidden
  58554. */
  58555. export interface IMaterialSubSurfaceDefines {
  58556. SUBSURFACE: boolean;
  58557. SS_REFRACTION: boolean;
  58558. SS_TRANSLUCENCY: boolean;
  58559. SS_SCATTERING: boolean;
  58560. SS_THICKNESSANDMASK_TEXTURE: boolean;
  58561. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  58562. SS_REFRACTIONMAP_3D: boolean;
  58563. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  58564. SS_LODINREFRACTIONALPHA: boolean;
  58565. SS_GAMMAREFRACTION: boolean;
  58566. SS_RGBDREFRACTION: boolean;
  58567. SS_LINEARSPECULARREFRACTION: boolean;
  58568. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  58569. SS_ALBEDOFORREFRACTIONTINT: boolean;
  58570. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  58571. /** @hidden */
  58572. _areTexturesDirty: boolean;
  58573. }
  58574. /**
  58575. * Define the code related to the sub surface parameters of the pbr material.
  58576. */
  58577. export class PBRSubSurfaceConfiguration {
  58578. private _isRefractionEnabled;
  58579. /**
  58580. * Defines if the refraction is enabled in the material.
  58581. */
  58582. isRefractionEnabled: boolean;
  58583. private _isTranslucencyEnabled;
  58584. /**
  58585. * Defines if the translucency is enabled in the material.
  58586. */
  58587. isTranslucencyEnabled: boolean;
  58588. private _isScatteringEnabled;
  58589. /**
  58590. * Defines if the sub surface scattering is enabled in the material.
  58591. */
  58592. isScatteringEnabled: boolean;
  58593. private _scatteringDiffusionProfileIndex;
  58594. /**
  58595. * Diffusion profile for subsurface scattering.
  58596. * Useful for better scattering in the skins or foliages.
  58597. */
  58598. get scatteringDiffusionProfile(): Nullable<Color3>;
  58599. set scatteringDiffusionProfile(c: Nullable<Color3>);
  58600. /**
  58601. * Defines the refraction intensity of the material.
  58602. * The refraction when enabled replaces the Diffuse part of the material.
  58603. * The intensity helps transitionning between diffuse and refraction.
  58604. */
  58605. refractionIntensity: number;
  58606. /**
  58607. * Defines the translucency intensity of the material.
  58608. * When translucency has been enabled, this defines how much of the "translucency"
  58609. * is addded to the diffuse part of the material.
  58610. */
  58611. translucencyIntensity: number;
  58612. /**
  58613. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  58614. */
  58615. useAlbedoToTintRefraction: boolean;
  58616. private _thicknessTexture;
  58617. /**
  58618. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  58619. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  58620. * 0 would mean minimumThickness
  58621. * 1 would mean maximumThickness
  58622. * The other channels might be use as a mask to vary the different effects intensity.
  58623. */
  58624. thicknessTexture: Nullable<BaseTexture>;
  58625. private _refractionTexture;
  58626. /**
  58627. * Defines the texture to use for refraction.
  58628. */
  58629. refractionTexture: Nullable<BaseTexture>;
  58630. private _indexOfRefraction;
  58631. /**
  58632. * Index of refraction of the material base layer.
  58633. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58634. *
  58635. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  58636. *
  58637. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  58638. */
  58639. indexOfRefraction: number;
  58640. private _volumeIndexOfRefraction;
  58641. /**
  58642. * Index of refraction of the material's volume.
  58643. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  58644. *
  58645. * This ONLY impacts refraction. If not provided or given a non-valid value,
  58646. * the volume will use the same IOR as the surface.
  58647. */
  58648. get volumeIndexOfRefraction(): number;
  58649. set volumeIndexOfRefraction(value: number);
  58650. private _invertRefractionY;
  58651. /**
  58652. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  58653. */
  58654. invertRefractionY: boolean;
  58655. private _linkRefractionWithTransparency;
  58656. /**
  58657. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  58658. * Materials half opaque for instance using refraction could benefit from this control.
  58659. */
  58660. linkRefractionWithTransparency: boolean;
  58661. /**
  58662. * Defines the minimum thickness stored in the thickness map.
  58663. * If no thickness map is defined, this value will be used to simulate thickness.
  58664. */
  58665. minimumThickness: number;
  58666. /**
  58667. * Defines the maximum thickness stored in the thickness map.
  58668. */
  58669. maximumThickness: number;
  58670. /**
  58671. * Defines the volume tint of the material.
  58672. * This is used for both translucency and scattering.
  58673. */
  58674. tintColor: Color3;
  58675. /**
  58676. * Defines the distance at which the tint color should be found in the media.
  58677. * This is used for refraction only.
  58678. */
  58679. tintColorAtDistance: number;
  58680. /**
  58681. * Defines how far each channel transmit through the media.
  58682. * It is defined as a color to simplify it selection.
  58683. */
  58684. diffusionDistance: Color3;
  58685. private _useMaskFromThicknessTexture;
  58686. /**
  58687. * Stores the intensity of the different subsurface effects in the thickness texture.
  58688. * * the green channel is the translucency intensity.
  58689. * * the blue channel is the scattering intensity.
  58690. * * the alpha channel is the refraction intensity.
  58691. */
  58692. useMaskFromThicknessTexture: boolean;
  58693. private _scene;
  58694. /** @hidden */
  58695. private _internalMarkAllSubMeshesAsTexturesDirty;
  58696. private _internalMarkScenePrePassDirty;
  58697. /** @hidden */
  58698. _markAllSubMeshesAsTexturesDirty(): void;
  58699. /** @hidden */
  58700. _markScenePrePassDirty(): void;
  58701. /**
  58702. * Instantiate a new istance of sub surface configuration.
  58703. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  58704. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  58705. * @param scene The scene
  58706. */
  58707. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  58708. /**
  58709. * Gets wehter the submesh is ready to be used or not.
  58710. * @param defines the list of "defines" to update.
  58711. * @param scene defines the scene the material belongs to.
  58712. * @returns - boolean indicating that the submesh is ready or not.
  58713. */
  58714. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  58715. /**
  58716. * Checks to see if a texture is used in the material.
  58717. * @param defines the list of "defines" to update.
  58718. * @param scene defines the scene to the material belongs to.
  58719. */
  58720. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  58721. /**
  58722. * Binds the material data.
  58723. * @param uniformBuffer defines the Uniform buffer to fill in.
  58724. * @param scene defines the scene the material belongs to.
  58725. * @param engine defines the engine the material belongs to.
  58726. * @param isFrozen defines whether the material is frozen or not.
  58727. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  58728. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  58729. */
  58730. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  58731. /**
  58732. * Unbinds the material from the mesh.
  58733. * @param activeEffect defines the effect that should be unbound from.
  58734. * @returns true if unbound, otherwise false
  58735. */
  58736. unbind(activeEffect: Effect): boolean;
  58737. /**
  58738. * Returns the texture used for refraction or null if none is used.
  58739. * @param scene defines the scene the material belongs to.
  58740. * @returns - Refraction texture if present. If no refraction texture and refraction
  58741. * is linked with transparency, returns environment texture. Otherwise, returns null.
  58742. */
  58743. private _getRefractionTexture;
  58744. /**
  58745. * Returns true if alpha blending should be disabled.
  58746. */
  58747. get disableAlphaBlending(): boolean;
  58748. /**
  58749. * Fills the list of render target textures.
  58750. * @param renderTargets the list of render targets to update
  58751. */
  58752. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  58753. /**
  58754. * Checks to see if a texture is used in the material.
  58755. * @param texture - Base texture to use.
  58756. * @returns - Boolean specifying if a texture is used in the material.
  58757. */
  58758. hasTexture(texture: BaseTexture): boolean;
  58759. /**
  58760. * Gets a boolean indicating that current material needs to register RTT
  58761. * @returns true if this uses a render target otherwise false.
  58762. */
  58763. hasRenderTargetTextures(): boolean;
  58764. /**
  58765. * Returns an array of the actively used textures.
  58766. * @param activeTextures Array of BaseTextures
  58767. */
  58768. getActiveTextures(activeTextures: BaseTexture[]): void;
  58769. /**
  58770. * Returns the animatable textures.
  58771. * @param animatables Array of animatable textures.
  58772. */
  58773. getAnimatables(animatables: IAnimatable[]): void;
  58774. /**
  58775. * Disposes the resources of the material.
  58776. * @param forceDisposeTextures - Forces the disposal of all textures.
  58777. */
  58778. dispose(forceDisposeTextures?: boolean): void;
  58779. /**
  58780. * Get the current class name of the texture useful for serialization or dynamic coding.
  58781. * @returns "PBRSubSurfaceConfiguration"
  58782. */
  58783. getClassName(): string;
  58784. /**
  58785. * Add fallbacks to the effect fallbacks list.
  58786. * @param defines defines the Base texture to use.
  58787. * @param fallbacks defines the current fallback list.
  58788. * @param currentRank defines the current fallback rank.
  58789. * @returns the new fallback rank.
  58790. */
  58791. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  58792. /**
  58793. * Add the required uniforms to the current list.
  58794. * @param uniforms defines the current uniform list.
  58795. */
  58796. static AddUniforms(uniforms: string[]): void;
  58797. /**
  58798. * Add the required samplers to the current list.
  58799. * @param samplers defines the current sampler list.
  58800. */
  58801. static AddSamplers(samplers: string[]): void;
  58802. /**
  58803. * Add the required uniforms to the current buffer.
  58804. * @param uniformBuffer defines the current uniform buffer.
  58805. */
  58806. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  58807. /**
  58808. * Makes a duplicate of the current configuration into another one.
  58809. * @param configuration define the config where to copy the info
  58810. */
  58811. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  58812. /**
  58813. * Serializes this Sub Surface configuration.
  58814. * @returns - An object with the serialized config.
  58815. */
  58816. serialize(): any;
  58817. /**
  58818. * Parses a anisotropy Configuration from a serialized object.
  58819. * @param source - Serialized object.
  58820. * @param scene Defines the scene we are parsing for
  58821. * @param rootUrl Defines the rootUrl to load from
  58822. */
  58823. parse(source: any, scene: Scene, rootUrl: string): void;
  58824. }
  58825. }
  58826. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration" {
  58827. /** @hidden */
  58828. export var pbrFragmentDeclaration: {
  58829. name: string;
  58830. shader: string;
  58831. };
  58832. }
  58833. declare module "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration" {
  58834. /** @hidden */
  58835. export var pbrUboDeclaration: {
  58836. name: string;
  58837. shader: string;
  58838. };
  58839. }
  58840. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration" {
  58841. /** @hidden */
  58842. export var pbrFragmentExtraDeclaration: {
  58843. name: string;
  58844. shader: string;
  58845. };
  58846. }
  58847. declare module "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration" {
  58848. /** @hidden */
  58849. export var pbrFragmentSamplersDeclaration: {
  58850. name: string;
  58851. shader: string;
  58852. };
  58853. }
  58854. declare module "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions" {
  58855. /** @hidden */
  58856. export var subSurfaceScatteringFunctions: {
  58857. name: string;
  58858. shader: string;
  58859. };
  58860. }
  58861. declare module "babylonjs/Shaders/ShadersInclude/importanceSampling" {
  58862. /** @hidden */
  58863. export var importanceSampling: {
  58864. name: string;
  58865. shader: string;
  58866. };
  58867. }
  58868. declare module "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions" {
  58869. /** @hidden */
  58870. export var pbrHelperFunctions: {
  58871. name: string;
  58872. shader: string;
  58873. };
  58874. }
  58875. declare module "babylonjs/Shaders/ShadersInclude/harmonicsFunctions" {
  58876. /** @hidden */
  58877. export var harmonicsFunctions: {
  58878. name: string;
  58879. shader: string;
  58880. };
  58881. }
  58882. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions" {
  58883. /** @hidden */
  58884. export var pbrDirectLightingSetupFunctions: {
  58885. name: string;
  58886. shader: string;
  58887. };
  58888. }
  58889. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions" {
  58890. /** @hidden */
  58891. export var pbrDirectLightingFalloffFunctions: {
  58892. name: string;
  58893. shader: string;
  58894. };
  58895. }
  58896. declare module "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions" {
  58897. /** @hidden */
  58898. export var pbrBRDFFunctions: {
  58899. name: string;
  58900. shader: string;
  58901. };
  58902. }
  58903. declare module "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions" {
  58904. /** @hidden */
  58905. export var hdrFilteringFunctions: {
  58906. name: string;
  58907. shader: string;
  58908. };
  58909. }
  58910. declare module "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions" {
  58911. /** @hidden */
  58912. export var pbrDirectLightingFunctions: {
  58913. name: string;
  58914. shader: string;
  58915. };
  58916. }
  58917. declare module "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions" {
  58918. /** @hidden */
  58919. export var pbrIBLFunctions: {
  58920. name: string;
  58921. shader: string;
  58922. };
  58923. }
  58924. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity" {
  58925. /** @hidden */
  58926. export var pbrBlockAlbedoOpacity: {
  58927. name: string;
  58928. shader: string;
  58929. };
  58930. }
  58931. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity" {
  58932. /** @hidden */
  58933. export var pbrBlockReflectivity: {
  58934. name: string;
  58935. shader: string;
  58936. };
  58937. }
  58938. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion" {
  58939. /** @hidden */
  58940. export var pbrBlockAmbientOcclusion: {
  58941. name: string;
  58942. shader: string;
  58943. };
  58944. }
  58945. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel" {
  58946. /** @hidden */
  58947. export var pbrBlockAlphaFresnel: {
  58948. name: string;
  58949. shader: string;
  58950. };
  58951. }
  58952. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic" {
  58953. /** @hidden */
  58954. export var pbrBlockAnisotropic: {
  58955. name: string;
  58956. shader: string;
  58957. };
  58958. }
  58959. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflection" {
  58960. /** @hidden */
  58961. export var pbrBlockReflection: {
  58962. name: string;
  58963. shader: string;
  58964. };
  58965. }
  58966. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSheen" {
  58967. /** @hidden */
  58968. export var pbrBlockSheen: {
  58969. name: string;
  58970. shader: string;
  58971. };
  58972. }
  58973. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat" {
  58974. /** @hidden */
  58975. export var pbrBlockClearcoat: {
  58976. name: string;
  58977. shader: string;
  58978. };
  58979. }
  58980. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface" {
  58981. /** @hidden */
  58982. export var pbrBlockSubSurface: {
  58983. name: string;
  58984. shader: string;
  58985. };
  58986. }
  58987. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric" {
  58988. /** @hidden */
  58989. export var pbrBlockNormalGeometric: {
  58990. name: string;
  58991. shader: string;
  58992. };
  58993. }
  58994. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal" {
  58995. /** @hidden */
  58996. export var pbrBlockNormalFinal: {
  58997. name: string;
  58998. shader: string;
  58999. };
  59000. }
  59001. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit" {
  59002. /** @hidden */
  59003. export var pbrBlockLightmapInit: {
  59004. name: string;
  59005. shader: string;
  59006. };
  59007. }
  59008. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo" {
  59009. /** @hidden */
  59010. export var pbrBlockGeometryInfo: {
  59011. name: string;
  59012. shader: string;
  59013. };
  59014. }
  59015. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0" {
  59016. /** @hidden */
  59017. export var pbrBlockReflectance0: {
  59018. name: string;
  59019. shader: string;
  59020. };
  59021. }
  59022. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance" {
  59023. /** @hidden */
  59024. export var pbrBlockReflectance: {
  59025. name: string;
  59026. shader: string;
  59027. };
  59028. }
  59029. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting" {
  59030. /** @hidden */
  59031. export var pbrBlockDirectLighting: {
  59032. name: string;
  59033. shader: string;
  59034. };
  59035. }
  59036. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents" {
  59037. /** @hidden */
  59038. export var pbrBlockFinalLitComponents: {
  59039. name: string;
  59040. shader: string;
  59041. };
  59042. }
  59043. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents" {
  59044. /** @hidden */
  59045. export var pbrBlockFinalUnlitComponents: {
  59046. name: string;
  59047. shader: string;
  59048. };
  59049. }
  59050. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition" {
  59051. /** @hidden */
  59052. export var pbrBlockFinalColorComposition: {
  59053. name: string;
  59054. shader: string;
  59055. };
  59056. }
  59057. declare module "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing" {
  59058. /** @hidden */
  59059. export var pbrBlockImageProcessing: {
  59060. name: string;
  59061. shader: string;
  59062. };
  59063. }
  59064. declare module "babylonjs/Shaders/ShadersInclude/pbrDebug" {
  59065. /** @hidden */
  59066. export var pbrDebug: {
  59067. name: string;
  59068. shader: string;
  59069. };
  59070. }
  59071. declare module "babylonjs/Shaders/pbr.fragment" {
  59072. import "babylonjs/Shaders/ShadersInclude/prePassDeclaration";
  59073. import "babylonjs/Shaders/ShadersInclude/pbrFragmentDeclaration";
  59074. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59075. import "babylonjs/Shaders/ShadersInclude/pbrFragmentExtraDeclaration";
  59076. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59077. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59078. import "babylonjs/Shaders/ShadersInclude/pbrFragmentSamplersDeclaration";
  59079. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  59080. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration";
  59081. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59082. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  59083. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59084. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  59085. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  59086. import "babylonjs/Shaders/ShadersInclude/pbrHelperFunctions";
  59087. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  59088. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  59089. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59090. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingSetupFunctions";
  59091. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFalloffFunctions";
  59092. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  59093. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  59094. import "babylonjs/Shaders/ShadersInclude/pbrDirectLightingFunctions";
  59095. import "babylonjs/Shaders/ShadersInclude/pbrIBLFunctions";
  59096. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  59097. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  59098. import "babylonjs/Shaders/ShadersInclude/reflectionFunction";
  59099. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlbedoOpacity";
  59100. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectivity";
  59101. import "babylonjs/Shaders/ShadersInclude/pbrBlockAmbientOcclusion";
  59102. import "babylonjs/Shaders/ShadersInclude/pbrBlockAlphaFresnel";
  59103. import "babylonjs/Shaders/ShadersInclude/pbrBlockAnisotropic";
  59104. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflection";
  59105. import "babylonjs/Shaders/ShadersInclude/pbrBlockSheen";
  59106. import "babylonjs/Shaders/ShadersInclude/pbrBlockClearcoat";
  59107. import "babylonjs/Shaders/ShadersInclude/pbrBlockSubSurface";
  59108. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  59109. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalGeometric";
  59110. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  59111. import "babylonjs/Shaders/ShadersInclude/pbrBlockNormalFinal";
  59112. import "babylonjs/Shaders/ShadersInclude/depthPrePass";
  59113. import "babylonjs/Shaders/ShadersInclude/pbrBlockLightmapInit";
  59114. import "babylonjs/Shaders/ShadersInclude/pbrBlockGeometryInfo";
  59115. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance0";
  59116. import "babylonjs/Shaders/ShadersInclude/pbrBlockReflectance";
  59117. import "babylonjs/Shaders/ShadersInclude/pbrBlockDirectLighting";
  59118. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  59119. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalLitComponents";
  59120. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalUnlitComponents";
  59121. import "babylonjs/Shaders/ShadersInclude/pbrBlockFinalColorComposition";
  59122. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  59123. import "babylonjs/Shaders/ShadersInclude/fogFragment";
  59124. import "babylonjs/Shaders/ShadersInclude/pbrBlockImageProcessing";
  59125. import "babylonjs/Shaders/ShadersInclude/pbrDebug";
  59126. /** @hidden */
  59127. export var pbrPixelShader: {
  59128. name: string;
  59129. shader: string;
  59130. };
  59131. }
  59132. declare module "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration" {
  59133. /** @hidden */
  59134. export var pbrVertexDeclaration: {
  59135. name: string;
  59136. shader: string;
  59137. };
  59138. }
  59139. declare module "babylonjs/Shaders/pbr.vertex" {
  59140. import "babylonjs/Shaders/ShadersInclude/pbrVertexDeclaration";
  59141. import "babylonjs/Shaders/ShadersInclude/pbrUboDeclaration";
  59142. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  59143. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  59144. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  59145. import "babylonjs/Shaders/ShadersInclude/prePassVertexDeclaration";
  59146. import "babylonjs/Shaders/ShadersInclude/harmonicsFunctions";
  59147. import "babylonjs/Shaders/ShadersInclude/bumpVertexDeclaration";
  59148. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration";
  59149. import "babylonjs/Shaders/ShadersInclude/fogVertexDeclaration";
  59150. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  59151. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  59152. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  59153. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  59154. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  59155. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  59156. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  59157. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  59158. import "babylonjs/Shaders/ShadersInclude/prePassVertex";
  59159. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  59160. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  59161. import "babylonjs/Shaders/ShadersInclude/fogVertex";
  59162. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  59163. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  59164. /** @hidden */
  59165. export var pbrVertexShader: {
  59166. name: string;
  59167. shader: string;
  59168. };
  59169. }
  59170. declare module "babylonjs/Materials/PBR/pbrBaseMaterial" {
  59171. import { Nullable } from "babylonjs/types";
  59172. import { Scene } from "babylonjs/scene";
  59173. import { Matrix } from "babylonjs/Maths/math.vector";
  59174. import { SubMesh } from "babylonjs/Meshes/subMesh";
  59175. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  59176. import { Mesh } from "babylonjs/Meshes/mesh";
  59177. import { IMaterialClearCoatDefines, PBRClearCoatConfiguration } from "babylonjs/Materials/PBR/pbrClearCoatConfiguration";
  59178. import { IMaterialAnisotropicDefines, PBRAnisotropicConfiguration } from "babylonjs/Materials/PBR/pbrAnisotropicConfiguration";
  59179. import { IMaterialBRDFDefines, PBRBRDFConfiguration } from "babylonjs/Materials/PBR/pbrBRDFConfiguration";
  59180. import { IMaterialSheenDefines, PBRSheenConfiguration } from "babylonjs/Materials/PBR/pbrSheenConfiguration";
  59181. import { IMaterialSubSurfaceDefines, PBRSubSurfaceConfiguration } from "babylonjs/Materials/PBR/pbrSubSurfaceConfiguration";
  59182. import { PrePassConfiguration } from "babylonjs/Materials/prePassConfiguration";
  59183. import { Color3 } from "babylonjs/Maths/math.color";
  59184. import { ImageProcessingConfiguration, IImageProcessingConfigurationDefines } from "babylonjs/Materials/imageProcessingConfiguration";
  59185. import { Material, IMaterialCompilationOptions } from "babylonjs/Materials/material";
  59186. import { MaterialDefines } from "babylonjs/Materials/materialDefines";
  59187. import { PushMaterial } from "babylonjs/Materials/pushMaterial";
  59188. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59189. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  59190. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  59191. import "babylonjs/Shaders/pbr.fragment";
  59192. import "babylonjs/Shaders/pbr.vertex";
  59193. import { IMaterialDetailMapDefines, DetailMapConfiguration } from "babylonjs/Materials/material.detailMapConfiguration";
  59194. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  59195. /**
  59196. * Manages the defines for the PBR Material.
  59197. * @hidden
  59198. */
  59199. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  59200. PBR: boolean;
  59201. NUM_SAMPLES: string;
  59202. REALTIME_FILTERING: boolean;
  59203. MAINUV1: boolean;
  59204. MAINUV2: boolean;
  59205. UV1: boolean;
  59206. UV2: boolean;
  59207. ALBEDO: boolean;
  59208. GAMMAALBEDO: boolean;
  59209. ALBEDODIRECTUV: number;
  59210. VERTEXCOLOR: boolean;
  59211. DETAIL: boolean;
  59212. DETAILDIRECTUV: number;
  59213. DETAIL_NORMALBLENDMETHOD: number;
  59214. AMBIENT: boolean;
  59215. AMBIENTDIRECTUV: number;
  59216. AMBIENTINGRAYSCALE: boolean;
  59217. OPACITY: boolean;
  59218. VERTEXALPHA: boolean;
  59219. OPACITYDIRECTUV: number;
  59220. OPACITYRGB: boolean;
  59221. ALPHATEST: boolean;
  59222. DEPTHPREPASS: boolean;
  59223. ALPHABLEND: boolean;
  59224. ALPHAFROMALBEDO: boolean;
  59225. ALPHATESTVALUE: string;
  59226. SPECULAROVERALPHA: boolean;
  59227. RADIANCEOVERALPHA: boolean;
  59228. ALPHAFRESNEL: boolean;
  59229. LINEARALPHAFRESNEL: boolean;
  59230. PREMULTIPLYALPHA: boolean;
  59231. EMISSIVE: boolean;
  59232. EMISSIVEDIRECTUV: number;
  59233. REFLECTIVITY: boolean;
  59234. REFLECTIVITYDIRECTUV: number;
  59235. SPECULARTERM: boolean;
  59236. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  59237. MICROSURFACEAUTOMATIC: boolean;
  59238. LODBASEDMICROSFURACE: boolean;
  59239. MICROSURFACEMAP: boolean;
  59240. MICROSURFACEMAPDIRECTUV: number;
  59241. METALLICWORKFLOW: boolean;
  59242. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  59243. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  59244. METALLNESSSTOREINMETALMAPBLUE: boolean;
  59245. AOSTOREINMETALMAPRED: boolean;
  59246. METALLIC_REFLECTANCE: boolean;
  59247. METALLIC_REFLECTANCEDIRECTUV: number;
  59248. ENVIRONMENTBRDF: boolean;
  59249. ENVIRONMENTBRDF_RGBD: boolean;
  59250. NORMAL: boolean;
  59251. TANGENT: boolean;
  59252. BUMP: boolean;
  59253. BUMPDIRECTUV: number;
  59254. OBJECTSPACE_NORMALMAP: boolean;
  59255. PARALLAX: boolean;
  59256. PARALLAXOCCLUSION: boolean;
  59257. NORMALXYSCALE: boolean;
  59258. LIGHTMAP: boolean;
  59259. LIGHTMAPDIRECTUV: number;
  59260. USELIGHTMAPASSHADOWMAP: boolean;
  59261. GAMMALIGHTMAP: boolean;
  59262. RGBDLIGHTMAP: boolean;
  59263. REFLECTION: boolean;
  59264. REFLECTIONMAP_3D: boolean;
  59265. REFLECTIONMAP_SPHERICAL: boolean;
  59266. REFLECTIONMAP_PLANAR: boolean;
  59267. REFLECTIONMAP_CUBIC: boolean;
  59268. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  59269. REFLECTIONMAP_PROJECTION: boolean;
  59270. REFLECTIONMAP_SKYBOX: boolean;
  59271. REFLECTIONMAP_EXPLICIT: boolean;
  59272. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  59273. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  59274. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  59275. INVERTCUBICMAP: boolean;
  59276. USESPHERICALFROMREFLECTIONMAP: boolean;
  59277. USEIRRADIANCEMAP: boolean;
  59278. SPHERICAL_HARMONICS: boolean;
  59279. USESPHERICALINVERTEX: boolean;
  59280. REFLECTIONMAP_OPPOSITEZ: boolean;
  59281. LODINREFLECTIONALPHA: boolean;
  59282. GAMMAREFLECTION: boolean;
  59283. RGBDREFLECTION: boolean;
  59284. LINEARSPECULARREFLECTION: boolean;
  59285. RADIANCEOCCLUSION: boolean;
  59286. HORIZONOCCLUSION: boolean;
  59287. INSTANCES: boolean;
  59288. THIN_INSTANCES: boolean;
  59289. PREPASS: boolean;
  59290. PREPASS_IRRADIANCE: boolean;
  59291. PREPASS_IRRADIANCE_INDEX: number;
  59292. PREPASS_ALBEDO: boolean;
  59293. PREPASS_ALBEDO_INDEX: number;
  59294. PREPASS_DEPTHNORMAL: boolean;
  59295. PREPASS_DEPTHNORMAL_INDEX: number;
  59296. PREPASS_POSITION: boolean;
  59297. PREPASS_POSITION_INDEX: number;
  59298. PREPASS_VELOCITY: boolean;
  59299. PREPASS_VELOCITY_INDEX: number;
  59300. PREPASS_REFLECTIVITY: boolean;
  59301. PREPASS_REFLECTIVITY_INDEX: number;
  59302. SCENE_MRT_COUNT: number;
  59303. NUM_BONE_INFLUENCERS: number;
  59304. BonesPerMesh: number;
  59305. BONETEXTURE: boolean;
  59306. BONES_VELOCITY_ENABLED: boolean;
  59307. NONUNIFORMSCALING: boolean;
  59308. MORPHTARGETS: boolean;
  59309. MORPHTARGETS_NORMAL: boolean;
  59310. MORPHTARGETS_TANGENT: boolean;
  59311. MORPHTARGETS_UV: boolean;
  59312. NUM_MORPH_INFLUENCERS: number;
  59313. IMAGEPROCESSING: boolean;
  59314. VIGNETTE: boolean;
  59315. VIGNETTEBLENDMODEMULTIPLY: boolean;
  59316. VIGNETTEBLENDMODEOPAQUE: boolean;
  59317. TONEMAPPING: boolean;
  59318. TONEMAPPING_ACES: boolean;
  59319. CONTRAST: boolean;
  59320. COLORCURVES: boolean;
  59321. COLORGRADING: boolean;
  59322. COLORGRADING3D: boolean;
  59323. SAMPLER3DGREENDEPTH: boolean;
  59324. SAMPLER3DBGRMAP: boolean;
  59325. IMAGEPROCESSINGPOSTPROCESS: boolean;
  59326. EXPOSURE: boolean;
  59327. MULTIVIEW: boolean;
  59328. USEPHYSICALLIGHTFALLOFF: boolean;
  59329. USEGLTFLIGHTFALLOFF: boolean;
  59330. TWOSIDEDLIGHTING: boolean;
  59331. SHADOWFLOAT: boolean;
  59332. CLIPPLANE: boolean;
  59333. CLIPPLANE2: boolean;
  59334. CLIPPLANE3: boolean;
  59335. CLIPPLANE4: boolean;
  59336. CLIPPLANE5: boolean;
  59337. CLIPPLANE6: boolean;
  59338. POINTSIZE: boolean;
  59339. FOG: boolean;
  59340. LOGARITHMICDEPTH: boolean;
  59341. FORCENORMALFORWARD: boolean;
  59342. SPECULARAA: boolean;
  59343. CLEARCOAT: boolean;
  59344. CLEARCOAT_DEFAULTIOR: boolean;
  59345. CLEARCOAT_TEXTURE: boolean;
  59346. CLEARCOAT_TEXTUREDIRECTUV: number;
  59347. CLEARCOAT_BUMP: boolean;
  59348. CLEARCOAT_BUMPDIRECTUV: number;
  59349. CLEARCOAT_REMAP_F0: boolean;
  59350. CLEARCOAT_TINT: boolean;
  59351. CLEARCOAT_TINT_TEXTURE: boolean;
  59352. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  59353. ANISOTROPIC: boolean;
  59354. ANISOTROPIC_TEXTURE: boolean;
  59355. ANISOTROPIC_TEXTUREDIRECTUV: number;
  59356. BRDF_V_HEIGHT_CORRELATED: boolean;
  59357. MS_BRDF_ENERGY_CONSERVATION: boolean;
  59358. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  59359. SHEEN: boolean;
  59360. SHEEN_TEXTURE: boolean;
  59361. SHEEN_TEXTUREDIRECTUV: number;
  59362. SHEEN_LINKWITHALBEDO: boolean;
  59363. SHEEN_ROUGHNESS: boolean;
  59364. SHEEN_ALBEDOSCALING: boolean;
  59365. SUBSURFACE: boolean;
  59366. SS_REFRACTION: boolean;
  59367. SS_TRANSLUCENCY: boolean;
  59368. SS_SCATTERING: boolean;
  59369. SS_THICKNESSANDMASK_TEXTURE: boolean;
  59370. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  59371. SS_REFRACTIONMAP_3D: boolean;
  59372. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  59373. SS_LODINREFRACTIONALPHA: boolean;
  59374. SS_GAMMAREFRACTION: boolean;
  59375. SS_RGBDREFRACTION: boolean;
  59376. SS_LINEARSPECULARREFRACTION: boolean;
  59377. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  59378. SS_ALBEDOFORREFRACTIONTINT: boolean;
  59379. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  59380. UNLIT: boolean;
  59381. DEBUGMODE: number;
  59382. /**
  59383. * Initializes the PBR Material defines.
  59384. */
  59385. constructor();
  59386. /**
  59387. * Resets the PBR Material defines.
  59388. */
  59389. reset(): void;
  59390. }
  59391. /**
  59392. * The Physically based material base class of BJS.
  59393. *
  59394. * This offers the main features of a standard PBR material.
  59395. * For more information, please refer to the documentation :
  59396. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59397. */
  59398. export abstract class PBRBaseMaterial extends PushMaterial {
  59399. /**
  59400. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59401. */
  59402. static readonly PBRMATERIAL_OPAQUE: number;
  59403. /**
  59404. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59405. */
  59406. static readonly PBRMATERIAL_ALPHATEST: number;
  59407. /**
  59408. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59409. */
  59410. static readonly PBRMATERIAL_ALPHABLEND: number;
  59411. /**
  59412. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59413. * They are also discarded below the alpha cutoff threshold to improve performances.
  59414. */
  59415. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59416. /**
  59417. * Defines the default value of how much AO map is occluding the analytical lights
  59418. * (point spot...).
  59419. */
  59420. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59421. /**
  59422. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  59423. */
  59424. static readonly LIGHTFALLOFF_PHYSICAL: number;
  59425. /**
  59426. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  59427. * to enhance interoperability with other engines.
  59428. */
  59429. static readonly LIGHTFALLOFF_GLTF: number;
  59430. /**
  59431. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  59432. * to enhance interoperability with other materials.
  59433. */
  59434. static readonly LIGHTFALLOFF_STANDARD: number;
  59435. /**
  59436. * Intensity of the direct lights e.g. the four lights available in your scene.
  59437. * This impacts both the direct diffuse and specular highlights.
  59438. */
  59439. protected _directIntensity: number;
  59440. /**
  59441. * Intensity of the emissive part of the material.
  59442. * This helps controlling the emissive effect without modifying the emissive color.
  59443. */
  59444. protected _emissiveIntensity: number;
  59445. /**
  59446. * Intensity of the environment e.g. how much the environment will light the object
  59447. * either through harmonics for rough material or through the refelction for shiny ones.
  59448. */
  59449. protected _environmentIntensity: number;
  59450. /**
  59451. * This is a special control allowing the reduction of the specular highlights coming from the
  59452. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59453. */
  59454. protected _specularIntensity: number;
  59455. /**
  59456. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  59457. */
  59458. private _lightingInfos;
  59459. /**
  59460. * Debug Control allowing disabling the bump map on this material.
  59461. */
  59462. protected _disableBumpMap: boolean;
  59463. /**
  59464. * AKA Diffuse Texture in standard nomenclature.
  59465. */
  59466. protected _albedoTexture: Nullable<BaseTexture>;
  59467. /**
  59468. * AKA Occlusion Texture in other nomenclature.
  59469. */
  59470. protected _ambientTexture: Nullable<BaseTexture>;
  59471. /**
  59472. * AKA Occlusion Texture Intensity in other nomenclature.
  59473. */
  59474. protected _ambientTextureStrength: number;
  59475. /**
  59476. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59477. * 1 means it completely occludes it
  59478. * 0 mean it has no impact
  59479. */
  59480. protected _ambientTextureImpactOnAnalyticalLights: number;
  59481. /**
  59482. * Stores the alpha values in a texture.
  59483. */
  59484. protected _opacityTexture: Nullable<BaseTexture>;
  59485. /**
  59486. * Stores the reflection values in a texture.
  59487. */
  59488. protected _reflectionTexture: Nullable<BaseTexture>;
  59489. /**
  59490. * Stores the emissive values in a texture.
  59491. */
  59492. protected _emissiveTexture: Nullable<BaseTexture>;
  59493. /**
  59494. * AKA Specular texture in other nomenclature.
  59495. */
  59496. protected _reflectivityTexture: Nullable<BaseTexture>;
  59497. /**
  59498. * Used to switch from specular/glossiness to metallic/roughness workflow.
  59499. */
  59500. protected _metallicTexture: Nullable<BaseTexture>;
  59501. /**
  59502. * Specifies the metallic scalar of the metallic/roughness workflow.
  59503. * Can also be used to scale the metalness values of the metallic texture.
  59504. */
  59505. protected _metallic: Nullable<number>;
  59506. /**
  59507. * Specifies the roughness scalar of the metallic/roughness workflow.
  59508. * Can also be used to scale the roughness values of the metallic texture.
  59509. */
  59510. protected _roughness: Nullable<number>;
  59511. /**
  59512. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  59513. * By default the indexOfrefraction is used to compute F0;
  59514. *
  59515. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  59516. *
  59517. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  59518. * F90 = metallicReflectanceColor;
  59519. */
  59520. protected _metallicF0Factor: number;
  59521. /**
  59522. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  59523. * By default the F90 is always 1;
  59524. *
  59525. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  59526. *
  59527. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  59528. * F90 = metallicReflectanceColor;
  59529. */
  59530. protected _metallicReflectanceColor: Color3;
  59531. /**
  59532. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  59533. * This is multiply against the scalar values defined in the material.
  59534. */
  59535. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  59536. /**
  59537. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  59538. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  59539. */
  59540. protected _microSurfaceTexture: Nullable<BaseTexture>;
  59541. /**
  59542. * Stores surface normal data used to displace a mesh in a texture.
  59543. */
  59544. protected _bumpTexture: Nullable<BaseTexture>;
  59545. /**
  59546. * Stores the pre-calculated light information of a mesh in a texture.
  59547. */
  59548. protected _lightmapTexture: Nullable<BaseTexture>;
  59549. /**
  59550. * The color of a material in ambient lighting.
  59551. */
  59552. protected _ambientColor: Color3;
  59553. /**
  59554. * AKA Diffuse Color in other nomenclature.
  59555. */
  59556. protected _albedoColor: Color3;
  59557. /**
  59558. * AKA Specular Color in other nomenclature.
  59559. */
  59560. protected _reflectivityColor: Color3;
  59561. /**
  59562. * The color applied when light is reflected from a material.
  59563. */
  59564. protected _reflectionColor: Color3;
  59565. /**
  59566. * The color applied when light is emitted from a material.
  59567. */
  59568. protected _emissiveColor: Color3;
  59569. /**
  59570. * AKA Glossiness in other nomenclature.
  59571. */
  59572. protected _microSurface: number;
  59573. /**
  59574. * Specifies that the material will use the light map as a show map.
  59575. */
  59576. protected _useLightmapAsShadowmap: boolean;
  59577. /**
  59578. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  59579. * makes the reflect vector face the model (under horizon).
  59580. */
  59581. protected _useHorizonOcclusion: boolean;
  59582. /**
  59583. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  59584. * too much the area relying on ambient texture to define their ambient occlusion.
  59585. */
  59586. protected _useRadianceOcclusion: boolean;
  59587. /**
  59588. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  59589. */
  59590. protected _useAlphaFromAlbedoTexture: boolean;
  59591. /**
  59592. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  59593. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  59594. */
  59595. protected _useSpecularOverAlpha: boolean;
  59596. /**
  59597. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  59598. */
  59599. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  59600. /**
  59601. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  59602. */
  59603. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  59604. /**
  59605. * Specifies if the metallic texture contains the roughness information in its green channel.
  59606. */
  59607. protected _useRoughnessFromMetallicTextureGreen: boolean;
  59608. /**
  59609. * Specifies if the metallic texture contains the metallness information in its blue channel.
  59610. */
  59611. protected _useMetallnessFromMetallicTextureBlue: boolean;
  59612. /**
  59613. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  59614. */
  59615. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  59616. /**
  59617. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  59618. */
  59619. protected _useAmbientInGrayScale: boolean;
  59620. /**
  59621. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  59622. * The material will try to infer what glossiness each pixel should be.
  59623. */
  59624. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  59625. /**
  59626. * Defines the falloff type used in this material.
  59627. * It by default is Physical.
  59628. */
  59629. protected _lightFalloff: number;
  59630. /**
  59631. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  59632. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  59633. */
  59634. protected _useRadianceOverAlpha: boolean;
  59635. /**
  59636. * Allows using an object space normal map (instead of tangent space).
  59637. */
  59638. protected _useObjectSpaceNormalMap: boolean;
  59639. /**
  59640. * Allows using the bump map in parallax mode.
  59641. */
  59642. protected _useParallax: boolean;
  59643. /**
  59644. * Allows using the bump map in parallax occlusion mode.
  59645. */
  59646. protected _useParallaxOcclusion: boolean;
  59647. /**
  59648. * Controls the scale bias of the parallax mode.
  59649. */
  59650. protected _parallaxScaleBias: number;
  59651. /**
  59652. * If sets to true, disables all the lights affecting the material.
  59653. */
  59654. protected _disableLighting: boolean;
  59655. /**
  59656. * Number of Simultaneous lights allowed on the material.
  59657. */
  59658. protected _maxSimultaneousLights: number;
  59659. /**
  59660. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  59661. */
  59662. protected _invertNormalMapX: boolean;
  59663. /**
  59664. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  59665. */
  59666. protected _invertNormalMapY: boolean;
  59667. /**
  59668. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  59669. */
  59670. protected _twoSidedLighting: boolean;
  59671. /**
  59672. * Defines the alpha limits in alpha test mode.
  59673. */
  59674. protected _alphaCutOff: number;
  59675. /**
  59676. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  59677. */
  59678. protected _forceAlphaTest: boolean;
  59679. /**
  59680. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59681. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  59682. */
  59683. protected _useAlphaFresnel: boolean;
  59684. /**
  59685. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  59686. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  59687. */
  59688. protected _useLinearAlphaFresnel: boolean;
  59689. /**
  59690. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  59691. * from cos thetav and roughness:
  59692. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  59693. */
  59694. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  59695. /**
  59696. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  59697. */
  59698. protected _forceIrradianceInFragment: boolean;
  59699. private _realTimeFiltering;
  59700. /**
  59701. * Enables realtime filtering on the texture.
  59702. */
  59703. get realTimeFiltering(): boolean;
  59704. set realTimeFiltering(b: boolean);
  59705. private _realTimeFilteringQuality;
  59706. /**
  59707. * Quality switch for realtime filtering
  59708. */
  59709. get realTimeFilteringQuality(): number;
  59710. set realTimeFilteringQuality(n: number);
  59711. /**
  59712. * Can this material render to several textures at once
  59713. */
  59714. get canRenderToMRT(): boolean;
  59715. /**
  59716. * Force normal to face away from face.
  59717. */
  59718. protected _forceNormalForward: boolean;
  59719. /**
  59720. * Enables specular anti aliasing in the PBR shader.
  59721. * It will both interacts on the Geometry for analytical and IBL lighting.
  59722. * It also prefilter the roughness map based on the bump values.
  59723. */
  59724. protected _enableSpecularAntiAliasing: boolean;
  59725. /**
  59726. * Default configuration related to image processing available in the PBR Material.
  59727. */
  59728. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  59729. /**
  59730. * Keep track of the image processing observer to allow dispose and replace.
  59731. */
  59732. private _imageProcessingObserver;
  59733. /**
  59734. * Attaches a new image processing configuration to the PBR Material.
  59735. * @param configuration
  59736. */
  59737. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  59738. /**
  59739. * Stores the available render targets.
  59740. */
  59741. private _renderTargets;
  59742. /**
  59743. * Sets the global ambient color for the material used in lighting calculations.
  59744. */
  59745. private _globalAmbientColor;
  59746. /**
  59747. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  59748. */
  59749. private _useLogarithmicDepth;
  59750. /**
  59751. * If set to true, no lighting calculations will be applied.
  59752. */
  59753. private _unlit;
  59754. private _debugMode;
  59755. /**
  59756. * @hidden
  59757. * This is reserved for the inspector.
  59758. * Defines the material debug mode.
  59759. * It helps seeing only some components of the material while troubleshooting.
  59760. */
  59761. debugMode: number;
  59762. /**
  59763. * @hidden
  59764. * This is reserved for the inspector.
  59765. * Specify from where on screen the debug mode should start.
  59766. * The value goes from -1 (full screen) to 1 (not visible)
  59767. * It helps with side by side comparison against the final render
  59768. * This defaults to -1
  59769. */
  59770. private debugLimit;
  59771. /**
  59772. * @hidden
  59773. * This is reserved for the inspector.
  59774. * As the default viewing range might not be enough (if the ambient is really small for instance)
  59775. * You can use the factor to better multiply the final value.
  59776. */
  59777. private debugFactor;
  59778. /**
  59779. * Defines the clear coat layer parameters for the material.
  59780. */
  59781. readonly clearCoat: PBRClearCoatConfiguration;
  59782. /**
  59783. * Defines the anisotropic parameters for the material.
  59784. */
  59785. readonly anisotropy: PBRAnisotropicConfiguration;
  59786. /**
  59787. * Defines the BRDF parameters for the material.
  59788. */
  59789. readonly brdf: PBRBRDFConfiguration;
  59790. /**
  59791. * Defines the Sheen parameters for the material.
  59792. */
  59793. readonly sheen: PBRSheenConfiguration;
  59794. /**
  59795. * Defines the SubSurface parameters for the material.
  59796. */
  59797. readonly subSurface: PBRSubSurfaceConfiguration;
  59798. /**
  59799. * Defines additionnal PrePass parameters for the material.
  59800. */
  59801. readonly prePassConfiguration: PrePassConfiguration;
  59802. /**
  59803. * Defines the detail map parameters for the material.
  59804. */
  59805. readonly detailMap: DetailMapConfiguration;
  59806. protected _rebuildInParallel: boolean;
  59807. /**
  59808. * Instantiates a new PBRMaterial instance.
  59809. *
  59810. * @param name The material name
  59811. * @param scene The scene the material will be use in.
  59812. */
  59813. constructor(name: string, scene: Scene);
  59814. /**
  59815. * Gets a boolean indicating that current material needs to register RTT
  59816. */
  59817. get hasRenderTargetTextures(): boolean;
  59818. /**
  59819. * Gets the name of the material class.
  59820. */
  59821. getClassName(): string;
  59822. /**
  59823. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59824. */
  59825. get useLogarithmicDepth(): boolean;
  59826. /**
  59827. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  59828. */
  59829. set useLogarithmicDepth(value: boolean);
  59830. /**
  59831. * Returns true if alpha blending should be disabled.
  59832. */
  59833. protected get _disableAlphaBlending(): boolean;
  59834. /**
  59835. * Specifies whether or not this material should be rendered in alpha blend mode.
  59836. */
  59837. needAlphaBlending(): boolean;
  59838. /**
  59839. * Specifies whether or not this material should be rendered in alpha test mode.
  59840. */
  59841. needAlphaTesting(): boolean;
  59842. /**
  59843. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  59844. */
  59845. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  59846. /**
  59847. * Gets the texture used for the alpha test.
  59848. */
  59849. getAlphaTestTexture(): Nullable<BaseTexture>;
  59850. /**
  59851. * Specifies that the submesh is ready to be used.
  59852. * @param mesh - BJS mesh.
  59853. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  59854. * @param useInstances - Specifies that instances should be used.
  59855. * @returns - boolean indicating that the submesh is ready or not.
  59856. */
  59857. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  59858. /**
  59859. * Specifies if the material uses metallic roughness workflow.
  59860. * @returns boolean specifiying if the material uses metallic roughness workflow.
  59861. */
  59862. isMetallicWorkflow(): boolean;
  59863. private _prepareEffect;
  59864. private _prepareDefines;
  59865. /**
  59866. * Force shader compilation
  59867. */
  59868. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  59869. /**
  59870. * Initializes the uniform buffer layout for the shader.
  59871. */
  59872. buildUniformLayout(): void;
  59873. /**
  59874. * Unbinds the material from the mesh
  59875. */
  59876. unbind(): void;
  59877. /**
  59878. * Binds the submesh data.
  59879. * @param world - The world matrix.
  59880. * @param mesh - The BJS mesh.
  59881. * @param subMesh - A submesh of the BJS mesh.
  59882. */
  59883. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  59884. /**
  59885. * Returns the animatable textures.
  59886. * @returns - Array of animatable textures.
  59887. */
  59888. getAnimatables(): IAnimatable[];
  59889. /**
  59890. * Returns the texture used for reflections.
  59891. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  59892. */
  59893. private _getReflectionTexture;
  59894. /**
  59895. * Returns an array of the actively used textures.
  59896. * @returns - Array of BaseTextures
  59897. */
  59898. getActiveTextures(): BaseTexture[];
  59899. /**
  59900. * Checks to see if a texture is used in the material.
  59901. * @param texture - Base texture to use.
  59902. * @returns - Boolean specifying if a texture is used in the material.
  59903. */
  59904. hasTexture(texture: BaseTexture): boolean;
  59905. /**
  59906. * Sets the required values to the prepass renderer.
  59907. * @param prePassRenderer defines the prepass renderer to setup
  59908. */
  59909. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  59910. /**
  59911. * Disposes the resources of the material.
  59912. * @param forceDisposeEffect - Forces the disposal of effects.
  59913. * @param forceDisposeTextures - Forces the disposal of all textures.
  59914. */
  59915. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  59916. }
  59917. }
  59918. declare module "babylonjs/Materials/PBR/pbrMaterial" {
  59919. import { Nullable } from "babylonjs/types";
  59920. import { Scene } from "babylonjs/scene";
  59921. import { Color3 } from "babylonjs/Maths/math.color";
  59922. import { ImageProcessingConfiguration } from "babylonjs/Materials/imageProcessingConfiguration";
  59923. import { ColorCurves } from "babylonjs/Materials/colorCurves";
  59924. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  59925. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  59926. /**
  59927. * The Physically based material of BJS.
  59928. *
  59929. * This offers the main features of a standard PBR material.
  59930. * For more information, please refer to the documentation :
  59931. * https://doc.babylonjs.com/how_to/physically_based_rendering
  59932. */
  59933. export class PBRMaterial extends PBRBaseMaterial {
  59934. /**
  59935. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  59936. */
  59937. static readonly PBRMATERIAL_OPAQUE: number;
  59938. /**
  59939. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  59940. */
  59941. static readonly PBRMATERIAL_ALPHATEST: number;
  59942. /**
  59943. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59944. */
  59945. static readonly PBRMATERIAL_ALPHABLEND: number;
  59946. /**
  59947. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  59948. * They are also discarded below the alpha cutoff threshold to improve performances.
  59949. */
  59950. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  59951. /**
  59952. * Defines the default value of how much AO map is occluding the analytical lights
  59953. * (point spot...).
  59954. */
  59955. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  59956. /**
  59957. * Intensity of the direct lights e.g. the four lights available in your scene.
  59958. * This impacts both the direct diffuse and specular highlights.
  59959. */
  59960. directIntensity: number;
  59961. /**
  59962. * Intensity of the emissive part of the material.
  59963. * This helps controlling the emissive effect without modifying the emissive color.
  59964. */
  59965. emissiveIntensity: number;
  59966. /**
  59967. * Intensity of the environment e.g. how much the environment will light the object
  59968. * either through harmonics for rough material or through the refelction for shiny ones.
  59969. */
  59970. environmentIntensity: number;
  59971. /**
  59972. * This is a special control allowing the reduction of the specular highlights coming from the
  59973. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  59974. */
  59975. specularIntensity: number;
  59976. /**
  59977. * Debug Control allowing disabling the bump map on this material.
  59978. */
  59979. disableBumpMap: boolean;
  59980. /**
  59981. * AKA Diffuse Texture in standard nomenclature.
  59982. */
  59983. albedoTexture: BaseTexture;
  59984. /**
  59985. * AKA Occlusion Texture in other nomenclature.
  59986. */
  59987. ambientTexture: BaseTexture;
  59988. /**
  59989. * AKA Occlusion Texture Intensity in other nomenclature.
  59990. */
  59991. ambientTextureStrength: number;
  59992. /**
  59993. * Defines how much the AO map is occluding the analytical lights (point spot...).
  59994. * 1 means it completely occludes it
  59995. * 0 mean it has no impact
  59996. */
  59997. ambientTextureImpactOnAnalyticalLights: number;
  59998. /**
  59999. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  60000. */
  60001. opacityTexture: BaseTexture;
  60002. /**
  60003. * Stores the reflection values in a texture.
  60004. */
  60005. reflectionTexture: Nullable<BaseTexture>;
  60006. /**
  60007. * Stores the emissive values in a texture.
  60008. */
  60009. emissiveTexture: BaseTexture;
  60010. /**
  60011. * AKA Specular texture in other nomenclature.
  60012. */
  60013. reflectivityTexture: BaseTexture;
  60014. /**
  60015. * Used to switch from specular/glossiness to metallic/roughness workflow.
  60016. */
  60017. metallicTexture: BaseTexture;
  60018. /**
  60019. * Specifies the metallic scalar of the metallic/roughness workflow.
  60020. * Can also be used to scale the metalness values of the metallic texture.
  60021. */
  60022. metallic: Nullable<number>;
  60023. /**
  60024. * Specifies the roughness scalar of the metallic/roughness workflow.
  60025. * Can also be used to scale the roughness values of the metallic texture.
  60026. */
  60027. roughness: Nullable<number>;
  60028. /**
  60029. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  60030. * By default the indexOfrefraction is used to compute F0;
  60031. *
  60032. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  60033. *
  60034. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  60035. * F90 = metallicReflectanceColor;
  60036. */
  60037. metallicF0Factor: number;
  60038. /**
  60039. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  60040. * By default the F90 is always 1;
  60041. *
  60042. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  60043. *
  60044. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  60045. * F90 = metallicReflectanceColor;
  60046. */
  60047. metallicReflectanceColor: Color3;
  60048. /**
  60049. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  60050. * This is multiply against the scalar values defined in the material.
  60051. */
  60052. metallicReflectanceTexture: Nullable<BaseTexture>;
  60053. /**
  60054. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  60055. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  60056. */
  60057. microSurfaceTexture: BaseTexture;
  60058. /**
  60059. * Stores surface normal data used to displace a mesh in a texture.
  60060. */
  60061. bumpTexture: BaseTexture;
  60062. /**
  60063. * Stores the pre-calculated light information of a mesh in a texture.
  60064. */
  60065. lightmapTexture: BaseTexture;
  60066. /**
  60067. * Stores the refracted light information in a texture.
  60068. */
  60069. get refractionTexture(): Nullable<BaseTexture>;
  60070. set refractionTexture(value: Nullable<BaseTexture>);
  60071. /**
  60072. * The color of a material in ambient lighting.
  60073. */
  60074. ambientColor: Color3;
  60075. /**
  60076. * AKA Diffuse Color in other nomenclature.
  60077. */
  60078. albedoColor: Color3;
  60079. /**
  60080. * AKA Specular Color in other nomenclature.
  60081. */
  60082. reflectivityColor: Color3;
  60083. /**
  60084. * The color reflected from the material.
  60085. */
  60086. reflectionColor: Color3;
  60087. /**
  60088. * The color emitted from the material.
  60089. */
  60090. emissiveColor: Color3;
  60091. /**
  60092. * AKA Glossiness in other nomenclature.
  60093. */
  60094. microSurface: number;
  60095. /**
  60096. * Index of refraction of the material base layer.
  60097. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  60098. *
  60099. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  60100. *
  60101. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  60102. */
  60103. get indexOfRefraction(): number;
  60104. set indexOfRefraction(value: number);
  60105. /**
  60106. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  60107. */
  60108. get invertRefractionY(): boolean;
  60109. set invertRefractionY(value: boolean);
  60110. /**
  60111. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  60112. * Materials half opaque for instance using refraction could benefit from this control.
  60113. */
  60114. get linkRefractionWithTransparency(): boolean;
  60115. set linkRefractionWithTransparency(value: boolean);
  60116. /**
  60117. * If true, the light map contains occlusion information instead of lighting info.
  60118. */
  60119. useLightmapAsShadowmap: boolean;
  60120. /**
  60121. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  60122. */
  60123. useAlphaFromAlbedoTexture: boolean;
  60124. /**
  60125. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  60126. */
  60127. forceAlphaTest: boolean;
  60128. /**
  60129. * Defines the alpha limits in alpha test mode.
  60130. */
  60131. alphaCutOff: number;
  60132. /**
  60133. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  60134. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  60135. */
  60136. useSpecularOverAlpha: boolean;
  60137. /**
  60138. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  60139. */
  60140. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  60141. /**
  60142. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  60143. */
  60144. useRoughnessFromMetallicTextureAlpha: boolean;
  60145. /**
  60146. * Specifies if the metallic texture contains the roughness information in its green channel.
  60147. */
  60148. useRoughnessFromMetallicTextureGreen: boolean;
  60149. /**
  60150. * Specifies if the metallic texture contains the metallness information in its blue channel.
  60151. */
  60152. useMetallnessFromMetallicTextureBlue: boolean;
  60153. /**
  60154. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  60155. */
  60156. useAmbientOcclusionFromMetallicTextureRed: boolean;
  60157. /**
  60158. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  60159. */
  60160. useAmbientInGrayScale: boolean;
  60161. /**
  60162. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  60163. * The material will try to infer what glossiness each pixel should be.
  60164. */
  60165. useAutoMicroSurfaceFromReflectivityMap: boolean;
  60166. /**
  60167. * BJS is using an harcoded light falloff based on a manually sets up range.
  60168. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60169. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60170. */
  60171. get usePhysicalLightFalloff(): boolean;
  60172. /**
  60173. * BJS is using an harcoded light falloff based on a manually sets up range.
  60174. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  60175. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  60176. */
  60177. set usePhysicalLightFalloff(value: boolean);
  60178. /**
  60179. * In order to support the falloff compatibility with gltf, a special mode has been added
  60180. * to reproduce the gltf light falloff.
  60181. */
  60182. get useGLTFLightFalloff(): boolean;
  60183. /**
  60184. * In order to support the falloff compatibility with gltf, a special mode has been added
  60185. * to reproduce the gltf light falloff.
  60186. */
  60187. set useGLTFLightFalloff(value: boolean);
  60188. /**
  60189. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  60190. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  60191. */
  60192. useRadianceOverAlpha: boolean;
  60193. /**
  60194. * Allows using an object space normal map (instead of tangent space).
  60195. */
  60196. useObjectSpaceNormalMap: boolean;
  60197. /**
  60198. * Allows using the bump map in parallax mode.
  60199. */
  60200. useParallax: boolean;
  60201. /**
  60202. * Allows using the bump map in parallax occlusion mode.
  60203. */
  60204. useParallaxOcclusion: boolean;
  60205. /**
  60206. * Controls the scale bias of the parallax mode.
  60207. */
  60208. parallaxScaleBias: number;
  60209. /**
  60210. * If sets to true, disables all the lights affecting the material.
  60211. */
  60212. disableLighting: boolean;
  60213. /**
  60214. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  60215. */
  60216. forceIrradianceInFragment: boolean;
  60217. /**
  60218. * Number of Simultaneous lights allowed on the material.
  60219. */
  60220. maxSimultaneousLights: number;
  60221. /**
  60222. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  60223. */
  60224. invertNormalMapX: boolean;
  60225. /**
  60226. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  60227. */
  60228. invertNormalMapY: boolean;
  60229. /**
  60230. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  60231. */
  60232. twoSidedLighting: boolean;
  60233. /**
  60234. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60235. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  60236. */
  60237. useAlphaFresnel: boolean;
  60238. /**
  60239. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  60240. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  60241. */
  60242. useLinearAlphaFresnel: boolean;
  60243. /**
  60244. * Let user defines the brdf lookup texture used for IBL.
  60245. * A default 8bit version is embedded but you could point at :
  60246. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  60247. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  60248. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  60249. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  60250. */
  60251. environmentBRDFTexture: Nullable<BaseTexture>;
  60252. /**
  60253. * Force normal to face away from face.
  60254. */
  60255. forceNormalForward: boolean;
  60256. /**
  60257. * Enables specular anti aliasing in the PBR shader.
  60258. * It will both interacts on the Geometry for analytical and IBL lighting.
  60259. * It also prefilter the roughness map based on the bump values.
  60260. */
  60261. enableSpecularAntiAliasing: boolean;
  60262. /**
  60263. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  60264. * makes the reflect vector face the model (under horizon).
  60265. */
  60266. useHorizonOcclusion: boolean;
  60267. /**
  60268. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  60269. * too much the area relying on ambient texture to define their ambient occlusion.
  60270. */
  60271. useRadianceOcclusion: boolean;
  60272. /**
  60273. * If set to true, no lighting calculations will be applied.
  60274. */
  60275. unlit: boolean;
  60276. /**
  60277. * Gets the image processing configuration used either in this material.
  60278. */
  60279. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  60280. /**
  60281. * Sets the Default image processing configuration used either in the this material.
  60282. *
  60283. * If sets to null, the scene one is in use.
  60284. */
  60285. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  60286. /**
  60287. * Gets wether the color curves effect is enabled.
  60288. */
  60289. get cameraColorCurvesEnabled(): boolean;
  60290. /**
  60291. * Sets wether the color curves effect is enabled.
  60292. */
  60293. set cameraColorCurvesEnabled(value: boolean);
  60294. /**
  60295. * Gets wether the color grading effect is enabled.
  60296. */
  60297. get cameraColorGradingEnabled(): boolean;
  60298. /**
  60299. * Gets wether the color grading effect is enabled.
  60300. */
  60301. set cameraColorGradingEnabled(value: boolean);
  60302. /**
  60303. * Gets wether tonemapping is enabled or not.
  60304. */
  60305. get cameraToneMappingEnabled(): boolean;
  60306. /**
  60307. * Sets wether tonemapping is enabled or not
  60308. */
  60309. set cameraToneMappingEnabled(value: boolean);
  60310. /**
  60311. * The camera exposure used on this material.
  60312. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60313. * This corresponds to a photographic exposure.
  60314. */
  60315. get cameraExposure(): number;
  60316. /**
  60317. * The camera exposure used on this material.
  60318. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  60319. * This corresponds to a photographic exposure.
  60320. */
  60321. set cameraExposure(value: number);
  60322. /**
  60323. * Gets The camera contrast used on this material.
  60324. */
  60325. get cameraContrast(): number;
  60326. /**
  60327. * Sets The camera contrast used on this material.
  60328. */
  60329. set cameraContrast(value: number);
  60330. /**
  60331. * Gets the Color Grading 2D Lookup Texture.
  60332. */
  60333. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  60334. /**
  60335. * Sets the Color Grading 2D Lookup Texture.
  60336. */
  60337. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  60338. /**
  60339. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60340. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60341. * 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;
  60342. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60343. */
  60344. get cameraColorCurves(): Nullable<ColorCurves>;
  60345. /**
  60346. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  60347. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  60348. * 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;
  60349. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  60350. */
  60351. set cameraColorCurves(value: Nullable<ColorCurves>);
  60352. /**
  60353. * Instantiates a new PBRMaterial instance.
  60354. *
  60355. * @param name The material name
  60356. * @param scene The scene the material will be use in.
  60357. */
  60358. constructor(name: string, scene: Scene);
  60359. /**
  60360. * Returns the name of this material class.
  60361. */
  60362. getClassName(): string;
  60363. /**
  60364. * Makes a duplicate of the current material.
  60365. * @param name - name to use for the new material.
  60366. */
  60367. clone(name: string): PBRMaterial;
  60368. /**
  60369. * Serializes this PBR Material.
  60370. * @returns - An object with the serialized material.
  60371. */
  60372. serialize(): any;
  60373. /**
  60374. * Parses a PBR Material from a serialized object.
  60375. * @param source - Serialized object.
  60376. * @param scene - BJS scene instance.
  60377. * @param rootUrl - url for the scene object
  60378. * @returns - PBRMaterial
  60379. */
  60380. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  60381. }
  60382. }
  60383. declare module "babylonjs/Misc/dds" {
  60384. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  60385. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60386. import { Nullable } from "babylonjs/types";
  60387. import { Scene } from "babylonjs/scene";
  60388. import "babylonjs/Engines/Extensions/engine.cubeTexture";
  60389. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60390. /**
  60391. * Direct draw surface info
  60392. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  60393. */
  60394. export interface DDSInfo {
  60395. /**
  60396. * Width of the texture
  60397. */
  60398. width: number;
  60399. /**
  60400. * Width of the texture
  60401. */
  60402. height: number;
  60403. /**
  60404. * Number of Mipmaps for the texture
  60405. * @see https://en.wikipedia.org/wiki/Mipmap
  60406. */
  60407. mipmapCount: number;
  60408. /**
  60409. * If the textures format is a known fourCC format
  60410. * @see https://www.fourcc.org/
  60411. */
  60412. isFourCC: boolean;
  60413. /**
  60414. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  60415. */
  60416. isRGB: boolean;
  60417. /**
  60418. * If the texture is a lumincance format
  60419. */
  60420. isLuminance: boolean;
  60421. /**
  60422. * If this is a cube texture
  60423. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  60424. */
  60425. isCube: boolean;
  60426. /**
  60427. * If the texture is a compressed format eg. FOURCC_DXT1
  60428. */
  60429. isCompressed: boolean;
  60430. /**
  60431. * The dxgiFormat of the texture
  60432. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  60433. */
  60434. dxgiFormat: number;
  60435. /**
  60436. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  60437. */
  60438. textureType: number;
  60439. /**
  60440. * Sphericle polynomial created for the dds texture
  60441. */
  60442. sphericalPolynomial?: SphericalPolynomial;
  60443. }
  60444. /**
  60445. * Class used to provide DDS decompression tools
  60446. */
  60447. export class DDSTools {
  60448. /**
  60449. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  60450. */
  60451. static StoreLODInAlphaChannel: boolean;
  60452. /**
  60453. * Gets DDS information from an array buffer
  60454. * @param data defines the array buffer view to read data from
  60455. * @returns the DDS information
  60456. */
  60457. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  60458. private static _FloatView;
  60459. private static _Int32View;
  60460. private static _ToHalfFloat;
  60461. private static _FromHalfFloat;
  60462. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  60463. private static _GetHalfFloatRGBAArrayBuffer;
  60464. private static _GetFloatRGBAArrayBuffer;
  60465. private static _GetFloatAsUIntRGBAArrayBuffer;
  60466. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  60467. private static _GetRGBAArrayBuffer;
  60468. private static _ExtractLongWordOrder;
  60469. private static _GetRGBArrayBuffer;
  60470. private static _GetLuminanceArrayBuffer;
  60471. /**
  60472. * Uploads DDS Levels to a Babylon Texture
  60473. * @hidden
  60474. */
  60475. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  60476. }
  60477. module "babylonjs/Engines/thinEngine" {
  60478. interface ThinEngine {
  60479. /**
  60480. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  60481. * @param rootUrl defines the url where the file to load is located
  60482. * @param scene defines the current scene
  60483. * @param lodScale defines scale to apply to the mip map selection
  60484. * @param lodOffset defines offset to apply to the mip map selection
  60485. * @param onLoad defines an optional callback raised when the texture is loaded
  60486. * @param onError defines an optional callback raised if there is an issue to load the texture
  60487. * @param format defines the format of the data
  60488. * @param forcedExtension defines the extension to use to pick the right loader
  60489. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  60490. * @returns the cube texture as an InternalTexture
  60491. */
  60492. 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;
  60493. }
  60494. }
  60495. }
  60496. declare module "babylonjs/Materials/Textures/Loaders/ddsTextureLoader" {
  60497. import { Nullable } from "babylonjs/types";
  60498. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60499. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60500. /**
  60501. * Implementation of the DDS Texture Loader.
  60502. * @hidden
  60503. */
  60504. export class _DDSTextureLoader implements IInternalTextureLoader {
  60505. /**
  60506. * Defines wether the loader supports cascade loading the different faces.
  60507. */
  60508. readonly supportCascades: boolean;
  60509. /**
  60510. * This returns if the loader support the current file information.
  60511. * @param extension defines the file extension of the file being loaded
  60512. * @returns true if the loader can load the specified file
  60513. */
  60514. canLoad(extension: string): boolean;
  60515. /**
  60516. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60517. * @param data contains the texture data
  60518. * @param texture defines the BabylonJS internal texture
  60519. * @param createPolynomials will be true if polynomials have been requested
  60520. * @param onLoad defines the callback to trigger once the texture is ready
  60521. * @param onError defines the callback to trigger in case of error
  60522. */
  60523. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60524. /**
  60525. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60526. * @param data contains the texture data
  60527. * @param texture defines the BabylonJS internal texture
  60528. * @param callback defines the method to call once ready to upload
  60529. */
  60530. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60531. }
  60532. }
  60533. declare module "babylonjs/Materials/Textures/Loaders/envTextureLoader" {
  60534. import { Nullable } from "babylonjs/types";
  60535. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60536. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60537. /**
  60538. * Implementation of the ENV Texture Loader.
  60539. * @hidden
  60540. */
  60541. export class _ENVTextureLoader implements IInternalTextureLoader {
  60542. /**
  60543. * Defines wether the loader supports cascade loading the different faces.
  60544. */
  60545. readonly supportCascades: boolean;
  60546. /**
  60547. * This returns if the loader support the current file information.
  60548. * @param extension defines the file extension of the file being loaded
  60549. * @returns true if the loader can load the specified file
  60550. */
  60551. canLoad(extension: string): boolean;
  60552. /**
  60553. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60554. * @param data contains the texture data
  60555. * @param texture defines the BabylonJS internal texture
  60556. * @param createPolynomials will be true if polynomials have been requested
  60557. * @param onLoad defines the callback to trigger once the texture is ready
  60558. * @param onError defines the callback to trigger in case of error
  60559. */
  60560. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60561. /**
  60562. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60563. * @param data contains the texture data
  60564. * @param texture defines the BabylonJS internal texture
  60565. * @param callback defines the method to call once ready to upload
  60566. */
  60567. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  60568. }
  60569. }
  60570. declare module "babylonjs/Misc/khronosTextureContainer" {
  60571. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60572. /**
  60573. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  60574. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  60575. */
  60576. export class KhronosTextureContainer {
  60577. /** contents of the KTX container file */
  60578. data: ArrayBufferView;
  60579. private static HEADER_LEN;
  60580. private static COMPRESSED_2D;
  60581. private static COMPRESSED_3D;
  60582. private static TEX_2D;
  60583. private static TEX_3D;
  60584. /**
  60585. * Gets the openGL type
  60586. */
  60587. glType: number;
  60588. /**
  60589. * Gets the openGL type size
  60590. */
  60591. glTypeSize: number;
  60592. /**
  60593. * Gets the openGL format
  60594. */
  60595. glFormat: number;
  60596. /**
  60597. * Gets the openGL internal format
  60598. */
  60599. glInternalFormat: number;
  60600. /**
  60601. * Gets the base internal format
  60602. */
  60603. glBaseInternalFormat: number;
  60604. /**
  60605. * Gets image width in pixel
  60606. */
  60607. pixelWidth: number;
  60608. /**
  60609. * Gets image height in pixel
  60610. */
  60611. pixelHeight: number;
  60612. /**
  60613. * Gets image depth in pixels
  60614. */
  60615. pixelDepth: number;
  60616. /**
  60617. * Gets the number of array elements
  60618. */
  60619. numberOfArrayElements: number;
  60620. /**
  60621. * Gets the number of faces
  60622. */
  60623. numberOfFaces: number;
  60624. /**
  60625. * Gets the number of mipmap levels
  60626. */
  60627. numberOfMipmapLevels: number;
  60628. /**
  60629. * Gets the bytes of key value data
  60630. */
  60631. bytesOfKeyValueData: number;
  60632. /**
  60633. * Gets the load type
  60634. */
  60635. loadType: number;
  60636. /**
  60637. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  60638. */
  60639. isInvalid: boolean;
  60640. /**
  60641. * Creates a new KhronosTextureContainer
  60642. * @param data contents of the KTX container file
  60643. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  60644. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  60645. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  60646. */
  60647. constructor(
  60648. /** contents of the KTX container file */
  60649. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  60650. /**
  60651. * Uploads KTX content to a Babylon Texture.
  60652. * It is assumed that the texture has already been created & is currently bound
  60653. * @hidden
  60654. */
  60655. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  60656. private _upload2DCompressedLevels;
  60657. /**
  60658. * Checks if the given data starts with a KTX file identifier.
  60659. * @param data the data to check
  60660. * @returns true if the data is a KTX file or false otherwise
  60661. */
  60662. static IsValid(data: ArrayBufferView): boolean;
  60663. }
  60664. }
  60665. declare module "babylonjs/Misc/workerPool" {
  60666. import { IDisposable } from "babylonjs/scene";
  60667. /**
  60668. * Helper class to push actions to a pool of workers.
  60669. */
  60670. export class WorkerPool implements IDisposable {
  60671. private _workerInfos;
  60672. private _pendingActions;
  60673. /**
  60674. * Constructor
  60675. * @param workers Array of workers to use for actions
  60676. */
  60677. constructor(workers: Array<Worker>);
  60678. /**
  60679. * Terminates all workers and clears any pending actions.
  60680. */
  60681. dispose(): void;
  60682. /**
  60683. * Pushes an action to the worker pool. If all the workers are active, the action will be
  60684. * pended until a worker has completed its action.
  60685. * @param action The action to perform. Call onComplete when the action is complete.
  60686. */
  60687. push(action: (worker: Worker, onComplete: () => void) => void): void;
  60688. private _execute;
  60689. }
  60690. }
  60691. declare module "babylonjs/Misc/khronosTextureContainer2" {
  60692. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60693. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  60694. /**
  60695. * Class for loading KTX2 files
  60696. */
  60697. export class KhronosTextureContainer2 {
  60698. private static _WorkerPoolPromise?;
  60699. private static _Initialized;
  60700. private static _Ktx2Decoder;
  60701. /**
  60702. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  60703. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  60704. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  60705. * Urls you can change:
  60706. * URLConfig.jsDecoderModule
  60707. * URLConfig.wasmUASTCToASTC
  60708. * URLConfig.wasmUASTCToBC7
  60709. * URLConfig.jsMSCTranscoder
  60710. * URLConfig.wasmMSCTranscoder
  60711. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  60712. */
  60713. static URLConfig: {
  60714. jsDecoderModule: string;
  60715. wasmUASTCToASTC: null;
  60716. wasmUASTCToBC7: null;
  60717. jsMSCTranscoder: null;
  60718. wasmMSCTranscoder: null;
  60719. };
  60720. /**
  60721. * Default number of workers used to handle data decoding
  60722. */
  60723. static DefaultNumWorkers: number;
  60724. private static GetDefaultNumWorkers;
  60725. private _engine;
  60726. private static _CreateWorkerPool;
  60727. /**
  60728. * Constructor
  60729. * @param engine The engine to use
  60730. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  60731. */
  60732. constructor(engine: ThinEngine, numWorkers?: number);
  60733. /** @hidden */
  60734. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  60735. /**
  60736. * Stop all async operations and release resources.
  60737. */
  60738. dispose(): void;
  60739. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  60740. /**
  60741. * Checks if the given data starts with a KTX2 file identifier.
  60742. * @param data the data to check
  60743. * @returns true if the data is a KTX2 file or false otherwise
  60744. */
  60745. static IsValid(data: ArrayBufferView): boolean;
  60746. }
  60747. }
  60748. declare module "babylonjs/Materials/Textures/Loaders/ktxTextureLoader" {
  60749. import { Nullable } from "babylonjs/types";
  60750. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  60751. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  60752. /**
  60753. * Implementation of the KTX Texture Loader.
  60754. * @hidden
  60755. */
  60756. export class _KTXTextureLoader implements IInternalTextureLoader {
  60757. /**
  60758. * Defines wether the loader supports cascade loading the different faces.
  60759. */
  60760. readonly supportCascades: boolean;
  60761. /**
  60762. * This returns if the loader support the current file information.
  60763. * @param extension defines the file extension of the file being loaded
  60764. * @param mimeType defines the optional mime type of the file being loaded
  60765. * @returns true if the loader can load the specified file
  60766. */
  60767. canLoad(extension: string, mimeType?: string): boolean;
  60768. /**
  60769. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  60770. * @param data contains the texture data
  60771. * @param texture defines the BabylonJS internal texture
  60772. * @param createPolynomials will be true if polynomials have been requested
  60773. * @param onLoad defines the callback to trigger once the texture is ready
  60774. * @param onError defines the callback to trigger in case of error
  60775. */
  60776. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  60777. /**
  60778. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  60779. * @param data contains the texture data
  60780. * @param texture defines the BabylonJS internal texture
  60781. * @param callback defines the method to call once ready to upload
  60782. */
  60783. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  60784. }
  60785. }
  60786. declare module "babylonjs/Helpers/sceneHelpers" {
  60787. import { Nullable } from "babylonjs/types";
  60788. import { Mesh } from "babylonjs/Meshes/mesh";
  60789. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  60790. import { IEnvironmentHelperOptions, EnvironmentHelper } from "babylonjs/Helpers/environmentHelper";
  60791. import { VRExperienceHelperOptions, VRExperienceHelper } from "babylonjs/Cameras/VR/vrExperienceHelper";
  60792. import "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  60793. import "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  60794. import "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  60795. import "babylonjs/Meshes/Builders/boxBuilder";
  60796. import { WebXRDefaultExperience, WebXRDefaultExperienceOptions } from "babylonjs/XR/webXRDefaultExperience";
  60797. /** @hidden */
  60798. export var _forceSceneHelpersToBundle: boolean;
  60799. module "babylonjs/scene" {
  60800. interface Scene {
  60801. /**
  60802. * Creates a default light for the scene.
  60803. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  60804. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  60805. */
  60806. createDefaultLight(replace?: boolean): void;
  60807. /**
  60808. * Creates a default camera for the scene.
  60809. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  60810. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60811. * @param replace has default false, when true replaces the active camera in the scene
  60812. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  60813. */
  60814. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60815. /**
  60816. * Creates a default camera and a default light.
  60817. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  60818. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  60819. * @param replace has the default false, when true replaces the active camera/light in the scene
  60820. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  60821. */
  60822. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  60823. /**
  60824. * Creates a new sky box
  60825. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  60826. * @param environmentTexture defines the texture to use as environment texture
  60827. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  60828. * @param scale defines the overall scale of the skybox
  60829. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  60830. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  60831. * @returns a new mesh holding the sky box
  60832. */
  60833. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  60834. /**
  60835. * Creates a new environment
  60836. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  60837. * @param options defines the options you can use to configure the environment
  60838. * @returns the new EnvironmentHelper
  60839. */
  60840. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  60841. /**
  60842. * Creates a new VREXperienceHelper
  60843. * @see https://doc.babylonjs.com/how_to/webvr_helper
  60844. * @param webVROptions defines the options used to create the new VREXperienceHelper
  60845. * @returns a new VREXperienceHelper
  60846. */
  60847. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  60848. /**
  60849. * Creates a new WebXRDefaultExperience
  60850. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  60851. * @param options experience options
  60852. * @returns a promise for a new WebXRDefaultExperience
  60853. */
  60854. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  60855. }
  60856. }
  60857. }
  60858. declare module "babylonjs/Helpers/videoDome" {
  60859. import { Scene } from "babylonjs/scene";
  60860. import { VideoTexture } from "babylonjs/Materials/Textures/videoTexture";
  60861. import { TextureDome } from "babylonjs/Helpers/textureDome";
  60862. /**
  60863. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  60864. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  60865. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  60866. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  60867. */
  60868. export class VideoDome extends TextureDome<VideoTexture> {
  60869. /**
  60870. * Define the video source as a Monoscopic panoramic 360 video.
  60871. */
  60872. static readonly MODE_MONOSCOPIC: number;
  60873. /**
  60874. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  60875. */
  60876. static readonly MODE_TOPBOTTOM: number;
  60877. /**
  60878. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  60879. */
  60880. static readonly MODE_SIDEBYSIDE: number;
  60881. /**
  60882. * Get the video texture associated with this video dome
  60883. */
  60884. get videoTexture(): VideoTexture;
  60885. /**
  60886. * Get the video mode of this dome
  60887. */
  60888. get videoMode(): number;
  60889. /**
  60890. * Set the video mode of this dome.
  60891. * @see textureMode
  60892. */
  60893. set videoMode(value: number);
  60894. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  60895. }
  60896. }
  60897. declare module "babylonjs/Helpers/index" {
  60898. export * from "babylonjs/Helpers/environmentHelper";
  60899. export * from "babylonjs/Helpers/photoDome";
  60900. export * from "babylonjs/Helpers/sceneHelpers";
  60901. export * from "babylonjs/Helpers/videoDome";
  60902. }
  60903. declare module "babylonjs/Instrumentation/engineInstrumentation" {
  60904. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60905. import { IDisposable } from "babylonjs/scene";
  60906. import { Engine } from "babylonjs/Engines/engine";
  60907. /**
  60908. * This class can be used to get instrumentation data from a Babylon engine
  60909. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60910. */
  60911. export class EngineInstrumentation implements IDisposable {
  60912. /**
  60913. * Define the instrumented engine.
  60914. */
  60915. engine: Engine;
  60916. private _captureGPUFrameTime;
  60917. private _gpuFrameTimeToken;
  60918. private _gpuFrameTime;
  60919. private _captureShaderCompilationTime;
  60920. private _shaderCompilationTime;
  60921. private _onBeginFrameObserver;
  60922. private _onEndFrameObserver;
  60923. private _onBeforeShaderCompilationObserver;
  60924. private _onAfterShaderCompilationObserver;
  60925. /**
  60926. * Gets the perf counter used for GPU frame time
  60927. */
  60928. get gpuFrameTimeCounter(): PerfCounter;
  60929. /**
  60930. * Gets the GPU frame time capture status
  60931. */
  60932. get captureGPUFrameTime(): boolean;
  60933. /**
  60934. * Enable or disable the GPU frame time capture
  60935. */
  60936. set captureGPUFrameTime(value: boolean);
  60937. /**
  60938. * Gets the perf counter used for shader compilation time
  60939. */
  60940. get shaderCompilationTimeCounter(): PerfCounter;
  60941. /**
  60942. * Gets the shader compilation time capture status
  60943. */
  60944. get captureShaderCompilationTime(): boolean;
  60945. /**
  60946. * Enable or disable the shader compilation time capture
  60947. */
  60948. set captureShaderCompilationTime(value: boolean);
  60949. /**
  60950. * Instantiates a new engine instrumentation.
  60951. * This class can be used to get instrumentation data from a Babylon engine
  60952. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  60953. * @param engine Defines the engine to instrument
  60954. */
  60955. constructor(
  60956. /**
  60957. * Define the instrumented engine.
  60958. */
  60959. engine: Engine);
  60960. /**
  60961. * Dispose and release associated resources.
  60962. */
  60963. dispose(): void;
  60964. }
  60965. }
  60966. declare module "babylonjs/Instrumentation/sceneInstrumentation" {
  60967. import { Scene, IDisposable } from "babylonjs/scene";
  60968. import { PerfCounter } from "babylonjs/Misc/perfCounter";
  60969. /**
  60970. * This class can be used to get instrumentation data from a Babylon engine
  60971. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  60972. */
  60973. export class SceneInstrumentation implements IDisposable {
  60974. /**
  60975. * Defines the scene to instrument
  60976. */
  60977. scene: Scene;
  60978. private _captureActiveMeshesEvaluationTime;
  60979. private _activeMeshesEvaluationTime;
  60980. private _captureRenderTargetsRenderTime;
  60981. private _renderTargetsRenderTime;
  60982. private _captureFrameTime;
  60983. private _frameTime;
  60984. private _captureRenderTime;
  60985. private _renderTime;
  60986. private _captureInterFrameTime;
  60987. private _interFrameTime;
  60988. private _captureParticlesRenderTime;
  60989. private _particlesRenderTime;
  60990. private _captureSpritesRenderTime;
  60991. private _spritesRenderTime;
  60992. private _capturePhysicsTime;
  60993. private _physicsTime;
  60994. private _captureAnimationsTime;
  60995. private _animationsTime;
  60996. private _captureCameraRenderTime;
  60997. private _cameraRenderTime;
  60998. private _onBeforeActiveMeshesEvaluationObserver;
  60999. private _onAfterActiveMeshesEvaluationObserver;
  61000. private _onBeforeRenderTargetsRenderObserver;
  61001. private _onAfterRenderTargetsRenderObserver;
  61002. private _onAfterRenderObserver;
  61003. private _onBeforeDrawPhaseObserver;
  61004. private _onAfterDrawPhaseObserver;
  61005. private _onBeforeAnimationsObserver;
  61006. private _onBeforeParticlesRenderingObserver;
  61007. private _onAfterParticlesRenderingObserver;
  61008. private _onBeforeSpritesRenderingObserver;
  61009. private _onAfterSpritesRenderingObserver;
  61010. private _onBeforePhysicsObserver;
  61011. private _onAfterPhysicsObserver;
  61012. private _onAfterAnimationsObserver;
  61013. private _onBeforeCameraRenderObserver;
  61014. private _onAfterCameraRenderObserver;
  61015. /**
  61016. * Gets the perf counter used for active meshes evaluation time
  61017. */
  61018. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  61019. /**
  61020. * Gets the active meshes evaluation time capture status
  61021. */
  61022. get captureActiveMeshesEvaluationTime(): boolean;
  61023. /**
  61024. * Enable or disable the active meshes evaluation time capture
  61025. */
  61026. set captureActiveMeshesEvaluationTime(value: boolean);
  61027. /**
  61028. * Gets the perf counter used for render targets render time
  61029. */
  61030. get renderTargetsRenderTimeCounter(): PerfCounter;
  61031. /**
  61032. * Gets the render targets render time capture status
  61033. */
  61034. get captureRenderTargetsRenderTime(): boolean;
  61035. /**
  61036. * Enable or disable the render targets render time capture
  61037. */
  61038. set captureRenderTargetsRenderTime(value: boolean);
  61039. /**
  61040. * Gets the perf counter used for particles render time
  61041. */
  61042. get particlesRenderTimeCounter(): PerfCounter;
  61043. /**
  61044. * Gets the particles render time capture status
  61045. */
  61046. get captureParticlesRenderTime(): boolean;
  61047. /**
  61048. * Enable or disable the particles render time capture
  61049. */
  61050. set captureParticlesRenderTime(value: boolean);
  61051. /**
  61052. * Gets the perf counter used for sprites render time
  61053. */
  61054. get spritesRenderTimeCounter(): PerfCounter;
  61055. /**
  61056. * Gets the sprites render time capture status
  61057. */
  61058. get captureSpritesRenderTime(): boolean;
  61059. /**
  61060. * Enable or disable the sprites render time capture
  61061. */
  61062. set captureSpritesRenderTime(value: boolean);
  61063. /**
  61064. * Gets the perf counter used for physics time
  61065. */
  61066. get physicsTimeCounter(): PerfCounter;
  61067. /**
  61068. * Gets the physics time capture status
  61069. */
  61070. get capturePhysicsTime(): boolean;
  61071. /**
  61072. * Enable or disable the physics time capture
  61073. */
  61074. set capturePhysicsTime(value: boolean);
  61075. /**
  61076. * Gets the perf counter used for animations time
  61077. */
  61078. get animationsTimeCounter(): PerfCounter;
  61079. /**
  61080. * Gets the animations time capture status
  61081. */
  61082. get captureAnimationsTime(): boolean;
  61083. /**
  61084. * Enable or disable the animations time capture
  61085. */
  61086. set captureAnimationsTime(value: boolean);
  61087. /**
  61088. * Gets the perf counter used for frame time capture
  61089. */
  61090. get frameTimeCounter(): PerfCounter;
  61091. /**
  61092. * Gets the frame time capture status
  61093. */
  61094. get captureFrameTime(): boolean;
  61095. /**
  61096. * Enable or disable the frame time capture
  61097. */
  61098. set captureFrameTime(value: boolean);
  61099. /**
  61100. * Gets the perf counter used for inter-frames time capture
  61101. */
  61102. get interFrameTimeCounter(): PerfCounter;
  61103. /**
  61104. * Gets the inter-frames time capture status
  61105. */
  61106. get captureInterFrameTime(): boolean;
  61107. /**
  61108. * Enable or disable the inter-frames time capture
  61109. */
  61110. set captureInterFrameTime(value: boolean);
  61111. /**
  61112. * Gets the perf counter used for render time capture
  61113. */
  61114. get renderTimeCounter(): PerfCounter;
  61115. /**
  61116. * Gets the render time capture status
  61117. */
  61118. get captureRenderTime(): boolean;
  61119. /**
  61120. * Enable or disable the render time capture
  61121. */
  61122. set captureRenderTime(value: boolean);
  61123. /**
  61124. * Gets the perf counter used for camera render time capture
  61125. */
  61126. get cameraRenderTimeCounter(): PerfCounter;
  61127. /**
  61128. * Gets the camera render time capture status
  61129. */
  61130. get captureCameraRenderTime(): boolean;
  61131. /**
  61132. * Enable or disable the camera render time capture
  61133. */
  61134. set captureCameraRenderTime(value: boolean);
  61135. /**
  61136. * Gets the perf counter used for draw calls
  61137. */
  61138. get drawCallsCounter(): PerfCounter;
  61139. /**
  61140. * Instantiates a new scene instrumentation.
  61141. * This class can be used to get instrumentation data from a Babylon engine
  61142. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  61143. * @param scene Defines the scene to instrument
  61144. */
  61145. constructor(
  61146. /**
  61147. * Defines the scene to instrument
  61148. */
  61149. scene: Scene);
  61150. /**
  61151. * Dispose and release associated resources.
  61152. */
  61153. dispose(): void;
  61154. }
  61155. }
  61156. declare module "babylonjs/Instrumentation/index" {
  61157. export * from "babylonjs/Instrumentation/engineInstrumentation";
  61158. export * from "babylonjs/Instrumentation/sceneInstrumentation";
  61159. export * from "babylonjs/Instrumentation/timeToken";
  61160. }
  61161. declare module "babylonjs/Shaders/glowMapGeneration.fragment" {
  61162. /** @hidden */
  61163. export var glowMapGenerationPixelShader: {
  61164. name: string;
  61165. shader: string;
  61166. };
  61167. }
  61168. declare module "babylonjs/Shaders/glowMapGeneration.vertex" {
  61169. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  61170. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  61171. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  61172. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  61173. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  61174. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  61175. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  61176. /** @hidden */
  61177. export var glowMapGenerationVertexShader: {
  61178. name: string;
  61179. shader: string;
  61180. };
  61181. }
  61182. declare module "babylonjs/Layers/effectLayer" {
  61183. import { Observable } from "babylonjs/Misc/observable";
  61184. import { Nullable } from "babylonjs/types";
  61185. import { Camera } from "babylonjs/Cameras/camera";
  61186. import { Scene } from "babylonjs/scene";
  61187. import { ISize } from "babylonjs/Maths/math.size";
  61188. import { Color4 } from "babylonjs/Maths/math.color";
  61189. import { Engine } from "babylonjs/Engines/engine";
  61190. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61191. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61192. import { Mesh } from "babylonjs/Meshes/mesh";
  61193. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  61194. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  61195. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  61196. import { Effect } from "babylonjs/Materials/effect";
  61197. import { Material } from "babylonjs/Materials/material";
  61198. import "babylonjs/Shaders/glowMapGeneration.fragment";
  61199. import "babylonjs/Shaders/glowMapGeneration.vertex";
  61200. /**
  61201. * Effect layer options. This helps customizing the behaviour
  61202. * of the effect layer.
  61203. */
  61204. export interface IEffectLayerOptions {
  61205. /**
  61206. * Multiplication factor apply to the canvas size to compute the render target size
  61207. * used to generated the objects (the smaller the faster).
  61208. */
  61209. mainTextureRatio: number;
  61210. /**
  61211. * Enforces a fixed size texture to ensure effect stability across devices.
  61212. */
  61213. mainTextureFixedSize?: number;
  61214. /**
  61215. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  61216. */
  61217. alphaBlendingMode: number;
  61218. /**
  61219. * The camera attached to the layer.
  61220. */
  61221. camera: Nullable<Camera>;
  61222. /**
  61223. * The rendering group to draw the layer in.
  61224. */
  61225. renderingGroupId: number;
  61226. }
  61227. /**
  61228. * The effect layer Helps adding post process effect blended with the main pass.
  61229. *
  61230. * This can be for instance use to generate glow or higlight effects on the scene.
  61231. *
  61232. * The effect layer class can not be used directly and is intented to inherited from to be
  61233. * customized per effects.
  61234. */
  61235. export abstract class EffectLayer {
  61236. private _vertexBuffers;
  61237. private _indexBuffer;
  61238. private _cachedDefines;
  61239. private _effectLayerMapGenerationEffect;
  61240. private _effectLayerOptions;
  61241. private _mergeEffect;
  61242. protected _scene: Scene;
  61243. protected _engine: Engine;
  61244. protected _maxSize: number;
  61245. protected _mainTextureDesiredSize: ISize;
  61246. protected _mainTexture: RenderTargetTexture;
  61247. protected _shouldRender: boolean;
  61248. protected _postProcesses: PostProcess[];
  61249. protected _textures: BaseTexture[];
  61250. protected _emissiveTextureAndColor: {
  61251. texture: Nullable<BaseTexture>;
  61252. color: Color4;
  61253. };
  61254. /**
  61255. * The name of the layer
  61256. */
  61257. name: string;
  61258. /**
  61259. * The clear color of the texture used to generate the glow map.
  61260. */
  61261. neutralColor: Color4;
  61262. /**
  61263. * Specifies whether the highlight layer is enabled or not.
  61264. */
  61265. isEnabled: boolean;
  61266. /**
  61267. * Gets the camera attached to the layer.
  61268. */
  61269. get camera(): Nullable<Camera>;
  61270. /**
  61271. * Gets the rendering group id the layer should render in.
  61272. */
  61273. get renderingGroupId(): number;
  61274. set renderingGroupId(renderingGroupId: number);
  61275. /**
  61276. * An event triggered when the effect layer has been disposed.
  61277. */
  61278. onDisposeObservable: Observable<EffectLayer>;
  61279. /**
  61280. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  61281. */
  61282. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  61283. /**
  61284. * An event triggered when the generated texture is being merged in the scene.
  61285. */
  61286. onBeforeComposeObservable: Observable<EffectLayer>;
  61287. /**
  61288. * An event triggered when the mesh is rendered into the effect render target.
  61289. */
  61290. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  61291. /**
  61292. * An event triggered after the mesh has been rendered into the effect render target.
  61293. */
  61294. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  61295. /**
  61296. * An event triggered when the generated texture has been merged in the scene.
  61297. */
  61298. onAfterComposeObservable: Observable<EffectLayer>;
  61299. /**
  61300. * An event triggered when the efffect layer changes its size.
  61301. */
  61302. onSizeChangedObservable: Observable<EffectLayer>;
  61303. /** @hidden */
  61304. static _SceneComponentInitialization: (scene: Scene) => void;
  61305. /**
  61306. * Instantiates a new effect Layer and references it in the scene.
  61307. * @param name The name of the layer
  61308. * @param scene The scene to use the layer in
  61309. */
  61310. constructor(
  61311. /** The Friendly of the effect in the scene */
  61312. name: string, scene: Scene);
  61313. /**
  61314. * Get the effect name of the layer.
  61315. * @return The effect name
  61316. */
  61317. abstract getEffectName(): string;
  61318. /**
  61319. * Checks for the readiness of the element composing the layer.
  61320. * @param subMesh the mesh to check for
  61321. * @param useInstances specify whether or not to use instances to render the mesh
  61322. * @return true if ready otherwise, false
  61323. */
  61324. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61325. /**
  61326. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61327. * @returns true if the effect requires stencil during the main canvas render pass.
  61328. */
  61329. abstract needStencil(): boolean;
  61330. /**
  61331. * Create the merge effect. This is the shader use to blit the information back
  61332. * to the main canvas at the end of the scene rendering.
  61333. * @returns The effect containing the shader used to merge the effect on the main canvas
  61334. */
  61335. protected abstract _createMergeEffect(): Effect;
  61336. /**
  61337. * Creates the render target textures and post processes used in the effect layer.
  61338. */
  61339. protected abstract _createTextureAndPostProcesses(): void;
  61340. /**
  61341. * Implementation specific of rendering the generating effect on the main canvas.
  61342. * @param effect The effect used to render through
  61343. */
  61344. protected abstract _internalRender(effect: Effect): void;
  61345. /**
  61346. * Sets the required values for both the emissive texture and and the main color.
  61347. */
  61348. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61349. /**
  61350. * Free any resources and references associated to a mesh.
  61351. * Internal use
  61352. * @param mesh The mesh to free.
  61353. */
  61354. abstract _disposeMesh(mesh: Mesh): void;
  61355. /**
  61356. * Serializes this layer (Glow or Highlight for example)
  61357. * @returns a serialized layer object
  61358. */
  61359. abstract serialize?(): any;
  61360. /**
  61361. * Initializes the effect layer with the required options.
  61362. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  61363. */
  61364. protected _init(options: Partial<IEffectLayerOptions>): void;
  61365. /**
  61366. * Generates the index buffer of the full screen quad blending to the main canvas.
  61367. */
  61368. private _generateIndexBuffer;
  61369. /**
  61370. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  61371. */
  61372. private _generateVertexBuffer;
  61373. /**
  61374. * Sets the main texture desired size which is the closest power of two
  61375. * of the engine canvas size.
  61376. */
  61377. private _setMainTextureSize;
  61378. /**
  61379. * Creates the main texture for the effect layer.
  61380. */
  61381. protected _createMainTexture(): void;
  61382. /**
  61383. * Adds specific effects defines.
  61384. * @param defines The defines to add specifics to.
  61385. */
  61386. protected _addCustomEffectDefines(defines: string[]): void;
  61387. /**
  61388. * Checks for the readiness of the element composing the layer.
  61389. * @param subMesh the mesh to check for
  61390. * @param useInstances specify whether or not to use instances to render the mesh
  61391. * @param emissiveTexture the associated emissive texture used to generate the glow
  61392. * @return true if ready otherwise, false
  61393. */
  61394. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  61395. /**
  61396. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  61397. */
  61398. render(): void;
  61399. /**
  61400. * Determine if a given mesh will be used in the current effect.
  61401. * @param mesh mesh to test
  61402. * @returns true if the mesh will be used
  61403. */
  61404. hasMesh(mesh: AbstractMesh): boolean;
  61405. /**
  61406. * Returns true if the layer contains information to display, otherwise false.
  61407. * @returns true if the glow layer should be rendered
  61408. */
  61409. shouldRender(): boolean;
  61410. /**
  61411. * Returns true if the mesh should render, otherwise false.
  61412. * @param mesh The mesh to render
  61413. * @returns true if it should render otherwise false
  61414. */
  61415. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  61416. /**
  61417. * Returns true if the mesh can be rendered, otherwise false.
  61418. * @param mesh The mesh to render
  61419. * @param material The material used on the mesh
  61420. * @returns true if it can be rendered otherwise false
  61421. */
  61422. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61423. /**
  61424. * Returns true if the mesh should render, otherwise false.
  61425. * @param mesh The mesh to render
  61426. * @returns true if it should render otherwise false
  61427. */
  61428. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  61429. /**
  61430. * Renders the submesh passed in parameter to the generation map.
  61431. */
  61432. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  61433. /**
  61434. * Defines whether the current material of the mesh should be use to render the effect.
  61435. * @param mesh defines the current mesh to render
  61436. */
  61437. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61438. /**
  61439. * Rebuild the required buffers.
  61440. * @hidden Internal use only.
  61441. */
  61442. _rebuild(): void;
  61443. /**
  61444. * Dispose only the render target textures and post process.
  61445. */
  61446. private _disposeTextureAndPostProcesses;
  61447. /**
  61448. * Dispose the highlight layer and free resources.
  61449. */
  61450. dispose(): void;
  61451. /**
  61452. * Gets the class name of the effect layer
  61453. * @returns the string with the class name of the effect layer
  61454. */
  61455. getClassName(): string;
  61456. /**
  61457. * Creates an effect layer from parsed effect layer data
  61458. * @param parsedEffectLayer defines effect layer data
  61459. * @param scene defines the current scene
  61460. * @param rootUrl defines the root URL containing the effect layer information
  61461. * @returns a parsed effect Layer
  61462. */
  61463. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  61464. }
  61465. }
  61466. declare module "babylonjs/Layers/effectLayerSceneComponent" {
  61467. import { Scene } from "babylonjs/scene";
  61468. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  61469. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61470. import { AbstractScene } from "babylonjs/abstractScene";
  61471. module "babylonjs/abstractScene" {
  61472. interface AbstractScene {
  61473. /**
  61474. * The list of effect layers (highlights/glow) added to the scene
  61475. * @see https://doc.babylonjs.com/how_to/highlight_layer
  61476. * @see https://doc.babylonjs.com/how_to/glow_layer
  61477. */
  61478. effectLayers: Array<EffectLayer>;
  61479. /**
  61480. * Removes the given effect layer from this scene.
  61481. * @param toRemove defines the effect layer to remove
  61482. * @returns the index of the removed effect layer
  61483. */
  61484. removeEffectLayer(toRemove: EffectLayer): number;
  61485. /**
  61486. * Adds the given effect layer to this scene
  61487. * @param newEffectLayer defines the effect layer to add
  61488. */
  61489. addEffectLayer(newEffectLayer: EffectLayer): void;
  61490. }
  61491. }
  61492. /**
  61493. * Defines the layer scene component responsible to manage any effect layers
  61494. * in a given scene.
  61495. */
  61496. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  61497. /**
  61498. * The component name helpfull to identify the component in the list of scene components.
  61499. */
  61500. readonly name: string;
  61501. /**
  61502. * The scene the component belongs to.
  61503. */
  61504. scene: Scene;
  61505. private _engine;
  61506. private _renderEffects;
  61507. private _needStencil;
  61508. private _previousStencilState;
  61509. /**
  61510. * Creates a new instance of the component for the given scene
  61511. * @param scene Defines the scene to register the component in
  61512. */
  61513. constructor(scene: Scene);
  61514. /**
  61515. * Registers the component in a given scene
  61516. */
  61517. register(): void;
  61518. /**
  61519. * Rebuilds the elements related to this component in case of
  61520. * context lost for instance.
  61521. */
  61522. rebuild(): void;
  61523. /**
  61524. * Serializes the component data to the specified json object
  61525. * @param serializationObject The object to serialize to
  61526. */
  61527. serialize(serializationObject: any): void;
  61528. /**
  61529. * Adds all the elements from the container to the scene
  61530. * @param container the container holding the elements
  61531. */
  61532. addFromContainer(container: AbstractScene): void;
  61533. /**
  61534. * Removes all the elements in the container from the scene
  61535. * @param container contains the elements to remove
  61536. * @param dispose if the removed element should be disposed (default: false)
  61537. */
  61538. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  61539. /**
  61540. * Disposes the component and the associated ressources.
  61541. */
  61542. dispose(): void;
  61543. private _isReadyForMesh;
  61544. private _renderMainTexture;
  61545. private _setStencil;
  61546. private _setStencilBack;
  61547. private _draw;
  61548. private _drawCamera;
  61549. private _drawRenderingGroup;
  61550. }
  61551. }
  61552. declare module "babylonjs/Shaders/glowMapMerge.fragment" {
  61553. /** @hidden */
  61554. export var glowMapMergePixelShader: {
  61555. name: string;
  61556. shader: string;
  61557. };
  61558. }
  61559. declare module "babylonjs/Shaders/glowMapMerge.vertex" {
  61560. /** @hidden */
  61561. export var glowMapMergeVertexShader: {
  61562. name: string;
  61563. shader: string;
  61564. };
  61565. }
  61566. declare module "babylonjs/Layers/glowLayer" {
  61567. import { Nullable } from "babylonjs/types";
  61568. import { Camera } from "babylonjs/Cameras/camera";
  61569. import { Scene } from "babylonjs/scene";
  61570. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61571. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61572. import { Mesh } from "babylonjs/Meshes/mesh";
  61573. import { Texture } from "babylonjs/Materials/Textures/texture";
  61574. import { Effect } from "babylonjs/Materials/effect";
  61575. import { Material } from "babylonjs/Materials/material";
  61576. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61577. import { Color4 } from "babylonjs/Maths/math.color";
  61578. import "babylonjs/Shaders/glowMapMerge.fragment";
  61579. import "babylonjs/Shaders/glowMapMerge.vertex";
  61580. import "babylonjs/Layers/effectLayerSceneComponent";
  61581. module "babylonjs/abstractScene" {
  61582. interface AbstractScene {
  61583. /**
  61584. * Return a the first highlight layer of the scene with a given name.
  61585. * @param name The name of the highlight layer to look for.
  61586. * @return The highlight layer if found otherwise null.
  61587. */
  61588. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  61589. }
  61590. }
  61591. /**
  61592. * Glow layer options. This helps customizing the behaviour
  61593. * of the glow layer.
  61594. */
  61595. export interface IGlowLayerOptions {
  61596. /**
  61597. * Multiplication factor apply to the canvas size to compute the render target size
  61598. * used to generated the glowing objects (the smaller the faster).
  61599. */
  61600. mainTextureRatio: number;
  61601. /**
  61602. * Enforces a fixed size texture to ensure resize independant blur.
  61603. */
  61604. mainTextureFixedSize?: number;
  61605. /**
  61606. * How big is the kernel of the blur texture.
  61607. */
  61608. blurKernelSize: number;
  61609. /**
  61610. * The camera attached to the layer.
  61611. */
  61612. camera: Nullable<Camera>;
  61613. /**
  61614. * Enable MSAA by chosing the number of samples.
  61615. */
  61616. mainTextureSamples?: number;
  61617. /**
  61618. * The rendering group to draw the layer in.
  61619. */
  61620. renderingGroupId: number;
  61621. }
  61622. /**
  61623. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  61624. *
  61625. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  61626. *
  61627. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  61628. */
  61629. export class GlowLayer extends EffectLayer {
  61630. /**
  61631. * Effect Name of the layer.
  61632. */
  61633. static readonly EffectName: string;
  61634. /**
  61635. * The default blur kernel size used for the glow.
  61636. */
  61637. static DefaultBlurKernelSize: number;
  61638. /**
  61639. * The default texture size ratio used for the glow.
  61640. */
  61641. static DefaultTextureRatio: number;
  61642. /**
  61643. * Sets the kernel size of the blur.
  61644. */
  61645. set blurKernelSize(value: number);
  61646. /**
  61647. * Gets the kernel size of the blur.
  61648. */
  61649. get blurKernelSize(): number;
  61650. /**
  61651. * Sets the glow intensity.
  61652. */
  61653. set intensity(value: number);
  61654. /**
  61655. * Gets the glow intensity.
  61656. */
  61657. get intensity(): number;
  61658. private _options;
  61659. private _intensity;
  61660. private _horizontalBlurPostprocess1;
  61661. private _verticalBlurPostprocess1;
  61662. private _horizontalBlurPostprocess2;
  61663. private _verticalBlurPostprocess2;
  61664. private _blurTexture1;
  61665. private _blurTexture2;
  61666. private _postProcesses1;
  61667. private _postProcesses2;
  61668. private _includedOnlyMeshes;
  61669. private _excludedMeshes;
  61670. private _meshesUsingTheirOwnMaterials;
  61671. /**
  61672. * Callback used to let the user override the color selection on a per mesh basis
  61673. */
  61674. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  61675. /**
  61676. * Callback used to let the user override the texture selection on a per mesh basis
  61677. */
  61678. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  61679. /**
  61680. * Instantiates a new glow Layer and references it to the scene.
  61681. * @param name The name of the layer
  61682. * @param scene The scene to use the layer in
  61683. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  61684. */
  61685. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  61686. /**
  61687. * Get the effect name of the layer.
  61688. * @return The effect name
  61689. */
  61690. getEffectName(): string;
  61691. /**
  61692. * Create the merge effect. This is the shader use to blit the information back
  61693. * to the main canvas at the end of the scene rendering.
  61694. */
  61695. protected _createMergeEffect(): Effect;
  61696. /**
  61697. * Creates the render target textures and post processes used in the glow layer.
  61698. */
  61699. protected _createTextureAndPostProcesses(): void;
  61700. /**
  61701. * Checks for the readiness of the element composing the layer.
  61702. * @param subMesh the mesh to check for
  61703. * @param useInstances specify wether or not to use instances to render the mesh
  61704. * @param emissiveTexture the associated emissive texture used to generate the glow
  61705. * @return true if ready otherwise, false
  61706. */
  61707. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61708. /**
  61709. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  61710. */
  61711. needStencil(): boolean;
  61712. /**
  61713. * Returns true if the mesh can be rendered, otherwise false.
  61714. * @param mesh The mesh to render
  61715. * @param material The material used on the mesh
  61716. * @returns true if it can be rendered otherwise false
  61717. */
  61718. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  61719. /**
  61720. * Implementation specific of rendering the generating effect on the main canvas.
  61721. * @param effect The effect used to render through
  61722. */
  61723. protected _internalRender(effect: Effect): void;
  61724. /**
  61725. * Sets the required values for both the emissive texture and and the main color.
  61726. */
  61727. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  61728. /**
  61729. * Returns true if the mesh should render, otherwise false.
  61730. * @param mesh The mesh to render
  61731. * @returns true if it should render otherwise false
  61732. */
  61733. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61734. /**
  61735. * Adds specific effects defines.
  61736. * @param defines The defines to add specifics to.
  61737. */
  61738. protected _addCustomEffectDefines(defines: string[]): void;
  61739. /**
  61740. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  61741. * @param mesh The mesh to exclude from the glow layer
  61742. */
  61743. addExcludedMesh(mesh: Mesh): void;
  61744. /**
  61745. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  61746. * @param mesh The mesh to remove
  61747. */
  61748. removeExcludedMesh(mesh: Mesh): void;
  61749. /**
  61750. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  61751. * @param mesh The mesh to include in the glow layer
  61752. */
  61753. addIncludedOnlyMesh(mesh: Mesh): void;
  61754. /**
  61755. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  61756. * @param mesh The mesh to remove
  61757. */
  61758. removeIncludedOnlyMesh(mesh: Mesh): void;
  61759. /**
  61760. * Determine if a given mesh will be used in the glow layer
  61761. * @param mesh The mesh to test
  61762. * @returns true if the mesh will be highlighted by the current glow layer
  61763. */
  61764. hasMesh(mesh: AbstractMesh): boolean;
  61765. /**
  61766. * Defines whether the current material of the mesh should be use to render the effect.
  61767. * @param mesh defines the current mesh to render
  61768. */
  61769. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  61770. /**
  61771. * Add a mesh to be rendered through its own material and not with emissive only.
  61772. * @param mesh The mesh for which we need to use its material
  61773. */
  61774. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  61775. /**
  61776. * Remove a mesh from being rendered through its own material and not with emissive only.
  61777. * @param mesh The mesh for which we need to not use its material
  61778. */
  61779. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  61780. /**
  61781. * Free any resources and references associated to a mesh.
  61782. * Internal use
  61783. * @param mesh The mesh to free.
  61784. * @hidden
  61785. */
  61786. _disposeMesh(mesh: Mesh): void;
  61787. /**
  61788. * Gets the class name of the effect layer
  61789. * @returns the string with the class name of the effect layer
  61790. */
  61791. getClassName(): string;
  61792. /**
  61793. * Serializes this glow layer
  61794. * @returns a serialized glow layer object
  61795. */
  61796. serialize(): any;
  61797. /**
  61798. * Creates a Glow Layer from parsed glow layer data
  61799. * @param parsedGlowLayer defines glow layer data
  61800. * @param scene defines the current scene
  61801. * @param rootUrl defines the root URL containing the glow layer information
  61802. * @returns a parsed Glow Layer
  61803. */
  61804. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  61805. }
  61806. }
  61807. declare module "babylonjs/Shaders/glowBlurPostProcess.fragment" {
  61808. /** @hidden */
  61809. export var glowBlurPostProcessPixelShader: {
  61810. name: string;
  61811. shader: string;
  61812. };
  61813. }
  61814. declare module "babylonjs/Layers/highlightLayer" {
  61815. import { Observable } from "babylonjs/Misc/observable";
  61816. import { Nullable } from "babylonjs/types";
  61817. import { Camera } from "babylonjs/Cameras/camera";
  61818. import { Scene } from "babylonjs/scene";
  61819. import { SubMesh } from "babylonjs/Meshes/subMesh";
  61820. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  61821. import { Mesh } from "babylonjs/Meshes/mesh";
  61822. import { Effect } from "babylonjs/Materials/effect";
  61823. import { Material } from "babylonjs/Materials/material";
  61824. import { EffectLayer } from "babylonjs/Layers/effectLayer";
  61825. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  61826. import "babylonjs/Shaders/glowMapMerge.fragment";
  61827. import "babylonjs/Shaders/glowMapMerge.vertex";
  61828. import "babylonjs/Shaders/glowBlurPostProcess.fragment";
  61829. module "babylonjs/abstractScene" {
  61830. interface AbstractScene {
  61831. /**
  61832. * Return a the first highlight layer of the scene with a given name.
  61833. * @param name The name of the highlight layer to look for.
  61834. * @return The highlight layer if found otherwise null.
  61835. */
  61836. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  61837. }
  61838. }
  61839. /**
  61840. * Highlight layer options. This helps customizing the behaviour
  61841. * of the highlight layer.
  61842. */
  61843. export interface IHighlightLayerOptions {
  61844. /**
  61845. * Multiplication factor apply to the canvas size to compute the render target size
  61846. * used to generated the glowing objects (the smaller the faster).
  61847. */
  61848. mainTextureRatio: number;
  61849. /**
  61850. * Enforces a fixed size texture to ensure resize independant blur.
  61851. */
  61852. mainTextureFixedSize?: number;
  61853. /**
  61854. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  61855. * of the picture to blur (the smaller the faster).
  61856. */
  61857. blurTextureSizeRatio: number;
  61858. /**
  61859. * How big in texel of the blur texture is the vertical blur.
  61860. */
  61861. blurVerticalSize: number;
  61862. /**
  61863. * How big in texel of the blur texture is the horizontal blur.
  61864. */
  61865. blurHorizontalSize: number;
  61866. /**
  61867. * Alpha blending mode used to apply the blur. Default is combine.
  61868. */
  61869. alphaBlendingMode: number;
  61870. /**
  61871. * The camera attached to the layer.
  61872. */
  61873. camera: Nullable<Camera>;
  61874. /**
  61875. * Should we display highlight as a solid stroke?
  61876. */
  61877. isStroke?: boolean;
  61878. /**
  61879. * The rendering group to draw the layer in.
  61880. */
  61881. renderingGroupId: number;
  61882. }
  61883. /**
  61884. * The highlight layer Helps adding a glow effect around a mesh.
  61885. *
  61886. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  61887. * glowy meshes to your scene.
  61888. *
  61889. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  61890. */
  61891. export class HighlightLayer extends EffectLayer {
  61892. name: string;
  61893. /**
  61894. * Effect Name of the highlight layer.
  61895. */
  61896. static readonly EffectName: string;
  61897. /**
  61898. * The neutral color used during the preparation of the glow effect.
  61899. * This is black by default as the blend operation is a blend operation.
  61900. */
  61901. static NeutralColor: Color4;
  61902. /**
  61903. * Stencil value used for glowing meshes.
  61904. */
  61905. static GlowingMeshStencilReference: number;
  61906. /**
  61907. * Stencil value used for the other meshes in the scene.
  61908. */
  61909. static NormalMeshStencilReference: number;
  61910. /**
  61911. * Specifies whether or not the inner glow is ACTIVE in the layer.
  61912. */
  61913. innerGlow: boolean;
  61914. /**
  61915. * Specifies whether or not the outer glow is ACTIVE in the layer.
  61916. */
  61917. outerGlow: boolean;
  61918. /**
  61919. * Specifies the horizontal size of the blur.
  61920. */
  61921. set blurHorizontalSize(value: number);
  61922. /**
  61923. * Specifies the vertical size of the blur.
  61924. */
  61925. set blurVerticalSize(value: number);
  61926. /**
  61927. * Gets the horizontal size of the blur.
  61928. */
  61929. get blurHorizontalSize(): number;
  61930. /**
  61931. * Gets the vertical size of the blur.
  61932. */
  61933. get blurVerticalSize(): number;
  61934. /**
  61935. * An event triggered when the highlight layer is being blurred.
  61936. */
  61937. onBeforeBlurObservable: Observable<HighlightLayer>;
  61938. /**
  61939. * An event triggered when the highlight layer has been blurred.
  61940. */
  61941. onAfterBlurObservable: Observable<HighlightLayer>;
  61942. private _instanceGlowingMeshStencilReference;
  61943. private _options;
  61944. private _downSamplePostprocess;
  61945. private _horizontalBlurPostprocess;
  61946. private _verticalBlurPostprocess;
  61947. private _blurTexture;
  61948. private _meshes;
  61949. private _excludedMeshes;
  61950. /**
  61951. * Instantiates a new highlight Layer and references it to the scene..
  61952. * @param name The name of the layer
  61953. * @param scene The scene to use the layer in
  61954. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  61955. */
  61956. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  61957. /**
  61958. * Get the effect name of the layer.
  61959. * @return The effect name
  61960. */
  61961. getEffectName(): string;
  61962. /**
  61963. * Create the merge effect. This is the shader use to blit the information back
  61964. * to the main canvas at the end of the scene rendering.
  61965. */
  61966. protected _createMergeEffect(): Effect;
  61967. /**
  61968. * Creates the render target textures and post processes used in the highlight layer.
  61969. */
  61970. protected _createTextureAndPostProcesses(): void;
  61971. /**
  61972. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  61973. */
  61974. needStencil(): boolean;
  61975. /**
  61976. * Checks for the readiness of the element composing the layer.
  61977. * @param subMesh the mesh to check for
  61978. * @param useInstances specify wether or not to use instances to render the mesh
  61979. * @param emissiveTexture the associated emissive texture used to generate the glow
  61980. * @return true if ready otherwise, false
  61981. */
  61982. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  61983. /**
  61984. * Implementation specific of rendering the generating effect on the main canvas.
  61985. * @param effect The effect used to render through
  61986. */
  61987. protected _internalRender(effect: Effect): void;
  61988. /**
  61989. * Returns true if the layer contains information to display, otherwise false.
  61990. */
  61991. shouldRender(): boolean;
  61992. /**
  61993. * Returns true if the mesh should render, otherwise false.
  61994. * @param mesh The mesh to render
  61995. * @returns true if it should render otherwise false
  61996. */
  61997. protected _shouldRenderMesh(mesh: Mesh): boolean;
  61998. /**
  61999. * Returns true if the mesh can be rendered, otherwise false.
  62000. * @param mesh The mesh to render
  62001. * @param material The material used on the mesh
  62002. * @returns true if it can be rendered otherwise false
  62003. */
  62004. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  62005. /**
  62006. * Adds specific effects defines.
  62007. * @param defines The defines to add specifics to.
  62008. */
  62009. protected _addCustomEffectDefines(defines: string[]): void;
  62010. /**
  62011. * Sets the required values for both the emissive texture and and the main color.
  62012. */
  62013. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  62014. /**
  62015. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  62016. * @param mesh The mesh to exclude from the highlight layer
  62017. */
  62018. addExcludedMesh(mesh: Mesh): void;
  62019. /**
  62020. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  62021. * @param mesh The mesh to highlight
  62022. */
  62023. removeExcludedMesh(mesh: Mesh): void;
  62024. /**
  62025. * Determine if a given mesh will be highlighted by the current HighlightLayer
  62026. * @param mesh mesh to test
  62027. * @returns true if the mesh will be highlighted by the current HighlightLayer
  62028. */
  62029. hasMesh(mesh: AbstractMesh): boolean;
  62030. /**
  62031. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  62032. * @param mesh The mesh to highlight
  62033. * @param color The color of the highlight
  62034. * @param glowEmissiveOnly Extract the glow from the emissive texture
  62035. */
  62036. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  62037. /**
  62038. * Remove a mesh from the highlight layer in order to make it stop glowing.
  62039. * @param mesh The mesh to highlight
  62040. */
  62041. removeMesh(mesh: Mesh): void;
  62042. /**
  62043. * Remove all the meshes currently referenced in the highlight layer
  62044. */
  62045. removeAllMeshes(): void;
  62046. /**
  62047. * Force the stencil to the normal expected value for none glowing parts
  62048. */
  62049. private _defaultStencilReference;
  62050. /**
  62051. * Free any resources and references associated to a mesh.
  62052. * Internal use
  62053. * @param mesh The mesh to free.
  62054. * @hidden
  62055. */
  62056. _disposeMesh(mesh: Mesh): void;
  62057. /**
  62058. * Dispose the highlight layer and free resources.
  62059. */
  62060. dispose(): void;
  62061. /**
  62062. * Gets the class name of the effect layer
  62063. * @returns the string with the class name of the effect layer
  62064. */
  62065. getClassName(): string;
  62066. /**
  62067. * Serializes this Highlight layer
  62068. * @returns a serialized Highlight layer object
  62069. */
  62070. serialize(): any;
  62071. /**
  62072. * Creates a Highlight layer from parsed Highlight layer data
  62073. * @param parsedHightlightLayer defines the Highlight layer data
  62074. * @param scene defines the current scene
  62075. * @param rootUrl defines the root URL containing the Highlight layer information
  62076. * @returns a parsed Highlight layer
  62077. */
  62078. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  62079. }
  62080. }
  62081. declare module "babylonjs/Layers/layerSceneComponent" {
  62082. import { Scene } from "babylonjs/scene";
  62083. import { ISceneComponent } from "babylonjs/sceneComponent";
  62084. import { Layer } from "babylonjs/Layers/layer";
  62085. import { AbstractScene } from "babylonjs/abstractScene";
  62086. module "babylonjs/abstractScene" {
  62087. interface AbstractScene {
  62088. /**
  62089. * The list of layers (background and foreground) of the scene
  62090. */
  62091. layers: Array<Layer>;
  62092. }
  62093. }
  62094. /**
  62095. * Defines the layer scene component responsible to manage any layers
  62096. * in a given scene.
  62097. */
  62098. export class LayerSceneComponent implements ISceneComponent {
  62099. /**
  62100. * The component name helpfull to identify the component in the list of scene components.
  62101. */
  62102. readonly name: string;
  62103. /**
  62104. * The scene the component belongs to.
  62105. */
  62106. scene: Scene;
  62107. private _engine;
  62108. /**
  62109. * Creates a new instance of the component for the given scene
  62110. * @param scene Defines the scene to register the component in
  62111. */
  62112. constructor(scene: Scene);
  62113. /**
  62114. * Registers the component in a given scene
  62115. */
  62116. register(): void;
  62117. /**
  62118. * Rebuilds the elements related to this component in case of
  62119. * context lost for instance.
  62120. */
  62121. rebuild(): void;
  62122. /**
  62123. * Disposes the component and the associated ressources.
  62124. */
  62125. dispose(): void;
  62126. private _draw;
  62127. private _drawCameraPredicate;
  62128. private _drawCameraBackground;
  62129. private _drawCameraForeground;
  62130. private _drawRenderTargetPredicate;
  62131. private _drawRenderTargetBackground;
  62132. private _drawRenderTargetForeground;
  62133. /**
  62134. * Adds all the elements from the container to the scene
  62135. * @param container the container holding the elements
  62136. */
  62137. addFromContainer(container: AbstractScene): void;
  62138. /**
  62139. * Removes all the elements in the container from the scene
  62140. * @param container contains the elements to remove
  62141. * @param dispose if the removed element should be disposed (default: false)
  62142. */
  62143. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62144. }
  62145. }
  62146. declare module "babylonjs/Shaders/layer.fragment" {
  62147. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  62148. /** @hidden */
  62149. export var layerPixelShader: {
  62150. name: string;
  62151. shader: string;
  62152. };
  62153. }
  62154. declare module "babylonjs/Shaders/layer.vertex" {
  62155. /** @hidden */
  62156. export var layerVertexShader: {
  62157. name: string;
  62158. shader: string;
  62159. };
  62160. }
  62161. declare module "babylonjs/Layers/layer" {
  62162. import { Observable } from "babylonjs/Misc/observable";
  62163. import { Nullable } from "babylonjs/types";
  62164. import { Scene } from "babylonjs/scene";
  62165. import { Vector2 } from "babylonjs/Maths/math.vector";
  62166. import { Color4 } from "babylonjs/Maths/math.color";
  62167. import { Texture } from "babylonjs/Materials/Textures/texture";
  62168. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62169. import "babylonjs/Shaders/layer.fragment";
  62170. import "babylonjs/Shaders/layer.vertex";
  62171. /**
  62172. * This represents a full screen 2d layer.
  62173. * This can be useful to display a picture in the background of your scene for instance.
  62174. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62175. */
  62176. export class Layer {
  62177. /**
  62178. * Define the name of the layer.
  62179. */
  62180. name: string;
  62181. /**
  62182. * Define the texture the layer should display.
  62183. */
  62184. texture: Nullable<Texture>;
  62185. /**
  62186. * Is the layer in background or foreground.
  62187. */
  62188. isBackground: boolean;
  62189. /**
  62190. * Define the color of the layer (instead of texture).
  62191. */
  62192. color: Color4;
  62193. /**
  62194. * Define the scale of the layer in order to zoom in out of the texture.
  62195. */
  62196. scale: Vector2;
  62197. /**
  62198. * Define an offset for the layer in order to shift the texture.
  62199. */
  62200. offset: Vector2;
  62201. /**
  62202. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  62203. */
  62204. alphaBlendingMode: number;
  62205. /**
  62206. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  62207. * Alpha test will not mix with the background color in case of transparency.
  62208. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  62209. */
  62210. alphaTest: boolean;
  62211. /**
  62212. * Define a mask to restrict the layer to only some of the scene cameras.
  62213. */
  62214. layerMask: number;
  62215. /**
  62216. * Define the list of render target the layer is visible into.
  62217. */
  62218. renderTargetTextures: RenderTargetTexture[];
  62219. /**
  62220. * Define if the layer is only used in renderTarget or if it also
  62221. * renders in the main frame buffer of the canvas.
  62222. */
  62223. renderOnlyInRenderTargetTextures: boolean;
  62224. private _scene;
  62225. private _vertexBuffers;
  62226. private _indexBuffer;
  62227. private _effect;
  62228. private _previousDefines;
  62229. /**
  62230. * An event triggered when the layer is disposed.
  62231. */
  62232. onDisposeObservable: Observable<Layer>;
  62233. private _onDisposeObserver;
  62234. /**
  62235. * Back compatibility with callback before the onDisposeObservable existed.
  62236. * The set callback will be triggered when the layer has been disposed.
  62237. */
  62238. set onDispose(callback: () => void);
  62239. /**
  62240. * An event triggered before rendering the scene
  62241. */
  62242. onBeforeRenderObservable: Observable<Layer>;
  62243. private _onBeforeRenderObserver;
  62244. /**
  62245. * Back compatibility with callback before the onBeforeRenderObservable existed.
  62246. * The set callback will be triggered just before rendering the layer.
  62247. */
  62248. set onBeforeRender(callback: () => void);
  62249. /**
  62250. * An event triggered after rendering the scene
  62251. */
  62252. onAfterRenderObservable: Observable<Layer>;
  62253. private _onAfterRenderObserver;
  62254. /**
  62255. * Back compatibility with callback before the onAfterRenderObservable existed.
  62256. * The set callback will be triggered just after rendering the layer.
  62257. */
  62258. set onAfterRender(callback: () => void);
  62259. /**
  62260. * Instantiates a new layer.
  62261. * This represents a full screen 2d layer.
  62262. * This can be useful to display a picture in the background of your scene for instance.
  62263. * @see https://www.babylonjs-playground.com/#08A2BS#1
  62264. * @param name Define the name of the layer in the scene
  62265. * @param imgUrl Define the url of the texture to display in the layer
  62266. * @param scene Define the scene the layer belongs to
  62267. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  62268. * @param color Defines a color for the layer
  62269. */
  62270. constructor(
  62271. /**
  62272. * Define the name of the layer.
  62273. */
  62274. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  62275. private _createIndexBuffer;
  62276. /** @hidden */
  62277. _rebuild(): void;
  62278. /**
  62279. * Renders the layer in the scene.
  62280. */
  62281. render(): void;
  62282. /**
  62283. * Disposes and releases the associated ressources.
  62284. */
  62285. dispose(): void;
  62286. }
  62287. }
  62288. declare module "babylonjs/Layers/index" {
  62289. export * from "babylonjs/Layers/effectLayer";
  62290. export * from "babylonjs/Layers/effectLayerSceneComponent";
  62291. export * from "babylonjs/Layers/glowLayer";
  62292. export * from "babylonjs/Layers/highlightLayer";
  62293. export * from "babylonjs/Layers/layer";
  62294. export * from "babylonjs/Layers/layerSceneComponent";
  62295. }
  62296. declare module "babylonjs/Shaders/lensFlare.fragment" {
  62297. /** @hidden */
  62298. export var lensFlarePixelShader: {
  62299. name: string;
  62300. shader: string;
  62301. };
  62302. }
  62303. declare module "babylonjs/Shaders/lensFlare.vertex" {
  62304. /** @hidden */
  62305. export var lensFlareVertexShader: {
  62306. name: string;
  62307. shader: string;
  62308. };
  62309. }
  62310. declare module "babylonjs/LensFlares/lensFlareSystem" {
  62311. import { Scene } from "babylonjs/scene";
  62312. import { Vector3 } from "babylonjs/Maths/math.vector";
  62313. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62314. import { LensFlare } from "babylonjs/LensFlares/lensFlare";
  62315. import "babylonjs/Shaders/lensFlare.fragment";
  62316. import "babylonjs/Shaders/lensFlare.vertex";
  62317. import { Viewport } from "babylonjs/Maths/math.viewport";
  62318. /**
  62319. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62320. * It is usually composed of several `lensFlare`.
  62321. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62322. */
  62323. export class LensFlareSystem {
  62324. /**
  62325. * Define the name of the lens flare system
  62326. */
  62327. name: string;
  62328. /**
  62329. * List of lens flares used in this system.
  62330. */
  62331. lensFlares: LensFlare[];
  62332. /**
  62333. * Define a limit from the border the lens flare can be visible.
  62334. */
  62335. borderLimit: number;
  62336. /**
  62337. * Define a viewport border we do not want to see the lens flare in.
  62338. */
  62339. viewportBorder: number;
  62340. /**
  62341. * Define a predicate which could limit the list of meshes able to occlude the effect.
  62342. */
  62343. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  62344. /**
  62345. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  62346. */
  62347. layerMask: number;
  62348. /**
  62349. * Define the id of the lens flare system in the scene.
  62350. * (equal to name by default)
  62351. */
  62352. id: string;
  62353. private _scene;
  62354. private _emitter;
  62355. private _vertexBuffers;
  62356. private _indexBuffer;
  62357. private _effect;
  62358. private _positionX;
  62359. private _positionY;
  62360. private _isEnabled;
  62361. /** @hidden */
  62362. static _SceneComponentInitialization: (scene: Scene) => void;
  62363. /**
  62364. * Instantiates a lens flare system.
  62365. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  62366. * It is usually composed of several `lensFlare`.
  62367. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62368. * @param name Define the name of the lens flare system in the scene
  62369. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  62370. * @param scene Define the scene the lens flare system belongs to
  62371. */
  62372. constructor(
  62373. /**
  62374. * Define the name of the lens flare system
  62375. */
  62376. name: string, emitter: any, scene: Scene);
  62377. /**
  62378. * Define if the lens flare system is enabled.
  62379. */
  62380. get isEnabled(): boolean;
  62381. set isEnabled(value: boolean);
  62382. /**
  62383. * Get the scene the effects belongs to.
  62384. * @returns the scene holding the lens flare system
  62385. */
  62386. getScene(): Scene;
  62387. /**
  62388. * Get the emitter of the lens flare system.
  62389. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62390. * @returns the emitter of the lens flare system
  62391. */
  62392. getEmitter(): any;
  62393. /**
  62394. * Set the emitter of the lens flare system.
  62395. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  62396. * @param newEmitter Define the new emitter of the system
  62397. */
  62398. setEmitter(newEmitter: any): void;
  62399. /**
  62400. * Get the lens flare system emitter position.
  62401. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  62402. * @returns the position
  62403. */
  62404. getEmitterPosition(): Vector3;
  62405. /**
  62406. * @hidden
  62407. */
  62408. computeEffectivePosition(globalViewport: Viewport): boolean;
  62409. /** @hidden */
  62410. _isVisible(): boolean;
  62411. /**
  62412. * @hidden
  62413. */
  62414. render(): boolean;
  62415. /**
  62416. * Dispose and release the lens flare with its associated resources.
  62417. */
  62418. dispose(): void;
  62419. /**
  62420. * Parse a lens flare system from a JSON repressentation
  62421. * @param parsedLensFlareSystem Define the JSON to parse
  62422. * @param scene Define the scene the parsed system should be instantiated in
  62423. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  62424. * @returns the parsed system
  62425. */
  62426. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  62427. /**
  62428. * Serialize the current Lens Flare System into a JSON representation.
  62429. * @returns the serialized JSON
  62430. */
  62431. serialize(): any;
  62432. }
  62433. }
  62434. declare module "babylonjs/LensFlares/lensFlare" {
  62435. import { Nullable } from "babylonjs/types";
  62436. import { Color3 } from "babylonjs/Maths/math.color";
  62437. import { Texture } from "babylonjs/Materials/Textures/texture";
  62438. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62439. /**
  62440. * This represents one of the lens effect in a `lensFlareSystem`.
  62441. * It controls one of the indiviual texture used in the effect.
  62442. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62443. */
  62444. export class LensFlare {
  62445. /**
  62446. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62447. */
  62448. size: number;
  62449. /**
  62450. * 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.
  62451. */
  62452. position: number;
  62453. /**
  62454. * Define the lens color.
  62455. */
  62456. color: Color3;
  62457. /**
  62458. * Define the lens texture.
  62459. */
  62460. texture: Nullable<Texture>;
  62461. /**
  62462. * Define the alpha mode to render this particular lens.
  62463. */
  62464. alphaMode: number;
  62465. private _system;
  62466. /**
  62467. * Creates a new Lens Flare.
  62468. * This represents one of the lens effect in a `lensFlareSystem`.
  62469. * It controls one of the indiviual texture used in the effect.
  62470. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62471. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  62472. * @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.
  62473. * @param color Define the lens color
  62474. * @param imgUrl Define the lens texture url
  62475. * @param system Define the `lensFlareSystem` this flare is part of
  62476. * @returns The newly created Lens Flare
  62477. */
  62478. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  62479. /**
  62480. * Instantiates a new Lens Flare.
  62481. * This represents one of the lens effect in a `lensFlareSystem`.
  62482. * It controls one of the indiviual texture used in the effect.
  62483. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62484. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  62485. * @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.
  62486. * @param color Define the lens color
  62487. * @param imgUrl Define the lens texture url
  62488. * @param system Define the `lensFlareSystem` this flare is part of
  62489. */
  62490. constructor(
  62491. /**
  62492. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  62493. */
  62494. size: number,
  62495. /**
  62496. * 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.
  62497. */
  62498. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  62499. /**
  62500. * Dispose and release the lens flare with its associated resources.
  62501. */
  62502. dispose(): void;
  62503. }
  62504. }
  62505. declare module "babylonjs/LensFlares/lensFlareSystemSceneComponent" {
  62506. import { Nullable } from "babylonjs/types";
  62507. import { Scene } from "babylonjs/scene";
  62508. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  62509. import { AbstractScene } from "babylonjs/abstractScene";
  62510. import { LensFlareSystem } from "babylonjs/LensFlares/lensFlareSystem";
  62511. module "babylonjs/abstractScene" {
  62512. interface AbstractScene {
  62513. /**
  62514. * The list of lens flare system added to the scene
  62515. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  62516. */
  62517. lensFlareSystems: Array<LensFlareSystem>;
  62518. /**
  62519. * Removes the given lens flare system from this scene.
  62520. * @param toRemove The lens flare system to remove
  62521. * @returns The index of the removed lens flare system
  62522. */
  62523. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  62524. /**
  62525. * Adds the given lens flare system to this scene
  62526. * @param newLensFlareSystem The lens flare system to add
  62527. */
  62528. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  62529. /**
  62530. * Gets a lens flare system using its name
  62531. * @param name defines the name to look for
  62532. * @returns the lens flare system or null if not found
  62533. */
  62534. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  62535. /**
  62536. * Gets a lens flare system using its id
  62537. * @param id defines the id to look for
  62538. * @returns the lens flare system or null if not found
  62539. */
  62540. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  62541. }
  62542. }
  62543. /**
  62544. * Defines the lens flare scene component responsible to manage any lens flares
  62545. * in a given scene.
  62546. */
  62547. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  62548. /**
  62549. * The component name helpfull to identify the component in the list of scene components.
  62550. */
  62551. readonly name: string;
  62552. /**
  62553. * The scene the component belongs to.
  62554. */
  62555. scene: Scene;
  62556. /**
  62557. * Creates a new instance of the component for the given scene
  62558. * @param scene Defines the scene to register the component in
  62559. */
  62560. constructor(scene: Scene);
  62561. /**
  62562. * Registers the component in a given scene
  62563. */
  62564. register(): void;
  62565. /**
  62566. * Rebuilds the elements related to this component in case of
  62567. * context lost for instance.
  62568. */
  62569. rebuild(): void;
  62570. /**
  62571. * Adds all the elements from the container to the scene
  62572. * @param container the container holding the elements
  62573. */
  62574. addFromContainer(container: AbstractScene): void;
  62575. /**
  62576. * Removes all the elements in the container from the scene
  62577. * @param container contains the elements to remove
  62578. * @param dispose if the removed element should be disposed (default: false)
  62579. */
  62580. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  62581. /**
  62582. * Serializes the component data to the specified json object
  62583. * @param serializationObject The object to serialize to
  62584. */
  62585. serialize(serializationObject: any): void;
  62586. /**
  62587. * Disposes the component and the associated ressources.
  62588. */
  62589. dispose(): void;
  62590. private _draw;
  62591. }
  62592. }
  62593. declare module "babylonjs/LensFlares/index" {
  62594. export * from "babylonjs/LensFlares/lensFlare";
  62595. export * from "babylonjs/LensFlares/lensFlareSystem";
  62596. export * from "babylonjs/LensFlares/lensFlareSystemSceneComponent";
  62597. }
  62598. declare module "babylonjs/Shaders/depth.fragment" {
  62599. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  62600. /** @hidden */
  62601. export var depthPixelShader: {
  62602. name: string;
  62603. shader: string;
  62604. };
  62605. }
  62606. declare module "babylonjs/Shaders/depth.vertex" {
  62607. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  62608. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  62609. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  62610. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  62611. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  62612. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  62613. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  62614. /** @hidden */
  62615. export var depthVertexShader: {
  62616. name: string;
  62617. shader: string;
  62618. };
  62619. }
  62620. declare module "babylonjs/Rendering/depthRenderer" {
  62621. import { Nullable } from "babylonjs/types";
  62622. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62623. import { Scene } from "babylonjs/scene";
  62624. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62625. import { Camera } from "babylonjs/Cameras/camera";
  62626. import "babylonjs/Shaders/depth.fragment";
  62627. import "babylonjs/Shaders/depth.vertex";
  62628. /**
  62629. * This represents a depth renderer in Babylon.
  62630. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  62631. */
  62632. export class DepthRenderer {
  62633. private _scene;
  62634. private _depthMap;
  62635. private _effect;
  62636. private readonly _storeNonLinearDepth;
  62637. private readonly _clearColor;
  62638. /** Get if the depth renderer is using packed depth or not */
  62639. readonly isPacked: boolean;
  62640. private _cachedDefines;
  62641. private _camera;
  62642. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  62643. enabled: boolean;
  62644. /**
  62645. * Specifiess that the depth renderer will only be used within
  62646. * the camera it is created for.
  62647. * This can help forcing its rendering during the camera processing.
  62648. */
  62649. useOnlyInActiveCamera: boolean;
  62650. /** @hidden */
  62651. static _SceneComponentInitialization: (scene: Scene) => void;
  62652. /**
  62653. * Instantiates a depth renderer
  62654. * @param scene The scene the renderer belongs to
  62655. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  62656. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  62657. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  62658. */
  62659. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  62660. /**
  62661. * Creates the depth rendering effect and checks if the effect is ready.
  62662. * @param subMesh The submesh to be used to render the depth map of
  62663. * @param useInstances If multiple world instances should be used
  62664. * @returns if the depth renderer is ready to render the depth map
  62665. */
  62666. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  62667. /**
  62668. * Gets the texture which the depth map will be written to.
  62669. * @returns The depth map texture
  62670. */
  62671. getDepthMap(): RenderTargetTexture;
  62672. /**
  62673. * Disposes of the depth renderer.
  62674. */
  62675. dispose(): void;
  62676. }
  62677. }
  62678. declare module "babylonjs/Shaders/minmaxRedux.fragment" {
  62679. /** @hidden */
  62680. export var minmaxReduxPixelShader: {
  62681. name: string;
  62682. shader: string;
  62683. };
  62684. }
  62685. declare module "babylonjs/Misc/minMaxReducer" {
  62686. import { Nullable } from "babylonjs/types";
  62687. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62688. import { Camera } from "babylonjs/Cameras/camera";
  62689. import { Observer } from "babylonjs/Misc/observable";
  62690. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  62691. import { PostProcessManager } from "babylonjs/PostProcesses/postProcessManager";
  62692. import { Observable } from "babylonjs/Misc/observable";
  62693. import "babylonjs/Shaders/minmaxRedux.fragment";
  62694. /**
  62695. * This class computes a min/max reduction from a texture: it means it computes the minimum
  62696. * and maximum values from all values of the texture.
  62697. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  62698. * The source values are read from the red channel of the texture.
  62699. */
  62700. export class MinMaxReducer {
  62701. /**
  62702. * Observable triggered when the computation has been performed
  62703. */
  62704. onAfterReductionPerformed: Observable<{
  62705. min: number;
  62706. max: number;
  62707. }>;
  62708. protected _camera: Camera;
  62709. protected _sourceTexture: Nullable<RenderTargetTexture>;
  62710. protected _reductionSteps: Nullable<Array<PostProcess>>;
  62711. protected _postProcessManager: PostProcessManager;
  62712. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  62713. protected _forceFullscreenViewport: boolean;
  62714. /**
  62715. * Creates a min/max reducer
  62716. * @param camera The camera to use for the post processes
  62717. */
  62718. constructor(camera: Camera);
  62719. /**
  62720. * Gets the texture used to read the values from.
  62721. */
  62722. get sourceTexture(): Nullable<RenderTargetTexture>;
  62723. /**
  62724. * Sets the source texture to read the values from.
  62725. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  62726. * because in such textures '1' value must not be taken into account to compute the maximum
  62727. * as this value is used to clear the texture.
  62728. * Note that the computation is not activated by calling this function, you must call activate() for that!
  62729. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  62730. * @param depthRedux Indicates if the texture is a depth texture or not
  62731. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  62732. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62733. */
  62734. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62735. /**
  62736. * Defines the refresh rate of the computation.
  62737. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  62738. */
  62739. get refreshRate(): number;
  62740. set refreshRate(value: number);
  62741. protected _activated: boolean;
  62742. /**
  62743. * Gets the activation status of the reducer
  62744. */
  62745. get activated(): boolean;
  62746. /**
  62747. * Activates the reduction computation.
  62748. * When activated, the observers registered in onAfterReductionPerformed are
  62749. * called after the compuation is performed
  62750. */
  62751. activate(): void;
  62752. /**
  62753. * Deactivates the reduction computation.
  62754. */
  62755. deactivate(): void;
  62756. /**
  62757. * Disposes the min/max reducer
  62758. * @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.
  62759. */
  62760. dispose(disposeAll?: boolean): void;
  62761. }
  62762. }
  62763. declare module "babylonjs/Misc/depthReducer" {
  62764. import { Nullable } from "babylonjs/types";
  62765. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  62766. import { Camera } from "babylonjs/Cameras/camera";
  62767. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62768. import { MinMaxReducer } from "babylonjs/Misc/minMaxReducer";
  62769. /**
  62770. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  62771. */
  62772. export class DepthReducer extends MinMaxReducer {
  62773. private _depthRenderer;
  62774. private _depthRendererId;
  62775. /**
  62776. * Gets the depth renderer used for the computation.
  62777. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  62778. */
  62779. get depthRenderer(): Nullable<DepthRenderer>;
  62780. /**
  62781. * Creates a depth reducer
  62782. * @param camera The camera used to render the depth texture
  62783. */
  62784. constructor(camera: Camera);
  62785. /**
  62786. * Sets the depth renderer to use to generate the depth map
  62787. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  62788. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  62789. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  62790. */
  62791. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  62792. /** @hidden */
  62793. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  62794. /**
  62795. * Activates the reduction computation.
  62796. * When activated, the observers registered in onAfterReductionPerformed are
  62797. * called after the compuation is performed
  62798. */
  62799. activate(): void;
  62800. /**
  62801. * Deactivates the reduction computation.
  62802. */
  62803. deactivate(): void;
  62804. /**
  62805. * Disposes the depth reducer
  62806. * @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.
  62807. */
  62808. dispose(disposeAll?: boolean): void;
  62809. }
  62810. }
  62811. declare module "babylonjs/Lights/Shadows/cascadedShadowGenerator" {
  62812. import { Nullable } from "babylonjs/types";
  62813. import { Scene } from "babylonjs/scene";
  62814. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  62815. import { SubMesh } from "babylonjs/Meshes/subMesh";
  62816. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  62817. import { Effect } from "babylonjs/Materials/effect";
  62818. import "babylonjs/Shaders/shadowMap.fragment";
  62819. import "babylonjs/Shaders/shadowMap.vertex";
  62820. import "babylonjs/Shaders/depthBoxBlur.fragment";
  62821. import { ShadowGenerator } from "babylonjs/Lights/Shadows/shadowGenerator";
  62822. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  62823. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  62824. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  62825. /**
  62826. * A CSM implementation allowing casting shadows on large scenes.
  62827. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  62828. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  62829. */
  62830. export class CascadedShadowGenerator extends ShadowGenerator {
  62831. private static readonly frustumCornersNDCSpace;
  62832. /**
  62833. * Name of the CSM class
  62834. */
  62835. static CLASSNAME: string;
  62836. /**
  62837. * Defines the default number of cascades used by the CSM.
  62838. */
  62839. static readonly DEFAULT_CASCADES_COUNT: number;
  62840. /**
  62841. * Defines the minimum number of cascades used by the CSM.
  62842. */
  62843. static readonly MIN_CASCADES_COUNT: number;
  62844. /**
  62845. * Defines the maximum number of cascades used by the CSM.
  62846. */
  62847. static readonly MAX_CASCADES_COUNT: number;
  62848. protected _validateFilter(filter: number): number;
  62849. /**
  62850. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  62851. */
  62852. penumbraDarkness: number;
  62853. private _numCascades;
  62854. /**
  62855. * Gets or set the number of cascades used by the CSM.
  62856. */
  62857. get numCascades(): number;
  62858. set numCascades(value: number);
  62859. /**
  62860. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  62861. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  62862. */
  62863. stabilizeCascades: boolean;
  62864. private _freezeShadowCastersBoundingInfo;
  62865. private _freezeShadowCastersBoundingInfoObservable;
  62866. /**
  62867. * Enables or disables the shadow casters bounding info computation.
  62868. * If your shadow casters don't move, you can disable this feature.
  62869. * If it is enabled, the bounding box computation is done every frame.
  62870. */
  62871. get freezeShadowCastersBoundingInfo(): boolean;
  62872. set freezeShadowCastersBoundingInfo(freeze: boolean);
  62873. private _scbiMin;
  62874. private _scbiMax;
  62875. protected _computeShadowCastersBoundingInfo(): void;
  62876. protected _shadowCastersBoundingInfo: BoundingInfo;
  62877. /**
  62878. * Gets or sets the shadow casters bounding info.
  62879. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  62880. * so that the system won't overwrite the bounds you provide
  62881. */
  62882. get shadowCastersBoundingInfo(): BoundingInfo;
  62883. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  62884. protected _breaksAreDirty: boolean;
  62885. protected _minDistance: number;
  62886. protected _maxDistance: number;
  62887. /**
  62888. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  62889. *
  62890. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  62891. * If you don't know these values, simply leave them to their defaults and don't call this function.
  62892. * @param min minimal distance for the breaks (default to 0.)
  62893. * @param max maximal distance for the breaks (default to 1.)
  62894. */
  62895. setMinMaxDistance(min: number, max: number): void;
  62896. /** Gets the minimal distance used in the cascade break computation */
  62897. get minDistance(): number;
  62898. /** Gets the maximal distance used in the cascade break computation */
  62899. get maxDistance(): number;
  62900. /**
  62901. * Gets the class name of that object
  62902. * @returns "CascadedShadowGenerator"
  62903. */
  62904. getClassName(): string;
  62905. private _cascadeMinExtents;
  62906. private _cascadeMaxExtents;
  62907. /**
  62908. * Gets a cascade minimum extents
  62909. * @param cascadeIndex index of the cascade
  62910. * @returns the minimum cascade extents
  62911. */
  62912. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  62913. /**
  62914. * Gets a cascade maximum extents
  62915. * @param cascadeIndex index of the cascade
  62916. * @returns the maximum cascade extents
  62917. */
  62918. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  62919. private _cascades;
  62920. private _currentLayer;
  62921. private _viewSpaceFrustumsZ;
  62922. private _viewMatrices;
  62923. private _projectionMatrices;
  62924. private _transformMatrices;
  62925. private _transformMatricesAsArray;
  62926. private _frustumLengths;
  62927. private _lightSizeUVCorrection;
  62928. private _depthCorrection;
  62929. private _frustumCornersWorldSpace;
  62930. private _frustumCenter;
  62931. private _shadowCameraPos;
  62932. private _shadowMaxZ;
  62933. /**
  62934. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  62935. * It defaults to camera.maxZ
  62936. */
  62937. get shadowMaxZ(): number;
  62938. /**
  62939. * Sets the shadow max z distance.
  62940. */
  62941. set shadowMaxZ(value: number);
  62942. protected _debug: boolean;
  62943. /**
  62944. * Gets or sets the debug flag.
  62945. * When enabled, the cascades are materialized by different colors on the screen.
  62946. */
  62947. get debug(): boolean;
  62948. set debug(dbg: boolean);
  62949. private _depthClamp;
  62950. /**
  62951. * Gets or sets the depth clamping value.
  62952. *
  62953. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  62954. * to account for the shadow casters far away.
  62955. *
  62956. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  62957. */
  62958. get depthClamp(): boolean;
  62959. set depthClamp(value: boolean);
  62960. private _cascadeBlendPercentage;
  62961. /**
  62962. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  62963. * It defaults to 0.1 (10% blending).
  62964. */
  62965. get cascadeBlendPercentage(): number;
  62966. set cascadeBlendPercentage(value: number);
  62967. private _lambda;
  62968. /**
  62969. * Gets or set the lambda parameter.
  62970. * This parameter is used to split the camera frustum and create the cascades.
  62971. * 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.
  62972. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  62973. */
  62974. get lambda(): number;
  62975. set lambda(value: number);
  62976. /**
  62977. * Gets the view matrix corresponding to a given cascade
  62978. * @param cascadeNum cascade to retrieve the view matrix from
  62979. * @returns the cascade view matrix
  62980. */
  62981. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  62982. /**
  62983. * Gets the projection matrix corresponding to a given cascade
  62984. * @param cascadeNum cascade to retrieve the projection matrix from
  62985. * @returns the cascade projection matrix
  62986. */
  62987. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  62988. /**
  62989. * Gets the transformation matrix corresponding to a given cascade
  62990. * @param cascadeNum cascade to retrieve the transformation matrix from
  62991. * @returns the cascade transformation matrix
  62992. */
  62993. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  62994. private _depthRenderer;
  62995. /**
  62996. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  62997. *
  62998. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  62999. *
  63000. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  63001. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  63002. * @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
  63003. */
  63004. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  63005. private _depthReducer;
  63006. private _autoCalcDepthBounds;
  63007. /**
  63008. * Gets or sets the autoCalcDepthBounds property.
  63009. *
  63010. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  63011. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  63012. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  63013. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  63014. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  63015. */
  63016. get autoCalcDepthBounds(): boolean;
  63017. set autoCalcDepthBounds(value: boolean);
  63018. /**
  63019. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  63020. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  63021. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  63022. * for setting the refresh rate on the renderer yourself!
  63023. */
  63024. get autoCalcDepthBoundsRefreshRate(): number;
  63025. set autoCalcDepthBoundsRefreshRate(value: number);
  63026. /**
  63027. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  63028. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  63029. * you change the camera near/far planes!
  63030. */
  63031. splitFrustum(): void;
  63032. private _splitFrustum;
  63033. private _computeMatrices;
  63034. private _computeFrustumInWorldSpace;
  63035. private _computeCascadeFrustum;
  63036. /**
  63037. * Support test.
  63038. */
  63039. static get IsSupported(): boolean;
  63040. /** @hidden */
  63041. static _SceneComponentInitialization: (scene: Scene) => void;
  63042. /**
  63043. * Creates a Cascaded Shadow Generator object.
  63044. * A ShadowGenerator is the required tool to use the shadows.
  63045. * Each directional light casting shadows needs to use its own ShadowGenerator.
  63046. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  63047. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  63048. * @param light The directional light object generating the shadows.
  63049. * @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.
  63050. */
  63051. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  63052. protected _initializeGenerator(): void;
  63053. protected _createTargetRenderTexture(): void;
  63054. protected _initializeShadowMap(): void;
  63055. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  63056. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  63057. /**
  63058. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  63059. * @param defines Defines of the material we want to update
  63060. * @param lightIndex Index of the light in the enabled light list of the material
  63061. */
  63062. prepareDefines(defines: any, lightIndex: number): void;
  63063. /**
  63064. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  63065. * defined in the generator but impacting the effect).
  63066. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  63067. * @param effect The effect we are binfing the information for
  63068. */
  63069. bindShadowLight(lightIndex: string, effect: Effect): void;
  63070. /**
  63071. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  63072. * (eq to view projection * shadow projection matrices)
  63073. * @returns The transform matrix used to create the shadow map
  63074. */
  63075. getTransformMatrix(): Matrix;
  63076. /**
  63077. * Disposes the ShadowGenerator.
  63078. * Returns nothing.
  63079. */
  63080. dispose(): void;
  63081. /**
  63082. * Serializes the shadow generator setup to a json object.
  63083. * @returns The serialized JSON object
  63084. */
  63085. serialize(): any;
  63086. /**
  63087. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  63088. * @param parsedShadowGenerator The JSON object to parse
  63089. * @param scene The scene to create the shadow map for
  63090. * @returns The parsed shadow generator
  63091. */
  63092. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  63093. }
  63094. }
  63095. declare module "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent" {
  63096. import { Scene } from "babylonjs/scene";
  63097. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  63098. import { AbstractScene } from "babylonjs/abstractScene";
  63099. /**
  63100. * Defines the shadow generator component responsible to manage any shadow generators
  63101. * in a given scene.
  63102. */
  63103. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  63104. /**
  63105. * The component name helpfull to identify the component in the list of scene components.
  63106. */
  63107. readonly name: string;
  63108. /**
  63109. * The scene the component belongs to.
  63110. */
  63111. scene: Scene;
  63112. /**
  63113. * Creates a new instance of the component for the given scene
  63114. * @param scene Defines the scene to register the component in
  63115. */
  63116. constructor(scene: Scene);
  63117. /**
  63118. * Registers the component in a given scene
  63119. */
  63120. register(): void;
  63121. /**
  63122. * Rebuilds the elements related to this component in case of
  63123. * context lost for instance.
  63124. */
  63125. rebuild(): void;
  63126. /**
  63127. * Serializes the component data to the specified json object
  63128. * @param serializationObject The object to serialize to
  63129. */
  63130. serialize(serializationObject: any): void;
  63131. /**
  63132. * Adds all the elements from the container to the scene
  63133. * @param container the container holding the elements
  63134. */
  63135. addFromContainer(container: AbstractScene): void;
  63136. /**
  63137. * Removes all the elements in the container from the scene
  63138. * @param container contains the elements to remove
  63139. * @param dispose if the removed element should be disposed (default: false)
  63140. */
  63141. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  63142. /**
  63143. * Rebuilds the elements related to this component in case of
  63144. * context lost for instance.
  63145. */
  63146. dispose(): void;
  63147. private _gatherRenderTargets;
  63148. }
  63149. }
  63150. declare module "babylonjs/Lights/Shadows/index" {
  63151. export * from "babylonjs/Lights/Shadows/shadowGenerator";
  63152. export * from "babylonjs/Lights/Shadows/cascadedShadowGenerator";
  63153. export * from "babylonjs/Lights/Shadows/shadowGeneratorSceneComponent";
  63154. }
  63155. declare module "babylonjs/Lights/pointLight" {
  63156. import { Scene } from "babylonjs/scene";
  63157. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63158. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63159. import { ShadowLight } from "babylonjs/Lights/shadowLight";
  63160. import { Effect } from "babylonjs/Materials/effect";
  63161. /**
  63162. * A point light is a light defined by an unique point in world space.
  63163. * The light is emitted in every direction from this point.
  63164. * A good example of a point light is a standard light bulb.
  63165. * Documentation: https://doc.babylonjs.com/babylon101/lights
  63166. */
  63167. export class PointLight extends ShadowLight {
  63168. private _shadowAngle;
  63169. /**
  63170. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63171. * This specifies what angle the shadow will use to be created.
  63172. *
  63173. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63174. */
  63175. get shadowAngle(): number;
  63176. /**
  63177. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63178. * This specifies what angle the shadow will use to be created.
  63179. *
  63180. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  63181. */
  63182. set shadowAngle(value: number);
  63183. /**
  63184. * Gets the direction if it has been set.
  63185. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63186. */
  63187. get direction(): Vector3;
  63188. /**
  63189. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  63190. */
  63191. set direction(value: Vector3);
  63192. /**
  63193. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  63194. * A PointLight emits the light in every direction.
  63195. * It can cast shadows.
  63196. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  63197. * ```javascript
  63198. * var pointLight = new PointLight("pl", camera.position, scene);
  63199. * ```
  63200. * Documentation : https://doc.babylonjs.com/babylon101/lights
  63201. * @param name The light friendly name
  63202. * @param position The position of the point light in the scene
  63203. * @param scene The scene the lights belongs to
  63204. */
  63205. constructor(name: string, position: Vector3, scene: Scene);
  63206. /**
  63207. * Returns the string "PointLight"
  63208. * @returns the class name
  63209. */
  63210. getClassName(): string;
  63211. /**
  63212. * Returns the integer 0.
  63213. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  63214. */
  63215. getTypeID(): number;
  63216. /**
  63217. * Specifies wether or not the shadowmap should be a cube texture.
  63218. * @returns true if the shadowmap needs to be a cube texture.
  63219. */
  63220. needCube(): boolean;
  63221. /**
  63222. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  63223. * @param faceIndex The index of the face we are computed the direction to generate shadow
  63224. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  63225. */
  63226. getShadowDirection(faceIndex?: number): Vector3;
  63227. /**
  63228. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  63229. * - fov = PI / 2
  63230. * - aspect ratio : 1.0
  63231. * - z-near and far equal to the active camera minZ and maxZ.
  63232. * Returns the PointLight.
  63233. */
  63234. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  63235. protected _buildUniformLayout(): void;
  63236. /**
  63237. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  63238. * @param effect The effect to update
  63239. * @param lightIndex The index of the light in the effect to update
  63240. * @returns The point light
  63241. */
  63242. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  63243. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  63244. /**
  63245. * Prepares the list of defines specific to the light type.
  63246. * @param defines the list of defines
  63247. * @param lightIndex defines the index of the light for the effect
  63248. */
  63249. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  63250. }
  63251. }
  63252. declare module "babylonjs/Lights/index" {
  63253. export * from "babylonjs/Lights/light";
  63254. export * from "babylonjs/Lights/shadowLight";
  63255. export * from "babylonjs/Lights/Shadows/index";
  63256. export * from "babylonjs/Lights/directionalLight";
  63257. export * from "babylonjs/Lights/hemisphericLight";
  63258. export * from "babylonjs/Lights/pointLight";
  63259. export * from "babylonjs/Lights/spotLight";
  63260. }
  63261. declare module "babylonjs/Misc/HighDynamicRange/hdr" {
  63262. import { CubeMapInfo } from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  63263. /**
  63264. * Header information of HDR texture files.
  63265. */
  63266. export interface HDRInfo {
  63267. /**
  63268. * The height of the texture in pixels.
  63269. */
  63270. height: number;
  63271. /**
  63272. * The width of the texture in pixels.
  63273. */
  63274. width: number;
  63275. /**
  63276. * The index of the beginning of the data in the binary file.
  63277. */
  63278. dataPosition: number;
  63279. }
  63280. /**
  63281. * This groups tools to convert HDR texture to native colors array.
  63282. */
  63283. export class HDRTools {
  63284. private static Ldexp;
  63285. private static Rgbe2float;
  63286. private static readStringLine;
  63287. /**
  63288. * Reads header information from an RGBE texture stored in a native array.
  63289. * More information on this format are available here:
  63290. * https://en.wikipedia.org/wiki/RGBE_image_format
  63291. *
  63292. * @param uint8array The binary file stored in native array.
  63293. * @return The header information.
  63294. */
  63295. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  63296. /**
  63297. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  63298. * This RGBE texture needs to store the information as a panorama.
  63299. *
  63300. * More information on this format are available here:
  63301. * https://en.wikipedia.org/wiki/RGBE_image_format
  63302. *
  63303. * @param buffer The binary file stored in an array buffer.
  63304. * @param size The expected size of the extracted cubemap.
  63305. * @return The Cube Map information.
  63306. */
  63307. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  63308. /**
  63309. * Returns the pixels data extracted from an RGBE texture.
  63310. * This pixels will be stored left to right up to down in the R G B order in one array.
  63311. *
  63312. * More information on this format are available here:
  63313. * https://en.wikipedia.org/wiki/RGBE_image_format
  63314. *
  63315. * @param uint8array The binary file stored in an array buffer.
  63316. * @param hdrInfo The header information of the file.
  63317. * @return The pixels data in RGB right to left up to down order.
  63318. */
  63319. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  63320. private static RGBE_ReadPixels_RLE;
  63321. private static RGBE_ReadPixels_NOT_RLE;
  63322. }
  63323. }
  63324. declare module "babylonjs/Materials/effectRenderer" {
  63325. import { Nullable } from "babylonjs/types";
  63326. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  63327. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  63328. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63329. import { Viewport } from "babylonjs/Maths/math.viewport";
  63330. import { Observable } from "babylonjs/Misc/observable";
  63331. import { Effect } from "babylonjs/Materials/effect";
  63332. import "babylonjs/Shaders/postprocess.vertex";
  63333. /**
  63334. * Effect Render Options
  63335. */
  63336. export interface IEffectRendererOptions {
  63337. /**
  63338. * Defines the vertices positions.
  63339. */
  63340. positions?: number[];
  63341. /**
  63342. * Defines the indices.
  63343. */
  63344. indices?: number[];
  63345. }
  63346. /**
  63347. * Helper class to render one or more effects.
  63348. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  63349. */
  63350. export class EffectRenderer {
  63351. private engine;
  63352. private static _DefaultOptions;
  63353. private _vertexBuffers;
  63354. private _indexBuffer;
  63355. private _fullscreenViewport;
  63356. /**
  63357. * Creates an effect renderer
  63358. * @param engine the engine to use for rendering
  63359. * @param options defines the options of the effect renderer
  63360. */
  63361. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  63362. /**
  63363. * Sets the current viewport in normalized coordinates 0-1
  63364. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  63365. */
  63366. setViewport(viewport?: Viewport): void;
  63367. /**
  63368. * Binds the embedded attributes buffer to the effect.
  63369. * @param effect Defines the effect to bind the attributes for
  63370. */
  63371. bindBuffers(effect: Effect): void;
  63372. /**
  63373. * Sets the current effect wrapper to use during draw.
  63374. * The effect needs to be ready before calling this api.
  63375. * This also sets the default full screen position attribute.
  63376. * @param effectWrapper Defines the effect to draw with
  63377. */
  63378. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  63379. /**
  63380. * Restores engine states
  63381. */
  63382. restoreStates(): void;
  63383. /**
  63384. * Draws a full screen quad.
  63385. */
  63386. draw(): void;
  63387. private isRenderTargetTexture;
  63388. /**
  63389. * renders one or more effects to a specified texture
  63390. * @param effectWrapper the effect to renderer
  63391. * @param outputTexture texture to draw to, if null it will render to the screen.
  63392. */
  63393. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  63394. /**
  63395. * Disposes of the effect renderer
  63396. */
  63397. dispose(): void;
  63398. }
  63399. /**
  63400. * Options to create an EffectWrapper
  63401. */
  63402. interface EffectWrapperCreationOptions {
  63403. /**
  63404. * Engine to use to create the effect
  63405. */
  63406. engine: ThinEngine;
  63407. /**
  63408. * Fragment shader for the effect
  63409. */
  63410. fragmentShader: string;
  63411. /**
  63412. * Use the shader store instead of direct source code
  63413. */
  63414. useShaderStore?: boolean;
  63415. /**
  63416. * Vertex shader for the effect
  63417. */
  63418. vertexShader?: string;
  63419. /**
  63420. * Attributes to use in the shader
  63421. */
  63422. attributeNames?: Array<string>;
  63423. /**
  63424. * Uniforms to use in the shader
  63425. */
  63426. uniformNames?: Array<string>;
  63427. /**
  63428. * Texture sampler names to use in the shader
  63429. */
  63430. samplerNames?: Array<string>;
  63431. /**
  63432. * Defines to use in the shader
  63433. */
  63434. defines?: Array<string>;
  63435. /**
  63436. * Callback when effect is compiled
  63437. */
  63438. onCompiled?: Nullable<(effect: Effect) => void>;
  63439. /**
  63440. * The friendly name of the effect displayed in Spector.
  63441. */
  63442. name?: string;
  63443. }
  63444. /**
  63445. * Wraps an effect to be used for rendering
  63446. */
  63447. export class EffectWrapper {
  63448. /**
  63449. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  63450. */
  63451. onApplyObservable: Observable<{}>;
  63452. /**
  63453. * The underlying effect
  63454. */
  63455. effect: Effect;
  63456. /**
  63457. * Creates an effect to be renderer
  63458. * @param creationOptions options to create the effect
  63459. */
  63460. constructor(creationOptions: EffectWrapperCreationOptions);
  63461. /**
  63462. * Disposes of the effect wrapper
  63463. */
  63464. dispose(): void;
  63465. }
  63466. }
  63467. declare module "babylonjs/Shaders/hdrFiltering.vertex" {
  63468. /** @hidden */
  63469. export var hdrFilteringVertexShader: {
  63470. name: string;
  63471. shader: string;
  63472. };
  63473. }
  63474. declare module "babylonjs/Shaders/hdrFiltering.fragment" {
  63475. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  63476. import "babylonjs/Shaders/ShadersInclude/importanceSampling";
  63477. import "babylonjs/Shaders/ShadersInclude/pbrBRDFFunctions";
  63478. import "babylonjs/Shaders/ShadersInclude/hdrFilteringFunctions";
  63479. /** @hidden */
  63480. export var hdrFilteringPixelShader: {
  63481. name: string;
  63482. shader: string;
  63483. };
  63484. }
  63485. declare module "babylonjs/Materials/Textures/Filtering/hdrFiltering" {
  63486. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63487. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63488. import { Nullable } from "babylonjs/types";
  63489. import "babylonjs/Shaders/hdrFiltering.vertex";
  63490. import "babylonjs/Shaders/hdrFiltering.fragment";
  63491. /**
  63492. * Options for texture filtering
  63493. */
  63494. interface IHDRFilteringOptions {
  63495. /**
  63496. * Scales pixel intensity for the input HDR map.
  63497. */
  63498. hdrScale?: number;
  63499. /**
  63500. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  63501. */
  63502. quality?: number;
  63503. }
  63504. /**
  63505. * Filters HDR maps to get correct renderings of PBR reflections
  63506. */
  63507. export class HDRFiltering {
  63508. private _engine;
  63509. private _effectRenderer;
  63510. private _effectWrapper;
  63511. private _lodGenerationOffset;
  63512. private _lodGenerationScale;
  63513. /**
  63514. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  63515. * you care about baking speed.
  63516. */
  63517. quality: number;
  63518. /**
  63519. * Scales pixel intensity for the input HDR map.
  63520. */
  63521. hdrScale: number;
  63522. /**
  63523. * Instantiates HDR filter for reflection maps
  63524. *
  63525. * @param engine Thin engine
  63526. * @param options Options
  63527. */
  63528. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  63529. private _createRenderTarget;
  63530. private _prefilterInternal;
  63531. private _createEffect;
  63532. /**
  63533. * Get a value indicating if the filter is ready to be used
  63534. * @param texture Texture to filter
  63535. * @returns true if the filter is ready
  63536. */
  63537. isReady(texture: BaseTexture): boolean;
  63538. /**
  63539. * Prefilters a cube texture to have mipmap levels representing roughness values.
  63540. * Prefiltering will be invoked at the end of next rendering pass.
  63541. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  63542. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  63543. * @param texture Texture to filter
  63544. * @param onFinished Callback when filtering is done
  63545. * @return Promise called when prefiltering is done
  63546. */
  63547. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  63548. }
  63549. }
  63550. declare module "babylonjs/Materials/Textures/hdrCubeTexture" {
  63551. import { Nullable } from "babylonjs/types";
  63552. import { Scene } from "babylonjs/scene";
  63553. import { Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  63554. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  63555. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  63556. import "babylonjs/Engines/Extensions/engine.rawTexture";
  63557. import "babylonjs/Materials/Textures/baseTexture.polynomial";
  63558. /**
  63559. * This represents a texture coming from an HDR input.
  63560. *
  63561. * The only supported format is currently panorama picture stored in RGBE format.
  63562. * Example of such files can be found on HDRLib: http://hdrlib.com/
  63563. */
  63564. export class HDRCubeTexture extends BaseTexture {
  63565. private static _facesMapping;
  63566. private _generateHarmonics;
  63567. private _noMipmap;
  63568. private _prefilterOnLoad;
  63569. private _textureMatrix;
  63570. private _size;
  63571. private _onLoad;
  63572. private _onError;
  63573. /**
  63574. * The texture URL.
  63575. */
  63576. url: string;
  63577. protected _isBlocking: boolean;
  63578. /**
  63579. * Sets wether or not the texture is blocking during loading.
  63580. */
  63581. set isBlocking(value: boolean);
  63582. /**
  63583. * Gets wether or not the texture is blocking during loading.
  63584. */
  63585. get isBlocking(): boolean;
  63586. protected _rotationY: number;
  63587. /**
  63588. * Sets texture matrix rotation angle around Y axis in radians.
  63589. */
  63590. set rotationY(value: number);
  63591. /**
  63592. * Gets texture matrix rotation angle around Y axis radians.
  63593. */
  63594. get rotationY(): number;
  63595. /**
  63596. * Gets or sets the center of the bounding box associated with the cube texture
  63597. * It must define where the camera used to render the texture was set
  63598. */
  63599. boundingBoxPosition: Vector3;
  63600. private _boundingBoxSize;
  63601. /**
  63602. * Gets or sets the size of the bounding box associated with the cube texture
  63603. * When defined, the cubemap will switch to local mode
  63604. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  63605. * @example https://www.babylonjs-playground.com/#RNASML
  63606. */
  63607. set boundingBoxSize(value: Vector3);
  63608. get boundingBoxSize(): Vector3;
  63609. /**
  63610. * Instantiates an HDRTexture from the following parameters.
  63611. *
  63612. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  63613. * @param sceneOrEngine The scene or engine the texture will be used in
  63614. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  63615. * @param noMipmap Forces to not generate the mipmap if true
  63616. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  63617. * @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)
  63618. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  63619. */
  63620. 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>);
  63621. /**
  63622. * Get the current class name of the texture useful for serialization or dynamic coding.
  63623. * @returns "HDRCubeTexture"
  63624. */
  63625. getClassName(): string;
  63626. /**
  63627. * Occurs when the file is raw .hdr file.
  63628. */
  63629. private loadTexture;
  63630. clone(): HDRCubeTexture;
  63631. delayLoad(): void;
  63632. /**
  63633. * Get the texture reflection matrix used to rotate/transform the reflection.
  63634. * @returns the reflection matrix
  63635. */
  63636. getReflectionTextureMatrix(): Matrix;
  63637. /**
  63638. * Set the texture reflection matrix used to rotate/transform the reflection.
  63639. * @param value Define the reflection matrix to set
  63640. */
  63641. setReflectionTextureMatrix(value: Matrix): void;
  63642. /**
  63643. * Parses a JSON representation of an HDR Texture in order to create the texture
  63644. * @param parsedTexture Define the JSON representation
  63645. * @param scene Define the scene the texture should be created in
  63646. * @param rootUrl Define the root url in case we need to load relative dependencies
  63647. * @returns the newly created texture after parsing
  63648. */
  63649. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  63650. serialize(): any;
  63651. }
  63652. }
  63653. declare module "babylonjs/Physics/physicsEngine" {
  63654. import { Nullable } from "babylonjs/types";
  63655. import { Vector3 } from "babylonjs/Maths/math.vector";
  63656. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  63657. import { PhysicsImpostor, IPhysicsEnabledObject } from "babylonjs/Physics/physicsImpostor";
  63658. import { PhysicsJoint } from "babylonjs/Physics/physicsJoint";
  63659. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63660. /**
  63661. * Class used to control physics engine
  63662. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63663. */
  63664. export class PhysicsEngine implements IPhysicsEngine {
  63665. private _physicsPlugin;
  63666. /**
  63667. * Global value used to control the smallest number supported by the simulation
  63668. */
  63669. static Epsilon: number;
  63670. private _impostors;
  63671. private _joints;
  63672. private _subTimeStep;
  63673. /**
  63674. * Gets the gravity vector used by the simulation
  63675. */
  63676. gravity: Vector3;
  63677. /**
  63678. * Factory used to create the default physics plugin.
  63679. * @returns The default physics plugin
  63680. */
  63681. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  63682. /**
  63683. * Creates a new Physics Engine
  63684. * @param gravity defines the gravity vector used by the simulation
  63685. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  63686. */
  63687. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  63688. /**
  63689. * Sets the gravity vector used by the simulation
  63690. * @param gravity defines the gravity vector to use
  63691. */
  63692. setGravity(gravity: Vector3): void;
  63693. /**
  63694. * Set the time step of the physics engine.
  63695. * Default is 1/60.
  63696. * To slow it down, enter 1/600 for example.
  63697. * To speed it up, 1/30
  63698. * @param newTimeStep defines the new timestep to apply to this world.
  63699. */
  63700. setTimeStep(newTimeStep?: number): void;
  63701. /**
  63702. * Get the time step of the physics engine.
  63703. * @returns the current time step
  63704. */
  63705. getTimeStep(): number;
  63706. /**
  63707. * Set the sub time step of the physics engine.
  63708. * Default is 0 meaning there is no sub steps
  63709. * To increase physics resolution precision, set a small value (like 1 ms)
  63710. * @param subTimeStep defines the new sub timestep used for physics resolution.
  63711. */
  63712. setSubTimeStep(subTimeStep?: number): void;
  63713. /**
  63714. * Get the sub time step of the physics engine.
  63715. * @returns the current sub time step
  63716. */
  63717. getSubTimeStep(): number;
  63718. /**
  63719. * Release all resources
  63720. */
  63721. dispose(): void;
  63722. /**
  63723. * Gets the name of the current physics plugin
  63724. * @returns the name of the plugin
  63725. */
  63726. getPhysicsPluginName(): string;
  63727. /**
  63728. * Adding a new impostor for the impostor tracking.
  63729. * This will be done by the impostor itself.
  63730. * @param impostor the impostor to add
  63731. */
  63732. addImpostor(impostor: PhysicsImpostor): void;
  63733. /**
  63734. * Remove an impostor from the engine.
  63735. * This impostor and its mesh will not longer be updated by the physics engine.
  63736. * @param impostor the impostor to remove
  63737. */
  63738. removeImpostor(impostor: PhysicsImpostor): void;
  63739. /**
  63740. * Add a joint to the physics engine
  63741. * @param mainImpostor defines the main impostor to which the joint is added.
  63742. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  63743. * @param joint defines the joint that will connect both impostors.
  63744. */
  63745. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63746. /**
  63747. * Removes a joint from the simulation
  63748. * @param mainImpostor defines the impostor used with the joint
  63749. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  63750. * @param joint defines the joint to remove
  63751. */
  63752. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  63753. /**
  63754. * Called by the scene. No need to call it.
  63755. * @param delta defines the timespam between frames
  63756. */
  63757. _step(delta: number): void;
  63758. /**
  63759. * Gets the current plugin used to run the simulation
  63760. * @returns current plugin
  63761. */
  63762. getPhysicsPlugin(): IPhysicsEnginePlugin;
  63763. /**
  63764. * Gets the list of physic impostors
  63765. * @returns an array of PhysicsImpostor
  63766. */
  63767. getImpostors(): Array<PhysicsImpostor>;
  63768. /**
  63769. * Gets the impostor for a physics enabled object
  63770. * @param object defines the object impersonated by the impostor
  63771. * @returns the PhysicsImpostor or null if not found
  63772. */
  63773. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  63774. /**
  63775. * Gets the impostor for a physics body object
  63776. * @param body defines physics body used by the impostor
  63777. * @returns the PhysicsImpostor or null if not found
  63778. */
  63779. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  63780. /**
  63781. * Does a raycast in the physics world
  63782. * @param from when should the ray start?
  63783. * @param to when should the ray end?
  63784. * @returns PhysicsRaycastResult
  63785. */
  63786. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63787. }
  63788. }
  63789. declare module "babylonjs/Physics/Plugins/cannonJSPlugin" {
  63790. import { Nullable } from "babylonjs/types";
  63791. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63792. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63793. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63794. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63795. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63796. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63797. /** @hidden */
  63798. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  63799. private _useDeltaForWorldStep;
  63800. world: any;
  63801. name: string;
  63802. private _physicsMaterials;
  63803. private _fixedTimeStep;
  63804. private _cannonRaycastResult;
  63805. private _raycastResult;
  63806. private _physicsBodysToRemoveAfterStep;
  63807. private _firstFrame;
  63808. BJSCANNON: any;
  63809. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  63810. setGravity(gravity: Vector3): void;
  63811. setTimeStep(timeStep: number): void;
  63812. getTimeStep(): number;
  63813. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63814. private _removeMarkedPhysicsBodiesFromWorld;
  63815. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63816. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63817. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63818. private _processChildMeshes;
  63819. removePhysicsBody(impostor: PhysicsImpostor): void;
  63820. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63821. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63822. private _addMaterial;
  63823. private _checkWithEpsilon;
  63824. private _createShape;
  63825. private _createHeightmap;
  63826. private _minus90X;
  63827. private _plus90X;
  63828. private _tmpPosition;
  63829. private _tmpDeltaPosition;
  63830. private _tmpUnityRotation;
  63831. private _updatePhysicsBodyTransformation;
  63832. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63833. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63834. isSupported(): boolean;
  63835. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63836. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63837. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63838. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63839. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63840. getBodyMass(impostor: PhysicsImpostor): number;
  63841. getBodyFriction(impostor: PhysicsImpostor): number;
  63842. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63843. getBodyRestitution(impostor: PhysicsImpostor): number;
  63844. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63845. sleepBody(impostor: PhysicsImpostor): void;
  63846. wakeUpBody(impostor: PhysicsImpostor): void;
  63847. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  63848. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  63849. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  63850. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63851. getRadius(impostor: PhysicsImpostor): number;
  63852. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63853. dispose(): void;
  63854. private _extendNamespace;
  63855. /**
  63856. * Does a raycast in the physics world
  63857. * @param from when should the ray start?
  63858. * @param to when should the ray end?
  63859. * @returns PhysicsRaycastResult
  63860. */
  63861. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63862. }
  63863. }
  63864. declare module "babylonjs/Physics/Plugins/oimoJSPlugin" {
  63865. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63866. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63867. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63868. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63869. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  63870. import { Nullable } from "babylonjs/types";
  63871. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63872. /** @hidden */
  63873. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  63874. private _useDeltaForWorldStep;
  63875. world: any;
  63876. name: string;
  63877. BJSOIMO: any;
  63878. private _raycastResult;
  63879. private _fixedTimeStep;
  63880. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  63881. setGravity(gravity: Vector3): void;
  63882. setTimeStep(timeStep: number): void;
  63883. getTimeStep(): number;
  63884. private _tmpImpostorsArray;
  63885. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  63886. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63887. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  63888. generatePhysicsBody(impostor: PhysicsImpostor): void;
  63889. private _tmpPositionVector;
  63890. removePhysicsBody(impostor: PhysicsImpostor): void;
  63891. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  63892. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  63893. isSupported(): boolean;
  63894. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  63895. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  63896. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63897. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  63898. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63899. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  63900. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  63901. getBodyMass(impostor: PhysicsImpostor): number;
  63902. getBodyFriction(impostor: PhysicsImpostor): number;
  63903. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  63904. getBodyRestitution(impostor: PhysicsImpostor): number;
  63905. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  63906. sleepBody(impostor: PhysicsImpostor): void;
  63907. wakeUpBody(impostor: PhysicsImpostor): void;
  63908. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  63909. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  63910. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  63911. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  63912. getRadius(impostor: PhysicsImpostor): number;
  63913. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  63914. dispose(): void;
  63915. /**
  63916. * Does a raycast in the physics world
  63917. * @param from when should the ray start?
  63918. * @param to when should the ray end?
  63919. * @returns PhysicsRaycastResult
  63920. */
  63921. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  63922. }
  63923. }
  63924. declare module "babylonjs/Physics/Plugins/ammoJSPlugin" {
  63925. import { Quaternion, Vector3 } from "babylonjs/Maths/math.vector";
  63926. import { IPhysicsEnginePlugin, PhysicsImpostorJoint } from "babylonjs/Physics/IPhysicsEngine";
  63927. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  63928. import { PhysicsJoint, IMotorEnabledJoint } from "babylonjs/Physics/physicsJoint";
  63929. import { Nullable } from "babylonjs/types";
  63930. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  63931. import { PhysicsRaycastResult } from "babylonjs/Physics/physicsRaycastResult";
  63932. /**
  63933. * AmmoJS Physics plugin
  63934. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  63935. * @see https://github.com/kripken/ammo.js/
  63936. */
  63937. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  63938. private _useDeltaForWorldStep;
  63939. /**
  63940. * Reference to the Ammo library
  63941. */
  63942. bjsAMMO: any;
  63943. /**
  63944. * Created ammoJS world which physics bodies are added to
  63945. */
  63946. world: any;
  63947. /**
  63948. * Name of the plugin
  63949. */
  63950. name: string;
  63951. private _timeStep;
  63952. private _fixedTimeStep;
  63953. private _maxSteps;
  63954. private _tmpQuaternion;
  63955. private _tmpAmmoTransform;
  63956. private _tmpAmmoQuaternion;
  63957. private _tmpAmmoConcreteContactResultCallback;
  63958. private _collisionConfiguration;
  63959. private _dispatcher;
  63960. private _overlappingPairCache;
  63961. private _solver;
  63962. private _softBodySolver;
  63963. private _tmpAmmoVectorA;
  63964. private _tmpAmmoVectorB;
  63965. private _tmpAmmoVectorC;
  63966. private _tmpAmmoVectorD;
  63967. private _tmpContactCallbackResult;
  63968. private _tmpAmmoVectorRCA;
  63969. private _tmpAmmoVectorRCB;
  63970. private _raycastResult;
  63971. private static readonly DISABLE_COLLISION_FLAG;
  63972. private static readonly KINEMATIC_FLAG;
  63973. private static readonly DISABLE_DEACTIVATION_FLAG;
  63974. /**
  63975. * Initializes the ammoJS plugin
  63976. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  63977. * @param ammoInjection can be used to inject your own ammo reference
  63978. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  63979. */
  63980. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  63981. /**
  63982. * Sets the gravity of the physics world (m/(s^2))
  63983. * @param gravity Gravity to set
  63984. */
  63985. setGravity(gravity: Vector3): void;
  63986. /**
  63987. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  63988. * @param timeStep timestep to use in seconds
  63989. */
  63990. setTimeStep(timeStep: number): void;
  63991. /**
  63992. * 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)
  63993. * @param fixedTimeStep fixedTimeStep to use in seconds
  63994. */
  63995. setFixedTimeStep(fixedTimeStep: number): void;
  63996. /**
  63997. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  63998. * @param maxSteps the maximum number of steps by the physics engine per frame
  63999. */
  64000. setMaxSteps(maxSteps: number): void;
  64001. /**
  64002. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  64003. * @returns the current timestep in seconds
  64004. */
  64005. getTimeStep(): number;
  64006. /**
  64007. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  64008. */
  64009. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  64010. private _isImpostorInContact;
  64011. private _isImpostorPairInContact;
  64012. private _stepSimulation;
  64013. /**
  64014. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  64015. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  64016. * After the step the babylon meshes are set to the position of the physics imposters
  64017. * @param delta amount of time to step forward
  64018. * @param impostors array of imposters to update before/after the step
  64019. */
  64020. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  64021. /**
  64022. * Update babylon mesh to match physics world object
  64023. * @param impostor imposter to match
  64024. */
  64025. private _afterSoftStep;
  64026. /**
  64027. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64028. * @param impostor imposter to match
  64029. */
  64030. private _ropeStep;
  64031. /**
  64032. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  64033. * @param impostor imposter to match
  64034. */
  64035. private _softbodyOrClothStep;
  64036. private _tmpMatrix;
  64037. /**
  64038. * Applies an impulse on the imposter
  64039. * @param impostor imposter to apply impulse to
  64040. * @param force amount of force to be applied to the imposter
  64041. * @param contactPoint the location to apply the impulse on the imposter
  64042. */
  64043. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64044. /**
  64045. * Applies a force on the imposter
  64046. * @param impostor imposter to apply force
  64047. * @param force amount of force to be applied to the imposter
  64048. * @param contactPoint the location to apply the force on the imposter
  64049. */
  64050. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  64051. /**
  64052. * Creates a physics body using the plugin
  64053. * @param impostor the imposter to create the physics body on
  64054. */
  64055. generatePhysicsBody(impostor: PhysicsImpostor): void;
  64056. /**
  64057. * Removes the physics body from the imposter and disposes of the body's memory
  64058. * @param impostor imposter to remove the physics body from
  64059. */
  64060. removePhysicsBody(impostor: PhysicsImpostor): void;
  64061. /**
  64062. * Generates a joint
  64063. * @param impostorJoint the imposter joint to create the joint with
  64064. */
  64065. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  64066. /**
  64067. * Removes a joint
  64068. * @param impostorJoint the imposter joint to remove the joint from
  64069. */
  64070. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  64071. private _addMeshVerts;
  64072. /**
  64073. * Initialise the soft body vertices to match its object's (mesh) vertices
  64074. * Softbody vertices (nodes) are in world space and to match this
  64075. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  64076. * @param impostor to create the softbody for
  64077. */
  64078. private _softVertexData;
  64079. /**
  64080. * Create an impostor's soft body
  64081. * @param impostor to create the softbody for
  64082. */
  64083. private _createSoftbody;
  64084. /**
  64085. * Create cloth for an impostor
  64086. * @param impostor to create the softbody for
  64087. */
  64088. private _createCloth;
  64089. /**
  64090. * Create rope for an impostor
  64091. * @param impostor to create the softbody for
  64092. */
  64093. private _createRope;
  64094. /**
  64095. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  64096. * @param impostor to create the custom physics shape for
  64097. */
  64098. private _createCustom;
  64099. private _addHullVerts;
  64100. private _createShape;
  64101. /**
  64102. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  64103. * @param impostor imposter containing the physics body and babylon object
  64104. */
  64105. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  64106. /**
  64107. * Sets the babylon object's position/rotation from the physics body's position/rotation
  64108. * @param impostor imposter containing the physics body and babylon object
  64109. * @param newPosition new position
  64110. * @param newRotation new rotation
  64111. */
  64112. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  64113. /**
  64114. * If this plugin is supported
  64115. * @returns true if its supported
  64116. */
  64117. isSupported(): boolean;
  64118. /**
  64119. * Sets the linear velocity of the physics body
  64120. * @param impostor imposter to set the velocity on
  64121. * @param velocity velocity to set
  64122. */
  64123. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64124. /**
  64125. * Sets the angular velocity of the physics body
  64126. * @param impostor imposter to set the velocity on
  64127. * @param velocity velocity to set
  64128. */
  64129. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  64130. /**
  64131. * gets the linear velocity
  64132. * @param impostor imposter to get linear velocity from
  64133. * @returns linear velocity
  64134. */
  64135. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64136. /**
  64137. * gets the angular velocity
  64138. * @param impostor imposter to get angular velocity from
  64139. * @returns angular velocity
  64140. */
  64141. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  64142. /**
  64143. * Sets the mass of physics body
  64144. * @param impostor imposter to set the mass on
  64145. * @param mass mass to set
  64146. */
  64147. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  64148. /**
  64149. * Gets the mass of the physics body
  64150. * @param impostor imposter to get the mass from
  64151. * @returns mass
  64152. */
  64153. getBodyMass(impostor: PhysicsImpostor): number;
  64154. /**
  64155. * Gets friction of the impostor
  64156. * @param impostor impostor to get friction from
  64157. * @returns friction value
  64158. */
  64159. getBodyFriction(impostor: PhysicsImpostor): number;
  64160. /**
  64161. * Sets friction of the impostor
  64162. * @param impostor impostor to set friction on
  64163. * @param friction friction value
  64164. */
  64165. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  64166. /**
  64167. * Gets restitution of the impostor
  64168. * @param impostor impostor to get restitution from
  64169. * @returns restitution value
  64170. */
  64171. getBodyRestitution(impostor: PhysicsImpostor): number;
  64172. /**
  64173. * Sets resitution of the impostor
  64174. * @param impostor impostor to set resitution on
  64175. * @param restitution resitution value
  64176. */
  64177. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  64178. /**
  64179. * Gets pressure inside the impostor
  64180. * @param impostor impostor to get pressure from
  64181. * @returns pressure value
  64182. */
  64183. getBodyPressure(impostor: PhysicsImpostor): number;
  64184. /**
  64185. * Sets pressure inside a soft body impostor
  64186. * Cloth and rope must remain 0 pressure
  64187. * @param impostor impostor to set pressure on
  64188. * @param pressure pressure value
  64189. */
  64190. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  64191. /**
  64192. * Gets stiffness of the impostor
  64193. * @param impostor impostor to get stiffness from
  64194. * @returns pressure value
  64195. */
  64196. getBodyStiffness(impostor: PhysicsImpostor): number;
  64197. /**
  64198. * Sets stiffness of the impostor
  64199. * @param impostor impostor to set stiffness on
  64200. * @param stiffness stiffness value from 0 to 1
  64201. */
  64202. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  64203. /**
  64204. * Gets velocityIterations of the impostor
  64205. * @param impostor impostor to get velocity iterations from
  64206. * @returns velocityIterations value
  64207. */
  64208. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  64209. /**
  64210. * Sets velocityIterations of the impostor
  64211. * @param impostor impostor to set velocity iterations on
  64212. * @param velocityIterations velocityIterations value
  64213. */
  64214. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  64215. /**
  64216. * Gets positionIterations of the impostor
  64217. * @param impostor impostor to get position iterations from
  64218. * @returns positionIterations value
  64219. */
  64220. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  64221. /**
  64222. * Sets positionIterations of the impostor
  64223. * @param impostor impostor to set position on
  64224. * @param positionIterations positionIterations value
  64225. */
  64226. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  64227. /**
  64228. * Append an anchor to a cloth object
  64229. * @param impostor is the cloth impostor to add anchor to
  64230. * @param otherImpostor is the rigid impostor to anchor to
  64231. * @param width ratio across width from 0 to 1
  64232. * @param height ratio up height from 0 to 1
  64233. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  64234. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64235. */
  64236. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64237. /**
  64238. * Append an hook to a rope object
  64239. * @param impostor is the rope impostor to add hook to
  64240. * @param otherImpostor is the rigid impostor to hook to
  64241. * @param length ratio along the rope from 0 to 1
  64242. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  64243. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  64244. */
  64245. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  64246. /**
  64247. * Sleeps the physics body and stops it from being active
  64248. * @param impostor impostor to sleep
  64249. */
  64250. sleepBody(impostor: PhysicsImpostor): void;
  64251. /**
  64252. * Activates the physics body
  64253. * @param impostor impostor to activate
  64254. */
  64255. wakeUpBody(impostor: PhysicsImpostor): void;
  64256. /**
  64257. * Updates the distance parameters of the joint
  64258. * @param joint joint to update
  64259. * @param maxDistance maximum distance of the joint
  64260. * @param minDistance minimum distance of the joint
  64261. */
  64262. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  64263. /**
  64264. * Sets a motor on the joint
  64265. * @param joint joint to set motor on
  64266. * @param speed speed of the motor
  64267. * @param maxForce maximum force of the motor
  64268. * @param motorIndex index of the motor
  64269. */
  64270. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  64271. /**
  64272. * Sets the motors limit
  64273. * @param joint joint to set limit on
  64274. * @param upperLimit upper limit
  64275. * @param lowerLimit lower limit
  64276. */
  64277. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  64278. /**
  64279. * Syncs the position and rotation of a mesh with the impostor
  64280. * @param mesh mesh to sync
  64281. * @param impostor impostor to update the mesh with
  64282. */
  64283. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  64284. /**
  64285. * Gets the radius of the impostor
  64286. * @param impostor impostor to get radius from
  64287. * @returns the radius
  64288. */
  64289. getRadius(impostor: PhysicsImpostor): number;
  64290. /**
  64291. * Gets the box size of the impostor
  64292. * @param impostor impostor to get box size from
  64293. * @param result the resulting box size
  64294. */
  64295. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  64296. /**
  64297. * Disposes of the impostor
  64298. */
  64299. dispose(): void;
  64300. /**
  64301. * Does a raycast in the physics world
  64302. * @param from when should the ray start?
  64303. * @param to when should the ray end?
  64304. * @returns PhysicsRaycastResult
  64305. */
  64306. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  64307. }
  64308. }
  64309. declare module "babylonjs/Probes/reflectionProbe" {
  64310. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  64311. import { Vector3 } from "babylonjs/Maths/math.vector";
  64312. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  64313. import { Nullable } from "babylonjs/types";
  64314. import { Scene } from "babylonjs/scene";
  64315. module "babylonjs/abstractScene" {
  64316. interface AbstractScene {
  64317. /**
  64318. * The list of reflection probes added to the scene
  64319. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64320. */
  64321. reflectionProbes: Array<ReflectionProbe>;
  64322. /**
  64323. * Removes the given reflection probe from this scene.
  64324. * @param toRemove The reflection probe to remove
  64325. * @returns The index of the removed reflection probe
  64326. */
  64327. removeReflectionProbe(toRemove: ReflectionProbe): number;
  64328. /**
  64329. * Adds the given reflection probe to this scene.
  64330. * @param newReflectionProbe The reflection probe to add
  64331. */
  64332. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  64333. }
  64334. }
  64335. /**
  64336. * Class used to generate realtime reflection / refraction cube textures
  64337. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  64338. */
  64339. export class ReflectionProbe {
  64340. /** defines the name of the probe */
  64341. name: string;
  64342. private _scene;
  64343. private _renderTargetTexture;
  64344. private _projectionMatrix;
  64345. private _viewMatrix;
  64346. private _target;
  64347. private _add;
  64348. private _attachedMesh;
  64349. private _invertYAxis;
  64350. /** Gets or sets probe position (center of the cube map) */
  64351. position: Vector3;
  64352. /**
  64353. * Creates a new reflection probe
  64354. * @param name defines the name of the probe
  64355. * @param size defines the texture resolution (for each face)
  64356. * @param scene defines the hosting scene
  64357. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  64358. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  64359. */
  64360. constructor(
  64361. /** defines the name of the probe */
  64362. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  64363. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  64364. get samples(): number;
  64365. set samples(value: number);
  64366. /** Gets or sets the refresh rate to use (on every frame by default) */
  64367. get refreshRate(): number;
  64368. set refreshRate(value: number);
  64369. /**
  64370. * Gets the hosting scene
  64371. * @returns a Scene
  64372. */
  64373. getScene(): Scene;
  64374. /** Gets the internal CubeTexture used to render to */
  64375. get cubeTexture(): RenderTargetTexture;
  64376. /** Gets the list of meshes to render */
  64377. get renderList(): Nullable<AbstractMesh[]>;
  64378. /**
  64379. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  64380. * @param mesh defines the mesh to attach to
  64381. */
  64382. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  64383. /**
  64384. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  64385. * @param renderingGroupId The rendering group id corresponding to its index
  64386. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  64387. */
  64388. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  64389. /**
  64390. * Clean all associated resources
  64391. */
  64392. dispose(): void;
  64393. /**
  64394. * Converts the reflection probe information to a readable string for debug purpose.
  64395. * @param fullDetails Supports for multiple levels of logging within scene loading
  64396. * @returns the human readable reflection probe info
  64397. */
  64398. toString(fullDetails?: boolean): string;
  64399. /**
  64400. * Get the class name of the relfection probe.
  64401. * @returns "ReflectionProbe"
  64402. */
  64403. getClassName(): string;
  64404. /**
  64405. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  64406. * @returns The JSON representation of the texture
  64407. */
  64408. serialize(): any;
  64409. /**
  64410. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  64411. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  64412. * @param scene Define the scene the parsed reflection probe should be instantiated in
  64413. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  64414. * @returns The parsed reflection probe if successful
  64415. */
  64416. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  64417. }
  64418. }
  64419. declare module "babylonjs/Loading/Plugins/babylonFileLoader" {
  64420. /** @hidden */
  64421. export var _BabylonLoaderRegistered: boolean;
  64422. /**
  64423. * Helps setting up some configuration for the babylon file loader.
  64424. */
  64425. export class BabylonFileLoaderConfiguration {
  64426. /**
  64427. * The loader does not allow injecting custom physix engine into the plugins.
  64428. * Unfortunately in ES6, we need to manually inject them into the plugin.
  64429. * So you could set this variable to your engine import to make it work.
  64430. */
  64431. static LoaderInjectedPhysicsEngine: any;
  64432. }
  64433. }
  64434. declare module "babylonjs/Loading/Plugins/index" {
  64435. export * from "babylonjs/Loading/Plugins/babylonFileLoader";
  64436. }
  64437. declare module "babylonjs/Loading/index" {
  64438. export * from "babylonjs/Loading/loadingScreen";
  64439. export * from "babylonjs/Loading/Plugins/index";
  64440. export * from "babylonjs/Loading/sceneLoader";
  64441. export * from "babylonjs/Loading/sceneLoaderFlags";
  64442. }
  64443. declare module "babylonjs/Materials/Background/index" {
  64444. export * from "babylonjs/Materials/Background/backgroundMaterial";
  64445. }
  64446. declare module "babylonjs/Materials/PBR/pbrBaseSimpleMaterial" {
  64447. import { Scene } from "babylonjs/scene";
  64448. import { Color3 } from "babylonjs/Maths/math.color";
  64449. import { PBRBaseMaterial } from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64450. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64451. /**
  64452. * The Physically based simple base material of BJS.
  64453. *
  64454. * This enables better naming and convention enforcements on top of the pbrMaterial.
  64455. * It is used as the base class for both the specGloss and metalRough conventions.
  64456. */
  64457. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  64458. /**
  64459. * Number of Simultaneous lights allowed on the material.
  64460. */
  64461. maxSimultaneousLights: number;
  64462. /**
  64463. * If sets to true, disables all the lights affecting the material.
  64464. */
  64465. disableLighting: boolean;
  64466. /**
  64467. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  64468. */
  64469. environmentTexture: BaseTexture;
  64470. /**
  64471. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  64472. */
  64473. invertNormalMapX: boolean;
  64474. /**
  64475. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  64476. */
  64477. invertNormalMapY: boolean;
  64478. /**
  64479. * Normal map used in the model.
  64480. */
  64481. normalTexture: BaseTexture;
  64482. /**
  64483. * Emissivie color used to self-illuminate the model.
  64484. */
  64485. emissiveColor: Color3;
  64486. /**
  64487. * Emissivie texture used to self-illuminate the model.
  64488. */
  64489. emissiveTexture: BaseTexture;
  64490. /**
  64491. * Occlusion Channel Strenght.
  64492. */
  64493. occlusionStrength: number;
  64494. /**
  64495. * Occlusion Texture of the material (adding extra occlusion effects).
  64496. */
  64497. occlusionTexture: BaseTexture;
  64498. /**
  64499. * Defines the alpha limits in alpha test mode.
  64500. */
  64501. alphaCutOff: number;
  64502. /**
  64503. * Gets the current double sided mode.
  64504. */
  64505. get doubleSided(): boolean;
  64506. /**
  64507. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  64508. */
  64509. set doubleSided(value: boolean);
  64510. /**
  64511. * Stores the pre-calculated light information of a mesh in a texture.
  64512. */
  64513. lightmapTexture: BaseTexture;
  64514. /**
  64515. * If true, the light map contains occlusion information instead of lighting info.
  64516. */
  64517. useLightmapAsShadowmap: boolean;
  64518. /**
  64519. * Instantiates a new PBRMaterial instance.
  64520. *
  64521. * @param name The material name
  64522. * @param scene The scene the material will be use in.
  64523. */
  64524. constructor(name: string, scene: Scene);
  64525. getClassName(): string;
  64526. }
  64527. }
  64528. declare module "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial" {
  64529. import { Scene } from "babylonjs/scene";
  64530. import { Color3 } from "babylonjs/Maths/math.color";
  64531. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64532. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64533. /**
  64534. * The PBR material of BJS following the metal roughness convention.
  64535. *
  64536. * This fits to the PBR convention in the GLTF definition:
  64537. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  64538. */
  64539. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  64540. /**
  64541. * The base color has two different interpretations depending on the value of metalness.
  64542. * When the material is a metal, the base color is the specific measured reflectance value
  64543. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  64544. * of the material.
  64545. */
  64546. baseColor: Color3;
  64547. /**
  64548. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  64549. * well as opacity information in the alpha channel.
  64550. */
  64551. baseTexture: BaseTexture;
  64552. /**
  64553. * Specifies the metallic scalar value of the material.
  64554. * Can also be used to scale the metalness values of the metallic texture.
  64555. */
  64556. metallic: number;
  64557. /**
  64558. * Specifies the roughness scalar value of the material.
  64559. * Can also be used to scale the roughness values of the metallic texture.
  64560. */
  64561. roughness: number;
  64562. /**
  64563. * Texture containing both the metallic value in the B channel and the
  64564. * roughness value in the G channel to keep better precision.
  64565. */
  64566. metallicRoughnessTexture: BaseTexture;
  64567. /**
  64568. * Instantiates a new PBRMetalRoughnessMaterial instance.
  64569. *
  64570. * @param name The material name
  64571. * @param scene The scene the material will be use in.
  64572. */
  64573. constructor(name: string, scene: Scene);
  64574. /**
  64575. * Return the currrent class name of the material.
  64576. */
  64577. getClassName(): string;
  64578. /**
  64579. * Makes a duplicate of the current material.
  64580. * @param name - name to use for the new material.
  64581. */
  64582. clone(name: string): PBRMetallicRoughnessMaterial;
  64583. /**
  64584. * Serialize the material to a parsable JSON object.
  64585. */
  64586. serialize(): any;
  64587. /**
  64588. * Parses a JSON object correponding to the serialize function.
  64589. */
  64590. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  64591. }
  64592. }
  64593. declare module "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial" {
  64594. import { Scene } from "babylonjs/scene";
  64595. import { Color3 } from "babylonjs/Maths/math.color";
  64596. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64597. import { PBRBaseSimpleMaterial } from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64598. /**
  64599. * The PBR material of BJS following the specular glossiness convention.
  64600. *
  64601. * This fits to the PBR convention in the GLTF definition:
  64602. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  64603. */
  64604. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  64605. /**
  64606. * Specifies the diffuse color of the material.
  64607. */
  64608. diffuseColor: Color3;
  64609. /**
  64610. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  64611. * channel.
  64612. */
  64613. diffuseTexture: BaseTexture;
  64614. /**
  64615. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  64616. */
  64617. specularColor: Color3;
  64618. /**
  64619. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  64620. */
  64621. glossiness: number;
  64622. /**
  64623. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  64624. */
  64625. specularGlossinessTexture: BaseTexture;
  64626. /**
  64627. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  64628. *
  64629. * @param name The material name
  64630. * @param scene The scene the material will be use in.
  64631. */
  64632. constructor(name: string, scene: Scene);
  64633. /**
  64634. * Return the currrent class name of the material.
  64635. */
  64636. getClassName(): string;
  64637. /**
  64638. * Makes a duplicate of the current material.
  64639. * @param name - name to use for the new material.
  64640. */
  64641. clone(name: string): PBRSpecularGlossinessMaterial;
  64642. /**
  64643. * Serialize the material to a parsable JSON object.
  64644. */
  64645. serialize(): any;
  64646. /**
  64647. * Parses a JSON object correponding to the serialize function.
  64648. */
  64649. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  64650. }
  64651. }
  64652. declare module "babylonjs/Materials/PBR/index" {
  64653. export * from "babylonjs/Materials/PBR/pbrBaseMaterial";
  64654. export * from "babylonjs/Materials/PBR/pbrBaseSimpleMaterial";
  64655. export * from "babylonjs/Materials/PBR/pbrMaterial";
  64656. export * from "babylonjs/Materials/PBR/pbrMetallicRoughnessMaterial";
  64657. export * from "babylonjs/Materials/PBR/pbrSpecularGlossinessMaterial";
  64658. }
  64659. declare module "babylonjs/Materials/Textures/colorGradingTexture" {
  64660. import { Nullable } from "babylonjs/types";
  64661. import { Scene } from "babylonjs/scene";
  64662. import { Matrix } from "babylonjs/Maths/math.vector";
  64663. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64664. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64665. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64666. /**
  64667. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  64668. * It can help converting any input color in a desired output one. This can then be used to create effects
  64669. * from sepia, black and white to sixties or futuristic rendering...
  64670. *
  64671. * The only supported format is currently 3dl.
  64672. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  64673. */
  64674. export class ColorGradingTexture extends BaseTexture {
  64675. /**
  64676. * The texture URL.
  64677. */
  64678. url: string;
  64679. /**
  64680. * Empty line regex stored for GC.
  64681. */
  64682. private static _noneEmptyLineRegex;
  64683. private _textureMatrix;
  64684. private _onLoad;
  64685. /**
  64686. * Instantiates a ColorGradingTexture from the following parameters.
  64687. *
  64688. * @param url The location of the color gradind data (currently only supporting 3dl)
  64689. * @param sceneOrEngine The scene or engine the texture will be used in
  64690. * @param onLoad defines a callback triggered when the texture has been loaded
  64691. */
  64692. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  64693. /**
  64694. * Fires the onload event from the constructor if requested.
  64695. */
  64696. private _triggerOnLoad;
  64697. /**
  64698. * Returns the texture matrix used in most of the material.
  64699. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  64700. */
  64701. getTextureMatrix(): Matrix;
  64702. /**
  64703. * Occurs when the file being loaded is a .3dl LUT file.
  64704. */
  64705. private load3dlTexture;
  64706. /**
  64707. * Starts the loading process of the texture.
  64708. */
  64709. private loadTexture;
  64710. /**
  64711. * Clones the color gradind texture.
  64712. */
  64713. clone(): ColorGradingTexture;
  64714. /**
  64715. * Called during delayed load for textures.
  64716. */
  64717. delayLoad(): void;
  64718. /**
  64719. * Parses a color grading texture serialized by Babylon.
  64720. * @param parsedTexture The texture information being parsedTexture
  64721. * @param scene The scene to load the texture in
  64722. * @param rootUrl The root url of the data assets to load
  64723. * @return A color gradind texture
  64724. */
  64725. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  64726. /**
  64727. * Serializes the LUT texture to json format.
  64728. */
  64729. serialize(): any;
  64730. }
  64731. }
  64732. declare module "babylonjs/Materials/Textures/equiRectangularCubeTexture" {
  64733. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64734. import { Scene } from "babylonjs/scene";
  64735. import { Nullable } from "babylonjs/types";
  64736. import "babylonjs/Engines/Extensions/engine.rawTexture";
  64737. /**
  64738. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  64739. */
  64740. export class EquiRectangularCubeTexture extends BaseTexture {
  64741. /** The six faces of the cube. */
  64742. private static _FacesMapping;
  64743. private _noMipmap;
  64744. private _onLoad;
  64745. private _onError;
  64746. /** The size of the cubemap. */
  64747. private _size;
  64748. /** The buffer of the image. */
  64749. private _buffer;
  64750. /** The width of the input image. */
  64751. private _width;
  64752. /** The height of the input image. */
  64753. private _height;
  64754. /** The URL to the image. */
  64755. url: string;
  64756. /**
  64757. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  64758. * @param url The location of the image
  64759. * @param scene The scene the texture will be used in
  64760. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  64761. * @param noMipmap Forces to not generate the mipmap if true
  64762. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  64763. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  64764. * @param onLoad — defines a callback called when texture is loaded
  64765. * @param onError — defines a callback called if there is an error
  64766. */
  64767. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  64768. /**
  64769. * Load the image data, by putting the image on a canvas and extracting its buffer.
  64770. */
  64771. private loadImage;
  64772. /**
  64773. * Convert the image buffer into a cubemap and create a CubeTexture.
  64774. */
  64775. private loadTexture;
  64776. /**
  64777. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  64778. * @param buffer The ArrayBuffer that should be converted.
  64779. * @returns The buffer as Float32Array.
  64780. */
  64781. private getFloat32ArrayFromArrayBuffer;
  64782. /**
  64783. * Get the current class name of the texture useful for serialization or dynamic coding.
  64784. * @returns "EquiRectangularCubeTexture"
  64785. */
  64786. getClassName(): string;
  64787. /**
  64788. * Create a clone of the current EquiRectangularCubeTexture and return it.
  64789. * @returns A clone of the current EquiRectangularCubeTexture.
  64790. */
  64791. clone(): EquiRectangularCubeTexture;
  64792. }
  64793. }
  64794. declare module "babylonjs/Materials/Textures/htmlElementTexture" {
  64795. import { Nullable } from "babylonjs/types";
  64796. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  64797. import { Matrix } from "babylonjs/Maths/math.vector";
  64798. import "babylonjs/Engines/Extensions/engine.dynamicTexture";
  64799. import "babylonjs/Engines/Extensions/engine.videoTexture";
  64800. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  64801. import { Scene } from "babylonjs/scene";
  64802. /**
  64803. * Defines the options related to the creation of an HtmlElementTexture
  64804. */
  64805. export interface IHtmlElementTextureOptions {
  64806. /**
  64807. * Defines wether mip maps should be created or not.
  64808. */
  64809. generateMipMaps?: boolean;
  64810. /**
  64811. * Defines the sampling mode of the texture.
  64812. */
  64813. samplingMode?: number;
  64814. /**
  64815. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  64816. */
  64817. engine: Nullable<ThinEngine>;
  64818. /**
  64819. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  64820. */
  64821. scene: Nullable<Scene>;
  64822. }
  64823. /**
  64824. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  64825. * To be as efficient as possible depending on your constraints nothing aside the first upload
  64826. * is automatically managed.
  64827. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  64828. * in your application.
  64829. *
  64830. * As the update is not automatic, you need to call them manually.
  64831. */
  64832. export class HtmlElementTexture extends BaseTexture {
  64833. /**
  64834. * The texture URL.
  64835. */
  64836. element: HTMLVideoElement | HTMLCanvasElement;
  64837. private static readonly DefaultOptions;
  64838. private _textureMatrix;
  64839. private _isVideo;
  64840. private _generateMipMaps;
  64841. private _samplingMode;
  64842. /**
  64843. * Instantiates a HtmlElementTexture from the following parameters.
  64844. *
  64845. * @param name Defines the name of the texture
  64846. * @param element Defines the video or canvas the texture is filled with
  64847. * @param options Defines the other none mandatory texture creation options
  64848. */
  64849. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  64850. private _createInternalTexture;
  64851. /**
  64852. * Returns the texture matrix used in most of the material.
  64853. */
  64854. getTextureMatrix(): Matrix;
  64855. /**
  64856. * Updates the content of the texture.
  64857. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  64858. */
  64859. update(invertY?: Nullable<boolean>): void;
  64860. }
  64861. }
  64862. declare module "babylonjs/Misc/tga" {
  64863. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64864. /**
  64865. * Based on jsTGALoader - Javascript loader for TGA file
  64866. * By Vincent Thibault
  64867. * @see http://blog.robrowser.com/javascript-tga-loader.html
  64868. */
  64869. export class TGATools {
  64870. private static _TYPE_INDEXED;
  64871. private static _TYPE_RGB;
  64872. private static _TYPE_GREY;
  64873. private static _TYPE_RLE_INDEXED;
  64874. private static _TYPE_RLE_RGB;
  64875. private static _TYPE_RLE_GREY;
  64876. private static _ORIGIN_MASK;
  64877. private static _ORIGIN_SHIFT;
  64878. private static _ORIGIN_BL;
  64879. private static _ORIGIN_BR;
  64880. private static _ORIGIN_UL;
  64881. private static _ORIGIN_UR;
  64882. /**
  64883. * Gets the header of a TGA file
  64884. * @param data defines the TGA data
  64885. * @returns the header
  64886. */
  64887. static GetTGAHeader(data: Uint8Array): any;
  64888. /**
  64889. * Uploads TGA content to a Babylon Texture
  64890. * @hidden
  64891. */
  64892. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  64893. /** @hidden */
  64894. 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;
  64895. /** @hidden */
  64896. 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;
  64897. /** @hidden */
  64898. 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;
  64899. /** @hidden */
  64900. 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;
  64901. /** @hidden */
  64902. 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;
  64903. /** @hidden */
  64904. 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;
  64905. }
  64906. }
  64907. declare module "babylonjs/Materials/Textures/Loaders/tgaTextureLoader" {
  64908. import { Nullable } from "babylonjs/types";
  64909. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64910. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  64911. /**
  64912. * Implementation of the TGA Texture Loader.
  64913. * @hidden
  64914. */
  64915. export class _TGATextureLoader implements IInternalTextureLoader {
  64916. /**
  64917. * Defines wether the loader supports cascade loading the different faces.
  64918. */
  64919. readonly supportCascades: boolean;
  64920. /**
  64921. * This returns if the loader support the current file information.
  64922. * @param extension defines the file extension of the file being loaded
  64923. * @returns true if the loader can load the specified file
  64924. */
  64925. canLoad(extension: string): boolean;
  64926. /**
  64927. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  64928. * @param data contains the texture data
  64929. * @param texture defines the BabylonJS internal texture
  64930. * @param createPolynomials will be true if polynomials have been requested
  64931. * @param onLoad defines the callback to trigger once the texture is ready
  64932. * @param onError defines the callback to trigger in case of error
  64933. */
  64934. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  64935. /**
  64936. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  64937. * @param data contains the texture data
  64938. * @param texture defines the BabylonJS internal texture
  64939. * @param callback defines the method to call once ready to upload
  64940. */
  64941. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  64942. }
  64943. }
  64944. declare module "babylonjs/Misc/basis" {
  64945. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  64946. /**
  64947. * Info about the .basis files
  64948. */
  64949. class BasisFileInfo {
  64950. /**
  64951. * If the file has alpha
  64952. */
  64953. hasAlpha: boolean;
  64954. /**
  64955. * Info about each image of the basis file
  64956. */
  64957. images: Array<{
  64958. levels: Array<{
  64959. width: number;
  64960. height: number;
  64961. transcodedPixels: ArrayBufferView;
  64962. }>;
  64963. }>;
  64964. }
  64965. /**
  64966. * Result of transcoding a basis file
  64967. */
  64968. class TranscodeResult {
  64969. /**
  64970. * Info about the .basis file
  64971. */
  64972. fileInfo: BasisFileInfo;
  64973. /**
  64974. * Format to use when loading the file
  64975. */
  64976. format: number;
  64977. }
  64978. /**
  64979. * Configuration options for the Basis transcoder
  64980. */
  64981. export class BasisTranscodeConfiguration {
  64982. /**
  64983. * Supported compression formats used to determine the supported output format of the transcoder
  64984. */
  64985. supportedCompressionFormats?: {
  64986. /**
  64987. * etc1 compression format
  64988. */
  64989. etc1?: boolean;
  64990. /**
  64991. * s3tc compression format
  64992. */
  64993. s3tc?: boolean;
  64994. /**
  64995. * pvrtc compression format
  64996. */
  64997. pvrtc?: boolean;
  64998. /**
  64999. * etc2 compression format
  65000. */
  65001. etc2?: boolean;
  65002. };
  65003. /**
  65004. * If mipmap levels should be loaded for transcoded images (Default: true)
  65005. */
  65006. loadMipmapLevels?: boolean;
  65007. /**
  65008. * Index of a single image to load (Default: all images)
  65009. */
  65010. loadSingleImage?: number;
  65011. }
  65012. /**
  65013. * Used to load .Basis files
  65014. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  65015. */
  65016. export class BasisTools {
  65017. private static _IgnoreSupportedFormats;
  65018. /**
  65019. * URL to use when loading the basis transcoder
  65020. */
  65021. static JSModuleURL: string;
  65022. /**
  65023. * URL to use when loading the wasm module for the transcoder
  65024. */
  65025. static WasmModuleURL: string;
  65026. /**
  65027. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  65028. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  65029. * @returns internal format corresponding to the Basis format
  65030. */
  65031. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  65032. private static _WorkerPromise;
  65033. private static _Worker;
  65034. private static _actionId;
  65035. private static _CreateWorkerAsync;
  65036. /**
  65037. * Transcodes a loaded image file to compressed pixel data
  65038. * @param data image data to transcode
  65039. * @param config configuration options for the transcoding
  65040. * @returns a promise resulting in the transcoded image
  65041. */
  65042. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  65043. /**
  65044. * Loads a texture from the transcode result
  65045. * @param texture texture load to
  65046. * @param transcodeResult the result of transcoding the basis file to load from
  65047. */
  65048. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  65049. }
  65050. }
  65051. declare module "babylonjs/Materials/Textures/Loaders/basisTextureLoader" {
  65052. import { Nullable } from "babylonjs/types";
  65053. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65054. import { IInternalTextureLoader } from "babylonjs/Materials/Textures/internalTextureLoader";
  65055. /**
  65056. * Loader for .basis file format
  65057. */
  65058. export class _BasisTextureLoader implements IInternalTextureLoader {
  65059. /**
  65060. * Defines whether the loader supports cascade loading the different faces.
  65061. */
  65062. readonly supportCascades: boolean;
  65063. /**
  65064. * This returns if the loader support the current file information.
  65065. * @param extension defines the file extension of the file being loaded
  65066. * @returns true if the loader can load the specified file
  65067. */
  65068. canLoad(extension: string): boolean;
  65069. /**
  65070. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  65071. * @param data contains the texture data
  65072. * @param texture defines the BabylonJS internal texture
  65073. * @param createPolynomials will be true if polynomials have been requested
  65074. * @param onLoad defines the callback to trigger once the texture is ready
  65075. * @param onError defines the callback to trigger in case of error
  65076. */
  65077. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  65078. /**
  65079. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  65080. * @param data contains the texture data
  65081. * @param texture defines the BabylonJS internal texture
  65082. * @param callback defines the method to call once ready to upload
  65083. */
  65084. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  65085. }
  65086. }
  65087. declare module "babylonjs/Materials/Textures/Loaders/index" {
  65088. export * from "babylonjs/Materials/Textures/Loaders/ddsTextureLoader";
  65089. export * from "babylonjs/Materials/Textures/Loaders/envTextureLoader";
  65090. export * from "babylonjs/Materials/Textures/Loaders/ktxTextureLoader";
  65091. export * from "babylonjs/Materials/Textures/Loaders/tgaTextureLoader";
  65092. export * from "babylonjs/Materials/Textures/Loaders/basisTextureLoader";
  65093. }
  65094. declare module "babylonjs/Materials/Textures/Packer/frame" {
  65095. import { Vector2 } from "babylonjs/Maths/math.vector";
  65096. /**
  65097. * Defines the basic options interface of a TexturePacker Frame
  65098. */
  65099. export interface ITexturePackerFrame {
  65100. /**
  65101. * The frame ID
  65102. */
  65103. id: number;
  65104. /**
  65105. * The frames Scale
  65106. */
  65107. scale: Vector2;
  65108. /**
  65109. * The Frames offset
  65110. */
  65111. offset: Vector2;
  65112. }
  65113. /**
  65114. * This is a support class for frame Data on texture packer sets.
  65115. */
  65116. export class TexturePackerFrame implements ITexturePackerFrame {
  65117. /**
  65118. * The frame ID
  65119. */
  65120. id: number;
  65121. /**
  65122. * The frames Scale
  65123. */
  65124. scale: Vector2;
  65125. /**
  65126. * The Frames offset
  65127. */
  65128. offset: Vector2;
  65129. /**
  65130. * Initializes a texture package frame.
  65131. * @param id The numerical frame identifier
  65132. * @param scale Scalar Vector2 for UV frame
  65133. * @param offset Vector2 for the frame position in UV units.
  65134. * @returns TexturePackerFrame
  65135. */
  65136. constructor(id: number, scale: Vector2, offset: Vector2);
  65137. }
  65138. }
  65139. declare module "babylonjs/Materials/Textures/Packer/packer" {
  65140. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65141. import { Scene } from "babylonjs/scene";
  65142. import { Nullable } from "babylonjs/types";
  65143. import { Color3, Color4 } from "babylonjs/Maths/math.color";
  65144. import { TexturePackerFrame } from "babylonjs/Materials/Textures/Packer/frame";
  65145. /**
  65146. * Defines the basic options interface of a TexturePacker
  65147. */
  65148. export interface ITexturePackerOptions {
  65149. /**
  65150. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  65151. */
  65152. map?: string[];
  65153. /**
  65154. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65155. */
  65156. uvsIn?: string;
  65157. /**
  65158. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  65159. */
  65160. uvsOut?: string;
  65161. /**
  65162. * number representing the layout style. Defaults to LAYOUT_STRIP
  65163. */
  65164. layout?: number;
  65165. /**
  65166. * number of columns if using custom column count layout(2). This defaults to 4.
  65167. */
  65168. colnum?: number;
  65169. /**
  65170. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  65171. */
  65172. updateInputMeshes?: boolean;
  65173. /**
  65174. * boolean flag to dispose all the source textures. Defaults to true.
  65175. */
  65176. disposeSources?: boolean;
  65177. /**
  65178. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  65179. */
  65180. fillBlanks?: boolean;
  65181. /**
  65182. * string value representing the context fill style color. Defaults to 'black'.
  65183. */
  65184. customFillColor?: string;
  65185. /**
  65186. * Width and Height Value of each Frame in the TexturePacker Sets
  65187. */
  65188. frameSize?: number;
  65189. /**
  65190. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  65191. */
  65192. paddingRatio?: number;
  65193. /**
  65194. * Number that declares the fill method for the padding gutter.
  65195. */
  65196. paddingMode?: number;
  65197. /**
  65198. * If in SUBUV_COLOR padding mode what color to use.
  65199. */
  65200. paddingColor?: Color3 | Color4;
  65201. }
  65202. /**
  65203. * Defines the basic interface of a TexturePacker JSON File
  65204. */
  65205. export interface ITexturePackerJSON {
  65206. /**
  65207. * The frame ID
  65208. */
  65209. name: string;
  65210. /**
  65211. * The base64 channel data
  65212. */
  65213. sets: any;
  65214. /**
  65215. * The options of the Packer
  65216. */
  65217. options: ITexturePackerOptions;
  65218. /**
  65219. * The frame data of the Packer
  65220. */
  65221. frames: Array<number>;
  65222. }
  65223. /**
  65224. * This is a support class that generates a series of packed texture sets.
  65225. * @see https://doc.babylonjs.com/babylon101/materials
  65226. */
  65227. export class TexturePacker {
  65228. /** Packer Layout Constant 0 */
  65229. static readonly LAYOUT_STRIP: number;
  65230. /** Packer Layout Constant 1 */
  65231. static readonly LAYOUT_POWER2: number;
  65232. /** Packer Layout Constant 2 */
  65233. static readonly LAYOUT_COLNUM: number;
  65234. /** Packer Layout Constant 0 */
  65235. static readonly SUBUV_WRAP: number;
  65236. /** Packer Layout Constant 1 */
  65237. static readonly SUBUV_EXTEND: number;
  65238. /** Packer Layout Constant 2 */
  65239. static readonly SUBUV_COLOR: number;
  65240. /** The Name of the Texture Package */
  65241. name: string;
  65242. /** The scene scope of the TexturePacker */
  65243. scene: Scene;
  65244. /** The Meshes to target */
  65245. meshes: AbstractMesh[];
  65246. /** Arguments passed with the Constructor */
  65247. options: ITexturePackerOptions;
  65248. /** The promise that is started upon initialization */
  65249. promise: Nullable<Promise<TexturePacker | string>>;
  65250. /** The Container object for the channel sets that are generated */
  65251. sets: object;
  65252. /** The Container array for the frames that are generated */
  65253. frames: TexturePackerFrame[];
  65254. /** The expected number of textures the system is parsing. */
  65255. private _expecting;
  65256. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  65257. private _paddingValue;
  65258. /**
  65259. * Initializes a texture package series from an array of meshes or a single mesh.
  65260. * @param name The name of the package
  65261. * @param meshes The target meshes to compose the package from
  65262. * @param options The arguments that texture packer should follow while building.
  65263. * @param scene The scene which the textures are scoped to.
  65264. * @returns TexturePacker
  65265. */
  65266. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  65267. /**
  65268. * Starts the package process
  65269. * @param resolve The promises resolution function
  65270. * @returns TexturePacker
  65271. */
  65272. private _createFrames;
  65273. /**
  65274. * Calculates the Size of the Channel Sets
  65275. * @returns Vector2
  65276. */
  65277. private _calculateSize;
  65278. /**
  65279. * Calculates the UV data for the frames.
  65280. * @param baseSize the base frameSize
  65281. * @param padding the base frame padding
  65282. * @param dtSize size of the Dynamic Texture for that channel
  65283. * @param dtUnits is 1/dtSize
  65284. * @param update flag to update the input meshes
  65285. */
  65286. private _calculateMeshUVFrames;
  65287. /**
  65288. * Calculates the frames Offset.
  65289. * @param index of the frame
  65290. * @returns Vector2
  65291. */
  65292. private _getFrameOffset;
  65293. /**
  65294. * Updates a Mesh to the frame data
  65295. * @param mesh that is the target
  65296. * @param frameID or the frame index
  65297. */
  65298. private _updateMeshUV;
  65299. /**
  65300. * Updates a Meshes materials to use the texture packer channels
  65301. * @param m is the mesh to target
  65302. * @param force all channels on the packer to be set.
  65303. */
  65304. private _updateTextureReferences;
  65305. /**
  65306. * Public method to set a Mesh to a frame
  65307. * @param m that is the target
  65308. * @param frameID or the frame index
  65309. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  65310. */
  65311. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  65312. /**
  65313. * Starts the async promise to compile the texture packer.
  65314. * @returns Promise<void>
  65315. */
  65316. processAsync(): Promise<void>;
  65317. /**
  65318. * Disposes all textures associated with this packer
  65319. */
  65320. dispose(): void;
  65321. /**
  65322. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  65323. * @param imageType is the image type to use.
  65324. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  65325. */
  65326. download(imageType?: string, quality?: number): void;
  65327. /**
  65328. * Public method to load a texturePacker JSON file.
  65329. * @param data of the JSON file in string format.
  65330. */
  65331. updateFromJSON(data: string): void;
  65332. }
  65333. }
  65334. declare module "babylonjs/Materials/Textures/Packer/index" {
  65335. export * from "babylonjs/Materials/Textures/Packer/packer";
  65336. export * from "babylonjs/Materials/Textures/Packer/frame";
  65337. }
  65338. declare module "babylonjs/Materials/Textures/Procedurals/customProceduralTexture" {
  65339. import { Scene } from "babylonjs/scene";
  65340. import { Texture } from "babylonjs/Materials/Textures/texture";
  65341. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65342. /**
  65343. * 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.
  65344. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65345. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65346. */
  65347. export class CustomProceduralTexture extends ProceduralTexture {
  65348. private _animate;
  65349. private _time;
  65350. private _config;
  65351. private _texturePath;
  65352. /**
  65353. * Instantiates a new Custom Procedural Texture.
  65354. * 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.
  65355. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  65356. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  65357. * @param name Define the name of the texture
  65358. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  65359. * @param size Define the size of the texture to create
  65360. * @param scene Define the scene the texture belongs to
  65361. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  65362. * @param generateMipMaps Define if the texture should creates mip maps or not
  65363. */
  65364. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65365. private _loadJson;
  65366. /**
  65367. * Is the texture ready to be used ? (rendered at least once)
  65368. * @returns true if ready, otherwise, false.
  65369. */
  65370. isReady(): boolean;
  65371. /**
  65372. * Render the texture to its associated render target.
  65373. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  65374. */
  65375. render(useCameraPostProcess?: boolean): void;
  65376. /**
  65377. * Update the list of dependant textures samplers in the shader.
  65378. */
  65379. updateTextures(): void;
  65380. /**
  65381. * Update the uniform values of the procedural texture in the shader.
  65382. */
  65383. updateShaderUniforms(): void;
  65384. /**
  65385. * Define if the texture animates or not.
  65386. */
  65387. get animate(): boolean;
  65388. set animate(value: boolean);
  65389. }
  65390. }
  65391. declare module "babylonjs/Shaders/noise.fragment" {
  65392. /** @hidden */
  65393. export var noisePixelShader: {
  65394. name: string;
  65395. shader: string;
  65396. };
  65397. }
  65398. declare module "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture" {
  65399. import { Nullable } from "babylonjs/types";
  65400. import { Scene } from "babylonjs/scene";
  65401. import { Texture } from "babylonjs/Materials/Textures/texture";
  65402. import { ProceduralTexture } from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65403. import "babylonjs/Shaders/noise.fragment";
  65404. /**
  65405. * Class used to generate noise procedural textures
  65406. */
  65407. export class NoiseProceduralTexture extends ProceduralTexture {
  65408. /** Gets or sets the start time (default is 0) */
  65409. time: number;
  65410. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  65411. brightness: number;
  65412. /** Defines the number of octaves to process */
  65413. octaves: number;
  65414. /** Defines the level of persistence (0.8 by default) */
  65415. persistence: number;
  65416. /** Gets or sets animation speed factor (default is 1) */
  65417. animationSpeedFactor: number;
  65418. /**
  65419. * Creates a new NoiseProceduralTexture
  65420. * @param name defines the name fo the texture
  65421. * @param size defines the size of the texture (default is 256)
  65422. * @param scene defines the hosting scene
  65423. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  65424. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  65425. */
  65426. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  65427. private _updateShaderUniforms;
  65428. protected _getDefines(): string;
  65429. /** Generate the current state of the procedural texture */
  65430. render(useCameraPostProcess?: boolean): void;
  65431. /**
  65432. * Serializes this noise procedural texture
  65433. * @returns a serialized noise procedural texture object
  65434. */
  65435. serialize(): any;
  65436. /**
  65437. * Clone the texture.
  65438. * @returns the cloned texture
  65439. */
  65440. clone(): NoiseProceduralTexture;
  65441. /**
  65442. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  65443. * @param parsedTexture defines parsed texture data
  65444. * @param scene defines the current scene
  65445. * @param rootUrl defines the root URL containing noise procedural texture information
  65446. * @returns a parsed NoiseProceduralTexture
  65447. */
  65448. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  65449. }
  65450. }
  65451. declare module "babylonjs/Materials/Textures/Procedurals/index" {
  65452. export * from "babylonjs/Materials/Textures/Procedurals/customProceduralTexture";
  65453. export * from "babylonjs/Materials/Textures/Procedurals/noiseProceduralTexture";
  65454. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTexture";
  65455. export * from "babylonjs/Materials/Textures/Procedurals/proceduralTextureSceneComponent";
  65456. }
  65457. declare module "babylonjs/Materials/Textures/rawCubeTexture" {
  65458. import { Nullable } from "babylonjs/types";
  65459. import { Scene } from "babylonjs/scene";
  65460. import { SphericalPolynomial } from "babylonjs/Maths/sphericalPolynomial";
  65461. import { InternalTexture } from "babylonjs/Materials/Textures/internalTexture";
  65462. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  65463. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65464. /**
  65465. * Raw cube texture where the raw buffers are passed in
  65466. */
  65467. export class RawCubeTexture extends CubeTexture {
  65468. /**
  65469. * Creates a cube texture where the raw buffers are passed in.
  65470. * @param scene defines the scene the texture is attached to
  65471. * @param data defines the array of data to use to create each face
  65472. * @param size defines the size of the textures
  65473. * @param format defines the format of the data
  65474. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  65475. * @param generateMipMaps defines if the engine should generate the mip levels
  65476. * @param invertY defines if data must be stored with Y axis inverted
  65477. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  65478. * @param compression defines the compression used (null by default)
  65479. */
  65480. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  65481. /**
  65482. * Updates the raw cube texture.
  65483. * @param data defines the data to store
  65484. * @param format defines the data format
  65485. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  65486. * @param invertY defines if data must be stored with Y axis inverted
  65487. * @param compression defines the compression used (null by default)
  65488. * @param level defines which level of the texture to update
  65489. */
  65490. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  65491. /**
  65492. * Updates a raw cube texture with RGBD encoded data.
  65493. * @param data defines the array of data [mipmap][face] to use to create each face
  65494. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  65495. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  65496. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  65497. * @returns a promsie that resolves when the operation is complete
  65498. */
  65499. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  65500. /**
  65501. * Clones the raw cube texture.
  65502. * @return a new cube texture
  65503. */
  65504. clone(): CubeTexture;
  65505. /** @hidden */
  65506. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  65507. }
  65508. }
  65509. declare module "babylonjs/Materials/Textures/rawTexture2DArray" {
  65510. import { Scene } from "babylonjs/scene";
  65511. import { Texture } from "babylonjs/Materials/Textures/texture";
  65512. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65513. /**
  65514. * Class used to store 2D array textures containing user data
  65515. */
  65516. export class RawTexture2DArray extends Texture {
  65517. /** Gets or sets the texture format to use */
  65518. format: number;
  65519. /**
  65520. * Create a new RawTexture2DArray
  65521. * @param data defines the data of the texture
  65522. * @param width defines the width of the texture
  65523. * @param height defines the height of the texture
  65524. * @param depth defines the number of layers of the texture
  65525. * @param format defines the texture format to use
  65526. * @param scene defines the hosting scene
  65527. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65528. * @param invertY defines if texture must be stored with Y axis inverted
  65529. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65530. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65531. */
  65532. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65533. /** Gets or sets the texture format to use */
  65534. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65535. /**
  65536. * Update the texture with new data
  65537. * @param data defines the data to store in the texture
  65538. */
  65539. update(data: ArrayBufferView): void;
  65540. }
  65541. }
  65542. declare module "babylonjs/Materials/Textures/rawTexture3D" {
  65543. import { Scene } from "babylonjs/scene";
  65544. import { Texture } from "babylonjs/Materials/Textures/texture";
  65545. import "babylonjs/Engines/Extensions/engine.rawTexture";
  65546. /**
  65547. * Class used to store 3D textures containing user data
  65548. */
  65549. export class RawTexture3D extends Texture {
  65550. /** Gets or sets the texture format to use */
  65551. format: number;
  65552. /**
  65553. * Create a new RawTexture3D
  65554. * @param data defines the data of the texture
  65555. * @param width defines the width of the texture
  65556. * @param height defines the height of the texture
  65557. * @param depth defines the depth of the texture
  65558. * @param format defines the texture format to use
  65559. * @param scene defines the hosting scene
  65560. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  65561. * @param invertY defines if texture must be stored with Y axis inverted
  65562. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  65563. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  65564. */
  65565. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  65566. /** Gets or sets the texture format to use */
  65567. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  65568. /**
  65569. * Update the texture with new data
  65570. * @param data defines the data to store in the texture
  65571. */
  65572. update(data: ArrayBufferView): void;
  65573. }
  65574. }
  65575. declare module "babylonjs/Materials/Textures/refractionTexture" {
  65576. import { Scene } from "babylonjs/scene";
  65577. import { Plane } from "babylonjs/Maths/math.plane";
  65578. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  65579. /**
  65580. * Creates a refraction texture used by refraction channel of the standard material.
  65581. * It is like a mirror but to see through a material.
  65582. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65583. */
  65584. export class RefractionTexture extends RenderTargetTexture {
  65585. /**
  65586. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  65587. * 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.
  65588. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65589. */
  65590. refractionPlane: Plane;
  65591. /**
  65592. * Define how deep under the surface we should see.
  65593. */
  65594. depth: number;
  65595. /**
  65596. * Creates a refraction texture used by refraction channel of the standard material.
  65597. * It is like a mirror but to see through a material.
  65598. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  65599. * @param name Define the texture name
  65600. * @param size Define the size of the underlying texture
  65601. * @param scene Define the scene the refraction belongs to
  65602. * @param generateMipMaps Define if we need to generate mips level for the refraction
  65603. */
  65604. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  65605. /**
  65606. * Clone the refraction texture.
  65607. * @returns the cloned texture
  65608. */
  65609. clone(): RefractionTexture;
  65610. /**
  65611. * Serialize the texture to a JSON representation you could use in Parse later on
  65612. * @returns the serialized JSON representation
  65613. */
  65614. serialize(): any;
  65615. }
  65616. }
  65617. declare module "babylonjs/Materials/Textures/index" {
  65618. export * from "babylonjs/Materials/Textures/baseTexture";
  65619. export * from "babylonjs/Materials/Textures/baseTexture.polynomial";
  65620. export * from "babylonjs/Materials/Textures/colorGradingTexture";
  65621. export * from "babylonjs/Materials/Textures/cubeTexture";
  65622. export * from "babylonjs/Materials/Textures/dynamicTexture";
  65623. export * from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  65624. export * from "babylonjs/Materials/Textures/Filtering/hdrFiltering";
  65625. export * from "babylonjs/Materials/Textures/hdrCubeTexture";
  65626. export * from "babylonjs/Materials/Textures/htmlElementTexture";
  65627. export * from "babylonjs/Materials/Textures/internalTexture";
  65628. export * from "babylonjs/Materials/Textures/internalTextureLoader";
  65629. export * from "babylonjs/Materials/Textures/Loaders/index";
  65630. export * from "babylonjs/Materials/Textures/mirrorTexture";
  65631. export * from "babylonjs/Materials/Textures/multiRenderTarget";
  65632. export * from "babylonjs/Materials/Textures/Packer/index";
  65633. export * from "babylonjs/Materials/Textures/Procedurals/index";
  65634. export * from "babylonjs/Materials/Textures/rawCubeTexture";
  65635. export * from "babylonjs/Materials/Textures/rawTexture";
  65636. export * from "babylonjs/Materials/Textures/rawTexture2DArray";
  65637. export * from "babylonjs/Materials/Textures/rawTexture3D";
  65638. export * from "babylonjs/Materials/Textures/refractionTexture";
  65639. export * from "babylonjs/Materials/Textures/renderTargetTexture";
  65640. export * from "babylonjs/Materials/Textures/texture";
  65641. export * from "babylonjs/Materials/Textures/videoTexture";
  65642. }
  65643. declare module "babylonjs/Materials/Node/Enums/index" {
  65644. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockTargets";
  65645. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointTypes";
  65646. export * from "babylonjs/Materials/Node/Enums/nodeMaterialBlockConnectionPointMode";
  65647. export * from "babylonjs/Materials/Node/Enums/nodeMaterialSystemValues";
  65648. export * from "babylonjs/Materials/Node/Enums/nodeMaterialModes";
  65649. }
  65650. declare module "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock" {
  65651. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65652. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65653. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65654. import { Mesh } from "babylonjs/Meshes/mesh";
  65655. import { Effect } from "babylonjs/Materials/effect";
  65656. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65657. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65658. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  65659. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  65660. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  65661. /**
  65662. * Block used to add support for vertex skinning (bones)
  65663. */
  65664. export class BonesBlock extends NodeMaterialBlock {
  65665. /**
  65666. * Creates a new BonesBlock
  65667. * @param name defines the block name
  65668. */
  65669. constructor(name: string);
  65670. /**
  65671. * Initialize the block and prepare the context for build
  65672. * @param state defines the state that will be used for the build
  65673. */
  65674. initialize(state: NodeMaterialBuildState): void;
  65675. /**
  65676. * Gets the current class name
  65677. * @returns the class name
  65678. */
  65679. getClassName(): string;
  65680. /**
  65681. * Gets the matrix indices input component
  65682. */
  65683. get matricesIndices(): NodeMaterialConnectionPoint;
  65684. /**
  65685. * Gets the matrix weights input component
  65686. */
  65687. get matricesWeights(): NodeMaterialConnectionPoint;
  65688. /**
  65689. * Gets the extra matrix indices input component
  65690. */
  65691. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  65692. /**
  65693. * Gets the extra matrix weights input component
  65694. */
  65695. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  65696. /**
  65697. * Gets the world input component
  65698. */
  65699. get world(): NodeMaterialConnectionPoint;
  65700. /**
  65701. * Gets the output component
  65702. */
  65703. get output(): NodeMaterialConnectionPoint;
  65704. autoConfigure(material: NodeMaterial): void;
  65705. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  65706. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65707. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65708. protected _buildBlock(state: NodeMaterialBuildState): this;
  65709. }
  65710. }
  65711. declare module "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock" {
  65712. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65713. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65714. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65715. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65716. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65717. import { SubMesh } from "babylonjs/Meshes/subMesh";
  65718. /**
  65719. * Block used to add support for instances
  65720. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  65721. */
  65722. export class InstancesBlock extends NodeMaterialBlock {
  65723. /**
  65724. * Creates a new InstancesBlock
  65725. * @param name defines the block name
  65726. */
  65727. constructor(name: string);
  65728. /**
  65729. * Gets the current class name
  65730. * @returns the class name
  65731. */
  65732. getClassName(): string;
  65733. /**
  65734. * Gets the first world row input component
  65735. */
  65736. get world0(): NodeMaterialConnectionPoint;
  65737. /**
  65738. * Gets the second world row input component
  65739. */
  65740. get world1(): NodeMaterialConnectionPoint;
  65741. /**
  65742. * Gets the third world row input component
  65743. */
  65744. get world2(): NodeMaterialConnectionPoint;
  65745. /**
  65746. * Gets the forth world row input component
  65747. */
  65748. get world3(): NodeMaterialConnectionPoint;
  65749. /**
  65750. * Gets the world input component
  65751. */
  65752. get world(): NodeMaterialConnectionPoint;
  65753. /**
  65754. * Gets the output component
  65755. */
  65756. get output(): NodeMaterialConnectionPoint;
  65757. /**
  65758. * Gets the isntanceID component
  65759. */
  65760. get instanceID(): NodeMaterialConnectionPoint;
  65761. autoConfigure(material: NodeMaterial): void;
  65762. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  65763. protected _buildBlock(state: NodeMaterialBuildState): this;
  65764. }
  65765. }
  65766. declare module "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock" {
  65767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65770. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65771. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65772. import { Effect } from "babylonjs/Materials/effect";
  65773. import { Mesh } from "babylonjs/Meshes/mesh";
  65774. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  65775. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  65776. /**
  65777. * Block used to add morph targets support to vertex shader
  65778. */
  65779. export class MorphTargetsBlock extends NodeMaterialBlock {
  65780. private _repeatableContentAnchor;
  65781. /**
  65782. * Create a new MorphTargetsBlock
  65783. * @param name defines the block name
  65784. */
  65785. constructor(name: string);
  65786. /**
  65787. * Gets the current class name
  65788. * @returns the class name
  65789. */
  65790. getClassName(): string;
  65791. /**
  65792. * Gets the position input component
  65793. */
  65794. get position(): NodeMaterialConnectionPoint;
  65795. /**
  65796. * Gets the normal input component
  65797. */
  65798. get normal(): NodeMaterialConnectionPoint;
  65799. /**
  65800. * Gets the tangent input component
  65801. */
  65802. get tangent(): NodeMaterialConnectionPoint;
  65803. /**
  65804. * Gets the tangent input component
  65805. */
  65806. get uv(): NodeMaterialConnectionPoint;
  65807. /**
  65808. * Gets the position output component
  65809. */
  65810. get positionOutput(): NodeMaterialConnectionPoint;
  65811. /**
  65812. * Gets the normal output component
  65813. */
  65814. get normalOutput(): NodeMaterialConnectionPoint;
  65815. /**
  65816. * Gets the tangent output component
  65817. */
  65818. get tangentOutput(): NodeMaterialConnectionPoint;
  65819. /**
  65820. * Gets the tangent output component
  65821. */
  65822. get uvOutput(): NodeMaterialConnectionPoint;
  65823. initialize(state: NodeMaterialBuildState): void;
  65824. autoConfigure(material: NodeMaterial): void;
  65825. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65826. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65827. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  65828. protected _buildBlock(state: NodeMaterialBuildState): this;
  65829. }
  65830. }
  65831. declare module "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock" {
  65832. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65833. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65834. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65835. import { Nullable } from "babylonjs/types";
  65836. import { Scene } from "babylonjs/scene";
  65837. import { Effect } from "babylonjs/Materials/effect";
  65838. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65839. import { Mesh } from "babylonjs/Meshes/mesh";
  65840. import { Light } from "babylonjs/Lights/light";
  65841. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65842. /**
  65843. * Block used to get data information from a light
  65844. */
  65845. export class LightInformationBlock extends NodeMaterialBlock {
  65846. private _lightDataUniformName;
  65847. private _lightColorUniformName;
  65848. private _lightTypeDefineName;
  65849. /**
  65850. * Gets or sets the light associated with this block
  65851. */
  65852. light: Nullable<Light>;
  65853. /**
  65854. * Creates a new LightInformationBlock
  65855. * @param name defines the block name
  65856. */
  65857. constructor(name: string);
  65858. /**
  65859. * Gets the current class name
  65860. * @returns the class name
  65861. */
  65862. getClassName(): string;
  65863. /**
  65864. * Gets the world position input component
  65865. */
  65866. get worldPosition(): NodeMaterialConnectionPoint;
  65867. /**
  65868. * Gets the direction output component
  65869. */
  65870. get direction(): NodeMaterialConnectionPoint;
  65871. /**
  65872. * Gets the direction output component
  65873. */
  65874. get color(): NodeMaterialConnectionPoint;
  65875. /**
  65876. * Gets the direction output component
  65877. */
  65878. get intensity(): NodeMaterialConnectionPoint;
  65879. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65880. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65881. protected _buildBlock(state: NodeMaterialBuildState): this;
  65882. serialize(): any;
  65883. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  65884. }
  65885. }
  65886. declare module "babylonjs/Materials/Node/Blocks/Vertex/index" {
  65887. export * from "babylonjs/Materials/Node/Blocks/Vertex/vertexOutputBlock";
  65888. export * from "babylonjs/Materials/Node/Blocks/Vertex/bonesBlock";
  65889. export * from "babylonjs/Materials/Node/Blocks/Vertex/instancesBlock";
  65890. export * from "babylonjs/Materials/Node/Blocks/Vertex/morphTargetsBlock";
  65891. export * from "babylonjs/Materials/Node/Blocks/Vertex/lightInformationBlock";
  65892. }
  65893. declare module "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock" {
  65894. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65895. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65896. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65897. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65898. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65899. import { Effect } from "babylonjs/Materials/effect";
  65900. import { Mesh } from "babylonjs/Meshes/mesh";
  65901. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  65902. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  65903. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  65904. /**
  65905. * Block used to add image processing support to fragment shader
  65906. */
  65907. export class ImageProcessingBlock extends NodeMaterialBlock {
  65908. /**
  65909. * Create a new ImageProcessingBlock
  65910. * @param name defines the block name
  65911. */
  65912. constructor(name: string);
  65913. /**
  65914. * Gets the current class name
  65915. * @returns the class name
  65916. */
  65917. getClassName(): string;
  65918. /**
  65919. * Gets the color input component
  65920. */
  65921. get color(): NodeMaterialConnectionPoint;
  65922. /**
  65923. * Gets the output component
  65924. */
  65925. get output(): NodeMaterialConnectionPoint;
  65926. /**
  65927. * Initialize the block and prepare the context for build
  65928. * @param state defines the state that will be used for the build
  65929. */
  65930. initialize(state: NodeMaterialBuildState): void;
  65931. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  65932. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65933. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65934. protected _buildBlock(state: NodeMaterialBuildState): this;
  65935. }
  65936. }
  65937. declare module "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock" {
  65938. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  65939. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  65940. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  65941. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  65942. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  65943. import { Effect } from "babylonjs/Materials/effect";
  65944. import { Mesh } from "babylonjs/Meshes/mesh";
  65945. import { Scene } from "babylonjs/scene";
  65946. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  65947. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  65948. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  65949. /**
  65950. * Block used to pertub normals based on a normal map
  65951. */
  65952. export class PerturbNormalBlock extends NodeMaterialBlock {
  65953. private _tangentSpaceParameterName;
  65954. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  65955. invertX: boolean;
  65956. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  65957. invertY: boolean;
  65958. /**
  65959. * Create a new PerturbNormalBlock
  65960. * @param name defines the block name
  65961. */
  65962. constructor(name: string);
  65963. /**
  65964. * Gets the current class name
  65965. * @returns the class name
  65966. */
  65967. getClassName(): string;
  65968. /**
  65969. * Gets the world position input component
  65970. */
  65971. get worldPosition(): NodeMaterialConnectionPoint;
  65972. /**
  65973. * Gets the world normal input component
  65974. */
  65975. get worldNormal(): NodeMaterialConnectionPoint;
  65976. /**
  65977. * Gets the world tangent input component
  65978. */
  65979. get worldTangent(): NodeMaterialConnectionPoint;
  65980. /**
  65981. * Gets the uv input component
  65982. */
  65983. get uv(): NodeMaterialConnectionPoint;
  65984. /**
  65985. * Gets the normal map color input component
  65986. */
  65987. get normalMapColor(): NodeMaterialConnectionPoint;
  65988. /**
  65989. * Gets the strength input component
  65990. */
  65991. get strength(): NodeMaterialConnectionPoint;
  65992. /**
  65993. * Gets the output component
  65994. */
  65995. get output(): NodeMaterialConnectionPoint;
  65996. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  65997. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  65998. autoConfigure(material: NodeMaterial): void;
  65999. protected _buildBlock(state: NodeMaterialBuildState): this;
  66000. protected _dumpPropertiesCode(): string;
  66001. serialize(): any;
  66002. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66003. }
  66004. }
  66005. declare module "babylonjs/Materials/Node/Blocks/Fragment/discardBlock" {
  66006. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66007. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66008. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66009. /**
  66010. * Block used to discard a pixel if a value is smaller than a cutoff
  66011. */
  66012. export class DiscardBlock extends NodeMaterialBlock {
  66013. /**
  66014. * Create a new DiscardBlock
  66015. * @param name defines the block name
  66016. */
  66017. constructor(name: string);
  66018. /**
  66019. * Gets the current class name
  66020. * @returns the class name
  66021. */
  66022. getClassName(): string;
  66023. /**
  66024. * Gets the color input component
  66025. */
  66026. get value(): NodeMaterialConnectionPoint;
  66027. /**
  66028. * Gets the cutoff input component
  66029. */
  66030. get cutoff(): NodeMaterialConnectionPoint;
  66031. protected _buildBlock(state: NodeMaterialBuildState): this;
  66032. }
  66033. }
  66034. declare module "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock" {
  66035. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66036. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66037. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66038. /**
  66039. * Block used to test if the fragment shader is front facing
  66040. */
  66041. export class FrontFacingBlock extends NodeMaterialBlock {
  66042. /**
  66043. * Creates a new FrontFacingBlock
  66044. * @param name defines the block name
  66045. */
  66046. constructor(name: string);
  66047. /**
  66048. * Gets the current class name
  66049. * @returns the class name
  66050. */
  66051. getClassName(): string;
  66052. /**
  66053. * Gets the output component
  66054. */
  66055. get output(): NodeMaterialConnectionPoint;
  66056. protected _buildBlock(state: NodeMaterialBuildState): this;
  66057. }
  66058. }
  66059. declare module "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock" {
  66060. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66061. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66062. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66063. /**
  66064. * Block used to get the derivative value on x and y of a given input
  66065. */
  66066. export class DerivativeBlock extends NodeMaterialBlock {
  66067. /**
  66068. * Create a new DerivativeBlock
  66069. * @param name defines the block name
  66070. */
  66071. constructor(name: string);
  66072. /**
  66073. * Gets the current class name
  66074. * @returns the class name
  66075. */
  66076. getClassName(): string;
  66077. /**
  66078. * Gets the input component
  66079. */
  66080. get input(): NodeMaterialConnectionPoint;
  66081. /**
  66082. * Gets the derivative output on x
  66083. */
  66084. get dx(): NodeMaterialConnectionPoint;
  66085. /**
  66086. * Gets the derivative output on y
  66087. */
  66088. get dy(): NodeMaterialConnectionPoint;
  66089. protected _buildBlock(state: NodeMaterialBuildState): this;
  66090. }
  66091. }
  66092. declare module "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock" {
  66093. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66094. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66095. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66096. /**
  66097. * Block used to make gl_FragCoord available
  66098. */
  66099. export class FragCoordBlock extends NodeMaterialBlock {
  66100. /**
  66101. * Creates a new FragCoordBlock
  66102. * @param name defines the block name
  66103. */
  66104. constructor(name: string);
  66105. /**
  66106. * Gets the current class name
  66107. * @returns the class name
  66108. */
  66109. getClassName(): string;
  66110. /**
  66111. * Gets the xy component
  66112. */
  66113. get xy(): NodeMaterialConnectionPoint;
  66114. /**
  66115. * Gets the xyz component
  66116. */
  66117. get xyz(): NodeMaterialConnectionPoint;
  66118. /**
  66119. * Gets the xyzw component
  66120. */
  66121. get xyzw(): NodeMaterialConnectionPoint;
  66122. /**
  66123. * Gets the x component
  66124. */
  66125. get x(): NodeMaterialConnectionPoint;
  66126. /**
  66127. * Gets the y component
  66128. */
  66129. get y(): NodeMaterialConnectionPoint;
  66130. /**
  66131. * Gets the z component
  66132. */
  66133. get z(): NodeMaterialConnectionPoint;
  66134. /**
  66135. * Gets the w component
  66136. */
  66137. get output(): NodeMaterialConnectionPoint;
  66138. protected writeOutputs(state: NodeMaterialBuildState): string;
  66139. protected _buildBlock(state: NodeMaterialBuildState): this;
  66140. }
  66141. }
  66142. declare module "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock" {
  66143. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66144. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66145. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66146. import { Effect } from "babylonjs/Materials/effect";
  66147. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66148. import { Mesh } from "babylonjs/Meshes/mesh";
  66149. /**
  66150. * Block used to get the screen sizes
  66151. */
  66152. export class ScreenSizeBlock extends NodeMaterialBlock {
  66153. private _varName;
  66154. private _scene;
  66155. /**
  66156. * Creates a new ScreenSizeBlock
  66157. * @param name defines the block name
  66158. */
  66159. constructor(name: string);
  66160. /**
  66161. * Gets the current class name
  66162. * @returns the class name
  66163. */
  66164. getClassName(): string;
  66165. /**
  66166. * Gets the xy component
  66167. */
  66168. get xy(): NodeMaterialConnectionPoint;
  66169. /**
  66170. * Gets the x component
  66171. */
  66172. get x(): NodeMaterialConnectionPoint;
  66173. /**
  66174. * Gets the y component
  66175. */
  66176. get y(): NodeMaterialConnectionPoint;
  66177. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66178. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  66179. protected _buildBlock(state: NodeMaterialBuildState): this;
  66180. }
  66181. }
  66182. declare module "babylonjs/Materials/Node/Blocks/Fragment/index" {
  66183. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragmentOutputBlock";
  66184. export * from "babylonjs/Materials/Node/Blocks/Fragment/imageProcessingBlock";
  66185. export * from "babylonjs/Materials/Node/Blocks/Fragment/perturbNormalBlock";
  66186. export * from "babylonjs/Materials/Node/Blocks/Fragment/discardBlock";
  66187. export * from "babylonjs/Materials/Node/Blocks/Fragment/frontFacingBlock";
  66188. export * from "babylonjs/Materials/Node/Blocks/Fragment/derivativeBlock";
  66189. export * from "babylonjs/Materials/Node/Blocks/Fragment/fragCoordBlock";
  66190. export * from "babylonjs/Materials/Node/Blocks/Fragment/screenSizeBlock";
  66191. }
  66192. declare module "babylonjs/Materials/Node/Blocks/Dual/fogBlock" {
  66193. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66194. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66195. import { Mesh } from "babylonjs/Meshes/mesh";
  66196. import { Effect } from "babylonjs/Materials/effect";
  66197. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66198. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66199. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66200. import "babylonjs/Shaders/ShadersInclude/fogFragmentDeclaration";
  66201. /**
  66202. * Block used to add support for scene fog
  66203. */
  66204. export class FogBlock extends NodeMaterialBlock {
  66205. private _fogDistanceName;
  66206. private _fogParameters;
  66207. /**
  66208. * Create a new FogBlock
  66209. * @param name defines the block name
  66210. */
  66211. constructor(name: string);
  66212. /**
  66213. * Gets the current class name
  66214. * @returns the class name
  66215. */
  66216. getClassName(): string;
  66217. /**
  66218. * Gets the world position input component
  66219. */
  66220. get worldPosition(): NodeMaterialConnectionPoint;
  66221. /**
  66222. * Gets the view input component
  66223. */
  66224. get view(): NodeMaterialConnectionPoint;
  66225. /**
  66226. * Gets the color input component
  66227. */
  66228. get input(): NodeMaterialConnectionPoint;
  66229. /**
  66230. * Gets the fog color input component
  66231. */
  66232. get fogColor(): NodeMaterialConnectionPoint;
  66233. /**
  66234. * Gets the output component
  66235. */
  66236. get output(): NodeMaterialConnectionPoint;
  66237. autoConfigure(material: NodeMaterial): void;
  66238. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66239. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66240. protected _buildBlock(state: NodeMaterialBuildState): this;
  66241. }
  66242. }
  66243. declare module "babylonjs/Materials/Node/Blocks/Dual/lightBlock" {
  66244. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66245. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66246. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66247. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  66248. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  66249. import { Effect } from "babylonjs/Materials/effect";
  66250. import { Mesh } from "babylonjs/Meshes/mesh";
  66251. import { Light } from "babylonjs/Lights/light";
  66252. import { Nullable } from "babylonjs/types";
  66253. import { Scene } from "babylonjs/scene";
  66254. import "babylonjs/Shaders/ShadersInclude/lightFragmentDeclaration";
  66255. import "babylonjs/Shaders/ShadersInclude/lightUboDeclaration";
  66256. import "babylonjs/Shaders/ShadersInclude/lightFragment";
  66257. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  66258. import "babylonjs/Shaders/ShadersInclude/lightsFragmentFunctions";
  66259. import "babylonjs/Shaders/ShadersInclude/shadowsFragmentFunctions";
  66260. import "babylonjs/Shaders/ShadersInclude/shadowsVertex";
  66261. /**
  66262. * Block used to add light in the fragment shader
  66263. */
  66264. export class LightBlock extends NodeMaterialBlock {
  66265. private _lightId;
  66266. /**
  66267. * Gets or sets the light associated with this block
  66268. */
  66269. light: Nullable<Light>;
  66270. /**
  66271. * Create a new LightBlock
  66272. * @param name defines the block name
  66273. */
  66274. constructor(name: string);
  66275. /**
  66276. * Gets the current class name
  66277. * @returns the class name
  66278. */
  66279. getClassName(): string;
  66280. /**
  66281. * Gets the world position input component
  66282. */
  66283. get worldPosition(): NodeMaterialConnectionPoint;
  66284. /**
  66285. * Gets the world normal input component
  66286. */
  66287. get worldNormal(): NodeMaterialConnectionPoint;
  66288. /**
  66289. * Gets the camera (or eye) position component
  66290. */
  66291. get cameraPosition(): NodeMaterialConnectionPoint;
  66292. /**
  66293. * Gets the glossiness component
  66294. */
  66295. get glossiness(): NodeMaterialConnectionPoint;
  66296. /**
  66297. * Gets the glossinness power component
  66298. */
  66299. get glossPower(): NodeMaterialConnectionPoint;
  66300. /**
  66301. * Gets the diffuse color component
  66302. */
  66303. get diffuseColor(): NodeMaterialConnectionPoint;
  66304. /**
  66305. * Gets the specular color component
  66306. */
  66307. get specularColor(): NodeMaterialConnectionPoint;
  66308. /**
  66309. * Gets the diffuse output component
  66310. */
  66311. get diffuseOutput(): NodeMaterialConnectionPoint;
  66312. /**
  66313. * Gets the specular output component
  66314. */
  66315. get specularOutput(): NodeMaterialConnectionPoint;
  66316. /**
  66317. * Gets the shadow output component
  66318. */
  66319. get shadow(): NodeMaterialConnectionPoint;
  66320. autoConfigure(material: NodeMaterial): void;
  66321. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  66322. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  66323. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  66324. private _injectVertexCode;
  66325. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  66326. serialize(): any;
  66327. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66328. }
  66329. }
  66330. declare module "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock" {
  66331. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66332. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66333. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66334. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  66335. /**
  66336. * Block used to read a reflection texture from a sampler
  66337. */
  66338. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  66339. /**
  66340. * Create a new ReflectionTextureBlock
  66341. * @param name defines the block name
  66342. */
  66343. constructor(name: string);
  66344. /**
  66345. * Gets the current class name
  66346. * @returns the class name
  66347. */
  66348. getClassName(): string;
  66349. /**
  66350. * Gets the world position input component
  66351. */
  66352. get position(): NodeMaterialConnectionPoint;
  66353. /**
  66354. * Gets the world position input component
  66355. */
  66356. get worldPosition(): NodeMaterialConnectionPoint;
  66357. /**
  66358. * Gets the world normal input component
  66359. */
  66360. get worldNormal(): NodeMaterialConnectionPoint;
  66361. /**
  66362. * Gets the world input component
  66363. */
  66364. get world(): NodeMaterialConnectionPoint;
  66365. /**
  66366. * Gets the camera (or eye) position component
  66367. */
  66368. get cameraPosition(): NodeMaterialConnectionPoint;
  66369. /**
  66370. * Gets the view input component
  66371. */
  66372. get view(): NodeMaterialConnectionPoint;
  66373. /**
  66374. * Gets the rgb output component
  66375. */
  66376. get rgb(): NodeMaterialConnectionPoint;
  66377. /**
  66378. * Gets the rgba output component
  66379. */
  66380. get rgba(): NodeMaterialConnectionPoint;
  66381. /**
  66382. * Gets the r output component
  66383. */
  66384. get r(): NodeMaterialConnectionPoint;
  66385. /**
  66386. * Gets the g output component
  66387. */
  66388. get g(): NodeMaterialConnectionPoint;
  66389. /**
  66390. * Gets the b output component
  66391. */
  66392. get b(): NodeMaterialConnectionPoint;
  66393. /**
  66394. * Gets the a output component
  66395. */
  66396. get a(): NodeMaterialConnectionPoint;
  66397. autoConfigure(material: NodeMaterial): void;
  66398. protected _buildBlock(state: NodeMaterialBuildState): this;
  66399. }
  66400. }
  66401. declare module "babylonjs/Materials/Node/Blocks/Dual/index" {
  66402. export * from "babylonjs/Materials/Node/Blocks/Dual/fogBlock";
  66403. export * from "babylonjs/Materials/Node/Blocks/Dual/lightBlock";
  66404. export * from "babylonjs/Materials/Node/Blocks/Dual/textureBlock";
  66405. export * from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBlock";
  66406. export * from "babylonjs/Materials/Node/Blocks/Dual/currentScreenBlock";
  66407. }
  66408. declare module "babylonjs/Materials/Node/Blocks/Input/index" {
  66409. export * from "babylonjs/Materials/Node/Blocks/Input/inputBlock";
  66410. export * from "babylonjs/Materials/Node/Blocks/Input/animatedInputBlockTypes";
  66411. }
  66412. declare module "babylonjs/Materials/Node/Blocks/addBlock" {
  66413. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66414. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66415. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66416. /**
  66417. * Block used to add 2 vectors
  66418. */
  66419. export class AddBlock extends NodeMaterialBlock {
  66420. /**
  66421. * Creates a new AddBlock
  66422. * @param name defines the block name
  66423. */
  66424. constructor(name: string);
  66425. /**
  66426. * Gets the current class name
  66427. * @returns the class name
  66428. */
  66429. getClassName(): string;
  66430. /**
  66431. * Gets the left operand input component
  66432. */
  66433. get left(): NodeMaterialConnectionPoint;
  66434. /**
  66435. * Gets the right operand input component
  66436. */
  66437. get right(): NodeMaterialConnectionPoint;
  66438. /**
  66439. * Gets the output component
  66440. */
  66441. get output(): NodeMaterialConnectionPoint;
  66442. protected _buildBlock(state: NodeMaterialBuildState): this;
  66443. }
  66444. }
  66445. declare module "babylonjs/Materials/Node/Blocks/scaleBlock" {
  66446. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66447. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66448. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66449. /**
  66450. * Block used to scale a vector by a float
  66451. */
  66452. export class ScaleBlock extends NodeMaterialBlock {
  66453. /**
  66454. * Creates a new ScaleBlock
  66455. * @param name defines the block name
  66456. */
  66457. constructor(name: string);
  66458. /**
  66459. * Gets the current class name
  66460. * @returns the class name
  66461. */
  66462. getClassName(): string;
  66463. /**
  66464. * Gets the input component
  66465. */
  66466. get input(): NodeMaterialConnectionPoint;
  66467. /**
  66468. * Gets the factor input component
  66469. */
  66470. get factor(): NodeMaterialConnectionPoint;
  66471. /**
  66472. * Gets the output component
  66473. */
  66474. get output(): NodeMaterialConnectionPoint;
  66475. protected _buildBlock(state: NodeMaterialBuildState): this;
  66476. }
  66477. }
  66478. declare module "babylonjs/Materials/Node/Blocks/clampBlock" {
  66479. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66480. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66481. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66482. import { Scene } from "babylonjs/scene";
  66483. /**
  66484. * Block used to clamp a float
  66485. */
  66486. export class ClampBlock extends NodeMaterialBlock {
  66487. /** Gets or sets the minimum range */
  66488. minimum: number;
  66489. /** Gets or sets the maximum range */
  66490. maximum: number;
  66491. /**
  66492. * Creates a new ClampBlock
  66493. * @param name defines the block name
  66494. */
  66495. constructor(name: string);
  66496. /**
  66497. * Gets the current class name
  66498. * @returns the class name
  66499. */
  66500. getClassName(): string;
  66501. /**
  66502. * Gets the value input component
  66503. */
  66504. get value(): NodeMaterialConnectionPoint;
  66505. /**
  66506. * Gets the output component
  66507. */
  66508. get output(): NodeMaterialConnectionPoint;
  66509. protected _buildBlock(state: NodeMaterialBuildState): this;
  66510. protected _dumpPropertiesCode(): string;
  66511. serialize(): any;
  66512. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  66513. }
  66514. }
  66515. declare module "babylonjs/Materials/Node/Blocks/crossBlock" {
  66516. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66517. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66518. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66519. /**
  66520. * Block used to apply a cross product between 2 vectors
  66521. */
  66522. export class CrossBlock extends NodeMaterialBlock {
  66523. /**
  66524. * Creates a new CrossBlock
  66525. * @param name defines the block name
  66526. */
  66527. constructor(name: string);
  66528. /**
  66529. * Gets the current class name
  66530. * @returns the class name
  66531. */
  66532. getClassName(): string;
  66533. /**
  66534. * Gets the left operand input component
  66535. */
  66536. get left(): NodeMaterialConnectionPoint;
  66537. /**
  66538. * Gets the right operand input component
  66539. */
  66540. get right(): NodeMaterialConnectionPoint;
  66541. /**
  66542. * Gets the output component
  66543. */
  66544. get output(): NodeMaterialConnectionPoint;
  66545. protected _buildBlock(state: NodeMaterialBuildState): this;
  66546. }
  66547. }
  66548. declare module "babylonjs/Materials/Node/Blocks/dotBlock" {
  66549. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66550. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66551. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66552. /**
  66553. * Block used to apply a dot product between 2 vectors
  66554. */
  66555. export class DotBlock extends NodeMaterialBlock {
  66556. /**
  66557. * Creates a new DotBlock
  66558. * @param name defines the block name
  66559. */
  66560. constructor(name: string);
  66561. /**
  66562. * Gets the current class name
  66563. * @returns the class name
  66564. */
  66565. getClassName(): string;
  66566. /**
  66567. * Gets the left operand input component
  66568. */
  66569. get left(): NodeMaterialConnectionPoint;
  66570. /**
  66571. * Gets the right operand input component
  66572. */
  66573. get right(): NodeMaterialConnectionPoint;
  66574. /**
  66575. * Gets the output component
  66576. */
  66577. get output(): NodeMaterialConnectionPoint;
  66578. protected _buildBlock(state: NodeMaterialBuildState): this;
  66579. }
  66580. }
  66581. declare module "babylonjs/Materials/Node/Blocks/normalizeBlock" {
  66582. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66583. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66584. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66585. /**
  66586. * Block used to normalize a vector
  66587. */
  66588. export class NormalizeBlock extends NodeMaterialBlock {
  66589. /**
  66590. * Creates a new NormalizeBlock
  66591. * @param name defines the block name
  66592. */
  66593. constructor(name: string);
  66594. /**
  66595. * Gets the current class name
  66596. * @returns the class name
  66597. */
  66598. getClassName(): string;
  66599. /**
  66600. * Gets the input component
  66601. */
  66602. get input(): NodeMaterialConnectionPoint;
  66603. /**
  66604. * Gets the output component
  66605. */
  66606. get output(): NodeMaterialConnectionPoint;
  66607. protected _buildBlock(state: NodeMaterialBuildState): this;
  66608. }
  66609. }
  66610. declare module "babylonjs/Materials/Node/Blocks/colorMergerBlock" {
  66611. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66612. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66613. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66614. /**
  66615. * Block used to create a Color3/4 out of individual inputs (one for each component)
  66616. */
  66617. export class ColorMergerBlock extends NodeMaterialBlock {
  66618. /**
  66619. * Create a new ColorMergerBlock
  66620. * @param name defines the block name
  66621. */
  66622. constructor(name: string);
  66623. /**
  66624. * Gets the current class name
  66625. * @returns the class name
  66626. */
  66627. getClassName(): string;
  66628. /**
  66629. * Gets the rgb component (input)
  66630. */
  66631. get rgbIn(): NodeMaterialConnectionPoint;
  66632. /**
  66633. * Gets the r component (input)
  66634. */
  66635. get r(): NodeMaterialConnectionPoint;
  66636. /**
  66637. * Gets the g component (input)
  66638. */
  66639. get g(): NodeMaterialConnectionPoint;
  66640. /**
  66641. * Gets the b component (input)
  66642. */
  66643. get b(): NodeMaterialConnectionPoint;
  66644. /**
  66645. * Gets the a component (input)
  66646. */
  66647. get a(): NodeMaterialConnectionPoint;
  66648. /**
  66649. * Gets the rgba component (output)
  66650. */
  66651. get rgba(): NodeMaterialConnectionPoint;
  66652. /**
  66653. * Gets the rgb component (output)
  66654. */
  66655. get rgbOut(): NodeMaterialConnectionPoint;
  66656. /**
  66657. * Gets the rgb component (output)
  66658. * @deprecated Please use rgbOut instead.
  66659. */
  66660. get rgb(): NodeMaterialConnectionPoint;
  66661. protected _buildBlock(state: NodeMaterialBuildState): this;
  66662. }
  66663. }
  66664. declare module "babylonjs/Materials/Node/Blocks/vectorSplitterBlock" {
  66665. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66666. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66667. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66668. /**
  66669. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  66670. */
  66671. export class VectorSplitterBlock extends NodeMaterialBlock {
  66672. /**
  66673. * Create a new VectorSplitterBlock
  66674. * @param name defines the block name
  66675. */
  66676. constructor(name: string);
  66677. /**
  66678. * Gets the current class name
  66679. * @returns the class name
  66680. */
  66681. getClassName(): string;
  66682. /**
  66683. * Gets the xyzw component (input)
  66684. */
  66685. get xyzw(): NodeMaterialConnectionPoint;
  66686. /**
  66687. * Gets the xyz component (input)
  66688. */
  66689. get xyzIn(): NodeMaterialConnectionPoint;
  66690. /**
  66691. * Gets the xy component (input)
  66692. */
  66693. get xyIn(): NodeMaterialConnectionPoint;
  66694. /**
  66695. * Gets the xyz component (output)
  66696. */
  66697. get xyzOut(): NodeMaterialConnectionPoint;
  66698. /**
  66699. * Gets the xy component (output)
  66700. */
  66701. get xyOut(): NodeMaterialConnectionPoint;
  66702. /**
  66703. * Gets the x component (output)
  66704. */
  66705. get x(): NodeMaterialConnectionPoint;
  66706. /**
  66707. * Gets the y component (output)
  66708. */
  66709. get y(): NodeMaterialConnectionPoint;
  66710. /**
  66711. * Gets the z component (output)
  66712. */
  66713. get z(): NodeMaterialConnectionPoint;
  66714. /**
  66715. * Gets the w component (output)
  66716. */
  66717. get w(): NodeMaterialConnectionPoint;
  66718. protected _inputRename(name: string): string;
  66719. protected _outputRename(name: string): string;
  66720. protected _buildBlock(state: NodeMaterialBuildState): this;
  66721. }
  66722. }
  66723. declare module "babylonjs/Materials/Node/Blocks/lerpBlock" {
  66724. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66725. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66726. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66727. /**
  66728. * Block used to lerp between 2 values
  66729. */
  66730. export class LerpBlock extends NodeMaterialBlock {
  66731. /**
  66732. * Creates a new LerpBlock
  66733. * @param name defines the block name
  66734. */
  66735. constructor(name: string);
  66736. /**
  66737. * Gets the current class name
  66738. * @returns the class name
  66739. */
  66740. getClassName(): string;
  66741. /**
  66742. * Gets the left operand input component
  66743. */
  66744. get left(): NodeMaterialConnectionPoint;
  66745. /**
  66746. * Gets the right operand input component
  66747. */
  66748. get right(): NodeMaterialConnectionPoint;
  66749. /**
  66750. * Gets the gradient operand input component
  66751. */
  66752. get gradient(): NodeMaterialConnectionPoint;
  66753. /**
  66754. * Gets the output component
  66755. */
  66756. get output(): NodeMaterialConnectionPoint;
  66757. protected _buildBlock(state: NodeMaterialBuildState): this;
  66758. }
  66759. }
  66760. declare module "babylonjs/Materials/Node/Blocks/divideBlock" {
  66761. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66762. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66763. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66764. /**
  66765. * Block used to divide 2 vectors
  66766. */
  66767. export class DivideBlock extends NodeMaterialBlock {
  66768. /**
  66769. * Creates a new DivideBlock
  66770. * @param name defines the block name
  66771. */
  66772. constructor(name: string);
  66773. /**
  66774. * Gets the current class name
  66775. * @returns the class name
  66776. */
  66777. getClassName(): string;
  66778. /**
  66779. * Gets the left operand input component
  66780. */
  66781. get left(): NodeMaterialConnectionPoint;
  66782. /**
  66783. * Gets the right operand input component
  66784. */
  66785. get right(): NodeMaterialConnectionPoint;
  66786. /**
  66787. * Gets the output component
  66788. */
  66789. get output(): NodeMaterialConnectionPoint;
  66790. protected _buildBlock(state: NodeMaterialBuildState): this;
  66791. }
  66792. }
  66793. declare module "babylonjs/Materials/Node/Blocks/subtractBlock" {
  66794. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66795. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66796. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66797. /**
  66798. * Block used to subtract 2 vectors
  66799. */
  66800. export class SubtractBlock extends NodeMaterialBlock {
  66801. /**
  66802. * Creates a new SubtractBlock
  66803. * @param name defines the block name
  66804. */
  66805. constructor(name: string);
  66806. /**
  66807. * Gets the current class name
  66808. * @returns the class name
  66809. */
  66810. getClassName(): string;
  66811. /**
  66812. * Gets the left operand input component
  66813. */
  66814. get left(): NodeMaterialConnectionPoint;
  66815. /**
  66816. * Gets the right operand input component
  66817. */
  66818. get right(): NodeMaterialConnectionPoint;
  66819. /**
  66820. * Gets the output component
  66821. */
  66822. get output(): NodeMaterialConnectionPoint;
  66823. protected _buildBlock(state: NodeMaterialBuildState): this;
  66824. }
  66825. }
  66826. declare module "babylonjs/Materials/Node/Blocks/stepBlock" {
  66827. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66828. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66829. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66830. /**
  66831. * Block used to step a value
  66832. */
  66833. export class StepBlock extends NodeMaterialBlock {
  66834. /**
  66835. * Creates a new StepBlock
  66836. * @param name defines the block name
  66837. */
  66838. constructor(name: string);
  66839. /**
  66840. * Gets the current class name
  66841. * @returns the class name
  66842. */
  66843. getClassName(): string;
  66844. /**
  66845. * Gets the value operand input component
  66846. */
  66847. get value(): NodeMaterialConnectionPoint;
  66848. /**
  66849. * Gets the edge operand input component
  66850. */
  66851. get edge(): NodeMaterialConnectionPoint;
  66852. /**
  66853. * Gets the output component
  66854. */
  66855. get output(): NodeMaterialConnectionPoint;
  66856. protected _buildBlock(state: NodeMaterialBuildState): this;
  66857. }
  66858. }
  66859. declare module "babylonjs/Materials/Node/Blocks/oneMinusBlock" {
  66860. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66861. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66862. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66863. /**
  66864. * Block used to get the opposite (1 - x) of a value
  66865. */
  66866. export class OneMinusBlock extends NodeMaterialBlock {
  66867. /**
  66868. * Creates a new OneMinusBlock
  66869. * @param name defines the block name
  66870. */
  66871. constructor(name: string);
  66872. /**
  66873. * Gets the current class name
  66874. * @returns the class name
  66875. */
  66876. getClassName(): string;
  66877. /**
  66878. * Gets the input component
  66879. */
  66880. get input(): NodeMaterialConnectionPoint;
  66881. /**
  66882. * Gets the output component
  66883. */
  66884. get output(): NodeMaterialConnectionPoint;
  66885. protected _buildBlock(state: NodeMaterialBuildState): this;
  66886. }
  66887. }
  66888. declare module "babylonjs/Materials/Node/Blocks/viewDirectionBlock" {
  66889. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66890. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66891. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66892. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66893. /**
  66894. * Block used to get the view direction
  66895. */
  66896. export class ViewDirectionBlock extends NodeMaterialBlock {
  66897. /**
  66898. * Creates a new ViewDirectionBlock
  66899. * @param name defines the block name
  66900. */
  66901. constructor(name: string);
  66902. /**
  66903. * Gets the current class name
  66904. * @returns the class name
  66905. */
  66906. getClassName(): string;
  66907. /**
  66908. * Gets the world position component
  66909. */
  66910. get worldPosition(): NodeMaterialConnectionPoint;
  66911. /**
  66912. * Gets the camera position component
  66913. */
  66914. get cameraPosition(): NodeMaterialConnectionPoint;
  66915. /**
  66916. * Gets the output component
  66917. */
  66918. get output(): NodeMaterialConnectionPoint;
  66919. autoConfigure(material: NodeMaterial): void;
  66920. protected _buildBlock(state: NodeMaterialBuildState): this;
  66921. }
  66922. }
  66923. declare module "babylonjs/Materials/Node/Blocks/fresnelBlock" {
  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. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  66928. import "babylonjs/Shaders/ShadersInclude/fresnelFunction";
  66929. /**
  66930. * Block used to compute fresnel value
  66931. */
  66932. export class FresnelBlock extends NodeMaterialBlock {
  66933. /**
  66934. * Create a new FresnelBlock
  66935. * @param name defines the block name
  66936. */
  66937. constructor(name: string);
  66938. /**
  66939. * Gets the current class name
  66940. * @returns the class name
  66941. */
  66942. getClassName(): string;
  66943. /**
  66944. * Gets the world normal input component
  66945. */
  66946. get worldNormal(): NodeMaterialConnectionPoint;
  66947. /**
  66948. * Gets the view direction input component
  66949. */
  66950. get viewDirection(): NodeMaterialConnectionPoint;
  66951. /**
  66952. * Gets the bias input component
  66953. */
  66954. get bias(): NodeMaterialConnectionPoint;
  66955. /**
  66956. * Gets the camera (or eye) position component
  66957. */
  66958. get power(): NodeMaterialConnectionPoint;
  66959. /**
  66960. * Gets the fresnel output component
  66961. */
  66962. get fresnel(): NodeMaterialConnectionPoint;
  66963. autoConfigure(material: NodeMaterial): void;
  66964. protected _buildBlock(state: NodeMaterialBuildState): this;
  66965. }
  66966. }
  66967. declare module "babylonjs/Materials/Node/Blocks/maxBlock" {
  66968. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  66969. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  66970. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  66971. /**
  66972. * Block used to get the max of 2 values
  66973. */
  66974. export class MaxBlock extends NodeMaterialBlock {
  66975. /**
  66976. * Creates a new MaxBlock
  66977. * @param name defines the block name
  66978. */
  66979. constructor(name: string);
  66980. /**
  66981. * Gets the current class name
  66982. * @returns the class name
  66983. */
  66984. getClassName(): string;
  66985. /**
  66986. * Gets the left operand input component
  66987. */
  66988. get left(): NodeMaterialConnectionPoint;
  66989. /**
  66990. * Gets the right operand input component
  66991. */
  66992. get right(): NodeMaterialConnectionPoint;
  66993. /**
  66994. * Gets the output component
  66995. */
  66996. get output(): NodeMaterialConnectionPoint;
  66997. protected _buildBlock(state: NodeMaterialBuildState): this;
  66998. }
  66999. }
  67000. declare module "babylonjs/Materials/Node/Blocks/minBlock" {
  67001. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67002. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67003. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67004. /**
  67005. * Block used to get the min of 2 values
  67006. */
  67007. export class MinBlock extends NodeMaterialBlock {
  67008. /**
  67009. * Creates a new MinBlock
  67010. * @param name defines the block name
  67011. */
  67012. constructor(name: string);
  67013. /**
  67014. * Gets the current class name
  67015. * @returns the class name
  67016. */
  67017. getClassName(): string;
  67018. /**
  67019. * Gets the left operand input component
  67020. */
  67021. get left(): NodeMaterialConnectionPoint;
  67022. /**
  67023. * Gets the right operand input component
  67024. */
  67025. get right(): NodeMaterialConnectionPoint;
  67026. /**
  67027. * Gets the output component
  67028. */
  67029. get output(): NodeMaterialConnectionPoint;
  67030. protected _buildBlock(state: NodeMaterialBuildState): this;
  67031. }
  67032. }
  67033. declare module "babylonjs/Materials/Node/Blocks/distanceBlock" {
  67034. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67035. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67036. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67037. /**
  67038. * Block used to get the distance between 2 values
  67039. */
  67040. export class DistanceBlock extends NodeMaterialBlock {
  67041. /**
  67042. * Creates a new DistanceBlock
  67043. * @param name defines the block name
  67044. */
  67045. constructor(name: string);
  67046. /**
  67047. * Gets the current class name
  67048. * @returns the class name
  67049. */
  67050. getClassName(): string;
  67051. /**
  67052. * Gets the left operand input component
  67053. */
  67054. get left(): NodeMaterialConnectionPoint;
  67055. /**
  67056. * Gets the right operand input component
  67057. */
  67058. get right(): NodeMaterialConnectionPoint;
  67059. /**
  67060. * Gets the output component
  67061. */
  67062. get output(): NodeMaterialConnectionPoint;
  67063. protected _buildBlock(state: NodeMaterialBuildState): this;
  67064. }
  67065. }
  67066. declare module "babylonjs/Materials/Node/Blocks/lengthBlock" {
  67067. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67068. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67069. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67070. /**
  67071. * Block used to get the length of a vector
  67072. */
  67073. export class LengthBlock extends NodeMaterialBlock {
  67074. /**
  67075. * Creates a new LengthBlock
  67076. * @param name defines the block name
  67077. */
  67078. constructor(name: string);
  67079. /**
  67080. * Gets the current class name
  67081. * @returns the class name
  67082. */
  67083. getClassName(): string;
  67084. /**
  67085. * Gets the value input component
  67086. */
  67087. get value(): NodeMaterialConnectionPoint;
  67088. /**
  67089. * Gets the output component
  67090. */
  67091. get output(): NodeMaterialConnectionPoint;
  67092. protected _buildBlock(state: NodeMaterialBuildState): this;
  67093. }
  67094. }
  67095. declare module "babylonjs/Materials/Node/Blocks/negateBlock" {
  67096. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67097. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67098. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67099. /**
  67100. * Block used to get negative version of a value (i.e. x * -1)
  67101. */
  67102. export class NegateBlock extends NodeMaterialBlock {
  67103. /**
  67104. * Creates a new NegateBlock
  67105. * @param name defines the block name
  67106. */
  67107. constructor(name: string);
  67108. /**
  67109. * Gets the current class name
  67110. * @returns the class name
  67111. */
  67112. getClassName(): string;
  67113. /**
  67114. * Gets the value input component
  67115. */
  67116. get value(): NodeMaterialConnectionPoint;
  67117. /**
  67118. * Gets the output component
  67119. */
  67120. get output(): NodeMaterialConnectionPoint;
  67121. protected _buildBlock(state: NodeMaterialBuildState): this;
  67122. }
  67123. }
  67124. declare module "babylonjs/Materials/Node/Blocks/powBlock" {
  67125. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67126. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67127. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67128. /**
  67129. * Block used to get the value of the first parameter raised to the power of the second
  67130. */
  67131. export class PowBlock extends NodeMaterialBlock {
  67132. /**
  67133. * Creates a new PowBlock
  67134. * @param name defines the block name
  67135. */
  67136. constructor(name: string);
  67137. /**
  67138. * Gets the current class name
  67139. * @returns the class name
  67140. */
  67141. getClassName(): string;
  67142. /**
  67143. * Gets the value operand input component
  67144. */
  67145. get value(): NodeMaterialConnectionPoint;
  67146. /**
  67147. * Gets the power operand input component
  67148. */
  67149. get power(): NodeMaterialConnectionPoint;
  67150. /**
  67151. * Gets the output component
  67152. */
  67153. get output(): NodeMaterialConnectionPoint;
  67154. protected _buildBlock(state: NodeMaterialBuildState): this;
  67155. }
  67156. }
  67157. declare module "babylonjs/Materials/Node/Blocks/randomNumberBlock" {
  67158. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67159. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67160. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67161. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  67162. /**
  67163. * Block used to get a random number
  67164. */
  67165. export class RandomNumberBlock extends NodeMaterialBlock {
  67166. /**
  67167. * Creates a new RandomNumberBlock
  67168. * @param name defines the block name
  67169. */
  67170. constructor(name: string);
  67171. /**
  67172. * Gets the current class name
  67173. * @returns the class name
  67174. */
  67175. getClassName(): string;
  67176. /**
  67177. * Gets the seed input component
  67178. */
  67179. get seed(): NodeMaterialConnectionPoint;
  67180. /**
  67181. * Gets the output component
  67182. */
  67183. get output(): NodeMaterialConnectionPoint;
  67184. protected _buildBlock(state: NodeMaterialBuildState): this;
  67185. }
  67186. }
  67187. declare module "babylonjs/Materials/Node/Blocks/arcTan2Block" {
  67188. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67189. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67190. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67191. /**
  67192. * Block used to compute arc tangent of 2 values
  67193. */
  67194. export class ArcTan2Block extends NodeMaterialBlock {
  67195. /**
  67196. * Creates a new ArcTan2Block
  67197. * @param name defines the block name
  67198. */
  67199. constructor(name: string);
  67200. /**
  67201. * Gets the current class name
  67202. * @returns the class name
  67203. */
  67204. getClassName(): string;
  67205. /**
  67206. * Gets the x operand input component
  67207. */
  67208. get x(): NodeMaterialConnectionPoint;
  67209. /**
  67210. * Gets the y operand input component
  67211. */
  67212. get y(): NodeMaterialConnectionPoint;
  67213. /**
  67214. * Gets the output component
  67215. */
  67216. get output(): NodeMaterialConnectionPoint;
  67217. protected _buildBlock(state: NodeMaterialBuildState): this;
  67218. }
  67219. }
  67220. declare module "babylonjs/Materials/Node/Blocks/smoothStepBlock" {
  67221. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67222. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67223. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67224. /**
  67225. * Block used to smooth step a value
  67226. */
  67227. export class SmoothStepBlock extends NodeMaterialBlock {
  67228. /**
  67229. * Creates a new SmoothStepBlock
  67230. * @param name defines the block name
  67231. */
  67232. constructor(name: string);
  67233. /**
  67234. * Gets the current class name
  67235. * @returns the class name
  67236. */
  67237. getClassName(): string;
  67238. /**
  67239. * Gets the value operand input component
  67240. */
  67241. get value(): NodeMaterialConnectionPoint;
  67242. /**
  67243. * Gets the first edge operand input component
  67244. */
  67245. get edge0(): NodeMaterialConnectionPoint;
  67246. /**
  67247. * Gets the second edge operand input component
  67248. */
  67249. get edge1(): NodeMaterialConnectionPoint;
  67250. /**
  67251. * Gets the output component
  67252. */
  67253. get output(): NodeMaterialConnectionPoint;
  67254. protected _buildBlock(state: NodeMaterialBuildState): this;
  67255. }
  67256. }
  67257. declare module "babylonjs/Materials/Node/Blocks/reciprocalBlock" {
  67258. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67259. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67260. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67261. /**
  67262. * Block used to get the reciprocal (1 / x) of a value
  67263. */
  67264. export class ReciprocalBlock extends NodeMaterialBlock {
  67265. /**
  67266. * Creates a new ReciprocalBlock
  67267. * @param name defines the block name
  67268. */
  67269. constructor(name: string);
  67270. /**
  67271. * Gets the current class name
  67272. * @returns the class name
  67273. */
  67274. getClassName(): string;
  67275. /**
  67276. * Gets the input component
  67277. */
  67278. get input(): NodeMaterialConnectionPoint;
  67279. /**
  67280. * Gets the output component
  67281. */
  67282. get output(): NodeMaterialConnectionPoint;
  67283. protected _buildBlock(state: NodeMaterialBuildState): this;
  67284. }
  67285. }
  67286. declare module "babylonjs/Materials/Node/Blocks/replaceColorBlock" {
  67287. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67288. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67289. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67290. /**
  67291. * Block used to replace a color by another one
  67292. */
  67293. export class ReplaceColorBlock extends NodeMaterialBlock {
  67294. /**
  67295. * Creates a new ReplaceColorBlock
  67296. * @param name defines the block name
  67297. */
  67298. constructor(name: string);
  67299. /**
  67300. * Gets the current class name
  67301. * @returns the class name
  67302. */
  67303. getClassName(): string;
  67304. /**
  67305. * Gets the value input component
  67306. */
  67307. get value(): NodeMaterialConnectionPoint;
  67308. /**
  67309. * Gets the reference input component
  67310. */
  67311. get reference(): NodeMaterialConnectionPoint;
  67312. /**
  67313. * Gets the distance input component
  67314. */
  67315. get distance(): NodeMaterialConnectionPoint;
  67316. /**
  67317. * Gets the replacement input component
  67318. */
  67319. get replacement(): NodeMaterialConnectionPoint;
  67320. /**
  67321. * Gets the output component
  67322. */
  67323. get output(): NodeMaterialConnectionPoint;
  67324. protected _buildBlock(state: NodeMaterialBuildState): this;
  67325. }
  67326. }
  67327. declare module "babylonjs/Materials/Node/Blocks/posterizeBlock" {
  67328. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67329. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67330. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67331. /**
  67332. * Block used to posterize a value
  67333. * @see https://en.wikipedia.org/wiki/Posterization
  67334. */
  67335. export class PosterizeBlock extends NodeMaterialBlock {
  67336. /**
  67337. * Creates a new PosterizeBlock
  67338. * @param name defines the block name
  67339. */
  67340. constructor(name: string);
  67341. /**
  67342. * Gets the current class name
  67343. * @returns the class name
  67344. */
  67345. getClassName(): string;
  67346. /**
  67347. * Gets the value input component
  67348. */
  67349. get value(): NodeMaterialConnectionPoint;
  67350. /**
  67351. * Gets the steps input component
  67352. */
  67353. get steps(): NodeMaterialConnectionPoint;
  67354. /**
  67355. * Gets the output component
  67356. */
  67357. get output(): NodeMaterialConnectionPoint;
  67358. protected _buildBlock(state: NodeMaterialBuildState): this;
  67359. }
  67360. }
  67361. declare module "babylonjs/Materials/Node/Blocks/waveBlock" {
  67362. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67363. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67364. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67365. import { Scene } from "babylonjs/scene";
  67366. /**
  67367. * Operations supported by the Wave block
  67368. */
  67369. export enum WaveBlockKind {
  67370. /** SawTooth */
  67371. SawTooth = 0,
  67372. /** Square */
  67373. Square = 1,
  67374. /** Triangle */
  67375. Triangle = 2
  67376. }
  67377. /**
  67378. * Block used to apply wave operation to floats
  67379. */
  67380. export class WaveBlock extends NodeMaterialBlock {
  67381. /**
  67382. * Gets or sets the kibnd of wave to be applied by the block
  67383. */
  67384. kind: WaveBlockKind;
  67385. /**
  67386. * Creates a new WaveBlock
  67387. * @param name defines the block name
  67388. */
  67389. constructor(name: string);
  67390. /**
  67391. * Gets the current class name
  67392. * @returns the class name
  67393. */
  67394. getClassName(): string;
  67395. /**
  67396. * Gets the input component
  67397. */
  67398. get input(): NodeMaterialConnectionPoint;
  67399. /**
  67400. * Gets the output component
  67401. */
  67402. get output(): NodeMaterialConnectionPoint;
  67403. protected _buildBlock(state: NodeMaterialBuildState): this;
  67404. serialize(): any;
  67405. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67406. }
  67407. }
  67408. declare module "babylonjs/Materials/Node/Blocks/gradientBlock" {
  67409. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67410. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67411. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67412. import { Color3 } from "babylonjs/Maths/math.color";
  67413. import { Scene } from "babylonjs/scene";
  67414. import { Observable } from "babylonjs/Misc/observable";
  67415. /**
  67416. * Class used to store a color step for the GradientBlock
  67417. */
  67418. export class GradientBlockColorStep {
  67419. private _step;
  67420. /**
  67421. * Gets value indicating which step this color is associated with (between 0 and 1)
  67422. */
  67423. get step(): number;
  67424. /**
  67425. * Sets a value indicating which step this color is associated with (between 0 and 1)
  67426. */
  67427. set step(val: number);
  67428. private _color;
  67429. /**
  67430. * Gets the color associated with this step
  67431. */
  67432. get color(): Color3;
  67433. /**
  67434. * Sets the color associated with this step
  67435. */
  67436. set color(val: Color3);
  67437. /**
  67438. * Creates a new GradientBlockColorStep
  67439. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  67440. * @param color defines the color associated with this step
  67441. */
  67442. constructor(step: number, color: Color3);
  67443. }
  67444. /**
  67445. * Block used to return a color from a gradient based on an input value between 0 and 1
  67446. */
  67447. export class GradientBlock extends NodeMaterialBlock {
  67448. /**
  67449. * Gets or sets the list of color steps
  67450. */
  67451. colorSteps: GradientBlockColorStep[];
  67452. /** Gets an observable raised when the value is changed */
  67453. onValueChangedObservable: Observable<GradientBlock>;
  67454. /** calls observable when the value is changed*/
  67455. colorStepsUpdated(): void;
  67456. /**
  67457. * Creates a new GradientBlock
  67458. * @param name defines the block name
  67459. */
  67460. constructor(name: string);
  67461. /**
  67462. * Gets the current class name
  67463. * @returns the class name
  67464. */
  67465. getClassName(): string;
  67466. /**
  67467. * Gets the gradient input component
  67468. */
  67469. get gradient(): NodeMaterialConnectionPoint;
  67470. /**
  67471. * Gets the output component
  67472. */
  67473. get output(): NodeMaterialConnectionPoint;
  67474. private _writeColorConstant;
  67475. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67476. serialize(): any;
  67477. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67478. protected _dumpPropertiesCode(): string;
  67479. }
  67480. }
  67481. declare module "babylonjs/Materials/Node/Blocks/nLerpBlock" {
  67482. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67483. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67484. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67485. /**
  67486. * Block used to normalize lerp between 2 values
  67487. */
  67488. export class NLerpBlock extends NodeMaterialBlock {
  67489. /**
  67490. * Creates a new NLerpBlock
  67491. * @param name defines the block name
  67492. */
  67493. constructor(name: string);
  67494. /**
  67495. * Gets the current class name
  67496. * @returns the class name
  67497. */
  67498. getClassName(): string;
  67499. /**
  67500. * Gets the left operand input component
  67501. */
  67502. get left(): NodeMaterialConnectionPoint;
  67503. /**
  67504. * Gets the right operand input component
  67505. */
  67506. get right(): NodeMaterialConnectionPoint;
  67507. /**
  67508. * Gets the gradient operand input component
  67509. */
  67510. get gradient(): NodeMaterialConnectionPoint;
  67511. /**
  67512. * Gets the output component
  67513. */
  67514. get output(): NodeMaterialConnectionPoint;
  67515. protected _buildBlock(state: NodeMaterialBuildState): this;
  67516. }
  67517. }
  67518. declare module "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock" {
  67519. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67520. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67521. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67522. import { Scene } from "babylonjs/scene";
  67523. /**
  67524. * block used to Generate a Worley Noise 3D Noise Pattern
  67525. */
  67526. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  67527. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  67528. manhattanDistance: boolean;
  67529. /**
  67530. * Creates a new WorleyNoise3DBlock
  67531. * @param name defines the block name
  67532. */
  67533. constructor(name: string);
  67534. /**
  67535. * Gets the current class name
  67536. * @returns the class name
  67537. */
  67538. getClassName(): string;
  67539. /**
  67540. * Gets the seed input component
  67541. */
  67542. get seed(): NodeMaterialConnectionPoint;
  67543. /**
  67544. * Gets the jitter input component
  67545. */
  67546. get jitter(): NodeMaterialConnectionPoint;
  67547. /**
  67548. * Gets the output component
  67549. */
  67550. get output(): NodeMaterialConnectionPoint;
  67551. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67552. /**
  67553. * Exposes the properties to the UI?
  67554. */
  67555. protected _dumpPropertiesCode(): string;
  67556. /**
  67557. * Exposes the properties to the Seralize?
  67558. */
  67559. serialize(): any;
  67560. /**
  67561. * Exposes the properties to the deseralize?
  67562. */
  67563. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67564. }
  67565. }
  67566. declare module "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock" {
  67567. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67568. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67569. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67570. /**
  67571. * block used to Generate a Simplex Perlin 3d Noise Pattern
  67572. */
  67573. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  67574. /**
  67575. * Creates a new SimplexPerlin3DBlock
  67576. * @param name defines the block name
  67577. */
  67578. constructor(name: string);
  67579. /**
  67580. * Gets the current class name
  67581. * @returns the class name
  67582. */
  67583. getClassName(): string;
  67584. /**
  67585. * Gets the seed operand input component
  67586. */
  67587. get seed(): NodeMaterialConnectionPoint;
  67588. /**
  67589. * Gets the output component
  67590. */
  67591. get output(): NodeMaterialConnectionPoint;
  67592. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  67593. }
  67594. }
  67595. declare module "babylonjs/Materials/Node/Blocks/normalBlendBlock" {
  67596. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67597. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67598. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67599. /**
  67600. * Block used to blend normals
  67601. */
  67602. export class NormalBlendBlock extends NodeMaterialBlock {
  67603. /**
  67604. * Creates a new NormalBlendBlock
  67605. * @param name defines the block name
  67606. */
  67607. constructor(name: string);
  67608. /**
  67609. * Gets the current class name
  67610. * @returns the class name
  67611. */
  67612. getClassName(): string;
  67613. /**
  67614. * Gets the first input component
  67615. */
  67616. get normalMap0(): NodeMaterialConnectionPoint;
  67617. /**
  67618. * Gets the second input component
  67619. */
  67620. get normalMap1(): NodeMaterialConnectionPoint;
  67621. /**
  67622. * Gets the output component
  67623. */
  67624. get output(): NodeMaterialConnectionPoint;
  67625. protected _buildBlock(state: NodeMaterialBuildState): this;
  67626. }
  67627. }
  67628. declare module "babylonjs/Materials/Node/Blocks/rotate2dBlock" {
  67629. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67630. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67631. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67632. import { NodeMaterial } from "babylonjs/Materials/Node/nodeMaterial";
  67633. /**
  67634. * Block used to rotate a 2d vector by a given angle
  67635. */
  67636. export class Rotate2dBlock extends NodeMaterialBlock {
  67637. /**
  67638. * Creates a new Rotate2dBlock
  67639. * @param name defines the block name
  67640. */
  67641. constructor(name: string);
  67642. /**
  67643. * Gets the current class name
  67644. * @returns the class name
  67645. */
  67646. getClassName(): string;
  67647. /**
  67648. * Gets the input vector
  67649. */
  67650. get input(): NodeMaterialConnectionPoint;
  67651. /**
  67652. * Gets the input angle
  67653. */
  67654. get angle(): NodeMaterialConnectionPoint;
  67655. /**
  67656. * Gets the output component
  67657. */
  67658. get output(): NodeMaterialConnectionPoint;
  67659. autoConfigure(material: NodeMaterial): void;
  67660. protected _buildBlock(state: NodeMaterialBuildState): this;
  67661. }
  67662. }
  67663. declare module "babylonjs/Materials/Node/Blocks/reflectBlock" {
  67664. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67665. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67666. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67667. /**
  67668. * Block used to get the reflected vector from a direction and a normal
  67669. */
  67670. export class ReflectBlock extends NodeMaterialBlock {
  67671. /**
  67672. * Creates a new ReflectBlock
  67673. * @param name defines the block name
  67674. */
  67675. constructor(name: string);
  67676. /**
  67677. * Gets the current class name
  67678. * @returns the class name
  67679. */
  67680. getClassName(): string;
  67681. /**
  67682. * Gets the incident component
  67683. */
  67684. get incident(): NodeMaterialConnectionPoint;
  67685. /**
  67686. * Gets the normal component
  67687. */
  67688. get normal(): NodeMaterialConnectionPoint;
  67689. /**
  67690. * Gets the output component
  67691. */
  67692. get output(): NodeMaterialConnectionPoint;
  67693. protected _buildBlock(state: NodeMaterialBuildState): this;
  67694. }
  67695. }
  67696. declare module "babylonjs/Materials/Node/Blocks/refractBlock" {
  67697. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67698. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67699. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67700. /**
  67701. * Block used to get the refracted vector from a direction and a normal
  67702. */
  67703. export class RefractBlock extends NodeMaterialBlock {
  67704. /**
  67705. * Creates a new RefractBlock
  67706. * @param name defines the block name
  67707. */
  67708. constructor(name: string);
  67709. /**
  67710. * Gets the current class name
  67711. * @returns the class name
  67712. */
  67713. getClassName(): string;
  67714. /**
  67715. * Gets the incident component
  67716. */
  67717. get incident(): NodeMaterialConnectionPoint;
  67718. /**
  67719. * Gets the normal component
  67720. */
  67721. get normal(): NodeMaterialConnectionPoint;
  67722. /**
  67723. * Gets the index of refraction component
  67724. */
  67725. get ior(): NodeMaterialConnectionPoint;
  67726. /**
  67727. * Gets the output component
  67728. */
  67729. get output(): NodeMaterialConnectionPoint;
  67730. protected _buildBlock(state: NodeMaterialBuildState): this;
  67731. }
  67732. }
  67733. declare module "babylonjs/Materials/Node/Blocks/desaturateBlock" {
  67734. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67735. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67736. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67737. /**
  67738. * Block used to desaturate a color
  67739. */
  67740. export class DesaturateBlock extends NodeMaterialBlock {
  67741. /**
  67742. * Creates a new DesaturateBlock
  67743. * @param name defines the block name
  67744. */
  67745. constructor(name: string);
  67746. /**
  67747. * Gets the current class name
  67748. * @returns the class name
  67749. */
  67750. getClassName(): string;
  67751. /**
  67752. * Gets the color operand input component
  67753. */
  67754. get color(): NodeMaterialConnectionPoint;
  67755. /**
  67756. * Gets the level operand input component
  67757. */
  67758. get level(): NodeMaterialConnectionPoint;
  67759. /**
  67760. * Gets the output component
  67761. */
  67762. get output(): NodeMaterialConnectionPoint;
  67763. protected _buildBlock(state: NodeMaterialBuildState): this;
  67764. }
  67765. }
  67766. declare module "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock" {
  67767. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67768. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67769. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67770. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67771. import { Nullable } from "babylonjs/types";
  67772. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67773. import { Scene } from "babylonjs/scene";
  67774. /**
  67775. * Block used to implement the ambient occlusion module of the PBR material
  67776. */
  67777. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  67778. /**
  67779. * Create a new AmbientOcclusionBlock
  67780. * @param name defines the block name
  67781. */
  67782. constructor(name: string);
  67783. /**
  67784. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  67785. */
  67786. useAmbientInGrayScale: boolean;
  67787. /**
  67788. * Initialize the block and prepare the context for build
  67789. * @param state defines the state that will be used for the build
  67790. */
  67791. initialize(state: NodeMaterialBuildState): void;
  67792. /**
  67793. * Gets the current class name
  67794. * @returns the class name
  67795. */
  67796. getClassName(): string;
  67797. /**
  67798. * Gets the texture input component
  67799. */
  67800. get texture(): NodeMaterialConnectionPoint;
  67801. /**
  67802. * Gets the texture intensity component
  67803. */
  67804. get intensity(): NodeMaterialConnectionPoint;
  67805. /**
  67806. * Gets the direct light intensity input component
  67807. */
  67808. get directLightIntensity(): NodeMaterialConnectionPoint;
  67809. /**
  67810. * Gets the ambient occlusion object output component
  67811. */
  67812. get ambientOcc(): NodeMaterialConnectionPoint;
  67813. /**
  67814. * Gets the main code of the block (fragment side)
  67815. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  67816. * @returns the shader code
  67817. */
  67818. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  67819. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67820. protected _buildBlock(state: NodeMaterialBuildState): this;
  67821. protected _dumpPropertiesCode(): string;
  67822. serialize(): any;
  67823. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67824. }
  67825. }
  67826. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock" {
  67827. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67828. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67829. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67830. import { ReflectionTextureBaseBlock } from "babylonjs/Materials/Node/Blocks/Dual/reflectionTextureBaseBlock";
  67831. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67832. import { Nullable } from "babylonjs/types";
  67833. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  67834. import { Mesh } from "babylonjs/Meshes/mesh";
  67835. import { SubMesh } from "babylonjs/Meshes/subMesh";
  67836. import { Effect } from "babylonjs/Materials/effect";
  67837. import { Scene } from "babylonjs/scene";
  67838. /**
  67839. * Block used to implement the reflection module of the PBR material
  67840. */
  67841. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  67842. /** @hidden */
  67843. _defineLODReflectionAlpha: string;
  67844. /** @hidden */
  67845. _defineLinearSpecularReflection: string;
  67846. private _vEnvironmentIrradianceName;
  67847. /** @hidden */
  67848. _vReflectionMicrosurfaceInfosName: string;
  67849. /** @hidden */
  67850. _vReflectionInfosName: string;
  67851. /** @hidden */
  67852. _vReflectionFilteringInfoName: string;
  67853. private _scene;
  67854. /**
  67855. * The three properties below are set by the main PBR block prior to calling methods of this class.
  67856. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  67857. * It's less burden on the user side in the editor part.
  67858. */
  67859. /** @hidden */
  67860. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  67861. /** @hidden */
  67862. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  67863. /** @hidden */
  67864. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  67865. /**
  67866. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  67867. * diffuse part of the IBL.
  67868. */
  67869. useSphericalHarmonics: boolean;
  67870. /**
  67871. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  67872. */
  67873. forceIrradianceInFragment: boolean;
  67874. /**
  67875. * Create a new ReflectionBlock
  67876. * @param name defines the block name
  67877. */
  67878. constructor(name: string);
  67879. /**
  67880. * Gets the current class name
  67881. * @returns the class name
  67882. */
  67883. getClassName(): string;
  67884. /**
  67885. * Gets the position input component
  67886. */
  67887. get position(): NodeMaterialConnectionPoint;
  67888. /**
  67889. * Gets the world position input component
  67890. */
  67891. get worldPosition(): NodeMaterialConnectionPoint;
  67892. /**
  67893. * Gets the world normal input component
  67894. */
  67895. get worldNormal(): NodeMaterialConnectionPoint;
  67896. /**
  67897. * Gets the world input component
  67898. */
  67899. get world(): NodeMaterialConnectionPoint;
  67900. /**
  67901. * Gets the camera (or eye) position component
  67902. */
  67903. get cameraPosition(): NodeMaterialConnectionPoint;
  67904. /**
  67905. * Gets the view input component
  67906. */
  67907. get view(): NodeMaterialConnectionPoint;
  67908. /**
  67909. * Gets the color input component
  67910. */
  67911. get color(): NodeMaterialConnectionPoint;
  67912. /**
  67913. * Gets the reflection object output component
  67914. */
  67915. get reflection(): NodeMaterialConnectionPoint;
  67916. /**
  67917. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  67918. */
  67919. get hasTexture(): boolean;
  67920. /**
  67921. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  67922. */
  67923. get reflectionColor(): string;
  67924. protected _getTexture(): Nullable<BaseTexture>;
  67925. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  67926. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  67927. /**
  67928. * Gets the code to inject in the vertex shader
  67929. * @param state current state of the node material building
  67930. * @returns the shader code
  67931. */
  67932. handleVertexSide(state: NodeMaterialBuildState): string;
  67933. /**
  67934. * Gets the main code of the block (fragment side)
  67935. * @param state current state of the node material building
  67936. * @param normalVarName name of the existing variable corresponding to the normal
  67937. * @returns the shader code
  67938. */
  67939. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  67940. protected _buildBlock(state: NodeMaterialBuildState): this;
  67941. protected _dumpPropertiesCode(): string;
  67942. serialize(): any;
  67943. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  67944. }
  67945. }
  67946. declare module "babylonjs/Materials/Node/Blocks/PBR/sheenBlock" {
  67947. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  67948. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  67949. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  67950. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  67951. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  67952. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  67953. import { Scene } from "babylonjs/scene";
  67954. import { Nullable } from "babylonjs/types";
  67955. /**
  67956. * Block used to implement the sheen module of the PBR material
  67957. */
  67958. export class SheenBlock extends NodeMaterialBlock {
  67959. /**
  67960. * Create a new SheenBlock
  67961. * @param name defines the block name
  67962. */
  67963. constructor(name: string);
  67964. /**
  67965. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  67966. * It allows the strength of the sheen effect to not depend on the base color of the material,
  67967. * making it easier to setup and tweak the effect
  67968. */
  67969. albedoScaling: boolean;
  67970. /**
  67971. * Defines if the sheen is linked to the sheen color.
  67972. */
  67973. linkSheenWithAlbedo: boolean;
  67974. /**
  67975. * Initialize the block and prepare the context for build
  67976. * @param state defines the state that will be used for the build
  67977. */
  67978. initialize(state: NodeMaterialBuildState): void;
  67979. /**
  67980. * Gets the current class name
  67981. * @returns the class name
  67982. */
  67983. getClassName(): string;
  67984. /**
  67985. * Gets the intensity input component
  67986. */
  67987. get intensity(): NodeMaterialConnectionPoint;
  67988. /**
  67989. * Gets the color input component
  67990. */
  67991. get color(): NodeMaterialConnectionPoint;
  67992. /**
  67993. * Gets the roughness input component
  67994. */
  67995. get roughness(): NodeMaterialConnectionPoint;
  67996. /**
  67997. * Gets the sheen object output component
  67998. */
  67999. get sheen(): NodeMaterialConnectionPoint;
  68000. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68001. /**
  68002. * Gets the main code of the block (fragment side)
  68003. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68004. * @returns the shader code
  68005. */
  68006. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  68007. protected _buildBlock(state: NodeMaterialBuildState): this;
  68008. protected _dumpPropertiesCode(): string;
  68009. serialize(): any;
  68010. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68011. }
  68012. }
  68013. declare module "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock" {
  68014. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68015. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68016. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68017. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68018. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68019. import { Scene } from "babylonjs/scene";
  68020. import { Nullable } from "babylonjs/types";
  68021. import { Mesh } from "babylonjs/Meshes/mesh";
  68022. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68023. import { Effect } from "babylonjs/Materials/effect";
  68024. /**
  68025. * Block used to implement the reflectivity module of the PBR material
  68026. */
  68027. export class ReflectivityBlock extends NodeMaterialBlock {
  68028. private _metallicReflectanceColor;
  68029. private _metallicF0Factor;
  68030. /** @hidden */
  68031. _vMetallicReflectanceFactorsName: string;
  68032. /**
  68033. * The property below is set by the main PBR block prior to calling methods of this class.
  68034. */
  68035. /** @hidden */
  68036. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  68037. /**
  68038. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  68039. */
  68040. useAmbientOcclusionFromMetallicTextureRed: boolean;
  68041. /**
  68042. * Specifies if the metallic texture contains the metallness information in its blue channel.
  68043. */
  68044. useMetallnessFromMetallicTextureBlue: boolean;
  68045. /**
  68046. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  68047. */
  68048. useRoughnessFromMetallicTextureAlpha: boolean;
  68049. /**
  68050. * Specifies if the metallic texture contains the roughness information in its green channel.
  68051. */
  68052. useRoughnessFromMetallicTextureGreen: boolean;
  68053. /**
  68054. * Create a new ReflectivityBlock
  68055. * @param name defines the block name
  68056. */
  68057. constructor(name: string);
  68058. /**
  68059. * Initialize the block and prepare the context for build
  68060. * @param state defines the state that will be used for the build
  68061. */
  68062. initialize(state: NodeMaterialBuildState): void;
  68063. /**
  68064. * Gets the current class name
  68065. * @returns the class name
  68066. */
  68067. getClassName(): string;
  68068. /**
  68069. * Gets the metallic input component
  68070. */
  68071. get metallic(): NodeMaterialConnectionPoint;
  68072. /**
  68073. * Gets the roughness input component
  68074. */
  68075. get roughness(): NodeMaterialConnectionPoint;
  68076. /**
  68077. * Gets the texture input component
  68078. */
  68079. get texture(): NodeMaterialConnectionPoint;
  68080. /**
  68081. * Gets the reflectivity object output component
  68082. */
  68083. get reflectivity(): NodeMaterialConnectionPoint;
  68084. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68085. /**
  68086. * Gets the main code of the block (fragment side)
  68087. * @param state current state of the node material building
  68088. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  68089. * @returns the shader code
  68090. */
  68091. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  68092. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68093. protected _buildBlock(state: NodeMaterialBuildState): this;
  68094. protected _dumpPropertiesCode(): string;
  68095. serialize(): any;
  68096. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68097. }
  68098. }
  68099. declare module "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock" {
  68100. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68101. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68102. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68103. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68104. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68105. /**
  68106. * Block used to implement the anisotropy module of the PBR material
  68107. */
  68108. export class AnisotropyBlock extends NodeMaterialBlock {
  68109. /**
  68110. * The two properties below are set by the main PBR block prior to calling methods of this class.
  68111. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  68112. * It's less burden on the user side in the editor part.
  68113. */
  68114. /** @hidden */
  68115. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  68116. /** @hidden */
  68117. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  68118. /**
  68119. * Create a new AnisotropyBlock
  68120. * @param name defines the block name
  68121. */
  68122. constructor(name: string);
  68123. /**
  68124. * Initialize the block and prepare the context for build
  68125. * @param state defines the state that will be used for the build
  68126. */
  68127. initialize(state: NodeMaterialBuildState): void;
  68128. /**
  68129. * Gets the current class name
  68130. * @returns the class name
  68131. */
  68132. getClassName(): string;
  68133. /**
  68134. * Gets the intensity input component
  68135. */
  68136. get intensity(): NodeMaterialConnectionPoint;
  68137. /**
  68138. * Gets the direction input component
  68139. */
  68140. get direction(): NodeMaterialConnectionPoint;
  68141. /**
  68142. * Gets the texture input component
  68143. */
  68144. get texture(): NodeMaterialConnectionPoint;
  68145. /**
  68146. * Gets the uv input component
  68147. */
  68148. get uv(): NodeMaterialConnectionPoint;
  68149. /**
  68150. * Gets the worldTangent input component
  68151. */
  68152. get worldTangent(): NodeMaterialConnectionPoint;
  68153. /**
  68154. * Gets the anisotropy object output component
  68155. */
  68156. get anisotropy(): NodeMaterialConnectionPoint;
  68157. private _generateTBNSpace;
  68158. /**
  68159. * Gets the main code of the block (fragment side)
  68160. * @param state current state of the node material building
  68161. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68162. * @returns the shader code
  68163. */
  68164. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  68165. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68166. protected _buildBlock(state: NodeMaterialBuildState): this;
  68167. }
  68168. }
  68169. declare module "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock" {
  68170. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68171. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68172. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68173. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68174. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68175. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68176. import { Nullable } from "babylonjs/types";
  68177. import { Mesh } from "babylonjs/Meshes/mesh";
  68178. import { SubMesh } from "babylonjs/Meshes/subMesh";
  68179. import { Effect } from "babylonjs/Materials/effect";
  68180. /**
  68181. * Block used to implement the clear coat module of the PBR material
  68182. */
  68183. export class ClearCoatBlock extends NodeMaterialBlock {
  68184. private _scene;
  68185. /**
  68186. * Create a new ClearCoatBlock
  68187. * @param name defines the block name
  68188. */
  68189. constructor(name: string);
  68190. /**
  68191. * Initialize the block and prepare the context for build
  68192. * @param state defines the state that will be used for the build
  68193. */
  68194. initialize(state: NodeMaterialBuildState): void;
  68195. /**
  68196. * Gets the current class name
  68197. * @returns the class name
  68198. */
  68199. getClassName(): string;
  68200. /**
  68201. * Gets the intensity input component
  68202. */
  68203. get intensity(): NodeMaterialConnectionPoint;
  68204. /**
  68205. * Gets the roughness input component
  68206. */
  68207. get roughness(): NodeMaterialConnectionPoint;
  68208. /**
  68209. * Gets the ior input component
  68210. */
  68211. get ior(): NodeMaterialConnectionPoint;
  68212. /**
  68213. * Gets the texture input component
  68214. */
  68215. get texture(): NodeMaterialConnectionPoint;
  68216. /**
  68217. * Gets the bump texture input component
  68218. */
  68219. get bumpTexture(): NodeMaterialConnectionPoint;
  68220. /**
  68221. * Gets the uv input component
  68222. */
  68223. get uv(): NodeMaterialConnectionPoint;
  68224. /**
  68225. * Gets the tint color input component
  68226. */
  68227. get tintColor(): NodeMaterialConnectionPoint;
  68228. /**
  68229. * Gets the tint "at distance" input component
  68230. */
  68231. get tintAtDistance(): NodeMaterialConnectionPoint;
  68232. /**
  68233. * Gets the tint thickness input component
  68234. */
  68235. get tintThickness(): NodeMaterialConnectionPoint;
  68236. /**
  68237. * Gets the world tangent input component
  68238. */
  68239. get worldTangent(): NodeMaterialConnectionPoint;
  68240. /**
  68241. * Gets the clear coat object output component
  68242. */
  68243. get clearcoat(): NodeMaterialConnectionPoint;
  68244. autoConfigure(material: NodeMaterial): void;
  68245. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68246. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  68247. private _generateTBNSpace;
  68248. /**
  68249. * Gets the main code of the block (fragment side)
  68250. * @param state current state of the node material building
  68251. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  68252. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68253. * @param worldPosVarName name of the variable holding the world position
  68254. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  68255. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  68256. * @param worldNormalVarName name of the variable holding the world normal
  68257. * @returns the shader code
  68258. */
  68259. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  68260. protected _buildBlock(state: NodeMaterialBuildState): this;
  68261. }
  68262. }
  68263. declare module "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock" {
  68264. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68265. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68266. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68267. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68268. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68269. import { ReflectionBlock } from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68270. import { Nullable } from "babylonjs/types";
  68271. /**
  68272. * Block used to implement the sub surface module of the PBR material
  68273. */
  68274. export class SubSurfaceBlock extends NodeMaterialBlock {
  68275. /**
  68276. * Create a new SubSurfaceBlock
  68277. * @param name defines the block name
  68278. */
  68279. constructor(name: string);
  68280. /**
  68281. * Stores the intensity of the different subsurface effects in the thickness texture.
  68282. * * the green channel is the translucency intensity.
  68283. * * the blue channel is the scattering intensity.
  68284. * * the alpha channel is the refraction intensity.
  68285. */
  68286. useMaskFromThicknessTexture: boolean;
  68287. /**
  68288. * Initialize the block and prepare the context for build
  68289. * @param state defines the state that will be used for the build
  68290. */
  68291. initialize(state: NodeMaterialBuildState): void;
  68292. /**
  68293. * Gets the current class name
  68294. * @returns the class name
  68295. */
  68296. getClassName(): string;
  68297. /**
  68298. * Gets the min thickness input component
  68299. */
  68300. get minThickness(): NodeMaterialConnectionPoint;
  68301. /**
  68302. * Gets the max thickness input component
  68303. */
  68304. get maxThickness(): NodeMaterialConnectionPoint;
  68305. /**
  68306. * Gets the thickness texture component
  68307. */
  68308. get thicknessTexture(): NodeMaterialConnectionPoint;
  68309. /**
  68310. * Gets the tint color input component
  68311. */
  68312. get tintColor(): NodeMaterialConnectionPoint;
  68313. /**
  68314. * Gets the translucency intensity input component
  68315. */
  68316. get translucencyIntensity(): NodeMaterialConnectionPoint;
  68317. /**
  68318. * Gets the translucency diffusion distance input component
  68319. */
  68320. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  68321. /**
  68322. * Gets the refraction object parameters
  68323. */
  68324. get refraction(): NodeMaterialConnectionPoint;
  68325. /**
  68326. * Gets the sub surface object output component
  68327. */
  68328. get subsurface(): NodeMaterialConnectionPoint;
  68329. autoConfigure(material: NodeMaterial): void;
  68330. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68331. /**
  68332. * Gets the main code of the block (fragment side)
  68333. * @param state current state of the node material building
  68334. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  68335. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  68336. * @param worldPosVarName name of the variable holding the world position
  68337. * @returns the shader code
  68338. */
  68339. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  68340. protected _buildBlock(state: NodeMaterialBuildState): this;
  68341. }
  68342. }
  68343. declare module "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock" {
  68344. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68345. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68346. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68347. import { NodeMaterial, NodeMaterialDefines } from "babylonjs/Materials/Node/nodeMaterial";
  68348. import { Light } from "babylonjs/Lights/light";
  68349. import { Nullable } from "babylonjs/types";
  68350. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  68351. import { Effect } from "babylonjs/Materials/effect";
  68352. import { Mesh } from "babylonjs/Meshes/mesh";
  68353. import { Scene } from "babylonjs/scene";
  68354. /**
  68355. * Block used to implement the PBR metallic/roughness model
  68356. */
  68357. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  68358. /**
  68359. * Gets or sets the light associated with this block
  68360. */
  68361. light: Nullable<Light>;
  68362. private _lightId;
  68363. private _scene;
  68364. private _environmentBRDFTexture;
  68365. private _environmentBrdfSamplerName;
  68366. private _vNormalWName;
  68367. private _invertNormalName;
  68368. /**
  68369. * Create a new ReflectionBlock
  68370. * @param name defines the block name
  68371. */
  68372. constructor(name: string);
  68373. /**
  68374. * Intensity of the direct lights e.g. the four lights available in your scene.
  68375. * This impacts both the direct diffuse and specular highlights.
  68376. */
  68377. directIntensity: number;
  68378. /**
  68379. * Intensity of the environment e.g. how much the environment will light the object
  68380. * either through harmonics for rough material or through the refelction for shiny ones.
  68381. */
  68382. environmentIntensity: number;
  68383. /**
  68384. * This is a special control allowing the reduction of the specular highlights coming from the
  68385. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  68386. */
  68387. specularIntensity: number;
  68388. /**
  68389. * Defines the falloff type used in this material.
  68390. * It by default is Physical.
  68391. */
  68392. lightFalloff: number;
  68393. /**
  68394. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  68395. */
  68396. useAlphaFromAlbedoTexture: boolean;
  68397. /**
  68398. * Specifies that alpha test should be used
  68399. */
  68400. useAlphaTest: boolean;
  68401. /**
  68402. * Defines the alpha limits in alpha test mode.
  68403. */
  68404. alphaTestCutoff: number;
  68405. /**
  68406. * Specifies that alpha blending should be used
  68407. */
  68408. useAlphaBlending: boolean;
  68409. /**
  68410. * Defines if the alpha value should be determined via the rgb values.
  68411. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  68412. */
  68413. opacityRGB: boolean;
  68414. /**
  68415. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  68416. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  68417. */
  68418. useRadianceOverAlpha: boolean;
  68419. /**
  68420. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  68421. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  68422. */
  68423. useSpecularOverAlpha: boolean;
  68424. /**
  68425. * Enables specular anti aliasing in the PBR shader.
  68426. * It will both interacts on the Geometry for analytical and IBL lighting.
  68427. * It also prefilter the roughness map based on the bump values.
  68428. */
  68429. enableSpecularAntiAliasing: boolean;
  68430. /**
  68431. * Enables realtime filtering on the texture.
  68432. */
  68433. realTimeFiltering: boolean;
  68434. /**
  68435. * Quality switch for realtime filtering
  68436. */
  68437. realTimeFilteringQuality: number;
  68438. /**
  68439. * Defines if the material uses energy conservation.
  68440. */
  68441. useEnergyConservation: boolean;
  68442. /**
  68443. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  68444. * too much the area relying on ambient texture to define their ambient occlusion.
  68445. */
  68446. useRadianceOcclusion: boolean;
  68447. /**
  68448. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  68449. * makes the reflect vector face the model (under horizon).
  68450. */
  68451. useHorizonOcclusion: boolean;
  68452. /**
  68453. * If set to true, no lighting calculations will be applied.
  68454. */
  68455. unlit: boolean;
  68456. /**
  68457. * Force normal to face away from face.
  68458. */
  68459. forceNormalForward: boolean;
  68460. /**
  68461. * Defines the material debug mode.
  68462. * It helps seeing only some components of the material while troubleshooting.
  68463. */
  68464. debugMode: number;
  68465. /**
  68466. * Specify from where on screen the debug mode should start.
  68467. * The value goes from -1 (full screen) to 1 (not visible)
  68468. * It helps with side by side comparison against the final render
  68469. * This defaults to 0
  68470. */
  68471. debugLimit: number;
  68472. /**
  68473. * As the default viewing range might not be enough (if the ambient is really small for instance)
  68474. * You can use the factor to better multiply the final value.
  68475. */
  68476. debugFactor: number;
  68477. /**
  68478. * Initialize the block and prepare the context for build
  68479. * @param state defines the state that will be used for the build
  68480. */
  68481. initialize(state: NodeMaterialBuildState): void;
  68482. /**
  68483. * Gets the current class name
  68484. * @returns the class name
  68485. */
  68486. getClassName(): string;
  68487. /**
  68488. * Gets the world position input component
  68489. */
  68490. get worldPosition(): NodeMaterialConnectionPoint;
  68491. /**
  68492. * Gets the world normal input component
  68493. */
  68494. get worldNormal(): NodeMaterialConnectionPoint;
  68495. /**
  68496. * Gets the perturbed normal input component
  68497. */
  68498. get perturbedNormal(): NodeMaterialConnectionPoint;
  68499. /**
  68500. * Gets the camera position input component
  68501. */
  68502. get cameraPosition(): NodeMaterialConnectionPoint;
  68503. /**
  68504. * Gets the base color input component
  68505. */
  68506. get baseColor(): NodeMaterialConnectionPoint;
  68507. /**
  68508. * Gets the opacity texture input component
  68509. */
  68510. get opacityTexture(): NodeMaterialConnectionPoint;
  68511. /**
  68512. * Gets the ambient color input component
  68513. */
  68514. get ambientColor(): NodeMaterialConnectionPoint;
  68515. /**
  68516. * Gets the reflectivity object parameters
  68517. */
  68518. get reflectivity(): NodeMaterialConnectionPoint;
  68519. /**
  68520. * Gets the ambient occlusion object parameters
  68521. */
  68522. get ambientOcc(): NodeMaterialConnectionPoint;
  68523. /**
  68524. * Gets the reflection object parameters
  68525. */
  68526. get reflection(): NodeMaterialConnectionPoint;
  68527. /**
  68528. * Gets the sheen object parameters
  68529. */
  68530. get sheen(): NodeMaterialConnectionPoint;
  68531. /**
  68532. * Gets the clear coat object parameters
  68533. */
  68534. get clearcoat(): NodeMaterialConnectionPoint;
  68535. /**
  68536. * Gets the sub surface object parameters
  68537. */
  68538. get subsurface(): NodeMaterialConnectionPoint;
  68539. /**
  68540. * Gets the anisotropy object parameters
  68541. */
  68542. get anisotropy(): NodeMaterialConnectionPoint;
  68543. /**
  68544. * Gets the ambient output component
  68545. */
  68546. get ambient(): NodeMaterialConnectionPoint;
  68547. /**
  68548. * Gets the diffuse output component
  68549. */
  68550. get diffuse(): NodeMaterialConnectionPoint;
  68551. /**
  68552. * Gets the specular output component
  68553. */
  68554. get specular(): NodeMaterialConnectionPoint;
  68555. /**
  68556. * Gets the sheen output component
  68557. */
  68558. get sheenDir(): NodeMaterialConnectionPoint;
  68559. /**
  68560. * Gets the clear coat output component
  68561. */
  68562. get clearcoatDir(): NodeMaterialConnectionPoint;
  68563. /**
  68564. * Gets the indirect diffuse output component
  68565. */
  68566. get diffuseIndirect(): NodeMaterialConnectionPoint;
  68567. /**
  68568. * Gets the indirect specular output component
  68569. */
  68570. get specularIndirect(): NodeMaterialConnectionPoint;
  68571. /**
  68572. * Gets the indirect sheen output component
  68573. */
  68574. get sheenIndirect(): NodeMaterialConnectionPoint;
  68575. /**
  68576. * Gets the indirect clear coat output component
  68577. */
  68578. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  68579. /**
  68580. * Gets the refraction output component
  68581. */
  68582. get refraction(): NodeMaterialConnectionPoint;
  68583. /**
  68584. * Gets the global lighting output component
  68585. */
  68586. get lighting(): NodeMaterialConnectionPoint;
  68587. /**
  68588. * Gets the shadow output component
  68589. */
  68590. get shadow(): NodeMaterialConnectionPoint;
  68591. /**
  68592. * Gets the alpha output component
  68593. */
  68594. get alpha(): NodeMaterialConnectionPoint;
  68595. autoConfigure(material: NodeMaterial): void;
  68596. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  68597. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  68598. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  68599. private _injectVertexCode;
  68600. /**
  68601. * Gets the code corresponding to the albedo/opacity module
  68602. * @returns the shader code
  68603. */
  68604. getAlbedoOpacityCode(): string;
  68605. protected _buildBlock(state: NodeMaterialBuildState): this;
  68606. protected _dumpPropertiesCode(): string;
  68607. serialize(): any;
  68608. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  68609. }
  68610. }
  68611. declare module "babylonjs/Materials/Node/Blocks/PBR/index" {
  68612. export * from "babylonjs/Materials/Node/Blocks/PBR/pbrMetallicRoughnessBlock";
  68613. export * from "babylonjs/Materials/Node/Blocks/PBR/sheenBlock";
  68614. export * from "babylonjs/Materials/Node/Blocks/PBR/ambientOcclusionBlock";
  68615. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectivityBlock";
  68616. export * from "babylonjs/Materials/Node/Blocks/PBR/anisotropyBlock";
  68617. export * from "babylonjs/Materials/Node/Blocks/PBR/reflectionBlock";
  68618. export * from "babylonjs/Materials/Node/Blocks/PBR/clearCoatBlock";
  68619. export * from "babylonjs/Materials/Node/Blocks/PBR/refractionBlock";
  68620. export * from "babylonjs/Materials/Node/Blocks/PBR/subSurfaceBlock";
  68621. }
  68622. declare module "babylonjs/Materials/Node/Blocks/Particle/index" {
  68623. export * from "babylonjs/Materials/Node/Blocks/Particle/particleTextureBlock";
  68624. export * from "babylonjs/Materials/Node/Blocks/Particle/particleRampGradientBlock";
  68625. export * from "babylonjs/Materials/Node/Blocks/Particle/particleBlendMultiplyBlock";
  68626. }
  68627. declare module "babylonjs/Materials/Node/Blocks/modBlock" {
  68628. import { NodeMaterialBlock } from "babylonjs/Materials/Node/nodeMaterialBlock";
  68629. import { NodeMaterialBuildState } from "babylonjs/Materials/Node/nodeMaterialBuildState";
  68630. import { NodeMaterialConnectionPoint } from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68631. /**
  68632. * Block used to compute value of one parameter modulo another
  68633. */
  68634. export class ModBlock extends NodeMaterialBlock {
  68635. /**
  68636. * Creates a new ModBlock
  68637. * @param name defines the block name
  68638. */
  68639. constructor(name: string);
  68640. /**
  68641. * Gets the current class name
  68642. * @returns the class name
  68643. */
  68644. getClassName(): string;
  68645. /**
  68646. * Gets the left operand input component
  68647. */
  68648. get left(): NodeMaterialConnectionPoint;
  68649. /**
  68650. * Gets the right operand input component
  68651. */
  68652. get right(): NodeMaterialConnectionPoint;
  68653. /**
  68654. * Gets the output component
  68655. */
  68656. get output(): NodeMaterialConnectionPoint;
  68657. protected _buildBlock(state: NodeMaterialBuildState): this;
  68658. }
  68659. }
  68660. declare module "babylonjs/Materials/Node/Blocks/index" {
  68661. export * from "babylonjs/Materials/Node/Blocks/Vertex/index";
  68662. export * from "babylonjs/Materials/Node/Blocks/Fragment/index";
  68663. export * from "babylonjs/Materials/Node/Blocks/Dual/index";
  68664. export * from "babylonjs/Materials/Node/Blocks/Input/index";
  68665. export * from "babylonjs/Materials/Node/Blocks/multiplyBlock";
  68666. export * from "babylonjs/Materials/Node/Blocks/addBlock";
  68667. export * from "babylonjs/Materials/Node/Blocks/scaleBlock";
  68668. export * from "babylonjs/Materials/Node/Blocks/clampBlock";
  68669. export * from "babylonjs/Materials/Node/Blocks/crossBlock";
  68670. export * from "babylonjs/Materials/Node/Blocks/dotBlock";
  68671. export * from "babylonjs/Materials/Node/Blocks/transformBlock";
  68672. export * from "babylonjs/Materials/Node/Blocks/remapBlock";
  68673. export * from "babylonjs/Materials/Node/Blocks/normalizeBlock";
  68674. export * from "babylonjs/Materials/Node/Blocks/trigonometryBlock";
  68675. export * from "babylonjs/Materials/Node/Blocks/colorMergerBlock";
  68676. export * from "babylonjs/Materials/Node/Blocks/vectorMergerBlock";
  68677. export * from "babylonjs/Materials/Node/Blocks/colorSplitterBlock";
  68678. export * from "babylonjs/Materials/Node/Blocks/vectorSplitterBlock";
  68679. export * from "babylonjs/Materials/Node/Blocks/lerpBlock";
  68680. export * from "babylonjs/Materials/Node/Blocks/divideBlock";
  68681. export * from "babylonjs/Materials/Node/Blocks/subtractBlock";
  68682. export * from "babylonjs/Materials/Node/Blocks/stepBlock";
  68683. export * from "babylonjs/Materials/Node/Blocks/oneMinusBlock";
  68684. export * from "babylonjs/Materials/Node/Blocks/viewDirectionBlock";
  68685. export * from "babylonjs/Materials/Node/Blocks/fresnelBlock";
  68686. export * from "babylonjs/Materials/Node/Blocks/maxBlock";
  68687. export * from "babylonjs/Materials/Node/Blocks/minBlock";
  68688. export * from "babylonjs/Materials/Node/Blocks/distanceBlock";
  68689. export * from "babylonjs/Materials/Node/Blocks/lengthBlock";
  68690. export * from "babylonjs/Materials/Node/Blocks/negateBlock";
  68691. export * from "babylonjs/Materials/Node/Blocks/powBlock";
  68692. export * from "babylonjs/Materials/Node/Blocks/randomNumberBlock";
  68693. export * from "babylonjs/Materials/Node/Blocks/arcTan2Block";
  68694. export * from "babylonjs/Materials/Node/Blocks/smoothStepBlock";
  68695. export * from "babylonjs/Materials/Node/Blocks/reciprocalBlock";
  68696. export * from "babylonjs/Materials/Node/Blocks/replaceColorBlock";
  68697. export * from "babylonjs/Materials/Node/Blocks/posterizeBlock";
  68698. export * from "babylonjs/Materials/Node/Blocks/waveBlock";
  68699. export * from "babylonjs/Materials/Node/Blocks/gradientBlock";
  68700. export * from "babylonjs/Materials/Node/Blocks/nLerpBlock";
  68701. export * from "babylonjs/Materials/Node/Blocks/worleyNoise3DBlock";
  68702. export * from "babylonjs/Materials/Node/Blocks/simplexPerlin3DBlock";
  68703. export * from "babylonjs/Materials/Node/Blocks/normalBlendBlock";
  68704. export * from "babylonjs/Materials/Node/Blocks/rotate2dBlock";
  68705. export * from "babylonjs/Materials/Node/Blocks/reflectBlock";
  68706. export * from "babylonjs/Materials/Node/Blocks/refractBlock";
  68707. export * from "babylonjs/Materials/Node/Blocks/desaturateBlock";
  68708. export * from "babylonjs/Materials/Node/Blocks/PBR/index";
  68709. export * from "babylonjs/Materials/Node/Blocks/Particle/index";
  68710. export * from "babylonjs/Materials/Node/Blocks/modBlock";
  68711. }
  68712. declare module "babylonjs/Materials/Node/Optimizers/index" {
  68713. export * from "babylonjs/Materials/Node/Optimizers/nodeMaterialOptimizer";
  68714. }
  68715. declare module "babylonjs/Materials/Node/index" {
  68716. export * from "babylonjs/Materials/Node/Enums/index";
  68717. export * from "babylonjs/Materials/Node/nodeMaterialBlockConnectionPoint";
  68718. export * from "babylonjs/Materials/Node/nodeMaterialBlock";
  68719. export * from "babylonjs/Materials/Node/nodeMaterial";
  68720. export * from "babylonjs/Materials/Node/Blocks/index";
  68721. export * from "babylonjs/Materials/Node/Optimizers/index";
  68722. export * from "babylonjs/Materials/Node/nodeMaterialDecorator";
  68723. }
  68724. declare module "babylonjs/Materials/index" {
  68725. export * from "babylonjs/Materials/Background/index";
  68726. export * from "babylonjs/Materials/colorCurves";
  68727. export * from "babylonjs/Materials/iEffectFallbacks";
  68728. export * from "babylonjs/Materials/effectFallbacks";
  68729. export * from "babylonjs/Materials/effect";
  68730. export * from "babylonjs/Materials/fresnelParameters";
  68731. export * from "babylonjs/Materials/imageProcessingConfiguration";
  68732. export * from "babylonjs/Materials/material";
  68733. export * from "babylonjs/Materials/materialDefines";
  68734. export * from "babylonjs/Materials/thinMaterialHelper";
  68735. export * from "babylonjs/Materials/materialHelper";
  68736. export * from "babylonjs/Materials/multiMaterial";
  68737. export * from "babylonjs/Materials/PBR/index";
  68738. export * from "babylonjs/Materials/pushMaterial";
  68739. export * from "babylonjs/Materials/shaderMaterial";
  68740. export * from "babylonjs/Materials/standardMaterial";
  68741. export * from "babylonjs/Materials/Textures/index";
  68742. export * from "babylonjs/Materials/uniformBuffer";
  68743. export * from "babylonjs/Materials/materialFlags";
  68744. export * from "babylonjs/Materials/Node/index";
  68745. export * from "babylonjs/Materials/effectRenderer";
  68746. export * from "babylonjs/Materials/shadowDepthWrapper";
  68747. }
  68748. declare module "babylonjs/Maths/index" {
  68749. export * from "babylonjs/Maths/math.scalar";
  68750. export * from "babylonjs/Maths/math";
  68751. export * from "babylonjs/Maths/sphericalPolynomial";
  68752. }
  68753. declare module "babylonjs/Meshes/Compression/dracoCompression" {
  68754. import { IDisposable } from "babylonjs/scene";
  68755. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  68756. /**
  68757. * Configuration for Draco compression
  68758. */
  68759. export interface IDracoCompressionConfiguration {
  68760. /**
  68761. * Configuration for the decoder.
  68762. */
  68763. decoder: {
  68764. /**
  68765. * The url to the WebAssembly module.
  68766. */
  68767. wasmUrl?: string;
  68768. /**
  68769. * The url to the WebAssembly binary.
  68770. */
  68771. wasmBinaryUrl?: string;
  68772. /**
  68773. * The url to the fallback JavaScript module.
  68774. */
  68775. fallbackUrl?: string;
  68776. };
  68777. }
  68778. /**
  68779. * Draco compression (https://google.github.io/draco/)
  68780. *
  68781. * This class wraps the Draco module.
  68782. *
  68783. * **Encoder**
  68784. *
  68785. * The encoder is not currently implemented.
  68786. *
  68787. * **Decoder**
  68788. *
  68789. * 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.
  68790. *
  68791. * To update the configuration, use the following code:
  68792. * ```javascript
  68793. * DracoCompression.Configuration = {
  68794. * decoder: {
  68795. * wasmUrl: "<url to the WebAssembly library>",
  68796. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  68797. * fallbackUrl: "<url to the fallback JavaScript library>",
  68798. * }
  68799. * };
  68800. * ```
  68801. *
  68802. * 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.
  68803. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  68804. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  68805. *
  68806. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  68807. * ```javascript
  68808. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  68809. * ```
  68810. *
  68811. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  68812. */
  68813. export class DracoCompression implements IDisposable {
  68814. private _workerPoolPromise?;
  68815. private _decoderModulePromise?;
  68816. /**
  68817. * The configuration. Defaults to the following urls:
  68818. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  68819. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  68820. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  68821. */
  68822. static Configuration: IDracoCompressionConfiguration;
  68823. /**
  68824. * Returns true if the decoder configuration is available.
  68825. */
  68826. static get DecoderAvailable(): boolean;
  68827. /**
  68828. * Default number of workers to create when creating the draco compression object.
  68829. */
  68830. static DefaultNumWorkers: number;
  68831. private static GetDefaultNumWorkers;
  68832. private static _Default;
  68833. /**
  68834. * Default instance for the draco compression object.
  68835. */
  68836. static get Default(): DracoCompression;
  68837. /**
  68838. * Constructor
  68839. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  68840. */
  68841. constructor(numWorkers?: number);
  68842. /**
  68843. * Stop all async operations and release resources.
  68844. */
  68845. dispose(): void;
  68846. /**
  68847. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  68848. * @returns a promise that resolves when ready
  68849. */
  68850. whenReadyAsync(): Promise<void>;
  68851. /**
  68852. * Decode Draco compressed mesh data to vertex data.
  68853. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  68854. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  68855. * @returns A promise that resolves with the decoded vertex data
  68856. */
  68857. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  68858. [kind: string]: number;
  68859. }): Promise<VertexData>;
  68860. }
  68861. }
  68862. declare module "babylonjs/Meshes/Compression/index" {
  68863. export * from "babylonjs/Meshes/Compression/dracoCompression";
  68864. }
  68865. declare module "babylonjs/Meshes/csg" {
  68866. import { Nullable } from "babylonjs/types";
  68867. import { Scene } from "babylonjs/scene";
  68868. import { Quaternion, Matrix, Vector3 } from "babylonjs/Maths/math.vector";
  68869. import { Mesh } from "babylonjs/Meshes/mesh";
  68870. import { Material } from "babylonjs/Materials/material";
  68871. /**
  68872. * Class for building Constructive Solid Geometry
  68873. */
  68874. export class CSG {
  68875. private polygons;
  68876. /**
  68877. * The world matrix
  68878. */
  68879. matrix: Matrix;
  68880. /**
  68881. * Stores the position
  68882. */
  68883. position: Vector3;
  68884. /**
  68885. * Stores the rotation
  68886. */
  68887. rotation: Vector3;
  68888. /**
  68889. * Stores the rotation quaternion
  68890. */
  68891. rotationQuaternion: Nullable<Quaternion>;
  68892. /**
  68893. * Stores the scaling vector
  68894. */
  68895. scaling: Vector3;
  68896. /**
  68897. * Convert the Mesh to CSG
  68898. * @param mesh The Mesh to convert to CSG
  68899. * @returns A new CSG from the Mesh
  68900. */
  68901. static FromMesh(mesh: Mesh): CSG;
  68902. /**
  68903. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  68904. * @param polygons Polygons used to construct a CSG solid
  68905. */
  68906. private static FromPolygons;
  68907. /**
  68908. * Clones, or makes a deep copy, of the CSG
  68909. * @returns A new CSG
  68910. */
  68911. clone(): CSG;
  68912. /**
  68913. * Unions this CSG with another CSG
  68914. * @param csg The CSG to union against this CSG
  68915. * @returns The unioned CSG
  68916. */
  68917. union(csg: CSG): CSG;
  68918. /**
  68919. * Unions this CSG with another CSG in place
  68920. * @param csg The CSG to union against this CSG
  68921. */
  68922. unionInPlace(csg: CSG): void;
  68923. /**
  68924. * Subtracts this CSG with another CSG
  68925. * @param csg The CSG to subtract against this CSG
  68926. * @returns A new CSG
  68927. */
  68928. subtract(csg: CSG): CSG;
  68929. /**
  68930. * Subtracts this CSG with another CSG in place
  68931. * @param csg The CSG to subtact against this CSG
  68932. */
  68933. subtractInPlace(csg: CSG): void;
  68934. /**
  68935. * Intersect this CSG with another CSG
  68936. * @param csg The CSG to intersect against this CSG
  68937. * @returns A new CSG
  68938. */
  68939. intersect(csg: CSG): CSG;
  68940. /**
  68941. * Intersects this CSG with another CSG in place
  68942. * @param csg The CSG to intersect against this CSG
  68943. */
  68944. intersectInPlace(csg: CSG): void;
  68945. /**
  68946. * Return a new CSG solid with solid and empty space switched. This solid is
  68947. * not modified.
  68948. * @returns A new CSG solid with solid and empty space switched
  68949. */
  68950. inverse(): CSG;
  68951. /**
  68952. * Inverses the CSG in place
  68953. */
  68954. inverseInPlace(): void;
  68955. /**
  68956. * This is used to keep meshes transformations so they can be restored
  68957. * when we build back a Babylon Mesh
  68958. * NB : All CSG operations are performed in world coordinates
  68959. * @param csg The CSG to copy the transform attributes from
  68960. * @returns This CSG
  68961. */
  68962. copyTransformAttributes(csg: CSG): CSG;
  68963. /**
  68964. * Build Raw mesh from CSG
  68965. * Coordinates here are in world space
  68966. * @param name The name of the mesh geometry
  68967. * @param scene The Scene
  68968. * @param keepSubMeshes Specifies if the submeshes should be kept
  68969. * @returns A new Mesh
  68970. */
  68971. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68972. /**
  68973. * Build Mesh from CSG taking material and transforms into account
  68974. * @param name The name of the Mesh
  68975. * @param material The material of the Mesh
  68976. * @param scene The Scene
  68977. * @param keepSubMeshes Specifies if submeshes should be kept
  68978. * @returns The new Mesh
  68979. */
  68980. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  68981. }
  68982. }
  68983. declare module "babylonjs/Meshes/trailMesh" {
  68984. import { Mesh } from "babylonjs/Meshes/mesh";
  68985. import { Scene } from "babylonjs/scene";
  68986. import { TransformNode } from "babylonjs/Meshes/transformNode";
  68987. /**
  68988. * Class used to create a trail following a mesh
  68989. */
  68990. export class TrailMesh extends Mesh {
  68991. private _generator;
  68992. private _autoStart;
  68993. private _running;
  68994. private _diameter;
  68995. private _length;
  68996. private _sectionPolygonPointsCount;
  68997. private _sectionVectors;
  68998. private _sectionNormalVectors;
  68999. private _beforeRenderObserver;
  69000. /**
  69001. * @constructor
  69002. * @param name The value used by scene.getMeshByName() to do a lookup.
  69003. * @param generator The mesh or transform node to generate a trail.
  69004. * @param scene The scene to add this mesh to.
  69005. * @param diameter Diameter of trailing mesh. Default is 1.
  69006. * @param length Length of trailing mesh. Default is 60.
  69007. * @param autoStart Automatically start trailing mesh. Default true.
  69008. */
  69009. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  69010. /**
  69011. * "TrailMesh"
  69012. * @returns "TrailMesh"
  69013. */
  69014. getClassName(): string;
  69015. private _createMesh;
  69016. /**
  69017. * Start trailing mesh.
  69018. */
  69019. start(): void;
  69020. /**
  69021. * Stop trailing mesh.
  69022. */
  69023. stop(): void;
  69024. /**
  69025. * Update trailing mesh geometry.
  69026. */
  69027. update(): void;
  69028. /**
  69029. * Returns a new TrailMesh object.
  69030. * @param name is a string, the name given to the new mesh
  69031. * @param newGenerator use new generator object for cloned trail mesh
  69032. * @returns a new mesh
  69033. */
  69034. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  69035. /**
  69036. * Serializes this trail mesh
  69037. * @param serializationObject object to write serialization to
  69038. */
  69039. serialize(serializationObject: any): void;
  69040. /**
  69041. * Parses a serialized trail mesh
  69042. * @param parsedMesh the serialized mesh
  69043. * @param scene the scene to create the trail mesh in
  69044. * @returns the created trail mesh
  69045. */
  69046. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  69047. }
  69048. }
  69049. declare module "babylonjs/Meshes/Builders/tiledBoxBuilder" {
  69050. import { Nullable } from "babylonjs/types";
  69051. import { Scene } from "babylonjs/scene";
  69052. import { Vector4 } from "babylonjs/Maths/math.vector";
  69053. import { Color4 } from "babylonjs/Maths/math.color";
  69054. import { Mesh } from "babylonjs/Meshes/mesh";
  69055. /**
  69056. * Class containing static functions to help procedurally build meshes
  69057. */
  69058. export class TiledBoxBuilder {
  69059. /**
  69060. * Creates a box mesh
  69061. * 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)
  69062. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69063. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69064. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69065. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69066. * @param name defines the name of the mesh
  69067. * @param options defines the options used to create the mesh
  69068. * @param scene defines the hosting scene
  69069. * @returns the box mesh
  69070. */
  69071. static CreateTiledBox(name: string, options: {
  69072. pattern?: number;
  69073. width?: number;
  69074. height?: number;
  69075. depth?: number;
  69076. tileSize?: number;
  69077. tileWidth?: number;
  69078. tileHeight?: number;
  69079. alignHorizontal?: number;
  69080. alignVertical?: number;
  69081. faceUV?: Vector4[];
  69082. faceColors?: Color4[];
  69083. sideOrientation?: number;
  69084. updatable?: boolean;
  69085. }, scene?: Nullable<Scene>): Mesh;
  69086. }
  69087. }
  69088. declare module "babylonjs/Meshes/Builders/torusKnotBuilder" {
  69089. import { Vector4 } from "babylonjs/Maths/math.vector";
  69090. import { Mesh } from "babylonjs/Meshes/mesh";
  69091. /**
  69092. * Class containing static functions to help procedurally build meshes
  69093. */
  69094. export class TorusKnotBuilder {
  69095. /**
  69096. * Creates a torus knot mesh
  69097. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69098. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69099. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69100. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69101. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69102. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69103. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69104. * @param name defines the name of the mesh
  69105. * @param options defines the options used to create the mesh
  69106. * @param scene defines the hosting scene
  69107. * @returns the torus knot mesh
  69108. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69109. */
  69110. static CreateTorusKnot(name: string, options: {
  69111. radius?: number;
  69112. tube?: number;
  69113. radialSegments?: number;
  69114. tubularSegments?: number;
  69115. p?: number;
  69116. q?: number;
  69117. updatable?: boolean;
  69118. sideOrientation?: number;
  69119. frontUVs?: Vector4;
  69120. backUVs?: Vector4;
  69121. }, scene: any): Mesh;
  69122. }
  69123. }
  69124. declare module "babylonjs/Meshes/polygonMesh" {
  69125. import { Scene } from "babylonjs/scene";
  69126. import { Vector2 } from "babylonjs/Maths/math.vector";
  69127. import { Mesh } from "babylonjs/Meshes/mesh";
  69128. import { VertexData } from "babylonjs/Meshes/mesh.vertexData";
  69129. import { Path2 } from "babylonjs/Maths/math.path";
  69130. /**
  69131. * Polygon
  69132. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  69133. */
  69134. export class Polygon {
  69135. /**
  69136. * Creates a rectangle
  69137. * @param xmin bottom X coord
  69138. * @param ymin bottom Y coord
  69139. * @param xmax top X coord
  69140. * @param ymax top Y coord
  69141. * @returns points that make the resulting rectation
  69142. */
  69143. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  69144. /**
  69145. * Creates a circle
  69146. * @param radius radius of circle
  69147. * @param cx scale in x
  69148. * @param cy scale in y
  69149. * @param numberOfSides number of sides that make up the circle
  69150. * @returns points that make the resulting circle
  69151. */
  69152. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  69153. /**
  69154. * Creates a polygon from input string
  69155. * @param input Input polygon data
  69156. * @returns the parsed points
  69157. */
  69158. static Parse(input: string): Vector2[];
  69159. /**
  69160. * Starts building a polygon from x and y coordinates
  69161. * @param x x coordinate
  69162. * @param y y coordinate
  69163. * @returns the started path2
  69164. */
  69165. static StartingAt(x: number, y: number): Path2;
  69166. }
  69167. /**
  69168. * Builds a polygon
  69169. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  69170. */
  69171. export class PolygonMeshBuilder {
  69172. private _points;
  69173. private _outlinepoints;
  69174. private _holes;
  69175. private _name;
  69176. private _scene;
  69177. private _epoints;
  69178. private _eholes;
  69179. private _addToepoint;
  69180. /**
  69181. * Babylon reference to the earcut plugin.
  69182. */
  69183. bjsEarcut: any;
  69184. /**
  69185. * Creates a PolygonMeshBuilder
  69186. * @param name name of the builder
  69187. * @param contours Path of the polygon
  69188. * @param scene scene to add to when creating the mesh
  69189. * @param earcutInjection can be used to inject your own earcut reference
  69190. */
  69191. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  69192. /**
  69193. * Adds a whole within the polygon
  69194. * @param hole Array of points defining the hole
  69195. * @returns this
  69196. */
  69197. addHole(hole: Vector2[]): PolygonMeshBuilder;
  69198. /**
  69199. * Creates the polygon
  69200. * @param updatable If the mesh should be updatable
  69201. * @param depth The depth of the mesh created
  69202. * @returns the created mesh
  69203. */
  69204. build(updatable?: boolean, depth?: number): Mesh;
  69205. /**
  69206. * Creates the polygon
  69207. * @param depth The depth of the mesh created
  69208. * @returns the created VertexData
  69209. */
  69210. buildVertexData(depth?: number): VertexData;
  69211. /**
  69212. * Adds a side to the polygon
  69213. * @param positions points that make the polygon
  69214. * @param normals normals of the polygon
  69215. * @param uvs uvs of the polygon
  69216. * @param indices indices of the polygon
  69217. * @param bounds bounds of the polygon
  69218. * @param points points of the polygon
  69219. * @param depth depth of the polygon
  69220. * @param flip flip of the polygon
  69221. */
  69222. private addSide;
  69223. }
  69224. }
  69225. declare module "babylonjs/Meshes/Builders/polygonBuilder" {
  69226. import { Scene } from "babylonjs/scene";
  69227. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69228. import { Color4 } from "babylonjs/Maths/math.color";
  69229. import { Mesh } from "babylonjs/Meshes/mesh";
  69230. import { Nullable } from "babylonjs/types";
  69231. /**
  69232. * Class containing static functions to help procedurally build meshes
  69233. */
  69234. export class PolygonBuilder {
  69235. /**
  69236. * Creates a polygon mesh
  69237. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  69238. * * 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
  69239. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  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)
  69242. * * Remember you can only change the shape positions, not their number when updating a polygon
  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. * @param earcutInjection can be used to inject your own earcut reference
  69247. * @returns the polygon mesh
  69248. */
  69249. static CreatePolygon(name: string, options: {
  69250. shape: Vector3[];
  69251. holes?: Vector3[][];
  69252. depth?: number;
  69253. faceUV?: Vector4[];
  69254. faceColors?: Color4[];
  69255. updatable?: boolean;
  69256. sideOrientation?: number;
  69257. frontUVs?: Vector4;
  69258. backUVs?: Vector4;
  69259. wrap?: boolean;
  69260. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69261. /**
  69262. * Creates an extruded polygon mesh, with depth in the Y direction.
  69263. * * 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)
  69264. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69265. * @param name defines the name of the mesh
  69266. * @param options defines the options used to create the mesh
  69267. * @param scene defines the hosting scene
  69268. * @param earcutInjection can be used to inject your own earcut reference
  69269. * @returns the polygon mesh
  69270. */
  69271. static ExtrudePolygon(name: string, options: {
  69272. shape: Vector3[];
  69273. holes?: Vector3[][];
  69274. depth?: number;
  69275. faceUV?: Vector4[];
  69276. faceColors?: Color4[];
  69277. updatable?: boolean;
  69278. sideOrientation?: number;
  69279. frontUVs?: Vector4;
  69280. backUVs?: Vector4;
  69281. wrap?: boolean;
  69282. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  69283. }
  69284. }
  69285. declare module "babylonjs/Meshes/Builders/latheBuilder" {
  69286. import { Scene } from "babylonjs/scene";
  69287. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69288. import { Mesh } from "babylonjs/Meshes/mesh";
  69289. import { Nullable } from "babylonjs/types";
  69290. /**
  69291. * Class containing static functions to help procedurally build meshes
  69292. */
  69293. export class LatheBuilder {
  69294. /**
  69295. * Creates lathe mesh.
  69296. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69297. * * 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
  69298. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69299. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69300. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69301. * * 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
  69302. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69303. * * 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
  69304. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69305. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69306. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69307. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69308. * @param name defines the name of the mesh
  69309. * @param options defines the options used to create the mesh
  69310. * @param scene defines the hosting scene
  69311. * @returns the lathe mesh
  69312. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69313. */
  69314. static CreateLathe(name: string, options: {
  69315. shape: Vector3[];
  69316. radius?: number;
  69317. tessellation?: number;
  69318. clip?: number;
  69319. arc?: number;
  69320. closed?: boolean;
  69321. updatable?: boolean;
  69322. sideOrientation?: number;
  69323. frontUVs?: Vector4;
  69324. backUVs?: Vector4;
  69325. cap?: number;
  69326. invertUV?: boolean;
  69327. }, scene?: Nullable<Scene>): Mesh;
  69328. }
  69329. }
  69330. declare module "babylonjs/Meshes/Builders/tiledPlaneBuilder" {
  69331. import { Nullable } from "babylonjs/types";
  69332. import { Scene } from "babylonjs/scene";
  69333. import { Vector4 } from "babylonjs/Maths/math.vector";
  69334. import { Mesh } from "babylonjs/Meshes/mesh";
  69335. /**
  69336. * Class containing static functions to help procedurally build meshes
  69337. */
  69338. export class TiledPlaneBuilder {
  69339. /**
  69340. * Creates a tiled plane mesh
  69341. * * The parameter `pattern` will, depending on value, do nothing or
  69342. * * * flip (reflect about central vertical) alternate tiles across and up
  69343. * * * flip every tile on alternate rows
  69344. * * * rotate (180 degs) alternate tiles across and up
  69345. * * * rotate every tile on alternate rows
  69346. * * * flip and rotate alternate tiles across and up
  69347. * * * flip and rotate every tile on alternate rows
  69348. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  69349. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  69350. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69351. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  69352. * * 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)
  69353. * * 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)
  69354. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69355. * @param name defines the name of the mesh
  69356. * @param options defines the options used to create the mesh
  69357. * @param scene defines the hosting scene
  69358. * @returns the box mesh
  69359. */
  69360. static CreateTiledPlane(name: string, options: {
  69361. pattern?: number;
  69362. tileSize?: number;
  69363. tileWidth?: number;
  69364. tileHeight?: number;
  69365. size?: number;
  69366. width?: number;
  69367. height?: number;
  69368. alignHorizontal?: number;
  69369. alignVertical?: number;
  69370. sideOrientation?: number;
  69371. frontUVs?: Vector4;
  69372. backUVs?: Vector4;
  69373. updatable?: boolean;
  69374. }, scene?: Nullable<Scene>): Mesh;
  69375. }
  69376. }
  69377. declare module "babylonjs/Meshes/Builders/tubeBuilder" {
  69378. import { Nullable } from "babylonjs/types";
  69379. import { Scene } from "babylonjs/scene";
  69380. import { Vector3, Vector4 } from "babylonjs/Maths/math.vector";
  69381. import { Mesh } from "babylonjs/Meshes/mesh";
  69382. /**
  69383. * Class containing static functions to help procedurally build meshes
  69384. */
  69385. export class TubeBuilder {
  69386. /**
  69387. * Creates a tube mesh.
  69388. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69389. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  69390. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  69391. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  69392. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  69393. * * 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)
  69394. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  69395. * * 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
  69396. * * 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
  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 optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69400. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69401. * @param name defines the name of the mesh
  69402. * @param options defines the options used to create the mesh
  69403. * @param scene defines the hosting scene
  69404. * @returns the tube mesh
  69405. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69406. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  69407. */
  69408. static CreateTube(name: string, options: {
  69409. path: Vector3[];
  69410. radius?: number;
  69411. tessellation?: number;
  69412. radiusFunction?: {
  69413. (i: number, distance: number): number;
  69414. };
  69415. cap?: number;
  69416. arc?: number;
  69417. updatable?: boolean;
  69418. sideOrientation?: number;
  69419. frontUVs?: Vector4;
  69420. backUVs?: Vector4;
  69421. instance?: Mesh;
  69422. invertUV?: boolean;
  69423. }, scene?: Nullable<Scene>): Mesh;
  69424. }
  69425. }
  69426. declare module "babylonjs/Meshes/Builders/icoSphereBuilder" {
  69427. import { Scene } from "babylonjs/scene";
  69428. import { Vector4 } from "babylonjs/Maths/math.vector";
  69429. import { Mesh } from "babylonjs/Meshes/mesh";
  69430. import { Nullable } from "babylonjs/types";
  69431. /**
  69432. * Class containing static functions to help procedurally build meshes
  69433. */
  69434. export class IcoSphereBuilder {
  69435. /**
  69436. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69437. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69438. * * 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`)
  69439. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69440. * * 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
  69441. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69442. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69443. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69444. * @param name defines the name of the mesh
  69445. * @param options defines the options used to create the mesh
  69446. * @param scene defines the hosting scene
  69447. * @returns the icosahedron mesh
  69448. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69449. */
  69450. static CreateIcoSphere(name: string, options: {
  69451. radius?: number;
  69452. radiusX?: number;
  69453. radiusY?: number;
  69454. radiusZ?: number;
  69455. flat?: boolean;
  69456. subdivisions?: number;
  69457. sideOrientation?: number;
  69458. frontUVs?: Vector4;
  69459. backUVs?: Vector4;
  69460. updatable?: boolean;
  69461. }, scene?: Nullable<Scene>): Mesh;
  69462. }
  69463. }
  69464. declare module "babylonjs/Meshes/Builders/decalBuilder" {
  69465. import { Vector3 } from "babylonjs/Maths/math.vector";
  69466. import { Mesh } from "babylonjs/Meshes/mesh";
  69467. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69468. /**
  69469. * Class containing static functions to help procedurally build meshes
  69470. */
  69471. export class DecalBuilder {
  69472. /**
  69473. * Creates a decal mesh.
  69474. * 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
  69475. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  69476. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  69477. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  69478. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  69479. * @param name defines the name of the mesh
  69480. * @param sourceMesh defines the mesh where the decal must be applied
  69481. * @param options defines the options used to create the mesh
  69482. * @param scene defines the hosting scene
  69483. * @returns the decal mesh
  69484. * @see https://doc.babylonjs.com/how_to/decals
  69485. */
  69486. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  69487. position?: Vector3;
  69488. normal?: Vector3;
  69489. size?: Vector3;
  69490. angle?: number;
  69491. }): Mesh;
  69492. }
  69493. }
  69494. declare module "babylonjs/Meshes/meshBuilder" {
  69495. import { ICreateCapsuleOptions } from "babylonjs/Meshes/Builders/capsuleBuilder";
  69496. import { Vector4, Vector3, Vector2 } from "babylonjs/Maths/math.vector";
  69497. import { Nullable } from "babylonjs/types";
  69498. import { Scene } from "babylonjs/scene";
  69499. import { Mesh } from "babylonjs/Meshes/mesh";
  69500. import { LinesMesh } from "babylonjs/Meshes/linesMesh";
  69501. import { GroundMesh } from "babylonjs/Meshes/groundMesh";
  69502. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  69503. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  69504. import { Plane } from "babylonjs/Maths/math.plane";
  69505. /**
  69506. * Class containing static functions to help procedurally build meshes
  69507. */
  69508. export class MeshBuilder {
  69509. /**
  69510. * Creates a box mesh
  69511. * * The parameter `size` sets the size (float) of each box side (default 1)
  69512. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  69513. * * 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)
  69514. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  69515. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69516. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69517. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69518. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  69519. * @param name defines the name of the mesh
  69520. * @param options defines the options used to create the mesh
  69521. * @param scene defines the hosting scene
  69522. * @returns the box mesh
  69523. */
  69524. static CreateBox(name: string, options: {
  69525. size?: number;
  69526. width?: number;
  69527. height?: number;
  69528. depth?: number;
  69529. faceUV?: Vector4[];
  69530. faceColors?: Color4[];
  69531. sideOrientation?: number;
  69532. frontUVs?: Vector4;
  69533. backUVs?: Vector4;
  69534. wrap?: boolean;
  69535. topBaseAt?: number;
  69536. bottomBaseAt?: number;
  69537. updatable?: boolean;
  69538. }, scene?: Nullable<Scene>): Mesh;
  69539. /**
  69540. * Creates a tiled box mesh
  69541. * * faceTiles sets the pattern, tile size and number of tiles for a face
  69542. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69543. * @param name defines the name of the mesh
  69544. * @param options defines the options used to create the mesh
  69545. * @param scene defines the hosting scene
  69546. * @returns the tiled box mesh
  69547. */
  69548. static CreateTiledBox(name: string, options: {
  69549. pattern?: number;
  69550. size?: number;
  69551. width?: number;
  69552. height?: number;
  69553. depth: number;
  69554. tileSize?: number;
  69555. tileWidth?: number;
  69556. tileHeight?: number;
  69557. faceUV?: Vector4[];
  69558. faceColors?: Color4[];
  69559. alignHorizontal?: number;
  69560. alignVertical?: number;
  69561. sideOrientation?: number;
  69562. updatable?: boolean;
  69563. }, scene?: Nullable<Scene>): Mesh;
  69564. /**
  69565. * Creates a sphere mesh
  69566. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  69567. * * 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`)
  69568. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  69569. * * 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
  69570. * * 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)
  69571. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69572. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69573. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69574. * @param name defines the name of the mesh
  69575. * @param options defines the options used to create the mesh
  69576. * @param scene defines the hosting scene
  69577. * @returns the sphere mesh
  69578. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  69579. */
  69580. static CreateSphere(name: string, options: {
  69581. segments?: number;
  69582. diameter?: number;
  69583. diameterX?: number;
  69584. diameterY?: number;
  69585. diameterZ?: number;
  69586. arc?: number;
  69587. slice?: number;
  69588. sideOrientation?: number;
  69589. frontUVs?: Vector4;
  69590. backUVs?: Vector4;
  69591. updatable?: boolean;
  69592. }, scene?: Nullable<Scene>): Mesh;
  69593. /**
  69594. * Creates a plane polygonal mesh. By default, this is a disc
  69595. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  69596. * * 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
  69597. * * 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
  69598. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69599. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69600. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69601. * @param name defines the name of the mesh
  69602. * @param options defines the options used to create the mesh
  69603. * @param scene defines the hosting scene
  69604. * @returns the plane polygonal mesh
  69605. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  69606. */
  69607. static CreateDisc(name: string, options: {
  69608. radius?: number;
  69609. tessellation?: number;
  69610. arc?: number;
  69611. updatable?: boolean;
  69612. sideOrientation?: number;
  69613. frontUVs?: Vector4;
  69614. backUVs?: Vector4;
  69615. }, scene?: Nullable<Scene>): Mesh;
  69616. /**
  69617. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  69618. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  69619. * * 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`)
  69620. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  69621. * * 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
  69622. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69623. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69624. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69625. * @param name defines the name of the mesh
  69626. * @param options defines the options used to create the mesh
  69627. * @param scene defines the hosting scene
  69628. * @returns the icosahedron mesh
  69629. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  69630. */
  69631. static CreateIcoSphere(name: string, options: {
  69632. radius?: number;
  69633. radiusX?: number;
  69634. radiusY?: number;
  69635. radiusZ?: number;
  69636. flat?: boolean;
  69637. subdivisions?: number;
  69638. sideOrientation?: number;
  69639. frontUVs?: Vector4;
  69640. backUVs?: Vector4;
  69641. updatable?: boolean;
  69642. }, scene?: Nullable<Scene>): Mesh;
  69643. /**
  69644. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  69645. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  69646. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  69647. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  69648. * * 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
  69649. * * 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
  69650. * * 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
  69651. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69652. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69653. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69654. * * 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
  69655. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  69656. * * 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
  69657. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  69658. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69659. * @param name defines the name of the mesh
  69660. * @param options defines the options used to create the mesh
  69661. * @param scene defines the hosting scene
  69662. * @returns the ribbon mesh
  69663. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  69664. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69665. */
  69666. static CreateRibbon(name: string, options: {
  69667. pathArray: Vector3[][];
  69668. closeArray?: boolean;
  69669. closePath?: boolean;
  69670. offset?: number;
  69671. updatable?: boolean;
  69672. sideOrientation?: number;
  69673. frontUVs?: Vector4;
  69674. backUVs?: Vector4;
  69675. instance?: Mesh;
  69676. invertUV?: boolean;
  69677. uvs?: Vector2[];
  69678. colors?: Color4[];
  69679. }, scene?: Nullable<Scene>): Mesh;
  69680. /**
  69681. * Creates a cylinder or a cone mesh
  69682. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  69683. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  69684. * * 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.
  69685. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  69686. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  69687. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  69688. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  69689. * * 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).
  69690. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  69691. * * 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).
  69692. * * 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
  69693. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  69694. * * 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
  69695. * * 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.
  69696. * * If `enclose` is false, a ring surface is one element.
  69697. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  69698. * * 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
  69699. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69700. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69701. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69702. * @param name defines the name of the mesh
  69703. * @param options defines the options used to create the mesh
  69704. * @param scene defines the hosting scene
  69705. * @returns the cylinder mesh
  69706. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  69707. */
  69708. static CreateCylinder(name: string, options: {
  69709. height?: number;
  69710. diameterTop?: number;
  69711. diameterBottom?: number;
  69712. diameter?: number;
  69713. tessellation?: number;
  69714. subdivisions?: number;
  69715. arc?: number;
  69716. faceColors?: Color4[];
  69717. faceUV?: Vector4[];
  69718. updatable?: boolean;
  69719. hasRings?: boolean;
  69720. enclose?: boolean;
  69721. cap?: number;
  69722. sideOrientation?: number;
  69723. frontUVs?: Vector4;
  69724. backUVs?: Vector4;
  69725. }, scene?: Nullable<Scene>): Mesh;
  69726. /**
  69727. * Creates a torus mesh
  69728. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  69729. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  69730. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  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 mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69734. * @param name defines the name of the mesh
  69735. * @param options defines the options used to create the mesh
  69736. * @param scene defines the hosting scene
  69737. * @returns the torus mesh
  69738. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  69739. */
  69740. static CreateTorus(name: string, options: {
  69741. diameter?: number;
  69742. thickness?: number;
  69743. tessellation?: number;
  69744. updatable?: boolean;
  69745. sideOrientation?: number;
  69746. frontUVs?: Vector4;
  69747. backUVs?: Vector4;
  69748. }, scene?: Nullable<Scene>): Mesh;
  69749. /**
  69750. * Creates a torus knot mesh
  69751. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  69752. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  69753. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  69754. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  69755. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69756. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69757. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69758. * @param name defines the name of the mesh
  69759. * @param options defines the options used to create the mesh
  69760. * @param scene defines the hosting scene
  69761. * @returns the torus knot mesh
  69762. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  69763. */
  69764. static CreateTorusKnot(name: string, options: {
  69765. radius?: number;
  69766. tube?: number;
  69767. radialSegments?: number;
  69768. tubularSegments?: number;
  69769. p?: number;
  69770. q?: number;
  69771. updatable?: boolean;
  69772. sideOrientation?: number;
  69773. frontUVs?: Vector4;
  69774. backUVs?: Vector4;
  69775. }, scene?: Nullable<Scene>): Mesh;
  69776. /**
  69777. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  69778. * * 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
  69779. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  69780. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  69781. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  69782. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  69783. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  69784. * * 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
  69785. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  69786. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69787. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  69788. * @param name defines the name of the new line system
  69789. * @param options defines the options used to create the line system
  69790. * @param scene defines the hosting scene
  69791. * @returns a new line system mesh
  69792. */
  69793. static CreateLineSystem(name: string, options: {
  69794. lines: Vector3[][];
  69795. updatable?: boolean;
  69796. instance?: Nullable<LinesMesh>;
  69797. colors?: Nullable<Color4[][]>;
  69798. useVertexAlpha?: boolean;
  69799. }, scene: Nullable<Scene>): LinesMesh;
  69800. /**
  69801. * Creates a line mesh
  69802. * 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
  69803. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69804. * * The parameter `points` is an array successive Vector3
  69805. * * 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
  69806. * * The optional parameter `colors` is an array of successive Color4, one per line point
  69807. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  69808. * * When updating an instance, remember that only point positions can change, not the number of points
  69809. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69810. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  69811. * @param name defines the name of the new line system
  69812. * @param options defines the options used to create the line system
  69813. * @param scene defines the hosting scene
  69814. * @returns a new line mesh
  69815. */
  69816. static CreateLines(name: string, options: {
  69817. points: Vector3[];
  69818. updatable?: boolean;
  69819. instance?: Nullable<LinesMesh>;
  69820. colors?: Color4[];
  69821. useVertexAlpha?: boolean;
  69822. }, scene?: Nullable<Scene>): LinesMesh;
  69823. /**
  69824. * Creates a dashed line mesh
  69825. * * 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
  69826. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  69827. * * The parameter `points` is an array successive Vector3
  69828. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  69829. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  69830. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  69831. * * 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
  69832. * * When updating an instance, remember that only point positions can change, not the number of points
  69833. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69834. * @param name defines the name of the mesh
  69835. * @param options defines the options used to create the mesh
  69836. * @param scene defines the hosting scene
  69837. * @returns the dashed line mesh
  69838. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  69839. */
  69840. static CreateDashedLines(name: string, options: {
  69841. points: Vector3[];
  69842. dashSize?: number;
  69843. gapSize?: number;
  69844. dashNb?: number;
  69845. updatable?: boolean;
  69846. instance?: LinesMesh;
  69847. }, scene?: Nullable<Scene>): LinesMesh;
  69848. /**
  69849. * 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.
  69850. * * 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.
  69851. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69852. * * 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.
  69853. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  69854. * * 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
  69855. * * 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
  69856. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  69857. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69858. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69859. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  69860. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  69861. * @param name defines the name of the mesh
  69862. * @param options defines the options used to create the mesh
  69863. * @param scene defines the hosting scene
  69864. * @returns the extruded shape mesh
  69865. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69866. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69867. */
  69868. static ExtrudeShape(name: string, options: {
  69869. shape: Vector3[];
  69870. path: Vector3[];
  69871. scale?: number;
  69872. rotation?: number;
  69873. cap?: number;
  69874. updatable?: boolean;
  69875. sideOrientation?: number;
  69876. frontUVs?: Vector4;
  69877. backUVs?: Vector4;
  69878. instance?: Mesh;
  69879. invertUV?: boolean;
  69880. }, scene?: Nullable<Scene>): Mesh;
  69881. /**
  69882. * Creates an custom extruded shape mesh.
  69883. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  69884. * * 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.
  69885. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  69886. * * 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
  69887. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  69888. * * 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
  69889. * * It must returns a float value that will be the scale value applied to the shape on each path point
  69890. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  69891. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  69892. * * 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
  69893. * * 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
  69894. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  69895. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69896. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69897. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69898. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69899. * @param name defines the name of the mesh
  69900. * @param options defines the options used to create the mesh
  69901. * @param scene defines the hosting scene
  69902. * @returns the custom extruded shape mesh
  69903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  69904. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  69905. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  69906. */
  69907. static ExtrudeShapeCustom(name: string, options: {
  69908. shape: Vector3[];
  69909. path: Vector3[];
  69910. scaleFunction?: any;
  69911. rotationFunction?: any;
  69912. ribbonCloseArray?: boolean;
  69913. ribbonClosePath?: boolean;
  69914. cap?: number;
  69915. updatable?: boolean;
  69916. sideOrientation?: number;
  69917. frontUVs?: Vector4;
  69918. backUVs?: Vector4;
  69919. instance?: Mesh;
  69920. invertUV?: boolean;
  69921. }, scene?: Nullable<Scene>): Mesh;
  69922. /**
  69923. * Creates lathe mesh.
  69924. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  69925. * * 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
  69926. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  69927. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  69928. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  69929. * * 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
  69930. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  69931. * * 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
  69932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69933. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  69935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69936. * @param name defines the name of the mesh
  69937. * @param options defines the options used to create the mesh
  69938. * @param scene defines the hosting scene
  69939. * @returns the lathe mesh
  69940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  69941. */
  69942. static CreateLathe(name: string, options: {
  69943. shape: Vector3[];
  69944. radius?: number;
  69945. tessellation?: number;
  69946. clip?: number;
  69947. arc?: number;
  69948. closed?: boolean;
  69949. updatable?: boolean;
  69950. sideOrientation?: number;
  69951. frontUVs?: Vector4;
  69952. backUVs?: Vector4;
  69953. cap?: number;
  69954. invertUV?: boolean;
  69955. }, scene?: Nullable<Scene>): Mesh;
  69956. /**
  69957. * Creates a tiled plane mesh
  69958. * * You can set a limited pattern arrangement with the tiles
  69959. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69960. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69961. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69962. * @param name defines the name of the mesh
  69963. * @param options defines the options used to create the mesh
  69964. * @param scene defines the hosting scene
  69965. * @returns the plane mesh
  69966. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69967. */
  69968. static CreateTiledPlane(name: string, options: {
  69969. pattern?: number;
  69970. tileSize?: number;
  69971. tileWidth?: number;
  69972. tileHeight?: number;
  69973. size?: number;
  69974. width?: number;
  69975. height?: number;
  69976. alignHorizontal?: number;
  69977. alignVertical?: number;
  69978. sideOrientation?: number;
  69979. frontUVs?: Vector4;
  69980. backUVs?: Vector4;
  69981. updatable?: boolean;
  69982. }, scene?: Nullable<Scene>): Mesh;
  69983. /**
  69984. * Creates a plane mesh
  69985. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  69986. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  69987. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  69988. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  69989. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  69990. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  69991. * @param name defines the name of the mesh
  69992. * @param options defines the options used to create the mesh
  69993. * @param scene defines the hosting scene
  69994. * @returns the plane mesh
  69995. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  69996. */
  69997. static CreatePlane(name: string, options: {
  69998. size?: number;
  69999. width?: number;
  70000. height?: number;
  70001. sideOrientation?: number;
  70002. frontUVs?: Vector4;
  70003. backUVs?: Vector4;
  70004. updatable?: boolean;
  70005. sourcePlane?: Plane;
  70006. }, scene?: Nullable<Scene>): Mesh;
  70007. /**
  70008. * Creates a ground mesh
  70009. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  70010. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  70011. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70012. * @param name defines the name of the mesh
  70013. * @param options defines the options used to create the mesh
  70014. * @param scene defines the hosting scene
  70015. * @returns the ground mesh
  70016. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  70017. */
  70018. static CreateGround(name: string, options: {
  70019. width?: number;
  70020. height?: number;
  70021. subdivisions?: number;
  70022. subdivisionsX?: number;
  70023. subdivisionsY?: number;
  70024. updatable?: boolean;
  70025. }, scene?: Nullable<Scene>): Mesh;
  70026. /**
  70027. * Creates a tiled ground mesh
  70028. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  70029. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  70030. * * 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
  70031. * * 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
  70032. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70033. * @param name defines the name of the mesh
  70034. * @param options defines the options used to create the mesh
  70035. * @param scene defines the hosting scene
  70036. * @returns the tiled ground mesh
  70037. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  70038. */
  70039. static CreateTiledGround(name: string, options: {
  70040. xmin: number;
  70041. zmin: number;
  70042. xmax: number;
  70043. zmax: number;
  70044. subdivisions?: {
  70045. w: number;
  70046. h: number;
  70047. };
  70048. precision?: {
  70049. w: number;
  70050. h: number;
  70051. };
  70052. updatable?: boolean;
  70053. }, scene?: Nullable<Scene>): Mesh;
  70054. /**
  70055. * Creates a ground mesh from a height map
  70056. * * The parameter `url` sets the URL of the height map image resource.
  70057. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  70058. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  70059. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  70060. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  70061. * * 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.
  70062. * * 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).
  70063. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  70064. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  70065. * @param name defines the name of the mesh
  70066. * @param url defines the url to the height map
  70067. * @param options defines the options used to create the mesh
  70068. * @param scene defines the hosting scene
  70069. * @returns the ground mesh
  70070. * @see https://doc.babylonjs.com/babylon101/height_map
  70071. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  70072. */
  70073. static CreateGroundFromHeightMap(name: string, url: string, options: {
  70074. width?: number;
  70075. height?: number;
  70076. subdivisions?: number;
  70077. minHeight?: number;
  70078. maxHeight?: number;
  70079. colorFilter?: Color3;
  70080. alphaFilter?: number;
  70081. updatable?: boolean;
  70082. onReady?: (mesh: GroundMesh) => void;
  70083. }, scene?: Nullable<Scene>): GroundMesh;
  70084. /**
  70085. * Creates a polygon mesh
  70086. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  70087. * * 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
  70088. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  70089. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70090. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  70091. * * Remember you can only change the shape positions, not their number when updating a polygon
  70092. * @param name defines the name of the mesh
  70093. * @param options defines the options used to create the mesh
  70094. * @param scene defines the hosting scene
  70095. * @param earcutInjection can be used to inject your own earcut reference
  70096. * @returns the polygon mesh
  70097. */
  70098. static CreatePolygon(name: string, options: {
  70099. shape: Vector3[];
  70100. holes?: Vector3[][];
  70101. depth?: number;
  70102. faceUV?: Vector4[];
  70103. faceColors?: Color4[];
  70104. updatable?: boolean;
  70105. sideOrientation?: number;
  70106. frontUVs?: Vector4;
  70107. backUVs?: Vector4;
  70108. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70109. /**
  70110. * Creates an extruded polygon mesh, with depth in the Y direction.
  70111. * * 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)
  70112. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  70113. * @param name defines the name of the mesh
  70114. * @param options defines the options used to create the mesh
  70115. * @param scene defines the hosting scene
  70116. * @param earcutInjection can be used to inject your own earcut reference
  70117. * @returns the polygon mesh
  70118. */
  70119. static ExtrudePolygon(name: string, options: {
  70120. shape: Vector3[];
  70121. holes?: Vector3[][];
  70122. depth?: number;
  70123. faceUV?: Vector4[];
  70124. faceColors?: Color4[];
  70125. updatable?: boolean;
  70126. sideOrientation?: number;
  70127. frontUVs?: Vector4;
  70128. backUVs?: Vector4;
  70129. wrap?: boolean;
  70130. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  70131. /**
  70132. * Creates a tube mesh.
  70133. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  70134. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  70135. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  70136. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  70137. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  70138. * * 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)
  70139. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  70140. * * 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
  70141. * * 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
  70142. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70143. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70144. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  70145. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70146. * @param name defines the name of the mesh
  70147. * @param options defines the options used to create the mesh
  70148. * @param scene defines the hosting scene
  70149. * @returns the tube mesh
  70150. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  70151. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  70152. */
  70153. static CreateTube(name: string, options: {
  70154. path: Vector3[];
  70155. radius?: number;
  70156. tessellation?: number;
  70157. radiusFunction?: {
  70158. (i: number, distance: number): number;
  70159. };
  70160. cap?: number;
  70161. arc?: number;
  70162. updatable?: boolean;
  70163. sideOrientation?: number;
  70164. frontUVs?: Vector4;
  70165. backUVs?: Vector4;
  70166. instance?: Mesh;
  70167. invertUV?: boolean;
  70168. }, scene?: Nullable<Scene>): Mesh;
  70169. /**
  70170. * Creates a polyhedron mesh
  70171. * * 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
  70172. * * The parameter `size` (positive float, default 1) sets the polygon size
  70173. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  70174. * * 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`
  70175. * * 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
  70176. * * 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)`)
  70177. * * 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
  70178. * * 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
  70179. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  70180. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  70181. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  70182. * @param name defines the name of the mesh
  70183. * @param options defines the options used to create the mesh
  70184. * @param scene defines the hosting scene
  70185. * @returns the polyhedron mesh
  70186. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  70187. */
  70188. static CreatePolyhedron(name: string, options: {
  70189. type?: number;
  70190. size?: number;
  70191. sizeX?: number;
  70192. sizeY?: number;
  70193. sizeZ?: number;
  70194. custom?: any;
  70195. faceUV?: Vector4[];
  70196. faceColors?: Color4[];
  70197. flat?: boolean;
  70198. updatable?: boolean;
  70199. sideOrientation?: number;
  70200. frontUVs?: Vector4;
  70201. backUVs?: Vector4;
  70202. }, scene?: Nullable<Scene>): Mesh;
  70203. /**
  70204. * Creates a decal mesh.
  70205. * 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
  70206. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  70207. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  70208. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  70209. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  70210. * @param name defines the name of the mesh
  70211. * @param sourceMesh defines the mesh where the decal must be applied
  70212. * @param options defines the options used to create the mesh
  70213. * @param scene defines the hosting scene
  70214. * @returns the decal mesh
  70215. * @see https://doc.babylonjs.com/how_to/decals
  70216. */
  70217. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  70218. position?: Vector3;
  70219. normal?: Vector3;
  70220. size?: Vector3;
  70221. angle?: number;
  70222. }): Mesh;
  70223. /**
  70224. * Creates a Capsule Mesh
  70225. * @param name defines the name of the mesh.
  70226. * @param options the constructors options used to shape the mesh.
  70227. * @param scene defines the scene the mesh is scoped to.
  70228. * @returns the capsule mesh
  70229. * @see https://doc.babylonjs.com/how_to/capsule_shape
  70230. */
  70231. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  70232. }
  70233. }
  70234. declare module "babylonjs/Meshes/meshSimplification" {
  70235. import { Mesh } from "babylonjs/Meshes/mesh";
  70236. /**
  70237. * A simplifier interface for future simplification implementations
  70238. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70239. */
  70240. export interface ISimplifier {
  70241. /**
  70242. * Simplification of a given mesh according to the given settings.
  70243. * Since this requires computation, it is assumed that the function runs async.
  70244. * @param settings The settings of the simplification, including quality and distance
  70245. * @param successCallback A callback that will be called after the mesh was simplified.
  70246. * @param errorCallback in case of an error, this callback will be called. optional.
  70247. */
  70248. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  70249. }
  70250. /**
  70251. * Expected simplification settings.
  70252. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  70253. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70254. */
  70255. export interface ISimplificationSettings {
  70256. /**
  70257. * Gets or sets the expected quality
  70258. */
  70259. quality: number;
  70260. /**
  70261. * Gets or sets the distance when this optimized version should be used
  70262. */
  70263. distance: number;
  70264. /**
  70265. * Gets an already optimized mesh
  70266. */
  70267. optimizeMesh?: boolean;
  70268. }
  70269. /**
  70270. * Class used to specify simplification options
  70271. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70272. */
  70273. export class SimplificationSettings implements ISimplificationSettings {
  70274. /** expected quality */
  70275. quality: number;
  70276. /** distance when this optimized version should be used */
  70277. distance: number;
  70278. /** already optimized mesh */
  70279. optimizeMesh?: boolean | undefined;
  70280. /**
  70281. * Creates a SimplificationSettings
  70282. * @param quality expected quality
  70283. * @param distance distance when this optimized version should be used
  70284. * @param optimizeMesh already optimized mesh
  70285. */
  70286. constructor(
  70287. /** expected quality */
  70288. quality: number,
  70289. /** distance when this optimized version should be used */
  70290. distance: number,
  70291. /** already optimized mesh */
  70292. optimizeMesh?: boolean | undefined);
  70293. }
  70294. /**
  70295. * Interface used to define a simplification task
  70296. */
  70297. export interface ISimplificationTask {
  70298. /**
  70299. * Array of settings
  70300. */
  70301. settings: Array<ISimplificationSettings>;
  70302. /**
  70303. * Simplification type
  70304. */
  70305. simplificationType: SimplificationType;
  70306. /**
  70307. * Mesh to simplify
  70308. */
  70309. mesh: Mesh;
  70310. /**
  70311. * Callback called on success
  70312. */
  70313. successCallback?: () => void;
  70314. /**
  70315. * Defines if parallel processing can be used
  70316. */
  70317. parallelProcessing: boolean;
  70318. }
  70319. /**
  70320. * Queue used to order the simplification tasks
  70321. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70322. */
  70323. export class SimplificationQueue {
  70324. private _simplificationArray;
  70325. /**
  70326. * Gets a boolean indicating that the process is still running
  70327. */
  70328. running: boolean;
  70329. /**
  70330. * Creates a new queue
  70331. */
  70332. constructor();
  70333. /**
  70334. * Adds a new simplification task
  70335. * @param task defines a task to add
  70336. */
  70337. addTask(task: ISimplificationTask): void;
  70338. /**
  70339. * Execute next task
  70340. */
  70341. executeNext(): void;
  70342. /**
  70343. * Execute a simplification task
  70344. * @param task defines the task to run
  70345. */
  70346. runSimplification(task: ISimplificationTask): void;
  70347. private getSimplifier;
  70348. }
  70349. /**
  70350. * The implemented types of simplification
  70351. * At the moment only Quadratic Error Decimation is implemented
  70352. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70353. */
  70354. export enum SimplificationType {
  70355. /** Quadratic error decimation */
  70356. QUADRATIC = 0
  70357. }
  70358. /**
  70359. * An implementation of the Quadratic Error simplification algorithm.
  70360. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  70361. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  70362. * @author RaananW
  70363. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70364. */
  70365. export class QuadraticErrorSimplification implements ISimplifier {
  70366. private _mesh;
  70367. private triangles;
  70368. private vertices;
  70369. private references;
  70370. private _reconstructedMesh;
  70371. /** Gets or sets the number pf sync interations */
  70372. syncIterations: number;
  70373. /** Gets or sets the aggressiveness of the simplifier */
  70374. aggressiveness: number;
  70375. /** Gets or sets the number of allowed iterations for decimation */
  70376. decimationIterations: number;
  70377. /** Gets or sets the espilon to use for bounding box computation */
  70378. boundingBoxEpsilon: number;
  70379. /**
  70380. * Creates a new QuadraticErrorSimplification
  70381. * @param _mesh defines the target mesh
  70382. */
  70383. constructor(_mesh: Mesh);
  70384. /**
  70385. * Simplification of a given mesh according to the given settings.
  70386. * Since this requires computation, it is assumed that the function runs async.
  70387. * @param settings The settings of the simplification, including quality and distance
  70388. * @param successCallback A callback that will be called after the mesh was simplified.
  70389. */
  70390. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  70391. private runDecimation;
  70392. private initWithMesh;
  70393. private init;
  70394. private reconstructMesh;
  70395. private initDecimatedMesh;
  70396. private isFlipped;
  70397. private updateTriangles;
  70398. private identifyBorder;
  70399. private updateMesh;
  70400. private vertexError;
  70401. private calculateError;
  70402. }
  70403. }
  70404. declare module "babylonjs/Meshes/meshSimplificationSceneComponent" {
  70405. import { Scene } from "babylonjs/scene";
  70406. import { SimplificationQueue, ISimplificationSettings, SimplificationType } from "babylonjs/Meshes/meshSimplification";
  70407. import { ISceneComponent } from "babylonjs/sceneComponent";
  70408. module "babylonjs/scene" {
  70409. interface Scene {
  70410. /** @hidden (Backing field) */
  70411. _simplificationQueue: SimplificationQueue;
  70412. /**
  70413. * Gets or sets the simplification queue attached to the scene
  70414. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  70415. */
  70416. simplificationQueue: SimplificationQueue;
  70417. }
  70418. }
  70419. module "babylonjs/Meshes/mesh" {
  70420. interface Mesh {
  70421. /**
  70422. * Simplify the mesh according to the given array of settings.
  70423. * Function will return immediately and will simplify async
  70424. * @param settings a collection of simplification settings
  70425. * @param parallelProcessing should all levels calculate parallel or one after the other
  70426. * @param simplificationType the type of simplification to run
  70427. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  70428. * @returns the current mesh
  70429. */
  70430. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  70431. }
  70432. }
  70433. /**
  70434. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  70435. * created in a scene
  70436. */
  70437. export class SimplicationQueueSceneComponent implements ISceneComponent {
  70438. /**
  70439. * The component name helpfull to identify the component in the list of scene components.
  70440. */
  70441. readonly name: string;
  70442. /**
  70443. * The scene the component belongs to.
  70444. */
  70445. scene: Scene;
  70446. /**
  70447. * Creates a new instance of the component for the given scene
  70448. * @param scene Defines the scene to register the component in
  70449. */
  70450. constructor(scene: Scene);
  70451. /**
  70452. * Registers the component in a given scene
  70453. */
  70454. register(): void;
  70455. /**
  70456. * Rebuilds the elements related to this component in case of
  70457. * context lost for instance.
  70458. */
  70459. rebuild(): void;
  70460. /**
  70461. * Disposes the component and the associated ressources
  70462. */
  70463. dispose(): void;
  70464. private _beforeCameraUpdate;
  70465. }
  70466. }
  70467. declare module "babylonjs/Meshes/Builders/index" {
  70468. export * from "babylonjs/Meshes/Builders/boxBuilder";
  70469. export * from "babylonjs/Meshes/Builders/tiledBoxBuilder";
  70470. export * from "babylonjs/Meshes/Builders/discBuilder";
  70471. export * from "babylonjs/Meshes/Builders/ribbonBuilder";
  70472. export * from "babylonjs/Meshes/Builders/sphereBuilder";
  70473. export * from "babylonjs/Meshes/Builders/hemisphereBuilder";
  70474. export * from "babylonjs/Meshes/Builders/cylinderBuilder";
  70475. export * from "babylonjs/Meshes/Builders/torusBuilder";
  70476. export * from "babylonjs/Meshes/Builders/torusKnotBuilder";
  70477. export * from "babylonjs/Meshes/Builders/linesBuilder";
  70478. export * from "babylonjs/Meshes/Builders/polygonBuilder";
  70479. export * from "babylonjs/Meshes/Builders/shapeBuilder";
  70480. export * from "babylonjs/Meshes/Builders/latheBuilder";
  70481. export * from "babylonjs/Meshes/Builders/planeBuilder";
  70482. export * from "babylonjs/Meshes/Builders/tiledPlaneBuilder";
  70483. export * from "babylonjs/Meshes/Builders/groundBuilder";
  70484. export * from "babylonjs/Meshes/Builders/tubeBuilder";
  70485. export * from "babylonjs/Meshes/Builders/polyhedronBuilder";
  70486. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70487. export * from "babylonjs/Meshes/Builders/decalBuilder";
  70488. export * from "babylonjs/Meshes/Builders/icoSphereBuilder";
  70489. export * from "babylonjs/Meshes/Builders/capsuleBuilder";
  70490. }
  70491. declare module "babylonjs/Meshes/thinInstanceMesh" {
  70492. import { Nullable, DeepImmutableObject } from "babylonjs/types";
  70493. import { VertexBuffer } from "babylonjs/Meshes/buffer";
  70494. import { Matrix } from "babylonjs/Maths/math.vector";
  70495. module "babylonjs/Meshes/mesh" {
  70496. interface Mesh {
  70497. /**
  70498. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  70499. */
  70500. thinInstanceEnablePicking: boolean;
  70501. /**
  70502. * Creates a new thin instance
  70503. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  70504. * @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
  70505. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  70506. */
  70507. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  70508. /**
  70509. * Adds the transformation (matrix) of the current mesh as a thin instance
  70510. * @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
  70511. * @returns the thin instance index number
  70512. */
  70513. thinInstanceAddSelf(refresh: boolean): number;
  70514. /**
  70515. * Registers a custom attribute to be used with thin instances
  70516. * @param kind name of the attribute
  70517. * @param stride size in floats of the attribute
  70518. */
  70519. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  70520. /**
  70521. * Sets the matrix of a thin instance
  70522. * @param index index of the thin instance
  70523. * @param matrix matrix to set
  70524. * @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
  70525. */
  70526. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  70527. /**
  70528. * Sets the value of a custom attribute for a thin instance
  70529. * @param kind name of the attribute
  70530. * @param index index of the thin instance
  70531. * @param value value to set
  70532. * @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
  70533. */
  70534. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  70535. /**
  70536. * 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.
  70537. */
  70538. thinInstanceCount: number;
  70539. /**
  70540. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  70541. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  70542. * @param buffer buffer to set
  70543. * @param stride size in floats of each value of the buffer
  70544. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  70545. */
  70546. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  70547. /**
  70548. * Gets the list of world matrices
  70549. * @return an array containing all the world matrices from the thin instances
  70550. */
  70551. thinInstanceGetWorldMatrices(): Matrix[];
  70552. /**
  70553. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  70554. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70555. */
  70556. thinInstanceBufferUpdated(kind: string): void;
  70557. /**
  70558. * Applies a partial update to a buffer directly on the GPU
  70559. * 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
  70560. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  70561. * @param data the data to set in the GPU buffer
  70562. * @param offset the offset in the GPU buffer where to update the data
  70563. */
  70564. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  70565. /**
  70566. * Refreshes the bounding info, taking into account all the thin instances defined
  70567. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  70568. */
  70569. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  70570. /** @hidden */
  70571. _thinInstanceInitializeUserStorage(): void;
  70572. /** @hidden */
  70573. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  70574. /** @hidden */
  70575. _userThinInstanceBuffersStorage: {
  70576. data: {
  70577. [key: string]: Float32Array;
  70578. };
  70579. sizes: {
  70580. [key: string]: number;
  70581. };
  70582. vertexBuffers: {
  70583. [key: string]: Nullable<VertexBuffer>;
  70584. };
  70585. strides: {
  70586. [key: string]: number;
  70587. };
  70588. };
  70589. }
  70590. }
  70591. }
  70592. declare module "babylonjs/Meshes/index" {
  70593. export * from "babylonjs/Meshes/abstractMesh";
  70594. export * from "babylonjs/Meshes/buffer";
  70595. export * from "babylonjs/Meshes/Compression/index";
  70596. export * from "babylonjs/Meshes/csg";
  70597. export * from "babylonjs/Meshes/geometry";
  70598. export * from "babylonjs/Meshes/groundMesh";
  70599. export * from "babylonjs/Meshes/trailMesh";
  70600. export * from "babylonjs/Meshes/instancedMesh";
  70601. export * from "babylonjs/Meshes/linesMesh";
  70602. export * from "babylonjs/Meshes/mesh";
  70603. export * from "babylonjs/Meshes/mesh.vertexData";
  70604. export * from "babylonjs/Meshes/meshBuilder";
  70605. export * from "babylonjs/Meshes/meshSimplification";
  70606. export * from "babylonjs/Meshes/meshSimplificationSceneComponent";
  70607. export * from "babylonjs/Meshes/polygonMesh";
  70608. export * from "babylonjs/Meshes/subMesh";
  70609. export * from "babylonjs/Meshes/meshLODLevel";
  70610. export * from "babylonjs/Meshes/transformNode";
  70611. export * from "babylonjs/Meshes/Builders/index";
  70612. export * from "babylonjs/Meshes/dataBuffer";
  70613. export * from "babylonjs/Meshes/WebGL/webGLDataBuffer";
  70614. import "babylonjs/Meshes/thinInstanceMesh";
  70615. export * from "babylonjs/Meshes/thinInstanceMesh";
  70616. }
  70617. declare module "babylonjs/Morph/index" {
  70618. export * from "babylonjs/Morph/morphTarget";
  70619. export * from "babylonjs/Morph/morphTargetManager";
  70620. }
  70621. declare module "babylonjs/Navigation/INavigationEngine" {
  70622. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70623. import { Vector3 } from "babylonjs/Maths/math";
  70624. import { Mesh } from "babylonjs/Meshes/mesh";
  70625. import { Scene } from "babylonjs/scene";
  70626. /**
  70627. * Navigation plugin interface to add navigation constrained by a navigation mesh
  70628. */
  70629. export interface INavigationEnginePlugin {
  70630. /**
  70631. * plugin name
  70632. */
  70633. name: string;
  70634. /**
  70635. * Creates a navigation mesh
  70636. * @param meshes array of all the geometry used to compute the navigatio mesh
  70637. * @param parameters bunch of parameters used to filter geometry
  70638. */
  70639. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70640. /**
  70641. * Create a navigation mesh debug mesh
  70642. * @param scene is where the mesh will be added
  70643. * @returns debug display mesh
  70644. */
  70645. createDebugNavMesh(scene: Scene): Mesh;
  70646. /**
  70647. * Get a navigation mesh constrained position, closest to the parameter position
  70648. * @param position world position
  70649. * @returns the closest point to position constrained by the navigation mesh
  70650. */
  70651. getClosestPoint(position: Vector3): Vector3;
  70652. /**
  70653. * Get a navigation mesh constrained position, closest to the parameter position
  70654. * @param position world position
  70655. * @param result output the closest point to position constrained by the navigation mesh
  70656. */
  70657. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70658. /**
  70659. * Get a navigation mesh constrained position, within a particular radius
  70660. * @param position world position
  70661. * @param maxRadius the maximum distance to the constrained world position
  70662. * @returns the closest point to position constrained by the navigation mesh
  70663. */
  70664. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70665. /**
  70666. * Get a navigation mesh constrained position, within a particular radius
  70667. * @param position world position
  70668. * @param maxRadius the maximum distance to the constrained world position
  70669. * @param result output the closest point to position constrained by the navigation mesh
  70670. */
  70671. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70672. /**
  70673. * Compute the final position from a segment made of destination-position
  70674. * @param position world position
  70675. * @param destination world position
  70676. * @returns the resulting point along the navmesh
  70677. */
  70678. moveAlong(position: Vector3, destination: Vector3): Vector3;
  70679. /**
  70680. * Compute the final position from a segment made of destination-position
  70681. * @param position world position
  70682. * @param destination world position
  70683. * @param result output the resulting point along the navmesh
  70684. */
  70685. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  70686. /**
  70687. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  70688. * @param start world position
  70689. * @param end world position
  70690. * @returns array containing world position composing the path
  70691. */
  70692. computePath(start: Vector3, end: Vector3): Vector3[];
  70693. /**
  70694. * If this plugin is supported
  70695. * @returns true if plugin is supported
  70696. */
  70697. isSupported(): boolean;
  70698. /**
  70699. * Create a new Crowd so you can add agents
  70700. * @param maxAgents the maximum agent count in the crowd
  70701. * @param maxAgentRadius the maximum radius an agent can have
  70702. * @param scene to attach the crowd to
  70703. * @returns the crowd you can add agents to
  70704. */
  70705. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  70706. /**
  70707. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70708. * The queries will try to find a solution within those bounds
  70709. * default is (1,1,1)
  70710. * @param extent x,y,z value that define the extent around the queries point of reference
  70711. */
  70712. setDefaultQueryExtent(extent: Vector3): void;
  70713. /**
  70714. * Get the Bounding box extent specified by setDefaultQueryExtent
  70715. * @returns the box extent values
  70716. */
  70717. getDefaultQueryExtent(): Vector3;
  70718. /**
  70719. * build the navmesh from a previously saved state using getNavmeshData
  70720. * @param data the Uint8Array returned by getNavmeshData
  70721. */
  70722. buildFromNavmeshData(data: Uint8Array): void;
  70723. /**
  70724. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  70725. * @returns data the Uint8Array that can be saved and reused
  70726. */
  70727. getNavmeshData(): Uint8Array;
  70728. /**
  70729. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70730. * @param result output the box extent values
  70731. */
  70732. getDefaultQueryExtentToRef(result: Vector3): void;
  70733. /**
  70734. * Release all resources
  70735. */
  70736. dispose(): void;
  70737. }
  70738. /**
  70739. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  70740. */
  70741. export interface ICrowd {
  70742. /**
  70743. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  70744. * You can attach anything to that node. The node position is updated in the scene update tick.
  70745. * @param pos world position that will be constrained by the navigation mesh
  70746. * @param parameters agent parameters
  70747. * @param transform hooked to the agent that will be update by the scene
  70748. * @returns agent index
  70749. */
  70750. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  70751. /**
  70752. * Returns the agent position in world space
  70753. * @param index agent index returned by addAgent
  70754. * @returns world space position
  70755. */
  70756. getAgentPosition(index: number): Vector3;
  70757. /**
  70758. * Gets the agent position result in world space
  70759. * @param index agent index returned by addAgent
  70760. * @param result output world space position
  70761. */
  70762. getAgentPositionToRef(index: number, result: Vector3): void;
  70763. /**
  70764. * Gets the agent velocity in world space
  70765. * @param index agent index returned by addAgent
  70766. * @returns world space velocity
  70767. */
  70768. getAgentVelocity(index: number): Vector3;
  70769. /**
  70770. * Gets the agent velocity result in world space
  70771. * @param index agent index returned by addAgent
  70772. * @param result output world space velocity
  70773. */
  70774. getAgentVelocityToRef(index: number, result: Vector3): void;
  70775. /**
  70776. * remove a particular agent previously created
  70777. * @param index agent index returned by addAgent
  70778. */
  70779. removeAgent(index: number): void;
  70780. /**
  70781. * get the list of all agents attached to this crowd
  70782. * @returns list of agent indices
  70783. */
  70784. getAgents(): number[];
  70785. /**
  70786. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  70787. * @param deltaTime in seconds
  70788. */
  70789. update(deltaTime: number): void;
  70790. /**
  70791. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  70792. * @param index agent index returned by addAgent
  70793. * @param destination targeted world position
  70794. */
  70795. agentGoto(index: number, destination: Vector3): void;
  70796. /**
  70797. * Teleport the agent to a new position
  70798. * @param index agent index returned by addAgent
  70799. * @param destination targeted world position
  70800. */
  70801. agentTeleport(index: number, destination: Vector3): void;
  70802. /**
  70803. * Update agent parameters
  70804. * @param index agent index returned by addAgent
  70805. * @param parameters agent parameters
  70806. */
  70807. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  70808. /**
  70809. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  70810. * The queries will try to find a solution within those bounds
  70811. * default is (1,1,1)
  70812. * @param extent x,y,z value that define the extent around the queries point of reference
  70813. */
  70814. setDefaultQueryExtent(extent: Vector3): void;
  70815. /**
  70816. * Get the Bounding box extent specified by setDefaultQueryExtent
  70817. * @returns the box extent values
  70818. */
  70819. getDefaultQueryExtent(): Vector3;
  70820. /**
  70821. * Get the Bounding box extent result specified by setDefaultQueryExtent
  70822. * @param result output the box extent values
  70823. */
  70824. getDefaultQueryExtentToRef(result: Vector3): void;
  70825. /**
  70826. * Release all resources
  70827. */
  70828. dispose(): void;
  70829. }
  70830. /**
  70831. * Configures an agent
  70832. */
  70833. export interface IAgentParameters {
  70834. /**
  70835. * Agent radius. [Limit: >= 0]
  70836. */
  70837. radius: number;
  70838. /**
  70839. * Agent height. [Limit: > 0]
  70840. */
  70841. height: number;
  70842. /**
  70843. * Maximum allowed acceleration. [Limit: >= 0]
  70844. */
  70845. maxAcceleration: number;
  70846. /**
  70847. * Maximum allowed speed. [Limit: >= 0]
  70848. */
  70849. maxSpeed: number;
  70850. /**
  70851. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  70852. */
  70853. collisionQueryRange: number;
  70854. /**
  70855. * The path visibility optimization range. [Limit: > 0]
  70856. */
  70857. pathOptimizationRange: number;
  70858. /**
  70859. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  70860. */
  70861. separationWeight: number;
  70862. }
  70863. /**
  70864. * Configures the navigation mesh creation
  70865. */
  70866. export interface INavMeshParameters {
  70867. /**
  70868. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  70869. */
  70870. cs: number;
  70871. /**
  70872. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  70873. */
  70874. ch: number;
  70875. /**
  70876. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  70877. */
  70878. walkableSlopeAngle: number;
  70879. /**
  70880. * Minimum floor to 'ceiling' height that will still allow the floor area to
  70881. * be considered walkable. [Limit: >= 3] [Units: vx]
  70882. */
  70883. walkableHeight: number;
  70884. /**
  70885. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  70886. */
  70887. walkableClimb: number;
  70888. /**
  70889. * The distance to erode/shrink the walkable area of the heightfield away from
  70890. * obstructions. [Limit: >=0] [Units: vx]
  70891. */
  70892. walkableRadius: number;
  70893. /**
  70894. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  70895. */
  70896. maxEdgeLen: number;
  70897. /**
  70898. * The maximum distance a simplfied contour's border edges should deviate
  70899. * the original raw contour. [Limit: >=0] [Units: vx]
  70900. */
  70901. maxSimplificationError: number;
  70902. /**
  70903. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  70904. */
  70905. minRegionArea: number;
  70906. /**
  70907. * Any regions with a span count smaller than this value will, if possible,
  70908. * be merged with larger regions. [Limit: >=0] [Units: vx]
  70909. */
  70910. mergeRegionArea: number;
  70911. /**
  70912. * The maximum number of vertices allowed for polygons generated during the
  70913. * contour to polygon conversion process. [Limit: >= 3]
  70914. */
  70915. maxVertsPerPoly: number;
  70916. /**
  70917. * Sets the sampling distance to use when generating the detail mesh.
  70918. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  70919. */
  70920. detailSampleDist: number;
  70921. /**
  70922. * The maximum distance the detail mesh surface should deviate from heightfield
  70923. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  70924. */
  70925. detailSampleMaxError: number;
  70926. }
  70927. }
  70928. declare module "babylonjs/Navigation/Plugins/recastJSPlugin" {
  70929. import { INavigationEnginePlugin, ICrowd, IAgentParameters, INavMeshParameters } from "babylonjs/Navigation/INavigationEngine";
  70930. import { Mesh } from "babylonjs/Meshes/mesh";
  70931. import { Scene } from "babylonjs/scene";
  70932. import { Vector3 } from "babylonjs/Maths/math";
  70933. import { TransformNode } from "babylonjs/Meshes/transformNode";
  70934. /**
  70935. * RecastJS navigation plugin
  70936. */
  70937. export class RecastJSPlugin implements INavigationEnginePlugin {
  70938. /**
  70939. * Reference to the Recast library
  70940. */
  70941. bjsRECAST: any;
  70942. /**
  70943. * plugin name
  70944. */
  70945. name: string;
  70946. /**
  70947. * the first navmesh created. We might extend this to support multiple navmeshes
  70948. */
  70949. navMesh: any;
  70950. /**
  70951. * Initializes the recastJS plugin
  70952. * @param recastInjection can be used to inject your own recast reference
  70953. */
  70954. constructor(recastInjection?: any);
  70955. /**
  70956. * Creates a navigation mesh
  70957. * @param meshes array of all the geometry used to compute the navigatio mesh
  70958. * @param parameters bunch of parameters used to filter geometry
  70959. */
  70960. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  70961. /**
  70962. * Create a navigation mesh debug mesh
  70963. * @param scene is where the mesh will be added
  70964. * @returns debug display mesh
  70965. */
  70966. createDebugNavMesh(scene: Scene): Mesh;
  70967. /**
  70968. * Get a navigation mesh constrained position, closest to the parameter position
  70969. * @param position world position
  70970. * @returns the closest point to position constrained by the navigation mesh
  70971. */
  70972. getClosestPoint(position: Vector3): Vector3;
  70973. /**
  70974. * Get a navigation mesh constrained position, closest to the parameter position
  70975. * @param position world position
  70976. * @param result output the closest point to position constrained by the navigation mesh
  70977. */
  70978. getClosestPointToRef(position: Vector3, result: Vector3): void;
  70979. /**
  70980. * Get a navigation mesh constrained position, within a particular radius
  70981. * @param position world position
  70982. * @param maxRadius the maximum distance to the constrained world position
  70983. * @returns the closest point to position constrained by the navigation mesh
  70984. */
  70985. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  70986. /**
  70987. * Get a navigation mesh constrained position, within a particular radius
  70988. * @param position world position
  70989. * @param maxRadius the maximum distance to the constrained world position
  70990. * @param result output the closest point to position constrained by the navigation mesh
  70991. */
  70992. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  70993. /**
  70994. * Compute the final position from a segment made of destination-position
  70995. * @param position world position
  70996. * @param destination world position
  70997. * @returns the resulting point along the navmesh
  70998. */
  70999. moveAlong(position: Vector3, destination: Vector3): Vector3;
  71000. /**
  71001. * Compute the final position from a segment made of destination-position
  71002. * @param position world position
  71003. * @param destination world position
  71004. * @param result output the resulting point along the navmesh
  71005. */
  71006. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  71007. /**
  71008. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  71009. * @param start world position
  71010. * @param end world position
  71011. * @returns array containing world position composing the path
  71012. */
  71013. computePath(start: Vector3, end: Vector3): Vector3[];
  71014. /**
  71015. * Create a new Crowd so you can add agents
  71016. * @param maxAgents the maximum agent count in the crowd
  71017. * @param maxAgentRadius the maximum radius an agent can have
  71018. * @param scene to attach the crowd to
  71019. * @returns the crowd you can add agents to
  71020. */
  71021. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  71022. /**
  71023. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71024. * The queries will try to find a solution within those bounds
  71025. * default is (1,1,1)
  71026. * @param extent x,y,z value that define the extent around the queries point of reference
  71027. */
  71028. setDefaultQueryExtent(extent: Vector3): void;
  71029. /**
  71030. * Get the Bounding box extent specified by setDefaultQueryExtent
  71031. * @returns the box extent values
  71032. */
  71033. getDefaultQueryExtent(): Vector3;
  71034. /**
  71035. * build the navmesh from a previously saved state using getNavmeshData
  71036. * @param data the Uint8Array returned by getNavmeshData
  71037. */
  71038. buildFromNavmeshData(data: Uint8Array): void;
  71039. /**
  71040. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  71041. * @returns data the Uint8Array that can be saved and reused
  71042. */
  71043. getNavmeshData(): Uint8Array;
  71044. /**
  71045. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71046. * @param result output the box extent values
  71047. */
  71048. getDefaultQueryExtentToRef(result: Vector3): void;
  71049. /**
  71050. * Disposes
  71051. */
  71052. dispose(): void;
  71053. /**
  71054. * If this plugin is supported
  71055. * @returns true if plugin is supported
  71056. */
  71057. isSupported(): boolean;
  71058. }
  71059. /**
  71060. * Recast detour crowd implementation
  71061. */
  71062. export class RecastJSCrowd implements ICrowd {
  71063. /**
  71064. * Recast/detour plugin
  71065. */
  71066. bjsRECASTPlugin: RecastJSPlugin;
  71067. /**
  71068. * Link to the detour crowd
  71069. */
  71070. recastCrowd: any;
  71071. /**
  71072. * One transform per agent
  71073. */
  71074. transforms: TransformNode[];
  71075. /**
  71076. * All agents created
  71077. */
  71078. agents: number[];
  71079. /**
  71080. * Link to the scene is kept to unregister the crowd from the scene
  71081. */
  71082. private _scene;
  71083. /**
  71084. * Observer for crowd updates
  71085. */
  71086. private _onBeforeAnimationsObserver;
  71087. /**
  71088. * Constructor
  71089. * @param plugin recastJS plugin
  71090. * @param maxAgents the maximum agent count in the crowd
  71091. * @param maxAgentRadius the maximum radius an agent can have
  71092. * @param scene to attach the crowd to
  71093. * @returns the crowd you can add agents to
  71094. */
  71095. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  71096. /**
  71097. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  71098. * You can attach anything to that node. The node position is updated in the scene update tick.
  71099. * @param pos world position that will be constrained by the navigation mesh
  71100. * @param parameters agent parameters
  71101. * @param transform hooked to the agent that will be update by the scene
  71102. * @returns agent index
  71103. */
  71104. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  71105. /**
  71106. * Returns the agent position in world space
  71107. * @param index agent index returned by addAgent
  71108. * @returns world space position
  71109. */
  71110. getAgentPosition(index: number): Vector3;
  71111. /**
  71112. * Returns the agent position result in world space
  71113. * @param index agent index returned by addAgent
  71114. * @param result output world space position
  71115. */
  71116. getAgentPositionToRef(index: number, result: Vector3): void;
  71117. /**
  71118. * Returns the agent velocity in world space
  71119. * @param index agent index returned by addAgent
  71120. * @returns world space velocity
  71121. */
  71122. getAgentVelocity(index: number): Vector3;
  71123. /**
  71124. * Returns the agent velocity result in world space
  71125. * @param index agent index returned by addAgent
  71126. * @param result output world space velocity
  71127. */
  71128. getAgentVelocityToRef(index: number, result: Vector3): void;
  71129. /**
  71130. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  71131. * @param index agent index returned by addAgent
  71132. * @param destination targeted world position
  71133. */
  71134. agentGoto(index: number, destination: Vector3): void;
  71135. /**
  71136. * Teleport the agent to a new position
  71137. * @param index agent index returned by addAgent
  71138. * @param destination targeted world position
  71139. */
  71140. agentTeleport(index: number, destination: Vector3): void;
  71141. /**
  71142. * Update agent parameters
  71143. * @param index agent index returned by addAgent
  71144. * @param parameters agent parameters
  71145. */
  71146. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  71147. /**
  71148. * remove a particular agent previously created
  71149. * @param index agent index returned by addAgent
  71150. */
  71151. removeAgent(index: number): void;
  71152. /**
  71153. * get the list of all agents attached to this crowd
  71154. * @returns list of agent indices
  71155. */
  71156. getAgents(): number[];
  71157. /**
  71158. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  71159. * @param deltaTime in seconds
  71160. */
  71161. update(deltaTime: number): void;
  71162. /**
  71163. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  71164. * The queries will try to find a solution within those bounds
  71165. * default is (1,1,1)
  71166. * @param extent x,y,z value that define the extent around the queries point of reference
  71167. */
  71168. setDefaultQueryExtent(extent: Vector3): void;
  71169. /**
  71170. * Get the Bounding box extent specified by setDefaultQueryExtent
  71171. * @returns the box extent values
  71172. */
  71173. getDefaultQueryExtent(): Vector3;
  71174. /**
  71175. * Get the Bounding box extent result specified by setDefaultQueryExtent
  71176. * @param result output the box extent values
  71177. */
  71178. getDefaultQueryExtentToRef(result: Vector3): void;
  71179. /**
  71180. * Release all resources
  71181. */
  71182. dispose(): void;
  71183. }
  71184. }
  71185. declare module "babylonjs/Navigation/Plugins/index" {
  71186. export * from "babylonjs/Navigation/Plugins/recastJSPlugin";
  71187. }
  71188. declare module "babylonjs/Navigation/index" {
  71189. export * from "babylonjs/Navigation/INavigationEngine";
  71190. export * from "babylonjs/Navigation/Plugins/index";
  71191. }
  71192. declare module "babylonjs/Offline/database" {
  71193. import { IOfflineProvider } from "babylonjs/Offline/IOfflineProvider";
  71194. /**
  71195. * Class used to enable access to IndexedDB
  71196. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  71197. */
  71198. export class Database implements IOfflineProvider {
  71199. private _callbackManifestChecked;
  71200. private _currentSceneUrl;
  71201. private _db;
  71202. private _enableSceneOffline;
  71203. private _enableTexturesOffline;
  71204. private _manifestVersionFound;
  71205. private _mustUpdateRessources;
  71206. private _hasReachedQuota;
  71207. private _isSupported;
  71208. private _idbFactory;
  71209. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  71210. private static IsUASupportingBlobStorage;
  71211. /**
  71212. * Gets a boolean indicating if Database storate is enabled (off by default)
  71213. */
  71214. static IDBStorageEnabled: boolean;
  71215. /**
  71216. * Gets a boolean indicating if scene must be saved in the database
  71217. */
  71218. get enableSceneOffline(): boolean;
  71219. /**
  71220. * Gets a boolean indicating if textures must be saved in the database
  71221. */
  71222. get enableTexturesOffline(): boolean;
  71223. /**
  71224. * Creates a new Database
  71225. * @param urlToScene defines the url to load the scene
  71226. * @param callbackManifestChecked defines the callback to use when manifest is checked
  71227. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  71228. */
  71229. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  71230. private static _ParseURL;
  71231. private static _ReturnFullUrlLocation;
  71232. private _checkManifestFile;
  71233. /**
  71234. * Open the database and make it available
  71235. * @param successCallback defines the callback to call on success
  71236. * @param errorCallback defines the callback to call on error
  71237. */
  71238. open(successCallback: () => void, errorCallback: () => void): void;
  71239. /**
  71240. * Loads an image from the database
  71241. * @param url defines the url to load from
  71242. * @param image defines the target DOM image
  71243. */
  71244. loadImage(url: string, image: HTMLImageElement): void;
  71245. private _loadImageFromDBAsync;
  71246. private _saveImageIntoDBAsync;
  71247. private _checkVersionFromDB;
  71248. private _loadVersionFromDBAsync;
  71249. private _saveVersionIntoDBAsync;
  71250. /**
  71251. * Loads a file from database
  71252. * @param url defines the URL to load from
  71253. * @param sceneLoaded defines a callback to call on success
  71254. * @param progressCallBack defines a callback to call when progress changed
  71255. * @param errorCallback defines a callback to call on error
  71256. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  71257. */
  71258. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  71259. private _loadFileAsync;
  71260. private _saveFileAsync;
  71261. /**
  71262. * Validates if xhr data is correct
  71263. * @param xhr defines the request to validate
  71264. * @param dataType defines the expected data type
  71265. * @returns true if data is correct
  71266. */
  71267. private static _ValidateXHRData;
  71268. }
  71269. }
  71270. declare module "babylonjs/Offline/index" {
  71271. export * from "babylonjs/Offline/database";
  71272. export * from "babylonjs/Offline/IOfflineProvider";
  71273. }
  71274. declare module "babylonjs/Shaders/gpuUpdateParticles.fragment" {
  71275. /** @hidden */
  71276. export var gpuUpdateParticlesPixelShader: {
  71277. name: string;
  71278. shader: string;
  71279. };
  71280. }
  71281. declare module "babylonjs/Shaders/gpuUpdateParticles.vertex" {
  71282. /** @hidden */
  71283. export var gpuUpdateParticlesVertexShader: {
  71284. name: string;
  71285. shader: string;
  71286. };
  71287. }
  71288. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2" {
  71289. /** @hidden */
  71290. export var clipPlaneFragmentDeclaration2: {
  71291. name: string;
  71292. shader: string;
  71293. };
  71294. }
  71295. declare module "babylonjs/Shaders/gpuRenderParticles.fragment" {
  71296. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragmentDeclaration2";
  71297. import "babylonjs/Shaders/ShadersInclude/imageProcessingDeclaration";
  71298. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  71299. import "babylonjs/Shaders/ShadersInclude/imageProcessingFunctions";
  71300. import "babylonjs/Shaders/ShadersInclude/clipPlaneFragment";
  71301. /** @hidden */
  71302. export var gpuRenderParticlesPixelShader: {
  71303. name: string;
  71304. shader: string;
  71305. };
  71306. }
  71307. declare module "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2" {
  71308. /** @hidden */
  71309. export var clipPlaneVertexDeclaration2: {
  71310. name: string;
  71311. shader: string;
  71312. };
  71313. }
  71314. declare module "babylonjs/Shaders/gpuRenderParticles.vertex" {
  71315. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertexDeclaration2";
  71316. import "babylonjs/Shaders/ShadersInclude/clipPlaneVertex";
  71317. /** @hidden */
  71318. export var gpuRenderParticlesVertexShader: {
  71319. name: string;
  71320. shader: string;
  71321. };
  71322. }
  71323. declare module "babylonjs/Particles/gpuParticleSystem" {
  71324. import { Nullable } from "babylonjs/types";
  71325. import { Color3Gradient, IValueGradient } from "babylonjs/Misc/gradients";
  71326. import { Observable } from "babylonjs/Misc/observable";
  71327. import { Matrix } from "babylonjs/Maths/math.vector";
  71328. import { Color4, Color3 } from "babylonjs/Maths/math.color";
  71329. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71330. import { BaseParticleSystem } from "babylonjs/Particles/baseParticleSystem";
  71331. import { IDisposable } from "babylonjs/scene";
  71332. import { Effect } from "babylonjs/Materials/effect";
  71333. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  71334. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  71335. import { ThinEngine } from "babylonjs/Engines/thinEngine";
  71336. import { Scene } from "babylonjs/scene";
  71337. import "babylonjs/Shaders/gpuUpdateParticles.fragment";
  71338. import "babylonjs/Shaders/gpuUpdateParticles.vertex";
  71339. import "babylonjs/Shaders/gpuRenderParticles.fragment";
  71340. import "babylonjs/Shaders/gpuRenderParticles.vertex";
  71341. /**
  71342. * This represents a GPU particle system in Babylon
  71343. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  71344. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  71345. */
  71346. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  71347. /**
  71348. * The layer mask we are rendering the particles through.
  71349. */
  71350. layerMask: number;
  71351. private _capacity;
  71352. private _activeCount;
  71353. private _currentActiveCount;
  71354. private _accumulatedCount;
  71355. private _renderEffect;
  71356. private _updateEffect;
  71357. private _buffer0;
  71358. private _buffer1;
  71359. private _spriteBuffer;
  71360. private _updateVAO;
  71361. private _renderVAO;
  71362. private _targetIndex;
  71363. private _sourceBuffer;
  71364. private _targetBuffer;
  71365. private _currentRenderId;
  71366. private _started;
  71367. private _stopped;
  71368. private _timeDelta;
  71369. private _randomTexture;
  71370. private _randomTexture2;
  71371. private _attributesStrideSize;
  71372. private _updateEffectOptions;
  71373. private _randomTextureSize;
  71374. private _actualFrame;
  71375. private _customEffect;
  71376. private readonly _rawTextureWidth;
  71377. /**
  71378. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  71379. */
  71380. static get IsSupported(): boolean;
  71381. /**
  71382. * An event triggered when the system is disposed.
  71383. */
  71384. onDisposeObservable: Observable<IParticleSystem>;
  71385. /**
  71386. * Gets the maximum number of particles active at the same time.
  71387. * @returns The max number of active particles.
  71388. */
  71389. getCapacity(): number;
  71390. /**
  71391. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  71392. * to override the particles.
  71393. */
  71394. forceDepthWrite: boolean;
  71395. /**
  71396. * Gets or set the number of active particles
  71397. */
  71398. get activeParticleCount(): number;
  71399. set activeParticleCount(value: number);
  71400. private _preWarmDone;
  71401. /**
  71402. * Specifies if the particles are updated in emitter local space or world space.
  71403. */
  71404. isLocal: boolean;
  71405. /** Gets or sets a matrix to use to compute projection */
  71406. defaultProjectionMatrix: Matrix;
  71407. /**
  71408. * Is this system ready to be used/rendered
  71409. * @return true if the system is ready
  71410. */
  71411. isReady(): boolean;
  71412. /**
  71413. * Gets if the system has been started. (Note: this will still be true after stop is called)
  71414. * @returns True if it has been started, otherwise false.
  71415. */
  71416. isStarted(): boolean;
  71417. /**
  71418. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  71419. * @returns True if it has been stopped, otherwise false.
  71420. */
  71421. isStopped(): boolean;
  71422. /**
  71423. * Gets a boolean indicating that the system is stopping
  71424. * @returns true if the system is currently stopping
  71425. */
  71426. isStopping(): boolean;
  71427. /**
  71428. * Gets the number of particles active at the same time.
  71429. * @returns The number of active particles.
  71430. */
  71431. getActiveCount(): number;
  71432. /**
  71433. * Starts the particle system and begins to emit
  71434. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  71435. */
  71436. start(delay?: number): void;
  71437. /**
  71438. * Stops the particle system.
  71439. */
  71440. stop(): void;
  71441. /**
  71442. * Remove all active particles
  71443. */
  71444. reset(): void;
  71445. /**
  71446. * Returns the string "GPUParticleSystem"
  71447. * @returns a string containing the class name
  71448. */
  71449. getClassName(): string;
  71450. /**
  71451. * Gets the custom effect used to render the particles
  71452. * @param blendMode Blend mode for which the effect should be retrieved
  71453. * @returns The effect
  71454. */
  71455. getCustomEffect(blendMode?: number): Nullable<Effect>;
  71456. /**
  71457. * Sets the custom effect used to render the particles
  71458. * @param effect The effect to set
  71459. * @param blendMode Blend mode for which the effect should be set
  71460. */
  71461. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  71462. /** @hidden */
  71463. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  71464. /**
  71465. * Observable that will be called just before the particles are drawn
  71466. */
  71467. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  71468. /**
  71469. * Gets the name of the particle vertex shader
  71470. */
  71471. get vertexShaderName(): string;
  71472. private _colorGradientsTexture;
  71473. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  71474. /**
  71475. * Adds a new color gradient
  71476. * @param gradient defines the gradient to use (between 0 and 1)
  71477. * @param color1 defines the color to affect to the specified gradient
  71478. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  71479. * @returns the current particle system
  71480. */
  71481. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  71482. private _refreshColorGradient;
  71483. /** Force the system to rebuild all gradients that need to be resync */
  71484. forceRefreshGradients(): void;
  71485. /**
  71486. * Remove a specific color gradient
  71487. * @param gradient defines the gradient to remove
  71488. * @returns the current particle system
  71489. */
  71490. removeColorGradient(gradient: number): GPUParticleSystem;
  71491. private _angularSpeedGradientsTexture;
  71492. private _sizeGradientsTexture;
  71493. private _velocityGradientsTexture;
  71494. private _limitVelocityGradientsTexture;
  71495. private _dragGradientsTexture;
  71496. private _addFactorGradient;
  71497. /**
  71498. * Adds a new size gradient
  71499. * @param gradient defines the gradient to use (between 0 and 1)
  71500. * @param factor defines the size factor to affect to the specified gradient
  71501. * @returns the current particle system
  71502. */
  71503. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  71504. /**
  71505. * Remove a specific size gradient
  71506. * @param gradient defines the gradient to remove
  71507. * @returns the current particle system
  71508. */
  71509. removeSizeGradient(gradient: number): GPUParticleSystem;
  71510. private _refreshFactorGradient;
  71511. /**
  71512. * Adds a new angular speed gradient
  71513. * @param gradient defines the gradient to use (between 0 and 1)
  71514. * @param factor defines the angular speed to affect to the specified gradient
  71515. * @returns the current particle system
  71516. */
  71517. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  71518. /**
  71519. * Remove a specific angular speed gradient
  71520. * @param gradient defines the gradient to remove
  71521. * @returns the current particle system
  71522. */
  71523. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  71524. /**
  71525. * Adds a new velocity gradient
  71526. * @param gradient defines the gradient to use (between 0 and 1)
  71527. * @param factor defines the velocity to affect to the specified gradient
  71528. * @returns the current particle system
  71529. */
  71530. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71531. /**
  71532. * Remove a specific velocity gradient
  71533. * @param gradient defines the gradient to remove
  71534. * @returns the current particle system
  71535. */
  71536. removeVelocityGradient(gradient: number): GPUParticleSystem;
  71537. /**
  71538. * Adds a new limit velocity gradient
  71539. * @param gradient defines the gradient to use (between 0 and 1)
  71540. * @param factor defines the limit velocity value to affect to the specified gradient
  71541. * @returns the current particle system
  71542. */
  71543. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  71544. /**
  71545. * Remove a specific limit velocity gradient
  71546. * @param gradient defines the gradient to remove
  71547. * @returns the current particle system
  71548. */
  71549. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  71550. /**
  71551. * Adds a new drag gradient
  71552. * @param gradient defines the gradient to use (between 0 and 1)
  71553. * @param factor defines the drag value to affect to the specified gradient
  71554. * @returns the current particle system
  71555. */
  71556. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  71557. /**
  71558. * Remove a specific drag gradient
  71559. * @param gradient defines the gradient to remove
  71560. * @returns the current particle system
  71561. */
  71562. removeDragGradient(gradient: number): GPUParticleSystem;
  71563. /**
  71564. * Not supported by GPUParticleSystem
  71565. * @param gradient defines the gradient to use (between 0 and 1)
  71566. * @param factor defines the emit rate value to affect to the specified gradient
  71567. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71568. * @returns the current particle system
  71569. */
  71570. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71571. /**
  71572. * Not supported by GPUParticleSystem
  71573. * @param gradient defines the gradient to remove
  71574. * @returns the current particle system
  71575. */
  71576. removeEmitRateGradient(gradient: number): IParticleSystem;
  71577. /**
  71578. * Not supported by GPUParticleSystem
  71579. * @param gradient defines the gradient to use (between 0 and 1)
  71580. * @param factor defines the start size value to affect to the specified gradient
  71581. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71582. * @returns the current particle system
  71583. */
  71584. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71585. /**
  71586. * Not supported by GPUParticleSystem
  71587. * @param gradient defines the gradient to remove
  71588. * @returns the current particle system
  71589. */
  71590. removeStartSizeGradient(gradient: number): IParticleSystem;
  71591. /**
  71592. * Not supported by GPUParticleSystem
  71593. * @param gradient defines the gradient to use (between 0 and 1)
  71594. * @param min defines the color remap minimal range
  71595. * @param max defines the color remap maximal range
  71596. * @returns the current particle system
  71597. */
  71598. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71599. /**
  71600. * Not supported by GPUParticleSystem
  71601. * @param gradient defines the gradient to remove
  71602. * @returns the current particle system
  71603. */
  71604. removeColorRemapGradient(): IParticleSystem;
  71605. /**
  71606. * Not supported by GPUParticleSystem
  71607. * @param gradient defines the gradient to use (between 0 and 1)
  71608. * @param min defines the alpha remap minimal range
  71609. * @param max defines the alpha remap maximal range
  71610. * @returns the current particle system
  71611. */
  71612. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  71613. /**
  71614. * Not supported by GPUParticleSystem
  71615. * @param gradient defines the gradient to remove
  71616. * @returns the current particle system
  71617. */
  71618. removeAlphaRemapGradient(): IParticleSystem;
  71619. /**
  71620. * Not supported by GPUParticleSystem
  71621. * @param gradient defines the gradient to use (between 0 and 1)
  71622. * @param color defines the color to affect to the specified gradient
  71623. * @returns the current particle system
  71624. */
  71625. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  71626. /**
  71627. * Not supported by GPUParticleSystem
  71628. * @param gradient defines the gradient to remove
  71629. * @returns the current particle system
  71630. */
  71631. removeRampGradient(): IParticleSystem;
  71632. /**
  71633. * Not supported by GPUParticleSystem
  71634. * @returns the list of ramp gradients
  71635. */
  71636. getRampGradients(): Nullable<Array<Color3Gradient>>;
  71637. /**
  71638. * Not supported by GPUParticleSystem
  71639. * Gets or sets a boolean indicating that ramp gradients must be used
  71640. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  71641. */
  71642. get useRampGradients(): boolean;
  71643. set useRampGradients(value: boolean);
  71644. /**
  71645. * Not supported by GPUParticleSystem
  71646. * @param gradient defines the gradient to use (between 0 and 1)
  71647. * @param factor defines the life time factor to affect to the specified gradient
  71648. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  71649. * @returns the current particle system
  71650. */
  71651. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  71652. /**
  71653. * Not supported by GPUParticleSystem
  71654. * @param gradient defines the gradient to remove
  71655. * @returns the current particle system
  71656. */
  71657. removeLifeTimeGradient(gradient: number): IParticleSystem;
  71658. /**
  71659. * Instantiates a GPU particle system.
  71660. * 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.
  71661. * @param name The name of the particle system
  71662. * @param options The options used to create the system
  71663. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  71664. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  71665. * @param customEffect a custom effect used to change the way particles are rendered by default
  71666. */
  71667. constructor(name: string, options: Partial<{
  71668. capacity: number;
  71669. randomTextureSize: number;
  71670. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  71671. protected _reset(): void;
  71672. private _createUpdateVAO;
  71673. private _createRenderVAO;
  71674. private _initialize;
  71675. /** @hidden */
  71676. _recreateUpdateEffect(): void;
  71677. private _getEffect;
  71678. /**
  71679. * Fill the defines array according to the current settings of the particle system
  71680. * @param defines Array to be updated
  71681. * @param blendMode blend mode to take into account when updating the array
  71682. */
  71683. fillDefines(defines: Array<string>, blendMode?: number): void;
  71684. /**
  71685. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  71686. * @param uniforms Uniforms array to fill
  71687. * @param attributes Attributes array to fill
  71688. * @param samplers Samplers array to fill
  71689. */
  71690. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  71691. /** @hidden */
  71692. _recreateRenderEffect(): Effect;
  71693. /**
  71694. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  71695. * @param preWarm defines if we are in the pre-warmimg phase
  71696. */
  71697. animate(preWarm?: boolean): void;
  71698. private _createFactorGradientTexture;
  71699. private _createSizeGradientTexture;
  71700. private _createAngularSpeedGradientTexture;
  71701. private _createVelocityGradientTexture;
  71702. private _createLimitVelocityGradientTexture;
  71703. private _createDragGradientTexture;
  71704. private _createColorGradientTexture;
  71705. /**
  71706. * Renders the particle system in its current state
  71707. * @param preWarm defines if the system should only update the particles but not render them
  71708. * @returns the current number of particles
  71709. */
  71710. render(preWarm?: boolean): number;
  71711. /**
  71712. * Rebuilds the particle system
  71713. */
  71714. rebuild(): void;
  71715. private _releaseBuffers;
  71716. private _releaseVAOs;
  71717. /**
  71718. * Disposes the particle system and free the associated resources
  71719. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  71720. */
  71721. dispose(disposeTexture?: boolean): void;
  71722. /**
  71723. * Clones the particle system.
  71724. * @param name The name of the cloned object
  71725. * @param newEmitter The new emitter to use
  71726. * @returns the cloned particle system
  71727. */
  71728. clone(name: string, newEmitter: any): GPUParticleSystem;
  71729. /**
  71730. * Serializes the particle system to a JSON object
  71731. * @param serializeTexture defines if the texture must be serialized as well
  71732. * @returns the JSON object
  71733. */
  71734. serialize(serializeTexture?: boolean): any;
  71735. /**
  71736. * Parses a JSON object to create a GPU particle system.
  71737. * @param parsedParticleSystem The JSON object to parse
  71738. * @param sceneOrEngine The scene or the engine to create the particle system in
  71739. * @param rootUrl The root url to use to load external dependencies like texture
  71740. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  71741. * @returns the parsed GPU particle system
  71742. */
  71743. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  71744. }
  71745. }
  71746. declare module "babylonjs/Particles/particleSystemSet" {
  71747. import { Nullable } from "babylonjs/types";
  71748. import { Color3 } from "babylonjs/Maths/math.color";
  71749. import { TransformNode } from "babylonjs/Meshes/transformNode";
  71750. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71751. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71752. import { Scene, IDisposable } from "babylonjs/scene";
  71753. /**
  71754. * Represents a set of particle systems working together to create a specific effect
  71755. */
  71756. export class ParticleSystemSet implements IDisposable {
  71757. /**
  71758. * Gets or sets base Assets URL
  71759. */
  71760. static BaseAssetsUrl: string;
  71761. private _emitterCreationOptions;
  71762. private _emitterNode;
  71763. /**
  71764. * Gets the particle system list
  71765. */
  71766. systems: IParticleSystem[];
  71767. /**
  71768. * Gets the emitter node used with this set
  71769. */
  71770. get emitterNode(): Nullable<TransformNode>;
  71771. /**
  71772. * Creates a new emitter mesh as a sphere
  71773. * @param options defines the options used to create the sphere
  71774. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  71775. * @param scene defines the hosting scene
  71776. */
  71777. setEmitterAsSphere(options: {
  71778. diameter: number;
  71779. segments: number;
  71780. color: Color3;
  71781. }, renderingGroupId: number, scene: Scene): void;
  71782. /**
  71783. * Starts all particle systems of the set
  71784. * @param emitter defines an optional mesh to use as emitter for the particle systems
  71785. */
  71786. start(emitter?: AbstractMesh): void;
  71787. /**
  71788. * Release all associated resources
  71789. */
  71790. dispose(): void;
  71791. /**
  71792. * Serialize the set into a JSON compatible object
  71793. * @param serializeTexture defines if the texture must be serialized as well
  71794. * @returns a JSON compatible representation of the set
  71795. */
  71796. serialize(serializeTexture?: boolean): any;
  71797. /**
  71798. * Parse a new ParticleSystemSet from a serialized source
  71799. * @param data defines a JSON compatible representation of the set
  71800. * @param scene defines the hosting scene
  71801. * @param gpu defines if we want GPU particles or CPU particles
  71802. * @returns a new ParticleSystemSet
  71803. */
  71804. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  71805. }
  71806. }
  71807. declare module "babylonjs/Particles/particleHelper" {
  71808. import { Nullable } from "babylonjs/types";
  71809. import { Scene } from "babylonjs/scene";
  71810. import { Vector3 } from "babylonjs/Maths/math.vector";
  71811. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  71812. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71813. import { ParticleSystemSet } from "babylonjs/Particles/particleSystemSet";
  71814. /**
  71815. * This class is made for on one-liner static method to help creating particle system set.
  71816. */
  71817. export class ParticleHelper {
  71818. /**
  71819. * Gets or sets base Assets URL
  71820. */
  71821. static BaseAssetsUrl: string;
  71822. /** Define the Url to load snippets */
  71823. static SnippetUrl: string;
  71824. /**
  71825. * Create a default particle system that you can tweak
  71826. * @param emitter defines the emitter to use
  71827. * @param capacity defines the system capacity (default is 500 particles)
  71828. * @param scene defines the hosting scene
  71829. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  71830. * @returns the new Particle system
  71831. */
  71832. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  71833. /**
  71834. * This is the main static method (one-liner) of this helper to create different particle systems
  71835. * @param type This string represents the type to the particle system to create
  71836. * @param scene The scene where the particle system should live
  71837. * @param gpu If the system will use gpu
  71838. * @returns the ParticleSystemSet created
  71839. */
  71840. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  71841. /**
  71842. * Static function used to export a particle system to a ParticleSystemSet variable.
  71843. * Please note that the emitter shape is not exported
  71844. * @param systems defines the particle systems to export
  71845. * @returns the created particle system set
  71846. */
  71847. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  71848. /**
  71849. * Creates a particle system from a snippet saved in a remote file
  71850. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  71851. * @param url defines the url to load from
  71852. * @param scene defines the hosting scene
  71853. * @param gpu If the system will use gpu
  71854. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71855. * @returns a promise that will resolve to the new particle system
  71856. */
  71857. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71858. /**
  71859. * Creates a particle system from a snippet saved by the particle system editor
  71860. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  71861. * @param scene defines the hosting scene
  71862. * @param gpu If the system will use gpu
  71863. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  71864. * @returns a promise that will resolve to the new particle system
  71865. */
  71866. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  71867. }
  71868. }
  71869. declare module "babylonjs/Particles/particleSystemComponent" {
  71870. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  71871. import { Effect } from "babylonjs/Materials/effect";
  71872. import "babylonjs/Shaders/particles.vertex";
  71873. import { EffectFallbacks } from "babylonjs/Materials/effectFallbacks";
  71874. module "babylonjs/Engines/engine" {
  71875. interface Engine {
  71876. /**
  71877. * Create an effect to use with particle systems.
  71878. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  71879. * the particle system for which you want to create a custom effect in the last parameter
  71880. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  71881. * @param uniformsNames defines a list of attribute names
  71882. * @param samplers defines an array of string used to represent textures
  71883. * @param defines defines the string containing the defines to use to compile the shaders
  71884. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  71885. * @param onCompiled defines a function to call when the effect creation is successful
  71886. * @param onError defines a function to call when the effect creation has failed
  71887. * @param particleSystem the particle system you want to create the effect for
  71888. * @returns the new Effect
  71889. */
  71890. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  71891. }
  71892. }
  71893. module "babylonjs/Meshes/mesh" {
  71894. interface Mesh {
  71895. /**
  71896. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  71897. * @returns an array of IParticleSystem
  71898. */
  71899. getEmittedParticleSystems(): IParticleSystem[];
  71900. /**
  71901. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  71902. * @returns an array of IParticleSystem
  71903. */
  71904. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  71905. }
  71906. }
  71907. }
  71908. declare module "babylonjs/Particles/pointsCloudSystem" {
  71909. import { Color4 } from "babylonjs/Maths/math";
  71910. import { Mesh } from "babylonjs/Meshes/mesh";
  71911. import { Scene, IDisposable } from "babylonjs/scene";
  71912. import { CloudPoint } from "babylonjs/Particles/cloudPoint";
  71913. /** Defines the 4 color options */
  71914. export enum PointColor {
  71915. /** color value */
  71916. Color = 2,
  71917. /** uv value */
  71918. UV = 1,
  71919. /** random value */
  71920. Random = 0,
  71921. /** stated value */
  71922. Stated = 3
  71923. }
  71924. /**
  71925. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  71926. * 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.
  71927. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  71928. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  71929. *
  71930. * Full documentation here : TO BE ENTERED
  71931. */
  71932. export class PointsCloudSystem implements IDisposable {
  71933. /**
  71934. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  71935. * Example : var p = SPS.particles[i];
  71936. */
  71937. particles: CloudPoint[];
  71938. /**
  71939. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  71940. */
  71941. nbParticles: number;
  71942. /**
  71943. * This a counter for your own usage. It's not set by any SPS functions.
  71944. */
  71945. counter: number;
  71946. /**
  71947. * The PCS name. This name is also given to the underlying mesh.
  71948. */
  71949. name: string;
  71950. /**
  71951. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  71952. */
  71953. mesh: Mesh;
  71954. /**
  71955. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  71956. * Please read :
  71957. */
  71958. vars: any;
  71959. /**
  71960. * @hidden
  71961. */
  71962. _size: number;
  71963. private _scene;
  71964. private _promises;
  71965. private _positions;
  71966. private _indices;
  71967. private _normals;
  71968. private _colors;
  71969. private _uvs;
  71970. private _indices32;
  71971. private _positions32;
  71972. private _colors32;
  71973. private _uvs32;
  71974. private _updatable;
  71975. private _isVisibilityBoxLocked;
  71976. private _alwaysVisible;
  71977. private _groups;
  71978. private _groupCounter;
  71979. private _computeParticleColor;
  71980. private _computeParticleTexture;
  71981. private _computeParticleRotation;
  71982. private _computeBoundingBox;
  71983. private _isReady;
  71984. /**
  71985. * Creates a PCS (Points Cloud System) object
  71986. * @param name (String) is the PCS name, this will be the underlying mesh name
  71987. * @param pointSize (number) is the size for each point
  71988. * @param scene (Scene) is the scene in which the PCS is added
  71989. * @param options defines the options of the PCS e.g.
  71990. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  71991. */
  71992. constructor(name: string, pointSize: number, scene: Scene, options?: {
  71993. updatable?: boolean;
  71994. });
  71995. /**
  71996. * Builds the PCS underlying mesh. Returns a standard Mesh.
  71997. * If no points were added to the PCS, the returned mesh is just a single point.
  71998. * @returns a promise for the created mesh
  71999. */
  72000. buildMeshAsync(): Promise<Mesh>;
  72001. /**
  72002. * @hidden
  72003. */
  72004. private _buildMesh;
  72005. private _addParticle;
  72006. private _randomUnitVector;
  72007. private _getColorIndicesForCoord;
  72008. private _setPointsColorOrUV;
  72009. private _colorFromTexture;
  72010. private _calculateDensity;
  72011. /**
  72012. * Adds points to the PCS in random positions within a unit sphere
  72013. * @param nb (positive integer) the number of particles to be created from this model
  72014. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  72015. * @returns the number of groups in the system
  72016. */
  72017. addPoints(nb: number, pointFunction?: any): number;
  72018. /**
  72019. * Adds points to the PCS from the surface of the model shape
  72020. * @param mesh is any Mesh object that will be used as a surface model for the points
  72021. * @param nb (positive integer) the number of particles to be created from this model
  72022. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72023. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72024. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72025. * @returns the number of groups in the system
  72026. */
  72027. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72028. /**
  72029. * Adds points to the PCS inside the model shape
  72030. * @param mesh is any Mesh object that will be used as a surface model for the points
  72031. * @param nb (positive integer) the number of particles to be created from this model
  72032. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  72033. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  72034. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  72035. * @returns the number of groups in the system
  72036. */
  72037. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  72038. /**
  72039. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  72040. * This method calls `updateParticle()` for each particle of the SPS.
  72041. * For an animated SPS, it is usually called within the render loop.
  72042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  72043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  72044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  72045. * @returns the PCS.
  72046. */
  72047. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  72048. /**
  72049. * Disposes the PCS.
  72050. */
  72051. dispose(): void;
  72052. /**
  72053. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  72054. * doc :
  72055. * @returns the PCS.
  72056. */
  72057. refreshVisibleSize(): PointsCloudSystem;
  72058. /**
  72059. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  72060. * @param size the size (float) of the visibility box
  72061. * note : this doesn't lock the PCS mesh bounding box.
  72062. * doc :
  72063. */
  72064. setVisibilityBox(size: number): void;
  72065. /**
  72066. * Gets whether the PCS is always visible or not
  72067. * doc :
  72068. */
  72069. get isAlwaysVisible(): boolean;
  72070. /**
  72071. * Sets the PCS as always visible or not
  72072. * doc :
  72073. */
  72074. set isAlwaysVisible(val: boolean);
  72075. /**
  72076. * Tells to `setParticles()` to compute the particle rotations or not
  72077. * Default value : false. The PCS is faster when it's set to false
  72078. * Note : particle rotations are only applied to parent particles
  72079. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  72080. */
  72081. set computeParticleRotation(val: boolean);
  72082. /**
  72083. * Tells to `setParticles()` to compute the particle colors or not.
  72084. * Default value : true. The PCS is faster when it's set to false.
  72085. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72086. */
  72087. set computeParticleColor(val: boolean);
  72088. set computeParticleTexture(val: boolean);
  72089. /**
  72090. * Gets if `setParticles()` computes the particle colors or not.
  72091. * Default value : false. The PCS is faster when it's set to false.
  72092. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  72093. */
  72094. get computeParticleColor(): boolean;
  72095. /**
  72096. * Gets if `setParticles()` computes the particle textures or not.
  72097. * Default value : false. The PCS is faster when it's set to false.
  72098. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  72099. */
  72100. get computeParticleTexture(): boolean;
  72101. /**
  72102. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  72103. */
  72104. set computeBoundingBox(val: boolean);
  72105. /**
  72106. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  72107. */
  72108. get computeBoundingBox(): boolean;
  72109. /**
  72110. * This function does nothing. It may be overwritten to set all the particle first values.
  72111. * The PCS doesn't call this function, you may have to call it by your own.
  72112. * doc :
  72113. */
  72114. initParticles(): void;
  72115. /**
  72116. * This function does nothing. It may be overwritten to recycle a particle
  72117. * The PCS doesn't call this function, you can to call it
  72118. * doc :
  72119. * @param particle The particle to recycle
  72120. * @returns the recycled particle
  72121. */
  72122. recycleParticle(particle: CloudPoint): CloudPoint;
  72123. /**
  72124. * Updates a particle : this function should be overwritten by the user.
  72125. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  72126. * doc :
  72127. * @example : just set a particle position or velocity and recycle conditions
  72128. * @param particle The particle to update
  72129. * @returns the updated particle
  72130. */
  72131. updateParticle(particle: CloudPoint): CloudPoint;
  72132. /**
  72133. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  72134. * This does nothing and may be overwritten by the user.
  72135. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72136. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72137. * @param update the boolean update value actually passed to setParticles()
  72138. */
  72139. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72140. /**
  72141. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  72142. * This will be passed three parameters.
  72143. * This does nothing and may be overwritten by the user.
  72144. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  72145. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  72146. * @param update the boolean update value actually passed to setParticles()
  72147. */
  72148. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  72149. }
  72150. }
  72151. declare module "babylonjs/Particles/cloudPoint" {
  72152. import { Nullable } from "babylonjs/types";
  72153. import { Color4, Vector2, Vector3, Matrix, Quaternion } from "babylonjs/Maths/math";
  72154. import { Mesh } from "babylonjs/Meshes/mesh";
  72155. import { BoundingInfo } from "babylonjs/Culling/boundingInfo";
  72156. import { PointsCloudSystem } from "babylonjs/Particles/pointsCloudSystem";
  72157. /**
  72158. * Represents one particle of a points cloud system.
  72159. */
  72160. export class CloudPoint {
  72161. /**
  72162. * particle global index
  72163. */
  72164. idx: number;
  72165. /**
  72166. * The color of the particle
  72167. */
  72168. color: Nullable<Color4>;
  72169. /**
  72170. * The world space position of the particle.
  72171. */
  72172. position: Vector3;
  72173. /**
  72174. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  72175. */
  72176. rotation: Vector3;
  72177. /**
  72178. * The world space rotation quaternion of the particle.
  72179. */
  72180. rotationQuaternion: Nullable<Quaternion>;
  72181. /**
  72182. * The uv of the particle.
  72183. */
  72184. uv: Nullable<Vector2>;
  72185. /**
  72186. * The current speed of the particle.
  72187. */
  72188. velocity: Vector3;
  72189. /**
  72190. * The pivot point in the particle local space.
  72191. */
  72192. pivot: Vector3;
  72193. /**
  72194. * Must the particle be translated from its pivot point in its local space ?
  72195. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  72196. * Default : false
  72197. */
  72198. translateFromPivot: boolean;
  72199. /**
  72200. * Index of this particle in the global "positions" array (Internal use)
  72201. * @hidden
  72202. */
  72203. _pos: number;
  72204. /**
  72205. * @hidden Index of this particle in the global "indices" array (Internal use)
  72206. */
  72207. _ind: number;
  72208. /**
  72209. * Group this particle belongs to
  72210. */
  72211. _group: PointsGroup;
  72212. /**
  72213. * Group id of this particle
  72214. */
  72215. groupId: number;
  72216. /**
  72217. * Index of the particle in its group id (Internal use)
  72218. */
  72219. idxInGroup: number;
  72220. /**
  72221. * @hidden Particle BoundingInfo object (Internal use)
  72222. */
  72223. _boundingInfo: BoundingInfo;
  72224. /**
  72225. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  72226. */
  72227. _pcs: PointsCloudSystem;
  72228. /**
  72229. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  72230. */
  72231. _stillInvisible: boolean;
  72232. /**
  72233. * @hidden Last computed particle rotation matrix
  72234. */
  72235. _rotationMatrix: number[];
  72236. /**
  72237. * Parent particle Id, if any.
  72238. * Default null.
  72239. */
  72240. parentId: Nullable<number>;
  72241. /**
  72242. * @hidden Internal global position in the PCS.
  72243. */
  72244. _globalPosition: Vector3;
  72245. /**
  72246. * Creates a Point Cloud object.
  72247. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  72248. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  72249. * @param group (PointsGroup) is the group the particle belongs to
  72250. * @param groupId (integer) is the group identifier in the PCS.
  72251. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  72252. * @param pcs defines the PCS it is associated to
  72253. */
  72254. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  72255. /**
  72256. * get point size
  72257. */
  72258. get size(): Vector3;
  72259. /**
  72260. * Set point size
  72261. */
  72262. set size(scale: Vector3);
  72263. /**
  72264. * Legacy support, changed quaternion to rotationQuaternion
  72265. */
  72266. get quaternion(): Nullable<Quaternion>;
  72267. /**
  72268. * Legacy support, changed quaternion to rotationQuaternion
  72269. */
  72270. set quaternion(q: Nullable<Quaternion>);
  72271. /**
  72272. * Returns a boolean. True if the particle intersects a mesh, else false
  72273. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  72274. * @param target is the object (point or mesh) what the intersection is computed against
  72275. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  72276. * @returns true if it intersects
  72277. */
  72278. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  72279. /**
  72280. * get the rotation matrix of the particle
  72281. * @hidden
  72282. */
  72283. getRotationMatrix(m: Matrix): void;
  72284. }
  72285. /**
  72286. * Represents a group of points in a points cloud system
  72287. * * PCS internal tool, don't use it manually.
  72288. */
  72289. export class PointsGroup {
  72290. /**
  72291. * The group id
  72292. * @hidden
  72293. */
  72294. groupID: number;
  72295. /**
  72296. * image data for group (internal use)
  72297. * @hidden
  72298. */
  72299. _groupImageData: Nullable<ArrayBufferView>;
  72300. /**
  72301. * Image Width (internal use)
  72302. * @hidden
  72303. */
  72304. _groupImgWidth: number;
  72305. /**
  72306. * Image Height (internal use)
  72307. * @hidden
  72308. */
  72309. _groupImgHeight: number;
  72310. /**
  72311. * Custom position function (internal use)
  72312. * @hidden
  72313. */
  72314. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  72315. /**
  72316. * density per facet for surface points
  72317. * @hidden
  72318. */
  72319. _groupDensity: number[];
  72320. /**
  72321. * Only when points are colored by texture carries pointer to texture list array
  72322. * @hidden
  72323. */
  72324. _textureNb: number;
  72325. /**
  72326. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  72327. * PCS internal tool, don't use it manually.
  72328. * @hidden
  72329. */
  72330. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  72331. }
  72332. }
  72333. declare module "babylonjs/Particles/index" {
  72334. export * from "babylonjs/Particles/baseParticleSystem";
  72335. export * from "babylonjs/Particles/EmitterTypes/index";
  72336. export * from "babylonjs/Particles/gpuParticleSystem";
  72337. export * from "babylonjs/Particles/IParticleSystem";
  72338. export * from "babylonjs/Particles/particle";
  72339. export * from "babylonjs/Particles/particleHelper";
  72340. export * from "babylonjs/Particles/particleSystem";
  72341. import "babylonjs/Particles/particleSystemComponent";
  72342. export * from "babylonjs/Particles/particleSystemComponent";
  72343. export * from "babylonjs/Particles/particleSystemSet";
  72344. export * from "babylonjs/Particles/solidParticle";
  72345. export * from "babylonjs/Particles/solidParticleSystem";
  72346. export * from "babylonjs/Particles/cloudPoint";
  72347. export * from "babylonjs/Particles/pointsCloudSystem";
  72348. export * from "babylonjs/Particles/subEmitter";
  72349. }
  72350. declare module "babylonjs/Physics/physicsEngineComponent" {
  72351. import { Nullable } from "babylonjs/types";
  72352. import { Observable, Observer } from "babylonjs/Misc/observable";
  72353. import { Vector3 } from "babylonjs/Maths/math.vector";
  72354. import { Mesh } from "babylonjs/Meshes/mesh";
  72355. import { ISceneComponent } from "babylonjs/sceneComponent";
  72356. import { Scene } from "babylonjs/scene";
  72357. import { Node } from "babylonjs/node";
  72358. import { IPhysicsEngine, IPhysicsEnginePlugin } from "babylonjs/Physics/IPhysicsEngine";
  72359. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72360. module "babylonjs/scene" {
  72361. interface Scene {
  72362. /** @hidden (Backing field) */
  72363. _physicsEngine: Nullable<IPhysicsEngine>;
  72364. /** @hidden */
  72365. _physicsTimeAccumulator: number;
  72366. /**
  72367. * Gets the current physics engine
  72368. * @returns a IPhysicsEngine or null if none attached
  72369. */
  72370. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  72371. /**
  72372. * Enables physics to the current scene
  72373. * @param gravity defines the scene's gravity for the physics engine
  72374. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  72375. * @return a boolean indicating if the physics engine was initialized
  72376. */
  72377. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  72378. /**
  72379. * Disables and disposes the physics engine associated with the scene
  72380. */
  72381. disablePhysicsEngine(): void;
  72382. /**
  72383. * Gets a boolean indicating if there is an active physics engine
  72384. * @returns a boolean indicating if there is an active physics engine
  72385. */
  72386. isPhysicsEnabled(): boolean;
  72387. /**
  72388. * Deletes a physics compound impostor
  72389. * @param compound defines the compound to delete
  72390. */
  72391. deleteCompoundImpostor(compound: any): void;
  72392. /**
  72393. * An event triggered when physic simulation is about to be run
  72394. */
  72395. onBeforePhysicsObservable: Observable<Scene>;
  72396. /**
  72397. * An event triggered when physic simulation has been done
  72398. */
  72399. onAfterPhysicsObservable: Observable<Scene>;
  72400. }
  72401. }
  72402. module "babylonjs/Meshes/abstractMesh" {
  72403. interface AbstractMesh {
  72404. /** @hidden */
  72405. _physicsImpostor: Nullable<PhysicsImpostor>;
  72406. /**
  72407. * Gets or sets impostor used for physic simulation
  72408. * @see https://doc.babylonjs.com/features/physics_engine
  72409. */
  72410. physicsImpostor: Nullable<PhysicsImpostor>;
  72411. /**
  72412. * Gets the current physics impostor
  72413. * @see https://doc.babylonjs.com/features/physics_engine
  72414. * @returns a physics impostor or null
  72415. */
  72416. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  72417. /** Apply a physic impulse to the mesh
  72418. * @param force defines the force to apply
  72419. * @param contactPoint defines where to apply the force
  72420. * @returns the current mesh
  72421. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  72422. */
  72423. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  72424. /**
  72425. * Creates a physic joint between two meshes
  72426. * @param otherMesh defines the other mesh to use
  72427. * @param pivot1 defines the pivot to use on this mesh
  72428. * @param pivot2 defines the pivot to use on the other mesh
  72429. * @param options defines additional options (can be plugin dependent)
  72430. * @returns the current mesh
  72431. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  72432. */
  72433. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  72434. /** @hidden */
  72435. _disposePhysicsObserver: Nullable<Observer<Node>>;
  72436. }
  72437. }
  72438. /**
  72439. * Defines the physics engine scene component responsible to manage a physics engine
  72440. */
  72441. export class PhysicsEngineSceneComponent implements ISceneComponent {
  72442. /**
  72443. * The component name helpful to identify the component in the list of scene components.
  72444. */
  72445. readonly name: string;
  72446. /**
  72447. * The scene the component belongs to.
  72448. */
  72449. scene: Scene;
  72450. /**
  72451. * Creates a new instance of the component for the given scene
  72452. * @param scene Defines the scene to register the component in
  72453. */
  72454. constructor(scene: Scene);
  72455. /**
  72456. * Registers the component in a given scene
  72457. */
  72458. register(): void;
  72459. /**
  72460. * Rebuilds the elements related to this component in case of
  72461. * context lost for instance.
  72462. */
  72463. rebuild(): void;
  72464. /**
  72465. * Disposes the component and the associated ressources
  72466. */
  72467. dispose(): void;
  72468. }
  72469. }
  72470. declare module "babylonjs/Physics/physicsHelper" {
  72471. import { Nullable } from "babylonjs/types";
  72472. import { Vector3 } from "babylonjs/Maths/math.vector";
  72473. import { Mesh } from "babylonjs/Meshes/mesh";
  72474. import { Scene } from "babylonjs/scene";
  72475. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  72476. /**
  72477. * A helper for physics simulations
  72478. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72479. */
  72480. export class PhysicsHelper {
  72481. private _scene;
  72482. private _physicsEngine;
  72483. /**
  72484. * Initializes the Physics helper
  72485. * @param scene Babylon.js scene
  72486. */
  72487. constructor(scene: Scene);
  72488. /**
  72489. * Applies a radial explosion impulse
  72490. * @param origin the origin of the explosion
  72491. * @param radiusOrEventOptions the radius or the options of radial explosion
  72492. * @param strength the explosion strength
  72493. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72494. * @returns A physics radial explosion event, or null
  72495. */
  72496. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72497. /**
  72498. * Applies a radial explosion force
  72499. * @param origin the origin of the explosion
  72500. * @param radiusOrEventOptions the radius or the options of radial explosion
  72501. * @param strength the explosion strength
  72502. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72503. * @returns A physics radial explosion event, or null
  72504. */
  72505. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  72506. /**
  72507. * Creates a gravitational field
  72508. * @param origin the origin of the explosion
  72509. * @param radiusOrEventOptions the radius or the options of radial explosion
  72510. * @param strength the explosion strength
  72511. * @param falloff possible options: Constant & Linear. Defaults to Constant
  72512. * @returns A physics gravitational field event, or null
  72513. */
  72514. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  72515. /**
  72516. * Creates a physics updraft event
  72517. * @param origin the origin of the updraft
  72518. * @param radiusOrEventOptions the radius or the options of the updraft
  72519. * @param strength the strength of the updraft
  72520. * @param height the height of the updraft
  72521. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  72522. * @returns A physics updraft event, or null
  72523. */
  72524. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  72525. /**
  72526. * Creates a physics vortex event
  72527. * @param origin the of the vortex
  72528. * @param radiusOrEventOptions the radius or the options of the vortex
  72529. * @param strength the strength of the vortex
  72530. * @param height the height of the vortex
  72531. * @returns a Physics vortex event, or null
  72532. * A physics vortex event or null
  72533. */
  72534. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  72535. }
  72536. /**
  72537. * Represents a physics radial explosion event
  72538. */
  72539. class PhysicsRadialExplosionEvent {
  72540. private _scene;
  72541. private _options;
  72542. private _sphere;
  72543. private _dataFetched;
  72544. /**
  72545. * Initializes a radial explosioin event
  72546. * @param _scene BabylonJS scene
  72547. * @param _options The options for the vortex event
  72548. */
  72549. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  72550. /**
  72551. * Returns the data related to the radial explosion event (sphere).
  72552. * @returns The radial explosion event data
  72553. */
  72554. getData(): PhysicsRadialExplosionEventData;
  72555. /**
  72556. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  72557. * @param impostor A physics imposter
  72558. * @param origin the origin of the explosion
  72559. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  72560. */
  72561. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  72562. /**
  72563. * Triggers affecterd impostors callbacks
  72564. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  72565. */
  72566. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  72567. /**
  72568. * Disposes the sphere.
  72569. * @param force Specifies if the sphere should be disposed by force
  72570. */
  72571. dispose(force?: boolean): void;
  72572. /*** Helpers ***/
  72573. private _prepareSphere;
  72574. private _intersectsWithSphere;
  72575. }
  72576. /**
  72577. * Represents a gravitational field event
  72578. */
  72579. class PhysicsGravitationalFieldEvent {
  72580. private _physicsHelper;
  72581. private _scene;
  72582. private _origin;
  72583. private _options;
  72584. private _tickCallback;
  72585. private _sphere;
  72586. private _dataFetched;
  72587. /**
  72588. * Initializes the physics gravitational field event
  72589. * @param _physicsHelper A physics helper
  72590. * @param _scene BabylonJS scene
  72591. * @param _origin The origin position of the gravitational field event
  72592. * @param _options The options for the vortex event
  72593. */
  72594. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  72595. /**
  72596. * Returns the data related to the gravitational field event (sphere).
  72597. * @returns A gravitational field event
  72598. */
  72599. getData(): PhysicsGravitationalFieldEventData;
  72600. /**
  72601. * Enables the gravitational field.
  72602. */
  72603. enable(): void;
  72604. /**
  72605. * Disables the gravitational field.
  72606. */
  72607. disable(): void;
  72608. /**
  72609. * Disposes the sphere.
  72610. * @param force The force to dispose from the gravitational field event
  72611. */
  72612. dispose(force?: boolean): void;
  72613. private _tick;
  72614. }
  72615. /**
  72616. * Represents a physics updraft event
  72617. */
  72618. class PhysicsUpdraftEvent {
  72619. private _scene;
  72620. private _origin;
  72621. private _options;
  72622. private _physicsEngine;
  72623. private _originTop;
  72624. private _originDirection;
  72625. private _tickCallback;
  72626. private _cylinder;
  72627. private _cylinderPosition;
  72628. private _dataFetched;
  72629. /**
  72630. * Initializes the physics updraft event
  72631. * @param _scene BabylonJS scene
  72632. * @param _origin The origin position of the updraft
  72633. * @param _options The options for the updraft event
  72634. */
  72635. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  72636. /**
  72637. * Returns the data related to the updraft event (cylinder).
  72638. * @returns A physics updraft event
  72639. */
  72640. getData(): PhysicsUpdraftEventData;
  72641. /**
  72642. * Enables the updraft.
  72643. */
  72644. enable(): void;
  72645. /**
  72646. * Disables the updraft.
  72647. */
  72648. disable(): void;
  72649. /**
  72650. * Disposes the cylinder.
  72651. * @param force Specifies if the updraft should be disposed by force
  72652. */
  72653. dispose(force?: boolean): void;
  72654. private getImpostorHitData;
  72655. private _tick;
  72656. /*** Helpers ***/
  72657. private _prepareCylinder;
  72658. private _intersectsWithCylinder;
  72659. }
  72660. /**
  72661. * Represents a physics vortex event
  72662. */
  72663. class PhysicsVortexEvent {
  72664. private _scene;
  72665. private _origin;
  72666. private _options;
  72667. private _physicsEngine;
  72668. private _originTop;
  72669. private _tickCallback;
  72670. private _cylinder;
  72671. private _cylinderPosition;
  72672. private _dataFetched;
  72673. /**
  72674. * Initializes the physics vortex event
  72675. * @param _scene The BabylonJS scene
  72676. * @param _origin The origin position of the vortex
  72677. * @param _options The options for the vortex event
  72678. */
  72679. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  72680. /**
  72681. * Returns the data related to the vortex event (cylinder).
  72682. * @returns The physics vortex event data
  72683. */
  72684. getData(): PhysicsVortexEventData;
  72685. /**
  72686. * Enables the vortex.
  72687. */
  72688. enable(): void;
  72689. /**
  72690. * Disables the cortex.
  72691. */
  72692. disable(): void;
  72693. /**
  72694. * Disposes the sphere.
  72695. * @param force
  72696. */
  72697. dispose(force?: boolean): void;
  72698. private getImpostorHitData;
  72699. private _tick;
  72700. /*** Helpers ***/
  72701. private _prepareCylinder;
  72702. private _intersectsWithCylinder;
  72703. }
  72704. /**
  72705. * Options fot the radial explosion event
  72706. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72707. */
  72708. export class PhysicsRadialExplosionEventOptions {
  72709. /**
  72710. * The radius of the sphere for the radial explosion.
  72711. */
  72712. radius: number;
  72713. /**
  72714. * The strenth of the explosion.
  72715. */
  72716. strength: number;
  72717. /**
  72718. * The strenght of the force in correspondence to the distance of the affected object
  72719. */
  72720. falloff: PhysicsRadialImpulseFalloff;
  72721. /**
  72722. * Sphere options for the radial explosion.
  72723. */
  72724. sphere: {
  72725. segments: number;
  72726. diameter: number;
  72727. };
  72728. /**
  72729. * Sphere options for the radial explosion.
  72730. */
  72731. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  72732. }
  72733. /**
  72734. * Options fot the updraft event
  72735. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72736. */
  72737. export class PhysicsUpdraftEventOptions {
  72738. /**
  72739. * The radius of the cylinder for the vortex
  72740. */
  72741. radius: number;
  72742. /**
  72743. * The strenth of the updraft.
  72744. */
  72745. strength: number;
  72746. /**
  72747. * The height of the cylinder for the updraft.
  72748. */
  72749. height: number;
  72750. /**
  72751. * The mode for the the updraft.
  72752. */
  72753. updraftMode: PhysicsUpdraftMode;
  72754. }
  72755. /**
  72756. * Options fot the vortex event
  72757. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72758. */
  72759. export class PhysicsVortexEventOptions {
  72760. /**
  72761. * The radius of the cylinder for the vortex
  72762. */
  72763. radius: number;
  72764. /**
  72765. * The strenth of the vortex.
  72766. */
  72767. strength: number;
  72768. /**
  72769. * The height of the cylinder for the vortex.
  72770. */
  72771. height: number;
  72772. /**
  72773. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  72774. */
  72775. centripetalForceThreshold: number;
  72776. /**
  72777. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  72778. */
  72779. centripetalForceMultiplier: number;
  72780. /**
  72781. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  72782. */
  72783. centrifugalForceMultiplier: number;
  72784. /**
  72785. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  72786. */
  72787. updraftForceMultiplier: number;
  72788. }
  72789. /**
  72790. * The strenght of the force in correspondence to the distance of the affected object
  72791. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72792. */
  72793. export enum PhysicsRadialImpulseFalloff {
  72794. /** Defines that impulse is constant in strength across it's whole radius */
  72795. Constant = 0,
  72796. /** Defines that impulse gets weaker if it's further from the origin */
  72797. Linear = 1
  72798. }
  72799. /**
  72800. * The strength of the force in correspondence to the distance of the affected object
  72801. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72802. */
  72803. export enum PhysicsUpdraftMode {
  72804. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  72805. Center = 0,
  72806. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  72807. Perpendicular = 1
  72808. }
  72809. /**
  72810. * Interface for a physics hit data
  72811. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72812. */
  72813. export interface PhysicsHitData {
  72814. /**
  72815. * The force applied at the contact point
  72816. */
  72817. force: Vector3;
  72818. /**
  72819. * The contact point
  72820. */
  72821. contactPoint: Vector3;
  72822. /**
  72823. * The distance from the origin to the contact point
  72824. */
  72825. distanceFromOrigin: number;
  72826. }
  72827. /**
  72828. * Interface for radial explosion event data
  72829. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72830. */
  72831. export interface PhysicsRadialExplosionEventData {
  72832. /**
  72833. * A sphere used for the radial explosion event
  72834. */
  72835. sphere: Mesh;
  72836. }
  72837. /**
  72838. * Interface for gravitational field event data
  72839. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72840. */
  72841. export interface PhysicsGravitationalFieldEventData {
  72842. /**
  72843. * A sphere mesh used for the gravitational field event
  72844. */
  72845. sphere: Mesh;
  72846. }
  72847. /**
  72848. * Interface for updraft event data
  72849. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72850. */
  72851. export interface PhysicsUpdraftEventData {
  72852. /**
  72853. * A cylinder used for the updraft event
  72854. */
  72855. cylinder: Mesh;
  72856. }
  72857. /**
  72858. * Interface for vortex event data
  72859. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72860. */
  72861. export interface PhysicsVortexEventData {
  72862. /**
  72863. * A cylinder used for the vortex event
  72864. */
  72865. cylinder: Mesh;
  72866. }
  72867. /**
  72868. * Interface for an affected physics impostor
  72869. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  72870. */
  72871. export interface PhysicsAffectedImpostorWithData {
  72872. /**
  72873. * The impostor affected by the effect
  72874. */
  72875. impostor: PhysicsImpostor;
  72876. /**
  72877. * The data about the hit/horce from the explosion
  72878. */
  72879. hitData: PhysicsHitData;
  72880. }
  72881. }
  72882. declare module "babylonjs/Physics/Plugins/index" {
  72883. export * from "babylonjs/Physics/Plugins/cannonJSPlugin";
  72884. export * from "babylonjs/Physics/Plugins/ammoJSPlugin";
  72885. export * from "babylonjs/Physics/Plugins/oimoJSPlugin";
  72886. }
  72887. declare module "babylonjs/Physics/index" {
  72888. export * from "babylonjs/Physics/IPhysicsEngine";
  72889. export * from "babylonjs/Physics/physicsEngine";
  72890. export * from "babylonjs/Physics/physicsEngineComponent";
  72891. export * from "babylonjs/Physics/physicsHelper";
  72892. export * from "babylonjs/Physics/physicsImpostor";
  72893. export * from "babylonjs/Physics/physicsJoint";
  72894. export * from "babylonjs/Physics/Plugins/index";
  72895. }
  72896. declare module "babylonjs/Shaders/blackAndWhite.fragment" {
  72897. /** @hidden */
  72898. export var blackAndWhitePixelShader: {
  72899. name: string;
  72900. shader: string;
  72901. };
  72902. }
  72903. declare module "babylonjs/PostProcesses/blackAndWhitePostProcess" {
  72904. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  72905. import { Camera } from "babylonjs/Cameras/camera";
  72906. import { Engine } from "babylonjs/Engines/engine";
  72907. import "babylonjs/Shaders/blackAndWhite.fragment";
  72908. import { Nullable } from "babylonjs/types";
  72909. import { Scene } from "babylonjs/scene";
  72910. /**
  72911. * Post process used to render in black and white
  72912. */
  72913. export class BlackAndWhitePostProcess extends PostProcess {
  72914. /**
  72915. * Linear about to convert he result to black and white (default: 1)
  72916. */
  72917. degree: number;
  72918. /**
  72919. * Gets a string identifying the name of the class
  72920. * @returns "BlackAndWhitePostProcess" string
  72921. */
  72922. getClassName(): string;
  72923. /**
  72924. * Creates a black and white post process
  72925. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  72926. * @param name The name of the effect.
  72927. * @param options The required width/height ratio to downsize to before computing the render pass.
  72928. * @param camera The camera to apply the render pass to.
  72929. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  72930. * @param engine The engine which the post process will be applied. (default: current engine)
  72931. * @param reusable If the post process can be reused on the same frame. (default: false)
  72932. */
  72933. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  72934. /** @hidden */
  72935. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  72936. }
  72937. }
  72938. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect" {
  72939. import { Nullable } from "babylonjs/types";
  72940. import { Camera } from "babylonjs/Cameras/camera";
  72941. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  72942. import { Engine } from "babylonjs/Engines/engine";
  72943. /**
  72944. * This represents a set of one or more post processes in Babylon.
  72945. * A post process can be used to apply a shader to a texture after it is rendered.
  72946. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  72947. */
  72948. export class PostProcessRenderEffect {
  72949. private _postProcesses;
  72950. private _getPostProcesses;
  72951. private _singleInstance;
  72952. private _cameras;
  72953. private _indicesForCamera;
  72954. /**
  72955. * Name of the effect
  72956. * @hidden
  72957. */
  72958. _name: string;
  72959. /**
  72960. * Instantiates a post process render effect.
  72961. * A post process can be used to apply a shader to a texture after it is rendered.
  72962. * @param engine The engine the effect is tied to
  72963. * @param name The name of the effect
  72964. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  72965. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  72966. */
  72967. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  72968. /**
  72969. * Checks if all the post processes in the effect are supported.
  72970. */
  72971. get isSupported(): boolean;
  72972. /**
  72973. * Updates the current state of the effect
  72974. * @hidden
  72975. */
  72976. _update(): void;
  72977. /**
  72978. * Attaches the effect on cameras
  72979. * @param cameras The camera to attach to.
  72980. * @hidden
  72981. */
  72982. _attachCameras(cameras: Camera): void;
  72983. /**
  72984. * Attaches the effect on cameras
  72985. * @param cameras The camera to attach to.
  72986. * @hidden
  72987. */
  72988. _attachCameras(cameras: Camera[]): void;
  72989. /**
  72990. * Detaches the effect on cameras
  72991. * @param cameras The camera to detatch from.
  72992. * @hidden
  72993. */
  72994. _detachCameras(cameras: Camera): void;
  72995. /**
  72996. * Detatches the effect on cameras
  72997. * @param cameras The camera to detatch from.
  72998. * @hidden
  72999. */
  73000. _detachCameras(cameras: Camera[]): void;
  73001. /**
  73002. * Enables the effect on given cameras
  73003. * @param cameras The camera to enable.
  73004. * @hidden
  73005. */
  73006. _enable(cameras: Camera): void;
  73007. /**
  73008. * Enables the effect on given cameras
  73009. * @param cameras The camera to enable.
  73010. * @hidden
  73011. */
  73012. _enable(cameras: Nullable<Camera[]>): void;
  73013. /**
  73014. * Disables the effect on the given cameras
  73015. * @param cameras The camera to disable.
  73016. * @hidden
  73017. */
  73018. _disable(cameras: Camera): void;
  73019. /**
  73020. * Disables the effect on the given cameras
  73021. * @param cameras The camera to disable.
  73022. * @hidden
  73023. */
  73024. _disable(cameras: Nullable<Camera[]>): void;
  73025. /**
  73026. * Gets a list of the post processes contained in the effect.
  73027. * @param camera The camera to get the post processes on.
  73028. * @returns The list of the post processes in the effect.
  73029. */
  73030. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  73031. }
  73032. }
  73033. declare module "babylonjs/Shaders/extractHighlights.fragment" {
  73034. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73035. /** @hidden */
  73036. export var extractHighlightsPixelShader: {
  73037. name: string;
  73038. shader: string;
  73039. };
  73040. }
  73041. declare module "babylonjs/PostProcesses/extractHighlightsPostProcess" {
  73042. import { Nullable } from "babylonjs/types";
  73043. import { Camera } from "babylonjs/Cameras/camera";
  73044. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73045. import { Engine } from "babylonjs/Engines/engine";
  73046. import "babylonjs/Shaders/extractHighlights.fragment";
  73047. /**
  73048. * 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.
  73049. */
  73050. export class ExtractHighlightsPostProcess extends PostProcess {
  73051. /**
  73052. * The luminance threshold, pixels below this value will be set to black.
  73053. */
  73054. threshold: number;
  73055. /** @hidden */
  73056. _exposure: number;
  73057. /**
  73058. * Post process which has the input texture to be used when performing highlight extraction
  73059. * @hidden
  73060. */
  73061. _inputPostProcess: Nullable<PostProcess>;
  73062. /**
  73063. * Gets a string identifying the name of the class
  73064. * @returns "ExtractHighlightsPostProcess" string
  73065. */
  73066. getClassName(): string;
  73067. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73068. }
  73069. }
  73070. declare module "babylonjs/Shaders/bloomMerge.fragment" {
  73071. /** @hidden */
  73072. export var bloomMergePixelShader: {
  73073. name: string;
  73074. shader: string;
  73075. };
  73076. }
  73077. declare module "babylonjs/PostProcesses/bloomMergePostProcess" {
  73078. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73079. import { Nullable } from "babylonjs/types";
  73080. import { Engine } from "babylonjs/Engines/engine";
  73081. import { Camera } from "babylonjs/Cameras/camera";
  73082. import "babylonjs/Shaders/bloomMerge.fragment";
  73083. /**
  73084. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73085. */
  73086. export class BloomMergePostProcess extends PostProcess {
  73087. /** Weight of the bloom to be added to the original input. */
  73088. weight: number;
  73089. /**
  73090. * Gets a string identifying the name of the class
  73091. * @returns "BloomMergePostProcess" string
  73092. */
  73093. getClassName(): string;
  73094. /**
  73095. * Creates a new instance of @see BloomMergePostProcess
  73096. * @param name The name of the effect.
  73097. * @param originalFromInput Post process which's input will be used for the merge.
  73098. * @param blurred Blurred highlights post process which's output will be used.
  73099. * @param weight Weight of the bloom to be added to the original input.
  73100. * @param options The required width/height ratio to downsize to before computing the render pass.
  73101. * @param camera The camera to apply the render pass to.
  73102. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73103. * @param engine The engine which the post process will be applied. (default: current engine)
  73104. * @param reusable If the post process can be reused on the same frame. (default: false)
  73105. * @param textureType Type of textures used when performing the post process. (default: 0)
  73106. * @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)
  73107. */
  73108. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  73109. /** Weight of the bloom to be added to the original input. */
  73110. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73111. }
  73112. }
  73113. declare module "babylonjs/PostProcesses/bloomEffect" {
  73114. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73115. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73116. import { ExtractHighlightsPostProcess } from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  73117. import { Camera } from "babylonjs/Cameras/camera";
  73118. import { Scene } from "babylonjs/scene";
  73119. /**
  73120. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  73121. */
  73122. export class BloomEffect extends PostProcessRenderEffect {
  73123. private bloomScale;
  73124. /**
  73125. * @hidden Internal
  73126. */
  73127. _effects: Array<PostProcess>;
  73128. /**
  73129. * @hidden Internal
  73130. */
  73131. _downscale: ExtractHighlightsPostProcess;
  73132. private _blurX;
  73133. private _blurY;
  73134. private _merge;
  73135. /**
  73136. * The luminance threshold to find bright areas of the image to bloom.
  73137. */
  73138. get threshold(): number;
  73139. set threshold(value: number);
  73140. /**
  73141. * The strength of the bloom.
  73142. */
  73143. get weight(): number;
  73144. set weight(value: number);
  73145. /**
  73146. * Specifies the size of the bloom blur kernel, relative to the final output size
  73147. */
  73148. get kernel(): number;
  73149. set kernel(value: number);
  73150. /**
  73151. * Creates a new instance of @see BloomEffect
  73152. * @param scene The scene the effect belongs to.
  73153. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  73154. * @param bloomKernel The size of the kernel to be used when applying the blur.
  73155. * @param bloomWeight The the strength of bloom.
  73156. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73157. * @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)
  73158. */
  73159. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  73160. /**
  73161. * Disposes each of the internal effects for a given camera.
  73162. * @param camera The camera to dispose the effect on.
  73163. */
  73164. disposeEffects(camera: Camera): void;
  73165. /**
  73166. * @hidden Internal
  73167. */
  73168. _updateEffects(): void;
  73169. /**
  73170. * Internal
  73171. * @returns if all the contained post processes are ready.
  73172. * @hidden
  73173. */
  73174. _isReady(): boolean;
  73175. }
  73176. }
  73177. declare module "babylonjs/Shaders/chromaticAberration.fragment" {
  73178. /** @hidden */
  73179. export var chromaticAberrationPixelShader: {
  73180. name: string;
  73181. shader: string;
  73182. };
  73183. }
  73184. declare module "babylonjs/PostProcesses/chromaticAberrationPostProcess" {
  73185. import { Vector2 } from "babylonjs/Maths/math.vector";
  73186. import { Nullable } from "babylonjs/types";
  73187. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73188. import { Camera } from "babylonjs/Cameras/camera";
  73189. import { Engine } from "babylonjs/Engines/engine";
  73190. import "babylonjs/Shaders/chromaticAberration.fragment";
  73191. import { Scene } from "babylonjs/scene";
  73192. /**
  73193. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  73194. */
  73195. export class ChromaticAberrationPostProcess extends PostProcess {
  73196. /**
  73197. * The amount of seperation of rgb channels (default: 30)
  73198. */
  73199. aberrationAmount: number;
  73200. /**
  73201. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  73202. */
  73203. radialIntensity: number;
  73204. /**
  73205. * 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))
  73206. */
  73207. direction: Vector2;
  73208. /**
  73209. * 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))
  73210. */
  73211. centerPosition: Vector2;
  73212. /** The width of the screen to apply the effect on */
  73213. screenWidth: number;
  73214. /** The height of the screen to apply the effect on */
  73215. screenHeight: number;
  73216. /**
  73217. * Gets a string identifying the name of the class
  73218. * @returns "ChromaticAberrationPostProcess" string
  73219. */
  73220. getClassName(): string;
  73221. /**
  73222. * Creates a new instance ChromaticAberrationPostProcess
  73223. * @param name The name of the effect.
  73224. * @param screenWidth The width of the screen to apply the effect on.
  73225. * @param screenHeight The height of the screen to apply the effect on.
  73226. * @param options The required width/height ratio to downsize to before computing the render pass.
  73227. * @param camera The camera to apply the render pass to.
  73228. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73229. * @param engine The engine which the post process will be applied. (default: current engine)
  73230. * @param reusable If the post process can be reused on the same frame. (default: false)
  73231. * @param textureType Type of textures used when performing the post process. (default: 0)
  73232. * @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)
  73233. */
  73234. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73235. /** @hidden */
  73236. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  73237. }
  73238. }
  73239. declare module "babylonjs/Shaders/circleOfConfusion.fragment" {
  73240. /** @hidden */
  73241. export var circleOfConfusionPixelShader: {
  73242. name: string;
  73243. shader: string;
  73244. };
  73245. }
  73246. declare module "babylonjs/PostProcesses/circleOfConfusionPostProcess" {
  73247. import { Nullable } from "babylonjs/types";
  73248. import { Engine } from "babylonjs/Engines/engine";
  73249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73250. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73251. import { Camera } from "babylonjs/Cameras/camera";
  73252. import "babylonjs/Shaders/circleOfConfusion.fragment";
  73253. /**
  73254. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  73255. */
  73256. export class CircleOfConfusionPostProcess extends PostProcess {
  73257. /**
  73258. * 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.
  73259. */
  73260. lensSize: number;
  73261. /**
  73262. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73263. */
  73264. fStop: number;
  73265. /**
  73266. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73267. */
  73268. focusDistance: number;
  73269. /**
  73270. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  73271. */
  73272. focalLength: number;
  73273. /**
  73274. * Gets a string identifying the name of the class
  73275. * @returns "CircleOfConfusionPostProcess" string
  73276. */
  73277. getClassName(): string;
  73278. private _depthTexture;
  73279. /**
  73280. * Creates a new instance CircleOfConfusionPostProcess
  73281. * @param name The name of the effect.
  73282. * @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.
  73283. * @param options The required width/height ratio to downsize to before computing the render pass.
  73284. * @param camera The camera to apply the render pass to.
  73285. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73286. * @param engine The engine which the post process will be applied. (default: current engine)
  73287. * @param reusable If the post process can be reused on the same frame. (default: false)
  73288. * @param textureType Type of textures used when performing the post process. (default: 0)
  73289. * @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)
  73290. */
  73291. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73292. /**
  73293. * 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.
  73294. */
  73295. set depthTexture(value: RenderTargetTexture);
  73296. }
  73297. }
  73298. declare module "babylonjs/Shaders/colorCorrection.fragment" {
  73299. /** @hidden */
  73300. export var colorCorrectionPixelShader: {
  73301. name: string;
  73302. shader: string;
  73303. };
  73304. }
  73305. declare module "babylonjs/PostProcesses/colorCorrectionPostProcess" {
  73306. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73307. import { Engine } from "babylonjs/Engines/engine";
  73308. import { Camera } from "babylonjs/Cameras/camera";
  73309. import "babylonjs/Shaders/colorCorrection.fragment";
  73310. import { Nullable } from "babylonjs/types";
  73311. import { Scene } from "babylonjs/scene";
  73312. /**
  73313. *
  73314. * This post-process allows the modification of rendered colors by using
  73315. * a 'look-up table' (LUT). This effect is also called Color Grading.
  73316. *
  73317. * The object needs to be provided an url to a texture containing the color
  73318. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  73319. * Use an image editing software to tweak the LUT to match your needs.
  73320. *
  73321. * For an example of a color LUT, see here:
  73322. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  73323. * For explanations on color grading, see here:
  73324. * @see http://udn.epicgames.com/Three/ColorGrading.html
  73325. *
  73326. */
  73327. export class ColorCorrectionPostProcess extends PostProcess {
  73328. private _colorTableTexture;
  73329. /**
  73330. * Gets the color table url used to create the LUT texture
  73331. */
  73332. colorTableUrl: string;
  73333. /**
  73334. * Gets a string identifying the name of the class
  73335. * @returns "ColorCorrectionPostProcess" string
  73336. */
  73337. getClassName(): string;
  73338. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73339. /** @hidden */
  73340. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  73341. }
  73342. }
  73343. declare module "babylonjs/Shaders/convolution.fragment" {
  73344. /** @hidden */
  73345. export var convolutionPixelShader: {
  73346. name: string;
  73347. shader: string;
  73348. };
  73349. }
  73350. declare module "babylonjs/PostProcesses/convolutionPostProcess" {
  73351. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73352. import { Nullable } from "babylonjs/types";
  73353. import { Camera } from "babylonjs/Cameras/camera";
  73354. import { Engine } from "babylonjs/Engines/engine";
  73355. import "babylonjs/Shaders/convolution.fragment";
  73356. import { Scene } from "babylonjs/scene";
  73357. /**
  73358. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  73359. * input texture to perform effects such as edge detection or sharpening
  73360. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  73361. */
  73362. export class ConvolutionPostProcess extends PostProcess {
  73363. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  73364. kernel: number[];
  73365. /**
  73366. * Gets a string identifying the name of the class
  73367. * @returns "ConvolutionPostProcess" string
  73368. */
  73369. getClassName(): string;
  73370. /**
  73371. * Creates a new instance ConvolutionPostProcess
  73372. * @param name The name of the effect.
  73373. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  73374. * @param options The required width/height ratio to downsize to before computing the render pass.
  73375. * @param camera The camera to apply the render pass to.
  73376. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73377. * @param engine The engine which the post process will be applied. (default: current engine)
  73378. * @param reusable If the post process can be reused on the same frame. (default: false)
  73379. * @param textureType Type of textures used when performing the post process. (default: 0)
  73380. */
  73381. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73382. /** @hidden */
  73383. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  73384. /**
  73385. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73386. */
  73387. static EdgeDetect0Kernel: number[];
  73388. /**
  73389. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73390. */
  73391. static EdgeDetect1Kernel: number[];
  73392. /**
  73393. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73394. */
  73395. static EdgeDetect2Kernel: number[];
  73396. /**
  73397. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73398. */
  73399. static SharpenKernel: number[];
  73400. /**
  73401. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73402. */
  73403. static EmbossKernel: number[];
  73404. /**
  73405. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  73406. */
  73407. static GaussianKernel: number[];
  73408. }
  73409. }
  73410. declare module "babylonjs/PostProcesses/depthOfFieldBlurPostProcess" {
  73411. import { Nullable } from "babylonjs/types";
  73412. import { Vector2 } from "babylonjs/Maths/math.vector";
  73413. import { Camera } from "babylonjs/Cameras/camera";
  73414. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73415. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  73416. import { Engine } from "babylonjs/Engines/engine";
  73417. import { Scene } from "babylonjs/scene";
  73418. /**
  73419. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  73420. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  73421. * based on samples that have a large difference in distance than the center pixel.
  73422. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  73423. */
  73424. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  73425. /**
  73426. * The direction the blur should be applied
  73427. */
  73428. direction: Vector2;
  73429. /**
  73430. * Gets a string identifying the name of the class
  73431. * @returns "DepthOfFieldBlurPostProcess" string
  73432. */
  73433. getClassName(): string;
  73434. /**
  73435. * Creates a new instance CircleOfConfusionPostProcess
  73436. * @param name The name of the effect.
  73437. * @param scene The scene the effect belongs to.
  73438. * @param direction The direction the blur should be applied.
  73439. * @param kernel The size of the kernel used to blur.
  73440. * @param options The required width/height ratio to downsize to before computing the render pass.
  73441. * @param camera The camera to apply the render pass to.
  73442. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  73443. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  73444. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73445. * @param engine The engine which the post process will be applied. (default: current engine)
  73446. * @param reusable If the post process can be reused on the same frame. (default: false)
  73447. * @param textureType Type of textures used when performing the post process. (default: 0)
  73448. * @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)
  73449. */
  73450. 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);
  73451. }
  73452. }
  73453. declare module "babylonjs/Shaders/depthOfFieldMerge.fragment" {
  73454. /** @hidden */
  73455. export var depthOfFieldMergePixelShader: {
  73456. name: string;
  73457. shader: string;
  73458. };
  73459. }
  73460. declare module "babylonjs/PostProcesses/depthOfFieldMergePostProcess" {
  73461. import { Nullable } from "babylonjs/types";
  73462. import { Camera } from "babylonjs/Cameras/camera";
  73463. import { Effect } from "babylonjs/Materials/effect";
  73464. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73465. import { Engine } from "babylonjs/Engines/engine";
  73466. import "babylonjs/Shaders/depthOfFieldMerge.fragment";
  73467. /**
  73468. * Options to be set when merging outputs from the default pipeline.
  73469. */
  73470. export class DepthOfFieldMergePostProcessOptions {
  73471. /**
  73472. * The original image to merge on top of
  73473. */
  73474. originalFromInput: PostProcess;
  73475. /**
  73476. * Parameters to perform the merge of the depth of field effect
  73477. */
  73478. depthOfField?: {
  73479. circleOfConfusion: PostProcess;
  73480. blurSteps: Array<PostProcess>;
  73481. };
  73482. /**
  73483. * Parameters to perform the merge of bloom effect
  73484. */
  73485. bloom?: {
  73486. blurred: PostProcess;
  73487. weight: number;
  73488. };
  73489. }
  73490. /**
  73491. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  73492. */
  73493. export class DepthOfFieldMergePostProcess extends PostProcess {
  73494. private blurSteps;
  73495. /**
  73496. * Gets a string identifying the name of the class
  73497. * @returns "DepthOfFieldMergePostProcess" string
  73498. */
  73499. getClassName(): string;
  73500. /**
  73501. * Creates a new instance of DepthOfFieldMergePostProcess
  73502. * @param name The name of the effect.
  73503. * @param originalFromInput Post process which's input will be used for the merge.
  73504. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  73505. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  73506. * @param options The required width/height ratio to downsize to before computing the render pass.
  73507. * @param camera The camera to apply the render pass to.
  73508. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73509. * @param engine The engine which the post process will be applied. (default: current engine)
  73510. * @param reusable If the post process can be reused on the same frame. (default: false)
  73511. * @param textureType Type of textures used when performing the post process. (default: 0)
  73512. * @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)
  73513. */
  73514. 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);
  73515. /**
  73516. * Updates the effect with the current post process compile time values and recompiles the shader.
  73517. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  73518. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  73519. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  73520. * @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
  73521. * @param onCompiled Called when the shader has been compiled.
  73522. * @param onError Called if there is an error when compiling a shader.
  73523. */
  73524. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  73525. }
  73526. }
  73527. declare module "babylonjs/PostProcesses/depthOfFieldEffect" {
  73528. import { Nullable } from "babylonjs/types";
  73529. import { Camera } from "babylonjs/Cameras/camera";
  73530. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  73531. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  73532. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  73533. import { DepthOfFieldBlurPostProcess } from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  73534. import { Scene } from "babylonjs/scene";
  73535. /**
  73536. * Specifies the level of max blur that should be applied when using the depth of field effect
  73537. */
  73538. export enum DepthOfFieldEffectBlurLevel {
  73539. /**
  73540. * Subtle blur
  73541. */
  73542. Low = 0,
  73543. /**
  73544. * Medium blur
  73545. */
  73546. Medium = 1,
  73547. /**
  73548. * Large blur
  73549. */
  73550. High = 2
  73551. }
  73552. /**
  73553. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  73554. */
  73555. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  73556. private _circleOfConfusion;
  73557. /**
  73558. * @hidden Internal, blurs from high to low
  73559. */
  73560. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  73561. private _depthOfFieldBlurY;
  73562. private _dofMerge;
  73563. /**
  73564. * @hidden Internal post processes in depth of field effect
  73565. */
  73566. _effects: Array<PostProcess>;
  73567. /**
  73568. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  73569. */
  73570. set focalLength(value: number);
  73571. get focalLength(): number;
  73572. /**
  73573. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  73574. */
  73575. set fStop(value: number);
  73576. get fStop(): number;
  73577. /**
  73578. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  73579. */
  73580. set focusDistance(value: number);
  73581. get focusDistance(): number;
  73582. /**
  73583. * 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.
  73584. */
  73585. set lensSize(value: number);
  73586. get lensSize(): number;
  73587. /**
  73588. * Creates a new instance DepthOfFieldEffect
  73589. * @param scene The scene the effect belongs to.
  73590. * @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.
  73591. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  73592. * @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)
  73593. */
  73594. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  73595. /**
  73596. * Get the current class name of the current effet
  73597. * @returns "DepthOfFieldEffect"
  73598. */
  73599. getClassName(): string;
  73600. /**
  73601. * 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.
  73602. */
  73603. set depthTexture(value: RenderTargetTexture);
  73604. /**
  73605. * Disposes each of the internal effects for a given camera.
  73606. * @param camera The camera to dispose the effect on.
  73607. */
  73608. disposeEffects(camera: Camera): void;
  73609. /**
  73610. * @hidden Internal
  73611. */
  73612. _updateEffects(): void;
  73613. /**
  73614. * Internal
  73615. * @returns if all the contained post processes are ready.
  73616. * @hidden
  73617. */
  73618. _isReady(): boolean;
  73619. }
  73620. }
  73621. declare module "babylonjs/Shaders/displayPass.fragment" {
  73622. /** @hidden */
  73623. export var displayPassPixelShader: {
  73624. name: string;
  73625. shader: string;
  73626. };
  73627. }
  73628. declare module "babylonjs/PostProcesses/displayPassPostProcess" {
  73629. import { Nullable } from "babylonjs/types";
  73630. import { Camera } from "babylonjs/Cameras/camera";
  73631. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73632. import { Engine } from "babylonjs/Engines/engine";
  73633. import "babylonjs/Shaders/displayPass.fragment";
  73634. import { Scene } from "babylonjs/scene";
  73635. /**
  73636. * DisplayPassPostProcess which produces an output the same as it's input
  73637. */
  73638. export class DisplayPassPostProcess extends PostProcess {
  73639. /**
  73640. * Gets a string identifying the name of the class
  73641. * @returns "DisplayPassPostProcess" string
  73642. */
  73643. getClassName(): string;
  73644. /**
  73645. * Creates the DisplayPassPostProcess
  73646. * @param name The name of the effect.
  73647. * @param options The required width/height ratio to downsize to before computing the render pass.
  73648. * @param camera The camera to apply the render pass to.
  73649. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73650. * @param engine The engine which the post process will be applied. (default: current engine)
  73651. * @param reusable If the post process can be reused on the same frame. (default: false)
  73652. */
  73653. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73654. /** @hidden */
  73655. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  73656. }
  73657. }
  73658. declare module "babylonjs/Shaders/filter.fragment" {
  73659. /** @hidden */
  73660. export var filterPixelShader: {
  73661. name: string;
  73662. shader: string;
  73663. };
  73664. }
  73665. declare module "babylonjs/PostProcesses/filterPostProcess" {
  73666. import { Nullable } from "babylonjs/types";
  73667. import { Matrix } from "babylonjs/Maths/math.vector";
  73668. import { Camera } from "babylonjs/Cameras/camera";
  73669. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73670. import { Engine } from "babylonjs/Engines/engine";
  73671. import "babylonjs/Shaders/filter.fragment";
  73672. import { Scene } from "babylonjs/scene";
  73673. /**
  73674. * Applies a kernel filter to the image
  73675. */
  73676. export class FilterPostProcess extends PostProcess {
  73677. /** The matrix to be applied to the image */
  73678. kernelMatrix: Matrix;
  73679. /**
  73680. * Gets a string identifying the name of the class
  73681. * @returns "FilterPostProcess" string
  73682. */
  73683. getClassName(): string;
  73684. /**
  73685. *
  73686. * @param name The name of the effect.
  73687. * @param kernelMatrix The matrix to be applied to the image
  73688. * @param options The required width/height ratio to downsize to before computing the render pass.
  73689. * @param camera The camera to apply the render pass to.
  73690. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73691. * @param engine The engine which the post process will be applied. (default: current engine)
  73692. * @param reusable If the post process can be reused on the same frame. (default: false)
  73693. */
  73694. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  73695. /** @hidden */
  73696. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  73697. }
  73698. }
  73699. declare module "babylonjs/Shaders/fxaa.fragment" {
  73700. /** @hidden */
  73701. export var fxaaPixelShader: {
  73702. name: string;
  73703. shader: string;
  73704. };
  73705. }
  73706. declare module "babylonjs/Shaders/fxaa.vertex" {
  73707. /** @hidden */
  73708. export var fxaaVertexShader: {
  73709. name: string;
  73710. shader: string;
  73711. };
  73712. }
  73713. declare module "babylonjs/PostProcesses/fxaaPostProcess" {
  73714. import { Nullable } from "babylonjs/types";
  73715. import { Camera } from "babylonjs/Cameras/camera";
  73716. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73717. import { Engine } from "babylonjs/Engines/engine";
  73718. import "babylonjs/Shaders/fxaa.fragment";
  73719. import "babylonjs/Shaders/fxaa.vertex";
  73720. import { Scene } from "babylonjs/scene";
  73721. /**
  73722. * Fxaa post process
  73723. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  73724. */
  73725. export class FxaaPostProcess extends PostProcess {
  73726. /**
  73727. * Gets a string identifying the name of the class
  73728. * @returns "FxaaPostProcess" string
  73729. */
  73730. getClassName(): string;
  73731. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73732. private _getDefines;
  73733. /** @hidden */
  73734. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  73735. }
  73736. }
  73737. declare module "babylonjs/Shaders/grain.fragment" {
  73738. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  73739. /** @hidden */
  73740. export var grainPixelShader: {
  73741. name: string;
  73742. shader: string;
  73743. };
  73744. }
  73745. declare module "babylonjs/PostProcesses/grainPostProcess" {
  73746. import { Nullable } from "babylonjs/types";
  73747. import { Camera } from "babylonjs/Cameras/camera";
  73748. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73749. import { Engine } from "babylonjs/Engines/engine";
  73750. import "babylonjs/Shaders/grain.fragment";
  73751. import { Scene } from "babylonjs/scene";
  73752. /**
  73753. * The GrainPostProcess adds noise to the image at mid luminance levels
  73754. */
  73755. export class GrainPostProcess extends PostProcess {
  73756. /**
  73757. * The intensity of the grain added (default: 30)
  73758. */
  73759. intensity: number;
  73760. /**
  73761. * If the grain should be randomized on every frame
  73762. */
  73763. animated: boolean;
  73764. /**
  73765. * Gets a string identifying the name of the class
  73766. * @returns "GrainPostProcess" string
  73767. */
  73768. getClassName(): string;
  73769. /**
  73770. * Creates a new instance of @see GrainPostProcess
  73771. * @param name The name of the effect.
  73772. * @param options The required width/height ratio to downsize to before computing the render pass.
  73773. * @param camera The camera to apply the render pass to.
  73774. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73775. * @param engine The engine which the post process will be applied. (default: current engine)
  73776. * @param reusable If the post process can be reused on the same frame. (default: false)
  73777. * @param textureType Type of textures used when performing the post process. (default: 0)
  73778. * @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)
  73779. */
  73780. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  73781. /** @hidden */
  73782. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  73783. }
  73784. }
  73785. declare module "babylonjs/Shaders/highlights.fragment" {
  73786. /** @hidden */
  73787. export var highlightsPixelShader: {
  73788. name: string;
  73789. shader: string;
  73790. };
  73791. }
  73792. declare module "babylonjs/PostProcesses/highlightsPostProcess" {
  73793. import { Nullable } from "babylonjs/types";
  73794. import { Camera } from "babylonjs/Cameras/camera";
  73795. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  73796. import { Engine } from "babylonjs/Engines/engine";
  73797. import "babylonjs/Shaders/highlights.fragment";
  73798. /**
  73799. * Extracts highlights from the image
  73800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73801. */
  73802. export class HighlightsPostProcess extends PostProcess {
  73803. /**
  73804. * Gets a string identifying the name of the class
  73805. * @returns "HighlightsPostProcess" string
  73806. */
  73807. getClassName(): string;
  73808. /**
  73809. * Extracts highlights from the image
  73810. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  73811. * @param name The name of the effect.
  73812. * @param options The required width/height ratio to downsize to before computing the render pass.
  73813. * @param camera The camera to apply the render pass to.
  73814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  73815. * @param engine The engine which the post process will be applied. (default: current engine)
  73816. * @param reusable If the post process can be reused on the same frame. (default: false)
  73817. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  73818. */
  73819. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  73820. }
  73821. }
  73822. declare module "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration" {
  73823. /** @hidden */
  73824. export var mrtFragmentDeclaration: {
  73825. name: string;
  73826. shader: string;
  73827. };
  73828. }
  73829. declare module "babylonjs/Shaders/geometry.fragment" {
  73830. import "babylonjs/Shaders/ShadersInclude/mrtFragmentDeclaration";
  73831. import "babylonjs/Shaders/ShadersInclude/bumpFragmentMainFunctions";
  73832. import "babylonjs/Shaders/ShadersInclude/bumpFragmentFunctions";
  73833. import "babylonjs/Shaders/ShadersInclude/bumpFragment";
  73834. /** @hidden */
  73835. export var geometryPixelShader: {
  73836. name: string;
  73837. shader: string;
  73838. };
  73839. }
  73840. declare module "babylonjs/Shaders/geometry.vertex" {
  73841. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  73842. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  73843. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  73844. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  73845. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  73846. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  73847. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  73848. import "babylonjs/Shaders/ShadersInclude/bumpVertex";
  73849. /** @hidden */
  73850. export var geometryVertexShader: {
  73851. name: string;
  73852. shader: string;
  73853. };
  73854. }
  73855. declare module "babylonjs/Rendering/geometryBufferRenderer" {
  73856. import { Matrix } from "babylonjs/Maths/math.vector";
  73857. import { SubMesh } from "babylonjs/Meshes/subMesh";
  73858. import { Mesh } from "babylonjs/Meshes/mesh";
  73859. import { MultiRenderTarget } from "babylonjs/Materials/Textures/multiRenderTarget";
  73860. import { Effect } from "babylonjs/Materials/effect";
  73861. import { Scene } from "babylonjs/scene";
  73862. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  73863. import "babylonjs/Shaders/geometry.fragment";
  73864. import "babylonjs/Shaders/geometry.vertex";
  73865. /** @hidden */
  73866. interface ISavedTransformationMatrix {
  73867. world: Matrix;
  73868. viewProjection: Matrix;
  73869. }
  73870. /**
  73871. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  73872. */
  73873. export class GeometryBufferRenderer {
  73874. /**
  73875. * Constant used to retrieve the position texture index in the G-Buffer textures array
  73876. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  73877. */
  73878. static readonly POSITION_TEXTURE_TYPE: number;
  73879. /**
  73880. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  73881. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  73882. */
  73883. static readonly VELOCITY_TEXTURE_TYPE: number;
  73884. /**
  73885. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  73886. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  73887. */
  73888. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  73889. /**
  73890. * Dictionary used to store the previous transformation matrices of each rendered mesh
  73891. * in order to compute objects velocities when enableVelocity is set to "true"
  73892. * @hidden
  73893. */
  73894. _previousTransformationMatrices: {
  73895. [index: number]: ISavedTransformationMatrix;
  73896. };
  73897. /**
  73898. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  73899. * in order to compute objects velocities when enableVelocity is set to "true"
  73900. * @hidden
  73901. */
  73902. _previousBonesTransformationMatrices: {
  73903. [index: number]: Float32Array;
  73904. };
  73905. /**
  73906. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  73907. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  73908. */
  73909. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  73910. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  73911. renderTransparentMeshes: boolean;
  73912. private _scene;
  73913. private _resizeObserver;
  73914. private _multiRenderTarget;
  73915. private _ratio;
  73916. private _enablePosition;
  73917. private _enableVelocity;
  73918. private _enableReflectivity;
  73919. private _positionIndex;
  73920. private _velocityIndex;
  73921. private _reflectivityIndex;
  73922. protected _effect: Effect;
  73923. protected _cachedDefines: string;
  73924. /**
  73925. * Set the render list (meshes to be rendered) used in the G buffer.
  73926. */
  73927. set renderList(meshes: Mesh[]);
  73928. /**
  73929. * Gets wether or not G buffer are supported by the running hardware.
  73930. * This requires draw buffer supports
  73931. */
  73932. get isSupported(): boolean;
  73933. /**
  73934. * Returns the index of the given texture type in the G-Buffer textures array
  73935. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  73936. * @returns the index of the given texture type in the G-Buffer textures array
  73937. */
  73938. getTextureIndex(textureType: number): number;
  73939. /**
  73940. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  73941. */
  73942. get enablePosition(): boolean;
  73943. /**
  73944. * Sets whether or not objects positions are enabled for the G buffer.
  73945. */
  73946. set enablePosition(enable: boolean);
  73947. /**
  73948. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  73949. */
  73950. get enableVelocity(): boolean;
  73951. /**
  73952. * Sets wether or not objects velocities are enabled for the G buffer.
  73953. */
  73954. set enableVelocity(enable: boolean);
  73955. /**
  73956. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  73957. */
  73958. get enableReflectivity(): boolean;
  73959. /**
  73960. * Sets wether or not objects roughness are enabled for the G buffer.
  73961. */
  73962. set enableReflectivity(enable: boolean);
  73963. /**
  73964. * Gets the scene associated with the buffer.
  73965. */
  73966. get scene(): Scene;
  73967. /**
  73968. * Gets the ratio used by the buffer during its creation.
  73969. * How big is the buffer related to the main canvas.
  73970. */
  73971. get ratio(): number;
  73972. /** @hidden */
  73973. static _SceneComponentInitialization: (scene: Scene) => void;
  73974. /**
  73975. * Creates a new G Buffer for the scene
  73976. * @param scene The scene the buffer belongs to
  73977. * @param ratio How big is the buffer related to the main canvas.
  73978. */
  73979. constructor(scene: Scene, ratio?: number);
  73980. /**
  73981. * Checks wether everything is ready to render a submesh to the G buffer.
  73982. * @param subMesh the submesh to check readiness for
  73983. * @param useInstances is the mesh drawn using instance or not
  73984. * @returns true if ready otherwise false
  73985. */
  73986. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  73987. /**
  73988. * Gets the current underlying G Buffer.
  73989. * @returns the buffer
  73990. */
  73991. getGBuffer(): MultiRenderTarget;
  73992. /**
  73993. * Gets the number of samples used to render the buffer (anti aliasing).
  73994. */
  73995. get samples(): number;
  73996. /**
  73997. * Sets the number of samples used to render the buffer (anti aliasing).
  73998. */
  73999. set samples(value: number);
  74000. /**
  74001. * Disposes the renderer and frees up associated resources.
  74002. */
  74003. dispose(): void;
  74004. protected _createRenderTargets(): void;
  74005. private _copyBonesTransformationMatrices;
  74006. }
  74007. }
  74008. declare module "babylonjs/Rendering/motionBlurConfiguration" {
  74009. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74010. /**
  74011. * Contains all parameters needed for the prepass to perform
  74012. * motion blur
  74013. */
  74014. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  74015. /**
  74016. * Is motion blur enabled
  74017. */
  74018. enabled: boolean;
  74019. /**
  74020. * Name of the configuration
  74021. */
  74022. name: string;
  74023. /**
  74024. * Textures that should be present in the MRT for this effect to work
  74025. */
  74026. readonly texturesRequired: number[];
  74027. }
  74028. }
  74029. declare module "babylonjs/Rendering/geometryBufferRendererSceneComponent" {
  74030. import { Nullable } from "babylonjs/types";
  74031. import { Scene } from "babylonjs/scene";
  74032. import { ISceneComponent } from "babylonjs/sceneComponent";
  74033. import { GeometryBufferRenderer } from "babylonjs/Rendering/geometryBufferRenderer";
  74034. module "babylonjs/scene" {
  74035. interface Scene {
  74036. /** @hidden (Backing field) */
  74037. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74038. /**
  74039. * Gets or Sets the current geometry buffer associated to the scene.
  74040. */
  74041. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  74042. /**
  74043. * Enables a GeometryBufferRender and associates it with the scene
  74044. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  74045. * @returns the GeometryBufferRenderer
  74046. */
  74047. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  74048. /**
  74049. * Disables the GeometryBufferRender associated with the scene
  74050. */
  74051. disableGeometryBufferRenderer(): void;
  74052. }
  74053. }
  74054. /**
  74055. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  74056. * in several rendering techniques.
  74057. */
  74058. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  74059. /**
  74060. * The component name helpful to identify the component in the list of scene components.
  74061. */
  74062. readonly name: string;
  74063. /**
  74064. * The scene the component belongs to.
  74065. */
  74066. scene: Scene;
  74067. /**
  74068. * Creates a new instance of the component for the given scene
  74069. * @param scene Defines the scene to register the component in
  74070. */
  74071. constructor(scene: Scene);
  74072. /**
  74073. * Registers the component in a given scene
  74074. */
  74075. register(): void;
  74076. /**
  74077. * Rebuilds the elements related to this component in case of
  74078. * context lost for instance.
  74079. */
  74080. rebuild(): void;
  74081. /**
  74082. * Disposes the component and the associated ressources
  74083. */
  74084. dispose(): void;
  74085. private _gatherRenderTargets;
  74086. }
  74087. }
  74088. declare module "babylonjs/Shaders/motionBlur.fragment" {
  74089. /** @hidden */
  74090. export var motionBlurPixelShader: {
  74091. name: string;
  74092. shader: string;
  74093. };
  74094. }
  74095. declare module "babylonjs/PostProcesses/motionBlurPostProcess" {
  74096. import { Nullable } from "babylonjs/types";
  74097. import { Camera } from "babylonjs/Cameras/camera";
  74098. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74099. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  74100. import "babylonjs/Animations/animatable";
  74101. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  74102. import "babylonjs/Shaders/motionBlur.fragment";
  74103. import { Engine } from "babylonjs/Engines/engine";
  74104. import { Scene } from "babylonjs/scene";
  74105. /**
  74106. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  74107. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  74108. * As an example, all you have to do is to create the post-process:
  74109. * var mb = new BABYLON.MotionBlurPostProcess(
  74110. * 'mb', // The name of the effect.
  74111. * scene, // The scene containing the objects to blur according to their velocity.
  74112. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  74113. * camera // The camera to apply the render pass to.
  74114. * );
  74115. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  74116. */
  74117. export class MotionBlurPostProcess extends PostProcess {
  74118. /**
  74119. * Defines how much the image is blurred by the movement. Default value is equal to 1
  74120. */
  74121. motionStrength: number;
  74122. /**
  74123. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  74124. */
  74125. get motionBlurSamples(): number;
  74126. /**
  74127. * Sets the number of iterations to be used for motion blur quality
  74128. */
  74129. set motionBlurSamples(samples: number);
  74130. private _motionBlurSamples;
  74131. private _forceGeometryBuffer;
  74132. private _geometryBufferRenderer;
  74133. private _prePassRenderer;
  74134. /**
  74135. * Gets a string identifying the name of the class
  74136. * @returns "MotionBlurPostProcess" string
  74137. */
  74138. getClassName(): string;
  74139. /**
  74140. * Creates a new instance MotionBlurPostProcess
  74141. * @param name The name of the effect.
  74142. * @param scene The scene containing the objects to blur according to their velocity.
  74143. * @param options The required width/height ratio to downsize to before computing the render pass.
  74144. * @param camera The camera to apply the render pass to.
  74145. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74146. * @param engine The engine which the post process will be applied. (default: current engine)
  74147. * @param reusable If the post process can be reused on the same frame. (default: false)
  74148. * @param textureType Type of textures used when performing the post process. (default: 0)
  74149. * @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)
  74150. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  74151. */
  74152. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  74153. /**
  74154. * Excludes the given skinned mesh from computing bones velocities.
  74155. * 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.
  74156. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  74157. */
  74158. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74159. /**
  74160. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  74161. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  74162. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  74163. */
  74164. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  74165. /**
  74166. * Disposes the post process.
  74167. * @param camera The camera to dispose the post process on.
  74168. */
  74169. dispose(camera?: Camera): void;
  74170. /** @hidden */
  74171. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  74172. }
  74173. }
  74174. declare module "babylonjs/Shaders/refraction.fragment" {
  74175. /** @hidden */
  74176. export var refractionPixelShader: {
  74177. name: string;
  74178. shader: string;
  74179. };
  74180. }
  74181. declare module "babylonjs/PostProcesses/refractionPostProcess" {
  74182. import { Color3 } from "babylonjs/Maths/math.color";
  74183. import { Camera } from "babylonjs/Cameras/camera";
  74184. import { Texture } from "babylonjs/Materials/Textures/texture";
  74185. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74186. import { Engine } from "babylonjs/Engines/engine";
  74187. import "babylonjs/Shaders/refraction.fragment";
  74188. import { Scene } from "babylonjs/scene";
  74189. /**
  74190. * Post process which applies a refractin texture
  74191. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74192. */
  74193. export class RefractionPostProcess extends PostProcess {
  74194. private _refTexture;
  74195. private _ownRefractionTexture;
  74196. /** the base color of the refraction (used to taint the rendering) */
  74197. color: Color3;
  74198. /** simulated refraction depth */
  74199. depth: number;
  74200. /** the coefficient of the base color (0 to remove base color tainting) */
  74201. colorLevel: number;
  74202. /** Gets the url used to load the refraction texture */
  74203. refractionTextureUrl: string;
  74204. /**
  74205. * Gets or sets the refraction texture
  74206. * Please note that you are responsible for disposing the texture if you set it manually
  74207. */
  74208. get refractionTexture(): Texture;
  74209. set refractionTexture(value: Texture);
  74210. /**
  74211. * Gets a string identifying the name of the class
  74212. * @returns "RefractionPostProcess" string
  74213. */
  74214. getClassName(): string;
  74215. /**
  74216. * Initializes the RefractionPostProcess
  74217. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  74218. * @param name The name of the effect.
  74219. * @param refractionTextureUrl Url of the refraction texture to use
  74220. * @param color the base color of the refraction (used to taint the rendering)
  74221. * @param depth simulated refraction depth
  74222. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  74223. * @param camera The camera to apply the render pass to.
  74224. * @param options The required width/height ratio to downsize to before computing the render pass.
  74225. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74226. * @param engine The engine which the post process will be applied. (default: current engine)
  74227. * @param reusable If the post process can be reused on the same frame. (default: false)
  74228. */
  74229. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  74230. /**
  74231. * Disposes of the post process
  74232. * @param camera Camera to dispose post process on
  74233. */
  74234. dispose(camera: Camera): void;
  74235. /** @hidden */
  74236. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  74237. }
  74238. }
  74239. declare module "babylonjs/Shaders/sharpen.fragment" {
  74240. /** @hidden */
  74241. export var sharpenPixelShader: {
  74242. name: string;
  74243. shader: string;
  74244. };
  74245. }
  74246. declare module "babylonjs/PostProcesses/sharpenPostProcess" {
  74247. import { Nullable } from "babylonjs/types";
  74248. import { Camera } from "babylonjs/Cameras/camera";
  74249. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  74250. import "babylonjs/Shaders/sharpen.fragment";
  74251. import { Engine } from "babylonjs/Engines/engine";
  74252. import { Scene } from "babylonjs/scene";
  74253. /**
  74254. * The SharpenPostProcess applies a sharpen kernel to every pixel
  74255. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  74256. */
  74257. export class SharpenPostProcess extends PostProcess {
  74258. /**
  74259. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  74260. */
  74261. colorAmount: number;
  74262. /**
  74263. * How much sharpness should be applied (default: 0.3)
  74264. */
  74265. edgeAmount: number;
  74266. /**
  74267. * Gets a string identifying the name of the class
  74268. * @returns "SharpenPostProcess" string
  74269. */
  74270. getClassName(): string;
  74271. /**
  74272. * Creates a new instance ConvolutionPostProcess
  74273. * @param name The name of the effect.
  74274. * @param options The required width/height ratio to downsize to before computing the render pass.
  74275. * @param camera The camera to apply the render pass to.
  74276. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  74277. * @param engine The engine which the post process will be applied. (default: current engine)
  74278. * @param reusable If the post process can be reused on the same frame. (default: false)
  74279. * @param textureType Type of textures used when performing the post process. (default: 0)
  74280. * @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)
  74281. */
  74282. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  74283. /** @hidden */
  74284. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  74285. }
  74286. }
  74287. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline" {
  74288. import { Nullable } from "babylonjs/types";
  74289. import { Camera } from "babylonjs/Cameras/camera";
  74290. import { Engine } from "babylonjs/Engines/engine";
  74291. import { PostProcessRenderEffect } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  74292. import { IInspectable } from "babylonjs/Misc/iInspectable";
  74293. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  74294. /**
  74295. * PostProcessRenderPipeline
  74296. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74297. */
  74298. export class PostProcessRenderPipeline {
  74299. private engine;
  74300. private _renderEffects;
  74301. private _renderEffectsForIsolatedPass;
  74302. /**
  74303. * List of inspectable custom properties (used by the Inspector)
  74304. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  74305. */
  74306. inspectableCustomProperties: IInspectable[];
  74307. /**
  74308. * @hidden
  74309. */
  74310. protected _cameras: Camera[];
  74311. /** @hidden */
  74312. _name: string;
  74313. /**
  74314. * Gets pipeline name
  74315. */
  74316. get name(): string;
  74317. /** Gets the list of attached cameras */
  74318. get cameras(): Camera[];
  74319. /**
  74320. * Initializes a PostProcessRenderPipeline
  74321. * @param engine engine to add the pipeline to
  74322. * @param name name of the pipeline
  74323. */
  74324. constructor(engine: Engine, name: string);
  74325. /**
  74326. * Gets the class name
  74327. * @returns "PostProcessRenderPipeline"
  74328. */
  74329. getClassName(): string;
  74330. /**
  74331. * If all the render effects in the pipeline are supported
  74332. */
  74333. get isSupported(): boolean;
  74334. /**
  74335. * Adds an effect to the pipeline
  74336. * @param renderEffect the effect to add
  74337. */
  74338. addEffect(renderEffect: PostProcessRenderEffect): void;
  74339. /** @hidden */
  74340. _rebuild(): void;
  74341. /** @hidden */
  74342. _enableEffect(renderEffectName: string, cameras: Camera): void;
  74343. /** @hidden */
  74344. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  74345. /** @hidden */
  74346. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74347. /** @hidden */
  74348. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  74349. /** @hidden */
  74350. _attachCameras(cameras: Camera, unique: boolean): void;
  74351. /** @hidden */
  74352. _attachCameras(cameras: Camera[], unique: boolean): void;
  74353. /** @hidden */
  74354. _detachCameras(cameras: Camera): void;
  74355. /** @hidden */
  74356. _detachCameras(cameras: Nullable<Camera[]>): void;
  74357. /** @hidden */
  74358. _update(): void;
  74359. /** @hidden */
  74360. _reset(): void;
  74361. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  74362. /**
  74363. * Sets the required values to the prepass renderer.
  74364. * @param prePassRenderer defines the prepass renderer to setup.
  74365. * @returns true if the pre pass is needed.
  74366. */
  74367. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  74368. /**
  74369. * Disposes of the pipeline
  74370. */
  74371. dispose(): void;
  74372. }
  74373. }
  74374. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager" {
  74375. import { Camera } from "babylonjs/Cameras/camera";
  74376. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74377. /**
  74378. * PostProcessRenderPipelineManager class
  74379. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74380. */
  74381. export class PostProcessRenderPipelineManager {
  74382. private _renderPipelines;
  74383. /**
  74384. * Initializes a PostProcessRenderPipelineManager
  74385. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74386. */
  74387. constructor();
  74388. /**
  74389. * Gets the list of supported render pipelines
  74390. */
  74391. get supportedPipelines(): PostProcessRenderPipeline[];
  74392. /**
  74393. * Adds a pipeline to the manager
  74394. * @param renderPipeline The pipeline to add
  74395. */
  74396. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  74397. /**
  74398. * Attaches a camera to the pipeline
  74399. * @param renderPipelineName The name of the pipeline to attach to
  74400. * @param cameras the camera to attach
  74401. * @param unique if the camera can be attached multiple times to the pipeline
  74402. */
  74403. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  74404. /**
  74405. * Detaches a camera from the pipeline
  74406. * @param renderPipelineName The name of the pipeline to detach from
  74407. * @param cameras the camera to detach
  74408. */
  74409. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  74410. /**
  74411. * Enables an effect by name on a pipeline
  74412. * @param renderPipelineName the name of the pipeline to enable the effect in
  74413. * @param renderEffectName the name of the effect to enable
  74414. * @param cameras the cameras that the effect should be enabled on
  74415. */
  74416. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74417. /**
  74418. * Disables an effect by name on a pipeline
  74419. * @param renderPipelineName the name of the pipeline to disable the effect in
  74420. * @param renderEffectName the name of the effect to disable
  74421. * @param cameras the cameras that the effect should be disabled on
  74422. */
  74423. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  74424. /**
  74425. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  74426. */
  74427. update(): void;
  74428. /** @hidden */
  74429. _rebuild(): void;
  74430. /**
  74431. * Disposes of the manager and pipelines
  74432. */
  74433. dispose(): void;
  74434. }
  74435. }
  74436. declare module "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent" {
  74437. import { ISceneComponent } from "babylonjs/sceneComponent";
  74438. import { PostProcessRenderPipelineManager } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  74439. import { Scene } from "babylonjs/scene";
  74440. module "babylonjs/scene" {
  74441. interface Scene {
  74442. /** @hidden (Backing field) */
  74443. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74444. /**
  74445. * Gets the postprocess render pipeline manager
  74446. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  74447. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74448. */
  74449. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  74450. }
  74451. }
  74452. /**
  74453. * Defines the Render Pipeline scene component responsible to rendering pipelines
  74454. */
  74455. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  74456. /**
  74457. * The component name helpfull to identify the component in the list of scene components.
  74458. */
  74459. readonly name: string;
  74460. /**
  74461. * The scene the component belongs to.
  74462. */
  74463. scene: Scene;
  74464. /**
  74465. * Creates a new instance of the component for the given scene
  74466. * @param scene Defines the scene to register the component in
  74467. */
  74468. constructor(scene: Scene);
  74469. /**
  74470. * Registers the component in a given scene
  74471. */
  74472. register(): void;
  74473. /**
  74474. * Rebuilds the elements related to this component in case of
  74475. * context lost for instance.
  74476. */
  74477. rebuild(): void;
  74478. /**
  74479. * Disposes the component and the associated ressources
  74480. */
  74481. dispose(): void;
  74482. private _gatherRenderTargets;
  74483. }
  74484. }
  74485. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline" {
  74486. import { Nullable } from "babylonjs/types";
  74487. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  74488. import { Camera } from "babylonjs/Cameras/camera";
  74489. import { IDisposable } from "babylonjs/scene";
  74490. import { GlowLayer } from "babylonjs/Layers/glowLayer";
  74491. import { Scene } from "babylonjs/scene";
  74492. import { SharpenPostProcess } from "babylonjs/PostProcesses/sharpenPostProcess";
  74493. import { ImageProcessingPostProcess } from "babylonjs/PostProcesses/imageProcessingPostProcess";
  74494. import { ChromaticAberrationPostProcess } from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  74495. import { GrainPostProcess } from "babylonjs/PostProcesses/grainPostProcess";
  74496. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  74497. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74498. import { DepthOfFieldEffect, DepthOfFieldEffectBlurLevel } from "babylonjs/PostProcesses/depthOfFieldEffect";
  74499. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74500. import { Animation } from "babylonjs/Animations/animation";
  74501. /**
  74502. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  74503. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  74504. */
  74505. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  74506. private _scene;
  74507. private _camerasToBeAttached;
  74508. /**
  74509. * ID of the sharpen post process,
  74510. */
  74511. private readonly SharpenPostProcessId;
  74512. /**
  74513. * @ignore
  74514. * ID of the image processing post process;
  74515. */
  74516. readonly ImageProcessingPostProcessId: string;
  74517. /**
  74518. * @ignore
  74519. * ID of the Fast Approximate Anti-Aliasing post process;
  74520. */
  74521. readonly FxaaPostProcessId: string;
  74522. /**
  74523. * ID of the chromatic aberration post process,
  74524. */
  74525. private readonly ChromaticAberrationPostProcessId;
  74526. /**
  74527. * ID of the grain post process
  74528. */
  74529. private readonly GrainPostProcessId;
  74530. /**
  74531. * Sharpen post process which will apply a sharpen convolution to enhance edges
  74532. */
  74533. sharpen: SharpenPostProcess;
  74534. private _sharpenEffect;
  74535. private bloom;
  74536. /**
  74537. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  74538. */
  74539. depthOfField: DepthOfFieldEffect;
  74540. /**
  74541. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  74542. */
  74543. fxaa: FxaaPostProcess;
  74544. /**
  74545. * Image post processing pass used to perform operations such as tone mapping or color grading.
  74546. */
  74547. imageProcessing: ImageProcessingPostProcess;
  74548. /**
  74549. * Chromatic aberration post process which will shift rgb colors in the image
  74550. */
  74551. chromaticAberration: ChromaticAberrationPostProcess;
  74552. private _chromaticAberrationEffect;
  74553. /**
  74554. * Grain post process which add noise to the image
  74555. */
  74556. grain: GrainPostProcess;
  74557. private _grainEffect;
  74558. /**
  74559. * Glow post process which adds a glow to emissive areas of the image
  74560. */
  74561. private _glowLayer;
  74562. /**
  74563. * Animations which can be used to tweak settings over a period of time
  74564. */
  74565. animations: Animation[];
  74566. private _imageProcessingConfigurationObserver;
  74567. private _sharpenEnabled;
  74568. private _bloomEnabled;
  74569. private _depthOfFieldEnabled;
  74570. private _depthOfFieldBlurLevel;
  74571. private _fxaaEnabled;
  74572. private _imageProcessingEnabled;
  74573. private _defaultPipelineTextureType;
  74574. private _bloomScale;
  74575. private _chromaticAberrationEnabled;
  74576. private _grainEnabled;
  74577. private _buildAllowed;
  74578. /**
  74579. * Gets active scene
  74580. */
  74581. get scene(): Scene;
  74582. /**
  74583. * Enable or disable the sharpen process from the pipeline
  74584. */
  74585. set sharpenEnabled(enabled: boolean);
  74586. get sharpenEnabled(): boolean;
  74587. private _resizeObserver;
  74588. private _hardwareScaleLevel;
  74589. private _bloomKernel;
  74590. /**
  74591. * Specifies the size of the bloom blur kernel, relative to the final output size
  74592. */
  74593. get bloomKernel(): number;
  74594. set bloomKernel(value: number);
  74595. /**
  74596. * Specifies the weight of the bloom in the final rendering
  74597. */
  74598. private _bloomWeight;
  74599. /**
  74600. * Specifies the luma threshold for the area that will be blurred by the bloom
  74601. */
  74602. private _bloomThreshold;
  74603. private _hdr;
  74604. /**
  74605. * The strength of the bloom.
  74606. */
  74607. set bloomWeight(value: number);
  74608. get bloomWeight(): number;
  74609. /**
  74610. * The strength of the bloom.
  74611. */
  74612. set bloomThreshold(value: number);
  74613. get bloomThreshold(): number;
  74614. /**
  74615. * The scale of the bloom, lower value will provide better performance.
  74616. */
  74617. set bloomScale(value: number);
  74618. get bloomScale(): number;
  74619. /**
  74620. * Enable or disable the bloom from the pipeline
  74621. */
  74622. set bloomEnabled(enabled: boolean);
  74623. get bloomEnabled(): boolean;
  74624. private _rebuildBloom;
  74625. /**
  74626. * If the depth of field is enabled.
  74627. */
  74628. get depthOfFieldEnabled(): boolean;
  74629. set depthOfFieldEnabled(enabled: boolean);
  74630. /**
  74631. * Blur level of the depth of field effect. (Higher blur will effect performance)
  74632. */
  74633. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  74634. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  74635. /**
  74636. * If the anti aliasing is enabled.
  74637. */
  74638. set fxaaEnabled(enabled: boolean);
  74639. get fxaaEnabled(): boolean;
  74640. private _samples;
  74641. /**
  74642. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  74643. */
  74644. set samples(sampleCount: number);
  74645. get samples(): number;
  74646. /**
  74647. * If image processing is enabled.
  74648. */
  74649. set imageProcessingEnabled(enabled: boolean);
  74650. get imageProcessingEnabled(): boolean;
  74651. /**
  74652. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  74653. */
  74654. set glowLayerEnabled(enabled: boolean);
  74655. get glowLayerEnabled(): boolean;
  74656. /**
  74657. * Gets the glow layer (or null if not defined)
  74658. */
  74659. get glowLayer(): Nullable<GlowLayer>;
  74660. /**
  74661. * Enable or disable the chromaticAberration process from the pipeline
  74662. */
  74663. set chromaticAberrationEnabled(enabled: boolean);
  74664. get chromaticAberrationEnabled(): boolean;
  74665. /**
  74666. * Enable or disable the grain process from the pipeline
  74667. */
  74668. set grainEnabled(enabled: boolean);
  74669. get grainEnabled(): boolean;
  74670. /**
  74671. * @constructor
  74672. * @param name - The rendering pipeline name (default: "")
  74673. * @param hdr - If high dynamic range textures should be used (default: true)
  74674. * @param scene - The scene linked to this pipeline (default: the last created scene)
  74675. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  74676. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  74677. */
  74678. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  74679. /**
  74680. * Get the class name
  74681. * @returns "DefaultRenderingPipeline"
  74682. */
  74683. getClassName(): string;
  74684. /**
  74685. * Force the compilation of the entire pipeline.
  74686. */
  74687. prepare(): void;
  74688. private _hasCleared;
  74689. private _prevPostProcess;
  74690. private _prevPrevPostProcess;
  74691. private _setAutoClearAndTextureSharing;
  74692. private _depthOfFieldSceneObserver;
  74693. private _buildPipeline;
  74694. private _disposePostProcesses;
  74695. /**
  74696. * Adds a camera to the pipeline
  74697. * @param camera the camera to be added
  74698. */
  74699. addCamera(camera: Camera): void;
  74700. /**
  74701. * Removes a camera from the pipeline
  74702. * @param camera the camera to remove
  74703. */
  74704. removeCamera(camera: Camera): void;
  74705. /**
  74706. * Dispose of the pipeline and stop all post processes
  74707. */
  74708. dispose(): void;
  74709. /**
  74710. * Serialize the rendering pipeline (Used when exporting)
  74711. * @returns the serialized object
  74712. */
  74713. serialize(): any;
  74714. /**
  74715. * Parse the serialized pipeline
  74716. * @param source Source pipeline.
  74717. * @param scene The scene to load the pipeline to.
  74718. * @param rootUrl The URL of the serialized pipeline.
  74719. * @returns An instantiated pipeline from the serialized object.
  74720. */
  74721. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  74722. }
  74723. }
  74724. declare module "babylonjs/Shaders/lensHighlights.fragment" {
  74725. /** @hidden */
  74726. export var lensHighlightsPixelShader: {
  74727. name: string;
  74728. shader: string;
  74729. };
  74730. }
  74731. declare module "babylonjs/Shaders/depthOfField.fragment" {
  74732. /** @hidden */
  74733. export var depthOfFieldPixelShader: {
  74734. name: string;
  74735. shader: string;
  74736. };
  74737. }
  74738. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline" {
  74739. import { Camera } from "babylonjs/Cameras/camera";
  74740. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  74741. import { Scene } from "babylonjs/scene";
  74742. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  74743. import "babylonjs/Shaders/chromaticAberration.fragment";
  74744. import "babylonjs/Shaders/lensHighlights.fragment";
  74745. import "babylonjs/Shaders/depthOfField.fragment";
  74746. /**
  74747. * BABYLON.JS Chromatic Aberration GLSL Shader
  74748. * Author: Olivier Guyot
  74749. * Separates very slightly R, G and B colors on the edges of the screen
  74750. * Inspired by Francois Tarlier & Martins Upitis
  74751. */
  74752. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  74753. /**
  74754. * @ignore
  74755. * The chromatic aberration PostProcess id in the pipeline
  74756. */
  74757. LensChromaticAberrationEffect: string;
  74758. /**
  74759. * @ignore
  74760. * The highlights enhancing PostProcess id in the pipeline
  74761. */
  74762. HighlightsEnhancingEffect: string;
  74763. /**
  74764. * @ignore
  74765. * The depth-of-field PostProcess id in the pipeline
  74766. */
  74767. LensDepthOfFieldEffect: string;
  74768. private _scene;
  74769. private _depthTexture;
  74770. private _grainTexture;
  74771. private _chromaticAberrationPostProcess;
  74772. private _highlightsPostProcess;
  74773. private _depthOfFieldPostProcess;
  74774. private _edgeBlur;
  74775. private _grainAmount;
  74776. private _chromaticAberration;
  74777. private _distortion;
  74778. private _highlightsGain;
  74779. private _highlightsThreshold;
  74780. private _dofDistance;
  74781. private _dofAperture;
  74782. private _dofDarken;
  74783. private _dofPentagon;
  74784. private _blurNoise;
  74785. /**
  74786. * @constructor
  74787. *
  74788. * Effect parameters are as follow:
  74789. * {
  74790. * chromatic_aberration: number; // from 0 to x (1 for realism)
  74791. * edge_blur: number; // from 0 to x (1 for realism)
  74792. * distortion: number; // from 0 to x (1 for realism)
  74793. * grain_amount: number; // from 0 to 1
  74794. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  74795. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  74796. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  74797. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  74798. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  74799. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  74800. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  74801. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  74802. * }
  74803. * Note: if an effect parameter is unset, effect is disabled
  74804. *
  74805. * @param name The rendering pipeline name
  74806. * @param parameters - An object containing all parameters (see above)
  74807. * @param scene The scene linked to this pipeline
  74808. * @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)
  74809. * @param cameras The array of cameras that the rendering pipeline will be attached to
  74810. */
  74811. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  74812. /**
  74813. * Get the class name
  74814. * @returns "LensRenderingPipeline"
  74815. */
  74816. getClassName(): string;
  74817. /**
  74818. * Gets associated scene
  74819. */
  74820. get scene(): Scene;
  74821. /**
  74822. * Gets or sets the edge blur
  74823. */
  74824. get edgeBlur(): number;
  74825. set edgeBlur(value: number);
  74826. /**
  74827. * Gets or sets the grain amount
  74828. */
  74829. get grainAmount(): number;
  74830. set grainAmount(value: number);
  74831. /**
  74832. * Gets or sets the chromatic aberration amount
  74833. */
  74834. get chromaticAberration(): number;
  74835. set chromaticAberration(value: number);
  74836. /**
  74837. * Gets or sets the depth of field aperture
  74838. */
  74839. get dofAperture(): number;
  74840. set dofAperture(value: number);
  74841. /**
  74842. * Gets or sets the edge distortion
  74843. */
  74844. get edgeDistortion(): number;
  74845. set edgeDistortion(value: number);
  74846. /**
  74847. * Gets or sets the depth of field distortion
  74848. */
  74849. get dofDistortion(): number;
  74850. set dofDistortion(value: number);
  74851. /**
  74852. * Gets or sets the darken out of focus amount
  74853. */
  74854. get darkenOutOfFocus(): number;
  74855. set darkenOutOfFocus(value: number);
  74856. /**
  74857. * Gets or sets a boolean indicating if blur noise is enabled
  74858. */
  74859. get blurNoise(): boolean;
  74860. set blurNoise(value: boolean);
  74861. /**
  74862. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  74863. */
  74864. get pentagonBokeh(): boolean;
  74865. set pentagonBokeh(value: boolean);
  74866. /**
  74867. * Gets or sets the highlight grain amount
  74868. */
  74869. get highlightsGain(): number;
  74870. set highlightsGain(value: number);
  74871. /**
  74872. * Gets or sets the highlight threshold
  74873. */
  74874. get highlightsThreshold(): number;
  74875. set highlightsThreshold(value: number);
  74876. /**
  74877. * Sets the amount of blur at the edges
  74878. * @param amount blur amount
  74879. */
  74880. setEdgeBlur(amount: number): void;
  74881. /**
  74882. * Sets edge blur to 0
  74883. */
  74884. disableEdgeBlur(): void;
  74885. /**
  74886. * Sets the amout of grain
  74887. * @param amount Amount of grain
  74888. */
  74889. setGrainAmount(amount: number): void;
  74890. /**
  74891. * Set grain amount to 0
  74892. */
  74893. disableGrain(): void;
  74894. /**
  74895. * Sets the chromatic aberration amount
  74896. * @param amount amount of chromatic aberration
  74897. */
  74898. setChromaticAberration(amount: number): void;
  74899. /**
  74900. * Sets chromatic aberration amount to 0
  74901. */
  74902. disableChromaticAberration(): void;
  74903. /**
  74904. * Sets the EdgeDistortion amount
  74905. * @param amount amount of EdgeDistortion
  74906. */
  74907. setEdgeDistortion(amount: number): void;
  74908. /**
  74909. * Sets edge distortion to 0
  74910. */
  74911. disableEdgeDistortion(): void;
  74912. /**
  74913. * Sets the FocusDistance amount
  74914. * @param amount amount of FocusDistance
  74915. */
  74916. setFocusDistance(amount: number): void;
  74917. /**
  74918. * Disables depth of field
  74919. */
  74920. disableDepthOfField(): void;
  74921. /**
  74922. * Sets the Aperture amount
  74923. * @param amount amount of Aperture
  74924. */
  74925. setAperture(amount: number): void;
  74926. /**
  74927. * Sets the DarkenOutOfFocus amount
  74928. * @param amount amount of DarkenOutOfFocus
  74929. */
  74930. setDarkenOutOfFocus(amount: number): void;
  74931. private _pentagonBokehIsEnabled;
  74932. /**
  74933. * Creates a pentagon bokeh effect
  74934. */
  74935. enablePentagonBokeh(): void;
  74936. /**
  74937. * Disables the pentagon bokeh effect
  74938. */
  74939. disablePentagonBokeh(): void;
  74940. /**
  74941. * Enables noise blur
  74942. */
  74943. enableNoiseBlur(): void;
  74944. /**
  74945. * Disables noise blur
  74946. */
  74947. disableNoiseBlur(): void;
  74948. /**
  74949. * Sets the HighlightsGain amount
  74950. * @param amount amount of HighlightsGain
  74951. */
  74952. setHighlightsGain(amount: number): void;
  74953. /**
  74954. * Sets the HighlightsThreshold amount
  74955. * @param amount amount of HighlightsThreshold
  74956. */
  74957. setHighlightsThreshold(amount: number): void;
  74958. /**
  74959. * Disables highlights
  74960. */
  74961. disableHighlights(): void;
  74962. /**
  74963. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  74964. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  74965. */
  74966. dispose(disableDepthRender?: boolean): void;
  74967. private _createChromaticAberrationPostProcess;
  74968. private _createHighlightsPostProcess;
  74969. private _createDepthOfFieldPostProcess;
  74970. private _createGrainTexture;
  74971. }
  74972. }
  74973. declare module "babylonjs/Rendering/ssao2Configuration" {
  74974. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  74975. /**
  74976. * Contains all parameters needed for the prepass to perform
  74977. * screen space subsurface scattering
  74978. */
  74979. export class SSAO2Configuration implements PrePassEffectConfiguration {
  74980. /**
  74981. * Is subsurface enabled
  74982. */
  74983. enabled: boolean;
  74984. /**
  74985. * Name of the configuration
  74986. */
  74987. name: string;
  74988. /**
  74989. * Textures that should be present in the MRT for this effect to work
  74990. */
  74991. readonly texturesRequired: number[];
  74992. }
  74993. }
  74994. declare module "babylonjs/Shaders/ssao2.fragment" {
  74995. /** @hidden */
  74996. export var ssao2PixelShader: {
  74997. name: string;
  74998. shader: string;
  74999. };
  75000. }
  75001. declare module "babylonjs/Shaders/ssaoCombine.fragment" {
  75002. /** @hidden */
  75003. export var ssaoCombinePixelShader: {
  75004. name: string;
  75005. shader: string;
  75006. };
  75007. }
  75008. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline" {
  75009. import { Camera } from "babylonjs/Cameras/camera";
  75010. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75011. import { Scene } from "babylonjs/scene";
  75012. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75013. import "babylonjs/Shaders/ssao2.fragment";
  75014. import "babylonjs/Shaders/ssaoCombine.fragment";
  75015. /**
  75016. * Render pipeline to produce ssao effect
  75017. */
  75018. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  75019. /**
  75020. * @ignore
  75021. * The PassPostProcess id in the pipeline that contains the original scene color
  75022. */
  75023. SSAOOriginalSceneColorEffect: string;
  75024. /**
  75025. * @ignore
  75026. * The SSAO PostProcess id in the pipeline
  75027. */
  75028. SSAORenderEffect: string;
  75029. /**
  75030. * @ignore
  75031. * The horizontal blur PostProcess id in the pipeline
  75032. */
  75033. SSAOBlurHRenderEffect: string;
  75034. /**
  75035. * @ignore
  75036. * The vertical blur PostProcess id in the pipeline
  75037. */
  75038. SSAOBlurVRenderEffect: string;
  75039. /**
  75040. * @ignore
  75041. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75042. */
  75043. SSAOCombineRenderEffect: string;
  75044. /**
  75045. * The output strength of the SSAO post-process. Default value is 1.0.
  75046. */
  75047. totalStrength: number;
  75048. /**
  75049. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  75050. */
  75051. maxZ: number;
  75052. /**
  75053. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  75054. */
  75055. minZAspect: number;
  75056. private _samples;
  75057. /**
  75058. * Number of samples used for the SSAO calculations. Default value is 8
  75059. */
  75060. set samples(n: number);
  75061. get samples(): number;
  75062. private _textureSamples;
  75063. /**
  75064. * Number of samples to use for antialiasing
  75065. */
  75066. set textureSamples(n: number);
  75067. get textureSamples(): number;
  75068. /**
  75069. * Force rendering the geometry through geometry buffer
  75070. */
  75071. private _forceGeometryBuffer;
  75072. /**
  75073. * Ratio object used for SSAO ratio and blur ratio
  75074. */
  75075. private _ratio;
  75076. /**
  75077. * Dynamically generated sphere sampler.
  75078. */
  75079. private _sampleSphere;
  75080. /**
  75081. * Blur filter offsets
  75082. */
  75083. private _samplerOffsets;
  75084. private _expensiveBlur;
  75085. /**
  75086. * If bilateral blur should be used
  75087. */
  75088. set expensiveBlur(b: boolean);
  75089. get expensiveBlur(): boolean;
  75090. /**
  75091. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  75092. */
  75093. radius: number;
  75094. /**
  75095. * The base color of the SSAO post-process
  75096. * The final result is "base + ssao" between [0, 1]
  75097. */
  75098. base: number;
  75099. /**
  75100. * Support test.
  75101. */
  75102. static get IsSupported(): boolean;
  75103. private _scene;
  75104. private _randomTexture;
  75105. private _originalColorPostProcess;
  75106. private _ssaoPostProcess;
  75107. private _blurHPostProcess;
  75108. private _blurVPostProcess;
  75109. private _ssaoCombinePostProcess;
  75110. private _prePassRenderer;
  75111. /**
  75112. * Gets active scene
  75113. */
  75114. get scene(): Scene;
  75115. /**
  75116. * @constructor
  75117. * @param name The rendering pipeline name
  75118. * @param scene The scene linked to this pipeline
  75119. * @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 }
  75120. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75121. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  75122. */
  75123. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  75124. /**
  75125. * Get the class name
  75126. * @returns "SSAO2RenderingPipeline"
  75127. */
  75128. getClassName(): string;
  75129. /**
  75130. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75131. */
  75132. dispose(disableGeometryBufferRenderer?: boolean): void;
  75133. private _createBlurPostProcess;
  75134. /** @hidden */
  75135. _rebuild(): void;
  75136. private _bits;
  75137. private _radicalInverse_VdC;
  75138. private _hammersley;
  75139. private _hemisphereSample_uniform;
  75140. private _generateHemisphere;
  75141. private _getDefinesForSSAO;
  75142. private _createSSAOPostProcess;
  75143. private _createSSAOCombinePostProcess;
  75144. private _createRandomTexture;
  75145. /**
  75146. * Serialize the rendering pipeline (Used when exporting)
  75147. * @returns the serialized object
  75148. */
  75149. serialize(): any;
  75150. /**
  75151. * Parse the serialized pipeline
  75152. * @param source Source pipeline.
  75153. * @param scene The scene to load the pipeline to.
  75154. * @param rootUrl The URL of the serialized pipeline.
  75155. * @returns An instantiated pipeline from the serialized object.
  75156. */
  75157. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  75158. }
  75159. }
  75160. declare module "babylonjs/Shaders/ssao.fragment" {
  75161. /** @hidden */
  75162. export var ssaoPixelShader: {
  75163. name: string;
  75164. shader: string;
  75165. };
  75166. }
  75167. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline" {
  75168. import { Camera } from "babylonjs/Cameras/camera";
  75169. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75170. import { Scene } from "babylonjs/scene";
  75171. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75172. import "babylonjs/Shaders/ssao.fragment";
  75173. import "babylonjs/Shaders/ssaoCombine.fragment";
  75174. /**
  75175. * Render pipeline to produce ssao effect
  75176. */
  75177. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  75178. /**
  75179. * @ignore
  75180. * The PassPostProcess id in the pipeline that contains the original scene color
  75181. */
  75182. SSAOOriginalSceneColorEffect: string;
  75183. /**
  75184. * @ignore
  75185. * The SSAO PostProcess id in the pipeline
  75186. */
  75187. SSAORenderEffect: string;
  75188. /**
  75189. * @ignore
  75190. * The horizontal blur PostProcess id in the pipeline
  75191. */
  75192. SSAOBlurHRenderEffect: string;
  75193. /**
  75194. * @ignore
  75195. * The vertical blur PostProcess id in the pipeline
  75196. */
  75197. SSAOBlurVRenderEffect: string;
  75198. /**
  75199. * @ignore
  75200. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  75201. */
  75202. SSAOCombineRenderEffect: string;
  75203. /**
  75204. * The output strength of the SSAO post-process. Default value is 1.0.
  75205. */
  75206. totalStrength: number;
  75207. /**
  75208. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  75209. */
  75210. radius: number;
  75211. /**
  75212. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  75213. * Must not be equal to fallOff and superior to fallOff.
  75214. * Default value is 0.0075
  75215. */
  75216. area: number;
  75217. /**
  75218. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  75219. * Must not be equal to area and inferior to area.
  75220. * Default value is 0.000001
  75221. */
  75222. fallOff: number;
  75223. /**
  75224. * The base color of the SSAO post-process
  75225. * The final result is "base + ssao" between [0, 1]
  75226. */
  75227. base: number;
  75228. private _scene;
  75229. private _depthTexture;
  75230. private _randomTexture;
  75231. private _originalColorPostProcess;
  75232. private _ssaoPostProcess;
  75233. private _blurHPostProcess;
  75234. private _blurVPostProcess;
  75235. private _ssaoCombinePostProcess;
  75236. private _firstUpdate;
  75237. /**
  75238. * Gets active scene
  75239. */
  75240. get scene(): Scene;
  75241. /**
  75242. * @constructor
  75243. * @param name - The rendering pipeline name
  75244. * @param scene - The scene linked to this pipeline
  75245. * @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 }
  75246. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  75247. */
  75248. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  75249. /**
  75250. * Get the class name
  75251. * @returns "SSAORenderingPipeline"
  75252. */
  75253. getClassName(): string;
  75254. /**
  75255. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  75256. */
  75257. dispose(disableDepthRender?: boolean): void;
  75258. private _createBlurPostProcess;
  75259. /** @hidden */
  75260. _rebuild(): void;
  75261. private _createSSAOPostProcess;
  75262. private _createSSAOCombinePostProcess;
  75263. private _createRandomTexture;
  75264. }
  75265. }
  75266. declare module "babylonjs/Rendering/screenSpaceReflectionsConfiguration" {
  75267. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  75268. /**
  75269. * Contains all parameters needed for the prepass to perform
  75270. * screen space reflections
  75271. */
  75272. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  75273. /**
  75274. * Is ssr enabled
  75275. */
  75276. enabled: boolean;
  75277. /**
  75278. * Name of the configuration
  75279. */
  75280. name: string;
  75281. /**
  75282. * Textures that should be present in the MRT for this effect to work
  75283. */
  75284. readonly texturesRequired: number[];
  75285. }
  75286. }
  75287. declare module "babylonjs/Shaders/screenSpaceReflection.fragment" {
  75288. /** @hidden */
  75289. export var screenSpaceReflectionPixelShader: {
  75290. name: string;
  75291. shader: string;
  75292. };
  75293. }
  75294. declare module "babylonjs/PostProcesses/screenSpaceReflectionPostProcess" {
  75295. import { Nullable } from "babylonjs/types";
  75296. import { Camera } from "babylonjs/Cameras/camera";
  75297. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  75298. import "babylonjs/Shaders/screenSpaceReflection.fragment";
  75299. import { Engine } from "babylonjs/Engines/engine";
  75300. import { Scene } from "babylonjs/scene";
  75301. /**
  75302. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  75303. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  75304. */
  75305. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  75306. /**
  75307. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  75308. */
  75309. threshold: number;
  75310. /**
  75311. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  75312. */
  75313. strength: number;
  75314. /**
  75315. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  75316. */
  75317. reflectionSpecularFalloffExponent: number;
  75318. /**
  75319. * 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]
  75320. */
  75321. step: number;
  75322. /**
  75323. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  75324. */
  75325. roughnessFactor: number;
  75326. private _forceGeometryBuffer;
  75327. private _geometryBufferRenderer;
  75328. private _prePassRenderer;
  75329. private _enableSmoothReflections;
  75330. private _reflectionSamples;
  75331. private _smoothSteps;
  75332. /**
  75333. * Gets a string identifying the name of the class
  75334. * @returns "ScreenSpaceReflectionPostProcess" string
  75335. */
  75336. getClassName(): string;
  75337. /**
  75338. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  75339. * @param name The name of the effect.
  75340. * @param scene The scene containing the objects to calculate reflections.
  75341. * @param options The required width/height ratio to downsize to before computing the render pass.
  75342. * @param camera The camera to apply the render pass to.
  75343. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75344. * @param engine The engine which the post process will be applied. (default: current engine)
  75345. * @param reusable If the post process can be reused on the same frame. (default: false)
  75346. * @param textureType Type of textures used when performing the post process. (default: 0)
  75347. * @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)
  75348. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  75349. */
  75350. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  75351. /**
  75352. * Gets wether or not smoothing reflections is enabled.
  75353. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75354. */
  75355. get enableSmoothReflections(): boolean;
  75356. /**
  75357. * Sets wether or not smoothing reflections is enabled.
  75358. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  75359. */
  75360. set enableSmoothReflections(enabled: boolean);
  75361. /**
  75362. * Gets the number of samples taken while computing reflections. More samples count is high,
  75363. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75364. */
  75365. get reflectionSamples(): number;
  75366. /**
  75367. * Sets the number of samples taken while computing reflections. More samples count is high,
  75368. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  75369. */
  75370. set reflectionSamples(samples: number);
  75371. /**
  75372. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  75373. * more the post-process will require GPU power and can generate a drop in FPS.
  75374. * Default value (5.0) work pretty well in all cases but can be adjusted.
  75375. */
  75376. get smoothSteps(): number;
  75377. set smoothSteps(steps: number);
  75378. private _updateEffectDefines;
  75379. /** @hidden */
  75380. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  75381. }
  75382. }
  75383. declare module "babylonjs/Shaders/standard.fragment" {
  75384. import "babylonjs/Shaders/ShadersInclude/packingFunctions";
  75385. /** @hidden */
  75386. export var standardPixelShader: {
  75387. name: string;
  75388. shader: string;
  75389. };
  75390. }
  75391. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline" {
  75392. import { Nullable } from "babylonjs/types";
  75393. import { IAnimatable } from "babylonjs/Animations/animatable.interface";
  75394. import { Camera } from "babylonjs/Cameras/camera";
  75395. import { Texture } from "babylonjs/Materials/Textures/texture";
  75396. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75397. import { PostProcessRenderPipeline } from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75398. import { BlurPostProcess } from "babylonjs/PostProcesses/blurPostProcess";
  75399. import { FxaaPostProcess } from "babylonjs/PostProcesses/fxaaPostProcess";
  75400. import { IDisposable } from "babylonjs/scene";
  75401. import { SpotLight } from "babylonjs/Lights/spotLight";
  75402. import { DirectionalLight } from "babylonjs/Lights/directionalLight";
  75403. import { Scene } from "babylonjs/scene";
  75404. import { ScreenSpaceReflectionPostProcess } from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  75405. import { Animation } from "babylonjs/Animations/animation";
  75406. import "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75407. import "babylonjs/Shaders/standard.fragment";
  75408. /**
  75409. * Standard rendering pipeline
  75410. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75411. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  75412. */
  75413. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  75414. /**
  75415. * Public members
  75416. */
  75417. /**
  75418. * Post-process which contains the original scene color before the pipeline applies all the effects
  75419. */
  75420. originalPostProcess: Nullable<PostProcess>;
  75421. /**
  75422. * Post-process used to down scale an image x4
  75423. */
  75424. downSampleX4PostProcess: Nullable<PostProcess>;
  75425. /**
  75426. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  75427. */
  75428. brightPassPostProcess: Nullable<PostProcess>;
  75429. /**
  75430. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  75431. */
  75432. blurHPostProcesses: PostProcess[];
  75433. /**
  75434. * Post-process array storing all the vertical blur post-processes used by the pipeline
  75435. */
  75436. blurVPostProcesses: PostProcess[];
  75437. /**
  75438. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  75439. */
  75440. textureAdderPostProcess: Nullable<PostProcess>;
  75441. /**
  75442. * Post-process used to create volumetric lighting effect
  75443. */
  75444. volumetricLightPostProcess: Nullable<PostProcess>;
  75445. /**
  75446. * Post-process used to smooth the previous volumetric light post-process on the X axis
  75447. */
  75448. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  75449. /**
  75450. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  75451. */
  75452. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  75453. /**
  75454. * Post-process used to merge the volumetric light effect and the real scene color
  75455. */
  75456. volumetricLightMergePostProces: Nullable<PostProcess>;
  75457. /**
  75458. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  75459. */
  75460. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  75461. /**
  75462. * Base post-process used to calculate the average luminance of the final image for HDR
  75463. */
  75464. luminancePostProcess: Nullable<PostProcess>;
  75465. /**
  75466. * Post-processes used to create down sample post-processes in order to get
  75467. * the average luminance of the final image for HDR
  75468. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  75469. */
  75470. luminanceDownSamplePostProcesses: PostProcess[];
  75471. /**
  75472. * Post-process used to create a HDR effect (light adaptation)
  75473. */
  75474. hdrPostProcess: Nullable<PostProcess>;
  75475. /**
  75476. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  75477. */
  75478. textureAdderFinalPostProcess: Nullable<PostProcess>;
  75479. /**
  75480. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  75481. */
  75482. lensFlareFinalPostProcess: Nullable<PostProcess>;
  75483. /**
  75484. * Post-process used to merge the final HDR post-process and the real scene color
  75485. */
  75486. hdrFinalPostProcess: Nullable<PostProcess>;
  75487. /**
  75488. * Post-process used to create a lens flare effect
  75489. */
  75490. lensFlarePostProcess: Nullable<PostProcess>;
  75491. /**
  75492. * Post-process that merges the result of the lens flare post-process and the real scene color
  75493. */
  75494. lensFlareComposePostProcess: Nullable<PostProcess>;
  75495. /**
  75496. * Post-process used to create a motion blur effect
  75497. */
  75498. motionBlurPostProcess: Nullable<PostProcess>;
  75499. /**
  75500. * Post-process used to create a depth of field effect
  75501. */
  75502. depthOfFieldPostProcess: Nullable<PostProcess>;
  75503. /**
  75504. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  75505. */
  75506. fxaaPostProcess: Nullable<FxaaPostProcess>;
  75507. /**
  75508. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  75509. */
  75510. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  75511. /**
  75512. * Represents the brightness threshold in order to configure the illuminated surfaces
  75513. */
  75514. brightThreshold: number;
  75515. /**
  75516. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  75517. */
  75518. blurWidth: number;
  75519. /**
  75520. * Sets if the blur for highlighted surfaces must be only horizontal
  75521. */
  75522. horizontalBlur: boolean;
  75523. /**
  75524. * Gets the overall exposure used by the pipeline
  75525. */
  75526. get exposure(): number;
  75527. /**
  75528. * Sets the overall exposure used by the pipeline
  75529. */
  75530. set exposure(value: number);
  75531. /**
  75532. * Texture used typically to simulate "dirty" on camera lens
  75533. */
  75534. lensTexture: Nullable<Texture>;
  75535. /**
  75536. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  75537. */
  75538. volumetricLightCoefficient: number;
  75539. /**
  75540. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  75541. */
  75542. volumetricLightPower: number;
  75543. /**
  75544. * Used the set the blur intensity to smooth the volumetric lights
  75545. */
  75546. volumetricLightBlurScale: number;
  75547. /**
  75548. * Light (spot or directional) used to generate the volumetric lights rays
  75549. * The source light must have a shadow generate so the pipeline can get its
  75550. * depth map
  75551. */
  75552. sourceLight: Nullable<SpotLight | DirectionalLight>;
  75553. /**
  75554. * For eye adaptation, represents the minimum luminance the eye can see
  75555. */
  75556. hdrMinimumLuminance: number;
  75557. /**
  75558. * For eye adaptation, represents the decrease luminance speed
  75559. */
  75560. hdrDecreaseRate: number;
  75561. /**
  75562. * For eye adaptation, represents the increase luminance speed
  75563. */
  75564. hdrIncreaseRate: number;
  75565. /**
  75566. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75567. */
  75568. get hdrAutoExposure(): boolean;
  75569. /**
  75570. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  75571. */
  75572. set hdrAutoExposure(value: boolean);
  75573. /**
  75574. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  75575. */
  75576. lensColorTexture: Nullable<Texture>;
  75577. /**
  75578. * The overall strengh for the lens flare effect
  75579. */
  75580. lensFlareStrength: number;
  75581. /**
  75582. * Dispersion coefficient for lens flare ghosts
  75583. */
  75584. lensFlareGhostDispersal: number;
  75585. /**
  75586. * Main lens flare halo width
  75587. */
  75588. lensFlareHaloWidth: number;
  75589. /**
  75590. * Based on the lens distortion effect, defines how much the lens flare result
  75591. * is distorted
  75592. */
  75593. lensFlareDistortionStrength: number;
  75594. /**
  75595. * Configures the blur intensity used for for lens flare (halo)
  75596. */
  75597. lensFlareBlurWidth: number;
  75598. /**
  75599. * Lens star texture must be used to simulate rays on the flares and is available
  75600. * in the documentation
  75601. */
  75602. lensStarTexture: Nullable<Texture>;
  75603. /**
  75604. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  75605. * flare effect by taking account of the dirt texture
  75606. */
  75607. lensFlareDirtTexture: Nullable<Texture>;
  75608. /**
  75609. * Represents the focal length for the depth of field effect
  75610. */
  75611. depthOfFieldDistance: number;
  75612. /**
  75613. * Represents the blur intensity for the blurred part of the depth of field effect
  75614. */
  75615. depthOfFieldBlurWidth: number;
  75616. /**
  75617. * Gets how much the image is blurred by the movement while using the motion blur post-process
  75618. */
  75619. get motionStrength(): number;
  75620. /**
  75621. * Sets how much the image is blurred by the movement while using the motion blur post-process
  75622. */
  75623. set motionStrength(strength: number);
  75624. /**
  75625. * Gets wether or not the motion blur post-process is object based or screen based.
  75626. */
  75627. get objectBasedMotionBlur(): boolean;
  75628. /**
  75629. * Sets wether or not the motion blur post-process should be object based or screen based
  75630. */
  75631. set objectBasedMotionBlur(value: boolean);
  75632. /**
  75633. * List of animations for the pipeline (IAnimatable implementation)
  75634. */
  75635. animations: Animation[];
  75636. /**
  75637. * Private members
  75638. */
  75639. private _scene;
  75640. private _currentDepthOfFieldSource;
  75641. private _basePostProcess;
  75642. private _fixedExposure;
  75643. private _currentExposure;
  75644. private _hdrAutoExposure;
  75645. private _hdrCurrentLuminance;
  75646. private _motionStrength;
  75647. private _isObjectBasedMotionBlur;
  75648. private _floatTextureType;
  75649. private _camerasToBeAttached;
  75650. private _ratio;
  75651. private _bloomEnabled;
  75652. private _depthOfFieldEnabled;
  75653. private _vlsEnabled;
  75654. private _lensFlareEnabled;
  75655. private _hdrEnabled;
  75656. private _motionBlurEnabled;
  75657. private _fxaaEnabled;
  75658. private _screenSpaceReflectionsEnabled;
  75659. private _motionBlurSamples;
  75660. private _volumetricLightStepsCount;
  75661. private _samples;
  75662. /**
  75663. * @ignore
  75664. * Specifies if the bloom pipeline is enabled
  75665. */
  75666. get BloomEnabled(): boolean;
  75667. set BloomEnabled(enabled: boolean);
  75668. /**
  75669. * @ignore
  75670. * Specifies if the depth of field pipeline is enabed
  75671. */
  75672. get DepthOfFieldEnabled(): boolean;
  75673. set DepthOfFieldEnabled(enabled: boolean);
  75674. /**
  75675. * @ignore
  75676. * Specifies if the lens flare pipeline is enabed
  75677. */
  75678. get LensFlareEnabled(): boolean;
  75679. set LensFlareEnabled(enabled: boolean);
  75680. /**
  75681. * @ignore
  75682. * Specifies if the HDR pipeline is enabled
  75683. */
  75684. get HDREnabled(): boolean;
  75685. set HDREnabled(enabled: boolean);
  75686. /**
  75687. * @ignore
  75688. * Specifies if the volumetric lights scattering effect is enabled
  75689. */
  75690. get VLSEnabled(): boolean;
  75691. set VLSEnabled(enabled: boolean);
  75692. /**
  75693. * @ignore
  75694. * Specifies if the motion blur effect is enabled
  75695. */
  75696. get MotionBlurEnabled(): boolean;
  75697. set MotionBlurEnabled(enabled: boolean);
  75698. /**
  75699. * Specifies if anti-aliasing is enabled
  75700. */
  75701. get fxaaEnabled(): boolean;
  75702. set fxaaEnabled(enabled: boolean);
  75703. /**
  75704. * Specifies if screen space reflections are enabled.
  75705. */
  75706. get screenSpaceReflectionsEnabled(): boolean;
  75707. set screenSpaceReflectionsEnabled(enabled: boolean);
  75708. /**
  75709. * Specifies the number of steps used to calculate the volumetric lights
  75710. * Typically in interval [50, 200]
  75711. */
  75712. get volumetricLightStepsCount(): number;
  75713. set volumetricLightStepsCount(count: number);
  75714. /**
  75715. * Specifies the number of samples used for the motion blur effect
  75716. * Typically in interval [16, 64]
  75717. */
  75718. get motionBlurSamples(): number;
  75719. set motionBlurSamples(samples: number);
  75720. /**
  75721. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  75722. */
  75723. get samples(): number;
  75724. set samples(sampleCount: number);
  75725. /**
  75726. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  75727. * @constructor
  75728. * @param name The rendering pipeline name
  75729. * @param scene The scene linked to this pipeline
  75730. * @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)
  75731. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  75732. * @param cameras The array of cameras that the rendering pipeline will be attached to
  75733. */
  75734. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  75735. private _buildPipeline;
  75736. private _createDownSampleX4PostProcess;
  75737. private _createBrightPassPostProcess;
  75738. private _createBlurPostProcesses;
  75739. private _createTextureAdderPostProcess;
  75740. private _createVolumetricLightPostProcess;
  75741. private _createLuminancePostProcesses;
  75742. private _createHdrPostProcess;
  75743. private _createLensFlarePostProcess;
  75744. private _createDepthOfFieldPostProcess;
  75745. private _createMotionBlurPostProcess;
  75746. private _getDepthTexture;
  75747. private _disposePostProcesses;
  75748. /**
  75749. * Dispose of the pipeline and stop all post processes
  75750. */
  75751. dispose(): void;
  75752. /**
  75753. * Serialize the rendering pipeline (Used when exporting)
  75754. * @returns the serialized object
  75755. */
  75756. serialize(): any;
  75757. /**
  75758. * Parse the serialized pipeline
  75759. * @param source Source pipeline.
  75760. * @param scene The scene to load the pipeline to.
  75761. * @param rootUrl The URL of the serialized pipeline.
  75762. * @returns An instantiated pipeline from the serialized object.
  75763. */
  75764. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  75765. /**
  75766. * Luminance steps
  75767. */
  75768. static LuminanceSteps: number;
  75769. }
  75770. }
  75771. declare module "babylonjs/PostProcesses/RenderPipeline/Pipelines/index" {
  75772. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline";
  75773. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline";
  75774. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline";
  75775. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline";
  75776. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline";
  75777. }
  75778. declare module "babylonjs/PostProcesses/RenderPipeline/index" {
  75779. export * from "babylonjs/PostProcesses/RenderPipeline/Pipelines/index";
  75780. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderEffect";
  75781. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipeline";
  75782. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManager";
  75783. export * from "babylonjs/PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent";
  75784. }
  75785. declare module "babylonjs/Shaders/stereoscopicInterlace.fragment" {
  75786. /** @hidden */
  75787. export var stereoscopicInterlacePixelShader: {
  75788. name: string;
  75789. shader: string;
  75790. };
  75791. }
  75792. declare module "babylonjs/PostProcesses/stereoscopicInterlacePostProcess" {
  75793. import { Camera } from "babylonjs/Cameras/camera";
  75794. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75795. import { Engine } from "babylonjs/Engines/engine";
  75796. import "babylonjs/Shaders/stereoscopicInterlace.fragment";
  75797. /**
  75798. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  75799. */
  75800. export class StereoscopicInterlacePostProcessI extends PostProcess {
  75801. private _stepSize;
  75802. private _passedProcess;
  75803. /**
  75804. * Gets a string identifying the name of the class
  75805. * @returns "StereoscopicInterlacePostProcessI" string
  75806. */
  75807. getClassName(): string;
  75808. /**
  75809. * Initializes a StereoscopicInterlacePostProcessI
  75810. * @param name The name of the effect.
  75811. * @param rigCameras The rig cameras to be appled to the post process
  75812. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  75813. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  75814. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75815. * @param engine The engine which the post process will be applied. (default: current engine)
  75816. * @param reusable If the post process can be reused on the same frame. (default: false)
  75817. */
  75818. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75819. }
  75820. /**
  75821. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  75822. */
  75823. export class StereoscopicInterlacePostProcess extends PostProcess {
  75824. private _stepSize;
  75825. private _passedProcess;
  75826. /**
  75827. * Gets a string identifying the name of the class
  75828. * @returns "StereoscopicInterlacePostProcess" string
  75829. */
  75830. getClassName(): string;
  75831. /**
  75832. * Initializes a StereoscopicInterlacePostProcess
  75833. * @param name The name of the effect.
  75834. * @param rigCameras The rig cameras to be appled to the post process
  75835. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  75836. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  75837. * @param engine The engine which the post process will be applied. (default: current engine)
  75838. * @param reusable If the post process can be reused on the same frame. (default: false)
  75839. */
  75840. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  75841. }
  75842. }
  75843. declare module "babylonjs/Shaders/tonemap.fragment" {
  75844. /** @hidden */
  75845. export var tonemapPixelShader: {
  75846. name: string;
  75847. shader: string;
  75848. };
  75849. }
  75850. declare module "babylonjs/PostProcesses/tonemapPostProcess" {
  75851. import { Camera } from "babylonjs/Cameras/camera";
  75852. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75853. import "babylonjs/Shaders/tonemap.fragment";
  75854. import { Engine } from "babylonjs/Engines/engine";
  75855. /** Defines operator used for tonemapping */
  75856. export enum TonemappingOperator {
  75857. /** Hable */
  75858. Hable = 0,
  75859. /** Reinhard */
  75860. Reinhard = 1,
  75861. /** HejiDawson */
  75862. HejiDawson = 2,
  75863. /** Photographic */
  75864. Photographic = 3
  75865. }
  75866. /**
  75867. * Defines a post process to apply tone mapping
  75868. */
  75869. export class TonemapPostProcess extends PostProcess {
  75870. private _operator;
  75871. /** Defines the required exposure adjustement */
  75872. exposureAdjustment: number;
  75873. /**
  75874. * Gets a string identifying the name of the class
  75875. * @returns "TonemapPostProcess" string
  75876. */
  75877. getClassName(): string;
  75878. /**
  75879. * Creates a new TonemapPostProcess
  75880. * @param name defines the name of the postprocess
  75881. * @param _operator defines the operator to use
  75882. * @param exposureAdjustment defines the required exposure adjustement
  75883. * @param camera defines the camera to use (can be null)
  75884. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  75885. * @param engine defines the hosting engine (can be ignore if camera is set)
  75886. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  75887. */
  75888. constructor(name: string, _operator: TonemappingOperator,
  75889. /** Defines the required exposure adjustement */
  75890. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  75891. }
  75892. }
  75893. declare module "babylonjs/Shaders/volumetricLightScattering.fragment" {
  75894. /** @hidden */
  75895. export var volumetricLightScatteringPixelShader: {
  75896. name: string;
  75897. shader: string;
  75898. };
  75899. }
  75900. declare module "babylonjs/Shaders/volumetricLightScatteringPass.vertex" {
  75901. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  75902. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  75903. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  75904. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  75905. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  75906. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  75907. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  75908. /** @hidden */
  75909. export var volumetricLightScatteringPassVertexShader: {
  75910. name: string;
  75911. shader: string;
  75912. };
  75913. }
  75914. declare module "babylonjs/Shaders/volumetricLightScatteringPass.fragment" {
  75915. /** @hidden */
  75916. export var volumetricLightScatteringPassPixelShader: {
  75917. name: string;
  75918. shader: string;
  75919. };
  75920. }
  75921. declare module "babylonjs/PostProcesses/volumetricLightScatteringPostProcess" {
  75922. import { Vector3 } from "babylonjs/Maths/math.vector";
  75923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  75924. import { Mesh } from "babylonjs/Meshes/mesh";
  75925. import { Camera } from "babylonjs/Cameras/camera";
  75926. import { RenderTargetTexture } from "babylonjs/Materials/Textures/renderTargetTexture";
  75927. import { PostProcess } from "babylonjs/PostProcesses/postProcess";
  75928. import { Scene } from "babylonjs/scene";
  75929. import "babylonjs/Meshes/Builders/planeBuilder";
  75930. import "babylonjs/Shaders/depth.vertex";
  75931. import "babylonjs/Shaders/volumetricLightScattering.fragment";
  75932. import "babylonjs/Shaders/volumetricLightScatteringPass.vertex";
  75933. import "babylonjs/Shaders/volumetricLightScatteringPass.fragment";
  75934. import { Engine } from "babylonjs/Engines/engine";
  75935. /**
  75936. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  75937. */
  75938. export class VolumetricLightScatteringPostProcess extends PostProcess {
  75939. private _volumetricLightScatteringPass;
  75940. private _volumetricLightScatteringRTT;
  75941. private _viewPort;
  75942. private _screenCoordinates;
  75943. private _cachedDefines;
  75944. /**
  75945. * If not undefined, the mesh position is computed from the attached node position
  75946. */
  75947. attachedNode: {
  75948. position: Vector3;
  75949. };
  75950. /**
  75951. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  75952. */
  75953. customMeshPosition: Vector3;
  75954. /**
  75955. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  75956. */
  75957. useCustomMeshPosition: boolean;
  75958. /**
  75959. * If the post-process should inverse the light scattering direction
  75960. */
  75961. invert: boolean;
  75962. /**
  75963. * The internal mesh used by the post-process
  75964. */
  75965. mesh: Mesh;
  75966. /**
  75967. * @hidden
  75968. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  75969. */
  75970. get useDiffuseColor(): boolean;
  75971. set useDiffuseColor(useDiffuseColor: boolean);
  75972. /**
  75973. * Array containing the excluded meshes not rendered in the internal pass
  75974. */
  75975. excludedMeshes: AbstractMesh[];
  75976. /**
  75977. * Controls the overall intensity of the post-process
  75978. */
  75979. exposure: number;
  75980. /**
  75981. * Dissipates each sample's contribution in range [0, 1]
  75982. */
  75983. decay: number;
  75984. /**
  75985. * Controls the overall intensity of each sample
  75986. */
  75987. weight: number;
  75988. /**
  75989. * Controls the density of each sample
  75990. */
  75991. density: number;
  75992. /**
  75993. * @constructor
  75994. * @param name The post-process name
  75995. * @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)
  75996. * @param camera The camera that the post-process will be attached to
  75997. * @param mesh The mesh used to create the light scattering
  75998. * @param samples The post-process quality, default 100
  75999. * @param samplingModeThe post-process filtering mode
  76000. * @param engine The babylon engine
  76001. * @param reusable If the post-process is reusable
  76002. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  76003. */
  76004. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  76005. /**
  76006. * Returns the string "VolumetricLightScatteringPostProcess"
  76007. * @returns "VolumetricLightScatteringPostProcess"
  76008. */
  76009. getClassName(): string;
  76010. private _isReady;
  76011. /**
  76012. * Sets the new light position for light scattering effect
  76013. * @param position The new custom light position
  76014. */
  76015. setCustomMeshPosition(position: Vector3): void;
  76016. /**
  76017. * Returns the light position for light scattering effect
  76018. * @return Vector3 The custom light position
  76019. */
  76020. getCustomMeshPosition(): Vector3;
  76021. /**
  76022. * Disposes the internal assets and detaches the post-process from the camera
  76023. */
  76024. dispose(camera: Camera): void;
  76025. /**
  76026. * Returns the render target texture used by the post-process
  76027. * @return the render target texture used by the post-process
  76028. */
  76029. getPass(): RenderTargetTexture;
  76030. private _meshExcluded;
  76031. private _createPass;
  76032. private _updateMeshScreenCoordinates;
  76033. /**
  76034. * Creates a default mesh for the Volumeric Light Scattering post-process
  76035. * @param name The mesh name
  76036. * @param scene The scene where to create the mesh
  76037. * @return the default mesh
  76038. */
  76039. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  76040. }
  76041. }
  76042. declare module "babylonjs/Shaders/screenSpaceCurvature.fragment" {
  76043. /** @hidden */
  76044. export var screenSpaceCurvaturePixelShader: {
  76045. name: string;
  76046. shader: string;
  76047. };
  76048. }
  76049. declare module "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess" {
  76050. import { Nullable } from "babylonjs/types";
  76051. import { Camera } from "babylonjs/Cameras/camera";
  76052. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76053. import "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76054. import "babylonjs/Shaders/screenSpaceCurvature.fragment";
  76055. import { Engine } from "babylonjs/Engines/engine";
  76056. import { Scene } from "babylonjs/scene";
  76057. /**
  76058. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  76059. */
  76060. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  76061. /**
  76062. * Defines how much ridge the curvature effect displays.
  76063. */
  76064. ridge: number;
  76065. /**
  76066. * Defines how much valley the curvature effect displays.
  76067. */
  76068. valley: number;
  76069. private _geometryBufferRenderer;
  76070. /**
  76071. * Gets a string identifying the name of the class
  76072. * @returns "ScreenSpaceCurvaturePostProcess" string
  76073. */
  76074. getClassName(): string;
  76075. /**
  76076. * Creates a new instance ScreenSpaceCurvaturePostProcess
  76077. * @param name The name of the effect.
  76078. * @param scene The scene containing the objects to blur according to their velocity.
  76079. * @param options The required width/height ratio to downsize to before computing the render pass.
  76080. * @param camera The camera to apply the render pass to.
  76081. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  76082. * @param engine The engine which the post process will be applied. (default: current engine)
  76083. * @param reusable If the post process can be reused on the same frame. (default: false)
  76084. * @param textureType Type of textures used when performing the post process. (default: 0)
  76085. * @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)
  76086. */
  76087. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  76088. /**
  76089. * Support test.
  76090. */
  76091. static get IsSupported(): boolean;
  76092. /** @hidden */
  76093. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  76094. }
  76095. }
  76096. declare module "babylonjs/PostProcesses/index" {
  76097. export * from "babylonjs/PostProcesses/anaglyphPostProcess";
  76098. export * from "babylonjs/PostProcesses/blackAndWhitePostProcess";
  76099. export * from "babylonjs/PostProcesses/bloomEffect";
  76100. export * from "babylonjs/PostProcesses/bloomMergePostProcess";
  76101. export * from "babylonjs/PostProcesses/blurPostProcess";
  76102. export * from "babylonjs/PostProcesses/chromaticAberrationPostProcess";
  76103. export * from "babylonjs/PostProcesses/circleOfConfusionPostProcess";
  76104. export * from "babylonjs/PostProcesses/colorCorrectionPostProcess";
  76105. export * from "babylonjs/PostProcesses/convolutionPostProcess";
  76106. export * from "babylonjs/PostProcesses/depthOfFieldBlurPostProcess";
  76107. export * from "babylonjs/PostProcesses/depthOfFieldEffect";
  76108. export * from "babylonjs/PostProcesses/depthOfFieldMergePostProcess";
  76109. export * from "babylonjs/PostProcesses/displayPassPostProcess";
  76110. export * from "babylonjs/PostProcesses/extractHighlightsPostProcess";
  76111. export * from "babylonjs/PostProcesses/filterPostProcess";
  76112. export * from "babylonjs/PostProcesses/fxaaPostProcess";
  76113. export * from "babylonjs/PostProcesses/grainPostProcess";
  76114. export * from "babylonjs/PostProcesses/highlightsPostProcess";
  76115. export * from "babylonjs/PostProcesses/imageProcessingPostProcess";
  76116. export * from "babylonjs/PostProcesses/motionBlurPostProcess";
  76117. export * from "babylonjs/PostProcesses/passPostProcess";
  76118. export * from "babylonjs/PostProcesses/postProcess";
  76119. export * from "babylonjs/PostProcesses/postProcessManager";
  76120. export * from "babylonjs/PostProcesses/refractionPostProcess";
  76121. export * from "babylonjs/PostProcesses/RenderPipeline/index";
  76122. export * from "babylonjs/PostProcesses/sharpenPostProcess";
  76123. export * from "babylonjs/PostProcesses/stereoscopicInterlacePostProcess";
  76124. export * from "babylonjs/PostProcesses/tonemapPostProcess";
  76125. export * from "babylonjs/PostProcesses/volumetricLightScatteringPostProcess";
  76126. export * from "babylonjs/PostProcesses/vrDistortionCorrectionPostProcess";
  76127. export * from "babylonjs/PostProcesses/vrMultiviewToSingleviewPostProcess";
  76128. export * from "babylonjs/PostProcesses/screenSpaceReflectionPostProcess";
  76129. export * from "babylonjs/PostProcesses/screenSpaceCurvaturePostProcess";
  76130. }
  76131. declare module "babylonjs/Probes/index" {
  76132. export * from "babylonjs/Probes/reflectionProbe";
  76133. }
  76134. declare module "babylonjs/Rendering/boundingBoxRenderer" {
  76135. import { Scene } from "babylonjs/scene";
  76136. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  76137. import { SmartArray } from "babylonjs/Misc/smartArray";
  76138. import { ISceneComponent } from "babylonjs/sceneComponent";
  76139. import { BoundingBox } from "babylonjs/Culling/boundingBox";
  76140. import "babylonjs/Meshes/Builders/boxBuilder";
  76141. import "babylonjs/Shaders/color.fragment";
  76142. import "babylonjs/Shaders/color.vertex";
  76143. import { Color3 } from "babylonjs/Maths/math.color";
  76144. import { Observable } from "babylonjs/Misc/observable";
  76145. module "babylonjs/scene" {
  76146. interface Scene {
  76147. /** @hidden (Backing field) */
  76148. _boundingBoxRenderer: BoundingBoxRenderer;
  76149. /** @hidden (Backing field) */
  76150. _forceShowBoundingBoxes: boolean;
  76151. /**
  76152. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  76153. */
  76154. forceShowBoundingBoxes: boolean;
  76155. /**
  76156. * Gets the bounding box renderer associated with the scene
  76157. * @returns a BoundingBoxRenderer
  76158. */
  76159. getBoundingBoxRenderer(): BoundingBoxRenderer;
  76160. }
  76161. }
  76162. module "babylonjs/Meshes/abstractMesh" {
  76163. interface AbstractMesh {
  76164. /** @hidden (Backing field) */
  76165. _showBoundingBox: boolean;
  76166. /**
  76167. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  76168. */
  76169. showBoundingBox: boolean;
  76170. }
  76171. }
  76172. /**
  76173. * Component responsible of rendering the bounding box of the meshes in a scene.
  76174. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  76175. */
  76176. export class BoundingBoxRenderer implements ISceneComponent {
  76177. /**
  76178. * The component name helpfull to identify the component in the list of scene components.
  76179. */
  76180. readonly name: string;
  76181. /**
  76182. * The scene the component belongs to.
  76183. */
  76184. scene: Scene;
  76185. /**
  76186. * Color of the bounding box lines placed in front of an object
  76187. */
  76188. frontColor: Color3;
  76189. /**
  76190. * Color of the bounding box lines placed behind an object
  76191. */
  76192. backColor: Color3;
  76193. /**
  76194. * Defines if the renderer should show the back lines or not
  76195. */
  76196. showBackLines: boolean;
  76197. /**
  76198. * Observable raised before rendering a bounding box
  76199. */
  76200. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  76201. /**
  76202. * Observable raised after rendering a bounding box
  76203. */
  76204. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  76205. /**
  76206. * @hidden
  76207. */
  76208. renderList: SmartArray<BoundingBox>;
  76209. private _colorShader;
  76210. private _vertexBuffers;
  76211. private _indexBuffer;
  76212. private _fillIndexBuffer;
  76213. private _fillIndexData;
  76214. /**
  76215. * Instantiates a new bounding box renderer in a scene.
  76216. * @param scene the scene the renderer renders in
  76217. */
  76218. constructor(scene: Scene);
  76219. /**
  76220. * Registers the component in a given scene
  76221. */
  76222. register(): void;
  76223. private _evaluateSubMesh;
  76224. private _activeMesh;
  76225. private _prepareRessources;
  76226. private _createIndexBuffer;
  76227. /**
  76228. * Rebuilds the elements related to this component in case of
  76229. * context lost for instance.
  76230. */
  76231. rebuild(): void;
  76232. /**
  76233. * @hidden
  76234. */
  76235. reset(): void;
  76236. /**
  76237. * Render the bounding boxes of a specific rendering group
  76238. * @param renderingGroupId defines the rendering group to render
  76239. */
  76240. render(renderingGroupId: number): void;
  76241. /**
  76242. * In case of occlusion queries, we can render the occlusion bounding box through this method
  76243. * @param mesh Define the mesh to render the occlusion bounding box for
  76244. */
  76245. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  76246. /**
  76247. * Dispose and release the resources attached to this renderer.
  76248. */
  76249. dispose(): void;
  76250. }
  76251. }
  76252. declare module "babylonjs/Rendering/depthRendererSceneComponent" {
  76253. import { Nullable } from "babylonjs/types";
  76254. import { Scene } from "babylonjs/scene";
  76255. import { DepthRenderer } from "babylonjs/Rendering/depthRenderer";
  76256. import { Camera } from "babylonjs/Cameras/camera";
  76257. import { ISceneComponent } from "babylonjs/sceneComponent";
  76258. module "babylonjs/scene" {
  76259. interface Scene {
  76260. /** @hidden (Backing field) */
  76261. _depthRenderer: {
  76262. [id: string]: DepthRenderer;
  76263. };
  76264. /**
  76265. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  76266. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  76267. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  76268. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  76269. * @returns the created depth renderer
  76270. */
  76271. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  76272. /**
  76273. * Disables a depth renderer for a given camera
  76274. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  76275. */
  76276. disableDepthRenderer(camera?: Nullable<Camera>): void;
  76277. }
  76278. }
  76279. /**
  76280. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  76281. * in several rendering techniques.
  76282. */
  76283. export class DepthRendererSceneComponent implements ISceneComponent {
  76284. /**
  76285. * The component name helpfull to identify the component in the list of scene components.
  76286. */
  76287. readonly name: string;
  76288. /**
  76289. * The scene the component belongs to.
  76290. */
  76291. scene: Scene;
  76292. /**
  76293. * Creates a new instance of the component for the given scene
  76294. * @param scene Defines the scene to register the component in
  76295. */
  76296. constructor(scene: Scene);
  76297. /**
  76298. * Registers the component in a given scene
  76299. */
  76300. register(): void;
  76301. /**
  76302. * Rebuilds the elements related to this component in case of
  76303. * context lost for instance.
  76304. */
  76305. rebuild(): void;
  76306. /**
  76307. * Disposes the component and the associated ressources
  76308. */
  76309. dispose(): void;
  76310. private _gatherRenderTargets;
  76311. private _gatherActiveCameraRenderTargets;
  76312. }
  76313. }
  76314. declare module "babylonjs/Rendering/prePassRendererSceneComponent" {
  76315. import { Nullable } from "babylonjs/types";
  76316. import { Scene } from "babylonjs/scene";
  76317. import { ISceneComponent } from "babylonjs/sceneComponent";
  76318. import { PrePassRenderer } from "babylonjs/Rendering/prePassRenderer";
  76319. module "babylonjs/abstractScene" {
  76320. interface AbstractScene {
  76321. /** @hidden (Backing field) */
  76322. _prePassRenderer: Nullable<PrePassRenderer>;
  76323. /**
  76324. * Gets or Sets the current prepass renderer associated to the scene.
  76325. */
  76326. prePassRenderer: Nullable<PrePassRenderer>;
  76327. /**
  76328. * Enables the prepass and associates it with the scene
  76329. * @returns the PrePassRenderer
  76330. */
  76331. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  76332. /**
  76333. * Disables the prepass associated with the scene
  76334. */
  76335. disablePrePassRenderer(): void;
  76336. }
  76337. }
  76338. /**
  76339. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76340. * in several rendering techniques.
  76341. */
  76342. export class PrePassRendererSceneComponent implements ISceneComponent {
  76343. /**
  76344. * The component name helpful to identify the component in the list of scene components.
  76345. */
  76346. readonly name: string;
  76347. /**
  76348. * The scene the component belongs to.
  76349. */
  76350. scene: Scene;
  76351. /**
  76352. * Creates a new instance of the component for the given scene
  76353. * @param scene Defines the scene to register the component in
  76354. */
  76355. constructor(scene: Scene);
  76356. /**
  76357. * Registers the component in a given scene
  76358. */
  76359. register(): void;
  76360. private _beforeCameraDraw;
  76361. private _afterCameraDraw;
  76362. private _beforeClearStage;
  76363. /**
  76364. * Rebuilds the elements related to this component in case of
  76365. * context lost for instance.
  76366. */
  76367. rebuild(): void;
  76368. /**
  76369. * Disposes the component and the associated ressources
  76370. */
  76371. dispose(): void;
  76372. }
  76373. }
  76374. declare module "babylonjs/Shaders/ShadersInclude/fibonacci" {
  76375. /** @hidden */
  76376. export var fibonacci: {
  76377. name: string;
  76378. shader: string;
  76379. };
  76380. }
  76381. declare module "babylonjs/Shaders/ShadersInclude/diffusionProfile" {
  76382. /** @hidden */
  76383. export var diffusionProfile: {
  76384. name: string;
  76385. shader: string;
  76386. };
  76387. }
  76388. declare module "babylonjs/Shaders/subSurfaceScattering.fragment" {
  76389. import "babylonjs/Shaders/ShadersInclude/fibonacci";
  76390. import "babylonjs/Shaders/ShadersInclude/helperFunctions";
  76391. import "babylonjs/Shaders/ShadersInclude/subSurfaceScatteringFunctions";
  76392. import "babylonjs/Shaders/ShadersInclude/diffusionProfile";
  76393. /** @hidden */
  76394. export var subSurfaceScatteringPixelShader: {
  76395. name: string;
  76396. shader: string;
  76397. };
  76398. }
  76399. declare module "babylonjs/PostProcesses/subSurfaceScatteringPostProcess" {
  76400. import { Nullable } from "babylonjs/types";
  76401. import { Camera } from "babylonjs/Cameras/camera";
  76402. import { PostProcess, PostProcessOptions } from "babylonjs/PostProcesses/postProcess";
  76403. import { Engine } from "babylonjs/Engines/engine";
  76404. import { Scene } from "babylonjs/scene";
  76405. import "babylonjs/Shaders/imageProcessing.fragment";
  76406. import "babylonjs/Shaders/subSurfaceScattering.fragment";
  76407. import "babylonjs/Shaders/postprocess.vertex";
  76408. /**
  76409. * Sub surface scattering post process
  76410. */
  76411. export class SubSurfaceScatteringPostProcess extends PostProcess {
  76412. /**
  76413. * Gets a string identifying the name of the class
  76414. * @returns "SubSurfaceScatteringPostProcess" string
  76415. */
  76416. getClassName(): string;
  76417. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  76418. }
  76419. }
  76420. declare module "babylonjs/Rendering/subSurfaceConfiguration" {
  76421. import { Scene } from "babylonjs/scene";
  76422. import { Color3 } from "babylonjs/Maths/math.color";
  76423. import { SubSurfaceScatteringPostProcess } from "babylonjs/PostProcesses/subSurfaceScatteringPostProcess";
  76424. import { PrePassEffectConfiguration } from "babylonjs/Rendering/prePassEffectConfiguration";
  76425. /**
  76426. * Contains all parameters needed for the prepass to perform
  76427. * screen space subsurface scattering
  76428. */
  76429. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  76430. /** @hidden */
  76431. static _SceneComponentInitialization: (scene: Scene) => void;
  76432. private _ssDiffusionS;
  76433. private _ssFilterRadii;
  76434. private _ssDiffusionD;
  76435. /**
  76436. * Post process to attach for screen space subsurface scattering
  76437. */
  76438. postProcess: SubSurfaceScatteringPostProcess;
  76439. /**
  76440. * Diffusion profile color for subsurface scattering
  76441. */
  76442. get ssDiffusionS(): number[];
  76443. /**
  76444. * Diffusion profile max color channel value for subsurface scattering
  76445. */
  76446. get ssDiffusionD(): number[];
  76447. /**
  76448. * Diffusion profile filter radius for subsurface scattering
  76449. */
  76450. get ssFilterRadii(): number[];
  76451. /**
  76452. * Is subsurface enabled
  76453. */
  76454. enabled: boolean;
  76455. /**
  76456. * Name of the configuration
  76457. */
  76458. name: string;
  76459. /**
  76460. * Diffusion profile colors for subsurface scattering
  76461. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  76462. * See ...
  76463. * Note that you can only store up to 5 of them
  76464. */
  76465. ssDiffusionProfileColors: Color3[];
  76466. /**
  76467. * Defines the ratio real world => scene units.
  76468. * Used for subsurface scattering
  76469. */
  76470. metersPerUnit: number;
  76471. /**
  76472. * Textures that should be present in the MRT for this effect to work
  76473. */
  76474. readonly texturesRequired: number[];
  76475. private _scene;
  76476. /**
  76477. * Builds a subsurface configuration object
  76478. * @param scene The scene
  76479. */
  76480. constructor(scene: Scene);
  76481. /**
  76482. * Adds a new diffusion profile.
  76483. * Useful for more realistic subsurface scattering on diverse materials.
  76484. * @param color The color of the diffusion profile. Should be the average color of the material.
  76485. * @return The index of the diffusion profile for the material subsurface configuration
  76486. */
  76487. addDiffusionProfile(color: Color3): number;
  76488. /**
  76489. * Creates the sss post process
  76490. * @return The created post process
  76491. */
  76492. createPostProcess(): SubSurfaceScatteringPostProcess;
  76493. /**
  76494. * Deletes all diffusion profiles.
  76495. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  76496. */
  76497. clearAllDiffusionProfiles(): void;
  76498. /**
  76499. * Disposes this object
  76500. */
  76501. dispose(): void;
  76502. /**
  76503. * @hidden
  76504. * https://zero-radiance.github.io/post/sampling-diffusion/
  76505. *
  76506. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  76507. * ------------------------------------------------------------------------------------
  76508. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  76509. * PDF[r, phi, s] = r * R[r, phi, s]
  76510. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  76511. * ------------------------------------------------------------------------------------
  76512. * We importance sample the color channel with the widest scattering distance.
  76513. */
  76514. getDiffusionProfileParameters(color: Color3): number;
  76515. /**
  76516. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  76517. * 'u' is the random number (the value of the CDF): [0, 1).
  76518. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  76519. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  76520. */
  76521. private _sampleBurleyDiffusionProfile;
  76522. }
  76523. }
  76524. declare module "babylonjs/Rendering/subSurfaceSceneComponent" {
  76525. import { Nullable } from "babylonjs/types";
  76526. import { Scene } from "babylonjs/scene";
  76527. import { ISceneSerializableComponent } from "babylonjs/sceneComponent";
  76528. import { SubSurfaceConfiguration } from "babylonjs/Rendering/subSurfaceConfiguration";
  76529. import { AbstractScene } from "babylonjs/abstractScene";
  76530. module "babylonjs/abstractScene" {
  76531. interface AbstractScene {
  76532. /** @hidden (Backing field) */
  76533. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76534. /**
  76535. * Gets or Sets the current prepass renderer associated to the scene.
  76536. */
  76537. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  76538. /**
  76539. * Enables the subsurface effect for prepass
  76540. * @returns the SubSurfaceConfiguration
  76541. */
  76542. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  76543. /**
  76544. * Disables the subsurface effect for prepass
  76545. */
  76546. disableSubSurfaceForPrePass(): void;
  76547. }
  76548. }
  76549. /**
  76550. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  76551. * in several rendering techniques.
  76552. */
  76553. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  76554. /**
  76555. * The component name helpful to identify the component in the list of scene components.
  76556. */
  76557. readonly name: string;
  76558. /**
  76559. * The scene the component belongs to.
  76560. */
  76561. scene: Scene;
  76562. /**
  76563. * Creates a new instance of the component for the given scene
  76564. * @param scene Defines the scene to register the component in
  76565. */
  76566. constructor(scene: Scene);
  76567. /**
  76568. * Registers the component in a given scene
  76569. */
  76570. register(): void;
  76571. /**
  76572. * Serializes the component data to the specified json object
  76573. * @param serializationObject The object to serialize to
  76574. */
  76575. serialize(serializationObject: any): void;
  76576. /**
  76577. * Adds all the elements from the container to the scene
  76578. * @param container the container holding the elements
  76579. */
  76580. addFromContainer(container: AbstractScene): void;
  76581. /**
  76582. * Removes all the elements in the container from the scene
  76583. * @param container contains the elements to remove
  76584. * @param dispose if the removed element should be disposed (default: false)
  76585. */
  76586. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  76587. /**
  76588. * Rebuilds the elements related to this component in case of
  76589. * context lost for instance.
  76590. */
  76591. rebuild(): void;
  76592. /**
  76593. * Disposes the component and the associated ressources
  76594. */
  76595. dispose(): void;
  76596. }
  76597. }
  76598. declare module "babylonjs/Shaders/outline.fragment" {
  76599. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76600. import "babylonjs/Shaders/ShadersInclude/logDepthFragment";
  76601. /** @hidden */
  76602. export var outlinePixelShader: {
  76603. name: string;
  76604. shader: string;
  76605. };
  76606. }
  76607. declare module "babylonjs/Shaders/outline.vertex" {
  76608. import "babylonjs/Shaders/ShadersInclude/bonesDeclaration";
  76609. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration";
  76610. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertexDeclaration";
  76611. import "babylonjs/Shaders/ShadersInclude/instancesDeclaration";
  76612. import "babylonjs/Shaders/ShadersInclude/logDepthDeclaration";
  76613. import "babylonjs/Shaders/ShadersInclude/morphTargetsVertex";
  76614. import "babylonjs/Shaders/ShadersInclude/instancesVertex";
  76615. import "babylonjs/Shaders/ShadersInclude/bonesVertex";
  76616. import "babylonjs/Shaders/ShadersInclude/logDepthVertex";
  76617. /** @hidden */
  76618. export var outlineVertexShader: {
  76619. name: string;
  76620. shader: string;
  76621. };
  76622. }
  76623. declare module "babylonjs/Rendering/outlineRenderer" {
  76624. import { SubMesh } from "babylonjs/Meshes/subMesh";
  76625. import { _InstancesBatch } from "babylonjs/Meshes/mesh";
  76626. import { Scene } from "babylonjs/scene";
  76627. import { ISceneComponent } from "babylonjs/sceneComponent";
  76628. import "babylonjs/Shaders/outline.fragment";
  76629. import "babylonjs/Shaders/outline.vertex";
  76630. module "babylonjs/scene" {
  76631. interface Scene {
  76632. /** @hidden */
  76633. _outlineRenderer: OutlineRenderer;
  76634. /**
  76635. * Gets the outline renderer associated with the scene
  76636. * @returns a OutlineRenderer
  76637. */
  76638. getOutlineRenderer(): OutlineRenderer;
  76639. }
  76640. }
  76641. module "babylonjs/Meshes/abstractMesh" {
  76642. interface AbstractMesh {
  76643. /** @hidden (Backing field) */
  76644. _renderOutline: boolean;
  76645. /**
  76646. * Gets or sets a boolean indicating if the outline must be rendered as well
  76647. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  76648. */
  76649. renderOutline: boolean;
  76650. /** @hidden (Backing field) */
  76651. _renderOverlay: boolean;
  76652. /**
  76653. * Gets or sets a boolean indicating if the overlay must be rendered as well
  76654. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  76655. */
  76656. renderOverlay: boolean;
  76657. }
  76658. }
  76659. /**
  76660. * This class is responsible to draw bothe outline/overlay of meshes.
  76661. * It should not be used directly but through the available method on mesh.
  76662. */
  76663. export class OutlineRenderer implements ISceneComponent {
  76664. /**
  76665. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  76666. */
  76667. private static _StencilReference;
  76668. /**
  76669. * The name of the component. Each component must have a unique name.
  76670. */
  76671. name: string;
  76672. /**
  76673. * The scene the component belongs to.
  76674. */
  76675. scene: Scene;
  76676. /**
  76677. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  76678. */
  76679. zOffset: number;
  76680. private _engine;
  76681. private _effect;
  76682. private _cachedDefines;
  76683. private _savedDepthWrite;
  76684. /**
  76685. * Instantiates a new outline renderer. (There could be only one per scene).
  76686. * @param scene Defines the scene it belongs to
  76687. */
  76688. constructor(scene: Scene);
  76689. /**
  76690. * Register the component to one instance of a scene.
  76691. */
  76692. register(): void;
  76693. /**
  76694. * Rebuilds the elements related to this component in case of
  76695. * context lost for instance.
  76696. */
  76697. rebuild(): void;
  76698. /**
  76699. * Disposes the component and the associated ressources.
  76700. */
  76701. dispose(): void;
  76702. /**
  76703. * Renders the outline in the canvas.
  76704. * @param subMesh Defines the sumesh to render
  76705. * @param batch Defines the batch of meshes in case of instances
  76706. * @param useOverlay Defines if the rendering is for the overlay or the outline
  76707. */
  76708. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  76709. /**
  76710. * Returns whether or not the outline renderer is ready for a given submesh.
  76711. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  76712. * @param subMesh Defines the submesh to check readyness for
  76713. * @param useInstances Defines wheter wee are trying to render instances or not
  76714. * @returns true if ready otherwise false
  76715. */
  76716. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  76717. private _beforeRenderingMesh;
  76718. private _afterRenderingMesh;
  76719. }
  76720. }
  76721. declare module "babylonjs/Rendering/index" {
  76722. export * from "babylonjs/Rendering/boundingBoxRenderer";
  76723. export * from "babylonjs/Rendering/depthRenderer";
  76724. export * from "babylonjs/Rendering/depthRendererSceneComponent";
  76725. export * from "babylonjs/Rendering/edgesRenderer";
  76726. export * from "babylonjs/Rendering/geometryBufferRenderer";
  76727. export * from "babylonjs/Rendering/geometryBufferRendererSceneComponent";
  76728. export * from "babylonjs/Rendering/prePassRenderer";
  76729. export * from "babylonjs/Rendering/prePassRendererSceneComponent";
  76730. export * from "babylonjs/Rendering/subSurfaceSceneComponent";
  76731. export * from "babylonjs/Rendering/outlineRenderer";
  76732. export * from "babylonjs/Rendering/renderingGroup";
  76733. export * from "babylonjs/Rendering/renderingManager";
  76734. export * from "babylonjs/Rendering/utilityLayerRenderer";
  76735. }
  76736. declare module "babylonjs/Sprites/ISprites" {
  76737. /**
  76738. * Defines the basic options interface of a Sprite Frame Source Size.
  76739. */
  76740. export interface ISpriteJSONSpriteSourceSize {
  76741. /**
  76742. * number of the original width of the Frame
  76743. */
  76744. w: number;
  76745. /**
  76746. * number of the original height of the Frame
  76747. */
  76748. h: number;
  76749. }
  76750. /**
  76751. * Defines the basic options interface of a Sprite Frame Data.
  76752. */
  76753. export interface ISpriteJSONSpriteFrameData {
  76754. /**
  76755. * number of the x offset of the Frame
  76756. */
  76757. x: number;
  76758. /**
  76759. * number of the y offset of the Frame
  76760. */
  76761. y: number;
  76762. /**
  76763. * number of the width of the Frame
  76764. */
  76765. w: number;
  76766. /**
  76767. * number of the height of the Frame
  76768. */
  76769. h: number;
  76770. }
  76771. /**
  76772. * Defines the basic options interface of a JSON Sprite.
  76773. */
  76774. export interface ISpriteJSONSprite {
  76775. /**
  76776. * string name of the Frame
  76777. */
  76778. filename: string;
  76779. /**
  76780. * ISpriteJSONSpriteFrame basic object of the frame data
  76781. */
  76782. frame: ISpriteJSONSpriteFrameData;
  76783. /**
  76784. * boolean to flag is the frame was rotated.
  76785. */
  76786. rotated: boolean;
  76787. /**
  76788. * boolean to flag is the frame was trimmed.
  76789. */
  76790. trimmed: boolean;
  76791. /**
  76792. * ISpriteJSONSpriteFrame basic object of the source data
  76793. */
  76794. spriteSourceSize: ISpriteJSONSpriteFrameData;
  76795. /**
  76796. * ISpriteJSONSpriteFrame basic object of the source data
  76797. */
  76798. sourceSize: ISpriteJSONSpriteSourceSize;
  76799. }
  76800. /**
  76801. * Defines the basic options interface of a JSON atlas.
  76802. */
  76803. export interface ISpriteJSONAtlas {
  76804. /**
  76805. * Array of objects that contain the frame data.
  76806. */
  76807. frames: Array<ISpriteJSONSprite>;
  76808. /**
  76809. * object basic object containing the sprite meta data.
  76810. */
  76811. meta?: object;
  76812. }
  76813. }
  76814. declare module "babylonjs/Shaders/spriteMap.fragment" {
  76815. /** @hidden */
  76816. export var spriteMapPixelShader: {
  76817. name: string;
  76818. shader: string;
  76819. };
  76820. }
  76821. declare module "babylonjs/Shaders/spriteMap.vertex" {
  76822. /** @hidden */
  76823. export var spriteMapVertexShader: {
  76824. name: string;
  76825. shader: string;
  76826. };
  76827. }
  76828. declare module "babylonjs/Sprites/spriteMap" {
  76829. import { IDisposable, Scene } from "babylonjs/scene";
  76830. import { Vector2, Vector3 } from "babylonjs/Maths/math.vector";
  76831. import { Texture } from "babylonjs/Materials/Textures/texture";
  76832. import { RawTexture } from "babylonjs/Materials/Textures/rawTexture";
  76833. import { ISpriteJSONSprite, ISpriteJSONAtlas } from "babylonjs/Sprites/ISprites";
  76834. import "babylonjs/Meshes/Builders/planeBuilder";
  76835. import "babylonjs/Shaders/spriteMap.fragment";
  76836. import "babylonjs/Shaders/spriteMap.vertex";
  76837. /**
  76838. * Defines the basic options interface of a SpriteMap
  76839. */
  76840. export interface ISpriteMapOptions {
  76841. /**
  76842. * Vector2 of the number of cells in the grid.
  76843. */
  76844. stageSize?: Vector2;
  76845. /**
  76846. * Vector2 of the size of the output plane in World Units.
  76847. */
  76848. outputSize?: Vector2;
  76849. /**
  76850. * Vector3 of the position of the output plane in World Units.
  76851. */
  76852. outputPosition?: Vector3;
  76853. /**
  76854. * Vector3 of the rotation of the output plane.
  76855. */
  76856. outputRotation?: Vector3;
  76857. /**
  76858. * number of layers that the system will reserve in resources.
  76859. */
  76860. layerCount?: number;
  76861. /**
  76862. * number of max animation frames a single cell will reserve in resources.
  76863. */
  76864. maxAnimationFrames?: number;
  76865. /**
  76866. * number cell index of the base tile when the system compiles.
  76867. */
  76868. baseTile?: number;
  76869. /**
  76870. * boolean flip the sprite after its been repositioned by the framing data.
  76871. */
  76872. flipU?: boolean;
  76873. /**
  76874. * Vector3 scalar of the global RGB values of the SpriteMap.
  76875. */
  76876. colorMultiply?: Vector3;
  76877. }
  76878. /**
  76879. * Defines the IDisposable interface in order to be cleanable from resources.
  76880. */
  76881. export interface ISpriteMap extends IDisposable {
  76882. /**
  76883. * String name of the SpriteMap.
  76884. */
  76885. name: string;
  76886. /**
  76887. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  76888. */
  76889. atlasJSON: ISpriteJSONAtlas;
  76890. /**
  76891. * Texture of the SpriteMap.
  76892. */
  76893. spriteSheet: Texture;
  76894. /**
  76895. * The parameters to initialize the SpriteMap with.
  76896. */
  76897. options: ISpriteMapOptions;
  76898. }
  76899. /**
  76900. * Class used to manage a grid restricted sprite deployment on an Output plane.
  76901. */
  76902. export class SpriteMap implements ISpriteMap {
  76903. /** The Name of the spriteMap */
  76904. name: string;
  76905. /** The JSON file with the frame and meta data */
  76906. atlasJSON: ISpriteJSONAtlas;
  76907. /** The systems Sprite Sheet Texture */
  76908. spriteSheet: Texture;
  76909. /** Arguments passed with the Constructor */
  76910. options: ISpriteMapOptions;
  76911. /** Public Sprite Storage array, parsed from atlasJSON */
  76912. sprites: Array<ISpriteJSONSprite>;
  76913. /** Returns the Number of Sprites in the System */
  76914. get spriteCount(): number;
  76915. /** Returns the Position of Output Plane*/
  76916. get position(): Vector3;
  76917. /** Returns the Position of Output Plane*/
  76918. set position(v: Vector3);
  76919. /** Returns the Rotation of Output Plane*/
  76920. get rotation(): Vector3;
  76921. /** Returns the Rotation of Output Plane*/
  76922. set rotation(v: Vector3);
  76923. /** Sets the AnimationMap*/
  76924. get animationMap(): RawTexture;
  76925. /** Sets the AnimationMap*/
  76926. set animationMap(v: RawTexture);
  76927. /** Scene that the SpriteMap was created in */
  76928. private _scene;
  76929. /** Texture Buffer of Float32 that holds tile frame data*/
  76930. private _frameMap;
  76931. /** Texture Buffers of Float32 that holds tileMap data*/
  76932. private _tileMaps;
  76933. /** Texture Buffer of Float32 that holds Animation Data*/
  76934. private _animationMap;
  76935. /** Custom ShaderMaterial Central to the System*/
  76936. private _material;
  76937. /** Custom ShaderMaterial Central to the System*/
  76938. private _output;
  76939. /** Systems Time Ticker*/
  76940. private _time;
  76941. /**
  76942. * Creates a new SpriteMap
  76943. * @param name defines the SpriteMaps Name
  76944. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  76945. * @param spriteSheet is the Texture that the Sprites are on.
  76946. * @param options a basic deployment configuration
  76947. * @param scene The Scene that the map is deployed on
  76948. */
  76949. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  76950. /**
  76951. * Returns tileID location
  76952. * @returns Vector2 the cell position ID
  76953. */
  76954. getTileID(): Vector2;
  76955. /**
  76956. * Gets the UV location of the mouse over the SpriteMap.
  76957. * @returns Vector2 the UV position of the mouse interaction
  76958. */
  76959. getMousePosition(): Vector2;
  76960. /**
  76961. * Creates the "frame" texture Buffer
  76962. * -------------------------------------
  76963. * Structure of frames
  76964. * "filename": "Falling-Water-2.png",
  76965. * "frame": {"x":69,"y":103,"w":24,"h":32},
  76966. * "rotated": true,
  76967. * "trimmed": true,
  76968. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  76969. * "sourceSize": {"w":32,"h":32}
  76970. * @returns RawTexture of the frameMap
  76971. */
  76972. private _createFrameBuffer;
  76973. /**
  76974. * Creates the tileMap texture Buffer
  76975. * @param buffer normally and array of numbers, or a false to generate from scratch
  76976. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  76977. * @returns RawTexture of the tileMap
  76978. */
  76979. private _createTileBuffer;
  76980. /**
  76981. * Modifies the data of the tileMaps
  76982. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  76983. * @param pos is the iVector2 Coordinates of the Tile
  76984. * @param tile The SpriteIndex of the new Tile
  76985. */
  76986. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  76987. /**
  76988. * Creates the animationMap texture Buffer
  76989. * @param buffer normally and array of numbers, or a false to generate from scratch
  76990. * @returns RawTexture of the animationMap
  76991. */
  76992. private _createTileAnimationBuffer;
  76993. /**
  76994. * Modifies the data of the animationMap
  76995. * @param cellID is the Index of the Sprite
  76996. * @param _frame is the target Animation frame
  76997. * @param toCell is the Target Index of the next frame of the animation
  76998. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  76999. * @param speed is a global scalar of the time variable on the map.
  77000. */
  77001. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  77002. /**
  77003. * Exports the .tilemaps file
  77004. */
  77005. saveTileMaps(): void;
  77006. /**
  77007. * Imports the .tilemaps file
  77008. * @param url of the .tilemaps file
  77009. */
  77010. loadTileMaps(url: string): void;
  77011. /**
  77012. * Release associated resources
  77013. */
  77014. dispose(): void;
  77015. }
  77016. }
  77017. declare module "babylonjs/Sprites/spritePackedManager" {
  77018. import { SpriteManager } from "babylonjs/Sprites/spriteManager";
  77019. import { Scene } from "babylonjs/scene";
  77020. /**
  77021. * Class used to manage multiple sprites of different sizes on the same spritesheet
  77022. * @see https://doc.babylonjs.com/babylon101/sprites
  77023. */
  77024. export class SpritePackedManager extends SpriteManager {
  77025. /** defines the packed manager's name */
  77026. name: string;
  77027. /**
  77028. * Creates a new sprite manager from a packed sprite sheet
  77029. * @param name defines the manager's name
  77030. * @param imgUrl defines the sprite sheet url
  77031. * @param capacity defines the maximum allowed number of sprites
  77032. * @param scene defines the hosting scene
  77033. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  77034. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  77035. * @param samplingMode defines the smapling mode to use with spritesheet
  77036. * @param fromPacked set to true; do not alter
  77037. */
  77038. constructor(
  77039. /** defines the packed manager's name */
  77040. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  77041. }
  77042. }
  77043. declare module "babylonjs/Sprites/index" {
  77044. export * from "babylonjs/Sprites/sprite";
  77045. export * from "babylonjs/Sprites/ISprites";
  77046. export * from "babylonjs/Sprites/spriteManager";
  77047. export * from "babylonjs/Sprites/spriteMap";
  77048. export * from "babylonjs/Sprites/spritePackedManager";
  77049. export * from "babylonjs/Sprites/spriteSceneComponent";
  77050. }
  77051. declare module "babylonjs/States/index" {
  77052. export * from "babylonjs/States/alphaCullingState";
  77053. export * from "babylonjs/States/depthCullingState";
  77054. export * from "babylonjs/States/stencilState";
  77055. }
  77056. declare module "babylonjs/Misc/assetsManager" {
  77057. import { Scene } from "babylonjs/scene";
  77058. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  77059. import { IParticleSystem } from "babylonjs/Particles/IParticleSystem";
  77060. import { Skeleton } from "babylonjs/Bones/skeleton";
  77061. import { Observable } from "babylonjs/Misc/observable";
  77062. import { BaseTexture } from "babylonjs/Materials/Textures/baseTexture";
  77063. import { Texture } from "babylonjs/Materials/Textures/texture";
  77064. import { CubeTexture } from "babylonjs/Materials/Textures/cubeTexture";
  77065. import { HDRCubeTexture } from "babylonjs/Materials/Textures/hdrCubeTexture";
  77066. import { EquiRectangularCubeTexture } from "babylonjs/Materials/Textures/equiRectangularCubeTexture";
  77067. import { AnimationGroup } from "babylonjs/Animations/animationGroup";
  77068. import { AssetContainer } from "babylonjs/assetContainer";
  77069. /**
  77070. * Defines the list of states available for a task inside a AssetsManager
  77071. */
  77072. export enum AssetTaskState {
  77073. /**
  77074. * Initialization
  77075. */
  77076. INIT = 0,
  77077. /**
  77078. * Running
  77079. */
  77080. RUNNING = 1,
  77081. /**
  77082. * Done
  77083. */
  77084. DONE = 2,
  77085. /**
  77086. * Error
  77087. */
  77088. ERROR = 3
  77089. }
  77090. /**
  77091. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  77092. */
  77093. export abstract class AbstractAssetTask {
  77094. /**
  77095. * Task name
  77096. */ name: string;
  77097. /**
  77098. * Callback called when the task is successful
  77099. */
  77100. onSuccess: (task: any) => void;
  77101. /**
  77102. * Callback called when the task is not successful
  77103. */
  77104. onError: (task: any, message?: string, exception?: any) => void;
  77105. /**
  77106. * Creates a new AssetsManager
  77107. * @param name defines the name of the task
  77108. */
  77109. constructor(
  77110. /**
  77111. * Task name
  77112. */ name: string);
  77113. private _isCompleted;
  77114. private _taskState;
  77115. private _errorObject;
  77116. /**
  77117. * Get if the task is completed
  77118. */
  77119. get isCompleted(): boolean;
  77120. /**
  77121. * Gets the current state of the task
  77122. */
  77123. get taskState(): AssetTaskState;
  77124. /**
  77125. * Gets the current error object (if task is in error)
  77126. */
  77127. get errorObject(): {
  77128. message?: string;
  77129. exception?: any;
  77130. };
  77131. /**
  77132. * Internal only
  77133. * @hidden
  77134. */
  77135. _setErrorObject(message?: string, exception?: any): void;
  77136. /**
  77137. * Execute the current task
  77138. * @param scene defines the scene where you want your assets to be loaded
  77139. * @param onSuccess is a callback called when the task is successfully executed
  77140. * @param onError is a callback called if an error occurs
  77141. */
  77142. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77143. /**
  77144. * Execute the current task
  77145. * @param scene defines the scene where you want your assets to be loaded
  77146. * @param onSuccess is a callback called when the task is successfully executed
  77147. * @param onError is a callback called if an error occurs
  77148. */
  77149. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77150. /**
  77151. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  77152. * This can be used with failed tasks that have the reason for failure fixed.
  77153. */
  77154. reset(): void;
  77155. private onErrorCallback;
  77156. private onDoneCallback;
  77157. }
  77158. /**
  77159. * Define the interface used by progress events raised during assets loading
  77160. */
  77161. export interface IAssetsProgressEvent {
  77162. /**
  77163. * Defines the number of remaining tasks to process
  77164. */
  77165. remainingCount: number;
  77166. /**
  77167. * Defines the total number of tasks
  77168. */
  77169. totalCount: number;
  77170. /**
  77171. * Defines the task that was just processed
  77172. */
  77173. task: AbstractAssetTask;
  77174. }
  77175. /**
  77176. * Class used to share progress information about assets loading
  77177. */
  77178. export class AssetsProgressEvent implements IAssetsProgressEvent {
  77179. /**
  77180. * Defines the number of remaining tasks to process
  77181. */
  77182. remainingCount: number;
  77183. /**
  77184. * Defines the total number of tasks
  77185. */
  77186. totalCount: number;
  77187. /**
  77188. * Defines the task that was just processed
  77189. */
  77190. task: AbstractAssetTask;
  77191. /**
  77192. * Creates a AssetsProgressEvent
  77193. * @param remainingCount defines the number of remaining tasks to process
  77194. * @param totalCount defines the total number of tasks
  77195. * @param task defines the task that was just processed
  77196. */
  77197. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  77198. }
  77199. /**
  77200. * Define a task used by AssetsManager to load assets into a container
  77201. */
  77202. export class ContainerAssetTask extends AbstractAssetTask {
  77203. /**
  77204. * Defines the name of the task
  77205. */
  77206. name: string;
  77207. /**
  77208. * Defines the list of mesh's names you want to load
  77209. */
  77210. meshesNames: any;
  77211. /**
  77212. * Defines the root url to use as a base to load your meshes and associated resources
  77213. */
  77214. rootUrl: string;
  77215. /**
  77216. * Defines the filename or File of the scene to load from
  77217. */
  77218. sceneFilename: string | File;
  77219. /**
  77220. * Get the loaded asset container
  77221. */
  77222. loadedContainer: AssetContainer;
  77223. /**
  77224. * Gets the list of loaded meshes
  77225. */
  77226. loadedMeshes: Array<AbstractMesh>;
  77227. /**
  77228. * Gets the list of loaded particle systems
  77229. */
  77230. loadedParticleSystems: Array<IParticleSystem>;
  77231. /**
  77232. * Gets the list of loaded skeletons
  77233. */
  77234. loadedSkeletons: Array<Skeleton>;
  77235. /**
  77236. * Gets the list of loaded animation groups
  77237. */
  77238. loadedAnimationGroups: Array<AnimationGroup>;
  77239. /**
  77240. * Callback called when the task is successful
  77241. */
  77242. onSuccess: (task: ContainerAssetTask) => void;
  77243. /**
  77244. * Callback called when the task is successful
  77245. */
  77246. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  77247. /**
  77248. * Creates a new ContainerAssetTask
  77249. * @param name defines the name of the task
  77250. * @param meshesNames defines the list of mesh's names you want to load
  77251. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77252. * @param sceneFilename defines the filename or File of the scene to load from
  77253. */
  77254. constructor(
  77255. /**
  77256. * Defines the name of the task
  77257. */
  77258. name: string,
  77259. /**
  77260. * Defines the list of mesh's names you want to load
  77261. */
  77262. meshesNames: any,
  77263. /**
  77264. * Defines the root url to use as a base to load your meshes and associated resources
  77265. */
  77266. rootUrl: string,
  77267. /**
  77268. * Defines the filename or File of the scene to load from
  77269. */
  77270. sceneFilename: string | File);
  77271. /**
  77272. * Execute the current task
  77273. * @param scene defines the scene where you want your assets to be loaded
  77274. * @param onSuccess is a callback called when the task is successfully executed
  77275. * @param onError is a callback called if an error occurs
  77276. */
  77277. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77278. }
  77279. /**
  77280. * Define a task used by AssetsManager to load meshes
  77281. */
  77282. export class MeshAssetTask extends AbstractAssetTask {
  77283. /**
  77284. * Defines the name of the task
  77285. */
  77286. name: string;
  77287. /**
  77288. * Defines the list of mesh's names you want to load
  77289. */
  77290. meshesNames: any;
  77291. /**
  77292. * Defines the root url to use as a base to load your meshes and associated resources
  77293. */
  77294. rootUrl: string;
  77295. /**
  77296. * Defines the filename or File of the scene to load from
  77297. */
  77298. sceneFilename: string | File;
  77299. /**
  77300. * Gets the list of loaded meshes
  77301. */
  77302. loadedMeshes: Array<AbstractMesh>;
  77303. /**
  77304. * Gets the list of loaded particle systems
  77305. */
  77306. loadedParticleSystems: Array<IParticleSystem>;
  77307. /**
  77308. * Gets the list of loaded skeletons
  77309. */
  77310. loadedSkeletons: Array<Skeleton>;
  77311. /**
  77312. * Gets the list of loaded animation groups
  77313. */
  77314. loadedAnimationGroups: Array<AnimationGroup>;
  77315. /**
  77316. * Callback called when the task is successful
  77317. */
  77318. onSuccess: (task: MeshAssetTask) => void;
  77319. /**
  77320. * Callback called when the task is successful
  77321. */
  77322. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  77323. /**
  77324. * Creates a new MeshAssetTask
  77325. * @param name defines the name of the task
  77326. * @param meshesNames defines the list of mesh's names you want to load
  77327. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  77328. * @param sceneFilename defines the filename or File of the scene to load from
  77329. */
  77330. constructor(
  77331. /**
  77332. * Defines the name of the task
  77333. */
  77334. name: string,
  77335. /**
  77336. * Defines the list of mesh's names you want to load
  77337. */
  77338. meshesNames: any,
  77339. /**
  77340. * Defines the root url to use as a base to load your meshes and associated resources
  77341. */
  77342. rootUrl: string,
  77343. /**
  77344. * Defines the filename or File of the scene to load from
  77345. */
  77346. sceneFilename: string | File);
  77347. /**
  77348. * Execute the current task
  77349. * @param scene defines the scene where you want your assets to be loaded
  77350. * @param onSuccess is a callback called when the task is successfully executed
  77351. * @param onError is a callback called if an error occurs
  77352. */
  77353. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77354. }
  77355. /**
  77356. * Define a task used by AssetsManager to load text content
  77357. */
  77358. export class TextFileAssetTask extends AbstractAssetTask {
  77359. /**
  77360. * Defines the name of the task
  77361. */
  77362. name: string;
  77363. /**
  77364. * Defines the location of the file to load
  77365. */
  77366. url: string;
  77367. /**
  77368. * Gets the loaded text string
  77369. */
  77370. text: string;
  77371. /**
  77372. * Callback called when the task is successful
  77373. */
  77374. onSuccess: (task: TextFileAssetTask) => void;
  77375. /**
  77376. * Callback called when the task is successful
  77377. */
  77378. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  77379. /**
  77380. * Creates a new TextFileAssetTask object
  77381. * @param name defines the name of the task
  77382. * @param url defines the location of the file to load
  77383. */
  77384. constructor(
  77385. /**
  77386. * Defines the name of the task
  77387. */
  77388. name: string,
  77389. /**
  77390. * Defines the location of the file to load
  77391. */
  77392. url: string);
  77393. /**
  77394. * Execute the current task
  77395. * @param scene defines the scene where you want your assets to be loaded
  77396. * @param onSuccess is a callback called when the task is successfully executed
  77397. * @param onError is a callback called if an error occurs
  77398. */
  77399. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77400. }
  77401. /**
  77402. * Define a task used by AssetsManager to load binary data
  77403. */
  77404. export class BinaryFileAssetTask extends AbstractAssetTask {
  77405. /**
  77406. * Defines the name of the task
  77407. */
  77408. name: string;
  77409. /**
  77410. * Defines the location of the file to load
  77411. */
  77412. url: string;
  77413. /**
  77414. * Gets the lodaded data (as an array buffer)
  77415. */
  77416. data: ArrayBuffer;
  77417. /**
  77418. * Callback called when the task is successful
  77419. */
  77420. onSuccess: (task: BinaryFileAssetTask) => void;
  77421. /**
  77422. * Callback called when the task is successful
  77423. */
  77424. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  77425. /**
  77426. * Creates a new BinaryFileAssetTask object
  77427. * @param name defines the name of the new task
  77428. * @param url defines the location of the file to load
  77429. */
  77430. constructor(
  77431. /**
  77432. * Defines the name of the task
  77433. */
  77434. name: string,
  77435. /**
  77436. * Defines the location of the file to load
  77437. */
  77438. url: string);
  77439. /**
  77440. * Execute the current task
  77441. * @param scene defines the scene where you want your assets to be loaded
  77442. * @param onSuccess is a callback called when the task is successfully executed
  77443. * @param onError is a callback called if an error occurs
  77444. */
  77445. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77446. }
  77447. /**
  77448. * Define a task used by AssetsManager to load images
  77449. */
  77450. export class ImageAssetTask extends AbstractAssetTask {
  77451. /**
  77452. * Defines the name of the task
  77453. */
  77454. name: string;
  77455. /**
  77456. * Defines the location of the image to load
  77457. */
  77458. url: string;
  77459. /**
  77460. * Gets the loaded images
  77461. */
  77462. image: HTMLImageElement;
  77463. /**
  77464. * Callback called when the task is successful
  77465. */
  77466. onSuccess: (task: ImageAssetTask) => void;
  77467. /**
  77468. * Callback called when the task is successful
  77469. */
  77470. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  77471. /**
  77472. * Creates a new ImageAssetTask
  77473. * @param name defines the name of the task
  77474. * @param url defines the location of the image to load
  77475. */
  77476. constructor(
  77477. /**
  77478. * Defines the name of the task
  77479. */
  77480. name: string,
  77481. /**
  77482. * Defines the location of the image to load
  77483. */
  77484. url: string);
  77485. /**
  77486. * Execute the current task
  77487. * @param scene defines the scene where you want your assets to be loaded
  77488. * @param onSuccess is a callback called when the task is successfully executed
  77489. * @param onError is a callback called if an error occurs
  77490. */
  77491. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77492. }
  77493. /**
  77494. * Defines the interface used by texture loading tasks
  77495. */
  77496. export interface ITextureAssetTask<TEX extends BaseTexture> {
  77497. /**
  77498. * Gets the loaded texture
  77499. */
  77500. texture: TEX;
  77501. }
  77502. /**
  77503. * Define a task used by AssetsManager to load 2D textures
  77504. */
  77505. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  77506. /**
  77507. * Defines the name of the task
  77508. */
  77509. name: string;
  77510. /**
  77511. * Defines the location of the file to load
  77512. */
  77513. url: string;
  77514. /**
  77515. * Defines if mipmap should not be generated (default is false)
  77516. */
  77517. noMipmap?: boolean | undefined;
  77518. /**
  77519. * Defines if texture must be inverted on Y axis (default is true)
  77520. */
  77521. invertY: boolean;
  77522. /**
  77523. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77524. */
  77525. samplingMode: number;
  77526. /**
  77527. * Gets the loaded texture
  77528. */
  77529. texture: Texture;
  77530. /**
  77531. * Callback called when the task is successful
  77532. */
  77533. onSuccess: (task: TextureAssetTask) => void;
  77534. /**
  77535. * Callback called when the task is successful
  77536. */
  77537. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  77538. /**
  77539. * Creates a new TextureAssetTask object
  77540. * @param name defines the name of the task
  77541. * @param url defines the location of the file to load
  77542. * @param noMipmap defines if mipmap should not be generated (default is false)
  77543. * @param invertY defines if texture must be inverted on Y axis (default is true)
  77544. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77545. */
  77546. constructor(
  77547. /**
  77548. * Defines the name of the task
  77549. */
  77550. name: string,
  77551. /**
  77552. * Defines the location of the file to load
  77553. */
  77554. url: string,
  77555. /**
  77556. * Defines if mipmap should not be generated (default is false)
  77557. */
  77558. noMipmap?: boolean | undefined,
  77559. /**
  77560. * Defines if texture must be inverted on Y axis (default is true)
  77561. */
  77562. invertY?: boolean,
  77563. /**
  77564. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  77565. */
  77566. samplingMode?: number);
  77567. /**
  77568. * Execute the current task
  77569. * @param scene defines the scene where you want your assets to be loaded
  77570. * @param onSuccess is a callback called when the task is successfully executed
  77571. * @param onError is a callback called if an error occurs
  77572. */
  77573. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77574. }
  77575. /**
  77576. * Define a task used by AssetsManager to load cube textures
  77577. */
  77578. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  77579. /**
  77580. * Defines the name of the task
  77581. */
  77582. name: string;
  77583. /**
  77584. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77585. */
  77586. url: string;
  77587. /**
  77588. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77589. */
  77590. extensions?: string[] | undefined;
  77591. /**
  77592. * Defines if mipmaps should not be generated (default is false)
  77593. */
  77594. noMipmap?: boolean | undefined;
  77595. /**
  77596. * Defines the explicit list of files (undefined by default)
  77597. */
  77598. files?: string[] | undefined;
  77599. /**
  77600. * Gets the loaded texture
  77601. */
  77602. texture: CubeTexture;
  77603. /**
  77604. * Callback called when the task is successful
  77605. */
  77606. onSuccess: (task: CubeTextureAssetTask) => void;
  77607. /**
  77608. * Callback called when the task is successful
  77609. */
  77610. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  77611. /**
  77612. * Creates a new CubeTextureAssetTask
  77613. * @param name defines the name of the task
  77614. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77615. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77616. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77617. * @param files defines the explicit list of files (undefined by default)
  77618. */
  77619. constructor(
  77620. /**
  77621. * Defines the name of the task
  77622. */
  77623. name: string,
  77624. /**
  77625. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  77626. */
  77627. url: string,
  77628. /**
  77629. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  77630. */
  77631. extensions?: string[] | undefined,
  77632. /**
  77633. * Defines if mipmaps should not be generated (default is false)
  77634. */
  77635. noMipmap?: boolean | undefined,
  77636. /**
  77637. * Defines the explicit list of files (undefined by default)
  77638. */
  77639. files?: string[] | undefined);
  77640. /**
  77641. * Execute the current task
  77642. * @param scene defines the scene where you want your assets to be loaded
  77643. * @param onSuccess is a callback called when the task is successfully executed
  77644. * @param onError is a callback called if an error occurs
  77645. */
  77646. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77647. }
  77648. /**
  77649. * Define a task used by AssetsManager to load HDR cube textures
  77650. */
  77651. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  77652. /**
  77653. * Defines the name of the task
  77654. */
  77655. name: string;
  77656. /**
  77657. * Defines the location of the file to load
  77658. */
  77659. url: string;
  77660. /**
  77661. * Defines the desired size (the more it increases the longer the generation will be)
  77662. */
  77663. size: number;
  77664. /**
  77665. * Defines if mipmaps should not be generated (default is false)
  77666. */
  77667. noMipmap: boolean;
  77668. /**
  77669. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77670. */
  77671. generateHarmonics: boolean;
  77672. /**
  77673. * 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)
  77674. */
  77675. gammaSpace: boolean;
  77676. /**
  77677. * Internal Use Only
  77678. */
  77679. reserved: boolean;
  77680. /**
  77681. * Gets the loaded texture
  77682. */
  77683. texture: HDRCubeTexture;
  77684. /**
  77685. * Callback called when the task is successful
  77686. */
  77687. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  77688. /**
  77689. * Callback called when the task is successful
  77690. */
  77691. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  77692. /**
  77693. * Creates a new HDRCubeTextureAssetTask object
  77694. * @param name defines the name of the task
  77695. * @param url defines the location of the file to load
  77696. * @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.
  77697. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77698. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77699. * @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)
  77700. * @param reserved Internal use only
  77701. */
  77702. constructor(
  77703. /**
  77704. * Defines the name of the task
  77705. */
  77706. name: string,
  77707. /**
  77708. * Defines the location of the file to load
  77709. */
  77710. url: string,
  77711. /**
  77712. * Defines the desired size (the more it increases the longer the generation will be)
  77713. */
  77714. size: number,
  77715. /**
  77716. * Defines if mipmaps should not be generated (default is false)
  77717. */
  77718. noMipmap?: boolean,
  77719. /**
  77720. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  77721. */
  77722. generateHarmonics?: boolean,
  77723. /**
  77724. * 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)
  77725. */
  77726. gammaSpace?: boolean,
  77727. /**
  77728. * Internal Use Only
  77729. */
  77730. reserved?: boolean);
  77731. /**
  77732. * Execute the current task
  77733. * @param scene defines the scene where you want your assets to be loaded
  77734. * @param onSuccess is a callback called when the task is successfully executed
  77735. * @param onError is a callback called if an error occurs
  77736. */
  77737. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77738. }
  77739. /**
  77740. * Define a task used by AssetsManager to load Equirectangular cube textures
  77741. */
  77742. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  77743. /**
  77744. * Defines the name of the task
  77745. */
  77746. name: string;
  77747. /**
  77748. * Defines the location of the file to load
  77749. */
  77750. url: string;
  77751. /**
  77752. * Defines the desired size (the more it increases the longer the generation will be)
  77753. */
  77754. size: number;
  77755. /**
  77756. * Defines if mipmaps should not be generated (default is false)
  77757. */
  77758. noMipmap: boolean;
  77759. /**
  77760. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77761. * but the standard material would require them in Gamma space) (default is true)
  77762. */
  77763. gammaSpace: boolean;
  77764. /**
  77765. * Gets the loaded texture
  77766. */
  77767. texture: EquiRectangularCubeTexture;
  77768. /**
  77769. * Callback called when the task is successful
  77770. */
  77771. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  77772. /**
  77773. * Callback called when the task is successful
  77774. */
  77775. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  77776. /**
  77777. * Creates a new EquiRectangularCubeTextureAssetTask object
  77778. * @param name defines the name of the task
  77779. * @param url defines the location of the file to load
  77780. * @param size defines the desired size (the more it increases the longer the generation will be)
  77781. * If the size is omitted this implies you are using a preprocessed cubemap.
  77782. * @param noMipmap defines if mipmaps should not be generated (default is false)
  77783. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  77784. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  77785. * (default is true)
  77786. */
  77787. constructor(
  77788. /**
  77789. * Defines the name of the task
  77790. */
  77791. name: string,
  77792. /**
  77793. * Defines the location of the file to load
  77794. */
  77795. url: string,
  77796. /**
  77797. * Defines the desired size (the more it increases the longer the generation will be)
  77798. */
  77799. size: number,
  77800. /**
  77801. * Defines if mipmaps should not be generated (default is false)
  77802. */
  77803. noMipmap?: boolean,
  77804. /**
  77805. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  77806. * but the standard material would require them in Gamma space) (default is true)
  77807. */
  77808. gammaSpace?: boolean);
  77809. /**
  77810. * Execute the current task
  77811. * @param scene defines the scene where you want your assets to be loaded
  77812. * @param onSuccess is a callback called when the task is successfully executed
  77813. * @param onError is a callback called if an error occurs
  77814. */
  77815. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  77816. }
  77817. /**
  77818. * This class can be used to easily import assets into a scene
  77819. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  77820. */
  77821. export class AssetsManager {
  77822. private _scene;
  77823. private _isLoading;
  77824. protected _tasks: AbstractAssetTask[];
  77825. protected _waitingTasksCount: number;
  77826. protected _totalTasksCount: number;
  77827. /**
  77828. * Callback called when all tasks are processed
  77829. */
  77830. onFinish: (tasks: AbstractAssetTask[]) => void;
  77831. /**
  77832. * Callback called when a task is successful
  77833. */
  77834. onTaskSuccess: (task: AbstractAssetTask) => void;
  77835. /**
  77836. * Callback called when a task had an error
  77837. */
  77838. onTaskError: (task: AbstractAssetTask) => void;
  77839. /**
  77840. * Callback called when a task is done (whatever the result is)
  77841. */
  77842. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  77843. /**
  77844. * Observable called when all tasks are processed
  77845. */
  77846. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  77847. /**
  77848. * Observable called when a task had an error
  77849. */
  77850. onTaskErrorObservable: Observable<AbstractAssetTask>;
  77851. /**
  77852. * Observable called when all tasks were executed
  77853. */
  77854. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  77855. /**
  77856. * Observable called when a task is done (whatever the result is)
  77857. */
  77858. onProgressObservable: Observable<IAssetsProgressEvent>;
  77859. /**
  77860. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  77861. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  77862. */
  77863. useDefaultLoadingScreen: boolean;
  77864. /**
  77865. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  77866. * when all assets have been downloaded.
  77867. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  77868. */
  77869. autoHideLoadingUI: boolean;
  77870. /**
  77871. * Creates a new AssetsManager
  77872. * @param scene defines the scene to work on
  77873. */
  77874. constructor(scene: Scene);
  77875. /**
  77876. * Add a ContainerAssetTask to the list of active tasks
  77877. * @param taskName defines the name of the new task
  77878. * @param meshesNames defines the name of meshes to load
  77879. * @param rootUrl defines the root url to use to locate files
  77880. * @param sceneFilename defines the filename of the scene file
  77881. * @returns a new ContainerAssetTask object
  77882. */
  77883. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  77884. /**
  77885. * Add a MeshAssetTask to the list of active tasks
  77886. * @param taskName defines the name of the new task
  77887. * @param meshesNames defines the name of meshes to load
  77888. * @param rootUrl defines the root url to use to locate files
  77889. * @param sceneFilename defines the filename of the scene file
  77890. * @returns a new MeshAssetTask object
  77891. */
  77892. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  77893. /**
  77894. * Add a TextFileAssetTask to the list of active tasks
  77895. * @param taskName defines the name of the new task
  77896. * @param url defines the url of the file to load
  77897. * @returns a new TextFileAssetTask object
  77898. */
  77899. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  77900. /**
  77901. * Add a BinaryFileAssetTask to the list of active tasks
  77902. * @param taskName defines the name of the new task
  77903. * @param url defines the url of the file to load
  77904. * @returns a new BinaryFileAssetTask object
  77905. */
  77906. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  77907. /**
  77908. * Add a ImageAssetTask to the list of active tasks
  77909. * @param taskName defines the name of the new task
  77910. * @param url defines the url of the file to load
  77911. * @returns a new ImageAssetTask object
  77912. */
  77913. addImageTask(taskName: string, url: string): ImageAssetTask;
  77914. /**
  77915. * Add a TextureAssetTask to the list of active tasks
  77916. * @param taskName defines the name of the new task
  77917. * @param url defines the url of the file to load
  77918. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77919. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  77920. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  77921. * @returns a new TextureAssetTask object
  77922. */
  77923. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  77924. /**
  77925. * Add a CubeTextureAssetTask to the list of active tasks
  77926. * @param taskName defines the name of the new task
  77927. * @param url defines the url of the file to load
  77928. * @param extensions defines the extension to use to load the cube map (can be null)
  77929. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77930. * @param files defines the list of files to load (can be null)
  77931. * @returns a new CubeTextureAssetTask object
  77932. */
  77933. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  77934. /**
  77935. *
  77936. * Add a HDRCubeTextureAssetTask to the list of active tasks
  77937. * @param taskName defines the name of the new task
  77938. * @param url defines the url of the file to load
  77939. * @param size defines the size you want for the cubemap (can be null)
  77940. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77941. * @param generateHarmonics defines if you want to automatically generate (true by default)
  77942. * @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)
  77943. * @param reserved Internal use only
  77944. * @returns a new HDRCubeTextureAssetTask object
  77945. */
  77946. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  77947. /**
  77948. *
  77949. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  77950. * @param taskName defines the name of the new task
  77951. * @param url defines the url of the file to load
  77952. * @param size defines the size you want for the cubemap (can be null)
  77953. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  77954. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  77955. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  77956. * @returns a new EquiRectangularCubeTextureAssetTask object
  77957. */
  77958. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  77959. /**
  77960. * Remove a task from the assets manager.
  77961. * @param task the task to remove
  77962. */
  77963. removeTask(task: AbstractAssetTask): void;
  77964. private _decreaseWaitingTasksCount;
  77965. private _runTask;
  77966. /**
  77967. * Reset the AssetsManager and remove all tasks
  77968. * @return the current instance of the AssetsManager
  77969. */
  77970. reset(): AssetsManager;
  77971. /**
  77972. * Start the loading process
  77973. * @return the current instance of the AssetsManager
  77974. */
  77975. load(): AssetsManager;
  77976. /**
  77977. * Start the loading process as an async operation
  77978. * @return a promise returning the list of failed tasks
  77979. */
  77980. loadAsync(): Promise<void>;
  77981. }
  77982. }
  77983. declare module "babylonjs/Misc/deferred" {
  77984. /**
  77985. * Wrapper class for promise with external resolve and reject.
  77986. */
  77987. export class Deferred<T> {
  77988. /**
  77989. * The promise associated with this deferred object.
  77990. */
  77991. readonly promise: Promise<T>;
  77992. private _resolve;
  77993. private _reject;
  77994. /**
  77995. * The resolve method of the promise associated with this deferred object.
  77996. */
  77997. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  77998. /**
  77999. * The reject method of the promise associated with this deferred object.
  78000. */
  78001. get reject(): (reason?: any) => void;
  78002. /**
  78003. * Constructor for this deferred object.
  78004. */
  78005. constructor();
  78006. }
  78007. }
  78008. declare module "babylonjs/Misc/meshExploder" {
  78009. import { Mesh } from "babylonjs/Meshes/mesh";
  78010. /**
  78011. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  78012. */
  78013. export class MeshExploder {
  78014. private _centerMesh;
  78015. private _meshes;
  78016. private _meshesOrigins;
  78017. private _toCenterVectors;
  78018. private _scaledDirection;
  78019. private _newPosition;
  78020. private _centerPosition;
  78021. /**
  78022. * Explodes meshes from a center mesh.
  78023. * @param meshes The meshes to explode.
  78024. * @param centerMesh The mesh to be center of explosion.
  78025. */
  78026. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  78027. private _setCenterMesh;
  78028. /**
  78029. * Get class name
  78030. * @returns "MeshExploder"
  78031. */
  78032. getClassName(): string;
  78033. /**
  78034. * "Exploded meshes"
  78035. * @returns Array of meshes with the centerMesh at index 0.
  78036. */
  78037. getMeshes(): Array<Mesh>;
  78038. /**
  78039. * Explodes meshes giving a specific direction
  78040. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  78041. */
  78042. explode(direction?: number): void;
  78043. }
  78044. }
  78045. declare module "babylonjs/Misc/filesInput" {
  78046. import { Engine } from "babylonjs/Engines/engine";
  78047. import { Scene } from "babylonjs/scene";
  78048. import { ISceneLoaderProgressEvent } from "babylonjs/Loading/sceneLoader";
  78049. import { Nullable } from "babylonjs/types";
  78050. /**
  78051. * Class used to help managing file picking and drag'n'drop
  78052. */
  78053. export class FilesInput {
  78054. /**
  78055. * List of files ready to be loaded
  78056. */
  78057. static get FilesToLoad(): {
  78058. [key: string]: File;
  78059. };
  78060. /**
  78061. * Callback called when a file is processed
  78062. */
  78063. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  78064. private _engine;
  78065. private _currentScene;
  78066. private _sceneLoadedCallback;
  78067. private _progressCallback;
  78068. private _additionalRenderLoopLogicCallback;
  78069. private _textureLoadingCallback;
  78070. private _startingProcessingFilesCallback;
  78071. private _onReloadCallback;
  78072. private _errorCallback;
  78073. private _elementToMonitor;
  78074. private _sceneFileToLoad;
  78075. private _filesToLoad;
  78076. /**
  78077. * Creates a new FilesInput
  78078. * @param engine defines the rendering engine
  78079. * @param scene defines the hosting scene
  78080. * @param sceneLoadedCallback callback called when scene is loaded
  78081. * @param progressCallback callback called to track progress
  78082. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  78083. * @param textureLoadingCallback callback called when a texture is loading
  78084. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  78085. * @param onReloadCallback callback called when a reload is requested
  78086. * @param errorCallback callback call if an error occurs
  78087. */
  78088. 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>);
  78089. private _dragEnterHandler;
  78090. private _dragOverHandler;
  78091. private _dropHandler;
  78092. /**
  78093. * Calls this function to listen to drag'n'drop events on a specific DOM element
  78094. * @param elementToMonitor defines the DOM element to track
  78095. */
  78096. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  78097. /** Gets the current list of files to load */
  78098. get filesToLoad(): File[];
  78099. /**
  78100. * Release all associated resources
  78101. */
  78102. dispose(): void;
  78103. private renderFunction;
  78104. private drag;
  78105. private drop;
  78106. private _traverseFolder;
  78107. private _processFiles;
  78108. /**
  78109. * Load files from a drop event
  78110. * @param event defines the drop event to use as source
  78111. */
  78112. loadFiles(event: any): void;
  78113. private _processReload;
  78114. /**
  78115. * Reload the current scene from the loaded files
  78116. */
  78117. reload(): void;
  78118. }
  78119. }
  78120. declare module "babylonjs/Misc/HighDynamicRange/index" {
  78121. export * from "babylonjs/Misc/HighDynamicRange/cubemapToSphericalPolynomial";
  78122. export * from "babylonjs/Misc/HighDynamicRange/hdr";
  78123. export * from "babylonjs/Misc/HighDynamicRange/panoramaToCubemap";
  78124. }
  78125. declare module "babylonjs/Misc/sceneOptimizer" {
  78126. import { Scene, IDisposable } from "babylonjs/scene";
  78127. import { Observable } from "babylonjs/Misc/observable";
  78128. /**
  78129. * Defines the root class used to create scene optimization to use with SceneOptimizer
  78130. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78131. */
  78132. export class SceneOptimization {
  78133. /**
  78134. * Defines the priority of this optimization (0 by default which means first in the list)
  78135. */
  78136. priority: number;
  78137. /**
  78138. * Gets a string describing the action executed by the current optimization
  78139. * @returns description string
  78140. */
  78141. getDescription(): string;
  78142. /**
  78143. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78144. * @param scene defines the current scene where to apply this optimization
  78145. * @param optimizer defines the current optimizer
  78146. * @returns true if everything that can be done was applied
  78147. */
  78148. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78149. /**
  78150. * Creates the SceneOptimization object
  78151. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78152. * @param desc defines the description associated with the optimization
  78153. */
  78154. constructor(
  78155. /**
  78156. * Defines the priority of this optimization (0 by default which means first in the list)
  78157. */
  78158. priority?: number);
  78159. }
  78160. /**
  78161. * Defines an optimization used to reduce the size of render target textures
  78162. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78163. */
  78164. export class TextureOptimization extends SceneOptimization {
  78165. /**
  78166. * Defines the priority of this optimization (0 by default which means first in the list)
  78167. */
  78168. priority: number;
  78169. /**
  78170. * 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
  78171. */
  78172. maximumSize: number;
  78173. /**
  78174. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78175. */
  78176. step: number;
  78177. /**
  78178. * Gets a string describing the action executed by the current optimization
  78179. * @returns description string
  78180. */
  78181. getDescription(): string;
  78182. /**
  78183. * Creates the TextureOptimization object
  78184. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78185. * @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
  78186. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78187. */
  78188. constructor(
  78189. /**
  78190. * Defines the priority of this optimization (0 by default which means first in the list)
  78191. */
  78192. priority?: number,
  78193. /**
  78194. * 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
  78195. */
  78196. maximumSize?: number,
  78197. /**
  78198. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  78199. */
  78200. step?: number);
  78201. /**
  78202. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78203. * @param scene defines the current scene where to apply this optimization
  78204. * @param optimizer defines the current optimizer
  78205. * @returns true if everything that can be done was applied
  78206. */
  78207. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78208. }
  78209. /**
  78210. * Defines an optimization used to increase or decrease the rendering resolution
  78211. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78212. */
  78213. export class HardwareScalingOptimization extends SceneOptimization {
  78214. /**
  78215. * Defines the priority of this optimization (0 by default which means first in the list)
  78216. */
  78217. priority: number;
  78218. /**
  78219. * Defines the maximum scale to use (2 by default)
  78220. */
  78221. maximumScale: number;
  78222. /**
  78223. * Defines the step to use between two passes (0.5 by default)
  78224. */
  78225. step: number;
  78226. private _currentScale;
  78227. private _directionOffset;
  78228. /**
  78229. * Gets a string describing the action executed by the current optimization
  78230. * @return description string
  78231. */
  78232. getDescription(): string;
  78233. /**
  78234. * Creates the HardwareScalingOptimization object
  78235. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78236. * @param maximumScale defines the maximum scale to use (2 by default)
  78237. * @param step defines the step to use between two passes (0.5 by default)
  78238. */
  78239. constructor(
  78240. /**
  78241. * Defines the priority of this optimization (0 by default which means first in the list)
  78242. */
  78243. priority?: number,
  78244. /**
  78245. * Defines the maximum scale to use (2 by default)
  78246. */
  78247. maximumScale?: number,
  78248. /**
  78249. * Defines the step to use between two passes (0.5 by default)
  78250. */
  78251. step?: number);
  78252. /**
  78253. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78254. * @param scene defines the current scene where to apply this optimization
  78255. * @param optimizer defines the current optimizer
  78256. * @returns true if everything that can be done was applied
  78257. */
  78258. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78259. }
  78260. /**
  78261. * Defines an optimization used to remove shadows
  78262. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78263. */
  78264. export class ShadowsOptimization extends SceneOptimization {
  78265. /**
  78266. * Gets a string describing the action executed by the current optimization
  78267. * @return description string
  78268. */
  78269. getDescription(): string;
  78270. /**
  78271. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78272. * @param scene defines the current scene where to apply this optimization
  78273. * @param optimizer defines the current optimizer
  78274. * @returns true if everything that can be done was applied
  78275. */
  78276. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78277. }
  78278. /**
  78279. * Defines an optimization used to turn post-processes off
  78280. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78281. */
  78282. export class PostProcessesOptimization extends SceneOptimization {
  78283. /**
  78284. * Gets a string describing the action executed by the current optimization
  78285. * @return description string
  78286. */
  78287. getDescription(): string;
  78288. /**
  78289. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78290. * @param scene defines the current scene where to apply this optimization
  78291. * @param optimizer defines the current optimizer
  78292. * @returns true if everything that can be done was applied
  78293. */
  78294. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78295. }
  78296. /**
  78297. * Defines an optimization used to turn lens flares off
  78298. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78299. */
  78300. export class LensFlaresOptimization extends SceneOptimization {
  78301. /**
  78302. * Gets a string describing the action executed by the current optimization
  78303. * @return description string
  78304. */
  78305. getDescription(): string;
  78306. /**
  78307. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78308. * @param scene defines the current scene where to apply this optimization
  78309. * @param optimizer defines the current optimizer
  78310. * @returns true if everything that can be done was applied
  78311. */
  78312. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78313. }
  78314. /**
  78315. * Defines an optimization based on user defined callback.
  78316. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78317. */
  78318. export class CustomOptimization extends SceneOptimization {
  78319. /**
  78320. * Callback called to apply the custom optimization.
  78321. */
  78322. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  78323. /**
  78324. * Callback called to get custom description
  78325. */
  78326. onGetDescription: () => string;
  78327. /**
  78328. * Gets a string describing the action executed by the current optimization
  78329. * @returns description string
  78330. */
  78331. getDescription(): string;
  78332. /**
  78333. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78334. * @param scene defines the current scene where to apply this optimization
  78335. * @param optimizer defines the current optimizer
  78336. * @returns true if everything that can be done was applied
  78337. */
  78338. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78339. }
  78340. /**
  78341. * Defines an optimization used to turn particles off
  78342. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78343. */
  78344. export class ParticlesOptimization extends SceneOptimization {
  78345. /**
  78346. * Gets a string describing the action executed by the current optimization
  78347. * @return description string
  78348. */
  78349. getDescription(): string;
  78350. /**
  78351. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78352. * @param scene defines the current scene where to apply this optimization
  78353. * @param optimizer defines the current optimizer
  78354. * @returns true if everything that can be done was applied
  78355. */
  78356. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78357. }
  78358. /**
  78359. * Defines an optimization used to turn render targets off
  78360. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78361. */
  78362. export class RenderTargetsOptimization extends SceneOptimization {
  78363. /**
  78364. * Gets a string describing the action executed by the current optimization
  78365. * @return description string
  78366. */
  78367. getDescription(): string;
  78368. /**
  78369. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78370. * @param scene defines the current scene where to apply this optimization
  78371. * @param optimizer defines the current optimizer
  78372. * @returns true if everything that can be done was applied
  78373. */
  78374. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  78375. }
  78376. /**
  78377. * Defines an optimization used to merge meshes with compatible materials
  78378. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78379. */
  78380. export class MergeMeshesOptimization extends SceneOptimization {
  78381. private static _UpdateSelectionTree;
  78382. /**
  78383. * Gets or sets a boolean which defines if optimization octree has to be updated
  78384. */
  78385. static get UpdateSelectionTree(): boolean;
  78386. /**
  78387. * Gets or sets a boolean which defines if optimization octree has to be updated
  78388. */
  78389. static set UpdateSelectionTree(value: boolean);
  78390. /**
  78391. * Gets a string describing the action executed by the current optimization
  78392. * @return description string
  78393. */
  78394. getDescription(): string;
  78395. private _canBeMerged;
  78396. /**
  78397. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  78398. * @param scene defines the current scene where to apply this optimization
  78399. * @param optimizer defines the current optimizer
  78400. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  78401. * @returns true if everything that can be done was applied
  78402. */
  78403. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  78404. }
  78405. /**
  78406. * Defines a list of options used by SceneOptimizer
  78407. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78408. */
  78409. export class SceneOptimizerOptions {
  78410. /**
  78411. * Defines the target frame rate to reach (60 by default)
  78412. */
  78413. targetFrameRate: number;
  78414. /**
  78415. * Defines the interval between two checkes (2000ms by default)
  78416. */
  78417. trackerDuration: number;
  78418. /**
  78419. * Gets the list of optimizations to apply
  78420. */
  78421. optimizations: SceneOptimization[];
  78422. /**
  78423. * Creates a new list of options used by SceneOptimizer
  78424. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  78425. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  78426. */
  78427. constructor(
  78428. /**
  78429. * Defines the target frame rate to reach (60 by default)
  78430. */
  78431. targetFrameRate?: number,
  78432. /**
  78433. * Defines the interval between two checkes (2000ms by default)
  78434. */
  78435. trackerDuration?: number);
  78436. /**
  78437. * Add a new optimization
  78438. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  78439. * @returns the current SceneOptimizerOptions
  78440. */
  78441. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  78442. /**
  78443. * Add a new custom optimization
  78444. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  78445. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  78446. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  78447. * @returns the current SceneOptimizerOptions
  78448. */
  78449. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  78450. /**
  78451. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  78452. * @param targetFrameRate defines the target frame rate (60 by default)
  78453. * @returns a SceneOptimizerOptions object
  78454. */
  78455. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78456. /**
  78457. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  78458. * @param targetFrameRate defines the target frame rate (60 by default)
  78459. * @returns a SceneOptimizerOptions object
  78460. */
  78461. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78462. /**
  78463. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  78464. * @param targetFrameRate defines the target frame rate (60 by default)
  78465. * @returns a SceneOptimizerOptions object
  78466. */
  78467. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  78468. }
  78469. /**
  78470. * Class used to run optimizations in order to reach a target frame rate
  78471. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  78472. */
  78473. export class SceneOptimizer implements IDisposable {
  78474. private _isRunning;
  78475. private _options;
  78476. private _scene;
  78477. private _currentPriorityLevel;
  78478. private _targetFrameRate;
  78479. private _trackerDuration;
  78480. private _currentFrameRate;
  78481. private _sceneDisposeObserver;
  78482. private _improvementMode;
  78483. /**
  78484. * Defines an observable called when the optimizer reaches the target frame rate
  78485. */
  78486. onSuccessObservable: Observable<SceneOptimizer>;
  78487. /**
  78488. * Defines an observable called when the optimizer enables an optimization
  78489. */
  78490. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  78491. /**
  78492. * Defines an observable called when the optimizer is not able to reach the target frame rate
  78493. */
  78494. onFailureObservable: Observable<SceneOptimizer>;
  78495. /**
  78496. * Gets a boolean indicating if the optimizer is in improvement mode
  78497. */
  78498. get isInImprovementMode(): boolean;
  78499. /**
  78500. * Gets the current priority level (0 at start)
  78501. */
  78502. get currentPriorityLevel(): number;
  78503. /**
  78504. * Gets the current frame rate checked by the SceneOptimizer
  78505. */
  78506. get currentFrameRate(): number;
  78507. /**
  78508. * Gets or sets the current target frame rate (60 by default)
  78509. */
  78510. get targetFrameRate(): number;
  78511. /**
  78512. * Gets or sets the current target frame rate (60 by default)
  78513. */
  78514. set targetFrameRate(value: number);
  78515. /**
  78516. * Gets or sets the current interval between two checks (every 2000ms by default)
  78517. */
  78518. get trackerDuration(): number;
  78519. /**
  78520. * Gets or sets the current interval between two checks (every 2000ms by default)
  78521. */
  78522. set trackerDuration(value: number);
  78523. /**
  78524. * Gets the list of active optimizations
  78525. */
  78526. get optimizations(): SceneOptimization[];
  78527. /**
  78528. * Creates a new SceneOptimizer
  78529. * @param scene defines the scene to work on
  78530. * @param options defines the options to use with the SceneOptimizer
  78531. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  78532. * @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)
  78533. */
  78534. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  78535. /**
  78536. * Stops the current optimizer
  78537. */
  78538. stop(): void;
  78539. /**
  78540. * Reset the optimizer to initial step (current priority level = 0)
  78541. */
  78542. reset(): void;
  78543. /**
  78544. * Start the optimizer. By default it will try to reach a specific framerate
  78545. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  78546. */
  78547. start(): void;
  78548. private _checkCurrentState;
  78549. /**
  78550. * Release all resources
  78551. */
  78552. dispose(): void;
  78553. /**
  78554. * Helper function to create a SceneOptimizer with one single line of code
  78555. * @param scene defines the scene to work on
  78556. * @param options defines the options to use with the SceneOptimizer
  78557. * @param onSuccess defines a callback to call on success
  78558. * @param onFailure defines a callback to call on failure
  78559. * @returns the new SceneOptimizer object
  78560. */
  78561. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  78562. }
  78563. }
  78564. declare module "babylonjs/Misc/sceneSerializer" {
  78565. import { Scene } from "babylonjs/scene";
  78566. /**
  78567. * Class used to serialize a scene into a string
  78568. */
  78569. export class SceneSerializer {
  78570. /**
  78571. * Clear cache used by a previous serialization
  78572. */
  78573. static ClearCache(): void;
  78574. /**
  78575. * Serialize a scene into a JSON compatible object
  78576. * @param scene defines the scene to serialize
  78577. * @returns a JSON compatible object
  78578. */
  78579. static Serialize(scene: Scene): any;
  78580. /**
  78581. * Serialize a mesh into a JSON compatible object
  78582. * @param toSerialize defines the mesh to serialize
  78583. * @param withParents defines if parents must be serialized as well
  78584. * @param withChildren defines if children must be serialized as well
  78585. * @returns a JSON compatible object
  78586. */
  78587. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  78588. }
  78589. }
  78590. declare module "babylonjs/Misc/textureTools" {
  78591. import { Texture } from "babylonjs/Materials/Textures/texture";
  78592. /**
  78593. * Class used to host texture specific utilities
  78594. */
  78595. export class TextureTools {
  78596. /**
  78597. * Uses the GPU to create a copy texture rescaled at a given size
  78598. * @param texture Texture to copy from
  78599. * @param width defines the desired width
  78600. * @param height defines the desired height
  78601. * @param useBilinearMode defines if bilinear mode has to be used
  78602. * @return the generated texture
  78603. */
  78604. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  78605. }
  78606. }
  78607. declare module "babylonjs/Misc/videoRecorder" {
  78608. import { Nullable } from "babylonjs/types";
  78609. import { Engine } from "babylonjs/Engines/engine";
  78610. /**
  78611. * This represents the different options available for the video capture.
  78612. */
  78613. export interface VideoRecorderOptions {
  78614. /** Defines the mime type of the video. */
  78615. mimeType: string;
  78616. /** Defines the FPS the video should be recorded at. */
  78617. fps: number;
  78618. /** Defines the chunk size for the recording data. */
  78619. recordChunckSize: number;
  78620. /** The audio tracks to attach to the recording. */
  78621. audioTracks?: MediaStreamTrack[];
  78622. }
  78623. /**
  78624. * This can help with recording videos from BabylonJS.
  78625. * This is based on the available WebRTC functionalities of the browser.
  78626. *
  78627. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  78628. */
  78629. export class VideoRecorder {
  78630. private static readonly _defaultOptions;
  78631. /**
  78632. * Returns whether or not the VideoRecorder is available in your browser.
  78633. * @param engine Defines the Babylon Engine.
  78634. * @returns true if supported otherwise false.
  78635. */
  78636. static IsSupported(engine: Engine): boolean;
  78637. private readonly _options;
  78638. private _canvas;
  78639. private _mediaRecorder;
  78640. private _recordedChunks;
  78641. private _fileName;
  78642. private _resolve;
  78643. private _reject;
  78644. /**
  78645. * True when a recording is already in progress.
  78646. */
  78647. get isRecording(): boolean;
  78648. /**
  78649. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  78650. * @param engine Defines the BabylonJS Engine you wish to record.
  78651. * @param options Defines options that can be used to customize the capture.
  78652. */
  78653. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  78654. /**
  78655. * Stops the current recording before the default capture timeout passed in the startRecording function.
  78656. */
  78657. stopRecording(): void;
  78658. /**
  78659. * Starts recording the canvas for a max duration specified in parameters.
  78660. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  78661. * If null no automatic download will start and you can rely on the promise to get the data back.
  78662. * @param maxDuration Defines the maximum recording time in seconds.
  78663. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  78664. * @return A promise callback at the end of the recording with the video data in Blob.
  78665. */
  78666. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  78667. /**
  78668. * Releases internal resources used during the recording.
  78669. */
  78670. dispose(): void;
  78671. private _handleDataAvailable;
  78672. private _handleError;
  78673. private _handleStop;
  78674. }
  78675. }
  78676. declare module "babylonjs/Misc/screenshotTools" {
  78677. import { Camera } from "babylonjs/Cameras/camera";
  78678. import { IScreenshotSize } from "babylonjs/Misc/interfaces/screenshotSize";
  78679. import { Engine } from "babylonjs/Engines/engine";
  78680. /**
  78681. * Class containing a set of static utilities functions for screenshots
  78682. */
  78683. export class ScreenshotTools {
  78684. /**
  78685. * Captures a screenshot of the current rendering
  78686. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78687. * @param engine defines the rendering engine
  78688. * @param camera defines the source camera
  78689. * @param size This parameter can be set to a single number or to an object with the
  78690. * following (optional) properties: precision, width, height. If a single number is passed,
  78691. * it will be used for both width and height. If an object is passed, the screenshot size
  78692. * will be derived from the parameters. The precision property is a multiplier allowing
  78693. * rendering at a higher or lower resolution
  78694. * @param successCallback defines the callback receives a single parameter which contains the
  78695. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78696. * src parameter of an <img> to display it
  78697. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78698. * Check your browser for supported MIME types
  78699. */
  78700. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  78701. /**
  78702. * Captures a screenshot of the current rendering
  78703. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78704. * @param engine defines the rendering engine
  78705. * @param camera defines the source camera
  78706. * @param size This parameter can be set to a single number or to an object with the
  78707. * following (optional) properties: precision, width, height. If a single number is passed,
  78708. * it will be used for both width and height. If an object is passed, the screenshot size
  78709. * will be derived from the parameters. The precision property is a multiplier allowing
  78710. * rendering at a higher or lower resolution
  78711. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  78712. * Check your browser for supported MIME types
  78713. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78714. * to the src parameter of an <img> to display it
  78715. */
  78716. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  78717. /**
  78718. * Generates an image screenshot from the specified camera.
  78719. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78720. * @param engine The engine to use for rendering
  78721. * @param camera The camera to use for rendering
  78722. * @param size This parameter can be set to a single number or to an object with the
  78723. * following (optional) properties: precision, width, height. If a single number is passed,
  78724. * it will be used for both width and height. If an object is passed, the screenshot size
  78725. * will be derived from the parameters. The precision property is a multiplier allowing
  78726. * rendering at a higher or lower resolution
  78727. * @param successCallback The callback receives a single parameter which contains the
  78728. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  78729. * src parameter of an <img> to display it
  78730. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78731. * Check your browser for supported MIME types
  78732. * @param samples Texture samples (default: 1)
  78733. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78734. * @param fileName A name for for the downloaded file.
  78735. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78736. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  78737. */
  78738. 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;
  78739. /**
  78740. * Generates an image screenshot from the specified camera.
  78741. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  78742. * @param engine The engine to use for rendering
  78743. * @param camera The camera to use for rendering
  78744. * @param size This parameter can be set to a single number or to an object with the
  78745. * following (optional) properties: precision, width, height. If a single number is passed,
  78746. * it will be used for both width and height. If an object is passed, the screenshot size
  78747. * will be derived from the parameters. The precision property is a multiplier allowing
  78748. * rendering at a higher or lower resolution
  78749. * @param mimeType The MIME type of the screenshot image (default: image/png).
  78750. * Check your browser for supported MIME types
  78751. * @param samples Texture samples (default: 1)
  78752. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  78753. * @param fileName A name for for the downloaded file.
  78754. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  78755. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  78756. * to the src parameter of an <img> to display it
  78757. */
  78758. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  78759. /**
  78760. * Gets height and width for screenshot size
  78761. * @private
  78762. */
  78763. private static _getScreenshotSize;
  78764. }
  78765. }
  78766. declare module "babylonjs/Misc/dataReader" {
  78767. /**
  78768. * Interface for a data buffer
  78769. */
  78770. export interface IDataBuffer {
  78771. /**
  78772. * Reads bytes from the data buffer.
  78773. * @param byteOffset The byte offset to read
  78774. * @param byteLength The byte length to read
  78775. * @returns A promise that resolves when the bytes are read
  78776. */
  78777. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  78778. /**
  78779. * The byte length of the buffer.
  78780. */
  78781. readonly byteLength: number;
  78782. }
  78783. /**
  78784. * Utility class for reading from a data buffer
  78785. */
  78786. export class DataReader {
  78787. /**
  78788. * The data buffer associated with this data reader.
  78789. */
  78790. readonly buffer: IDataBuffer;
  78791. /**
  78792. * The current byte offset from the beginning of the data buffer.
  78793. */
  78794. byteOffset: number;
  78795. private _dataView;
  78796. private _dataByteOffset;
  78797. /**
  78798. * Constructor
  78799. * @param buffer The buffer to read
  78800. */
  78801. constructor(buffer: IDataBuffer);
  78802. /**
  78803. * Loads the given byte length.
  78804. * @param byteLength The byte length to load
  78805. * @returns A promise that resolves when the load is complete
  78806. */
  78807. loadAsync(byteLength: number): Promise<void>;
  78808. /**
  78809. * Read a unsigned 32-bit integer from the currently loaded data range.
  78810. * @returns The 32-bit integer read
  78811. */
  78812. readUint32(): number;
  78813. /**
  78814. * Read a byte array from the currently loaded data range.
  78815. * @param byteLength The byte length to read
  78816. * @returns The byte array read
  78817. */
  78818. readUint8Array(byteLength: number): Uint8Array;
  78819. /**
  78820. * Read a string from the currently loaded data range.
  78821. * @param byteLength The byte length to read
  78822. * @returns The string read
  78823. */
  78824. readString(byteLength: number): string;
  78825. /**
  78826. * Skips the given byte length the currently loaded data range.
  78827. * @param byteLength The byte length to skip
  78828. */
  78829. skipBytes(byteLength: number): void;
  78830. }
  78831. }
  78832. declare module "babylonjs/Misc/dataStorage" {
  78833. /**
  78834. * Class for storing data to local storage if available or in-memory storage otherwise
  78835. */
  78836. export class DataStorage {
  78837. private static _Storage;
  78838. private static _GetStorage;
  78839. /**
  78840. * Reads a string from the data storage
  78841. * @param key The key to read
  78842. * @param defaultValue The value if the key doesn't exist
  78843. * @returns The string value
  78844. */
  78845. static ReadString(key: string, defaultValue: string): string;
  78846. /**
  78847. * Writes a string to the data storage
  78848. * @param key The key to write
  78849. * @param value The value to write
  78850. */
  78851. static WriteString(key: string, value: string): void;
  78852. /**
  78853. * Reads a boolean from the data storage
  78854. * @param key The key to read
  78855. * @param defaultValue The value if the key doesn't exist
  78856. * @returns The boolean value
  78857. */
  78858. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  78859. /**
  78860. * Writes a boolean to the data storage
  78861. * @param key The key to write
  78862. * @param value The value to write
  78863. */
  78864. static WriteBoolean(key: string, value: boolean): void;
  78865. /**
  78866. * Reads a number from the data storage
  78867. * @param key The key to read
  78868. * @param defaultValue The value if the key doesn't exist
  78869. * @returns The number value
  78870. */
  78871. static ReadNumber(key: string, defaultValue: number): number;
  78872. /**
  78873. * Writes a number to the data storage
  78874. * @param key The key to write
  78875. * @param value The value to write
  78876. */
  78877. static WriteNumber(key: string, value: number): void;
  78878. }
  78879. }
  78880. declare module "babylonjs/Misc/sceneRecorder" {
  78881. import { Scene } from "babylonjs/scene";
  78882. /**
  78883. * Class used to record delta files between 2 scene states
  78884. */
  78885. export class SceneRecorder {
  78886. private _trackedScene;
  78887. private _savedJSON;
  78888. /**
  78889. * Track a given scene. This means the current scene state will be considered the original state
  78890. * @param scene defines the scene to track
  78891. */
  78892. track(scene: Scene): void;
  78893. /**
  78894. * Get the delta between current state and original state
  78895. * @returns a string containing the delta
  78896. */
  78897. getDelta(): any;
  78898. private _compareArray;
  78899. private _compareObjects;
  78900. private _compareCollections;
  78901. private static GetShadowGeneratorById;
  78902. /**
  78903. * Apply a given delta to a given scene
  78904. * @param deltaJSON defines the JSON containing the delta
  78905. * @param scene defines the scene to apply the delta to
  78906. */
  78907. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  78908. private static _ApplyPropertiesToEntity;
  78909. private static _ApplyDeltaForEntity;
  78910. }
  78911. }
  78912. declare module "babylonjs/Misc/trajectoryClassifier" {
  78913. import { DeepImmutable, Nullable } from "babylonjs/types";
  78914. import { Vector3 } from "babylonjs/Maths/math.vector";
  78915. /**
  78916. * A 3D trajectory consisting of an order list of vectors describing a
  78917. * path of motion through 3D space.
  78918. */
  78919. export class Trajectory {
  78920. private _points;
  78921. private readonly _segmentLength;
  78922. /**
  78923. * Serialize to JSON.
  78924. * @returns serialized JSON string
  78925. */
  78926. serialize(): string;
  78927. /**
  78928. * Deserialize from JSON.
  78929. * @param json serialized JSON string
  78930. * @returns deserialized Trajectory
  78931. */
  78932. static Deserialize(json: string): Trajectory;
  78933. /**
  78934. * Create a new empty Trajectory.
  78935. * @param segmentLength radius of discretization for Trajectory points
  78936. */
  78937. constructor(segmentLength?: number);
  78938. /**
  78939. * Get the length of the Trajectory.
  78940. * @returns length of the Trajectory
  78941. */
  78942. getLength(): number;
  78943. /**
  78944. * Append a new point to the Trajectory.
  78945. * NOTE: This implementation has many allocations.
  78946. * @param point point to append to the Trajectory
  78947. */
  78948. add(point: DeepImmutable<Vector3>): void;
  78949. /**
  78950. * Create a new Trajectory with a segment length chosen to make it
  78951. * probable that the new Trajectory will have a specified number of
  78952. * segments. This operation is imprecise.
  78953. * @param targetResolution number of segments desired
  78954. * @returns new Trajectory with approximately the requested number of segments
  78955. */
  78956. resampleAtTargetResolution(targetResolution: number): Trajectory;
  78957. /**
  78958. * Convert Trajectory segments into tokenized representation. This
  78959. * representation is an array of numbers where each nth number is the
  78960. * index of the token which is most similar to the nth segment of the
  78961. * Trajectory.
  78962. * @param tokens list of vectors which serve as discrete tokens
  78963. * @returns list of indices of most similar token per segment
  78964. */
  78965. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  78966. private static _forwardDir;
  78967. private static _inverseFromVec;
  78968. private static _upDir;
  78969. private static _fromToVec;
  78970. private static _lookMatrix;
  78971. /**
  78972. * Transform the rotation (i.e., direction) of a segment to isolate
  78973. * the relative transformation represented by the segment. This operation
  78974. * may or may not succeed due to singularities in the equations that define
  78975. * motion relativity in this context.
  78976. * @param priorVec the origin of the prior segment
  78977. * @param fromVec the origin of the current segment
  78978. * @param toVec the destination of the current segment
  78979. * @param result reference to output variable
  78980. * @returns whether or not transformation was successful
  78981. */
  78982. private static _transformSegmentDirToRef;
  78983. private static _bestMatch;
  78984. private static _score;
  78985. private static _bestScore;
  78986. /**
  78987. * Determine which token vector is most similar to the
  78988. * segment vector.
  78989. * @param segment segment vector
  78990. * @param tokens token vector list
  78991. * @returns index of the most similar token to the segment
  78992. */
  78993. private static _tokenizeSegment;
  78994. }
  78995. /**
  78996. * Class representing a set of known, named trajectories to which Trajectories can be
  78997. * added and using which Trajectories can be recognized.
  78998. */
  78999. export class TrajectoryClassifier {
  79000. private _maximumAllowableMatchCost;
  79001. private _vector3Alphabet;
  79002. private _levenshteinAlphabet;
  79003. private _nameToDescribedTrajectory;
  79004. /**
  79005. * Serialize to JSON.
  79006. * @returns JSON serialization
  79007. */
  79008. serialize(): string;
  79009. /**
  79010. * Deserialize from JSON.
  79011. * @param json JSON serialization
  79012. * @returns deserialized TrajectorySet
  79013. */
  79014. static Deserialize(json: string): TrajectoryClassifier;
  79015. /**
  79016. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  79017. * VERY naive, need to be generating these things from known
  79018. * sets. Better version later, probably eliminating this one.
  79019. * @returns auto-generated TrajectorySet
  79020. */
  79021. static Generate(): TrajectoryClassifier;
  79022. private constructor();
  79023. /**
  79024. * Add a new Trajectory to the set with a given name.
  79025. * @param trajectory new Trajectory to be added
  79026. * @param classification name to which to add the Trajectory
  79027. */
  79028. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  79029. /**
  79030. * Remove a known named trajectory and all Trajectories associated with it.
  79031. * @param classification name to remove
  79032. * @returns whether anything was removed
  79033. */
  79034. deleteClassification(classification: string): boolean;
  79035. /**
  79036. * Attempt to recognize a Trajectory from among all the classifications
  79037. * already known to the classifier.
  79038. * @param trajectory Trajectory to be recognized
  79039. * @returns classification of Trajectory if recognized, null otherwise
  79040. */
  79041. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  79042. }
  79043. }
  79044. declare module "babylonjs/Misc/index" {
  79045. export * from "babylonjs/Misc/andOrNotEvaluator";
  79046. export * from "babylonjs/Misc/assetsManager";
  79047. export * from "babylonjs/Misc/basis";
  79048. export * from "babylonjs/Misc/dds";
  79049. export * from "babylonjs/Misc/decorators";
  79050. export * from "babylonjs/Misc/deferred";
  79051. export * from "babylonjs/Misc/environmentTextureTools";
  79052. export * from "babylonjs/Misc/meshExploder";
  79053. export * from "babylonjs/Misc/filesInput";
  79054. export * from "babylonjs/Misc/HighDynamicRange/index";
  79055. export * from "babylonjs/Misc/khronosTextureContainer";
  79056. export * from "babylonjs/Misc/observable";
  79057. export * from "babylonjs/Misc/performanceMonitor";
  79058. export * from "babylonjs/Misc/promise";
  79059. export * from "babylonjs/Misc/sceneOptimizer";
  79060. export * from "babylonjs/Misc/sceneSerializer";
  79061. export * from "babylonjs/Misc/smartArray";
  79062. export * from "babylonjs/Misc/stringDictionary";
  79063. export * from "babylonjs/Misc/tags";
  79064. export * from "babylonjs/Misc/textureTools";
  79065. export * from "babylonjs/Misc/tga";
  79066. export * from "babylonjs/Misc/tools";
  79067. export * from "babylonjs/Misc/videoRecorder";
  79068. export * from "babylonjs/Misc/virtualJoystick";
  79069. export * from "babylonjs/Misc/workerPool";
  79070. export * from "babylonjs/Misc/logger";
  79071. export * from "babylonjs/Misc/typeStore";
  79072. export * from "babylonjs/Misc/filesInputStore";
  79073. export * from "babylonjs/Misc/deepCopier";
  79074. export * from "babylonjs/Misc/pivotTools";
  79075. export * from "babylonjs/Misc/precisionDate";
  79076. export * from "babylonjs/Misc/screenshotTools";
  79077. export * from "babylonjs/Misc/typeStore";
  79078. export * from "babylonjs/Misc/webRequest";
  79079. export * from "babylonjs/Misc/iInspectable";
  79080. export * from "babylonjs/Misc/brdfTextureTools";
  79081. export * from "babylonjs/Misc/rgbdTextureTools";
  79082. export * from "babylonjs/Misc/gradients";
  79083. export * from "babylonjs/Misc/perfCounter";
  79084. export * from "babylonjs/Misc/fileRequest";
  79085. export * from "babylonjs/Misc/customAnimationFrameRequester";
  79086. export * from "babylonjs/Misc/retryStrategy";
  79087. export * from "babylonjs/Misc/interfaces/screenshotSize";
  79088. export * from "babylonjs/Misc/canvasGenerator";
  79089. export * from "babylonjs/Misc/fileTools";
  79090. export * from "babylonjs/Misc/stringTools";
  79091. export * from "babylonjs/Misc/dataReader";
  79092. export * from "babylonjs/Misc/minMaxReducer";
  79093. export * from "babylonjs/Misc/depthReducer";
  79094. export * from "babylonjs/Misc/dataStorage";
  79095. export * from "babylonjs/Misc/sceneRecorder";
  79096. export * from "babylonjs/Misc/khronosTextureContainer2";
  79097. export * from "babylonjs/Misc/trajectoryClassifier";
  79098. }
  79099. declare module "babylonjs/XR/features/WebXRHitTestLegacy" {
  79100. import { IWebXRFeature } from "babylonjs/XR/webXRFeaturesManager";
  79101. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79102. import { Observable } from "babylonjs/Misc/observable";
  79103. import { Matrix } from "babylonjs/Maths/math.vector";
  79104. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79105. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79106. /**
  79107. * An interface for all Hit test features
  79108. */
  79109. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  79110. /**
  79111. * Triggered when new babylon (transformed) hit test results are available
  79112. */
  79113. onHitTestResultObservable: Observable<T[]>;
  79114. }
  79115. /**
  79116. * Options used for hit testing
  79117. */
  79118. export interface IWebXRLegacyHitTestOptions {
  79119. /**
  79120. * Only test when user interacted with the scene. Default - hit test every frame
  79121. */
  79122. testOnPointerDownOnly?: boolean;
  79123. /**
  79124. * The node to use to transform the local results to world coordinates
  79125. */
  79126. worldParentNode?: TransformNode;
  79127. }
  79128. /**
  79129. * Interface defining the babylon result of raycasting/hit-test
  79130. */
  79131. export interface IWebXRLegacyHitResult {
  79132. /**
  79133. * Transformation matrix that can be applied to a node that will put it in the hit point location
  79134. */
  79135. transformationMatrix: Matrix;
  79136. /**
  79137. * The native hit test result
  79138. */
  79139. xrHitResult: XRHitResult | XRHitTestResult;
  79140. }
  79141. /**
  79142. * The currently-working hit-test module.
  79143. * Hit test (or Ray-casting) is used to interact with the real world.
  79144. * For further information read here - https://github.com/immersive-web/hit-test
  79145. */
  79146. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  79147. /**
  79148. * options to use when constructing this feature
  79149. */
  79150. readonly options: IWebXRLegacyHitTestOptions;
  79151. private _direction;
  79152. private _mat;
  79153. private _onSelectEnabled;
  79154. private _origin;
  79155. /**
  79156. * The module's name
  79157. */
  79158. static readonly Name: string;
  79159. /**
  79160. * The (Babylon) version of this module.
  79161. * This is an integer representing the implementation version.
  79162. * This number does not correspond to the WebXR specs version
  79163. */
  79164. static readonly Version: number;
  79165. /**
  79166. * Populated with the last native XR Hit Results
  79167. */
  79168. lastNativeXRHitResults: XRHitResult[];
  79169. /**
  79170. * Triggered when new babylon (transformed) hit test results are available
  79171. */
  79172. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  79173. /**
  79174. * Creates a new instance of the (legacy version) hit test feature
  79175. * @param _xrSessionManager an instance of WebXRSessionManager
  79176. * @param options options to use when constructing this feature
  79177. */
  79178. constructor(_xrSessionManager: WebXRSessionManager,
  79179. /**
  79180. * options to use when constructing this feature
  79181. */
  79182. options?: IWebXRLegacyHitTestOptions);
  79183. /**
  79184. * execute a hit test with an XR Ray
  79185. *
  79186. * @param xrSession a native xrSession that will execute this hit test
  79187. * @param xrRay the ray (position and direction) to use for ray-casting
  79188. * @param referenceSpace native XR reference space to use for the hit-test
  79189. * @param filter filter function that will filter the results
  79190. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79191. */
  79192. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  79193. /**
  79194. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  79195. * @param event the (select) event to use to select with
  79196. * @param referenceSpace the reference space to use for this hit test
  79197. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  79198. */
  79199. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  79200. /**
  79201. * attach this feature
  79202. * Will usually be called by the features manager
  79203. *
  79204. * @returns true if successful.
  79205. */
  79206. attach(): boolean;
  79207. /**
  79208. * detach this feature.
  79209. * Will usually be called by the features manager
  79210. *
  79211. * @returns true if successful.
  79212. */
  79213. detach(): boolean;
  79214. /**
  79215. * Dispose this feature and all of the resources attached
  79216. */
  79217. dispose(): void;
  79218. protected _onXRFrame(frame: XRFrame): void;
  79219. private _onHitTestResults;
  79220. private _onSelect;
  79221. }
  79222. }
  79223. declare module "babylonjs/XR/features/WebXRHitTest" {
  79224. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79225. import { Observable } from "babylonjs/Misc/observable";
  79226. import { Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79227. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79228. import { IWebXRLegacyHitTestOptions, IWebXRLegacyHitResult, IWebXRHitTestFeature } from "babylonjs/XR/features/WebXRHitTestLegacy";
  79229. /**
  79230. * Options used for hit testing (version 2)
  79231. */
  79232. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  79233. /**
  79234. * Do not create a permanent hit test. Will usually be used when only
  79235. * transient inputs are needed.
  79236. */
  79237. disablePermanentHitTest?: boolean;
  79238. /**
  79239. * Enable transient (for example touch-based) hit test inspections
  79240. */
  79241. enableTransientHitTest?: boolean;
  79242. /**
  79243. * Offset ray for the permanent hit test
  79244. */
  79245. offsetRay?: Vector3;
  79246. /**
  79247. * Offset ray for the transient hit test
  79248. */
  79249. transientOffsetRay?: Vector3;
  79250. /**
  79251. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  79252. */
  79253. useReferenceSpace?: boolean;
  79254. /**
  79255. * Override the default entity type(s) of the hit-test result
  79256. */
  79257. entityTypes?: XRHitTestTrackableType[];
  79258. }
  79259. /**
  79260. * Interface defining the babylon result of hit-test
  79261. */
  79262. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  79263. /**
  79264. * The input source that generated this hit test (if transient)
  79265. */
  79266. inputSource?: XRInputSource;
  79267. /**
  79268. * Is this a transient hit test
  79269. */
  79270. isTransient?: boolean;
  79271. /**
  79272. * Position of the hit test result
  79273. */
  79274. position: Vector3;
  79275. /**
  79276. * Rotation of the hit test result
  79277. */
  79278. rotationQuaternion: Quaternion;
  79279. /**
  79280. * The native hit test result
  79281. */
  79282. xrHitResult: XRHitTestResult;
  79283. }
  79284. /**
  79285. * The currently-working hit-test module.
  79286. * Hit test (or Ray-casting) is used to interact with the real world.
  79287. * For further information read here - https://github.com/immersive-web/hit-test
  79288. *
  79289. * Tested on chrome (mobile) 80.
  79290. */
  79291. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  79292. /**
  79293. * options to use when constructing this feature
  79294. */
  79295. readonly options: IWebXRHitTestOptions;
  79296. private _tmpMat;
  79297. private _tmpPos;
  79298. private _tmpQuat;
  79299. private _transientXrHitTestSource;
  79300. private _xrHitTestSource;
  79301. private initHitTestSource;
  79302. /**
  79303. * The module's name
  79304. */
  79305. static readonly Name: string;
  79306. /**
  79307. * The (Babylon) version of this module.
  79308. * This is an integer representing the implementation version.
  79309. * This number does not correspond to the WebXR specs version
  79310. */
  79311. static readonly Version: number;
  79312. /**
  79313. * When set to true, each hit test will have its own position/rotation objects
  79314. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  79315. * the developers will clone them or copy them as they see fit.
  79316. */
  79317. autoCloneTransformation: boolean;
  79318. /**
  79319. * Triggered when new babylon (transformed) hit test results are available
  79320. * Note - this will be called when results come back from the device. It can be an empty array!!
  79321. */
  79322. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  79323. /**
  79324. * Use this to temporarily pause hit test checks.
  79325. */
  79326. paused: boolean;
  79327. /**
  79328. * Creates a new instance of the hit test feature
  79329. * @param _xrSessionManager an instance of WebXRSessionManager
  79330. * @param options options to use when constructing this feature
  79331. */
  79332. constructor(_xrSessionManager: WebXRSessionManager,
  79333. /**
  79334. * options to use when constructing this feature
  79335. */
  79336. options?: IWebXRHitTestOptions);
  79337. /**
  79338. * attach this feature
  79339. * Will usually be called by the features manager
  79340. *
  79341. * @returns true if successful.
  79342. */
  79343. attach(): boolean;
  79344. /**
  79345. * detach this feature.
  79346. * Will usually be called by the features manager
  79347. *
  79348. * @returns true if successful.
  79349. */
  79350. detach(): boolean;
  79351. /**
  79352. * Dispose this feature and all of the resources attached
  79353. */
  79354. dispose(): void;
  79355. protected _onXRFrame(frame: XRFrame): void;
  79356. private _processWebXRHitTestResult;
  79357. }
  79358. }
  79359. declare module "babylonjs/XR/features/WebXRAnchorSystem" {
  79360. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79361. import { Observable } from "babylonjs/Misc/observable";
  79362. import { Matrix, Vector3, Quaternion } from "babylonjs/Maths/math.vector";
  79363. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79364. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79365. import { IWebXRHitResult } from "babylonjs/XR/features/WebXRHitTest";
  79366. /**
  79367. * Configuration options of the anchor system
  79368. */
  79369. export interface IWebXRAnchorSystemOptions {
  79370. /**
  79371. * a node that will be used to convert local to world coordinates
  79372. */
  79373. worldParentNode?: TransformNode;
  79374. /**
  79375. * If set to true a reference of the created anchors will be kept until the next session starts
  79376. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  79377. */
  79378. doNotRemoveAnchorsOnSessionEnded?: boolean;
  79379. }
  79380. /**
  79381. * A babylon container for an XR Anchor
  79382. */
  79383. export interface IWebXRAnchor {
  79384. /**
  79385. * A babylon-assigned ID for this anchor
  79386. */
  79387. id: number;
  79388. /**
  79389. * Transformation matrix to apply to an object attached to this anchor
  79390. */
  79391. transformationMatrix: Matrix;
  79392. /**
  79393. * The native anchor object
  79394. */
  79395. xrAnchor: XRAnchor;
  79396. /**
  79397. * if defined, this object will be constantly updated by the anchor's position and rotation
  79398. */
  79399. attachedNode?: TransformNode;
  79400. }
  79401. /**
  79402. * An implementation of the anchor system for WebXR.
  79403. * For further information see https://github.com/immersive-web/anchors/
  79404. */
  79405. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  79406. private _options;
  79407. private _lastFrameDetected;
  79408. private _trackedAnchors;
  79409. private _referenceSpaceForFrameAnchors;
  79410. private _futureAnchors;
  79411. /**
  79412. * The module's name
  79413. */
  79414. static readonly Name: string;
  79415. /**
  79416. * The (Babylon) version of this module.
  79417. * This is an integer representing the implementation version.
  79418. * This number does not correspond to the WebXR specs version
  79419. */
  79420. static readonly Version: number;
  79421. /**
  79422. * Observers registered here will be executed when a new anchor was added to the session
  79423. */
  79424. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  79425. /**
  79426. * Observers registered here will be executed when an anchor was removed from the session
  79427. */
  79428. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  79429. /**
  79430. * Observers registered here will be executed when an existing anchor updates
  79431. * This can execute N times every frame
  79432. */
  79433. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  79434. /**
  79435. * Set the reference space to use for anchor creation, when not using a hit test.
  79436. * Will default to the session's reference space if not defined
  79437. */
  79438. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  79439. /**
  79440. * constructs a new anchor system
  79441. * @param _xrSessionManager an instance of WebXRSessionManager
  79442. * @param _options configuration object for this feature
  79443. */
  79444. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  79445. private _tmpVector;
  79446. private _tmpQuaternion;
  79447. private _populateTmpTransformation;
  79448. /**
  79449. * Create a new anchor point using a hit test result at a specific point in the scene
  79450. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79451. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79452. *
  79453. * @param hitTestResult The hit test result to use for this anchor creation
  79454. * @param position an optional position offset for this anchor
  79455. * @param rotationQuaternion an optional rotation offset for this anchor
  79456. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79457. */
  79458. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  79459. /**
  79460. * Add a new anchor at a specific position and rotation
  79461. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  79462. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  79463. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  79464. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  79465. *
  79466. * @param position the position in which to add an anchor
  79467. * @param rotationQuaternion an optional rotation for the anchor transformation
  79468. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  79469. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  79470. */
  79471. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  79472. /**
  79473. * detach this feature.
  79474. * Will usually be called by the features manager
  79475. *
  79476. * @returns true if successful.
  79477. */
  79478. detach(): boolean;
  79479. /**
  79480. * Dispose this feature and all of the resources attached
  79481. */
  79482. dispose(): void;
  79483. protected _onXRFrame(frame: XRFrame): void;
  79484. /**
  79485. * avoiding using Array.find for global support.
  79486. * @param xrAnchor the plane to find in the array
  79487. */
  79488. private _findIndexInAnchorArray;
  79489. private _updateAnchorWithXRFrame;
  79490. private _createAnchorAtTransformation;
  79491. }
  79492. }
  79493. declare module "babylonjs/XR/features/WebXRPlaneDetector" {
  79494. import { TransformNode } from "babylonjs/Meshes/transformNode";
  79495. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79496. import { Observable } from "babylonjs/Misc/observable";
  79497. import { Vector3, Matrix } from "babylonjs/Maths/math.vector";
  79498. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79499. /**
  79500. * Options used in the plane detector module
  79501. */
  79502. export interface IWebXRPlaneDetectorOptions {
  79503. /**
  79504. * The node to use to transform the local results to world coordinates
  79505. */
  79506. worldParentNode?: TransformNode;
  79507. /**
  79508. * If set to true a reference of the created planes will be kept until the next session starts
  79509. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  79510. */
  79511. doNotRemovePlanesOnSessionEnded?: boolean;
  79512. }
  79513. /**
  79514. * A babylon interface for a WebXR plane.
  79515. * A Plane is actually a polygon, built from N points in space
  79516. *
  79517. * Supported in chrome 79, not supported in canary 81 ATM
  79518. */
  79519. export interface IWebXRPlane {
  79520. /**
  79521. * a babylon-assigned ID for this polygon
  79522. */
  79523. id: number;
  79524. /**
  79525. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  79526. */
  79527. polygonDefinition: Array<Vector3>;
  79528. /**
  79529. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  79530. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  79531. */
  79532. transformationMatrix: Matrix;
  79533. /**
  79534. * the native xr-plane object
  79535. */
  79536. xrPlane: XRPlane;
  79537. }
  79538. /**
  79539. * The plane detector is used to detect planes in the real world when in AR
  79540. * For more information see https://github.com/immersive-web/real-world-geometry/
  79541. */
  79542. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  79543. private _options;
  79544. private _detectedPlanes;
  79545. private _enabled;
  79546. private _lastFrameDetected;
  79547. /**
  79548. * The module's name
  79549. */
  79550. static readonly Name: string;
  79551. /**
  79552. * The (Babylon) version of this module.
  79553. * This is an integer representing the implementation version.
  79554. * This number does not correspond to the WebXR specs version
  79555. */
  79556. static readonly Version: number;
  79557. /**
  79558. * Observers registered here will be executed when a new plane was added to the session
  79559. */
  79560. onPlaneAddedObservable: Observable<IWebXRPlane>;
  79561. /**
  79562. * Observers registered here will be executed when a plane is no longer detected in the session
  79563. */
  79564. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  79565. /**
  79566. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  79567. * This can execute N times every frame
  79568. */
  79569. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  79570. /**
  79571. * construct a new Plane Detector
  79572. * @param _xrSessionManager an instance of xr Session manager
  79573. * @param _options configuration to use when constructing this feature
  79574. */
  79575. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  79576. /**
  79577. * detach this feature.
  79578. * Will usually be called by the features manager
  79579. *
  79580. * @returns true if successful.
  79581. */
  79582. detach(): boolean;
  79583. /**
  79584. * Dispose this feature and all of the resources attached
  79585. */
  79586. dispose(): void;
  79587. protected _onXRFrame(frame: XRFrame): void;
  79588. private _init;
  79589. private _updatePlaneWithXRPlane;
  79590. /**
  79591. * avoiding using Array.find for global support.
  79592. * @param xrPlane the plane to find in the array
  79593. */
  79594. private findIndexInPlaneArray;
  79595. }
  79596. }
  79597. declare module "babylonjs/XR/features/WebXRBackgroundRemover" {
  79598. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79599. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79600. import { Observable } from "babylonjs/Misc/observable";
  79601. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79602. /**
  79603. * Options interface for the background remover plugin
  79604. */
  79605. export interface IWebXRBackgroundRemoverOptions {
  79606. /**
  79607. * Further background meshes to disable when entering AR
  79608. */
  79609. backgroundMeshes?: AbstractMesh[];
  79610. /**
  79611. * flags to configure the removal of the environment helper.
  79612. * If not set, the entire background will be removed. If set, flags should be set as well.
  79613. */
  79614. environmentHelperRemovalFlags?: {
  79615. /**
  79616. * Should the skybox be removed (default false)
  79617. */
  79618. skyBox?: boolean;
  79619. /**
  79620. * Should the ground be removed (default false)
  79621. */
  79622. ground?: boolean;
  79623. };
  79624. /**
  79625. * don't disable the environment helper
  79626. */
  79627. ignoreEnvironmentHelper?: boolean;
  79628. }
  79629. /**
  79630. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  79631. */
  79632. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  79633. /**
  79634. * read-only options to be used in this module
  79635. */
  79636. readonly options: IWebXRBackgroundRemoverOptions;
  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. * registered observers will be triggered when the background state changes
  79649. */
  79650. onBackgroundStateChangedObservable: Observable<boolean>;
  79651. /**
  79652. * constructs a new background remover module
  79653. * @param _xrSessionManager the session manager for this module
  79654. * @param options read-only options to be used in this module
  79655. */
  79656. constructor(_xrSessionManager: WebXRSessionManager,
  79657. /**
  79658. * read-only options to be used in this module
  79659. */
  79660. options?: IWebXRBackgroundRemoverOptions);
  79661. /**
  79662. * attach this feature
  79663. * Will usually be called by the features manager
  79664. *
  79665. * @returns true if successful.
  79666. */
  79667. attach(): boolean;
  79668. /**
  79669. * detach this feature.
  79670. * Will usually be called by the features manager
  79671. *
  79672. * @returns true if successful.
  79673. */
  79674. detach(): boolean;
  79675. /**
  79676. * Dispose this feature and all of the resources attached
  79677. */
  79678. dispose(): void;
  79679. protected _onXRFrame(_xrFrame: XRFrame): void;
  79680. private _setBackgroundState;
  79681. }
  79682. }
  79683. declare module "babylonjs/XR/features/WebXRControllerPhysics" {
  79684. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79685. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79686. import { PhysicsImpostor } from "babylonjs/Physics/physicsImpostor";
  79687. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79688. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79689. import { Nullable } from "babylonjs/types";
  79690. /**
  79691. * Options for the controller physics feature
  79692. */
  79693. export class IWebXRControllerPhysicsOptions {
  79694. /**
  79695. * Should the headset get its own impostor
  79696. */
  79697. enableHeadsetImpostor?: boolean;
  79698. /**
  79699. * Optional parameters for the headset impostor
  79700. */
  79701. headsetImpostorParams?: {
  79702. /**
  79703. * The type of impostor to create. Default is sphere
  79704. */
  79705. impostorType: number;
  79706. /**
  79707. * the size of the impostor. Defaults to 10cm
  79708. */
  79709. impostorSize?: number | {
  79710. width: number;
  79711. height: number;
  79712. depth: number;
  79713. };
  79714. /**
  79715. * Friction definitions
  79716. */
  79717. friction?: number;
  79718. /**
  79719. * Restitution
  79720. */
  79721. restitution?: number;
  79722. };
  79723. /**
  79724. * The physics properties of the future impostors
  79725. */
  79726. physicsProperties?: {
  79727. /**
  79728. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  79729. * Note that this requires a physics engine that supports mesh impostors!
  79730. */
  79731. useControllerMesh?: boolean;
  79732. /**
  79733. * The type of impostor to create. Default is sphere
  79734. */
  79735. impostorType?: number;
  79736. /**
  79737. * the size of the impostor. Defaults to 10cm
  79738. */
  79739. impostorSize?: number | {
  79740. width: number;
  79741. height: number;
  79742. depth: number;
  79743. };
  79744. /**
  79745. * Friction definitions
  79746. */
  79747. friction?: number;
  79748. /**
  79749. * Restitution
  79750. */
  79751. restitution?: number;
  79752. };
  79753. /**
  79754. * the xr input to use with this pointer selection
  79755. */
  79756. xrInput: WebXRInput;
  79757. }
  79758. /**
  79759. * Add physics impostor to your webxr controllers,
  79760. * including naive calculation of their linear and angular velocity
  79761. */
  79762. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  79763. private readonly _options;
  79764. private _attachController;
  79765. private _controllers;
  79766. private _debugMode;
  79767. private _delta;
  79768. private _headsetImpostor?;
  79769. private _headsetMesh?;
  79770. private _lastTimestamp;
  79771. private _tmpQuaternion;
  79772. private _tmpVector;
  79773. /**
  79774. * The module's name
  79775. */
  79776. static readonly Name: string;
  79777. /**
  79778. * The (Babylon) version of this module.
  79779. * This is an integer representing the implementation version.
  79780. * This number does not correspond to the webxr specs version
  79781. */
  79782. static readonly Version: number;
  79783. /**
  79784. * Construct a new Controller Physics Feature
  79785. * @param _xrSessionManager the corresponding xr session manager
  79786. * @param _options options to create this feature with
  79787. */
  79788. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  79789. /**
  79790. * @hidden
  79791. * enable debugging - will show console outputs and the impostor mesh
  79792. */
  79793. _enablePhysicsDebug(): void;
  79794. /**
  79795. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  79796. * @param xrController the controller to add
  79797. */
  79798. addController(xrController: WebXRInputSource): void;
  79799. /**
  79800. * attach this feature
  79801. * Will usually be called by the features manager
  79802. *
  79803. * @returns true if successful.
  79804. */
  79805. attach(): boolean;
  79806. /**
  79807. * detach this feature.
  79808. * Will usually be called by the features manager
  79809. *
  79810. * @returns true if successful.
  79811. */
  79812. detach(): boolean;
  79813. /**
  79814. * Get the headset impostor, if enabled
  79815. * @returns the impostor
  79816. */
  79817. getHeadsetImpostor(): PhysicsImpostor | undefined;
  79818. /**
  79819. * Get the physics impostor of a specific controller.
  79820. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  79821. * @param controller the controller or the controller id of which to get the impostor
  79822. * @returns the impostor or null
  79823. */
  79824. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  79825. /**
  79826. * Update the physics properties provided in the constructor
  79827. * @param newProperties the new properties object
  79828. */
  79829. setPhysicsProperties(newProperties: {
  79830. impostorType?: number;
  79831. impostorSize?: number | {
  79832. width: number;
  79833. height: number;
  79834. depth: number;
  79835. };
  79836. friction?: number;
  79837. restitution?: number;
  79838. }): void;
  79839. protected _onXRFrame(_xrFrame: any): void;
  79840. private _detachController;
  79841. }
  79842. }
  79843. declare module "babylonjs/XR/features/WebXRFeaturePointSystem" {
  79844. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79845. import { Observable } from "babylonjs/Misc/observable";
  79846. import { Vector3 } from "babylonjs/Maths/math.vector";
  79847. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79848. /**
  79849. * A babylon interface for a "WebXR" feature point.
  79850. * Represents the position and confidence value of a given feature point.
  79851. */
  79852. export interface IWebXRFeaturePoint {
  79853. /**
  79854. * Represents the position of the feature point in world space.
  79855. */
  79856. position: Vector3;
  79857. /**
  79858. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  79859. */
  79860. confidenceValue: number;
  79861. }
  79862. /**
  79863. * The feature point system is used to detect feature points from real world geometry.
  79864. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  79865. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  79866. */
  79867. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  79868. private _enabled;
  79869. private _featurePointCloud;
  79870. /**
  79871. * The module's name
  79872. */
  79873. static readonly Name: string;
  79874. /**
  79875. * The (Babylon) version of this module.
  79876. * This is an integer representing the implementation version.
  79877. * This number does not correspond to the WebXR specs version
  79878. */
  79879. static readonly Version: number;
  79880. /**
  79881. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  79882. * Will notify the observers about which feature points have been added.
  79883. */
  79884. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  79885. /**
  79886. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  79887. * Will notify the observers about which feature points have been updated.
  79888. */
  79889. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  79890. /**
  79891. * The current feature point cloud maintained across frames.
  79892. */
  79893. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  79894. /**
  79895. * construct the feature point system
  79896. * @param _xrSessionManager an instance of xr Session manager
  79897. */
  79898. constructor(_xrSessionManager: WebXRSessionManager);
  79899. /**
  79900. * Detach this feature.
  79901. * Will usually be called by the features manager
  79902. *
  79903. * @returns true if successful.
  79904. */
  79905. detach(): boolean;
  79906. /**
  79907. * Dispose this feature and all of the resources attached
  79908. */
  79909. dispose(): void;
  79910. /**
  79911. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  79912. */
  79913. protected _onXRFrame(frame: XRFrame): void;
  79914. /**
  79915. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  79916. */
  79917. private _init;
  79918. }
  79919. }
  79920. declare module "babylonjs/XR/features/WebXRHandTracking" {
  79921. import { WebXRAbstractFeature } from "babylonjs/XR/features/WebXRAbstractFeature";
  79922. import { WebXRSessionManager } from "babylonjs/XR/webXRSessionManager";
  79923. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  79924. import { Mesh } from "babylonjs/Meshes/mesh";
  79925. import { WebXRInput } from "babylonjs/XR/webXRInput";
  79926. import { WebXRInputSource } from "babylonjs/XR/webXRInputSource";
  79927. import { Nullable } from "babylonjs/types";
  79928. import { IDisposable } from "babylonjs/scene";
  79929. import { Observable } from "babylonjs/Misc/observable";
  79930. /**
  79931. * Configuration interface for the hand tracking feature
  79932. */
  79933. export interface IWebXRHandTrackingOptions {
  79934. /**
  79935. * The xrInput that will be used as source for new hands
  79936. */
  79937. xrInput: WebXRInput;
  79938. /**
  79939. * Configuration object for the joint meshes
  79940. */
  79941. jointMeshes?: {
  79942. /**
  79943. * Should the meshes created be invisible (defaults to false)
  79944. */
  79945. invisible?: boolean;
  79946. /**
  79947. * A source mesh to be used to create instances. Defaults to a sphere.
  79948. * This mesh will be the source for all other (25) meshes.
  79949. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  79950. */
  79951. sourceMesh?: Mesh;
  79952. /**
  79953. * Should the source mesh stay visible. Defaults to false
  79954. */
  79955. keepOriginalVisible?: boolean;
  79956. /**
  79957. * Scale factor for all instances (defaults to 2)
  79958. */
  79959. scaleFactor?: number;
  79960. /**
  79961. * Should each instance have its own physics impostor
  79962. */
  79963. enablePhysics?: boolean;
  79964. /**
  79965. * If enabled, override default physics properties
  79966. */
  79967. physicsProps?: {
  79968. friction?: number;
  79969. restitution?: number;
  79970. impostorType?: number;
  79971. };
  79972. /**
  79973. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  79974. */
  79975. handMesh?: AbstractMesh;
  79976. };
  79977. }
  79978. /**
  79979. * Parts of the hands divided to writs and finger names
  79980. */
  79981. export const enum HandPart {
  79982. /**
  79983. * HandPart - Wrist
  79984. */
  79985. WRIST = "wrist",
  79986. /**
  79987. * HandPart - The THumb
  79988. */
  79989. THUMB = "thumb",
  79990. /**
  79991. * HandPart - Index finger
  79992. */
  79993. INDEX = "index",
  79994. /**
  79995. * HandPart - Middle finger
  79996. */
  79997. MIDDLE = "middle",
  79998. /**
  79999. * HandPart - Ring finger
  80000. */
  80001. RING = "ring",
  80002. /**
  80003. * HandPart - Little finger
  80004. */
  80005. LITTLE = "little"
  80006. }
  80007. /**
  80008. * Representing a single hand (with its corresponding native XRHand object)
  80009. */
  80010. export class WebXRHand implements IDisposable {
  80011. /** the controller to which the hand correlates */
  80012. readonly xrController: WebXRInputSource;
  80013. /** the meshes to be used to track the hand joints */
  80014. readonly trackedMeshes: AbstractMesh[];
  80015. /**
  80016. * Hand-parts definition (key is HandPart)
  80017. */
  80018. handPartsDefinition: {
  80019. [key: string]: number[];
  80020. };
  80021. /**
  80022. * Populate the HandPartsDefinition object.
  80023. * This is called as a side effect since certain browsers don't have XRHand defined.
  80024. */
  80025. private generateHandPartsDefinition;
  80026. /**
  80027. * Construct a new hand object
  80028. * @param xrController the controller to which the hand correlates
  80029. * @param trackedMeshes the meshes to be used to track the hand joints
  80030. */
  80031. constructor(
  80032. /** the controller to which the hand correlates */
  80033. xrController: WebXRInputSource,
  80034. /** the meshes to be used to track the hand joints */
  80035. trackedMeshes: AbstractMesh[]);
  80036. /**
  80037. * Update this hand from the latest xr frame
  80038. * @param xrFrame xrFrame to update from
  80039. * @param referenceSpace The current viewer reference space
  80040. * @param scaleFactor optional scale factor for the meshes
  80041. */
  80042. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  80043. /**
  80044. * Get meshes of part of the hand
  80045. * @param part the part of hand to get
  80046. * @returns An array of meshes that correlate to the hand part requested
  80047. */
  80048. getHandPartMeshes(part: HandPart): AbstractMesh[];
  80049. /**
  80050. * Dispose this Hand object
  80051. */
  80052. dispose(): void;
  80053. }
  80054. /**
  80055. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  80056. */
  80057. export class WebXRHandTracking extends WebXRAbstractFeature {
  80058. /**
  80059. * options to use when constructing this feature
  80060. */
  80061. readonly options: IWebXRHandTrackingOptions;
  80062. private static _idCounter;
  80063. /**
  80064. * The module's name
  80065. */
  80066. static readonly Name: string;
  80067. /**
  80068. * The (Babylon) version of this module.
  80069. * This is an integer representing the implementation version.
  80070. * This number does not correspond to the WebXR specs version
  80071. */
  80072. static readonly Version: number;
  80073. /**
  80074. * This observable will notify registered observers when a new hand object was added and initialized
  80075. */
  80076. onHandAddedObservable: Observable<WebXRHand>;
  80077. /**
  80078. * This observable will notify its observers right before the hand object is disposed
  80079. */
  80080. onHandRemovedObservable: Observable<WebXRHand>;
  80081. private _hands;
  80082. /**
  80083. * Creates a new instance of the hit test feature
  80084. * @param _xrSessionManager an instance of WebXRSessionManager
  80085. * @param options options to use when constructing this feature
  80086. */
  80087. constructor(_xrSessionManager: WebXRSessionManager,
  80088. /**
  80089. * options to use when constructing this feature
  80090. */
  80091. options: IWebXRHandTrackingOptions);
  80092. /**
  80093. * Check if the needed objects are defined.
  80094. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  80095. */
  80096. isCompatible(): boolean;
  80097. /**
  80098. * attach this feature
  80099. * Will usually be called by the features manager
  80100. *
  80101. * @returns true if successful.
  80102. */
  80103. attach(): boolean;
  80104. /**
  80105. * detach this feature.
  80106. * Will usually be called by the features manager
  80107. *
  80108. * @returns true if successful.
  80109. */
  80110. detach(): boolean;
  80111. /**
  80112. * Dispose this feature and all of the resources attached
  80113. */
  80114. dispose(): void;
  80115. /**
  80116. * Get the hand object according to the controller id
  80117. * @param controllerId the controller id to which we want to get the hand
  80118. * @returns null if not found or the WebXRHand object if found
  80119. */
  80120. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  80121. /**
  80122. * Get a hand object according to the requested handedness
  80123. * @param handedness the handedness to request
  80124. * @returns null if not found or the WebXRHand object if found
  80125. */
  80126. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  80127. protected _onXRFrame(_xrFrame: XRFrame): void;
  80128. private _attachHand;
  80129. private _detachHand;
  80130. }
  80131. }
  80132. declare module "babylonjs/XR/features/index" {
  80133. export * from "babylonjs/XR/features/WebXRHitTestLegacy";
  80134. export * from "babylonjs/XR/features/WebXRAnchorSystem";
  80135. export * from "babylonjs/XR/features/WebXRPlaneDetector";
  80136. export * from "babylonjs/XR/features/WebXRBackgroundRemover";
  80137. export * from "babylonjs/XR/features/WebXRControllerTeleportation";
  80138. export * from "babylonjs/XR/features/WebXRControllerPointerSelection";
  80139. export * from "babylonjs/XR/features/WebXRControllerPhysics";
  80140. export * from "babylonjs/XR/features/WebXRHitTest";
  80141. export * from "babylonjs/XR/features/WebXRFeaturePointSystem";
  80142. export * from "babylonjs/XR/features/WebXRHandTracking";
  80143. }
  80144. declare module "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController" {
  80145. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80146. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80147. import { Scene } from "babylonjs/scene";
  80148. /**
  80149. * The motion controller class for all microsoft mixed reality controllers
  80150. */
  80151. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  80152. protected readonly _mapping: {
  80153. defaultButton: {
  80154. valueNodeName: string;
  80155. unpressedNodeName: string;
  80156. pressedNodeName: string;
  80157. };
  80158. defaultAxis: {
  80159. valueNodeName: string;
  80160. minNodeName: string;
  80161. maxNodeName: string;
  80162. };
  80163. buttons: {
  80164. "xr-standard-trigger": {
  80165. rootNodeName: string;
  80166. componentProperty: string;
  80167. states: string[];
  80168. };
  80169. "xr-standard-squeeze": {
  80170. rootNodeName: string;
  80171. componentProperty: string;
  80172. states: string[];
  80173. };
  80174. "xr-standard-touchpad": {
  80175. rootNodeName: string;
  80176. labelAnchorNodeName: string;
  80177. touchPointNodeName: string;
  80178. };
  80179. "xr-standard-thumbstick": {
  80180. rootNodeName: string;
  80181. componentProperty: string;
  80182. states: string[];
  80183. };
  80184. };
  80185. axes: {
  80186. "xr-standard-touchpad": {
  80187. "x-axis": {
  80188. rootNodeName: string;
  80189. };
  80190. "y-axis": {
  80191. rootNodeName: string;
  80192. };
  80193. };
  80194. "xr-standard-thumbstick": {
  80195. "x-axis": {
  80196. rootNodeName: string;
  80197. };
  80198. "y-axis": {
  80199. rootNodeName: string;
  80200. };
  80201. };
  80202. };
  80203. };
  80204. /**
  80205. * The base url used to load the left and right controller models
  80206. */
  80207. static MODEL_BASE_URL: string;
  80208. /**
  80209. * The name of the left controller model file
  80210. */
  80211. static MODEL_LEFT_FILENAME: string;
  80212. /**
  80213. * The name of the right controller model file
  80214. */
  80215. static MODEL_RIGHT_FILENAME: string;
  80216. profileId: string;
  80217. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80218. protected _getFilenameAndPath(): {
  80219. filename: string;
  80220. path: string;
  80221. };
  80222. protected _getModelLoadingConstraints(): boolean;
  80223. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80224. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80225. protected _updateModel(): void;
  80226. }
  80227. }
  80228. declare module "babylonjs/XR/motionController/webXROculusTouchMotionController" {
  80229. import { WebXRAbstractMotionController, IMinimalMotionControllerObject, MotionControllerHandedness } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80230. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80231. import { Scene } from "babylonjs/scene";
  80232. /**
  80233. * The motion controller class for oculus touch (quest, rift).
  80234. * This class supports legacy mapping as well the standard xr mapping
  80235. */
  80236. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  80237. private _forceLegacyControllers;
  80238. private _modelRootNode;
  80239. /**
  80240. * The base url used to load the left and right controller models
  80241. */
  80242. static MODEL_BASE_URL: string;
  80243. /**
  80244. * The name of the left controller model file
  80245. */
  80246. static MODEL_LEFT_FILENAME: string;
  80247. /**
  80248. * The name of the right controller model file
  80249. */
  80250. static MODEL_RIGHT_FILENAME: string;
  80251. /**
  80252. * Base Url for the Quest controller model.
  80253. */
  80254. static QUEST_MODEL_BASE_URL: string;
  80255. profileId: string;
  80256. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  80257. protected _getFilenameAndPath(): {
  80258. filename: string;
  80259. path: string;
  80260. };
  80261. protected _getModelLoadingConstraints(): boolean;
  80262. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80263. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80264. protected _updateModel(): void;
  80265. /**
  80266. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  80267. * between the touch and touch 2.
  80268. */
  80269. private _isQuest;
  80270. }
  80271. }
  80272. declare module "babylonjs/XR/motionController/webXRHTCViveMotionController" {
  80273. import { IMinimalMotionControllerObject, MotionControllerHandedness, WebXRAbstractMotionController } from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80274. import { Scene } from "babylonjs/scene";
  80275. import { AbstractMesh } from "babylonjs/Meshes/abstractMesh";
  80276. /**
  80277. * The motion controller class for the standard HTC-Vive controllers
  80278. */
  80279. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  80280. private _modelRootNode;
  80281. /**
  80282. * The base url used to load the left and right controller models
  80283. */
  80284. static MODEL_BASE_URL: string;
  80285. /**
  80286. * File name for the controller model.
  80287. */
  80288. static MODEL_FILENAME: string;
  80289. profileId: string;
  80290. /**
  80291. * Create a new Vive motion controller object
  80292. * @param scene the scene to use to create this controller
  80293. * @param gamepadObject the corresponding gamepad object
  80294. * @param handedness the handedness of the controller
  80295. */
  80296. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  80297. protected _getFilenameAndPath(): {
  80298. filename: string;
  80299. path: string;
  80300. };
  80301. protected _getModelLoadingConstraints(): boolean;
  80302. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  80303. protected _setRootMesh(meshes: AbstractMesh[]): void;
  80304. protected _updateModel(): void;
  80305. }
  80306. }
  80307. declare module "babylonjs/XR/motionController/index" {
  80308. export * from "babylonjs/XR/motionController/webXRAbstractMotionController";
  80309. export * from "babylonjs/XR/motionController/webXRControllerComponent";
  80310. export * from "babylonjs/XR/motionController/webXRGenericMotionController";
  80311. export * from "babylonjs/XR/motionController/webXRMicrosoftMixedRealityController";
  80312. export * from "babylonjs/XR/motionController/webXRMotionControllerManager";
  80313. export * from "babylonjs/XR/motionController/webXROculusTouchMotionController";
  80314. export * from "babylonjs/XR/motionController/webXRHTCViveMotionController";
  80315. export * from "babylonjs/XR/motionController/webXRProfiledMotionController";
  80316. }
  80317. declare module "babylonjs/XR/index" {
  80318. export * from "babylonjs/XR/webXRCamera";
  80319. export * from "babylonjs/XR/webXREnterExitUI";
  80320. export * from "babylonjs/XR/webXRExperienceHelper";
  80321. export * from "babylonjs/XR/webXRInput";
  80322. export * from "babylonjs/XR/webXRInputSource";
  80323. export * from "babylonjs/XR/webXRManagedOutputCanvas";
  80324. export * from "babylonjs/XR/webXRTypes";
  80325. export * from "babylonjs/XR/webXRSessionManager";
  80326. export * from "babylonjs/XR/webXRDefaultExperience";
  80327. export * from "babylonjs/XR/webXRFeaturesManager";
  80328. export * from "babylonjs/XR/features/index";
  80329. export * from "babylonjs/XR/motionController/index";
  80330. }
  80331. declare module "babylonjs/index" {
  80332. export * from "babylonjs/abstractScene";
  80333. export * from "babylonjs/Actions/index";
  80334. export * from "babylonjs/Animations/index";
  80335. export * from "babylonjs/assetContainer";
  80336. export * from "babylonjs/Audio/index";
  80337. export * from "babylonjs/Behaviors/index";
  80338. export * from "babylonjs/Bones/index";
  80339. export * from "babylonjs/Cameras/index";
  80340. export * from "babylonjs/Collisions/index";
  80341. export * from "babylonjs/Culling/index";
  80342. export * from "babylonjs/Debug/index";
  80343. export * from "babylonjs/DeviceInput/index";
  80344. export * from "babylonjs/Engines/index";
  80345. export * from "babylonjs/Events/index";
  80346. export * from "babylonjs/Gamepads/index";
  80347. export * from "babylonjs/Gizmos/index";
  80348. export * from "babylonjs/Helpers/index";
  80349. export * from "babylonjs/Instrumentation/index";
  80350. export * from "babylonjs/Layers/index";
  80351. export * from "babylonjs/LensFlares/index";
  80352. export * from "babylonjs/Lights/index";
  80353. export * from "babylonjs/Loading/index";
  80354. export * from "babylonjs/Materials/index";
  80355. export * from "babylonjs/Maths/index";
  80356. export * from "babylonjs/Meshes/index";
  80357. export * from "babylonjs/Morph/index";
  80358. export * from "babylonjs/Navigation/index";
  80359. export * from "babylonjs/node";
  80360. export * from "babylonjs/Offline/index";
  80361. export * from "babylonjs/Particles/index";
  80362. export * from "babylonjs/Physics/index";
  80363. export * from "babylonjs/PostProcesses/index";
  80364. export * from "babylonjs/Probes/index";
  80365. export * from "babylonjs/Rendering/index";
  80366. export * from "babylonjs/scene";
  80367. export * from "babylonjs/sceneComponent";
  80368. export * from "babylonjs/Sprites/index";
  80369. export * from "babylonjs/States/index";
  80370. export * from "babylonjs/Misc/index";
  80371. export * from "babylonjs/XR/index";
  80372. export * from "babylonjs/types";
  80373. }
  80374. declare module "babylonjs/Animations/pathCursor" {
  80375. import { Vector3 } from "babylonjs/Maths/math.vector";
  80376. import { Path2 } from "babylonjs/Maths/math.path";
  80377. /**
  80378. * A cursor which tracks a point on a path
  80379. */
  80380. export class PathCursor {
  80381. private path;
  80382. /**
  80383. * Stores path cursor callbacks for when an onchange event is triggered
  80384. */
  80385. private _onchange;
  80386. /**
  80387. * The value of the path cursor
  80388. */
  80389. value: number;
  80390. /**
  80391. * The animation array of the path cursor
  80392. */
  80393. animations: Animation[];
  80394. /**
  80395. * Initializes the path cursor
  80396. * @param path The path to track
  80397. */
  80398. constructor(path: Path2);
  80399. /**
  80400. * Gets the cursor point on the path
  80401. * @returns A point on the path cursor at the cursor location
  80402. */
  80403. getPoint(): Vector3;
  80404. /**
  80405. * Moves the cursor ahead by the step amount
  80406. * @param step The amount to move the cursor forward
  80407. * @returns This path cursor
  80408. */
  80409. moveAhead(step?: number): PathCursor;
  80410. /**
  80411. * Moves the cursor behind by the step amount
  80412. * @param step The amount to move the cursor back
  80413. * @returns This path cursor
  80414. */
  80415. moveBack(step?: number): PathCursor;
  80416. /**
  80417. * Moves the cursor by the step amount
  80418. * If the step amount is greater than one, an exception is thrown
  80419. * @param step The amount to move the cursor
  80420. * @returns This path cursor
  80421. */
  80422. move(step: number): PathCursor;
  80423. /**
  80424. * Ensures that the value is limited between zero and one
  80425. * @returns This path cursor
  80426. */
  80427. private ensureLimits;
  80428. /**
  80429. * Runs onchange callbacks on change (used by the animation engine)
  80430. * @returns This path cursor
  80431. */
  80432. private raiseOnChange;
  80433. /**
  80434. * Executes a function on change
  80435. * @param f A path cursor onchange callback
  80436. * @returns This path cursor
  80437. */
  80438. onchange(f: (cursor: PathCursor) => void): PathCursor;
  80439. }
  80440. }
  80441. declare module "babylonjs/Engines/Processors/Expressions/Operators/index" {
  80442. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineAndOperator";
  80443. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineArithmeticOperator";
  80444. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineIsDefinedOperator";
  80445. export * from "babylonjs/Engines/Processors/Expressions/Operators/shaderDefineOrOperator";
  80446. }
  80447. declare module "babylonjs/Engines/Processors/Expressions/index" {
  80448. export * from "babylonjs/Engines/Processors/Expressions/shaderDefineExpression";
  80449. export * from "babylonjs/Engines/Processors/Expressions/Operators/index";
  80450. }
  80451. declare module "babylonjs/Engines/Processors/index" {
  80452. export * from "babylonjs/Engines/Processors/iShaderProcessor";
  80453. export * from "babylonjs/Engines/Processors/Expressions/index";
  80454. export * from "babylonjs/Engines/Processors/shaderCodeConditionNode";
  80455. export * from "babylonjs/Engines/Processors/shaderCodeCursor";
  80456. export * from "babylonjs/Engines/Processors/shaderCodeNode";
  80457. export * from "babylonjs/Engines/Processors/shaderCodeTestNode";
  80458. export * from "babylonjs/Engines/Processors/shaderProcessingOptions";
  80459. export * from "babylonjs/Engines/Processors/shaderProcessor";
  80460. export * from "babylonjs/Engines/Processors/shaderCodeInliner";
  80461. }
  80462. declare module "babylonjs/Legacy/legacy" {
  80463. import * as Babylon from "babylonjs/index";
  80464. export * from "babylonjs/index";
  80465. }
  80466. declare module "babylonjs/Shaders/blur.fragment" {
  80467. /** @hidden */
  80468. export var blurPixelShader: {
  80469. name: string;
  80470. shader: string;
  80471. };
  80472. }
  80473. declare module "babylonjs/Shaders/ShadersInclude/pointCloudVertexDeclaration" {
  80474. /** @hidden */
  80475. export var pointCloudVertexDeclaration: {
  80476. name: string;
  80477. shader: string;
  80478. };
  80479. }
  80480. declare module "babylonjs" {
  80481. export * from "babylonjs/Legacy/legacy";
  80482. }
  80483. declare module BABYLON {
  80484. /** Alias type for value that can be null */
  80485. export type Nullable<T> = T | null;
  80486. /**
  80487. * Alias type for number that are floats
  80488. * @ignorenaming
  80489. */
  80490. export type float = number;
  80491. /**
  80492. * Alias type for number that are doubles.
  80493. * @ignorenaming
  80494. */
  80495. export type double = number;
  80496. /**
  80497. * Alias type for number that are integer
  80498. * @ignorenaming
  80499. */
  80500. export type int = number;
  80501. /** Alias type for number array or Float32Array */
  80502. export type FloatArray = number[] | Float32Array;
  80503. /** Alias type for number array or Float32Array or Int32Array or Uint32Array or Uint16Array */
  80504. export type IndicesArray = number[] | Int32Array | Uint32Array | Uint16Array;
  80505. /**
  80506. * Alias for types that can be used by a Buffer or VertexBuffer.
  80507. */
  80508. export type DataArray = number[] | ArrayBuffer | ArrayBufferView;
  80509. /**
  80510. * Alias type for primitive types
  80511. * @ignorenaming
  80512. */
  80513. type Primitive = undefined | null | boolean | string | number | Function;
  80514. /**
  80515. * Type modifier to make all the properties of an object Readonly
  80516. */
  80517. export type Immutable<T> = T extends Primitive ? T : T extends Array<infer U> ? ReadonlyArray<U> : DeepImmutable<T>;
  80518. /**
  80519. * Type modifier to make all the properties of an object Readonly recursively
  80520. */
  80521. export type DeepImmutable<T> = T extends Primitive ? T : T extends Array<infer U> ? DeepImmutableArray<U> : DeepImmutableObject<T>;
  80522. /**
  80523. * Type modifier to make object properties readonly.
  80524. */
  80525. export type DeepImmutableObject<T> = {
  80526. readonly [K in keyof T]: DeepImmutable<T[K]>;
  80527. };
  80528. /** @hidden */
  80529. interface DeepImmutableArray<T> extends ReadonlyArray<DeepImmutable<T>> {
  80530. }
  80531. }
  80532. declare module BABYLON {
  80533. /**
  80534. * A class serves as a medium between the observable and its observers
  80535. */
  80536. export class EventState {
  80537. /**
  80538. * Create a new EventState
  80539. * @param mask defines the mask associated with this state
  80540. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80541. * @param target defines the original target of the state
  80542. * @param currentTarget defines the current target of the state
  80543. */
  80544. constructor(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any);
  80545. /**
  80546. * Initialize the current event state
  80547. * @param mask defines the mask associated with this state
  80548. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  80549. * @param target defines the original target of the state
  80550. * @param currentTarget defines the current target of the state
  80551. * @returns the current event state
  80552. */
  80553. initalize(mask: number, skipNextObservers?: boolean, target?: any, currentTarget?: any): EventState;
  80554. /**
  80555. * An Observer can set this property to true to prevent subsequent observers of being notified
  80556. */
  80557. skipNextObservers: boolean;
  80558. /**
  80559. * Get the mask value that were used to trigger the event corresponding to this EventState object
  80560. */
  80561. mask: number;
  80562. /**
  80563. * The object that originally notified the event
  80564. */
  80565. target?: any;
  80566. /**
  80567. * The current object in the bubbling phase
  80568. */
  80569. currentTarget?: any;
  80570. /**
  80571. * This will be populated with the return value of the last function that was executed.
  80572. * If it is the first function in the callback chain it will be the event data.
  80573. */
  80574. lastReturnValue?: any;
  80575. }
  80576. /**
  80577. * Represent an Observer registered to a given Observable object.
  80578. */
  80579. export class Observer<T> {
  80580. /**
  80581. * Defines the callback to call when the observer is notified
  80582. */
  80583. callback: (eventData: T, eventState: EventState) => void;
  80584. /**
  80585. * Defines the mask of the observer (used to filter notifications)
  80586. */
  80587. mask: number;
  80588. /**
  80589. * Defines the current scope used to restore the JS context
  80590. */
  80591. scope: any;
  80592. /** @hidden */
  80593. _willBeUnregistered: boolean;
  80594. /**
  80595. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  80596. */
  80597. unregisterOnNextCall: boolean;
  80598. /**
  80599. * Creates a new observer
  80600. * @param callback defines the callback to call when the observer is notified
  80601. * @param mask defines the mask of the observer (used to filter notifications)
  80602. * @param scope defines the current scope used to restore the JS context
  80603. */
  80604. constructor(
  80605. /**
  80606. * Defines the callback to call when the observer is notified
  80607. */
  80608. callback: (eventData: T, eventState: EventState) => void,
  80609. /**
  80610. * Defines the mask of the observer (used to filter notifications)
  80611. */
  80612. mask: number,
  80613. /**
  80614. * Defines the current scope used to restore the JS context
  80615. */
  80616. scope?: any);
  80617. }
  80618. /**
  80619. * Represent a list of observers registered to multiple Observables object.
  80620. */
  80621. export class MultiObserver<T> {
  80622. private _observers;
  80623. private _observables;
  80624. /**
  80625. * Release associated resources
  80626. */
  80627. dispose(): void;
  80628. /**
  80629. * Raise a callback when one of the observable will notify
  80630. * @param observables defines a list of observables to watch
  80631. * @param callback defines the callback to call on notification
  80632. * @param mask defines the mask used to filter notifications
  80633. * @param scope defines the current scope used to restore the JS context
  80634. * @returns the new MultiObserver
  80635. */
  80636. static Watch<T>(observables: Observable<T>[], callback: (eventData: T, eventState: EventState) => void, mask?: number, scope?: any): MultiObserver<T>;
  80637. }
  80638. /**
  80639. * The Observable class is a simple implementation of the Observable pattern.
  80640. *
  80641. * 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.
  80642. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  80643. * 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).
  80644. * 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.
  80645. */
  80646. export class Observable<T> {
  80647. private _observers;
  80648. private _eventState;
  80649. private _onObserverAdded;
  80650. /**
  80651. * Gets the list of observers
  80652. */
  80653. get observers(): Array<Observer<T>>;
  80654. /**
  80655. * Creates a new observable
  80656. * @param onObserverAdded defines a callback to call when a new observer is added
  80657. */
  80658. constructor(onObserverAdded?: (observer: Observer<T>) => void);
  80659. /**
  80660. * Create a new Observer with the specified callback
  80661. * @param callback the callback that will be executed for that Observer
  80662. * @param mask the mask used to filter observers
  80663. * @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.
  80664. * @param scope optional scope for the callback to be called from
  80665. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  80666. * @returns the new observer created for the callback
  80667. */
  80668. add(callback: (eventData: T, eventState: EventState) => void, mask?: number, insertFirst?: boolean, scope?: any, unregisterOnFirstCall?: boolean): Nullable<Observer<T>>;
  80669. /**
  80670. * Create a new Observer with the specified callback and unregisters after the next notification
  80671. * @param callback the callback that will be executed for that Observer
  80672. * @returns the new observer created for the callback
  80673. */
  80674. addOnce(callback: (eventData: T, eventState: EventState) => void): Nullable<Observer<T>>;
  80675. /**
  80676. * Remove an Observer from the Observable object
  80677. * @param observer the instance of the Observer to remove
  80678. * @returns false if it doesn't belong to this Observable
  80679. */
  80680. remove(observer: Nullable<Observer<T>>): boolean;
  80681. /**
  80682. * Remove a callback from the Observable object
  80683. * @param callback the callback to remove
  80684. * @param scope optional scope. If used only the callbacks with this scope will be removed
  80685. * @returns false if it doesn't belong to this Observable
  80686. */
  80687. removeCallback(callback: (eventData: T, eventState: EventState) => void, scope?: any): boolean;
  80688. private _deferUnregister;
  80689. private _remove;
  80690. /**
  80691. * Moves the observable to the top of the observer list making it get called first when notified
  80692. * @param observer the observer to move
  80693. */
  80694. makeObserverTopPriority(observer: Observer<T>): void;
  80695. /**
  80696. * Moves the observable to the bottom of the observer list making it get called last when notified
  80697. * @param observer the observer to move
  80698. */
  80699. makeObserverBottomPriority(observer: Observer<T>): void;
  80700. /**
  80701. * Notify all Observers by calling their respective callback with the given data
  80702. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  80703. * @param eventData defines the data to send to all observers
  80704. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  80705. * @param target defines the original target of the state
  80706. * @param currentTarget defines the current target of the state
  80707. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  80708. */
  80709. notifyObservers(eventData: T, mask?: number, target?: any, currentTarget?: any): boolean;
  80710. /**
  80711. * Calling this will execute each callback, expecting it to be a promise or return a value.
  80712. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  80713. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  80714. * and it is crucial that all callbacks will be executed.
  80715. * The order of the callbacks is kept, callbacks are not executed parallel.
  80716. *
  80717. * @param eventData The data to be sent to each callback
  80718. * @param mask is used to filter observers defaults to -1
  80719. * @param target defines the callback target (see EventState)
  80720. * @param currentTarget defines he current object in the bubbling phase
  80721. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  80722. */
  80723. notifyObserversWithPromise(eventData: T, mask?: number, target?: any, currentTarget?: any): Promise<T>;
  80724. /**
  80725. * Notify a specific observer
  80726. * @param observer defines the observer to notify
  80727. * @param eventData defines the data to be sent to each callback
  80728. * @param mask is used to filter observers defaults to -1
  80729. */
  80730. notifyObserver(observer: Observer<T>, eventData: T, mask?: number): void;
  80731. /**
  80732. * Gets a boolean indicating if the observable has at least one observer
  80733. * @returns true is the Observable has at least one Observer registered
  80734. */
  80735. hasObservers(): boolean;
  80736. /**
  80737. * Clear the list of observers
  80738. */
  80739. clear(): void;
  80740. /**
  80741. * Clone the current observable
  80742. * @returns a new observable
  80743. */
  80744. clone(): Observable<T>;
  80745. /**
  80746. * Does this observable handles observer registered with a given mask
  80747. * @param mask defines the mask to be tested
  80748. * @return whether or not one observer registered with the given mask is handeled
  80749. **/
  80750. hasSpecificMask(mask?: number): boolean;
  80751. }
  80752. }
  80753. declare module BABYLON {
  80754. /**
  80755. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  80756. * Babylon.js
  80757. */
  80758. export class DomManagement {
  80759. /**
  80760. * Checks if the window object exists
  80761. * @returns true if the window object exists
  80762. */
  80763. static IsWindowObjectExist(): boolean;
  80764. /**
  80765. * Checks if the navigator object exists
  80766. * @returns true if the navigator object exists
  80767. */
  80768. static IsNavigatorAvailable(): boolean;
  80769. /**
  80770. * Check if the document object exists
  80771. * @returns true if the document object exists
  80772. */
  80773. static IsDocumentAvailable(): boolean;
  80774. /**
  80775. * Extracts text content from a DOM element hierarchy
  80776. * @param element defines the root element
  80777. * @returns a string
  80778. */
  80779. static GetDOMTextContent(element: HTMLElement): string;
  80780. }
  80781. }
  80782. declare module BABYLON {
  80783. /**
  80784. * Logger used througouht the application to allow configuration of
  80785. * the log level required for the messages.
  80786. */
  80787. export class Logger {
  80788. /**
  80789. * No log
  80790. */
  80791. static readonly NoneLogLevel: number;
  80792. /**
  80793. * Only message logs
  80794. */
  80795. static readonly MessageLogLevel: number;
  80796. /**
  80797. * Only warning logs
  80798. */
  80799. static readonly WarningLogLevel: number;
  80800. /**
  80801. * Only error logs
  80802. */
  80803. static readonly ErrorLogLevel: number;
  80804. /**
  80805. * All logs
  80806. */
  80807. static readonly AllLogLevel: number;
  80808. private static _LogCache;
  80809. /**
  80810. * Gets a value indicating the number of loading errors
  80811. * @ignorenaming
  80812. */
  80813. static errorsCount: number;
  80814. /**
  80815. * Callback called when a new log is added
  80816. */
  80817. static OnNewCacheEntry: (entry: string) => void;
  80818. private static _AddLogEntry;
  80819. private static _FormatMessage;
  80820. private static _LogDisabled;
  80821. private static _LogEnabled;
  80822. private static _WarnDisabled;
  80823. private static _WarnEnabled;
  80824. private static _ErrorDisabled;
  80825. private static _ErrorEnabled;
  80826. /**
  80827. * Log a message to the console
  80828. */
  80829. static Log: (message: string) => void;
  80830. /**
  80831. * Write a warning message to the console
  80832. */
  80833. static Warn: (message: string) => void;
  80834. /**
  80835. * Write an error message to the console
  80836. */
  80837. static Error: (message: string) => void;
  80838. /**
  80839. * Gets current log cache (list of logs)
  80840. */
  80841. static get LogCache(): string;
  80842. /**
  80843. * Clears the log cache
  80844. */
  80845. static ClearLogCache(): void;
  80846. /**
  80847. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  80848. */
  80849. static set LogLevels(level: number);
  80850. }
  80851. }
  80852. declare module BABYLON {
  80853. /** @hidden */
  80854. export class _TypeStore {
  80855. /** @hidden */
  80856. static RegisteredTypes: {
  80857. [key: string]: Object;
  80858. };
  80859. /** @hidden */
  80860. static GetClass(fqdn: string): any;
  80861. }
  80862. }
  80863. declare module BABYLON {
  80864. /**
  80865. * Helper to manipulate strings
  80866. */
  80867. export class StringTools {
  80868. /**
  80869. * Checks for a matching suffix at the end of a string (for ES5 and lower)
  80870. * @param str Source string
  80871. * @param suffix Suffix to search for in the source string
  80872. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80873. */
  80874. static EndsWith(str: string, suffix: string): boolean;
  80875. /**
  80876. * Checks for a matching suffix at the beginning of a string (for ES5 and lower)
  80877. * @param str Source string
  80878. * @param suffix Suffix to search for in the source string
  80879. * @returns Boolean indicating whether the suffix was found (true) or not (false)
  80880. */
  80881. static StartsWith(str: string, suffix: string): boolean;
  80882. /**
  80883. * Decodes a buffer into a string
  80884. * @param buffer The buffer to decode
  80885. * @returns The decoded string
  80886. */
  80887. static Decode(buffer: Uint8Array | Uint16Array): string;
  80888. /**
  80889. * Encode a buffer to a base64 string
  80890. * @param buffer defines the buffer to encode
  80891. * @returns the encoded string
  80892. */
  80893. static EncodeArrayBufferToBase64(buffer: ArrayBuffer | ArrayBufferView): string;
  80894. /**
  80895. * Converts a number to string and pads with preceeding zeroes until it is of specified length.
  80896. * @param num the number to convert and pad
  80897. * @param length the expected length of the string
  80898. * @returns the padded string
  80899. */
  80900. static PadNumber(num: number, length: number): string;
  80901. }
  80902. }
  80903. declare module BABYLON {
  80904. /**
  80905. * Class containing a set of static utilities functions for deep copy.
  80906. */
  80907. export class DeepCopier {
  80908. /**
  80909. * Tries to copy an object by duplicating every property
  80910. * @param source defines the source object
  80911. * @param destination defines the target object
  80912. * @param doNotCopyList defines a list of properties to avoid
  80913. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  80914. */
  80915. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  80916. }
  80917. }
  80918. declare module BABYLON {
  80919. /**
  80920. * Class containing a set of static utilities functions for precision date
  80921. */
  80922. export class PrecisionDate {
  80923. /**
  80924. * Gets either window.performance.now() if supported or Date.now() else
  80925. */
  80926. static get Now(): number;
  80927. }
  80928. }
  80929. declare module BABYLON {
  80930. /** @hidden */
  80931. export class _DevTools {
  80932. static WarnImport(name: string): string;
  80933. }
  80934. }
  80935. declare module BABYLON {
  80936. /**
  80937. * Interface used to define the mechanism to get data from the network
  80938. */
  80939. export interface IWebRequest {
  80940. /**
  80941. * Returns client's response url
  80942. */
  80943. responseURL: string;
  80944. /**
  80945. * Returns client's status
  80946. */
  80947. status: number;
  80948. /**
  80949. * Returns client's status as a text
  80950. */
  80951. statusText: string;
  80952. }
  80953. }
  80954. declare module BABYLON {
  80955. /**
  80956. * Extended version of XMLHttpRequest with support for customizations (headers, ...)
  80957. */
  80958. export class WebRequest implements IWebRequest {
  80959. private _xhr;
  80960. /**
  80961. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  80962. * i.e. when loading files, where the server/service expects an Authorization header
  80963. */
  80964. static CustomRequestHeaders: {
  80965. [key: string]: string;
  80966. };
  80967. /**
  80968. * Add callback functions in this array to update all the requests before they get sent to the network
  80969. */
  80970. static CustomRequestModifiers: ((request: XMLHttpRequest, url: string) => void)[];
  80971. private _injectCustomRequestHeaders;
  80972. /**
  80973. * Gets or sets a function to be called when loading progress changes
  80974. */
  80975. get onprogress(): ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null;
  80976. set onprogress(value: ((this: XMLHttpRequest, ev: ProgressEvent) => any) | null);
  80977. /**
  80978. * Returns client's state
  80979. */
  80980. get readyState(): number;
  80981. /**
  80982. * Returns client's status
  80983. */
  80984. get status(): number;
  80985. /**
  80986. * Returns client's status as a text
  80987. */
  80988. get statusText(): string;
  80989. /**
  80990. * Returns client's response
  80991. */
  80992. get response(): any;
  80993. /**
  80994. * Returns client's response url
  80995. */
  80996. get responseURL(): string;
  80997. /**
  80998. * Returns client's response as text
  80999. */
  81000. get responseText(): string;
  81001. /**
  81002. * Gets or sets the expected response type
  81003. */
  81004. get responseType(): XMLHttpRequestResponseType;
  81005. set responseType(value: XMLHttpRequestResponseType);
  81006. /** @hidden */
  81007. addEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | AddEventListenerOptions): void;
  81008. /** @hidden */
  81009. removeEventListener<K extends keyof XMLHttpRequestEventMap>(type: K, listener: (this: XMLHttpRequest, ev: XMLHttpRequestEventMap[K]) => any, options?: boolean | EventListenerOptions): void;
  81010. /**
  81011. * Cancels any network activity
  81012. */
  81013. abort(): void;
  81014. /**
  81015. * Initiates the request. The optional argument provides the request body. The argument is ignored if request method is GET or HEAD
  81016. * @param body defines an optional request body
  81017. */
  81018. send(body?: Document | BodyInit | null): void;
  81019. /**
  81020. * Sets the request method, request URL
  81021. * @param method defines the method to use (GET, POST, etc..)
  81022. * @param url defines the url to connect with
  81023. */
  81024. open(method: string, url: string): void;
  81025. /**
  81026. * Sets the value of a request header.
  81027. * @param name The name of the header whose value is to be set
  81028. * @param value The value to set as the body of the header
  81029. */
  81030. setRequestHeader(name: string, value: string): void;
  81031. /**
  81032. * Get the string containing the text of a particular header's value.
  81033. * @param name The name of the header
  81034. * @returns The string containing the text of the given header name
  81035. */
  81036. getResponseHeader(name: string): Nullable<string>;
  81037. }
  81038. }
  81039. declare module BABYLON {
  81040. /**
  81041. * File request interface
  81042. */
  81043. export interface IFileRequest {
  81044. /**
  81045. * Raised when the request is complete (success or error).
  81046. */
  81047. onCompleteObservable: Observable<IFileRequest>;
  81048. /**
  81049. * Aborts the request for a file.
  81050. */
  81051. abort: () => void;
  81052. }
  81053. }
  81054. declare module BABYLON {
  81055. /**
  81056. * Define options used to create a render target texture
  81057. */
  81058. export class RenderTargetCreationOptions {
  81059. /**
  81060. * Specifies is mipmaps must be generated
  81061. */
  81062. generateMipMaps?: boolean;
  81063. /** Specifies whether or not a depth should be allocated in the texture (true by default) */
  81064. generateDepthBuffer?: boolean;
  81065. /** Specifies whether or not a stencil should be allocated in the texture (false by default)*/
  81066. generateStencilBuffer?: boolean;
  81067. /** Defines texture type (int by default) */
  81068. type?: number;
  81069. /** Defines sampling mode (trilinear by default) */
  81070. samplingMode?: number;
  81071. /** Defines format (RGBA by default) */
  81072. format?: number;
  81073. }
  81074. }
  81075. declare module BABYLON {
  81076. /** Defines the cross module used constants to avoid circular dependncies */
  81077. export class Constants {
  81078. /** Defines that alpha blending is disabled */
  81079. static readonly ALPHA_DISABLE: number;
  81080. /** Defines that alpha blending is SRC ALPHA * SRC + DEST */
  81081. static readonly ALPHA_ADD: number;
  81082. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  81083. static readonly ALPHA_COMBINE: number;
  81084. /** Defines that alpha blending is DEST - SRC * DEST */
  81085. static readonly ALPHA_SUBTRACT: number;
  81086. /** Defines that alpha blending is SRC * DEST */
  81087. static readonly ALPHA_MULTIPLY: number;
  81088. /** Defines that alpha blending is SRC ALPHA * SRC + (1 - SRC) * DEST */
  81089. static readonly ALPHA_MAXIMIZED: number;
  81090. /** Defines that alpha blending is SRC + DEST */
  81091. static readonly ALPHA_ONEONE: number;
  81092. /** Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST */
  81093. static readonly ALPHA_PREMULTIPLIED: number;
  81094. /**
  81095. * Defines that alpha blending is SRC + (1 - SRC ALPHA) * DEST
  81096. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  81097. */
  81098. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  81099. /** Defines that alpha blending is CST * SRC + (1 - CST) * DEST */
  81100. static readonly ALPHA_INTERPOLATE: number;
  81101. /**
  81102. * Defines that alpha blending is SRC + (1 - SRC) * DEST
  81103. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  81104. */
  81105. static readonly ALPHA_SCREENMODE: number;
  81106. /**
  81107. * Defines that alpha blending is SRC + DST
  81108. * Alpha will be set to SRC ALPHA + DST ALPHA
  81109. */
  81110. static readonly ALPHA_ONEONE_ONEONE: number;
  81111. /**
  81112. * Defines that alpha blending is SRC * DST ALPHA + DST
  81113. * Alpha will be set to 0
  81114. */
  81115. static readonly ALPHA_ALPHATOCOLOR: number;
  81116. /**
  81117. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81118. */
  81119. static readonly ALPHA_REVERSEONEMINUS: number;
  81120. /**
  81121. * Defines that alpha blending is SRC + DST * (1 - SRC ALPHA)
  81122. * Alpha will be set to SRC ALPHA + DST ALPHA * (1 - SRC ALPHA)
  81123. */
  81124. static readonly ALPHA_SRC_DSTONEMINUSSRCALPHA: number;
  81125. /**
  81126. * Defines that alpha blending is SRC + DST
  81127. * Alpha will be set to SRC ALPHA
  81128. */
  81129. static readonly ALPHA_ONEONE_ONEZERO: number;
  81130. /**
  81131. * Defines that alpha blending is SRC * (1 - DST) + DST * (1 - SRC)
  81132. * Alpha will be set to DST ALPHA
  81133. */
  81134. static readonly ALPHA_EXCLUSION: number;
  81135. /** Defines that alpha blending equation a SUM */
  81136. static readonly ALPHA_EQUATION_ADD: number;
  81137. /** Defines that alpha blending equation a SUBSTRACTION */
  81138. static readonly ALPHA_EQUATION_SUBSTRACT: number;
  81139. /** Defines that alpha blending equation a REVERSE SUBSTRACTION */
  81140. static readonly ALPHA_EQUATION_REVERSE_SUBTRACT: number;
  81141. /** Defines that alpha blending equation a MAX operation */
  81142. static readonly ALPHA_EQUATION_MAX: number;
  81143. /** Defines that alpha blending equation a MIN operation */
  81144. static readonly ALPHA_EQUATION_MIN: number;
  81145. /**
  81146. * Defines that alpha blending equation a DARKEN operation:
  81147. * It takes the min of the src and sums the alpha channels.
  81148. */
  81149. static readonly ALPHA_EQUATION_DARKEN: number;
  81150. /** Defines that the ressource is not delayed*/
  81151. static readonly DELAYLOADSTATE_NONE: number;
  81152. /** Defines that the ressource was successfully delay loaded */
  81153. static readonly DELAYLOADSTATE_LOADED: number;
  81154. /** Defines that the ressource is currently delay loading */
  81155. static readonly DELAYLOADSTATE_LOADING: number;
  81156. /** Defines that the ressource is delayed and has not started loading */
  81157. static readonly DELAYLOADSTATE_NOTLOADED: number;
  81158. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  81159. static readonly NEVER: number;
  81160. /** 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 */
  81161. static readonly ALWAYS: number;
  81162. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  81163. static readonly LESS: number;
  81164. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  81165. static readonly EQUAL: number;
  81166. /** 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 */
  81167. static readonly LEQUAL: number;
  81168. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  81169. static readonly GREATER: number;
  81170. /** 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 */
  81171. static readonly GEQUAL: number;
  81172. /** 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 */
  81173. static readonly NOTEQUAL: number;
  81174. /** Passed to stencilOperation to specify that stencil value must be kept */
  81175. static readonly KEEP: number;
  81176. /** Passed to stencilOperation to specify that stencil value must be replaced */
  81177. static readonly REPLACE: number;
  81178. /** Passed to stencilOperation to specify that stencil value must be incremented */
  81179. static readonly INCR: number;
  81180. /** Passed to stencilOperation to specify that stencil value must be decremented */
  81181. static readonly DECR: number;
  81182. /** Passed to stencilOperation to specify that stencil value must be inverted */
  81183. static readonly INVERT: number;
  81184. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  81185. static readonly INCR_WRAP: number;
  81186. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  81187. static readonly DECR_WRAP: number;
  81188. /** Texture is not repeating outside of 0..1 UVs */
  81189. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  81190. /** Texture is repeating outside of 0..1 UVs */
  81191. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  81192. /** Texture is repeating and mirrored */
  81193. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  81194. /** ALPHA */
  81195. static readonly TEXTUREFORMAT_ALPHA: number;
  81196. /** LUMINANCE */
  81197. static readonly TEXTUREFORMAT_LUMINANCE: number;
  81198. /** LUMINANCE_ALPHA */
  81199. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  81200. /** RGB */
  81201. static readonly TEXTUREFORMAT_RGB: number;
  81202. /** RGBA */
  81203. static readonly TEXTUREFORMAT_RGBA: number;
  81204. /** RED */
  81205. static readonly TEXTUREFORMAT_RED: number;
  81206. /** RED (2nd reference) */
  81207. static readonly TEXTUREFORMAT_R: number;
  81208. /** RG */
  81209. static readonly TEXTUREFORMAT_RG: number;
  81210. /** RED_INTEGER */
  81211. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  81212. /** RED_INTEGER (2nd reference) */
  81213. static readonly TEXTUREFORMAT_R_INTEGER: number;
  81214. /** RG_INTEGER */
  81215. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  81216. /** RGB_INTEGER */
  81217. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  81218. /** RGBA_INTEGER */
  81219. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  81220. /** UNSIGNED_BYTE */
  81221. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  81222. /** UNSIGNED_BYTE (2nd reference) */
  81223. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  81224. /** FLOAT */
  81225. static readonly TEXTURETYPE_FLOAT: number;
  81226. /** HALF_FLOAT */
  81227. static readonly TEXTURETYPE_HALF_FLOAT: number;
  81228. /** BYTE */
  81229. static readonly TEXTURETYPE_BYTE: number;
  81230. /** SHORT */
  81231. static readonly TEXTURETYPE_SHORT: number;
  81232. /** UNSIGNED_SHORT */
  81233. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  81234. /** INT */
  81235. static readonly TEXTURETYPE_INT: number;
  81236. /** UNSIGNED_INT */
  81237. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  81238. /** UNSIGNED_SHORT_4_4_4_4 */
  81239. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  81240. /** UNSIGNED_SHORT_5_5_5_1 */
  81241. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  81242. /** UNSIGNED_SHORT_5_6_5 */
  81243. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  81244. /** UNSIGNED_INT_2_10_10_10_REV */
  81245. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  81246. /** UNSIGNED_INT_24_8 */
  81247. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  81248. /** UNSIGNED_INT_10F_11F_11F_REV */
  81249. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  81250. /** UNSIGNED_INT_5_9_9_9_REV */
  81251. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  81252. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  81253. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  81254. /** nearest is mag = nearest and min = nearest and no mip */
  81255. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  81256. /** mag = nearest and min = nearest and mip = none */
  81257. static readonly TEXTURE_NEAREST_NEAREST: number;
  81258. /** Bilinear is mag = linear and min = linear and no mip */
  81259. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  81260. /** mag = linear and min = linear and mip = none */
  81261. static readonly TEXTURE_LINEAR_LINEAR: number;
  81262. /** Trilinear is mag = linear and min = linear and mip = linear */
  81263. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  81264. /** Trilinear is mag = linear and min = linear and mip = linear */
  81265. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  81266. /** mag = nearest and min = nearest and mip = nearest */
  81267. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  81268. /** mag = nearest and min = linear and mip = nearest */
  81269. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  81270. /** mag = nearest and min = linear and mip = linear */
  81271. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  81272. /** mag = nearest and min = linear and mip = none */
  81273. static readonly TEXTURE_NEAREST_LINEAR: number;
  81274. /** nearest is mag = nearest and min = nearest and mip = linear */
  81275. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  81276. /** mag = linear and min = nearest and mip = nearest */
  81277. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  81278. /** mag = linear and min = nearest and mip = linear */
  81279. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  81280. /** Bilinear is mag = linear and min = linear and mip = nearest */
  81281. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  81282. /** mag = linear and min = nearest and mip = none */
  81283. static readonly TEXTURE_LINEAR_NEAREST: number;
  81284. /** Explicit coordinates mode */
  81285. static readonly TEXTURE_EXPLICIT_MODE: number;
  81286. /** Spherical coordinates mode */
  81287. static readonly TEXTURE_SPHERICAL_MODE: number;
  81288. /** Planar coordinates mode */
  81289. static readonly TEXTURE_PLANAR_MODE: number;
  81290. /** Cubic coordinates mode */
  81291. static readonly TEXTURE_CUBIC_MODE: number;
  81292. /** Projection coordinates mode */
  81293. static readonly TEXTURE_PROJECTION_MODE: number;
  81294. /** Skybox coordinates mode */
  81295. static readonly TEXTURE_SKYBOX_MODE: number;
  81296. /** Inverse Cubic coordinates mode */
  81297. static readonly TEXTURE_INVCUBIC_MODE: number;
  81298. /** Equirectangular coordinates mode */
  81299. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  81300. /** Equirectangular Fixed coordinates mode */
  81301. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  81302. /** Equirectangular Fixed Mirrored coordinates mode */
  81303. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  81304. /** Offline (baking) quality for texture filtering */
  81305. static readonly TEXTURE_FILTERING_QUALITY_OFFLINE: number;
  81306. /** High quality for texture filtering */
  81307. static readonly TEXTURE_FILTERING_QUALITY_HIGH: number;
  81308. /** Medium quality for texture filtering */
  81309. static readonly TEXTURE_FILTERING_QUALITY_MEDIUM: number;
  81310. /** Low quality for texture filtering */
  81311. static readonly TEXTURE_FILTERING_QUALITY_LOW: number;
  81312. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  81313. static readonly SCALEMODE_FLOOR: number;
  81314. /** Defines that texture rescaling will look for the nearest power of 2 size */
  81315. static readonly SCALEMODE_NEAREST: number;
  81316. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  81317. static readonly SCALEMODE_CEILING: number;
  81318. /**
  81319. * The dirty texture flag value
  81320. */
  81321. static readonly MATERIAL_TextureDirtyFlag: number;
  81322. /**
  81323. * The dirty light flag value
  81324. */
  81325. static readonly MATERIAL_LightDirtyFlag: number;
  81326. /**
  81327. * The dirty fresnel flag value
  81328. */
  81329. static readonly MATERIAL_FresnelDirtyFlag: number;
  81330. /**
  81331. * The dirty attribute flag value
  81332. */
  81333. static readonly MATERIAL_AttributesDirtyFlag: number;
  81334. /**
  81335. * The dirty misc flag value
  81336. */
  81337. static readonly MATERIAL_MiscDirtyFlag: number;
  81338. /**
  81339. * The dirty prepass flag value
  81340. */
  81341. static readonly MATERIAL_PrePassDirtyFlag: number;
  81342. /**
  81343. * The all dirty flag value
  81344. */
  81345. static readonly MATERIAL_AllDirtyFlag: number;
  81346. /**
  81347. * Returns the triangle fill mode
  81348. */
  81349. static readonly MATERIAL_TriangleFillMode: number;
  81350. /**
  81351. * Returns the wireframe mode
  81352. */
  81353. static readonly MATERIAL_WireFrameFillMode: number;
  81354. /**
  81355. * Returns the point fill mode
  81356. */
  81357. static readonly MATERIAL_PointFillMode: number;
  81358. /**
  81359. * Returns the point list draw mode
  81360. */
  81361. static readonly MATERIAL_PointListDrawMode: number;
  81362. /**
  81363. * Returns the line list draw mode
  81364. */
  81365. static readonly MATERIAL_LineListDrawMode: number;
  81366. /**
  81367. * Returns the line loop draw mode
  81368. */
  81369. static readonly MATERIAL_LineLoopDrawMode: number;
  81370. /**
  81371. * Returns the line strip draw mode
  81372. */
  81373. static readonly MATERIAL_LineStripDrawMode: number;
  81374. /**
  81375. * Returns the triangle strip draw mode
  81376. */
  81377. static readonly MATERIAL_TriangleStripDrawMode: number;
  81378. /**
  81379. * Returns the triangle fan draw mode
  81380. */
  81381. static readonly MATERIAL_TriangleFanDrawMode: number;
  81382. /**
  81383. * Stores the clock-wise side orientation
  81384. */
  81385. static readonly MATERIAL_ClockWiseSideOrientation: number;
  81386. /**
  81387. * Stores the counter clock-wise side orientation
  81388. */
  81389. static readonly MATERIAL_CounterClockWiseSideOrientation: number;
  81390. /**
  81391. * Nothing
  81392. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81393. */
  81394. static readonly ACTION_NothingTrigger: number;
  81395. /**
  81396. * On pick
  81397. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81398. */
  81399. static readonly ACTION_OnPickTrigger: number;
  81400. /**
  81401. * On left pick
  81402. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81403. */
  81404. static readonly ACTION_OnLeftPickTrigger: number;
  81405. /**
  81406. * On right pick
  81407. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81408. */
  81409. static readonly ACTION_OnRightPickTrigger: number;
  81410. /**
  81411. * On center pick
  81412. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81413. */
  81414. static readonly ACTION_OnCenterPickTrigger: number;
  81415. /**
  81416. * On pick down
  81417. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81418. */
  81419. static readonly ACTION_OnPickDownTrigger: number;
  81420. /**
  81421. * On double pick
  81422. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81423. */
  81424. static readonly ACTION_OnDoublePickTrigger: number;
  81425. /**
  81426. * On pick up
  81427. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81428. */
  81429. static readonly ACTION_OnPickUpTrigger: number;
  81430. /**
  81431. * On pick out.
  81432. * This trigger will only be raised if you also declared a OnPickDown
  81433. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81434. */
  81435. static readonly ACTION_OnPickOutTrigger: number;
  81436. /**
  81437. * On long press
  81438. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81439. */
  81440. static readonly ACTION_OnLongPressTrigger: number;
  81441. /**
  81442. * On pointer over
  81443. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81444. */
  81445. static readonly ACTION_OnPointerOverTrigger: number;
  81446. /**
  81447. * On pointer out
  81448. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81449. */
  81450. static readonly ACTION_OnPointerOutTrigger: number;
  81451. /**
  81452. * On every frame
  81453. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81454. */
  81455. static readonly ACTION_OnEveryFrameTrigger: number;
  81456. /**
  81457. * On intersection enter
  81458. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81459. */
  81460. static readonly ACTION_OnIntersectionEnterTrigger: number;
  81461. /**
  81462. * On intersection exit
  81463. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81464. */
  81465. static readonly ACTION_OnIntersectionExitTrigger: number;
  81466. /**
  81467. * On key down
  81468. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81469. */
  81470. static readonly ACTION_OnKeyDownTrigger: number;
  81471. /**
  81472. * On key up
  81473. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  81474. */
  81475. static readonly ACTION_OnKeyUpTrigger: number;
  81476. /**
  81477. * Billboard mode will only apply to Y axis
  81478. */
  81479. static readonly PARTICLES_BILLBOARDMODE_Y: number;
  81480. /**
  81481. * Billboard mode will apply to all axes
  81482. */
  81483. static readonly PARTICLES_BILLBOARDMODE_ALL: number;
  81484. /**
  81485. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  81486. */
  81487. static readonly PARTICLES_BILLBOARDMODE_STRETCHED: number;
  81488. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  81489. * Test order :
  81490. * Is the bounding sphere outside the frustum ?
  81491. * If not, are the bounding box vertices outside the frustum ?
  81492. * It not, then the cullable object is in the frustum.
  81493. */
  81494. static readonly MESHES_CULLINGSTRATEGY_STANDARD: number;
  81495. /** Culling strategy : Bounding Sphere Only.
  81496. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  81497. * It's also less accurate than the standard because some not visible objects can still be selected.
  81498. * Test : is the bounding sphere outside the frustum ?
  81499. * If not, then the cullable object is in the frustum.
  81500. */
  81501. static readonly MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  81502. /** Culling strategy : Optimistic Inclusion.
  81503. * This in an inclusion test first, then the standard exclusion test.
  81504. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  81505. * 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.
  81506. * Anyway, it's as accurate as the standard strategy.
  81507. * Test :
  81508. * Is the cullable object bounding sphere center in the frustum ?
  81509. * If not, apply the default culling strategy.
  81510. */
  81511. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  81512. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  81513. * This in an inclusion test first, then the bounding sphere only exclusion test.
  81514. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  81515. * 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.
  81516. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  81517. * Test :
  81518. * Is the cullable object bounding sphere center in the frustum ?
  81519. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  81520. */
  81521. static readonly MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  81522. /**
  81523. * No logging while loading
  81524. */
  81525. static readonly SCENELOADER_NO_LOGGING: number;
  81526. /**
  81527. * Minimal logging while loading
  81528. */
  81529. static readonly SCENELOADER_MINIMAL_LOGGING: number;
  81530. /**
  81531. * Summary logging while loading
  81532. */
  81533. static readonly SCENELOADER_SUMMARY_LOGGING: number;
  81534. /**
  81535. * Detailled logging while loading
  81536. */
  81537. static readonly SCENELOADER_DETAILED_LOGGING: number;
  81538. /**
  81539. * Constant used to retrieve the irradiance texture index in the textures array in the prepass
  81540. * using getIndex(Constants.PREPASS_IRRADIANCE_TEXTURE_TYPE)
  81541. */
  81542. static readonly PREPASS_IRRADIANCE_TEXTURE_TYPE: number;
  81543. /**
  81544. * Constant used to retrieve the position texture index in the textures array in the prepass
  81545. * using getIndex(Constants.PREPASS_POSITION_TEXTURE_INDEX)
  81546. */
  81547. static readonly PREPASS_POSITION_TEXTURE_TYPE: number;
  81548. /**
  81549. * Constant used to retrieve the velocity texture index in the textures array in the prepass
  81550. * using getIndex(Constants.PREPASS_VELOCITY_TEXTURE_INDEX)
  81551. */
  81552. static readonly PREPASS_VELOCITY_TEXTURE_TYPE: number;
  81553. /**
  81554. * Constant used to retrieve the reflectivity texture index in the textures array in the prepass
  81555. * using the getIndex(Constants.PREPASS_REFLECTIVITY_TEXTURE_TYPE)
  81556. */
  81557. static readonly PREPASS_REFLECTIVITY_TEXTURE_TYPE: number;
  81558. /**
  81559. * Constant used to retrieve the lit color texture index in the textures array in the prepass
  81560. * using the getIndex(Constants.PREPASS_COLOR_TEXTURE_TYPE)
  81561. */
  81562. static readonly PREPASS_COLOR_TEXTURE_TYPE: number;
  81563. /**
  81564. * Constant used to retrieve depth + normal index in the textures array in the prepass
  81565. * using the getIndex(Constants.PREPASS_DEPTHNORMAL_TEXTURE_TYPE)
  81566. */
  81567. static readonly PREPASS_DEPTHNORMAL_TEXTURE_TYPE: number;
  81568. /**
  81569. * Constant used to retrieve albedo index in the textures array in the prepass
  81570. * using the getIndex(Constants.PREPASS_ALBEDO_TEXTURE_TYPE)
  81571. */
  81572. static readonly PREPASS_ALBEDO_TEXTURE_TYPE: number;
  81573. }
  81574. }
  81575. declare module BABYLON {
  81576. /**
  81577. * This represents the required contract to create a new type of texture loader.
  81578. */
  81579. export interface IInternalTextureLoader {
  81580. /**
  81581. * Defines wether the loader supports cascade loading the different faces.
  81582. */
  81583. supportCascades: boolean;
  81584. /**
  81585. * This returns if the loader support the current file information.
  81586. * @param extension defines the file extension of the file being loaded
  81587. * @param mimeType defines the optional mime type of the file being loaded
  81588. * @returns true if the loader can load the specified file
  81589. */
  81590. canLoad(extension: string, mimeType?: string): boolean;
  81591. /**
  81592. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  81593. * @param data contains the texture data
  81594. * @param texture defines the BabylonJS internal texture
  81595. * @param createPolynomials will be true if polynomials have been requested
  81596. * @param onLoad defines the callback to trigger once the texture is ready
  81597. * @param onError defines the callback to trigger in case of error
  81598. */
  81599. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  81600. /**
  81601. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  81602. * @param data contains the texture data
  81603. * @param texture defines the BabylonJS internal texture
  81604. * @param callback defines the method to call once ready to upload
  81605. */
  81606. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed?: boolean) => void): void;
  81607. }
  81608. }
  81609. declare module BABYLON {
  81610. /**
  81611. * Class used to store and describe the pipeline context associated with an effect
  81612. */
  81613. export interface IPipelineContext {
  81614. /**
  81615. * Gets a boolean indicating that this pipeline context is supporting asynchronous creating
  81616. */
  81617. isAsync: boolean;
  81618. /**
  81619. * Gets a boolean indicating that the context is ready to be used (like shaders / pipelines are compiled and ready for instance)
  81620. */
  81621. isReady: boolean;
  81622. /** @hidden */
  81623. _getVertexShaderCode(): string | null;
  81624. /** @hidden */
  81625. _getFragmentShaderCode(): string | null;
  81626. /** @hidden */
  81627. _handlesSpectorRebuildCallback(onCompiled: (compiledObject: any) => void): void;
  81628. }
  81629. }
  81630. declare module BABYLON {
  81631. /**
  81632. * Class used to store gfx data (like WebGLBuffer)
  81633. */
  81634. export class DataBuffer {
  81635. /**
  81636. * Gets or sets the number of objects referencing this buffer
  81637. */
  81638. references: number;
  81639. /** Gets or sets the size of the underlying buffer */
  81640. capacity: number;
  81641. /**
  81642. * Gets or sets a boolean indicating if the buffer contains 32bits indices
  81643. */
  81644. is32Bits: boolean;
  81645. /**
  81646. * Gets the underlying buffer
  81647. */
  81648. get underlyingResource(): any;
  81649. }
  81650. }
  81651. declare module BABYLON {
  81652. /** @hidden */
  81653. export interface IShaderProcessor {
  81654. attributeProcessor?: (attribute: string) => string;
  81655. varyingProcessor?: (varying: string, isFragment: boolean) => string;
  81656. uniformProcessor?: (uniform: string, isFragment: boolean) => string;
  81657. uniformBufferProcessor?: (uniformBuffer: string, isFragment: boolean) => string;
  81658. endOfUniformBufferProcessor?: (closingBracketLine: string, isFragment: boolean) => string;
  81659. lineProcessor?: (line: string, isFragment: boolean) => string;
  81660. preProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81661. postProcessor?: (code: string, defines: string[], isFragment: boolean) => string;
  81662. }
  81663. }
  81664. declare module BABYLON {
  81665. /** @hidden */
  81666. export interface ProcessingOptions {
  81667. defines: string[];
  81668. indexParameters: any;
  81669. isFragment: boolean;
  81670. shouldUseHighPrecisionShader: boolean;
  81671. supportsUniformBuffers: boolean;
  81672. shadersRepository: string;
  81673. includesShadersStore: {
  81674. [key: string]: string;
  81675. };
  81676. processor?: IShaderProcessor;
  81677. version: string;
  81678. platformName: string;
  81679. lookForClosingBracketForUniformBuffer?: boolean;
  81680. }
  81681. }
  81682. declare module BABYLON {
  81683. /** @hidden */
  81684. export class ShaderCodeNode {
  81685. line: string;
  81686. children: ShaderCodeNode[];
  81687. additionalDefineKey?: string;
  81688. additionalDefineValue?: string;
  81689. isValid(preprocessors: {
  81690. [key: string]: string;
  81691. }): boolean;
  81692. process(preprocessors: {
  81693. [key: string]: string;
  81694. }, options: ProcessingOptions): string;
  81695. }
  81696. }
  81697. declare module BABYLON {
  81698. /** @hidden */
  81699. export class ShaderCodeCursor {
  81700. private _lines;
  81701. lineIndex: number;
  81702. get currentLine(): string;
  81703. get canRead(): boolean;
  81704. set lines(value: string[]);
  81705. }
  81706. }
  81707. declare module BABYLON {
  81708. /** @hidden */
  81709. export class ShaderCodeConditionNode extends ShaderCodeNode {
  81710. process(preprocessors: {
  81711. [key: string]: string;
  81712. }, options: ProcessingOptions): string;
  81713. }
  81714. }
  81715. declare module BABYLON {
  81716. /** @hidden */
  81717. export class ShaderDefineExpression {
  81718. isTrue(preprocessors: {
  81719. [key: string]: string;
  81720. }): boolean;
  81721. private static _OperatorPriority;
  81722. private static _Stack;
  81723. static postfixToInfix(postfix: string[]): string;
  81724. static infixToPostfix(infix: string): string[];
  81725. }
  81726. }
  81727. declare module BABYLON {
  81728. /** @hidden */
  81729. export class ShaderCodeTestNode extends ShaderCodeNode {
  81730. testExpression: ShaderDefineExpression;
  81731. isValid(preprocessors: {
  81732. [key: string]: string;
  81733. }): boolean;
  81734. }
  81735. }
  81736. declare module BABYLON {
  81737. /** @hidden */
  81738. export class ShaderDefineIsDefinedOperator extends ShaderDefineExpression {
  81739. define: string;
  81740. not: boolean;
  81741. constructor(define: string, not?: boolean);
  81742. isTrue(preprocessors: {
  81743. [key: string]: string;
  81744. }): boolean;
  81745. }
  81746. }
  81747. declare module BABYLON {
  81748. /** @hidden */
  81749. export class ShaderDefineOrOperator extends ShaderDefineExpression {
  81750. leftOperand: ShaderDefineExpression;
  81751. rightOperand: ShaderDefineExpression;
  81752. isTrue(preprocessors: {
  81753. [key: string]: string;
  81754. }): boolean;
  81755. }
  81756. }
  81757. declare module BABYLON {
  81758. /** @hidden */
  81759. export class ShaderDefineAndOperator extends ShaderDefineExpression {
  81760. leftOperand: ShaderDefineExpression;
  81761. rightOperand: ShaderDefineExpression;
  81762. isTrue(preprocessors: {
  81763. [key: string]: string;
  81764. }): boolean;
  81765. }
  81766. }
  81767. declare module BABYLON {
  81768. /** @hidden */
  81769. export class ShaderDefineArithmeticOperator extends ShaderDefineExpression {
  81770. define: string;
  81771. operand: string;
  81772. testValue: string;
  81773. constructor(define: string, operand: string, testValue: string);
  81774. isTrue(preprocessors: {
  81775. [key: string]: string;
  81776. }): boolean;
  81777. }
  81778. }
  81779. declare module BABYLON {
  81780. /**
  81781. * Class used to enable access to offline support
  81782. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  81783. */
  81784. export interface IOfflineProvider {
  81785. /**
  81786. * Gets a boolean indicating if scene must be saved in the database
  81787. */
  81788. enableSceneOffline: boolean;
  81789. /**
  81790. * Gets a boolean indicating if textures must be saved in the database
  81791. */
  81792. enableTexturesOffline: boolean;
  81793. /**
  81794. * Open the offline support and make it available
  81795. * @param successCallback defines the callback to call on success
  81796. * @param errorCallback defines the callback to call on error
  81797. */
  81798. open(successCallback: () => void, errorCallback: () => void): void;
  81799. /**
  81800. * Loads an image from the offline support
  81801. * @param url defines the url to load from
  81802. * @param image defines the target DOM image
  81803. */
  81804. loadImage(url: string, image: HTMLImageElement): void;
  81805. /**
  81806. * Loads a file from offline support
  81807. * @param url defines the URL to load from
  81808. * @param sceneLoaded defines a callback to call on success
  81809. * @param progressCallBack defines a callback to call when progress changed
  81810. * @param errorCallback defines a callback to call on error
  81811. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  81812. */
  81813. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  81814. }
  81815. }
  81816. declare module BABYLON {
  81817. /**
  81818. * Class used to help managing file picking and drag'n'drop
  81819. * File Storage
  81820. */
  81821. export class FilesInputStore {
  81822. /**
  81823. * List of files ready to be loaded
  81824. */
  81825. static FilesToLoad: {
  81826. [key: string]: File;
  81827. };
  81828. }
  81829. }
  81830. declare module BABYLON {
  81831. /**
  81832. * Class used to define a retry strategy when error happens while loading assets
  81833. */
  81834. export class RetryStrategy {
  81835. /**
  81836. * Function used to defines an exponential back off strategy
  81837. * @param maxRetries defines the maximum number of retries (3 by default)
  81838. * @param baseInterval defines the interval between retries
  81839. * @returns the strategy function to use
  81840. */
  81841. static ExponentialBackoff(maxRetries?: number, baseInterval?: number): (url: string, request: WebRequest, retryIndex: number) => number;
  81842. }
  81843. }
  81844. declare module BABYLON {
  81845. /**
  81846. * @ignore
  81847. * Application error to support additional information when loading a file
  81848. */
  81849. export abstract class BaseError extends Error {
  81850. protected static _setPrototypeOf: (o: any, proto: object | null) => any;
  81851. }
  81852. }
  81853. declare module BABYLON {
  81854. /** @ignore */
  81855. export class LoadFileError extends BaseError {
  81856. request?: WebRequest;
  81857. file?: File;
  81858. /**
  81859. * Creates a new LoadFileError
  81860. * @param message defines the message of the error
  81861. * @param request defines the optional web request
  81862. * @param file defines the optional file
  81863. */
  81864. constructor(message: string, object?: WebRequest | File);
  81865. }
  81866. /** @ignore */
  81867. export class RequestFileError extends BaseError {
  81868. request: WebRequest;
  81869. /**
  81870. * Creates a new LoadFileError
  81871. * @param message defines the message of the error
  81872. * @param request defines the optional web request
  81873. */
  81874. constructor(message: string, request: WebRequest);
  81875. }
  81876. /** @ignore */
  81877. export class ReadFileError extends BaseError {
  81878. file: File;
  81879. /**
  81880. * Creates a new ReadFileError
  81881. * @param message defines the message of the error
  81882. * @param file defines the optional file
  81883. */
  81884. constructor(message: string, file: File);
  81885. }
  81886. /**
  81887. * @hidden
  81888. */
  81889. export class FileTools {
  81890. /**
  81891. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  81892. */
  81893. static DefaultRetryStrategy: (url: string, request: WebRequest, retryIndex: number) => number;
  81894. /**
  81895. * Gets or sets the base URL to use to load assets
  81896. */
  81897. static BaseUrl: string;
  81898. /**
  81899. * Default behaviour for cors in the application.
  81900. * It can be a string if the expected behavior is identical in the entire app.
  81901. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  81902. */
  81903. static CorsBehavior: string | ((url: string | string[]) => string);
  81904. /**
  81905. * Gets or sets a function used to pre-process url before using them to load assets
  81906. */
  81907. static PreprocessUrl: (url: string) => string;
  81908. /**
  81909. * Removes unwanted characters from an url
  81910. * @param url defines the url to clean
  81911. * @returns the cleaned url
  81912. */
  81913. private static _CleanUrl;
  81914. /**
  81915. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  81916. * @param url define the url we are trying
  81917. * @param element define the dom element where to configure the cors policy
  81918. */
  81919. static SetCorsBehavior(url: string | string[], element: {
  81920. crossOrigin: string | null;
  81921. }): void;
  81922. /**
  81923. * Loads an image as an HTMLImageElement.
  81924. * @param input url string, ArrayBuffer, or Blob to load
  81925. * @param onLoad callback called when the image successfully loads
  81926. * @param onError callback called when the image fails to load
  81927. * @param offlineProvider offline provider for caching
  81928. * @param mimeType optional mime type
  81929. * @returns the HTMLImageElement of the loaded image
  81930. */
  81931. 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>;
  81932. /**
  81933. * Reads a file from a File object
  81934. * @param file defines the file to load
  81935. * @param onSuccess defines the callback to call when data is loaded
  81936. * @param onProgress defines the callback to call during loading process
  81937. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  81938. * @param onError defines the callback to call when an error occurs
  81939. * @returns a file request object
  81940. */
  81941. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  81942. /**
  81943. * Loads a file from a url
  81944. * @param url url to load
  81945. * @param onSuccess callback called when the file successfully loads
  81946. * @param onProgress callback called while file is loading (if the server supports this mode)
  81947. * @param offlineProvider defines the offline provider for caching
  81948. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81949. * @param onError callback called when the file fails to load
  81950. * @returns a file request object
  81951. */
  81952. 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;
  81953. /**
  81954. * Loads a file
  81955. * @param url url to load
  81956. * @param onSuccess callback called when the file successfully loads
  81957. * @param onProgress callback called while file is loading (if the server supports this mode)
  81958. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81959. * @param onError callback called when the file fails to load
  81960. * @param onOpened callback called when the web request is opened
  81961. * @returns a file request object
  81962. */
  81963. 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;
  81964. /**
  81965. * Checks if the loaded document was accessed via `file:`-Protocol.
  81966. * @returns boolean
  81967. */
  81968. static IsFileURL(): boolean;
  81969. }
  81970. }
  81971. declare module BABYLON {
  81972. /** @hidden */
  81973. export class ShaderProcessor {
  81974. static Process(sourceCode: string, options: ProcessingOptions, callback: (migratedCode: string) => void): void;
  81975. private static _ProcessPrecision;
  81976. private static _ExtractOperation;
  81977. private static _BuildSubExpression;
  81978. private static _BuildExpression;
  81979. private static _MoveCursorWithinIf;
  81980. private static _MoveCursor;
  81981. private static _EvaluatePreProcessors;
  81982. private static _PreparePreProcessors;
  81983. private static _ProcessShaderConversion;
  81984. private static _ProcessIncludes;
  81985. /**
  81986. * Loads a file from a url
  81987. * @param url url to load
  81988. * @param onSuccess callback called when the file successfully loads
  81989. * @param onProgress callback called while file is loading (if the server supports this mode)
  81990. * @param offlineProvider defines the offline provider for caching
  81991. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  81992. * @param onError callback called when the file fails to load
  81993. * @returns a file request object
  81994. * @hidden
  81995. */
  81996. 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;
  81997. }
  81998. }
  81999. declare module BABYLON {
  82000. /**
  82001. * @hidden
  82002. */
  82003. export interface IColor4Like {
  82004. r: float;
  82005. g: float;
  82006. b: float;
  82007. a: float;
  82008. }
  82009. /**
  82010. * @hidden
  82011. */
  82012. export interface IColor3Like {
  82013. r: float;
  82014. g: float;
  82015. b: float;
  82016. }
  82017. /**
  82018. * @hidden
  82019. */
  82020. export interface IVector4Like {
  82021. x: float;
  82022. y: float;
  82023. z: float;
  82024. w: float;
  82025. }
  82026. /**
  82027. * @hidden
  82028. */
  82029. export interface IVector3Like {
  82030. x: float;
  82031. y: float;
  82032. z: float;
  82033. }
  82034. /**
  82035. * @hidden
  82036. */
  82037. export interface IVector2Like {
  82038. x: float;
  82039. y: float;
  82040. }
  82041. /**
  82042. * @hidden
  82043. */
  82044. export interface IMatrixLike {
  82045. toArray(): DeepImmutable<Float32Array | Array<number>>;
  82046. updateFlag: int;
  82047. }
  82048. /**
  82049. * @hidden
  82050. */
  82051. export interface IViewportLike {
  82052. x: float;
  82053. y: float;
  82054. width: float;
  82055. height: float;
  82056. }
  82057. /**
  82058. * @hidden
  82059. */
  82060. export interface IPlaneLike {
  82061. normal: IVector3Like;
  82062. d: float;
  82063. normalize(): void;
  82064. }
  82065. }
  82066. declare module BABYLON {
  82067. /**
  82068. * Interface used to define common properties for effect fallbacks
  82069. */
  82070. export interface IEffectFallbacks {
  82071. /**
  82072. * Removes the defines that should be removed when falling back.
  82073. * @param currentDefines defines the current define statements for the shader.
  82074. * @param effect defines the current effect we try to compile
  82075. * @returns The resulting defines with defines of the current rank removed.
  82076. */
  82077. reduce(currentDefines: string, effect: Effect): string;
  82078. /**
  82079. * Removes the fallback from the bound mesh.
  82080. */
  82081. unBindMesh(): void;
  82082. /**
  82083. * Checks to see if more fallbacks are still availible.
  82084. */
  82085. hasMoreFallbacks: boolean;
  82086. }
  82087. }
  82088. declare module BABYLON {
  82089. /**
  82090. * Class used to evalaute queries containing `and` and `or` operators
  82091. */
  82092. export class AndOrNotEvaluator {
  82093. /**
  82094. * Evaluate a query
  82095. * @param query defines the query to evaluate
  82096. * @param evaluateCallback defines the callback used to filter result
  82097. * @returns true if the query matches
  82098. */
  82099. static Eval(query: string, evaluateCallback: (val: any) => boolean): boolean;
  82100. private static _HandleParenthesisContent;
  82101. private static _SimplifyNegation;
  82102. }
  82103. }
  82104. declare module BABYLON {
  82105. /**
  82106. * Class used to store custom tags
  82107. */
  82108. export class Tags {
  82109. /**
  82110. * Adds support for tags on the given object
  82111. * @param obj defines the object to use
  82112. */
  82113. static EnableFor(obj: any): void;
  82114. /**
  82115. * Removes tags support
  82116. * @param obj defines the object to use
  82117. */
  82118. static DisableFor(obj: any): void;
  82119. /**
  82120. * Gets a boolean indicating if the given object has tags
  82121. * @param obj defines the object to use
  82122. * @returns a boolean
  82123. */
  82124. static HasTags(obj: any): boolean;
  82125. /**
  82126. * Gets the tags available on a given object
  82127. * @param obj defines the object to use
  82128. * @param asString defines if the tags must be returned as a string instead of an array of strings
  82129. * @returns the tags
  82130. */
  82131. static GetTags(obj: any, asString?: boolean): any;
  82132. /**
  82133. * Adds tags to an object
  82134. * @param obj defines the object to use
  82135. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  82136. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  82137. */
  82138. static AddTagsTo(obj: any, tagsString: string): void;
  82139. /**
  82140. * @hidden
  82141. */
  82142. static _AddTagTo(obj: any, tag: string): void;
  82143. /**
  82144. * Removes specific tags from a specific object
  82145. * @param obj defines the object to use
  82146. * @param tagsString defines the tags to remove
  82147. */
  82148. static RemoveTagsFrom(obj: any, tagsString: string): void;
  82149. /**
  82150. * @hidden
  82151. */
  82152. static _RemoveTagFrom(obj: any, tag: string): void;
  82153. /**
  82154. * Defines if tags hosted on an object match a given query
  82155. * @param obj defines the object to use
  82156. * @param tagsQuery defines the tag query
  82157. * @returns a boolean
  82158. */
  82159. static MatchesQuery(obj: any, tagsQuery: string): boolean;
  82160. }
  82161. }
  82162. declare module BABYLON {
  82163. /**
  82164. * Scalar computation library
  82165. */
  82166. export class Scalar {
  82167. /**
  82168. * Two pi constants convenient for computation.
  82169. */
  82170. static TwoPi: number;
  82171. /**
  82172. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82173. * @param a number
  82174. * @param b number
  82175. * @param epsilon (default = 1.401298E-45)
  82176. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  82177. */
  82178. static WithinEpsilon(a: number, b: number, epsilon?: number): boolean;
  82179. /**
  82180. * Returns a string : the upper case translation of the number i to hexadecimal.
  82181. * @param i number
  82182. * @returns the upper case translation of the number i to hexadecimal.
  82183. */
  82184. static ToHex(i: number): string;
  82185. /**
  82186. * Returns -1 if value is negative and +1 is value is positive.
  82187. * @param value the value
  82188. * @returns the value itself if it's equal to zero.
  82189. */
  82190. static Sign(value: number): number;
  82191. /**
  82192. * Returns the value itself if it's between min and max.
  82193. * Returns min if the value is lower than min.
  82194. * Returns max if the value is greater than max.
  82195. * @param value the value to clmap
  82196. * @param min the min value to clamp to (default: 0)
  82197. * @param max the max value to clamp to (default: 1)
  82198. * @returns the clamped value
  82199. */
  82200. static Clamp(value: number, min?: number, max?: number): number;
  82201. /**
  82202. * the log2 of value.
  82203. * @param value the value to compute log2 of
  82204. * @returns the log2 of value.
  82205. */
  82206. static Log2(value: number): number;
  82207. /**
  82208. * Loops the value, so that it is never larger than length and never smaller than 0.
  82209. *
  82210. * This is similar to the modulo operator but it works with floating point numbers.
  82211. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  82212. * With t = 5 and length = 2.5, the result would be 0.0.
  82213. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  82214. * @param value the value
  82215. * @param length the length
  82216. * @returns the looped value
  82217. */
  82218. static Repeat(value: number, length: number): number;
  82219. /**
  82220. * Normalize the value between 0.0 and 1.0 using min and max values
  82221. * @param value value to normalize
  82222. * @param min max to normalize between
  82223. * @param max min to normalize between
  82224. * @returns the normalized value
  82225. */
  82226. static Normalize(value: number, min: number, max: number): number;
  82227. /**
  82228. * Denormalize the value from 0.0 and 1.0 using min and max values
  82229. * @param normalized value to denormalize
  82230. * @param min max to denormalize between
  82231. * @param max min to denormalize between
  82232. * @returns the denormalized value
  82233. */
  82234. static Denormalize(normalized: number, min: number, max: number): number;
  82235. /**
  82236. * Calculates the shortest difference between two given angles given in degrees.
  82237. * @param current current angle in degrees
  82238. * @param target target angle in degrees
  82239. * @returns the delta
  82240. */
  82241. static DeltaAngle(current: number, target: number): number;
  82242. /**
  82243. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  82244. * @param tx value
  82245. * @param length length
  82246. * @returns The returned value will move back and forth between 0 and length
  82247. */
  82248. static PingPong(tx: number, length: number): number;
  82249. /**
  82250. * Interpolates between min and max with smoothing at the limits.
  82251. *
  82252. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  82253. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  82254. * @param from from
  82255. * @param to to
  82256. * @param tx value
  82257. * @returns the smooth stepped value
  82258. */
  82259. static SmoothStep(from: number, to: number, tx: number): number;
  82260. /**
  82261. * Moves a value current towards target.
  82262. *
  82263. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  82264. * Negative values of maxDelta pushes the value away from target.
  82265. * @param current current value
  82266. * @param target target value
  82267. * @param maxDelta max distance to move
  82268. * @returns resulting value
  82269. */
  82270. static MoveTowards(current: number, target: number, maxDelta: number): number;
  82271. /**
  82272. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82273. *
  82274. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  82275. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  82276. * @param current current value
  82277. * @param target target value
  82278. * @param maxDelta max distance to move
  82279. * @returns resulting angle
  82280. */
  82281. static MoveTowardsAngle(current: number, target: number, maxDelta: number): number;
  82282. /**
  82283. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  82284. * @param start start value
  82285. * @param end target value
  82286. * @param amount amount to lerp between
  82287. * @returns the lerped value
  82288. */
  82289. static Lerp(start: number, end: number, amount: number): number;
  82290. /**
  82291. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  82292. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  82293. * @param start start value
  82294. * @param end target value
  82295. * @param amount amount to lerp between
  82296. * @returns the lerped value
  82297. */
  82298. static LerpAngle(start: number, end: number, amount: number): number;
  82299. /**
  82300. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  82301. * @param a start value
  82302. * @param b target value
  82303. * @param value value between a and b
  82304. * @returns the inverseLerp value
  82305. */
  82306. static InverseLerp(a: number, b: number, value: number): number;
  82307. /**
  82308. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  82309. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  82310. * @param value1 spline value
  82311. * @param tangent1 spline value
  82312. * @param value2 spline value
  82313. * @param tangent2 spline value
  82314. * @param amount input value
  82315. * @returns hermite result
  82316. */
  82317. static Hermite(value1: number, tangent1: number, value2: number, tangent2: number, amount: number): number;
  82318. /**
  82319. * Returns a random float number between and min and max values
  82320. * @param min min value of random
  82321. * @param max max value of random
  82322. * @returns random value
  82323. */
  82324. static RandomRange(min: number, max: number): number;
  82325. /**
  82326. * This function returns percentage of a number in a given range.
  82327. *
  82328. * RangeToPercent(40,20,60) will return 0.5 (50%)
  82329. * RangeToPercent(34,0,100) will return 0.34 (34%)
  82330. * @param number to convert to percentage
  82331. * @param min min range
  82332. * @param max max range
  82333. * @returns the percentage
  82334. */
  82335. static RangeToPercent(number: number, min: number, max: number): number;
  82336. /**
  82337. * This function returns number that corresponds to the percentage in a given range.
  82338. *
  82339. * PercentToRange(0.34,0,100) will return 34.
  82340. * @param percent to convert to number
  82341. * @param min min range
  82342. * @param max max range
  82343. * @returns the number
  82344. */
  82345. static PercentToRange(percent: number, min: number, max: number): number;
  82346. /**
  82347. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  82348. * @param angle The angle to normalize in radian.
  82349. * @return The converted angle.
  82350. */
  82351. static NormalizeRadians(angle: number): number;
  82352. }
  82353. }
  82354. declare module BABYLON {
  82355. /**
  82356. * Constant used to convert a value to gamma space
  82357. * @ignorenaming
  82358. */
  82359. export const ToGammaSpace: number;
  82360. /**
  82361. * Constant used to convert a value to linear space
  82362. * @ignorenaming
  82363. */
  82364. export const ToLinearSpace = 2.2;
  82365. /**
  82366. * Constant used to define the minimal number value in Babylon.js
  82367. * @ignorenaming
  82368. */
  82369. let Epsilon: number;
  82370. }
  82371. declare module BABYLON {
  82372. /**
  82373. * Class used to represent a viewport on screen
  82374. */
  82375. export class Viewport {
  82376. /** viewport left coordinate */
  82377. x: number;
  82378. /** viewport top coordinate */
  82379. y: number;
  82380. /**viewport width */
  82381. width: number;
  82382. /** viewport height */
  82383. height: number;
  82384. /**
  82385. * Creates a Viewport object located at (x, y) and sized (width, height)
  82386. * @param x defines viewport left coordinate
  82387. * @param y defines viewport top coordinate
  82388. * @param width defines the viewport width
  82389. * @param height defines the viewport height
  82390. */
  82391. constructor(
  82392. /** viewport left coordinate */
  82393. x: number,
  82394. /** viewport top coordinate */
  82395. y: number,
  82396. /**viewport width */
  82397. width: number,
  82398. /** viewport height */
  82399. height: number);
  82400. /**
  82401. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  82402. * @param renderWidth defines the rendering width
  82403. * @param renderHeight defines the rendering height
  82404. * @returns a new Viewport
  82405. */
  82406. toGlobal(renderWidth: number, renderHeight: number): Viewport;
  82407. /**
  82408. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  82409. * @param renderWidth defines the rendering width
  82410. * @param renderHeight defines the rendering height
  82411. * @param ref defines the target viewport
  82412. * @returns the current viewport
  82413. */
  82414. toGlobalToRef(renderWidth: number, renderHeight: number, ref: Viewport): Viewport;
  82415. /**
  82416. * Returns a new Viewport copied from the current one
  82417. * @returns a new Viewport
  82418. */
  82419. clone(): Viewport;
  82420. }
  82421. }
  82422. declare module BABYLON {
  82423. /**
  82424. * Class containing a set of static utilities functions for arrays.
  82425. */
  82426. export class ArrayTools {
  82427. /**
  82428. * Returns an array of the given size filled with element built from the given constructor and the paramters
  82429. * @param size the number of element to construct and put in the array
  82430. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  82431. * @returns a new array filled with new objects
  82432. */
  82433. static BuildArray<T>(size: number, itemBuilder: () => T): Array<T>;
  82434. }
  82435. }
  82436. declare module BABYLON {
  82437. /**
  82438. * Represents a plane by the equation ax + by + cz + d = 0
  82439. */
  82440. export class Plane {
  82441. private static _TmpMatrix;
  82442. /**
  82443. * Normal of the plane (a,b,c)
  82444. */
  82445. normal: Vector3;
  82446. /**
  82447. * d component of the plane
  82448. */
  82449. d: number;
  82450. /**
  82451. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  82452. * @param a a component of the plane
  82453. * @param b b component of the plane
  82454. * @param c c component of the plane
  82455. * @param d d component of the plane
  82456. */
  82457. constructor(a: number, b: number, c: number, d: number);
  82458. /**
  82459. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  82460. */
  82461. asArray(): number[];
  82462. /**
  82463. * @returns a new plane copied from the current Plane.
  82464. */
  82465. clone(): Plane;
  82466. /**
  82467. * @returns the string "Plane".
  82468. */
  82469. getClassName(): string;
  82470. /**
  82471. * @returns the Plane hash code.
  82472. */
  82473. getHashCode(): number;
  82474. /**
  82475. * Normalize the current Plane in place.
  82476. * @returns the updated Plane.
  82477. */
  82478. normalize(): Plane;
  82479. /**
  82480. * Applies a transformation the plane and returns the result
  82481. * @param transformation the transformation matrix to be applied to the plane
  82482. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  82483. */
  82484. transform(transformation: DeepImmutable<Matrix>): Plane;
  82485. /**
  82486. * Compute the dot product between the point and the plane normal
  82487. * @param point point to calculate the dot product with
  82488. * @returns the dot product (float) of the point coordinates and the plane normal.
  82489. */
  82490. dotCoordinate(point: DeepImmutable<Vector3>): number;
  82491. /**
  82492. * Updates the current Plane from the plane defined by the three given points.
  82493. * @param point1 one of the points used to contruct the plane
  82494. * @param point2 one of the points used to contruct the plane
  82495. * @param point3 one of the points used to contruct the plane
  82496. * @returns the updated Plane.
  82497. */
  82498. copyFromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82499. /**
  82500. * Checks if the plane is facing a given direction
  82501. * @param direction the direction to check if the plane is facing
  82502. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  82503. * @returns True is the vector "direction" is the same side than the plane normal.
  82504. */
  82505. isFrontFacingTo(direction: DeepImmutable<Vector3>, epsilon: number): boolean;
  82506. /**
  82507. * Calculates the distance to a point
  82508. * @param point point to calculate distance to
  82509. * @returns the signed distance (float) from the given point to the Plane.
  82510. */
  82511. signedDistanceTo(point: DeepImmutable<Vector3>): number;
  82512. /**
  82513. * Creates a plane from an array
  82514. * @param array the array to create a plane from
  82515. * @returns a new Plane from the given array.
  82516. */
  82517. static FromArray(array: DeepImmutable<ArrayLike<number>>): Plane;
  82518. /**
  82519. * Creates a plane from three points
  82520. * @param point1 point used to create the plane
  82521. * @param point2 point used to create the plane
  82522. * @param point3 point used to create the plane
  82523. * @returns a new Plane defined by the three given points.
  82524. */
  82525. static FromPoints(point1: DeepImmutable<Vector3>, point2: DeepImmutable<Vector3>, point3: DeepImmutable<Vector3>): Plane;
  82526. /**
  82527. * Creates a plane from an origin point and a normal
  82528. * @param origin origin of the plane to be constructed
  82529. * @param normal normal of the plane to be constructed
  82530. * @returns a new Plane the normal vector to this plane at the given origin point.
  82531. * Note : the vector "normal" is updated because normalized.
  82532. */
  82533. static FromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: Vector3): Plane;
  82534. /**
  82535. * Calculates the distance from a plane and a point
  82536. * @param origin origin of the plane to be constructed
  82537. * @param normal normal of the plane to be constructed
  82538. * @param point point to calculate distance to
  82539. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  82540. */
  82541. static SignedDistanceToPlaneFromPositionAndNormal(origin: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>, point: DeepImmutable<Vector3>): number;
  82542. }
  82543. }
  82544. declare module BABYLON {
  82545. /** @hidden */
  82546. export class PerformanceConfigurator {
  82547. /** @hidden */
  82548. static MatrixUse64Bits: boolean;
  82549. /** @hidden */
  82550. static MatrixTrackPrecisionChange: boolean;
  82551. /** @hidden */
  82552. static MatrixCurrentType: any;
  82553. /** @hidden */
  82554. static MatrixTrackedMatrices: Array<any> | null;
  82555. /** @hidden */
  82556. static SetMatrixPrecision(use64bits: boolean): void;
  82557. }
  82558. }
  82559. declare module BABYLON {
  82560. /**
  82561. * Class representing a vector containing 2 coordinates
  82562. */
  82563. export class Vector2 {
  82564. /** defines the first coordinate */
  82565. x: number;
  82566. /** defines the second coordinate */
  82567. y: number;
  82568. /**
  82569. * Creates a new Vector2 from the given x and y coordinates
  82570. * @param x defines the first coordinate
  82571. * @param y defines the second coordinate
  82572. */
  82573. constructor(
  82574. /** defines the first coordinate */
  82575. x?: number,
  82576. /** defines the second coordinate */
  82577. y?: number);
  82578. /**
  82579. * Gets a string with the Vector2 coordinates
  82580. * @returns a string with the Vector2 coordinates
  82581. */
  82582. toString(): string;
  82583. /**
  82584. * Gets class name
  82585. * @returns the string "Vector2"
  82586. */
  82587. getClassName(): string;
  82588. /**
  82589. * Gets current vector hash code
  82590. * @returns the Vector2 hash code as a number
  82591. */
  82592. getHashCode(): number;
  82593. /**
  82594. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  82595. * @param array defines the source array
  82596. * @param index defines the offset in source array
  82597. * @returns the current Vector2
  82598. */
  82599. toArray(array: FloatArray, index?: number): Vector2;
  82600. /**
  82601. * Update the current vector from an array
  82602. * @param array defines the destination array
  82603. * @param index defines the offset in the destination array
  82604. * @returns the current Vector3
  82605. */
  82606. fromArray(array: FloatArray, index?: number): Vector2;
  82607. /**
  82608. * Copy the current vector to an array
  82609. * @returns a new array with 2 elements: the Vector2 coordinates.
  82610. */
  82611. asArray(): number[];
  82612. /**
  82613. * Sets the Vector2 coordinates with the given Vector2 coordinates
  82614. * @param source defines the source Vector2
  82615. * @returns the current updated Vector2
  82616. */
  82617. copyFrom(source: DeepImmutable<Vector2>): Vector2;
  82618. /**
  82619. * Sets the Vector2 coordinates with the given floats
  82620. * @param x defines the first coordinate
  82621. * @param y defines the second coordinate
  82622. * @returns the current updated Vector2
  82623. */
  82624. copyFromFloats(x: number, y: number): Vector2;
  82625. /**
  82626. * Sets the Vector2 coordinates with the given floats
  82627. * @param x defines the first coordinate
  82628. * @param y defines the second coordinate
  82629. * @returns the current updated Vector2
  82630. */
  82631. set(x: number, y: number): Vector2;
  82632. /**
  82633. * Add another vector with the current one
  82634. * @param otherVector defines the other vector
  82635. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  82636. */
  82637. add(otherVector: DeepImmutable<Vector2>): Vector2;
  82638. /**
  82639. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  82640. * @param otherVector defines the other vector
  82641. * @param result defines the target vector
  82642. * @returns the unmodified current Vector2
  82643. */
  82644. addToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82645. /**
  82646. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  82647. * @param otherVector defines the other vector
  82648. * @returns the current updated Vector2
  82649. */
  82650. addInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82651. /**
  82652. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  82653. * @param otherVector defines the other vector
  82654. * @returns a new Vector2
  82655. */
  82656. addVector3(otherVector: Vector3): Vector2;
  82657. /**
  82658. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  82659. * @param otherVector defines the other vector
  82660. * @returns a new Vector2
  82661. */
  82662. subtract(otherVector: Vector2): Vector2;
  82663. /**
  82664. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  82665. * @param otherVector defines the other vector
  82666. * @param result defines the target vector
  82667. * @returns the unmodified current Vector2
  82668. */
  82669. subtractToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82670. /**
  82671. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  82672. * @param otherVector defines the other vector
  82673. * @returns the current updated Vector2
  82674. */
  82675. subtractInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82676. /**
  82677. * Multiplies in place the current Vector2 coordinates by the given ones
  82678. * @param otherVector defines the other vector
  82679. * @returns the current updated Vector2
  82680. */
  82681. multiplyInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82682. /**
  82683. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  82684. * @param otherVector defines the other vector
  82685. * @returns a new Vector2
  82686. */
  82687. multiply(otherVector: DeepImmutable<Vector2>): Vector2;
  82688. /**
  82689. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  82690. * @param otherVector defines the other vector
  82691. * @param result defines the target vector
  82692. * @returns the unmodified current Vector2
  82693. */
  82694. multiplyToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82695. /**
  82696. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  82697. * @param x defines the first coordinate
  82698. * @param y defines the second coordinate
  82699. * @returns a new Vector2
  82700. */
  82701. multiplyByFloats(x: number, y: number): Vector2;
  82702. /**
  82703. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  82704. * @param otherVector defines the other vector
  82705. * @returns a new Vector2
  82706. */
  82707. divide(otherVector: Vector2): Vector2;
  82708. /**
  82709. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  82710. * @param otherVector defines the other vector
  82711. * @param result defines the target vector
  82712. * @returns the unmodified current Vector2
  82713. */
  82714. divideToRef(otherVector: DeepImmutable<Vector2>, result: Vector2): Vector2;
  82715. /**
  82716. * Divides the current Vector2 coordinates by the given ones
  82717. * @param otherVector defines the other vector
  82718. * @returns the current updated Vector2
  82719. */
  82720. divideInPlace(otherVector: DeepImmutable<Vector2>): Vector2;
  82721. /**
  82722. * Gets a new Vector2 with current Vector2 negated coordinates
  82723. * @returns a new Vector2
  82724. */
  82725. negate(): Vector2;
  82726. /**
  82727. * Negate this vector in place
  82728. * @returns this
  82729. */
  82730. negateInPlace(): Vector2;
  82731. /**
  82732. * Negate the current Vector2 and stores the result in the given vector "result" coordinates
  82733. * @param result defines the Vector3 object where to store the result
  82734. * @returns the current Vector2
  82735. */
  82736. negateToRef(result: Vector2): Vector2;
  82737. /**
  82738. * Multiply the Vector2 coordinates by scale
  82739. * @param scale defines the scaling factor
  82740. * @returns the current updated Vector2
  82741. */
  82742. scaleInPlace(scale: number): Vector2;
  82743. /**
  82744. * Returns a new Vector2 scaled by "scale" from the current Vector2
  82745. * @param scale defines the scaling factor
  82746. * @returns a new Vector2
  82747. */
  82748. scale(scale: number): Vector2;
  82749. /**
  82750. * Scale the current Vector2 values by a factor to a given Vector2
  82751. * @param scale defines the scale factor
  82752. * @param result defines the Vector2 object where to store the result
  82753. * @returns the unmodified current Vector2
  82754. */
  82755. scaleToRef(scale: number, result: Vector2): Vector2;
  82756. /**
  82757. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  82758. * @param scale defines the scale factor
  82759. * @param result defines the Vector2 object where to store the result
  82760. * @returns the unmodified current Vector2
  82761. */
  82762. scaleAndAddToRef(scale: number, result: Vector2): Vector2;
  82763. /**
  82764. * Gets a boolean if two vectors are equals
  82765. * @param otherVector defines the other vector
  82766. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  82767. */
  82768. equals(otherVector: DeepImmutable<Vector2>): boolean;
  82769. /**
  82770. * Gets a boolean if two vectors are equals (using an epsilon value)
  82771. * @param otherVector defines the other vector
  82772. * @param epsilon defines the minimal distance to consider equality
  82773. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  82774. */
  82775. equalsWithEpsilon(otherVector: DeepImmutable<Vector2>, epsilon?: number): boolean;
  82776. /**
  82777. * Gets a new Vector2 from current Vector2 floored values
  82778. * @returns a new Vector2
  82779. */
  82780. floor(): Vector2;
  82781. /**
  82782. * Gets a new Vector2 from current Vector2 floored values
  82783. * @returns a new Vector2
  82784. */
  82785. fract(): Vector2;
  82786. /**
  82787. * Gets the length of the vector
  82788. * @returns the vector length (float)
  82789. */
  82790. length(): number;
  82791. /**
  82792. * Gets the vector squared length
  82793. * @returns the vector squared length (float)
  82794. */
  82795. lengthSquared(): number;
  82796. /**
  82797. * Normalize the vector
  82798. * @returns the current updated Vector2
  82799. */
  82800. normalize(): Vector2;
  82801. /**
  82802. * Gets a new Vector2 copied from the Vector2
  82803. * @returns a new Vector2
  82804. */
  82805. clone(): Vector2;
  82806. /**
  82807. * Gets a new Vector2(0, 0)
  82808. * @returns a new Vector2
  82809. */
  82810. static Zero(): Vector2;
  82811. /**
  82812. * Gets a new Vector2(1, 1)
  82813. * @returns a new Vector2
  82814. */
  82815. static One(): Vector2;
  82816. /**
  82817. * Gets a new Vector2 set from the given index element of the given array
  82818. * @param array defines the data source
  82819. * @param offset defines the offset in the data source
  82820. * @returns a new Vector2
  82821. */
  82822. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector2;
  82823. /**
  82824. * Sets "result" from the given index element of the given array
  82825. * @param array defines the data source
  82826. * @param offset defines the offset in the data source
  82827. * @param result defines the target vector
  82828. */
  82829. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector2): void;
  82830. /**
  82831. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  82832. * @param value1 defines 1st point of control
  82833. * @param value2 defines 2nd point of control
  82834. * @param value3 defines 3rd point of control
  82835. * @param value4 defines 4th point of control
  82836. * @param amount defines the interpolation factor
  82837. * @returns a new Vector2
  82838. */
  82839. static CatmullRom(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, value3: DeepImmutable<Vector2>, value4: DeepImmutable<Vector2>, amount: number): Vector2;
  82840. /**
  82841. * 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".
  82842. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  82843. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  82844. * @param value defines the value to clamp
  82845. * @param min defines the lower limit
  82846. * @param max defines the upper limit
  82847. * @returns a new Vector2
  82848. */
  82849. static Clamp(value: DeepImmutable<Vector2>, min: DeepImmutable<Vector2>, max: DeepImmutable<Vector2>): Vector2;
  82850. /**
  82851. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  82852. * @param value1 defines the 1st control point
  82853. * @param tangent1 defines the outgoing tangent
  82854. * @param value2 defines the 2nd control point
  82855. * @param tangent2 defines the incoming tangent
  82856. * @param amount defines the interpolation factor
  82857. * @returns a new Vector2
  82858. */
  82859. static Hermite(value1: DeepImmutable<Vector2>, tangent1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>, tangent2: DeepImmutable<Vector2>, amount: number): Vector2;
  82860. /**
  82861. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  82862. * @param start defines the start vector
  82863. * @param end defines the end vector
  82864. * @param amount defines the interpolation factor
  82865. * @returns a new Vector2
  82866. */
  82867. static Lerp(start: DeepImmutable<Vector2>, end: DeepImmutable<Vector2>, amount: number): Vector2;
  82868. /**
  82869. * Gets the dot product of the vector "left" and the vector "right"
  82870. * @param left defines first vector
  82871. * @param right defines second vector
  82872. * @returns the dot product (float)
  82873. */
  82874. static Dot(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): number;
  82875. /**
  82876. * Returns a new Vector2 equal to the normalized given vector
  82877. * @param vector defines the vector to normalize
  82878. * @returns a new Vector2
  82879. */
  82880. static Normalize(vector: DeepImmutable<Vector2>): Vector2;
  82881. /**
  82882. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  82883. * @param left defines 1st vector
  82884. * @param right defines 2nd vector
  82885. * @returns a new Vector2
  82886. */
  82887. static Minimize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82888. /**
  82889. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  82890. * @param left defines 1st vector
  82891. * @param right defines 2nd vector
  82892. * @returns a new Vector2
  82893. */
  82894. static Maximize(left: DeepImmutable<Vector2>, right: DeepImmutable<Vector2>): Vector2;
  82895. /**
  82896. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  82897. * @param vector defines the vector to transform
  82898. * @param transformation defines the matrix to apply
  82899. * @returns a new Vector2
  82900. */
  82901. static Transform(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>): Vector2;
  82902. /**
  82903. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  82904. * @param vector defines the vector to transform
  82905. * @param transformation defines the matrix to apply
  82906. * @param result defines the target vector
  82907. */
  82908. static TransformToRef(vector: DeepImmutable<Vector2>, transformation: DeepImmutable<Matrix>, result: Vector2): void;
  82909. /**
  82910. * Determines if a given vector is included in a triangle
  82911. * @param p defines the vector to test
  82912. * @param p0 defines 1st triangle point
  82913. * @param p1 defines 2nd triangle point
  82914. * @param p2 defines 3rd triangle point
  82915. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  82916. */
  82917. static PointInTriangle(p: DeepImmutable<Vector2>, p0: DeepImmutable<Vector2>, p1: DeepImmutable<Vector2>, p2: DeepImmutable<Vector2>): boolean;
  82918. /**
  82919. * Gets the distance between the vectors "value1" and "value2"
  82920. * @param value1 defines first vector
  82921. * @param value2 defines second vector
  82922. * @returns the distance between vectors
  82923. */
  82924. static Distance(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82925. /**
  82926. * Returns the squared distance between the vectors "value1" and "value2"
  82927. * @param value1 defines first vector
  82928. * @param value2 defines second vector
  82929. * @returns the squared distance between vectors
  82930. */
  82931. static DistanceSquared(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): number;
  82932. /**
  82933. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  82934. * @param value1 defines first vector
  82935. * @param value2 defines second vector
  82936. * @returns a new Vector2
  82937. */
  82938. static Center(value1: DeepImmutable<Vector2>, value2: DeepImmutable<Vector2>): Vector2;
  82939. /**
  82940. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  82941. * @param p defines the middle point
  82942. * @param segA defines one point of the segment
  82943. * @param segB defines the other point of the segment
  82944. * @returns the shortest distance
  82945. */
  82946. static DistanceOfPointFromSegment(p: DeepImmutable<Vector2>, segA: DeepImmutable<Vector2>, segB: DeepImmutable<Vector2>): number;
  82947. }
  82948. /**
  82949. * Class used to store (x,y,z) vector representation
  82950. * A Vector3 is the main object used in 3D geometry
  82951. * It can represent etiher the coordinates of a point the space, either a direction
  82952. * Reminder: js uses a left handed forward facing system
  82953. */
  82954. export class Vector3 {
  82955. private static _UpReadOnly;
  82956. private static _ZeroReadOnly;
  82957. /** @hidden */
  82958. _x: number;
  82959. /** @hidden */
  82960. _y: number;
  82961. /** @hidden */
  82962. _z: number;
  82963. /** @hidden */
  82964. _isDirty: boolean;
  82965. /** Gets or sets the x coordinate */
  82966. get x(): number;
  82967. set x(value: number);
  82968. /** Gets or sets the y coordinate */
  82969. get y(): number;
  82970. set y(value: number);
  82971. /** Gets or sets the z coordinate */
  82972. get z(): number;
  82973. set z(value: number);
  82974. /**
  82975. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  82976. * @param x defines the first coordinates (on X axis)
  82977. * @param y defines the second coordinates (on Y axis)
  82978. * @param z defines the third coordinates (on Z axis)
  82979. */
  82980. constructor(x?: number, y?: number, z?: number);
  82981. /**
  82982. * Creates a string representation of the Vector3
  82983. * @returns a string with the Vector3 coordinates.
  82984. */
  82985. toString(): string;
  82986. /**
  82987. * Gets the class name
  82988. * @returns the string "Vector3"
  82989. */
  82990. getClassName(): string;
  82991. /**
  82992. * Creates the Vector3 hash code
  82993. * @returns a number which tends to be unique between Vector3 instances
  82994. */
  82995. getHashCode(): number;
  82996. /**
  82997. * Creates an array containing three elements : the coordinates of the Vector3
  82998. * @returns a new array of numbers
  82999. */
  83000. asArray(): number[];
  83001. /**
  83002. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  83003. * @param array defines the destination array
  83004. * @param index defines the offset in the destination array
  83005. * @returns the current Vector3
  83006. */
  83007. toArray(array: FloatArray, index?: number): Vector3;
  83008. /**
  83009. * Update the current vector from an array
  83010. * @param array defines the destination array
  83011. * @param index defines the offset in the destination array
  83012. * @returns the current Vector3
  83013. */
  83014. fromArray(array: FloatArray, index?: number): Vector3;
  83015. /**
  83016. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  83017. * @returns a new Quaternion object, computed from the Vector3 coordinates
  83018. */
  83019. toQuaternion(): Quaternion;
  83020. /**
  83021. * Adds the given vector to the current Vector3
  83022. * @param otherVector defines the second operand
  83023. * @returns the current updated Vector3
  83024. */
  83025. addInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83026. /**
  83027. * Adds the given coordinates to the current Vector3
  83028. * @param x defines the x coordinate of the operand
  83029. * @param y defines the y coordinate of the operand
  83030. * @param z defines the z coordinate of the operand
  83031. * @returns the current updated Vector3
  83032. */
  83033. addInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83034. /**
  83035. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  83036. * @param otherVector defines the second operand
  83037. * @returns the resulting Vector3
  83038. */
  83039. add(otherVector: DeepImmutable<Vector3>): Vector3;
  83040. /**
  83041. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  83042. * @param otherVector defines the second operand
  83043. * @param result defines the Vector3 object where to store the result
  83044. * @returns the current Vector3
  83045. */
  83046. addToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83047. /**
  83048. * Subtract the given vector from the current Vector3
  83049. * @param otherVector defines the second operand
  83050. * @returns the current updated Vector3
  83051. */
  83052. subtractInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83053. /**
  83054. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  83055. * @param otherVector defines the second operand
  83056. * @returns the resulting Vector3
  83057. */
  83058. subtract(otherVector: DeepImmutable<Vector3>): Vector3;
  83059. /**
  83060. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  83061. * @param otherVector defines the second operand
  83062. * @param result defines the Vector3 object where to store the result
  83063. * @returns the current Vector3
  83064. */
  83065. subtractToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83066. /**
  83067. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  83068. * @param x defines the x coordinate of the operand
  83069. * @param y defines the y coordinate of the operand
  83070. * @param z defines the z coordinate of the operand
  83071. * @returns the resulting Vector3
  83072. */
  83073. subtractFromFloats(x: number, y: number, z: number): Vector3;
  83074. /**
  83075. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  83076. * @param x defines the x coordinate of the operand
  83077. * @param y defines the y coordinate of the operand
  83078. * @param z defines the z coordinate of the operand
  83079. * @param result defines the Vector3 object where to store the result
  83080. * @returns the current Vector3
  83081. */
  83082. subtractFromFloatsToRef(x: number, y: number, z: number, result: Vector3): Vector3;
  83083. /**
  83084. * Gets a new Vector3 set with the current Vector3 negated coordinates
  83085. * @returns a new Vector3
  83086. */
  83087. negate(): Vector3;
  83088. /**
  83089. * Negate this vector in place
  83090. * @returns this
  83091. */
  83092. negateInPlace(): Vector3;
  83093. /**
  83094. * Negate the current Vector3 and stores the result in the given vector "result" coordinates
  83095. * @param result defines the Vector3 object where to store the result
  83096. * @returns the current Vector3
  83097. */
  83098. negateToRef(result: Vector3): Vector3;
  83099. /**
  83100. * Multiplies the Vector3 coordinates by the float "scale"
  83101. * @param scale defines the multiplier factor
  83102. * @returns the current updated Vector3
  83103. */
  83104. scaleInPlace(scale: number): Vector3;
  83105. /**
  83106. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  83107. * @param scale defines the multiplier factor
  83108. * @returns a new Vector3
  83109. */
  83110. scale(scale: number): Vector3;
  83111. /**
  83112. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  83113. * @param scale defines the multiplier factor
  83114. * @param result defines the Vector3 object where to store the result
  83115. * @returns the current Vector3
  83116. */
  83117. scaleToRef(scale: number, result: Vector3): Vector3;
  83118. /**
  83119. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  83120. * @param scale defines the scale factor
  83121. * @param result defines the Vector3 object where to store the result
  83122. * @returns the unmodified current Vector3
  83123. */
  83124. scaleAndAddToRef(scale: number, result: Vector3): Vector3;
  83125. /**
  83126. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83127. * @param origin defines the origin of the projection ray
  83128. * @param plane defines the plane to project to
  83129. * @returns the projected vector3
  83130. */
  83131. projectOnPlane(plane: Plane, origin: Vector3): Vector3;
  83132. /**
  83133. * Projects the current vector3 to a plane along a ray starting from a specified origin and directed towards the point.
  83134. * @param origin defines the origin of the projection ray
  83135. * @param plane defines the plane to project to
  83136. * @param result defines the Vector3 where to store the result
  83137. */
  83138. projectOnPlaneToRef(plane: Plane, origin: Vector3, result: Vector3): void;
  83139. /**
  83140. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  83141. * @param otherVector defines the second operand
  83142. * @returns true if both vectors are equals
  83143. */
  83144. equals(otherVector: DeepImmutable<Vector3>): boolean;
  83145. /**
  83146. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  83147. * @param otherVector defines the second operand
  83148. * @param epsilon defines the minimal distance to define values as equals
  83149. * @returns true if both vectors are distant less than epsilon
  83150. */
  83151. equalsWithEpsilon(otherVector: DeepImmutable<Vector3>, epsilon?: number): boolean;
  83152. /**
  83153. * Returns true if the current Vector3 coordinates equals the given floats
  83154. * @param x defines the x coordinate of the operand
  83155. * @param y defines the y coordinate of the operand
  83156. * @param z defines the z coordinate of the operand
  83157. * @returns true if both vectors are equals
  83158. */
  83159. equalsToFloats(x: number, y: number, z: number): boolean;
  83160. /**
  83161. * Multiplies the current Vector3 coordinates by the given ones
  83162. * @param otherVector defines the second operand
  83163. * @returns the current updated Vector3
  83164. */
  83165. multiplyInPlace(otherVector: DeepImmutable<Vector3>): Vector3;
  83166. /**
  83167. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  83168. * @param otherVector defines the second operand
  83169. * @returns the new Vector3
  83170. */
  83171. multiply(otherVector: DeepImmutable<Vector3>): Vector3;
  83172. /**
  83173. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  83174. * @param otherVector defines the second operand
  83175. * @param result defines the Vector3 object where to store the result
  83176. * @returns the current Vector3
  83177. */
  83178. multiplyToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83179. /**
  83180. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  83181. * @param x defines the x coordinate of the operand
  83182. * @param y defines the y coordinate of the operand
  83183. * @param z defines the z coordinate of the operand
  83184. * @returns the new Vector3
  83185. */
  83186. multiplyByFloats(x: number, y: number, z: number): Vector3;
  83187. /**
  83188. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  83189. * @param otherVector defines the second operand
  83190. * @returns the new Vector3
  83191. */
  83192. divide(otherVector: DeepImmutable<Vector3>): Vector3;
  83193. /**
  83194. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  83195. * @param otherVector defines the second operand
  83196. * @param result defines the Vector3 object where to store the result
  83197. * @returns the current Vector3
  83198. */
  83199. divideToRef(otherVector: DeepImmutable<Vector3>, result: Vector3): Vector3;
  83200. /**
  83201. * Divides the current Vector3 coordinates by the given ones.
  83202. * @param otherVector defines the second operand
  83203. * @returns the current updated Vector3
  83204. */
  83205. divideInPlace(otherVector: Vector3): Vector3;
  83206. /**
  83207. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  83208. * @param other defines the second operand
  83209. * @returns the current updated Vector3
  83210. */
  83211. minimizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83212. /**
  83213. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  83214. * @param other defines the second operand
  83215. * @returns the current updated Vector3
  83216. */
  83217. maximizeInPlace(other: DeepImmutable<Vector3>): Vector3;
  83218. /**
  83219. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  83220. * @param x defines the x coordinate of the operand
  83221. * @param y defines the y coordinate of the operand
  83222. * @param z defines the z coordinate of the operand
  83223. * @returns the current updated Vector3
  83224. */
  83225. minimizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83226. /**
  83227. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  83228. * @param x defines the x coordinate of the operand
  83229. * @param y defines the y coordinate of the operand
  83230. * @param z defines the z coordinate of the operand
  83231. * @returns the current updated Vector3
  83232. */
  83233. maximizeInPlaceFromFloats(x: number, y: number, z: number): Vector3;
  83234. /**
  83235. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  83236. * Check if is non uniform within a certain amount of decimal places to account for this
  83237. * @param epsilon the amount the values can differ
  83238. * @returns if the the vector is non uniform to a certain number of decimal places
  83239. */
  83240. isNonUniformWithinEpsilon(epsilon: number): boolean;
  83241. /**
  83242. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  83243. */
  83244. get isNonUniform(): boolean;
  83245. /**
  83246. * Gets a new Vector3 from current Vector3 floored values
  83247. * @returns a new Vector3
  83248. */
  83249. floor(): Vector3;
  83250. /**
  83251. * Gets a new Vector3 from current Vector3 floored values
  83252. * @returns a new Vector3
  83253. */
  83254. fract(): Vector3;
  83255. /**
  83256. * Gets the length of the Vector3
  83257. * @returns the length of the Vector3
  83258. */
  83259. length(): number;
  83260. /**
  83261. * Gets the squared length of the Vector3
  83262. * @returns squared length of the Vector3
  83263. */
  83264. lengthSquared(): number;
  83265. /**
  83266. * Normalize the current Vector3.
  83267. * Please note that this is an in place operation.
  83268. * @returns the current updated Vector3
  83269. */
  83270. normalize(): Vector3;
  83271. /**
  83272. * Reorders the x y z properties of the vector in place
  83273. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  83274. * @returns the current updated vector
  83275. */
  83276. reorderInPlace(order: string): this;
  83277. /**
  83278. * Rotates the vector around 0,0,0 by a quaternion
  83279. * @param quaternion the rotation quaternion
  83280. * @param result vector to store the result
  83281. * @returns the resulting vector
  83282. */
  83283. rotateByQuaternionToRef(quaternion: Quaternion, result: Vector3): Vector3;
  83284. /**
  83285. * Rotates a vector around a given point
  83286. * @param quaternion the rotation quaternion
  83287. * @param point the point to rotate around
  83288. * @param result vector to store the result
  83289. * @returns the resulting vector
  83290. */
  83291. rotateByQuaternionAroundPointToRef(quaternion: Quaternion, point: Vector3, result: Vector3): Vector3;
  83292. /**
  83293. * Returns a new Vector3 as the cross product of the current vector and the "other" one
  83294. * The cross product is then orthogonal to both current and "other"
  83295. * @param other defines the right operand
  83296. * @returns the cross product
  83297. */
  83298. cross(other: Vector3): Vector3;
  83299. /**
  83300. * Normalize the current Vector3 with the given input length.
  83301. * Please note that this is an in place operation.
  83302. * @param len the length of the vector
  83303. * @returns the current updated Vector3
  83304. */
  83305. normalizeFromLength(len: number): Vector3;
  83306. /**
  83307. * Normalize the current Vector3 to a new vector
  83308. * @returns the new Vector3
  83309. */
  83310. normalizeToNew(): Vector3;
  83311. /**
  83312. * Normalize the current Vector3 to the reference
  83313. * @param reference define the Vector3 to update
  83314. * @returns the updated Vector3
  83315. */
  83316. normalizeToRef(reference: Vector3): Vector3;
  83317. /**
  83318. * Creates a new Vector3 copied from the current Vector3
  83319. * @returns the new Vector3
  83320. */
  83321. clone(): Vector3;
  83322. /**
  83323. * Copies the given vector coordinates to the current Vector3 ones
  83324. * @param source defines the source Vector3
  83325. * @returns the current updated Vector3
  83326. */
  83327. copyFrom(source: DeepImmutable<Vector3>): Vector3;
  83328. /**
  83329. * Copies the given floats to the current Vector3 coordinates
  83330. * @param x defines the x coordinate of the operand
  83331. * @param y defines the y coordinate of the operand
  83332. * @param z defines the z coordinate of the operand
  83333. * @returns the current updated Vector3
  83334. */
  83335. copyFromFloats(x: number, y: number, z: number): Vector3;
  83336. /**
  83337. * Copies the given floats to the current Vector3 coordinates
  83338. * @param x defines the x coordinate of the operand
  83339. * @param y defines the y coordinate of the operand
  83340. * @param z defines the z coordinate of the operand
  83341. * @returns the current updated Vector3
  83342. */
  83343. set(x: number, y: number, z: number): Vector3;
  83344. /**
  83345. * Copies the given float to the current Vector3 coordinates
  83346. * @param v defines the x, y and z coordinates of the operand
  83347. * @returns the current updated Vector3
  83348. */
  83349. setAll(v: number): Vector3;
  83350. /**
  83351. * Get the clip factor between two vectors
  83352. * @param vector0 defines the first operand
  83353. * @param vector1 defines the second operand
  83354. * @param axis defines the axis to use
  83355. * @param size defines the size along the axis
  83356. * @returns the clip factor
  83357. */
  83358. static GetClipFactor(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, axis: DeepImmutable<Vector3>, size: number): number;
  83359. /**
  83360. * Get angle between two vectors
  83361. * @param vector0 angle between vector0 and vector1
  83362. * @param vector1 angle between vector0 and vector1
  83363. * @param normal direction of the normal
  83364. * @return the angle between vector0 and vector1
  83365. */
  83366. static GetAngleBetweenVectors(vector0: DeepImmutable<Vector3>, vector1: DeepImmutable<Vector3>, normal: DeepImmutable<Vector3>): number;
  83367. /**
  83368. * Returns a new Vector3 set from the index "offset" of the given array
  83369. * @param array defines the source array
  83370. * @param offset defines the offset in the source array
  83371. * @returns the new Vector3
  83372. */
  83373. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector3;
  83374. /**
  83375. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  83376. * @param array defines the source array
  83377. * @param offset defines the offset in the source array
  83378. * @returns the new Vector3
  83379. * @deprecated Please use FromArray instead.
  83380. */
  83381. static FromFloatArray(array: DeepImmutable<Float32Array>, offset?: number): Vector3;
  83382. /**
  83383. * Sets the given vector "result" with the element values from the index "offset" of the given array
  83384. * @param array defines the source array
  83385. * @param offset defines the offset in the source array
  83386. * @param result defines the Vector3 where to store the result
  83387. */
  83388. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector3): void;
  83389. /**
  83390. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  83391. * @param array defines the source array
  83392. * @param offset defines the offset in the source array
  83393. * @param result defines the Vector3 where to store the result
  83394. * @deprecated Please use FromArrayToRef instead.
  83395. */
  83396. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector3): void;
  83397. /**
  83398. * Sets the given vector "result" with the given floats.
  83399. * @param x defines the x coordinate of the source
  83400. * @param y defines the y coordinate of the source
  83401. * @param z defines the z coordinate of the source
  83402. * @param result defines the Vector3 where to store the result
  83403. */
  83404. static FromFloatsToRef(x: number, y: number, z: number, result: Vector3): void;
  83405. /**
  83406. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  83407. * @returns a new empty Vector3
  83408. */
  83409. static Zero(): Vector3;
  83410. /**
  83411. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  83412. * @returns a new unit Vector3
  83413. */
  83414. static One(): Vector3;
  83415. /**
  83416. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  83417. * @returns a new up Vector3
  83418. */
  83419. static Up(): Vector3;
  83420. /**
  83421. * Gets a up Vector3 that must not be updated
  83422. */
  83423. static get UpReadOnly(): DeepImmutable<Vector3>;
  83424. /**
  83425. * Gets a zero Vector3 that must not be updated
  83426. */
  83427. static get ZeroReadOnly(): DeepImmutable<Vector3>;
  83428. /**
  83429. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  83430. * @returns a new down Vector3
  83431. */
  83432. static Down(): Vector3;
  83433. /**
  83434. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  83435. * @param rightHandedSystem is the scene right-handed (negative z)
  83436. * @returns a new forward Vector3
  83437. */
  83438. static Forward(rightHandedSystem?: boolean): Vector3;
  83439. /**
  83440. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  83441. * @param rightHandedSystem is the scene right-handed (negative-z)
  83442. * @returns a new forward Vector3
  83443. */
  83444. static Backward(rightHandedSystem?: boolean): Vector3;
  83445. /**
  83446. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  83447. * @returns a new right Vector3
  83448. */
  83449. static Right(): Vector3;
  83450. /**
  83451. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  83452. * @returns a new left Vector3
  83453. */
  83454. static Left(): Vector3;
  83455. /**
  83456. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  83457. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83458. * @param vector defines the Vector3 to transform
  83459. * @param transformation defines the transformation matrix
  83460. * @returns the transformed Vector3
  83461. */
  83462. static TransformCoordinates(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83463. /**
  83464. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  83465. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  83466. * @param vector defines the Vector3 to transform
  83467. * @param transformation defines the transformation matrix
  83468. * @param result defines the Vector3 where to store the result
  83469. */
  83470. static TransformCoordinatesToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83471. /**
  83472. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  83473. * This method computes tranformed coordinates only, not transformed direction vectors
  83474. * @param x define the x coordinate of the source vector
  83475. * @param y define the y coordinate of the source vector
  83476. * @param z define the z coordinate of the source vector
  83477. * @param transformation defines the transformation matrix
  83478. * @param result defines the Vector3 where to store the result
  83479. */
  83480. static TransformCoordinatesFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83481. /**
  83482. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  83483. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83484. * @param vector defines the Vector3 to transform
  83485. * @param transformation defines the transformation matrix
  83486. * @returns the new Vector3
  83487. */
  83488. static TransformNormal(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>): Vector3;
  83489. /**
  83490. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  83491. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83492. * @param vector defines the Vector3 to transform
  83493. * @param transformation defines the transformation matrix
  83494. * @param result defines the Vector3 where to store the result
  83495. */
  83496. static TransformNormalToRef(vector: DeepImmutable<Vector3>, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83497. /**
  83498. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  83499. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  83500. * @param x define the x coordinate of the source vector
  83501. * @param y define the y coordinate of the source vector
  83502. * @param z define the z coordinate of the source vector
  83503. * @param transformation defines the transformation matrix
  83504. * @param result defines the Vector3 where to store the result
  83505. */
  83506. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, transformation: DeepImmutable<Matrix>, result: Vector3): void;
  83507. /**
  83508. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  83509. * @param value1 defines the first control point
  83510. * @param value2 defines the second control point
  83511. * @param value3 defines the third control point
  83512. * @param value4 defines the fourth control point
  83513. * @param amount defines the amount on the spline to use
  83514. * @returns the new Vector3
  83515. */
  83516. static CatmullRom(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, value3: DeepImmutable<Vector3>, value4: DeepImmutable<Vector3>, amount: number): Vector3;
  83517. /**
  83518. * 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"
  83519. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83520. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83521. * @param value defines the current value
  83522. * @param min defines the lower range value
  83523. * @param max defines the upper range value
  83524. * @returns the new Vector3
  83525. */
  83526. static Clamp(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): Vector3;
  83527. /**
  83528. * 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"
  83529. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  83530. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  83531. * @param value defines the current value
  83532. * @param min defines the lower range value
  83533. * @param max defines the upper range value
  83534. * @param result defines the Vector3 where to store the result
  83535. */
  83536. static ClampToRef(value: DeepImmutable<Vector3>, min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, result: Vector3): void;
  83537. /**
  83538. * Checks if a given vector is inside a specific range
  83539. * @param v defines the vector to test
  83540. * @param min defines the minimum range
  83541. * @param max defines the maximum range
  83542. */
  83543. static CheckExtends(v: Vector3, min: Vector3, max: Vector3): void;
  83544. /**
  83545. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  83546. * @param value1 defines the first control point
  83547. * @param tangent1 defines the first tangent vector
  83548. * @param value2 defines the second control point
  83549. * @param tangent2 defines the second tangent vector
  83550. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  83551. * @returns the new Vector3
  83552. */
  83553. static Hermite(value1: DeepImmutable<Vector3>, tangent1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>, tangent2: DeepImmutable<Vector3>, amount: number): Vector3;
  83554. /**
  83555. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  83556. * @param start defines the start value
  83557. * @param end defines the end value
  83558. * @param amount max defines amount between both (between 0 and 1)
  83559. * @returns the new Vector3
  83560. */
  83561. static Lerp(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number): Vector3;
  83562. /**
  83563. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  83564. * @param start defines the start value
  83565. * @param end defines the end value
  83566. * @param amount max defines amount between both (between 0 and 1)
  83567. * @param result defines the Vector3 where to store the result
  83568. */
  83569. static LerpToRef(start: DeepImmutable<Vector3>, end: DeepImmutable<Vector3>, amount: number, result: Vector3): void;
  83570. /**
  83571. * Returns the dot product (float) between the vectors "left" and "right"
  83572. * @param left defines the left operand
  83573. * @param right defines the right operand
  83574. * @returns the dot product
  83575. */
  83576. static Dot(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): number;
  83577. /**
  83578. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  83579. * The cross product is then orthogonal to both "left" and "right"
  83580. * @param left defines the left operand
  83581. * @param right defines the right operand
  83582. * @returns the cross product
  83583. */
  83584. static Cross(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83585. /**
  83586. * Sets the given vector "result" with the cross product of "left" and "right"
  83587. * The cross product is then orthogonal to both "left" and "right"
  83588. * @param left defines the left operand
  83589. * @param right defines the right operand
  83590. * @param result defines the Vector3 where to store the result
  83591. */
  83592. static CrossToRef(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>, result: Vector3): void;
  83593. /**
  83594. * Returns a new Vector3 as the normalization of the given vector
  83595. * @param vector defines the Vector3 to normalize
  83596. * @returns the new Vector3
  83597. */
  83598. static Normalize(vector: DeepImmutable<Vector3>): Vector3;
  83599. /**
  83600. * Sets the given vector "result" with the normalization of the given first vector
  83601. * @param vector defines the Vector3 to normalize
  83602. * @param result defines the Vector3 where to store the result
  83603. */
  83604. static NormalizeToRef(vector: DeepImmutable<Vector3>, result: Vector3): void;
  83605. /**
  83606. * Project a Vector3 onto screen space
  83607. * @param vector defines the Vector3 to project
  83608. * @param world defines the world matrix to use
  83609. * @param transform defines the transform (view x projection) matrix to use
  83610. * @param viewport defines the screen viewport to use
  83611. * @returns the new Vector3
  83612. */
  83613. static Project(vector: DeepImmutable<Vector3>, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>, viewport: DeepImmutable<Viewport>): Vector3;
  83614. /** @hidden */
  83615. static _UnprojectFromInvertedMatrixToRef(source: DeepImmutable<Vector3>, matrix: DeepImmutable<Matrix>, result: Vector3): void;
  83616. /**
  83617. * Unproject from screen space to object space
  83618. * @param source defines the screen space Vector3 to use
  83619. * @param viewportWidth defines the current width of the viewport
  83620. * @param viewportHeight defines the current height of the viewport
  83621. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83622. * @param transform defines the transform (view x projection) matrix to use
  83623. * @returns the new Vector3
  83624. */
  83625. static UnprojectFromTransform(source: Vector3, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, transform: DeepImmutable<Matrix>): Vector3;
  83626. /**
  83627. * Unproject from screen space to object space
  83628. * @param source defines the screen space Vector3 to use
  83629. * @param viewportWidth defines the current width of the viewport
  83630. * @param viewportHeight defines the current height of the viewport
  83631. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83632. * @param view defines the view matrix to use
  83633. * @param projection defines the projection matrix to use
  83634. * @returns the new Vector3
  83635. */
  83636. static Unproject(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Vector3;
  83637. /**
  83638. * Unproject from screen space to object space
  83639. * @param source defines the screen space Vector3 to use
  83640. * @param viewportWidth defines the current width of the viewport
  83641. * @param viewportHeight defines the current height of the viewport
  83642. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83643. * @param view defines the view matrix to use
  83644. * @param projection defines the projection matrix to use
  83645. * @param result defines the Vector3 where to store the result
  83646. */
  83647. static UnprojectToRef(source: DeepImmutable<Vector3>, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83648. /**
  83649. * Unproject from screen space to object space
  83650. * @param sourceX defines the screen space x coordinate to use
  83651. * @param sourceY defines the screen space y coordinate to use
  83652. * @param sourceZ defines the screen space z coordinate to use
  83653. * @param viewportWidth defines the current width of the viewport
  83654. * @param viewportHeight defines the current height of the viewport
  83655. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  83656. * @param view defines the view matrix to use
  83657. * @param projection defines the projection matrix to use
  83658. * @param result defines the Vector3 where to store the result
  83659. */
  83660. static UnprojectFloatsToRef(sourceX: float, sourceY: float, sourceZ: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, result: Vector3): void;
  83661. /**
  83662. * Gets the minimal coordinate values between two Vector3
  83663. * @param left defines the first operand
  83664. * @param right defines the second operand
  83665. * @returns the new Vector3
  83666. */
  83667. static Minimize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83668. /**
  83669. * Gets the maximal coordinate values between two Vector3
  83670. * @param left defines the first operand
  83671. * @param right defines the second operand
  83672. * @returns the new Vector3
  83673. */
  83674. static Maximize(left: DeepImmutable<Vector3>, right: DeepImmutable<Vector3>): Vector3;
  83675. /**
  83676. * Returns the distance between the vectors "value1" and "value2"
  83677. * @param value1 defines the first operand
  83678. * @param value2 defines the second operand
  83679. * @returns the distance
  83680. */
  83681. static Distance(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83682. /**
  83683. * Returns the squared distance between the vectors "value1" and "value2"
  83684. * @param value1 defines the first operand
  83685. * @param value2 defines the second operand
  83686. * @returns the squared distance
  83687. */
  83688. static DistanceSquared(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): number;
  83689. /**
  83690. * Returns a new Vector3 located at the center between "value1" and "value2"
  83691. * @param value1 defines the first operand
  83692. * @param value2 defines the second operand
  83693. * @returns the new Vector3
  83694. */
  83695. static Center(value1: DeepImmutable<Vector3>, value2: DeepImmutable<Vector3>): Vector3;
  83696. /**
  83697. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  83698. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  83699. * to something in order to rotate it from its local system to the given target system
  83700. * Note: axis1, axis2 and axis3 are normalized during this operation
  83701. * @param axis1 defines the first axis
  83702. * @param axis2 defines the second axis
  83703. * @param axis3 defines the third axis
  83704. * @returns a new Vector3
  83705. */
  83706. static RotationFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Vector3;
  83707. /**
  83708. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  83709. * @param axis1 defines the first axis
  83710. * @param axis2 defines the second axis
  83711. * @param axis3 defines the third axis
  83712. * @param ref defines the Vector3 where to store the result
  83713. */
  83714. static RotationFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Vector3): void;
  83715. }
  83716. /**
  83717. * Vector4 class created for EulerAngle class conversion to Quaternion
  83718. */
  83719. export class Vector4 {
  83720. /** x value of the vector */
  83721. x: number;
  83722. /** y value of the vector */
  83723. y: number;
  83724. /** z value of the vector */
  83725. z: number;
  83726. /** w value of the vector */
  83727. w: number;
  83728. /**
  83729. * Creates a Vector4 object from the given floats.
  83730. * @param x x value of the vector
  83731. * @param y y value of the vector
  83732. * @param z z value of the vector
  83733. * @param w w value of the vector
  83734. */
  83735. constructor(
  83736. /** x value of the vector */
  83737. x: number,
  83738. /** y value of the vector */
  83739. y: number,
  83740. /** z value of the vector */
  83741. z: number,
  83742. /** w value of the vector */
  83743. w: number);
  83744. /**
  83745. * Returns the string with the Vector4 coordinates.
  83746. * @returns a string containing all the vector values
  83747. */
  83748. toString(): string;
  83749. /**
  83750. * Returns the string "Vector4".
  83751. * @returns "Vector4"
  83752. */
  83753. getClassName(): string;
  83754. /**
  83755. * Returns the Vector4 hash code.
  83756. * @returns a unique hash code
  83757. */
  83758. getHashCode(): number;
  83759. /**
  83760. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  83761. * @returns the resulting array
  83762. */
  83763. asArray(): number[];
  83764. /**
  83765. * Populates the given array from the given index with the Vector4 coordinates.
  83766. * @param array array to populate
  83767. * @param index index of the array to start at (default: 0)
  83768. * @returns the Vector4.
  83769. */
  83770. toArray(array: FloatArray, index?: number): Vector4;
  83771. /**
  83772. * Update the current vector from an array
  83773. * @param array defines the destination array
  83774. * @param index defines the offset in the destination array
  83775. * @returns the current Vector3
  83776. */
  83777. fromArray(array: FloatArray, index?: number): Vector4;
  83778. /**
  83779. * Adds the given vector to the current Vector4.
  83780. * @param otherVector the vector to add
  83781. * @returns the updated Vector4.
  83782. */
  83783. addInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83784. /**
  83785. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  83786. * @param otherVector the vector to add
  83787. * @returns the resulting vector
  83788. */
  83789. add(otherVector: DeepImmutable<Vector4>): Vector4;
  83790. /**
  83791. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  83792. * @param otherVector the vector to add
  83793. * @param result the vector to store the result
  83794. * @returns the current Vector4.
  83795. */
  83796. addToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83797. /**
  83798. * Subtract in place the given vector from the current Vector4.
  83799. * @param otherVector the vector to subtract
  83800. * @returns the updated Vector4.
  83801. */
  83802. subtractInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83803. /**
  83804. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  83805. * @param otherVector the vector to add
  83806. * @returns the new vector with the result
  83807. */
  83808. subtract(otherVector: DeepImmutable<Vector4>): Vector4;
  83809. /**
  83810. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  83811. * @param otherVector the vector to subtract
  83812. * @param result the vector to store the result
  83813. * @returns the current Vector4.
  83814. */
  83815. subtractToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83816. /**
  83817. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83818. */
  83819. /**
  83820. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83821. * @param x value to subtract
  83822. * @param y value to subtract
  83823. * @param z value to subtract
  83824. * @param w value to subtract
  83825. * @returns new vector containing the result
  83826. */
  83827. subtractFromFloats(x: number, y: number, z: number, w: number): Vector4;
  83828. /**
  83829. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  83830. * @param x value to subtract
  83831. * @param y value to subtract
  83832. * @param z value to subtract
  83833. * @param w value to subtract
  83834. * @param result the vector to store the result in
  83835. * @returns the current Vector4.
  83836. */
  83837. subtractFromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): Vector4;
  83838. /**
  83839. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  83840. * @returns a new vector with the negated values
  83841. */
  83842. negate(): Vector4;
  83843. /**
  83844. * Negate this vector in place
  83845. * @returns this
  83846. */
  83847. negateInPlace(): Vector4;
  83848. /**
  83849. * Negate the current Vector4 and stores the result in the given vector "result" coordinates
  83850. * @param result defines the Vector3 object where to store the result
  83851. * @returns the current Vector4
  83852. */
  83853. negateToRef(result: Vector4): Vector4;
  83854. /**
  83855. * Multiplies the current Vector4 coordinates by scale (float).
  83856. * @param scale the number to scale with
  83857. * @returns the updated Vector4.
  83858. */
  83859. scaleInPlace(scale: number): Vector4;
  83860. /**
  83861. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  83862. * @param scale the number to scale with
  83863. * @returns a new vector with the result
  83864. */
  83865. scale(scale: number): Vector4;
  83866. /**
  83867. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  83868. * @param scale the number to scale with
  83869. * @param result a vector to store the result in
  83870. * @returns the current Vector4.
  83871. */
  83872. scaleToRef(scale: number, result: Vector4): Vector4;
  83873. /**
  83874. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  83875. * @param scale defines the scale factor
  83876. * @param result defines the Vector4 object where to store the result
  83877. * @returns the unmodified current Vector4
  83878. */
  83879. scaleAndAddToRef(scale: number, result: Vector4): Vector4;
  83880. /**
  83881. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  83882. * @param otherVector the vector to compare against
  83883. * @returns true if they are equal
  83884. */
  83885. equals(otherVector: DeepImmutable<Vector4>): boolean;
  83886. /**
  83887. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  83888. * @param otherVector vector to compare against
  83889. * @param epsilon (Default: very small number)
  83890. * @returns true if they are equal
  83891. */
  83892. equalsWithEpsilon(otherVector: DeepImmutable<Vector4>, epsilon?: number): boolean;
  83893. /**
  83894. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  83895. * @param x x value to compare against
  83896. * @param y y value to compare against
  83897. * @param z z value to compare against
  83898. * @param w w value to compare against
  83899. * @returns true if equal
  83900. */
  83901. equalsToFloats(x: number, y: number, z: number, w: number): boolean;
  83902. /**
  83903. * Multiplies in place the current Vector4 by the given one.
  83904. * @param otherVector vector to multiple with
  83905. * @returns the updated Vector4.
  83906. */
  83907. multiplyInPlace(otherVector: Vector4): Vector4;
  83908. /**
  83909. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  83910. * @param otherVector vector to multiple with
  83911. * @returns resulting new vector
  83912. */
  83913. multiply(otherVector: DeepImmutable<Vector4>): Vector4;
  83914. /**
  83915. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  83916. * @param otherVector vector to multiple with
  83917. * @param result vector to store the result
  83918. * @returns the current Vector4.
  83919. */
  83920. multiplyToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83921. /**
  83922. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  83923. * @param x x value multiply with
  83924. * @param y y value multiply with
  83925. * @param z z value multiply with
  83926. * @param w w value multiply with
  83927. * @returns resulting new vector
  83928. */
  83929. multiplyByFloats(x: number, y: number, z: number, w: number): Vector4;
  83930. /**
  83931. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  83932. * @param otherVector vector to devide with
  83933. * @returns resulting new vector
  83934. */
  83935. divide(otherVector: DeepImmutable<Vector4>): Vector4;
  83936. /**
  83937. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  83938. * @param otherVector vector to devide with
  83939. * @param result vector to store the result
  83940. * @returns the current Vector4.
  83941. */
  83942. divideToRef(otherVector: DeepImmutable<Vector4>, result: Vector4): Vector4;
  83943. /**
  83944. * Divides the current Vector3 coordinates by the given ones.
  83945. * @param otherVector vector to devide with
  83946. * @returns the updated Vector3.
  83947. */
  83948. divideInPlace(otherVector: DeepImmutable<Vector4>): Vector4;
  83949. /**
  83950. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  83951. * @param other defines the second operand
  83952. * @returns the current updated Vector4
  83953. */
  83954. minimizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83955. /**
  83956. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  83957. * @param other defines the second operand
  83958. * @returns the current updated Vector4
  83959. */
  83960. maximizeInPlace(other: DeepImmutable<Vector4>): Vector4;
  83961. /**
  83962. * Gets a new Vector4 from current Vector4 floored values
  83963. * @returns a new Vector4
  83964. */
  83965. floor(): Vector4;
  83966. /**
  83967. * Gets a new Vector4 from current Vector3 floored values
  83968. * @returns a new Vector4
  83969. */
  83970. fract(): Vector4;
  83971. /**
  83972. * Returns the Vector4 length (float).
  83973. * @returns the length
  83974. */
  83975. length(): number;
  83976. /**
  83977. * Returns the Vector4 squared length (float).
  83978. * @returns the length squared
  83979. */
  83980. lengthSquared(): number;
  83981. /**
  83982. * Normalizes in place the Vector4.
  83983. * @returns the updated Vector4.
  83984. */
  83985. normalize(): Vector4;
  83986. /**
  83987. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  83988. * @returns this converted to a new vector3
  83989. */
  83990. toVector3(): Vector3;
  83991. /**
  83992. * Returns a new Vector4 copied from the current one.
  83993. * @returns the new cloned vector
  83994. */
  83995. clone(): Vector4;
  83996. /**
  83997. * Updates the current Vector4 with the given one coordinates.
  83998. * @param source the source vector to copy from
  83999. * @returns the updated Vector4.
  84000. */
  84001. copyFrom(source: DeepImmutable<Vector4>): Vector4;
  84002. /**
  84003. * Updates the current Vector4 coordinates with the given floats.
  84004. * @param x float to copy from
  84005. * @param y float to copy from
  84006. * @param z float to copy from
  84007. * @param w float to copy from
  84008. * @returns the updated Vector4.
  84009. */
  84010. copyFromFloats(x: number, y: number, z: number, w: number): Vector4;
  84011. /**
  84012. * Updates the current Vector4 coordinates with the given floats.
  84013. * @param x float to set from
  84014. * @param y float to set from
  84015. * @param z float to set from
  84016. * @param w float to set from
  84017. * @returns the updated Vector4.
  84018. */
  84019. set(x: number, y: number, z: number, w: number): Vector4;
  84020. /**
  84021. * Copies the given float to the current Vector3 coordinates
  84022. * @param v defines the x, y, z and w coordinates of the operand
  84023. * @returns the current updated Vector3
  84024. */
  84025. setAll(v: number): Vector4;
  84026. /**
  84027. * Returns a new Vector4 set from the starting index of the given array.
  84028. * @param array the array to pull values from
  84029. * @param offset the offset into the array to start at
  84030. * @returns the new vector
  84031. */
  84032. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Vector4;
  84033. /**
  84034. * Updates the given vector "result" from the starting index of the given array.
  84035. * @param array the array to pull values from
  84036. * @param offset the offset into the array to start at
  84037. * @param result the vector to store the result in
  84038. */
  84039. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Vector4): void;
  84040. /**
  84041. * Updates the given vector "result" from the starting index of the given Float32Array.
  84042. * @param array the array to pull values from
  84043. * @param offset the offset into the array to start at
  84044. * @param result the vector to store the result in
  84045. */
  84046. static FromFloatArrayToRef(array: DeepImmutable<Float32Array>, offset: number, result: Vector4): void;
  84047. /**
  84048. * Updates the given vector "result" coordinates from the given floats.
  84049. * @param x float to set from
  84050. * @param y float to set from
  84051. * @param z float to set from
  84052. * @param w float to set from
  84053. * @param result the vector to the floats in
  84054. */
  84055. static FromFloatsToRef(x: number, y: number, z: number, w: number, result: Vector4): void;
  84056. /**
  84057. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  84058. * @returns the new vector
  84059. */
  84060. static Zero(): Vector4;
  84061. /**
  84062. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  84063. * @returns the new vector
  84064. */
  84065. static One(): Vector4;
  84066. /**
  84067. * Returns a new normalized Vector4 from the given one.
  84068. * @param vector the vector to normalize
  84069. * @returns the vector
  84070. */
  84071. static Normalize(vector: DeepImmutable<Vector4>): Vector4;
  84072. /**
  84073. * Updates the given vector "result" from the normalization of the given one.
  84074. * @param vector the vector to normalize
  84075. * @param result the vector to store the result in
  84076. */
  84077. static NormalizeToRef(vector: DeepImmutable<Vector4>, result: Vector4): void;
  84078. /**
  84079. * Returns a vector with the minimum values from the left and right vectors
  84080. * @param left left vector to minimize
  84081. * @param right right vector to minimize
  84082. * @returns a new vector with the minimum of the left and right vector values
  84083. */
  84084. static Minimize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84085. /**
  84086. * Returns a vector with the maximum values from the left and right vectors
  84087. * @param left left vector to maximize
  84088. * @param right right vector to maximize
  84089. * @returns a new vector with the maximum of the left and right vector values
  84090. */
  84091. static Maximize(left: DeepImmutable<Vector4>, right: DeepImmutable<Vector4>): Vector4;
  84092. /**
  84093. * Returns the distance (float) between the vectors "value1" and "value2".
  84094. * @param value1 value to calulate the distance between
  84095. * @param value2 value to calulate the distance between
  84096. * @return the distance between the two vectors
  84097. */
  84098. static Distance(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84099. /**
  84100. * Returns the squared distance (float) between the vectors "value1" and "value2".
  84101. * @param value1 value to calulate the distance between
  84102. * @param value2 value to calulate the distance between
  84103. * @return the distance between the two vectors squared
  84104. */
  84105. static DistanceSquared(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): number;
  84106. /**
  84107. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  84108. * @param value1 value to calulate the center between
  84109. * @param value2 value to calulate the center between
  84110. * @return the center between the two vectors
  84111. */
  84112. static Center(value1: DeepImmutable<Vector4>, value2: DeepImmutable<Vector4>): Vector4;
  84113. /**
  84114. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  84115. * This methods computes transformed normalized direction vectors only.
  84116. * @param vector the vector to transform
  84117. * @param transformation the transformation matrix to apply
  84118. * @returns the new vector
  84119. */
  84120. static TransformNormal(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>): Vector4;
  84121. /**
  84122. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  84123. * This methods computes transformed normalized direction vectors only.
  84124. * @param vector the vector to transform
  84125. * @param transformation the transformation matrix to apply
  84126. * @param result the vector to store the result in
  84127. */
  84128. static TransformNormalToRef(vector: DeepImmutable<Vector4>, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84129. /**
  84130. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  84131. * This methods computes transformed normalized direction vectors only.
  84132. * @param x value to transform
  84133. * @param y value to transform
  84134. * @param z value to transform
  84135. * @param w value to transform
  84136. * @param transformation the transformation matrix to apply
  84137. * @param result the vector to store the results in
  84138. */
  84139. static TransformNormalFromFloatsToRef(x: number, y: number, z: number, w: number, transformation: DeepImmutable<Matrix>, result: Vector4): void;
  84140. /**
  84141. * Creates a new Vector4 from a Vector3
  84142. * @param source defines the source data
  84143. * @param w defines the 4th component (default is 0)
  84144. * @returns a new Vector4
  84145. */
  84146. static FromVector3(source: Vector3, w?: number): Vector4;
  84147. }
  84148. /**
  84149. * Class used to store quaternion data
  84150. * @see https://en.wikipedia.org/wiki/Quaternion
  84151. * @see https://doc.babylonjs.com/features/position,_rotation,_scaling
  84152. */
  84153. export class Quaternion {
  84154. /** @hidden */
  84155. _x: number;
  84156. /** @hidden */
  84157. _y: number;
  84158. /** @hidden */
  84159. _z: number;
  84160. /** @hidden */
  84161. _w: number;
  84162. /** @hidden */
  84163. _isDirty: boolean;
  84164. /** Gets or sets the x coordinate */
  84165. get x(): number;
  84166. set x(value: number);
  84167. /** Gets or sets the y coordinate */
  84168. get y(): number;
  84169. set y(value: number);
  84170. /** Gets or sets the z coordinate */
  84171. get z(): number;
  84172. set z(value: number);
  84173. /** Gets or sets the w coordinate */
  84174. get w(): number;
  84175. set w(value: number);
  84176. /**
  84177. * Creates a new Quaternion from the given floats
  84178. * @param x defines the first component (0 by default)
  84179. * @param y defines the second component (0 by default)
  84180. * @param z defines the third component (0 by default)
  84181. * @param w defines the fourth component (1.0 by default)
  84182. */
  84183. constructor(x?: number, y?: number, z?: number, w?: number);
  84184. /**
  84185. * Gets a string representation for the current quaternion
  84186. * @returns a string with the Quaternion coordinates
  84187. */
  84188. toString(): string;
  84189. /**
  84190. * Gets the class name of the quaternion
  84191. * @returns the string "Quaternion"
  84192. */
  84193. getClassName(): string;
  84194. /**
  84195. * Gets a hash code for this quaternion
  84196. * @returns the quaternion hash code
  84197. */
  84198. getHashCode(): number;
  84199. /**
  84200. * Copy the quaternion to an array
  84201. * @returns a new array populated with 4 elements from the quaternion coordinates
  84202. */
  84203. asArray(): number[];
  84204. /**
  84205. * Check if two quaternions are equals
  84206. * @param otherQuaternion defines the second operand
  84207. * @return true if the current quaternion and the given one coordinates are strictly equals
  84208. */
  84209. equals(otherQuaternion: DeepImmutable<Quaternion>): boolean;
  84210. /**
  84211. * Gets a boolean if two quaternions are equals (using an epsilon value)
  84212. * @param otherQuaternion defines the other quaternion
  84213. * @param epsilon defines the minimal distance to consider equality
  84214. * @returns true if the given quaternion coordinates are close to the current ones by a distance of epsilon.
  84215. */
  84216. equalsWithEpsilon(otherQuaternion: DeepImmutable<Quaternion>, epsilon?: number): boolean;
  84217. /**
  84218. * Clone the current quaternion
  84219. * @returns a new quaternion copied from the current one
  84220. */
  84221. clone(): Quaternion;
  84222. /**
  84223. * Copy a quaternion to the current one
  84224. * @param other defines the other quaternion
  84225. * @returns the updated current quaternion
  84226. */
  84227. copyFrom(other: DeepImmutable<Quaternion>): Quaternion;
  84228. /**
  84229. * Updates the current quaternion with the given float coordinates
  84230. * @param x defines the x coordinate
  84231. * @param y defines the y coordinate
  84232. * @param z defines the z coordinate
  84233. * @param w defines the w coordinate
  84234. * @returns the updated current quaternion
  84235. */
  84236. copyFromFloats(x: number, y: number, z: number, w: number): Quaternion;
  84237. /**
  84238. * Updates the current quaternion from the given float coordinates
  84239. * @param x defines the x coordinate
  84240. * @param y defines the y coordinate
  84241. * @param z defines the z coordinate
  84242. * @param w defines the w coordinate
  84243. * @returns the updated current quaternion
  84244. */
  84245. set(x: number, y: number, z: number, w: number): Quaternion;
  84246. /**
  84247. * Adds two quaternions
  84248. * @param other defines the second operand
  84249. * @returns a new quaternion as the addition result of the given one and the current quaternion
  84250. */
  84251. add(other: DeepImmutable<Quaternion>): Quaternion;
  84252. /**
  84253. * Add a quaternion to the current one
  84254. * @param other defines the quaternion to add
  84255. * @returns the current quaternion
  84256. */
  84257. addInPlace(other: DeepImmutable<Quaternion>): Quaternion;
  84258. /**
  84259. * Subtract two quaternions
  84260. * @param other defines the second operand
  84261. * @returns a new quaternion as the subtraction result of the given one from the current one
  84262. */
  84263. subtract(other: Quaternion): Quaternion;
  84264. /**
  84265. * Multiplies the current quaternion by a scale factor
  84266. * @param value defines the scale factor
  84267. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  84268. */
  84269. scale(value: number): Quaternion;
  84270. /**
  84271. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  84272. * @param scale defines the scale factor
  84273. * @param result defines the Quaternion object where to store the result
  84274. * @returns the unmodified current quaternion
  84275. */
  84276. scaleToRef(scale: number, result: Quaternion): Quaternion;
  84277. /**
  84278. * Multiplies in place the current quaternion by a scale factor
  84279. * @param value defines the scale factor
  84280. * @returns the current modified quaternion
  84281. */
  84282. scaleInPlace(value: number): Quaternion;
  84283. /**
  84284. * Scale the current quaternion values by a factor and add the result to a given quaternion
  84285. * @param scale defines the scale factor
  84286. * @param result defines the Quaternion object where to store the result
  84287. * @returns the unmodified current quaternion
  84288. */
  84289. scaleAndAddToRef(scale: number, result: Quaternion): Quaternion;
  84290. /**
  84291. * Multiplies two quaternions
  84292. * @param q1 defines the second operand
  84293. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  84294. */
  84295. multiply(q1: DeepImmutable<Quaternion>): Quaternion;
  84296. /**
  84297. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  84298. * @param q1 defines the second operand
  84299. * @param result defines the target quaternion
  84300. * @returns the current quaternion
  84301. */
  84302. multiplyToRef(q1: DeepImmutable<Quaternion>, result: Quaternion): Quaternion;
  84303. /**
  84304. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  84305. * @param q1 defines the second operand
  84306. * @returns the currentupdated quaternion
  84307. */
  84308. multiplyInPlace(q1: DeepImmutable<Quaternion>): Quaternion;
  84309. /**
  84310. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  84311. * @param ref defines the target quaternion
  84312. * @returns the current quaternion
  84313. */
  84314. conjugateToRef(ref: Quaternion): Quaternion;
  84315. /**
  84316. * Conjugates in place (1-q) the current quaternion
  84317. * @returns the current updated quaternion
  84318. */
  84319. conjugateInPlace(): Quaternion;
  84320. /**
  84321. * Conjugates in place (1-q) the current quaternion
  84322. * @returns a new quaternion
  84323. */
  84324. conjugate(): Quaternion;
  84325. /**
  84326. * Gets length of current quaternion
  84327. * @returns the quaternion length (float)
  84328. */
  84329. length(): number;
  84330. /**
  84331. * Normalize in place the current quaternion
  84332. * @returns the current updated quaternion
  84333. */
  84334. normalize(): Quaternion;
  84335. /**
  84336. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  84337. * @param order is a reserved parameter and is ignored for now
  84338. * @returns a new Vector3 containing the Euler angles
  84339. */
  84340. toEulerAngles(order?: string): Vector3;
  84341. /**
  84342. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  84343. * @param result defines the vector which will be filled with the Euler angles
  84344. * @returns the current unchanged quaternion
  84345. */
  84346. toEulerAnglesToRef(result: Vector3): Quaternion;
  84347. /**
  84348. * Updates the given rotation matrix with the current quaternion values
  84349. * @param result defines the target matrix
  84350. * @returns the current unchanged quaternion
  84351. */
  84352. toRotationMatrix(result: Matrix): Quaternion;
  84353. /**
  84354. * Updates the current quaternion from the given rotation matrix values
  84355. * @param matrix defines the source matrix
  84356. * @returns the current updated quaternion
  84357. */
  84358. fromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84359. /**
  84360. * Creates a new quaternion from a rotation matrix
  84361. * @param matrix defines the source matrix
  84362. * @returns a new quaternion created from the given rotation matrix values
  84363. */
  84364. static FromRotationMatrix(matrix: DeepImmutable<Matrix>): Quaternion;
  84365. /**
  84366. * Updates the given quaternion with the given rotation matrix values
  84367. * @param matrix defines the source matrix
  84368. * @param result defines the target quaternion
  84369. */
  84370. static FromRotationMatrixToRef(matrix: DeepImmutable<Matrix>, result: Quaternion): void;
  84371. /**
  84372. * Returns the dot product (float) between the quaternions "left" and "right"
  84373. * @param left defines the left operand
  84374. * @param right defines the right operand
  84375. * @returns the dot product
  84376. */
  84377. static Dot(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>): number;
  84378. /**
  84379. * Checks if the two quaternions are close to each other
  84380. * @param quat0 defines the first quaternion to check
  84381. * @param quat1 defines the second quaternion to check
  84382. * @returns true if the two quaternions are close to each other
  84383. */
  84384. static AreClose(quat0: DeepImmutable<Quaternion>, quat1: DeepImmutable<Quaternion>): boolean;
  84385. /**
  84386. * Creates an empty quaternion
  84387. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  84388. */
  84389. static Zero(): Quaternion;
  84390. /**
  84391. * Inverse a given quaternion
  84392. * @param q defines the source quaternion
  84393. * @returns a new quaternion as the inverted current quaternion
  84394. */
  84395. static Inverse(q: DeepImmutable<Quaternion>): Quaternion;
  84396. /**
  84397. * Inverse a given quaternion
  84398. * @param q defines the source quaternion
  84399. * @param result the quaternion the result will be stored in
  84400. * @returns the result quaternion
  84401. */
  84402. static InverseToRef(q: Quaternion, result: Quaternion): Quaternion;
  84403. /**
  84404. * Creates an identity quaternion
  84405. * @returns the identity quaternion
  84406. */
  84407. static Identity(): Quaternion;
  84408. /**
  84409. * Gets a boolean indicating if the given quaternion is identity
  84410. * @param quaternion defines the quaternion to check
  84411. * @returns true if the quaternion is identity
  84412. */
  84413. static IsIdentity(quaternion: DeepImmutable<Quaternion>): boolean;
  84414. /**
  84415. * Creates a quaternion from a rotation around an axis
  84416. * @param axis defines the axis to use
  84417. * @param angle defines the angle to use
  84418. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  84419. */
  84420. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Quaternion;
  84421. /**
  84422. * Creates a rotation around an axis and stores it into the given quaternion
  84423. * @param axis defines the axis to use
  84424. * @param angle defines the angle to use
  84425. * @param result defines the target quaternion
  84426. * @returns the target quaternion
  84427. */
  84428. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Quaternion): Quaternion;
  84429. /**
  84430. * Creates a new quaternion from data stored into an array
  84431. * @param array defines the data source
  84432. * @param offset defines the offset in the source array where the data starts
  84433. * @returns a new quaternion
  84434. */
  84435. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Quaternion;
  84436. /**
  84437. * Updates the given quaternion "result" from the starting index of the given array.
  84438. * @param array the array to pull values from
  84439. * @param offset the offset into the array to start at
  84440. * @param result the quaternion to store the result in
  84441. */
  84442. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Quaternion): void;
  84443. /**
  84444. * Create a quaternion from Euler rotation angles
  84445. * @param x Pitch
  84446. * @param y Yaw
  84447. * @param z Roll
  84448. * @returns the new Quaternion
  84449. */
  84450. static FromEulerAngles(x: number, y: number, z: number): Quaternion;
  84451. /**
  84452. * Updates a quaternion from Euler rotation angles
  84453. * @param x Pitch
  84454. * @param y Yaw
  84455. * @param z Roll
  84456. * @param result the quaternion to store the result
  84457. * @returns the updated quaternion
  84458. */
  84459. static FromEulerAnglesToRef(x: number, y: number, z: number, result: Quaternion): Quaternion;
  84460. /**
  84461. * Create a quaternion from Euler rotation vector
  84462. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84463. * @returns the new Quaternion
  84464. */
  84465. static FromEulerVector(vec: DeepImmutable<Vector3>): Quaternion;
  84466. /**
  84467. * Updates a quaternion from Euler rotation vector
  84468. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  84469. * @param result the quaternion to store the result
  84470. * @returns the updated quaternion
  84471. */
  84472. static FromEulerVectorToRef(vec: DeepImmutable<Vector3>, result: Quaternion): Quaternion;
  84473. /**
  84474. * Creates a new quaternion from the given Euler float angles (y, x, z)
  84475. * @param yaw defines the rotation around Y axis
  84476. * @param pitch defines the rotation around X axis
  84477. * @param roll defines the rotation around Z axis
  84478. * @returns the new quaternion
  84479. */
  84480. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Quaternion;
  84481. /**
  84482. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  84483. * @param yaw defines the rotation around Y axis
  84484. * @param pitch defines the rotation around X axis
  84485. * @param roll defines the rotation around Z axis
  84486. * @param result defines the target quaternion
  84487. */
  84488. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Quaternion): void;
  84489. /**
  84490. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  84491. * @param alpha defines the rotation around first axis
  84492. * @param beta defines the rotation around second axis
  84493. * @param gamma defines the rotation around third axis
  84494. * @returns the new quaternion
  84495. */
  84496. static RotationAlphaBetaGamma(alpha: number, beta: number, gamma: number): Quaternion;
  84497. /**
  84498. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  84499. * @param alpha defines the rotation around first axis
  84500. * @param beta defines the rotation around second axis
  84501. * @param gamma defines the rotation around third axis
  84502. * @param result defines the target quaternion
  84503. */
  84504. static RotationAlphaBetaGammaToRef(alpha: number, beta: number, gamma: number, result: Quaternion): void;
  84505. /**
  84506. * 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)
  84507. * @param axis1 defines the first axis
  84508. * @param axis2 defines the second axis
  84509. * @param axis3 defines the third axis
  84510. * @returns the new quaternion
  84511. */
  84512. static RotationQuaternionFromAxis(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>): Quaternion;
  84513. /**
  84514. * 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
  84515. * @param axis1 defines the first axis
  84516. * @param axis2 defines the second axis
  84517. * @param axis3 defines the third axis
  84518. * @param ref defines the target quaternion
  84519. */
  84520. static RotationQuaternionFromAxisToRef(axis1: DeepImmutable<Vector3>, axis2: DeepImmutable<Vector3>, axis3: DeepImmutable<Vector3>, ref: Quaternion): void;
  84521. /**
  84522. * Interpolates between two quaternions
  84523. * @param left defines first quaternion
  84524. * @param right defines second quaternion
  84525. * @param amount defines the gradient to use
  84526. * @returns the new interpolated quaternion
  84527. */
  84528. static Slerp(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84529. /**
  84530. * Interpolates between two quaternions and stores it into a target quaternion
  84531. * @param left defines first quaternion
  84532. * @param right defines second quaternion
  84533. * @param amount defines the gradient to use
  84534. * @param result defines the target quaternion
  84535. */
  84536. static SlerpToRef(left: DeepImmutable<Quaternion>, right: DeepImmutable<Quaternion>, amount: number, result: Quaternion): void;
  84537. /**
  84538. * Interpolate between two quaternions using Hermite interpolation
  84539. * @param value1 defines first quaternion
  84540. * @param tangent1 defines the incoming tangent
  84541. * @param value2 defines second quaternion
  84542. * @param tangent2 defines the outgoing tangent
  84543. * @param amount defines the target quaternion
  84544. * @returns the new interpolated quaternion
  84545. */
  84546. static Hermite(value1: DeepImmutable<Quaternion>, tangent1: DeepImmutable<Quaternion>, value2: DeepImmutable<Quaternion>, tangent2: DeepImmutable<Quaternion>, amount: number): Quaternion;
  84547. }
  84548. /**
  84549. * Class used to store matrix data (4x4)
  84550. */
  84551. export class Matrix {
  84552. /**
  84553. * Gets the precision of matrix computations
  84554. */
  84555. static get Use64Bits(): boolean;
  84556. private static _updateFlagSeed;
  84557. private static _identityReadOnly;
  84558. private _isIdentity;
  84559. private _isIdentityDirty;
  84560. private _isIdentity3x2;
  84561. private _isIdentity3x2Dirty;
  84562. /**
  84563. * Gets the update flag of the matrix which is an unique number for the matrix.
  84564. * It will be incremented every time the matrix data change.
  84565. * You can use it to speed the comparison between two versions of the same matrix.
  84566. */
  84567. updateFlag: number;
  84568. private readonly _m;
  84569. /**
  84570. * Gets the internal data of the matrix
  84571. */
  84572. get m(): DeepImmutable<Float32Array | Array<number>>;
  84573. /** @hidden */
  84574. _markAsUpdated(): void;
  84575. /** @hidden */
  84576. private _updateIdentityStatus;
  84577. /**
  84578. * Creates an empty matrix (filled with zeros)
  84579. */
  84580. constructor();
  84581. /**
  84582. * Check if the current matrix is identity
  84583. * @returns true is the matrix is the identity matrix
  84584. */
  84585. isIdentity(): boolean;
  84586. /**
  84587. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  84588. * @returns true is the matrix is the identity matrix
  84589. */
  84590. isIdentityAs3x2(): boolean;
  84591. /**
  84592. * Gets the determinant of the matrix
  84593. * @returns the matrix determinant
  84594. */
  84595. determinant(): number;
  84596. /**
  84597. * Returns the matrix as a Float32Array or Array<number>
  84598. * @returns the matrix underlying array
  84599. */
  84600. toArray(): DeepImmutable<Float32Array | Array<number>>;
  84601. /**
  84602. * Returns the matrix as a Float32Array or Array<number>
  84603. * @returns the matrix underlying array.
  84604. */
  84605. asArray(): DeepImmutable<Float32Array | Array<number>>;
  84606. /**
  84607. * Inverts the current matrix in place
  84608. * @returns the current inverted matrix
  84609. */
  84610. invert(): Matrix;
  84611. /**
  84612. * Sets all the matrix elements to zero
  84613. * @returns the current matrix
  84614. */
  84615. reset(): Matrix;
  84616. /**
  84617. * Adds the current matrix with a second one
  84618. * @param other defines the matrix to add
  84619. * @returns a new matrix as the addition of the current matrix and the given one
  84620. */
  84621. add(other: DeepImmutable<Matrix>): Matrix;
  84622. /**
  84623. * Sets the given matrix "result" to the addition of the current matrix and the given one
  84624. * @param other defines the matrix to add
  84625. * @param result defines the target matrix
  84626. * @returns the current matrix
  84627. */
  84628. addToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84629. /**
  84630. * Adds in place the given matrix to the current matrix
  84631. * @param other defines the second operand
  84632. * @returns the current updated matrix
  84633. */
  84634. addToSelf(other: DeepImmutable<Matrix>): Matrix;
  84635. /**
  84636. * Sets the given matrix to the current inverted Matrix
  84637. * @param other defines the target matrix
  84638. * @returns the unmodified current matrix
  84639. */
  84640. invertToRef(other: Matrix): Matrix;
  84641. /**
  84642. * add a value at the specified position in the current Matrix
  84643. * @param index the index of the value within the matrix. between 0 and 15.
  84644. * @param value the value to be added
  84645. * @returns the current updated matrix
  84646. */
  84647. addAtIndex(index: number, value: number): Matrix;
  84648. /**
  84649. * mutiply the specified position in the current Matrix by a value
  84650. * @param index the index of the value within the matrix. between 0 and 15.
  84651. * @param value the value to be added
  84652. * @returns the current updated matrix
  84653. */
  84654. multiplyAtIndex(index: number, value: number): Matrix;
  84655. /**
  84656. * Inserts the translation vector (using 3 floats) in the current matrix
  84657. * @param x defines the 1st component of the translation
  84658. * @param y defines the 2nd component of the translation
  84659. * @param z defines the 3rd component of the translation
  84660. * @returns the current updated matrix
  84661. */
  84662. setTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84663. /**
  84664. * Adds the translation vector (using 3 floats) in the current matrix
  84665. * @param x defines the 1st component of the translation
  84666. * @param y defines the 2nd component of the translation
  84667. * @param z defines the 3rd component of the translation
  84668. * @returns the current updated matrix
  84669. */
  84670. addTranslationFromFloats(x: number, y: number, z: number): Matrix;
  84671. /**
  84672. * Inserts the translation vector in the current matrix
  84673. * @param vector3 defines the translation to insert
  84674. * @returns the current updated matrix
  84675. */
  84676. setTranslation(vector3: DeepImmutable<Vector3>): Matrix;
  84677. /**
  84678. * Gets the translation value of the current matrix
  84679. * @returns a new Vector3 as the extracted translation from the matrix
  84680. */
  84681. getTranslation(): Vector3;
  84682. /**
  84683. * Fill a Vector3 with the extracted translation from the matrix
  84684. * @param result defines the Vector3 where to store the translation
  84685. * @returns the current matrix
  84686. */
  84687. getTranslationToRef(result: Vector3): Matrix;
  84688. /**
  84689. * Remove rotation and scaling part from the matrix
  84690. * @returns the updated matrix
  84691. */
  84692. removeRotationAndScaling(): Matrix;
  84693. /**
  84694. * Multiply two matrices
  84695. * @param other defines the second operand
  84696. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  84697. */
  84698. multiply(other: DeepImmutable<Matrix>): Matrix;
  84699. /**
  84700. * Copy the current matrix from the given one
  84701. * @param other defines the source matrix
  84702. * @returns the current updated matrix
  84703. */
  84704. copyFrom(other: DeepImmutable<Matrix>): Matrix;
  84705. /**
  84706. * Populates the given array from the starting index with the current matrix values
  84707. * @param array defines the target array
  84708. * @param offset defines the offset in the target array where to start storing values
  84709. * @returns the current matrix
  84710. */
  84711. copyToArray(array: Float32Array | Array<number>, offset?: number): Matrix;
  84712. /**
  84713. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  84714. * @param other defines the second operand
  84715. * @param result defines the matrix where to store the multiplication
  84716. * @returns the current matrix
  84717. */
  84718. multiplyToRef(other: DeepImmutable<Matrix>, result: Matrix): Matrix;
  84719. /**
  84720. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  84721. * @param other defines the second operand
  84722. * @param result defines the array where to store the multiplication
  84723. * @param offset defines the offset in the target array where to start storing values
  84724. * @returns the current matrix
  84725. */
  84726. multiplyToArray(other: DeepImmutable<Matrix>, result: Float32Array | Array<number>, offset: number): Matrix;
  84727. /**
  84728. * Check equality between this matrix and a second one
  84729. * @param value defines the second matrix to compare
  84730. * @returns true is the current matrix and the given one values are strictly equal
  84731. */
  84732. equals(value: DeepImmutable<Matrix>): boolean;
  84733. /**
  84734. * Clone the current matrix
  84735. * @returns a new matrix from the current matrix
  84736. */
  84737. clone(): Matrix;
  84738. /**
  84739. * Returns the name of the current matrix class
  84740. * @returns the string "Matrix"
  84741. */
  84742. getClassName(): string;
  84743. /**
  84744. * Gets the hash code of the current matrix
  84745. * @returns the hash code
  84746. */
  84747. getHashCode(): number;
  84748. /**
  84749. * Decomposes the current Matrix into a translation, rotation and scaling components
  84750. * @param scale defines the scale vector3 given as a reference to update
  84751. * @param rotation defines the rotation quaternion given as a reference to update
  84752. * @param translation defines the translation vector3 given as a reference to update
  84753. * @returns true if operation was successful
  84754. */
  84755. decompose(scale?: Vector3, rotation?: Quaternion, translation?: Vector3): boolean;
  84756. /**
  84757. * Gets specific row of the matrix
  84758. * @param index defines the number of the row to get
  84759. * @returns the index-th row of the current matrix as a new Vector4
  84760. */
  84761. getRow(index: number): Nullable<Vector4>;
  84762. /**
  84763. * Sets the index-th row of the current matrix to the vector4 values
  84764. * @param index defines the number of the row to set
  84765. * @param row defines the target vector4
  84766. * @returns the updated current matrix
  84767. */
  84768. setRow(index: number, row: Vector4): Matrix;
  84769. /**
  84770. * Compute the transpose of the matrix
  84771. * @returns the new transposed matrix
  84772. */
  84773. transpose(): Matrix;
  84774. /**
  84775. * Compute the transpose of the matrix and store it in a given matrix
  84776. * @param result defines the target matrix
  84777. * @returns the current matrix
  84778. */
  84779. transposeToRef(result: Matrix): Matrix;
  84780. /**
  84781. * Sets the index-th row of the current matrix with the given 4 x float values
  84782. * @param index defines the row index
  84783. * @param x defines the x component to set
  84784. * @param y defines the y component to set
  84785. * @param z defines the z component to set
  84786. * @param w defines the w component to set
  84787. * @returns the updated current matrix
  84788. */
  84789. setRowFromFloats(index: number, x: number, y: number, z: number, w: number): Matrix;
  84790. /**
  84791. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  84792. * @param scale defines the scale factor
  84793. * @returns a new matrix
  84794. */
  84795. scale(scale: number): Matrix;
  84796. /**
  84797. * Scale the current matrix values by a factor to a given result matrix
  84798. * @param scale defines the scale factor
  84799. * @param result defines the matrix to store the result
  84800. * @returns the current matrix
  84801. */
  84802. scaleToRef(scale: number, result: Matrix): Matrix;
  84803. /**
  84804. * Scale the current matrix values by a factor and add the result to a given matrix
  84805. * @param scale defines the scale factor
  84806. * @param result defines the Matrix to store the result
  84807. * @returns the current matrix
  84808. */
  84809. scaleAndAddToRef(scale: number, result: Matrix): Matrix;
  84810. /**
  84811. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  84812. * @param ref matrix to store the result
  84813. */
  84814. toNormalMatrix(ref: Matrix): void;
  84815. /**
  84816. * Gets only rotation part of the current matrix
  84817. * @returns a new matrix sets to the extracted rotation matrix from the current one
  84818. */
  84819. getRotationMatrix(): Matrix;
  84820. /**
  84821. * Extracts the rotation matrix from the current one and sets it as the given "result"
  84822. * @param result defines the target matrix to store data to
  84823. * @returns the current matrix
  84824. */
  84825. getRotationMatrixToRef(result: Matrix): Matrix;
  84826. /**
  84827. * Toggles model matrix from being right handed to left handed in place and vice versa
  84828. */
  84829. toggleModelMatrixHandInPlace(): void;
  84830. /**
  84831. * Toggles projection matrix from being right handed to left handed in place and vice versa
  84832. */
  84833. toggleProjectionMatrixHandInPlace(): void;
  84834. /**
  84835. * Creates a matrix from an array
  84836. * @param array defines the source array
  84837. * @param offset defines an offset in the source array
  84838. * @returns a new Matrix set from the starting index of the given array
  84839. */
  84840. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Matrix;
  84841. /**
  84842. * Copy the content of an array into a given matrix
  84843. * @param array defines the source array
  84844. * @param offset defines an offset in the source array
  84845. * @param result defines the target matrix
  84846. */
  84847. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number, result: Matrix): void;
  84848. /**
  84849. * Stores an array into a matrix after having multiplied each component by a given factor
  84850. * @param array defines the source array
  84851. * @param offset defines the offset in the source array
  84852. * @param scale defines the scaling factor
  84853. * @param result defines the target matrix
  84854. */
  84855. static FromFloat32ArrayToRefScaled(array: DeepImmutable<Float32Array | Array<number>>, offset: number, scale: number, result: Matrix): void;
  84856. /**
  84857. * Gets an identity matrix that must not be updated
  84858. */
  84859. static get IdentityReadOnly(): DeepImmutable<Matrix>;
  84860. /**
  84861. * Stores a list of values (16) inside a given matrix
  84862. * @param initialM11 defines 1st value of 1st row
  84863. * @param initialM12 defines 2nd value of 1st row
  84864. * @param initialM13 defines 3rd value of 1st row
  84865. * @param initialM14 defines 4th value of 1st row
  84866. * @param initialM21 defines 1st value of 2nd row
  84867. * @param initialM22 defines 2nd value of 2nd row
  84868. * @param initialM23 defines 3rd value of 2nd row
  84869. * @param initialM24 defines 4th value of 2nd row
  84870. * @param initialM31 defines 1st value of 3rd row
  84871. * @param initialM32 defines 2nd value of 3rd row
  84872. * @param initialM33 defines 3rd value of 3rd row
  84873. * @param initialM34 defines 4th value of 3rd row
  84874. * @param initialM41 defines 1st value of 4th row
  84875. * @param initialM42 defines 2nd value of 4th row
  84876. * @param initialM43 defines 3rd value of 4th row
  84877. * @param initialM44 defines 4th value of 4th row
  84878. * @param result defines the target matrix
  84879. */
  84880. 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;
  84881. /**
  84882. * Creates new matrix from a list of values (16)
  84883. * @param initialM11 defines 1st value of 1st row
  84884. * @param initialM12 defines 2nd value of 1st row
  84885. * @param initialM13 defines 3rd value of 1st row
  84886. * @param initialM14 defines 4th value of 1st row
  84887. * @param initialM21 defines 1st value of 2nd row
  84888. * @param initialM22 defines 2nd value of 2nd row
  84889. * @param initialM23 defines 3rd value of 2nd row
  84890. * @param initialM24 defines 4th value of 2nd row
  84891. * @param initialM31 defines 1st value of 3rd row
  84892. * @param initialM32 defines 2nd value of 3rd row
  84893. * @param initialM33 defines 3rd value of 3rd row
  84894. * @param initialM34 defines 4th value of 3rd row
  84895. * @param initialM41 defines 1st value of 4th row
  84896. * @param initialM42 defines 2nd value of 4th row
  84897. * @param initialM43 defines 3rd value of 4th row
  84898. * @param initialM44 defines 4th value of 4th row
  84899. * @returns the new matrix
  84900. */
  84901. 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;
  84902. /**
  84903. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84904. * @param scale defines the scale vector3
  84905. * @param rotation defines the rotation quaternion
  84906. * @param translation defines the translation vector3
  84907. * @returns a new matrix
  84908. */
  84909. static Compose(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>): Matrix;
  84910. /**
  84911. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  84912. * @param scale defines the scale vector3
  84913. * @param rotation defines the rotation quaternion
  84914. * @param translation defines the translation vector3
  84915. * @param result defines the target matrix
  84916. */
  84917. static ComposeToRef(scale: DeepImmutable<Vector3>, rotation: DeepImmutable<Quaternion>, translation: DeepImmutable<Vector3>, result: Matrix): void;
  84918. /**
  84919. * Creates a new identity matrix
  84920. * @returns a new identity matrix
  84921. */
  84922. static Identity(): Matrix;
  84923. /**
  84924. * Creates a new identity matrix and stores the result in a given matrix
  84925. * @param result defines the target matrix
  84926. */
  84927. static IdentityToRef(result: Matrix): void;
  84928. /**
  84929. * Creates a new zero matrix
  84930. * @returns a new zero matrix
  84931. */
  84932. static Zero(): Matrix;
  84933. /**
  84934. * Creates a new rotation matrix for "angle" radians around the X axis
  84935. * @param angle defines the angle (in radians) to use
  84936. * @return the new matrix
  84937. */
  84938. static RotationX(angle: number): Matrix;
  84939. /**
  84940. * Creates a new matrix as the invert of a given matrix
  84941. * @param source defines the source matrix
  84942. * @returns the new matrix
  84943. */
  84944. static Invert(source: DeepImmutable<Matrix>): Matrix;
  84945. /**
  84946. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  84947. * @param angle defines the angle (in radians) to use
  84948. * @param result defines the target matrix
  84949. */
  84950. static RotationXToRef(angle: number, result: Matrix): void;
  84951. /**
  84952. * Creates a new rotation matrix for "angle" radians around the Y axis
  84953. * @param angle defines the angle (in radians) to use
  84954. * @return the new matrix
  84955. */
  84956. static RotationY(angle: number): Matrix;
  84957. /**
  84958. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  84959. * @param angle defines the angle (in radians) to use
  84960. * @param result defines the target matrix
  84961. */
  84962. static RotationYToRef(angle: number, result: Matrix): void;
  84963. /**
  84964. * Creates a new rotation matrix for "angle" radians around the Z axis
  84965. * @param angle defines the angle (in radians) to use
  84966. * @return the new matrix
  84967. */
  84968. static RotationZ(angle: number): Matrix;
  84969. /**
  84970. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  84971. * @param angle defines the angle (in radians) to use
  84972. * @param result defines the target matrix
  84973. */
  84974. static RotationZToRef(angle: number, result: Matrix): void;
  84975. /**
  84976. * Creates a new rotation matrix for "angle" radians around the given axis
  84977. * @param axis defines the axis to use
  84978. * @param angle defines the angle (in radians) to use
  84979. * @return the new matrix
  84980. */
  84981. static RotationAxis(axis: DeepImmutable<Vector3>, angle: number): Matrix;
  84982. /**
  84983. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  84984. * @param axis defines the axis to use
  84985. * @param angle defines the angle (in radians) to use
  84986. * @param result defines the target matrix
  84987. */
  84988. static RotationAxisToRef(axis: DeepImmutable<Vector3>, angle: number, result: Matrix): void;
  84989. /**
  84990. * Takes normalised vectors and returns a rotation matrix to align "from" with "to".
  84991. * Taken from http://www.iquilezles.org/www/articles/noacos/noacos.htm
  84992. * @param from defines the vector to align
  84993. * @param to defines the vector to align to
  84994. * @param result defines the target matrix
  84995. */
  84996. static RotationAlignToRef(from: DeepImmutable<Vector3>, to: DeepImmutable<Vector3>, result: Matrix): void;
  84997. /**
  84998. * Creates a rotation matrix
  84999. * @param yaw defines the yaw angle in radians (Y axis)
  85000. * @param pitch defines the pitch angle in radians (X axis)
  85001. * @param roll defines the roll angle in radians (Z axis)
  85002. * @returns the new rotation matrix
  85003. */
  85004. static RotationYawPitchRoll(yaw: number, pitch: number, roll: number): Matrix;
  85005. /**
  85006. * Creates a rotation matrix and stores it in a given matrix
  85007. * @param yaw defines the yaw angle in radians (Y axis)
  85008. * @param pitch defines the pitch angle in radians (X axis)
  85009. * @param roll defines the roll angle in radians (Z axis)
  85010. * @param result defines the target matrix
  85011. */
  85012. static RotationYawPitchRollToRef(yaw: number, pitch: number, roll: number, result: Matrix): void;
  85013. /**
  85014. * Creates a scaling matrix
  85015. * @param x defines the scale factor on X axis
  85016. * @param y defines the scale factor on Y axis
  85017. * @param z defines the scale factor on Z axis
  85018. * @returns the new matrix
  85019. */
  85020. static Scaling(x: number, y: number, z: number): Matrix;
  85021. /**
  85022. * Creates a scaling matrix and stores it in a given matrix
  85023. * @param x defines the scale factor on X axis
  85024. * @param y defines the scale factor on Y axis
  85025. * @param z defines the scale factor on Z axis
  85026. * @param result defines the target matrix
  85027. */
  85028. static ScalingToRef(x: number, y: number, z: number, result: Matrix): void;
  85029. /**
  85030. * Creates a translation matrix
  85031. * @param x defines the translation on X axis
  85032. * @param y defines the translation on Y axis
  85033. * @param z defines the translationon Z axis
  85034. * @returns the new matrix
  85035. */
  85036. static Translation(x: number, y: number, z: number): Matrix;
  85037. /**
  85038. * Creates a translation matrix and stores it in a given matrix
  85039. * @param x defines the translation on X axis
  85040. * @param y defines the translation on Y axis
  85041. * @param z defines the translationon Z axis
  85042. * @param result defines the target matrix
  85043. */
  85044. static TranslationToRef(x: number, y: number, z: number, result: Matrix): void;
  85045. /**
  85046. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85047. * @param startValue defines the start value
  85048. * @param endValue defines the end value
  85049. * @param gradient defines the gradient factor
  85050. * @returns the new matrix
  85051. */
  85052. static Lerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85053. /**
  85054. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  85055. * @param startValue defines the start value
  85056. * @param endValue defines the end value
  85057. * @param gradient defines the gradient factor
  85058. * @param result defines the Matrix object where to store data
  85059. */
  85060. static LerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85061. /**
  85062. * Builds a new matrix whose values are computed by:
  85063. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85064. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85065. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85066. * @param startValue defines the first matrix
  85067. * @param endValue defines the second matrix
  85068. * @param gradient defines the gradient between the two matrices
  85069. * @returns the new matrix
  85070. */
  85071. static DecomposeLerp(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number): Matrix;
  85072. /**
  85073. * Update a matrix to values which are computed by:
  85074. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  85075. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  85076. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  85077. * @param startValue defines the first matrix
  85078. * @param endValue defines the second matrix
  85079. * @param gradient defines the gradient between the two matrices
  85080. * @param result defines the target matrix
  85081. */
  85082. static DecomposeLerpToRef(startValue: DeepImmutable<Matrix>, endValue: DeepImmutable<Matrix>, gradient: number, result: Matrix): void;
  85083. /**
  85084. * 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"
  85085. * This function works in left handed mode
  85086. * @param eye defines the final position of the entity
  85087. * @param target defines where the entity should look at
  85088. * @param up defines the up vector for the entity
  85089. * @returns the new matrix
  85090. */
  85091. static LookAtLH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85092. /**
  85093. * 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".
  85094. * This function works in left handed mode
  85095. * @param eye defines the final position of the entity
  85096. * @param target defines where the entity should look at
  85097. * @param up defines the up vector for the entity
  85098. * @param result defines the target matrix
  85099. */
  85100. static LookAtLHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85101. /**
  85102. * 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"
  85103. * This function works in right handed mode
  85104. * @param eye defines the final position of the entity
  85105. * @param target defines where the entity should look at
  85106. * @param up defines the up vector for the entity
  85107. * @returns the new matrix
  85108. */
  85109. static LookAtRH(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>): Matrix;
  85110. /**
  85111. * 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".
  85112. * This function works in right handed mode
  85113. * @param eye defines the final position of the entity
  85114. * @param target defines where the entity should look at
  85115. * @param up defines the up vector for the entity
  85116. * @param result defines the target matrix
  85117. */
  85118. static LookAtRHToRef(eye: DeepImmutable<Vector3>, target: DeepImmutable<Vector3>, up: DeepImmutable<Vector3>, result: Matrix): void;
  85119. /**
  85120. * Create a left-handed orthographic projection matrix
  85121. * @param width defines the viewport width
  85122. * @param height defines the viewport height
  85123. * @param znear defines the near clip plane
  85124. * @param zfar defines the far clip plane
  85125. * @returns a new matrix as a left-handed orthographic projection matrix
  85126. */
  85127. static OrthoLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85128. /**
  85129. * Store a left-handed orthographic projection to a given matrix
  85130. * @param width defines the viewport width
  85131. * @param height defines the viewport height
  85132. * @param znear defines the near clip plane
  85133. * @param zfar defines the far clip plane
  85134. * @param result defines the target matrix
  85135. */
  85136. static OrthoLHToRef(width: number, height: number, znear: number, zfar: number, result: Matrix): void;
  85137. /**
  85138. * Create a left-handed orthographic projection matrix
  85139. * @param left defines the viewport left coordinate
  85140. * @param right defines the viewport right coordinate
  85141. * @param bottom defines the viewport bottom coordinate
  85142. * @param top defines the viewport top coordinate
  85143. * @param znear defines the near clip plane
  85144. * @param zfar defines the far clip plane
  85145. * @returns a new matrix as a left-handed orthographic projection matrix
  85146. */
  85147. static OrthoOffCenterLH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85148. /**
  85149. * Stores a left-handed orthographic projection into a given matrix
  85150. * @param left defines the viewport left coordinate
  85151. * @param right defines the viewport right coordinate
  85152. * @param bottom defines the viewport bottom coordinate
  85153. * @param top defines the viewport top coordinate
  85154. * @param znear defines the near clip plane
  85155. * @param zfar defines the far clip plane
  85156. * @param result defines the target matrix
  85157. */
  85158. static OrthoOffCenterLHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85159. /**
  85160. * Creates a right-handed orthographic projection matrix
  85161. * @param left defines the viewport left coordinate
  85162. * @param right defines the viewport right coordinate
  85163. * @param bottom defines the viewport bottom coordinate
  85164. * @param top defines the viewport top coordinate
  85165. * @param znear defines the near clip plane
  85166. * @param zfar defines the far clip plane
  85167. * @returns a new matrix as a right-handed orthographic projection matrix
  85168. */
  85169. static OrthoOffCenterRH(left: number, right: number, bottom: number, top: number, znear: number, zfar: number): Matrix;
  85170. /**
  85171. * Stores a right-handed orthographic projection into a given matrix
  85172. * @param left defines the viewport left coordinate
  85173. * @param right defines the viewport right coordinate
  85174. * @param bottom defines the viewport bottom coordinate
  85175. * @param top defines the viewport top coordinate
  85176. * @param znear defines the near clip plane
  85177. * @param zfar defines the far clip plane
  85178. * @param result defines the target matrix
  85179. */
  85180. static OrthoOffCenterRHToRef(left: number, right: number, bottom: number, top: number, znear: number, zfar: number, result: Matrix): void;
  85181. /**
  85182. * Creates a left-handed perspective projection matrix
  85183. * @param width defines the viewport width
  85184. * @param height defines the viewport height
  85185. * @param znear defines the near clip plane
  85186. * @param zfar defines the far clip plane
  85187. * @returns a new matrix as a left-handed perspective projection matrix
  85188. */
  85189. static PerspectiveLH(width: number, height: number, znear: number, zfar: number): Matrix;
  85190. /**
  85191. * Creates a left-handed perspective projection matrix
  85192. * @param fov defines the horizontal field of view
  85193. * @param aspect defines the aspect ratio
  85194. * @param znear defines the near clip plane
  85195. * @param zfar defines the far clip plane
  85196. * @returns a new matrix as a left-handed perspective projection matrix
  85197. */
  85198. static PerspectiveFovLH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85199. /**
  85200. * Stores a left-handed perspective projection into a given matrix
  85201. * @param fov defines the horizontal field of view
  85202. * @param aspect defines the aspect ratio
  85203. * @param znear defines the near clip plane
  85204. * @param zfar defines the far clip plane
  85205. * @param result defines the target matrix
  85206. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85207. */
  85208. static PerspectiveFovLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85209. /**
  85210. * Stores a left-handed perspective projection into a given matrix with depth reversed
  85211. * @param fov defines the horizontal field of view
  85212. * @param aspect defines the aspect ratio
  85213. * @param znear defines the near clip plane
  85214. * @param zfar not used as infinity is used as far clip
  85215. * @param result defines the target matrix
  85216. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85217. */
  85218. static PerspectiveFovReverseLHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85219. /**
  85220. * Creates a right-handed perspective projection matrix
  85221. * @param fov defines the horizontal field of view
  85222. * @param aspect defines the aspect ratio
  85223. * @param znear defines the near clip plane
  85224. * @param zfar defines the far clip plane
  85225. * @returns a new matrix as a right-handed perspective projection matrix
  85226. */
  85227. static PerspectiveFovRH(fov: number, aspect: number, znear: number, zfar: number): Matrix;
  85228. /**
  85229. * Stores a right-handed perspective projection into a given matrix
  85230. * @param fov defines the horizontal field of view
  85231. * @param aspect defines the aspect ratio
  85232. * @param znear defines the near clip plane
  85233. * @param zfar defines the far clip plane
  85234. * @param result defines the target matrix
  85235. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85236. */
  85237. static PerspectiveFovRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85238. /**
  85239. * Stores a right-handed perspective projection into a given matrix
  85240. * @param fov defines the horizontal field of view
  85241. * @param aspect defines the aspect ratio
  85242. * @param znear defines the near clip plane
  85243. * @param zfar not used as infinity is used as far clip
  85244. * @param result defines the target matrix
  85245. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  85246. */
  85247. static PerspectiveFovReverseRHToRef(fov: number, aspect: number, znear: number, zfar: number, result: Matrix, isVerticalFovFixed?: boolean): void;
  85248. /**
  85249. * Stores a perspective projection for WebVR info a given matrix
  85250. * @param fov defines the field of view
  85251. * @param znear defines the near clip plane
  85252. * @param zfar defines the far clip plane
  85253. * @param result defines the target matrix
  85254. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  85255. */
  85256. static PerspectiveFovWebVRToRef(fov: {
  85257. upDegrees: number;
  85258. downDegrees: number;
  85259. leftDegrees: number;
  85260. rightDegrees: number;
  85261. }, znear: number, zfar: number, result: Matrix, rightHanded?: boolean): void;
  85262. /**
  85263. * Computes a complete transformation matrix
  85264. * @param viewport defines the viewport to use
  85265. * @param world defines the world matrix
  85266. * @param view defines the view matrix
  85267. * @param projection defines the projection matrix
  85268. * @param zmin defines the near clip plane
  85269. * @param zmax defines the far clip plane
  85270. * @returns the transformation matrix
  85271. */
  85272. static GetFinalMatrix(viewport: DeepImmutable<Viewport>, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>, zmin: number, zmax: number): Matrix;
  85273. /**
  85274. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  85275. * @param matrix defines the matrix to use
  85276. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  85277. */
  85278. static GetAsMatrix2x2(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85279. /**
  85280. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  85281. * @param matrix defines the matrix to use
  85282. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  85283. */
  85284. static GetAsMatrix3x3(matrix: DeepImmutable<Matrix>): Float32Array | Array<number>;
  85285. /**
  85286. * Compute the transpose of a given matrix
  85287. * @param matrix defines the matrix to transpose
  85288. * @returns the new matrix
  85289. */
  85290. static Transpose(matrix: DeepImmutable<Matrix>): Matrix;
  85291. /**
  85292. * Compute the transpose of a matrix and store it in a target matrix
  85293. * @param matrix defines the matrix to transpose
  85294. * @param result defines the target matrix
  85295. */
  85296. static TransposeToRef(matrix: DeepImmutable<Matrix>, result: Matrix): void;
  85297. /**
  85298. * Computes a reflection matrix from a plane
  85299. * @param plane defines the reflection plane
  85300. * @returns a new matrix
  85301. */
  85302. static Reflection(plane: DeepImmutable<IPlaneLike>): Matrix;
  85303. /**
  85304. * Computes a reflection matrix from a plane
  85305. * @param plane defines the reflection plane
  85306. * @param result defines the target matrix
  85307. */
  85308. static ReflectionToRef(plane: DeepImmutable<IPlaneLike>, result: Matrix): void;
  85309. /**
  85310. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  85311. * @param xaxis defines the value of the 1st axis
  85312. * @param yaxis defines the value of the 2nd axis
  85313. * @param zaxis defines the value of the 3rd axis
  85314. * @param result defines the target matrix
  85315. */
  85316. static FromXYZAxesToRef(xaxis: DeepImmutable<Vector3>, yaxis: DeepImmutable<Vector3>, zaxis: DeepImmutable<Vector3>, result: Matrix): void;
  85317. /**
  85318. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  85319. * @param quat defines the quaternion to use
  85320. * @param result defines the target matrix
  85321. */
  85322. static FromQuaternionToRef(quat: DeepImmutable<Quaternion>, result: Matrix): void;
  85323. }
  85324. /**
  85325. * @hidden
  85326. */
  85327. export class TmpVectors {
  85328. static Vector2: Vector2[];
  85329. static Vector3: Vector3[];
  85330. static Vector4: Vector4[];
  85331. static Quaternion: Quaternion[];
  85332. static Matrix: Matrix[];
  85333. }
  85334. }
  85335. declare module BABYLON {
  85336. /**
  85337. * Defines potential orientation for back face culling
  85338. */
  85339. export enum Orientation {
  85340. /**
  85341. * Clockwise
  85342. */
  85343. CW = 0,
  85344. /** Counter clockwise */
  85345. CCW = 1
  85346. }
  85347. /** Class used to represent a Bezier curve */
  85348. export class BezierCurve {
  85349. /**
  85350. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  85351. * @param t defines the time
  85352. * @param x1 defines the left coordinate on X axis
  85353. * @param y1 defines the left coordinate on Y axis
  85354. * @param x2 defines the right coordinate on X axis
  85355. * @param y2 defines the right coordinate on Y axis
  85356. * @returns the interpolated value
  85357. */
  85358. static Interpolate(t: number, x1: number, y1: number, x2: number, y2: number): number;
  85359. }
  85360. /**
  85361. * Defines angle representation
  85362. */
  85363. export class Angle {
  85364. private _radians;
  85365. /**
  85366. * Creates an Angle object of "radians" radians (float).
  85367. * @param radians the angle in radians
  85368. */
  85369. constructor(radians: number);
  85370. /**
  85371. * Get value in degrees
  85372. * @returns the Angle value in degrees (float)
  85373. */
  85374. degrees(): number;
  85375. /**
  85376. * Get value in radians
  85377. * @returns the Angle value in radians (float)
  85378. */
  85379. radians(): number;
  85380. /**
  85381. * Gets a new Angle object valued with the gradient angle, in radians, of the line joining two points
  85382. * @param a defines first point as the origin
  85383. * @param b defines point
  85384. * @returns a new Angle
  85385. */
  85386. static BetweenTwoPoints(a: DeepImmutable<Vector2>, b: DeepImmutable<Vector2>): Angle;
  85387. /**
  85388. * Gets a new Angle object from the given float in radians
  85389. * @param radians defines the angle value in radians
  85390. * @returns a new Angle
  85391. */
  85392. static FromRadians(radians: number): Angle;
  85393. /**
  85394. * Gets a new Angle object from the given float in degrees
  85395. * @param degrees defines the angle value in degrees
  85396. * @returns a new Angle
  85397. */
  85398. static FromDegrees(degrees: number): Angle;
  85399. }
  85400. /**
  85401. * This represents an arc in a 2d space.
  85402. */
  85403. export class Arc2 {
  85404. /** Defines the start point of the arc */
  85405. startPoint: Vector2;
  85406. /** Defines the mid point of the arc */
  85407. midPoint: Vector2;
  85408. /** Defines the end point of the arc */
  85409. endPoint: Vector2;
  85410. /**
  85411. * Defines the center point of the arc.
  85412. */
  85413. centerPoint: Vector2;
  85414. /**
  85415. * Defines the radius of the arc.
  85416. */
  85417. radius: number;
  85418. /**
  85419. * Defines the angle of the arc (from mid point to end point).
  85420. */
  85421. angle: Angle;
  85422. /**
  85423. * Defines the start angle of the arc (from start point to middle point).
  85424. */
  85425. startAngle: Angle;
  85426. /**
  85427. * Defines the orientation of the arc (clock wise/counter clock wise).
  85428. */
  85429. orientation: Orientation;
  85430. /**
  85431. * Creates an Arc object from the three given points : start, middle and end.
  85432. * @param startPoint Defines the start point of the arc
  85433. * @param midPoint Defines the midlle point of the arc
  85434. * @param endPoint Defines the end point of the arc
  85435. */
  85436. constructor(
  85437. /** Defines the start point of the arc */
  85438. startPoint: Vector2,
  85439. /** Defines the mid point of the arc */
  85440. midPoint: Vector2,
  85441. /** Defines the end point of the arc */
  85442. endPoint: Vector2);
  85443. }
  85444. /**
  85445. * Represents a 2D path made up of multiple 2D points
  85446. */
  85447. export class Path2 {
  85448. private _points;
  85449. private _length;
  85450. /**
  85451. * If the path start and end point are the same
  85452. */
  85453. closed: boolean;
  85454. /**
  85455. * Creates a Path2 object from the starting 2D coordinates x and y.
  85456. * @param x the starting points x value
  85457. * @param y the starting points y value
  85458. */
  85459. constructor(x: number, y: number);
  85460. /**
  85461. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  85462. * @param x the added points x value
  85463. * @param y the added points y value
  85464. * @returns the updated Path2.
  85465. */
  85466. addLineTo(x: number, y: number): Path2;
  85467. /**
  85468. * 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.
  85469. * @param midX middle point x value
  85470. * @param midY middle point y value
  85471. * @param endX end point x value
  85472. * @param endY end point y value
  85473. * @param numberOfSegments (default: 36)
  85474. * @returns the updated Path2.
  85475. */
  85476. addArcTo(midX: number, midY: number, endX: number, endY: number, numberOfSegments?: number): Path2;
  85477. /**
  85478. * Closes the Path2.
  85479. * @returns the Path2.
  85480. */
  85481. close(): Path2;
  85482. /**
  85483. * Gets the sum of the distance between each sequential point in the path
  85484. * @returns the Path2 total length (float).
  85485. */
  85486. length(): number;
  85487. /**
  85488. * Gets the points which construct the path
  85489. * @returns the Path2 internal array of points.
  85490. */
  85491. getPoints(): Vector2[];
  85492. /**
  85493. * Retreives the point at the distance aways from the starting point
  85494. * @param normalizedLengthPosition the length along the path to retreive the point from
  85495. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  85496. */
  85497. getPointAtLengthPosition(normalizedLengthPosition: number): Vector2;
  85498. /**
  85499. * Creates a new path starting from an x and y position
  85500. * @param x starting x value
  85501. * @param y starting y value
  85502. * @returns a new Path2 starting at the coordinates (x, y).
  85503. */
  85504. static StartingAt(x: number, y: number): Path2;
  85505. }
  85506. /**
  85507. * Represents a 3D path made up of multiple 3D points
  85508. */
  85509. export class Path3D {
  85510. /**
  85511. * an array of Vector3, the curve axis of the Path3D
  85512. */
  85513. path: Vector3[];
  85514. private _curve;
  85515. private _distances;
  85516. private _tangents;
  85517. private _normals;
  85518. private _binormals;
  85519. private _raw;
  85520. private _alignTangentsWithPath;
  85521. private readonly _pointAtData;
  85522. /**
  85523. * new Path3D(path, normal, raw)
  85524. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  85525. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  85526. * @param path an array of Vector3, the curve axis of the Path3D
  85527. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  85528. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  85529. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path.
  85530. */
  85531. constructor(
  85532. /**
  85533. * an array of Vector3, the curve axis of the Path3D
  85534. */
  85535. path: Vector3[], firstNormal?: Nullable<Vector3>, raw?: boolean, alignTangentsWithPath?: boolean);
  85536. /**
  85537. * Returns the Path3D array of successive Vector3 designing its curve.
  85538. * @returns the Path3D array of successive Vector3 designing its curve.
  85539. */
  85540. getCurve(): Vector3[];
  85541. /**
  85542. * Returns the Path3D array of successive Vector3 designing its curve.
  85543. * @returns the Path3D array of successive Vector3 designing its curve.
  85544. */
  85545. getPoints(): Vector3[];
  85546. /**
  85547. * @returns the computed length (float) of the path.
  85548. */
  85549. length(): number;
  85550. /**
  85551. * Returns an array populated with tangent vectors on each Path3D curve point.
  85552. * @returns an array populated with tangent vectors on each Path3D curve point.
  85553. */
  85554. getTangents(): Vector3[];
  85555. /**
  85556. * Returns an array populated with normal vectors on each Path3D curve point.
  85557. * @returns an array populated with normal vectors on each Path3D curve point.
  85558. */
  85559. getNormals(): Vector3[];
  85560. /**
  85561. * Returns an array populated with binormal vectors on each Path3D curve point.
  85562. * @returns an array populated with binormal vectors on each Path3D curve point.
  85563. */
  85564. getBinormals(): Vector3[];
  85565. /**
  85566. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  85567. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  85568. */
  85569. getDistances(): number[];
  85570. /**
  85571. * Returns an interpolated point along this path
  85572. * @param position the position of the point along this path, from 0.0 to 1.0
  85573. * @returns a new Vector3 as the point
  85574. */
  85575. getPointAt(position: number): Vector3;
  85576. /**
  85577. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85578. * @param position the position of the point along this path, from 0.0 to 1.0
  85579. * @param interpolated (optional, default false) : boolean, if true returns an interpolated tangent instead of the tangent of the previous path point.
  85580. * @returns a tangent vector corresponding to the interpolated Path3D curve point, if not interpolated, the tangent is taken from the precomputed tangents array.
  85581. */
  85582. getTangentAt(position: number, interpolated?: boolean): Vector3;
  85583. /**
  85584. * Returns the tangent vector of an interpolated Path3D curve point at the specified position along this path.
  85585. * @param position the position of the point along this path, from 0.0 to 1.0
  85586. * @param interpolated (optional, default false) : boolean, if true returns an interpolated normal instead of the normal of the previous path point.
  85587. * @returns a normal vector corresponding to the interpolated Path3D curve point, if not interpolated, the normal is taken from the precomputed normals array.
  85588. */
  85589. getNormalAt(position: number, interpolated?: boolean): Vector3;
  85590. /**
  85591. * Returns the binormal vector of an interpolated Path3D curve point at the specified position along this path.
  85592. * @param position the position of the point along this path, from 0.0 to 1.0
  85593. * @param interpolated (optional, default false) : boolean, if true returns an interpolated binormal instead of the binormal of the previous path point.
  85594. * @returns a binormal vector corresponding to the interpolated Path3D curve point, if not interpolated, the binormal is taken from the precomputed binormals array.
  85595. */
  85596. getBinormalAt(position: number, interpolated?: boolean): Vector3;
  85597. /**
  85598. * Returns the distance (float) of an interpolated Path3D curve point at the specified position along this path.
  85599. * @param position the position of the point along this path, from 0.0 to 1.0
  85600. * @returns the distance of the interpolated Path3D curve point at the specified position along this path.
  85601. */
  85602. getDistanceAt(position: number): number;
  85603. /**
  85604. * Returns the array index of the previous point of an interpolated point along this path
  85605. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85606. * @returns the array index
  85607. */
  85608. getPreviousPointIndexAt(position: number): number;
  85609. /**
  85610. * 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)
  85611. * @param position the position of the point to interpolate along this path, from 0.0 to 1.0
  85612. * @returns the sub position
  85613. */
  85614. getSubPositionAt(position: number): number;
  85615. /**
  85616. * Returns the position of the closest virtual point on this path to an arbitrary Vector3, from 0.0 to 1.0
  85617. * @param target the vector of which to get the closest position to
  85618. * @returns the position of the closest virtual point on this path to the target vector
  85619. */
  85620. getClosestPositionTo(target: Vector3): number;
  85621. /**
  85622. * Returns a sub path (slice) of this path
  85623. * @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
  85624. * @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
  85625. * @returns a sub path (slice) of this path
  85626. */
  85627. slice(start?: number, end?: number): Path3D;
  85628. /**
  85629. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  85630. * @param path path which all values are copied into the curves points
  85631. * @param firstNormal which should be projected onto the curve
  85632. * @param alignTangentsWithPath (optional, default false) : boolean, if true the tangents will be aligned with the path
  85633. * @returns the same object updated.
  85634. */
  85635. update(path: Vector3[], firstNormal?: Nullable<Vector3>, alignTangentsWithPath?: boolean): Path3D;
  85636. private _compute;
  85637. private _getFirstNonNullVector;
  85638. private _getLastNonNullVector;
  85639. private _normalVector;
  85640. /**
  85641. * Updates the point at data for an interpolated point along this curve
  85642. * @param position the position of the point along this curve, from 0.0 to 1.0
  85643. * @interpolateTNB wether to compute the interpolated tangent, normal and binormal
  85644. * @returns the (updated) point at data
  85645. */
  85646. private _updatePointAtData;
  85647. /**
  85648. * Updates the point at data from the specified parameters
  85649. * @param position where along the path the interpolated point is, from 0.0 to 1.0
  85650. * @param point the interpolated point
  85651. * @param parentIndex the index of an existing curve point that is on, or else positionally the first behind, the interpolated point
  85652. */
  85653. private _setPointAtData;
  85654. /**
  85655. * Updates the point at interpolation matrix for the tangents, normals and binormals
  85656. */
  85657. private _updateInterpolationMatrix;
  85658. }
  85659. /**
  85660. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85661. * A Curve3 is designed from a series of successive Vector3.
  85662. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  85663. */
  85664. export class Curve3 {
  85665. private _points;
  85666. private _length;
  85667. /**
  85668. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  85669. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  85670. * @param v1 (Vector3) the control point
  85671. * @param v2 (Vector3) the end point of the Quadratic Bezier
  85672. * @param nbPoints (integer) the wanted number of points in the curve
  85673. * @returns the created Curve3
  85674. */
  85675. static CreateQuadraticBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85676. /**
  85677. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  85678. * @param v0 (Vector3) the origin point of the Cubic Bezier
  85679. * @param v1 (Vector3) the first control point
  85680. * @param v2 (Vector3) the second control point
  85681. * @param v3 (Vector3) the end point of the Cubic Bezier
  85682. * @param nbPoints (integer) the wanted number of points in the curve
  85683. * @returns the created Curve3
  85684. */
  85685. static CreateCubicBezier(v0: DeepImmutable<Vector3>, v1: DeepImmutable<Vector3>, v2: DeepImmutable<Vector3>, v3: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85686. /**
  85687. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  85688. * @param p1 (Vector3) the origin point of the Hermite Spline
  85689. * @param t1 (Vector3) the tangent vector at the origin point
  85690. * @param p2 (Vector3) the end point of the Hermite Spline
  85691. * @param t2 (Vector3) the tangent vector at the end point
  85692. * @param nbPoints (integer) the wanted number of points in the curve
  85693. * @returns the created Curve3
  85694. */
  85695. static CreateHermiteSpline(p1: DeepImmutable<Vector3>, t1: DeepImmutable<Vector3>, p2: DeepImmutable<Vector3>, t2: DeepImmutable<Vector3>, nbPoints: number): Curve3;
  85696. /**
  85697. * Returns a Curve3 object along a CatmullRom Spline curve :
  85698. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  85699. * @param nbPoints (integer) the wanted number of points between each curve control points
  85700. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  85701. * @returns the created Curve3
  85702. */
  85703. static CreateCatmullRomSpline(points: DeepImmutable<Vector3[]>, nbPoints: number, closed?: boolean): Curve3;
  85704. /**
  85705. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  85706. * A Curve3 is designed from a series of successive Vector3.
  85707. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  85708. * @param points points which make up the curve
  85709. */
  85710. constructor(points: Vector3[]);
  85711. /**
  85712. * @returns the Curve3 stored array of successive Vector3
  85713. */
  85714. getPoints(): Vector3[];
  85715. /**
  85716. * @returns the computed length (float) of the curve.
  85717. */
  85718. length(): number;
  85719. /**
  85720. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  85721. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  85722. * curveA and curveB keep unchanged.
  85723. * @param curve the curve to continue from this curve
  85724. * @returns the newly constructed curve
  85725. */
  85726. continue(curve: DeepImmutable<Curve3>): Curve3;
  85727. private _computeLength;
  85728. }
  85729. }
  85730. declare module BABYLON {
  85731. /**
  85732. * This represents the main contract an easing function should follow.
  85733. * Easing functions are used throughout the animation system.
  85734. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85735. */
  85736. export interface IEasingFunction {
  85737. /**
  85738. * Given an input gradient between 0 and 1, this returns the corrseponding value
  85739. * of the easing function.
  85740. * The link below provides some of the most common examples of easing functions.
  85741. * @see https://easings.net/
  85742. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85743. * @returns the corresponding value on the curve defined by the easing function
  85744. */
  85745. ease(gradient: number): number;
  85746. }
  85747. /**
  85748. * Base class used for every default easing function.
  85749. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85750. */
  85751. export class EasingFunction implements IEasingFunction {
  85752. /**
  85753. * Interpolation follows the mathematical formula associated with the easing function.
  85754. */
  85755. static readonly EASINGMODE_EASEIN: number;
  85756. /**
  85757. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  85758. */
  85759. static readonly EASINGMODE_EASEOUT: number;
  85760. /**
  85761. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  85762. */
  85763. static readonly EASINGMODE_EASEINOUT: number;
  85764. private _easingMode;
  85765. /**
  85766. * Sets the easing mode of the current function.
  85767. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  85768. */
  85769. setEasingMode(easingMode: number): void;
  85770. /**
  85771. * Gets the current easing mode.
  85772. * @returns the easing mode
  85773. */
  85774. getEasingMode(): number;
  85775. /**
  85776. * @hidden
  85777. */
  85778. easeInCore(gradient: number): number;
  85779. /**
  85780. * Given an input gradient between 0 and 1, this returns the corresponding value
  85781. * of the easing function.
  85782. * @param gradient Defines the value between 0 and 1 we want the easing value for
  85783. * @returns the corresponding value on the curve defined by the easing function
  85784. */
  85785. ease(gradient: number): number;
  85786. }
  85787. /**
  85788. * Easing function with a circle shape (see link below).
  85789. * @see https://easings.net/#easeInCirc
  85790. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85791. */
  85792. export class CircleEase extends EasingFunction implements IEasingFunction {
  85793. /** @hidden */
  85794. easeInCore(gradient: number): number;
  85795. }
  85796. /**
  85797. * Easing function with a ease back shape (see link below).
  85798. * @see https://easings.net/#easeInBack
  85799. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85800. */
  85801. export class BackEase extends EasingFunction implements IEasingFunction {
  85802. /** Defines the amplitude of the function */
  85803. amplitude: number;
  85804. /**
  85805. * Instantiates a back ease easing
  85806. * @see https://easings.net/#easeInBack
  85807. * @param amplitude Defines the amplitude of the function
  85808. */
  85809. constructor(
  85810. /** Defines the amplitude of the function */
  85811. amplitude?: number);
  85812. /** @hidden */
  85813. easeInCore(gradient: number): number;
  85814. }
  85815. /**
  85816. * Easing function with a bouncing shape (see link below).
  85817. * @see https://easings.net/#easeInBounce
  85818. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85819. */
  85820. export class BounceEase extends EasingFunction implements IEasingFunction {
  85821. /** Defines the number of bounces */
  85822. bounces: number;
  85823. /** Defines the amplitude of the bounce */
  85824. bounciness: number;
  85825. /**
  85826. * Instantiates a bounce easing
  85827. * @see https://easings.net/#easeInBounce
  85828. * @param bounces Defines the number of bounces
  85829. * @param bounciness Defines the amplitude of the bounce
  85830. */
  85831. constructor(
  85832. /** Defines the number of bounces */
  85833. bounces?: number,
  85834. /** Defines the amplitude of the bounce */
  85835. bounciness?: number);
  85836. /** @hidden */
  85837. easeInCore(gradient: number): number;
  85838. }
  85839. /**
  85840. * Easing function with a power of 3 shape (see link below).
  85841. * @see https://easings.net/#easeInCubic
  85842. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85843. */
  85844. export class CubicEase extends EasingFunction implements IEasingFunction {
  85845. /** @hidden */
  85846. easeInCore(gradient: number): number;
  85847. }
  85848. /**
  85849. * Easing function with an elastic shape (see link below).
  85850. * @see https://easings.net/#easeInElastic
  85851. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85852. */
  85853. export class ElasticEase extends EasingFunction implements IEasingFunction {
  85854. /** Defines the number of oscillations*/
  85855. oscillations: number;
  85856. /** Defines the amplitude of the oscillations*/
  85857. springiness: number;
  85858. /**
  85859. * Instantiates an elastic easing function
  85860. * @see https://easings.net/#easeInElastic
  85861. * @param oscillations Defines the number of oscillations
  85862. * @param springiness Defines the amplitude of the oscillations
  85863. */
  85864. constructor(
  85865. /** Defines the number of oscillations*/
  85866. oscillations?: number,
  85867. /** Defines the amplitude of the oscillations*/
  85868. springiness?: number);
  85869. /** @hidden */
  85870. easeInCore(gradient: number): number;
  85871. }
  85872. /**
  85873. * Easing function with an exponential shape (see link below).
  85874. * @see https://easings.net/#easeInExpo
  85875. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85876. */
  85877. export class ExponentialEase extends EasingFunction implements IEasingFunction {
  85878. /** Defines the exponent of the function */
  85879. exponent: number;
  85880. /**
  85881. * Instantiates an exponential easing function
  85882. * @see https://easings.net/#easeInExpo
  85883. * @param exponent Defines the exponent of the function
  85884. */
  85885. constructor(
  85886. /** Defines the exponent of the function */
  85887. exponent?: number);
  85888. /** @hidden */
  85889. easeInCore(gradient: number): number;
  85890. }
  85891. /**
  85892. * Easing function with a power shape (see link below).
  85893. * @see https://easings.net/#easeInQuad
  85894. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85895. */
  85896. export class PowerEase extends EasingFunction implements IEasingFunction {
  85897. /** Defines the power of the function */
  85898. power: number;
  85899. /**
  85900. * Instantiates an power base easing function
  85901. * @see https://easings.net/#easeInQuad
  85902. * @param power Defines the power of the function
  85903. */
  85904. constructor(
  85905. /** Defines the power of the function */
  85906. power?: number);
  85907. /** @hidden */
  85908. easeInCore(gradient: number): number;
  85909. }
  85910. /**
  85911. * Easing function with a power of 2 shape (see link below).
  85912. * @see https://easings.net/#easeInQuad
  85913. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85914. */
  85915. export class QuadraticEase extends EasingFunction implements IEasingFunction {
  85916. /** @hidden */
  85917. easeInCore(gradient: number): number;
  85918. }
  85919. /**
  85920. * Easing function with a power of 4 shape (see link below).
  85921. * @see https://easings.net/#easeInQuart
  85922. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85923. */
  85924. export class QuarticEase extends EasingFunction implements IEasingFunction {
  85925. /** @hidden */
  85926. easeInCore(gradient: number): number;
  85927. }
  85928. /**
  85929. * Easing function with a power of 5 shape (see link below).
  85930. * @see https://easings.net/#easeInQuint
  85931. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85932. */
  85933. export class QuinticEase extends EasingFunction implements IEasingFunction {
  85934. /** @hidden */
  85935. easeInCore(gradient: number): number;
  85936. }
  85937. /**
  85938. * Easing function with a sin shape (see link below).
  85939. * @see https://easings.net/#easeInSine
  85940. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85941. */
  85942. export class SineEase extends EasingFunction implements IEasingFunction {
  85943. /** @hidden */
  85944. easeInCore(gradient: number): number;
  85945. }
  85946. /**
  85947. * Easing function with a bezier shape (see link below).
  85948. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85949. * @see https://doc.babylonjs.com/babylon101/animations#easing-functions
  85950. */
  85951. export class BezierCurveEase extends EasingFunction implements IEasingFunction {
  85952. /** Defines the x component of the start tangent in the bezier curve */
  85953. x1: number;
  85954. /** Defines the y component of the start tangent in the bezier curve */
  85955. y1: number;
  85956. /** Defines the x component of the end tangent in the bezier curve */
  85957. x2: number;
  85958. /** Defines the y component of the end tangent in the bezier curve */
  85959. y2: number;
  85960. /**
  85961. * Instantiates a bezier function
  85962. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  85963. * @param x1 Defines the x component of the start tangent in the bezier curve
  85964. * @param y1 Defines the y component of the start tangent in the bezier curve
  85965. * @param x2 Defines the x component of the end tangent in the bezier curve
  85966. * @param y2 Defines the y component of the end tangent in the bezier curve
  85967. */
  85968. constructor(
  85969. /** Defines the x component of the start tangent in the bezier curve */
  85970. x1?: number,
  85971. /** Defines the y component of the start tangent in the bezier curve */
  85972. y1?: number,
  85973. /** Defines the x component of the end tangent in the bezier curve */
  85974. x2?: number,
  85975. /** Defines the y component of the end tangent in the bezier curve */
  85976. y2?: number);
  85977. /** @hidden */
  85978. easeInCore(gradient: number): number;
  85979. }
  85980. }
  85981. declare module BABYLON {
  85982. /**
  85983. * Class used to hold a RBG color
  85984. */
  85985. export class Color3 {
  85986. /**
  85987. * Defines the red component (between 0 and 1, default is 0)
  85988. */
  85989. r: number;
  85990. /**
  85991. * Defines the green component (between 0 and 1, default is 0)
  85992. */
  85993. g: number;
  85994. /**
  85995. * Defines the blue component (between 0 and 1, default is 0)
  85996. */
  85997. b: number;
  85998. /**
  85999. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  86000. * @param r defines the red component (between 0 and 1, default is 0)
  86001. * @param g defines the green component (between 0 and 1, default is 0)
  86002. * @param b defines the blue component (between 0 and 1, default is 0)
  86003. */
  86004. constructor(
  86005. /**
  86006. * Defines the red component (between 0 and 1, default is 0)
  86007. */
  86008. r?: number,
  86009. /**
  86010. * Defines the green component (between 0 and 1, default is 0)
  86011. */
  86012. g?: number,
  86013. /**
  86014. * Defines the blue component (between 0 and 1, default is 0)
  86015. */
  86016. b?: number);
  86017. /**
  86018. * Creates a string with the Color3 current values
  86019. * @returns the string representation of the Color3 object
  86020. */
  86021. toString(): string;
  86022. /**
  86023. * Returns the string "Color3"
  86024. * @returns "Color3"
  86025. */
  86026. getClassName(): string;
  86027. /**
  86028. * Compute the Color3 hash code
  86029. * @returns an unique number that can be used to hash Color3 objects
  86030. */
  86031. getHashCode(): number;
  86032. /**
  86033. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  86034. * @param array defines the array where to store the r,g,b components
  86035. * @param index defines an optional index in the target array to define where to start storing values
  86036. * @returns the current Color3 object
  86037. */
  86038. toArray(array: FloatArray, index?: number): Color3;
  86039. /**
  86040. * Update the current color with values stored in an array from the starting index of the given array
  86041. * @param array defines the source array
  86042. * @param offset defines an offset in the source array
  86043. * @returns the current Color3 object
  86044. */
  86045. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86046. /**
  86047. * Returns a new Color4 object from the current Color3 and the given alpha
  86048. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  86049. * @returns a new Color4 object
  86050. */
  86051. toColor4(alpha?: number): Color4;
  86052. /**
  86053. * Returns a new array populated with 3 numeric elements : red, green and blue values
  86054. * @returns the new array
  86055. */
  86056. asArray(): number[];
  86057. /**
  86058. * Returns the luminance value
  86059. * @returns a float value
  86060. */
  86061. toLuminance(): number;
  86062. /**
  86063. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  86064. * @param otherColor defines the second operand
  86065. * @returns the new Color3 object
  86066. */
  86067. multiply(otherColor: DeepImmutable<Color3>): Color3;
  86068. /**
  86069. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  86070. * @param otherColor defines the second operand
  86071. * @param result defines the Color3 object where to store the result
  86072. * @returns the current Color3
  86073. */
  86074. multiplyToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86075. /**
  86076. * Determines equality between Color3 objects
  86077. * @param otherColor defines the second operand
  86078. * @returns true if the rgb values are equal to the given ones
  86079. */
  86080. equals(otherColor: DeepImmutable<Color3>): boolean;
  86081. /**
  86082. * Determines equality between the current Color3 object and a set of r,b,g values
  86083. * @param r defines the red component to check
  86084. * @param g defines the green component to check
  86085. * @param b defines the blue component to check
  86086. * @returns true if the rgb values are equal to the given ones
  86087. */
  86088. equalsFloats(r: number, g: number, b: number): boolean;
  86089. /**
  86090. * Multiplies in place each rgb value by scale
  86091. * @param scale defines the scaling factor
  86092. * @returns the updated Color3
  86093. */
  86094. scale(scale: number): Color3;
  86095. /**
  86096. * Multiplies the rgb values by scale and stores the result into "result"
  86097. * @param scale defines the scaling factor
  86098. * @param result defines the Color3 object where to store the result
  86099. * @returns the unmodified current Color3
  86100. */
  86101. scaleToRef(scale: number, result: Color3): Color3;
  86102. /**
  86103. * Scale the current Color3 values by a factor and add the result to a given Color3
  86104. * @param scale defines the scale factor
  86105. * @param result defines color to store the result into
  86106. * @returns the unmodified current Color3
  86107. */
  86108. scaleAndAddToRef(scale: number, result: Color3): Color3;
  86109. /**
  86110. * Clamps the rgb values by the min and max values and stores the result into "result"
  86111. * @param min defines minimum clamping value (default is 0)
  86112. * @param max defines maximum clamping value (default is 1)
  86113. * @param result defines color to store the result into
  86114. * @returns the original Color3
  86115. */
  86116. clampToRef(min: number | undefined, max: number | undefined, result: Color3): Color3;
  86117. /**
  86118. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  86119. * @param otherColor defines the second operand
  86120. * @returns the new Color3
  86121. */
  86122. add(otherColor: DeepImmutable<Color3>): Color3;
  86123. /**
  86124. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  86125. * @param otherColor defines the second operand
  86126. * @param result defines Color3 object to store the result into
  86127. * @returns the unmodified current Color3
  86128. */
  86129. addToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86130. /**
  86131. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  86132. * @param otherColor defines the second operand
  86133. * @returns the new Color3
  86134. */
  86135. subtract(otherColor: DeepImmutable<Color3>): Color3;
  86136. /**
  86137. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  86138. * @param otherColor defines the second operand
  86139. * @param result defines Color3 object to store the result into
  86140. * @returns the unmodified current Color3
  86141. */
  86142. subtractToRef(otherColor: DeepImmutable<Color3>, result: Color3): Color3;
  86143. /**
  86144. * Copy the current object
  86145. * @returns a new Color3 copied the current one
  86146. */
  86147. clone(): Color3;
  86148. /**
  86149. * Copies the rgb values from the source in the current Color3
  86150. * @param source defines the source Color3 object
  86151. * @returns the updated Color3 object
  86152. */
  86153. copyFrom(source: DeepImmutable<Color3>): Color3;
  86154. /**
  86155. * Updates the Color3 rgb values from the given floats
  86156. * @param r defines the red component to read from
  86157. * @param g defines the green component to read from
  86158. * @param b defines the blue component to read from
  86159. * @returns the current Color3 object
  86160. */
  86161. copyFromFloats(r: number, g: number, b: number): Color3;
  86162. /**
  86163. * Updates the Color3 rgb values from the given floats
  86164. * @param r defines the red component to read from
  86165. * @param g defines the green component to read from
  86166. * @param b defines the blue component to read from
  86167. * @returns the current Color3 object
  86168. */
  86169. set(r: number, g: number, b: number): Color3;
  86170. /**
  86171. * Compute the Color3 hexadecimal code as a string
  86172. * @returns a string containing the hexadecimal representation of the Color3 object
  86173. */
  86174. toHexString(): string;
  86175. /**
  86176. * Computes a new Color3 converted from the current one to linear space
  86177. * @returns a new Color3 object
  86178. */
  86179. toLinearSpace(): Color3;
  86180. /**
  86181. * Converts current color in rgb space to HSV values
  86182. * @returns a new color3 representing the HSV values
  86183. */
  86184. toHSV(): Color3;
  86185. /**
  86186. * Converts current color in rgb space to HSV values
  86187. * @param result defines the Color3 where to store the HSV values
  86188. */
  86189. toHSVToRef(result: Color3): void;
  86190. /**
  86191. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  86192. * @param convertedColor defines the Color3 object where to store the linear space version
  86193. * @returns the unmodified Color3
  86194. */
  86195. toLinearSpaceToRef(convertedColor: Color3): Color3;
  86196. /**
  86197. * Computes a new Color3 converted from the current one to gamma space
  86198. * @returns a new Color3 object
  86199. */
  86200. toGammaSpace(): Color3;
  86201. /**
  86202. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  86203. * @param convertedColor defines the Color3 object where to store the gamma space version
  86204. * @returns the unmodified Color3
  86205. */
  86206. toGammaSpaceToRef(convertedColor: Color3): Color3;
  86207. private static _BlackReadOnly;
  86208. /**
  86209. * Convert Hue, saturation and value to a Color3 (RGB)
  86210. * @param hue defines the hue
  86211. * @param saturation defines the saturation
  86212. * @param value defines the value
  86213. * @param result defines the Color3 where to store the RGB values
  86214. */
  86215. static HSVtoRGBToRef(hue: number, saturation: number, value: number, result: Color3): void;
  86216. /**
  86217. * Creates a new Color3 from the string containing valid hexadecimal values
  86218. * @param hex defines a string containing valid hexadecimal values
  86219. * @returns a new Color3 object
  86220. */
  86221. static FromHexString(hex: string): Color3;
  86222. /**
  86223. * Creates a new Color3 from the starting index of the given array
  86224. * @param array defines the source array
  86225. * @param offset defines an offset in the source array
  86226. * @returns a new Color3 object
  86227. */
  86228. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color3;
  86229. /**
  86230. * Creates a new Color3 from the starting index element of the given array
  86231. * @param array defines the source array to read from
  86232. * @param offset defines the offset in the source array
  86233. * @param result defines the target Color3 object
  86234. */
  86235. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color3): void;
  86236. /**
  86237. * Creates a new Color3 from integer values (< 256)
  86238. * @param r defines the red component to read from (value between 0 and 255)
  86239. * @param g defines the green component to read from (value between 0 and 255)
  86240. * @param b defines the blue component to read from (value between 0 and 255)
  86241. * @returns a new Color3 object
  86242. */
  86243. static FromInts(r: number, g: number, b: number): Color3;
  86244. /**
  86245. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86246. * @param start defines the start Color3 value
  86247. * @param end defines the end Color3 value
  86248. * @param amount defines the gradient value between start and end
  86249. * @returns a new Color3 object
  86250. */
  86251. static Lerp(start: DeepImmutable<Color3>, end: DeepImmutable<Color3>, amount: number): Color3;
  86252. /**
  86253. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  86254. * @param left defines the start value
  86255. * @param right defines the end value
  86256. * @param amount defines the gradient factor
  86257. * @param result defines the Color3 object where to store the result
  86258. */
  86259. static LerpToRef(left: DeepImmutable<Color3>, right: DeepImmutable<Color3>, amount: number, result: Color3): void;
  86260. /**
  86261. * Returns a Color3 value containing a red color
  86262. * @returns a new Color3 object
  86263. */
  86264. static Red(): Color3;
  86265. /**
  86266. * Returns a Color3 value containing a green color
  86267. * @returns a new Color3 object
  86268. */
  86269. static Green(): Color3;
  86270. /**
  86271. * Returns a Color3 value containing a blue color
  86272. * @returns a new Color3 object
  86273. */
  86274. static Blue(): Color3;
  86275. /**
  86276. * Returns a Color3 value containing a black color
  86277. * @returns a new Color3 object
  86278. */
  86279. static Black(): Color3;
  86280. /**
  86281. * Gets a Color3 value containing a black color that must not be updated
  86282. */
  86283. static get BlackReadOnly(): DeepImmutable<Color3>;
  86284. /**
  86285. * Returns a Color3 value containing a white color
  86286. * @returns a new Color3 object
  86287. */
  86288. static White(): Color3;
  86289. /**
  86290. * Returns a Color3 value containing a purple color
  86291. * @returns a new Color3 object
  86292. */
  86293. static Purple(): Color3;
  86294. /**
  86295. * Returns a Color3 value containing a magenta color
  86296. * @returns a new Color3 object
  86297. */
  86298. static Magenta(): Color3;
  86299. /**
  86300. * Returns a Color3 value containing a yellow color
  86301. * @returns a new Color3 object
  86302. */
  86303. static Yellow(): Color3;
  86304. /**
  86305. * Returns a Color3 value containing a gray color
  86306. * @returns a new Color3 object
  86307. */
  86308. static Gray(): Color3;
  86309. /**
  86310. * Returns a Color3 value containing a teal color
  86311. * @returns a new Color3 object
  86312. */
  86313. static Teal(): Color3;
  86314. /**
  86315. * Returns a Color3 value containing a random color
  86316. * @returns a new Color3 object
  86317. */
  86318. static Random(): Color3;
  86319. }
  86320. /**
  86321. * Class used to hold a RBGA color
  86322. */
  86323. export class Color4 {
  86324. /**
  86325. * Defines the red component (between 0 and 1, default is 0)
  86326. */
  86327. r: number;
  86328. /**
  86329. * Defines the green component (between 0 and 1, default is 0)
  86330. */
  86331. g: number;
  86332. /**
  86333. * Defines the blue component (between 0 and 1, default is 0)
  86334. */
  86335. b: number;
  86336. /**
  86337. * Defines the alpha component (between 0 and 1, default is 1)
  86338. */
  86339. a: number;
  86340. /**
  86341. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  86342. * @param r defines the red component (between 0 and 1, default is 0)
  86343. * @param g defines the green component (between 0 and 1, default is 0)
  86344. * @param b defines the blue component (between 0 and 1, default is 0)
  86345. * @param a defines the alpha component (between 0 and 1, default is 1)
  86346. */
  86347. constructor(
  86348. /**
  86349. * Defines the red component (between 0 and 1, default is 0)
  86350. */
  86351. r?: number,
  86352. /**
  86353. * Defines the green component (between 0 and 1, default is 0)
  86354. */
  86355. g?: number,
  86356. /**
  86357. * Defines the blue component (between 0 and 1, default is 0)
  86358. */
  86359. b?: number,
  86360. /**
  86361. * Defines the alpha component (between 0 and 1, default is 1)
  86362. */
  86363. a?: number);
  86364. /**
  86365. * Adds in place the given Color4 values to the current Color4 object
  86366. * @param right defines the second operand
  86367. * @returns the current updated Color4 object
  86368. */
  86369. addInPlace(right: DeepImmutable<Color4>): Color4;
  86370. /**
  86371. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  86372. * @returns the new array
  86373. */
  86374. asArray(): number[];
  86375. /**
  86376. * Stores from the starting index in the given array the Color4 successive values
  86377. * @param array defines the array where to store the r,g,b components
  86378. * @param index defines an optional index in the target array to define where to start storing values
  86379. * @returns the current Color4 object
  86380. */
  86381. toArray(array: number[], index?: number): Color4;
  86382. /**
  86383. * Update the current color with values stored in an array from the starting index of the given array
  86384. * @param array defines the source array
  86385. * @param offset defines an offset in the source array
  86386. * @returns the current Color4 object
  86387. */
  86388. fromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86389. /**
  86390. * Determines equality between Color4 objects
  86391. * @param otherColor defines the second operand
  86392. * @returns true if the rgba values are equal to the given ones
  86393. */
  86394. equals(otherColor: DeepImmutable<Color4>): boolean;
  86395. /**
  86396. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  86397. * @param right defines the second operand
  86398. * @returns a new Color4 object
  86399. */
  86400. add(right: DeepImmutable<Color4>): Color4;
  86401. /**
  86402. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  86403. * @param right defines the second operand
  86404. * @returns a new Color4 object
  86405. */
  86406. subtract(right: DeepImmutable<Color4>): Color4;
  86407. /**
  86408. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  86409. * @param right defines the second operand
  86410. * @param result defines the Color4 object where to store the result
  86411. * @returns the current Color4 object
  86412. */
  86413. subtractToRef(right: DeepImmutable<Color4>, result: Color4): Color4;
  86414. /**
  86415. * Creates a new Color4 with the current Color4 values multiplied by scale
  86416. * @param scale defines the scaling factor to apply
  86417. * @returns a new Color4 object
  86418. */
  86419. scale(scale: number): Color4;
  86420. /**
  86421. * Multiplies the current Color4 values by scale and stores the result in "result"
  86422. * @param scale defines the scaling factor to apply
  86423. * @param result defines the Color4 object where to store the result
  86424. * @returns the current unmodified Color4
  86425. */
  86426. scaleToRef(scale: number, result: Color4): Color4;
  86427. /**
  86428. * Scale the current Color4 values by a factor and add the result to a given Color4
  86429. * @param scale defines the scale factor
  86430. * @param result defines the Color4 object where to store the result
  86431. * @returns the unmodified current Color4
  86432. */
  86433. scaleAndAddToRef(scale: number, result: Color4): Color4;
  86434. /**
  86435. * Clamps the rgb values by the min and max values and stores the result into "result"
  86436. * @param min defines minimum clamping value (default is 0)
  86437. * @param max defines maximum clamping value (default is 1)
  86438. * @param result defines color to store the result into.
  86439. * @returns the cuurent Color4
  86440. */
  86441. clampToRef(min: number | undefined, max: number | undefined, result: Color4): Color4;
  86442. /**
  86443. * Multipy an Color4 value by another and return a new Color4 object
  86444. * @param color defines the Color4 value to multiply by
  86445. * @returns a new Color4 object
  86446. */
  86447. multiply(color: Color4): Color4;
  86448. /**
  86449. * Multipy a Color4 value by another and push the result in a reference value
  86450. * @param color defines the Color4 value to multiply by
  86451. * @param result defines the Color4 to fill the result in
  86452. * @returns the result Color4
  86453. */
  86454. multiplyToRef(color: Color4, result: Color4): Color4;
  86455. /**
  86456. * Creates a string with the Color4 current values
  86457. * @returns the string representation of the Color4 object
  86458. */
  86459. toString(): string;
  86460. /**
  86461. * Returns the string "Color4"
  86462. * @returns "Color4"
  86463. */
  86464. getClassName(): string;
  86465. /**
  86466. * Compute the Color4 hash code
  86467. * @returns an unique number that can be used to hash Color4 objects
  86468. */
  86469. getHashCode(): number;
  86470. /**
  86471. * Creates a new Color4 copied from the current one
  86472. * @returns a new Color4 object
  86473. */
  86474. clone(): Color4;
  86475. /**
  86476. * Copies the given Color4 values into the current one
  86477. * @param source defines the source Color4 object
  86478. * @returns the current updated Color4 object
  86479. */
  86480. copyFrom(source: Color4): Color4;
  86481. /**
  86482. * Copies the given float values into the current one
  86483. * @param r defines the red component to read from
  86484. * @param g defines the green component to read from
  86485. * @param b defines the blue component to read from
  86486. * @param a defines the alpha component to read from
  86487. * @returns the current updated Color4 object
  86488. */
  86489. copyFromFloats(r: number, g: number, b: number, a: number): Color4;
  86490. /**
  86491. * Copies the given float values into the current one
  86492. * @param r defines the red component to read from
  86493. * @param g defines the green component to read from
  86494. * @param b defines the blue component to read from
  86495. * @param a defines the alpha component to read from
  86496. * @returns the current updated Color4 object
  86497. */
  86498. set(r: number, g: number, b: number, a: number): Color4;
  86499. /**
  86500. * Compute the Color4 hexadecimal code as a string
  86501. * @param returnAsColor3 defines if the string should only contains RGB values (off by default)
  86502. * @returns a string containing the hexadecimal representation of the Color4 object
  86503. */
  86504. toHexString(returnAsColor3?: boolean): string;
  86505. /**
  86506. * Computes a new Color4 converted from the current one to linear space
  86507. * @returns a new Color4 object
  86508. */
  86509. toLinearSpace(): Color4;
  86510. /**
  86511. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  86512. * @param convertedColor defines the Color4 object where to store the linear space version
  86513. * @returns the unmodified Color4
  86514. */
  86515. toLinearSpaceToRef(convertedColor: Color4): Color4;
  86516. /**
  86517. * Computes a new Color4 converted from the current one to gamma space
  86518. * @returns a new Color4 object
  86519. */
  86520. toGammaSpace(): Color4;
  86521. /**
  86522. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  86523. * @param convertedColor defines the Color4 object where to store the gamma space version
  86524. * @returns the unmodified Color4
  86525. */
  86526. toGammaSpaceToRef(convertedColor: Color4): Color4;
  86527. /**
  86528. * Creates a new Color4 from the string containing valid hexadecimal values
  86529. * @param hex defines a string containing valid hexadecimal values
  86530. * @returns a new Color4 object
  86531. */
  86532. static FromHexString(hex: string): Color4;
  86533. /**
  86534. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86535. * @param left defines the start value
  86536. * @param right defines the end value
  86537. * @param amount defines the gradient factor
  86538. * @returns a new Color4 object
  86539. */
  86540. static Lerp(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number): Color4;
  86541. /**
  86542. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  86543. * @param left defines the start value
  86544. * @param right defines the end value
  86545. * @param amount defines the gradient factor
  86546. * @param result defines the Color4 object where to store data
  86547. */
  86548. static LerpToRef(left: DeepImmutable<Color4>, right: DeepImmutable<Color4>, amount: number, result: Color4): void;
  86549. /**
  86550. * Creates a new Color4 from a Color3 and an alpha value
  86551. * @param color3 defines the source Color3 to read from
  86552. * @param alpha defines the alpha component (1.0 by default)
  86553. * @returns a new Color4 object
  86554. */
  86555. static FromColor3(color3: DeepImmutable<Color3>, alpha?: number): Color4;
  86556. /**
  86557. * Creates a new Color4 from the starting index element of the given array
  86558. * @param array defines the source array to read from
  86559. * @param offset defines the offset in the source array
  86560. * @returns a new Color4 object
  86561. */
  86562. static FromArray(array: DeepImmutable<ArrayLike<number>>, offset?: number): Color4;
  86563. /**
  86564. * Creates a new Color4 from the starting index element of the given array
  86565. * @param array defines the source array to read from
  86566. * @param offset defines the offset in the source array
  86567. * @param result defines the target Color4 object
  86568. */
  86569. static FromArrayToRef(array: DeepImmutable<ArrayLike<number>>, offset: number | undefined, result: Color4): void;
  86570. /**
  86571. * Creates a new Color3 from integer values (< 256)
  86572. * @param r defines the red component to read from (value between 0 and 255)
  86573. * @param g defines the green component to read from (value between 0 and 255)
  86574. * @param b defines the blue component to read from (value between 0 and 255)
  86575. * @param a defines the alpha component to read from (value between 0 and 255)
  86576. * @returns a new Color3 object
  86577. */
  86578. static FromInts(r: number, g: number, b: number, a: number): Color4;
  86579. /**
  86580. * Check the content of a given array and convert it to an array containing RGBA data
  86581. * If the original array was already containing count * 4 values then it is returned directly
  86582. * @param colors defines the array to check
  86583. * @param count defines the number of RGBA data to expect
  86584. * @returns an array containing count * 4 values (RGBA)
  86585. */
  86586. static CheckColors4(colors: number[], count: number): number[];
  86587. }
  86588. /**
  86589. * @hidden
  86590. */
  86591. export class TmpColors {
  86592. static Color3: Color3[];
  86593. static Color4: Color4[];
  86594. }
  86595. }
  86596. declare module BABYLON {
  86597. /**
  86598. * Defines an interface which represents an animation key frame
  86599. */
  86600. export interface IAnimationKey {
  86601. /**
  86602. * Frame of the key frame
  86603. */
  86604. frame: number;
  86605. /**
  86606. * Value at the specifies key frame
  86607. */
  86608. value: any;
  86609. /**
  86610. * The input tangent for the cubic hermite spline
  86611. */
  86612. inTangent?: any;
  86613. /**
  86614. * The output tangent for the cubic hermite spline
  86615. */
  86616. outTangent?: any;
  86617. /**
  86618. * The animation interpolation type
  86619. */
  86620. interpolation?: AnimationKeyInterpolation;
  86621. }
  86622. /**
  86623. * Enum for the animation key frame interpolation type
  86624. */
  86625. export enum AnimationKeyInterpolation {
  86626. /**
  86627. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  86628. */
  86629. STEP = 1
  86630. }
  86631. }
  86632. declare module BABYLON {
  86633. /**
  86634. * Represents the range of an animation
  86635. */
  86636. export class AnimationRange {
  86637. /**The name of the animation range**/
  86638. name: string;
  86639. /**The starting frame of the animation */
  86640. from: number;
  86641. /**The ending frame of the animation*/
  86642. to: number;
  86643. /**
  86644. * Initializes the range of an animation
  86645. * @param name The name of the animation range
  86646. * @param from The starting frame of the animation
  86647. * @param to The ending frame of the animation
  86648. */
  86649. constructor(
  86650. /**The name of the animation range**/
  86651. name: string,
  86652. /**The starting frame of the animation */
  86653. from: number,
  86654. /**The ending frame of the animation*/
  86655. to: number);
  86656. /**
  86657. * Makes a copy of the animation range
  86658. * @returns A copy of the animation range
  86659. */
  86660. clone(): AnimationRange;
  86661. }
  86662. }
  86663. declare module BABYLON {
  86664. /**
  86665. * Composed of a frame, and an action function
  86666. */
  86667. export class AnimationEvent {
  86668. /** The frame for which the event is triggered **/
  86669. frame: number;
  86670. /** The event to perform when triggered **/
  86671. action: (currentFrame: number) => void;
  86672. /** Specifies if the event should be triggered only once**/
  86673. onlyOnce?: boolean | undefined;
  86674. /**
  86675. * Specifies if the animation event is done
  86676. */
  86677. isDone: boolean;
  86678. /**
  86679. * Initializes the animation event
  86680. * @param frame The frame for which the event is triggered
  86681. * @param action The event to perform when triggered
  86682. * @param onlyOnce Specifies if the event should be triggered only once
  86683. */
  86684. constructor(
  86685. /** The frame for which the event is triggered **/
  86686. frame: number,
  86687. /** The event to perform when triggered **/
  86688. action: (currentFrame: number) => void,
  86689. /** Specifies if the event should be triggered only once**/
  86690. onlyOnce?: boolean | undefined);
  86691. /** @hidden */
  86692. _clone(): AnimationEvent;
  86693. }
  86694. }
  86695. declare module BABYLON {
  86696. /**
  86697. * Interface used to define a behavior
  86698. */
  86699. export interface Behavior<T> {
  86700. /** gets or sets behavior's name */
  86701. name: string;
  86702. /**
  86703. * Function called when the behavior needs to be initialized (after attaching it to a target)
  86704. */
  86705. init(): void;
  86706. /**
  86707. * Called when the behavior is attached to a target
  86708. * @param target defines the target where the behavior is attached to
  86709. */
  86710. attach(target: T): void;
  86711. /**
  86712. * Called when the behavior is detached from its target
  86713. */
  86714. detach(): void;
  86715. }
  86716. /**
  86717. * Interface implemented by classes supporting behaviors
  86718. */
  86719. export interface IBehaviorAware<T> {
  86720. /**
  86721. * Attach a behavior
  86722. * @param behavior defines the behavior to attach
  86723. * @returns the current host
  86724. */
  86725. addBehavior(behavior: Behavior<T>): T;
  86726. /**
  86727. * Remove a behavior from the current object
  86728. * @param behavior defines the behavior to detach
  86729. * @returns the current host
  86730. */
  86731. removeBehavior(behavior: Behavior<T>): T;
  86732. /**
  86733. * Gets a behavior using its name to search
  86734. * @param name defines the name to search
  86735. * @returns the behavior or null if not found
  86736. */
  86737. getBehaviorByName(name: string): Nullable<Behavior<T>>;
  86738. }
  86739. }
  86740. declare module BABYLON {
  86741. /**
  86742. * Defines an array and its length.
  86743. * It can be helpfull to group result from both Arrays and smart arrays in one structure.
  86744. */
  86745. export interface ISmartArrayLike<T> {
  86746. /**
  86747. * The data of the array.
  86748. */
  86749. data: Array<T>;
  86750. /**
  86751. * The active length of the array.
  86752. */
  86753. length: number;
  86754. }
  86755. /**
  86756. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86757. */
  86758. export class SmartArray<T> implements ISmartArrayLike<T> {
  86759. /**
  86760. * The full set of data from the array.
  86761. */
  86762. data: Array<T>;
  86763. /**
  86764. * The active length of the array.
  86765. */
  86766. length: number;
  86767. protected _id: number;
  86768. /**
  86769. * Instantiates a Smart Array.
  86770. * @param capacity defines the default capacity of the array.
  86771. */
  86772. constructor(capacity: number);
  86773. /**
  86774. * Pushes a value at the end of the active data.
  86775. * @param value defines the object to push in the array.
  86776. */
  86777. push(value: T): void;
  86778. /**
  86779. * Iterates over the active data and apply the lambda to them.
  86780. * @param func defines the action to apply on each value.
  86781. */
  86782. forEach(func: (content: T) => void): void;
  86783. /**
  86784. * Sorts the full sets of data.
  86785. * @param compareFn defines the comparison function to apply.
  86786. */
  86787. sort(compareFn: (a: T, b: T) => number): void;
  86788. /**
  86789. * Resets the active data to an empty array.
  86790. */
  86791. reset(): void;
  86792. /**
  86793. * Releases all the data from the array as well as the array.
  86794. */
  86795. dispose(): void;
  86796. /**
  86797. * Concats the active data with a given array.
  86798. * @param array defines the data to concatenate with.
  86799. */
  86800. concat(array: any): void;
  86801. /**
  86802. * Returns the position of a value in the active data.
  86803. * @param value defines the value to find the index for
  86804. * @returns the index if found in the active data otherwise -1
  86805. */
  86806. indexOf(value: T): number;
  86807. /**
  86808. * Returns whether an element is part of the active data.
  86809. * @param value defines the value to look for
  86810. * @returns true if found in the active data otherwise false
  86811. */
  86812. contains(value: T): boolean;
  86813. private static _GlobalId;
  86814. }
  86815. /**
  86816. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  86817. * The data in this array can only be present once
  86818. */
  86819. export class SmartArrayNoDuplicate<T> extends SmartArray<T> {
  86820. private _duplicateId;
  86821. /**
  86822. * Pushes a value at the end of the active data.
  86823. * THIS DOES NOT PREVENT DUPPLICATE DATA
  86824. * @param value defines the object to push in the array.
  86825. */
  86826. push(value: T): void;
  86827. /**
  86828. * Pushes a value at the end of the active data.
  86829. * If the data is already present, it won t be added again
  86830. * @param value defines the object to push in the array.
  86831. * @returns true if added false if it was already present
  86832. */
  86833. pushNoDuplicate(value: T): boolean;
  86834. /**
  86835. * Resets the active data to an empty array.
  86836. */
  86837. reset(): void;
  86838. /**
  86839. * Concats the active data with a given array.
  86840. * This ensures no dupplicate will be present in the result.
  86841. * @param array defines the data to concatenate with.
  86842. */
  86843. concatWithNoDuplicate(array: any): void;
  86844. }
  86845. }
  86846. declare module BABYLON {
  86847. /**
  86848. * @ignore
  86849. * This is a list of all the different input types that are available in the application.
  86850. * Fo instance: ArcRotateCameraGamepadInput...
  86851. */
  86852. export var CameraInputTypes: {};
  86853. /**
  86854. * This is the contract to implement in order to create a new input class.
  86855. * Inputs are dealing with listening to user actions and moving the camera accordingly.
  86856. */
  86857. export interface ICameraInput<TCamera extends Camera> {
  86858. /**
  86859. * Defines the camera the input is attached to.
  86860. */
  86861. camera: Nullable<TCamera>;
  86862. /**
  86863. * Gets the class name of the current intput.
  86864. * @returns the class name
  86865. */
  86866. getClassName(): string;
  86867. /**
  86868. * Get the friendly name associated with the input class.
  86869. * @returns the input friendly name
  86870. */
  86871. getSimpleName(): string;
  86872. /**
  86873. * Attach the input controls to a specific dom element to get the input from.
  86874. * @param element Defines the element the controls should be listened from
  86875. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86876. */
  86877. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  86878. /**
  86879. * Detach the current controls from the specified dom element.
  86880. * @param element Defines the element to stop listening the inputs from
  86881. */
  86882. detachControl(element: Nullable<HTMLElement>): void;
  86883. /**
  86884. * Update the current camera state depending on the inputs that have been used this frame.
  86885. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86886. */
  86887. checkInputs?: () => void;
  86888. }
  86889. /**
  86890. * Represents a map of input types to input instance or input index to input instance.
  86891. */
  86892. export interface CameraInputsMap<TCamera extends Camera> {
  86893. /**
  86894. * Accessor to the input by input type.
  86895. */
  86896. [name: string]: ICameraInput<TCamera>;
  86897. /**
  86898. * Accessor to the input by input index.
  86899. */
  86900. [idx: number]: ICameraInput<TCamera>;
  86901. }
  86902. /**
  86903. * This represents the input manager used within a camera.
  86904. * It helps dealing with all the different kind of input attached to a camera.
  86905. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86906. */
  86907. export class CameraInputsManager<TCamera extends Camera> {
  86908. /**
  86909. * Defines the list of inputs attahed to the camera.
  86910. */
  86911. attached: CameraInputsMap<TCamera>;
  86912. /**
  86913. * Defines the dom element the camera is collecting inputs from.
  86914. * This is null if the controls have not been attached.
  86915. */
  86916. attachedElement: Nullable<HTMLElement>;
  86917. /**
  86918. * Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86919. */
  86920. noPreventDefault: boolean;
  86921. /**
  86922. * Defined the camera the input manager belongs to.
  86923. */
  86924. camera: TCamera;
  86925. /**
  86926. * Update the current camera state depending on the inputs that have been used this frame.
  86927. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  86928. */
  86929. checkInputs: () => void;
  86930. /**
  86931. * Instantiate a new Camera Input Manager.
  86932. * @param camera Defines the camera the input manager blongs to
  86933. */
  86934. constructor(camera: TCamera);
  86935. /**
  86936. * Add an input method to a camera
  86937. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  86938. * @param input camera input method
  86939. */
  86940. add(input: ICameraInput<TCamera>): void;
  86941. /**
  86942. * Remove a specific input method from a camera
  86943. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  86944. * @param inputToRemove camera input method
  86945. */
  86946. remove(inputToRemove: ICameraInput<TCamera>): void;
  86947. /**
  86948. * Remove a specific input type from a camera
  86949. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  86950. * @param inputType the type of the input to remove
  86951. */
  86952. removeByType(inputType: string): void;
  86953. private _addCheckInputs;
  86954. /**
  86955. * Attach the input controls to the currently attached dom element to listen the events from.
  86956. * @param input Defines the input to attach
  86957. */
  86958. attachInput(input: ICameraInput<TCamera>): void;
  86959. /**
  86960. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  86961. * @param element Defines the dom element to collect the events from
  86962. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  86963. */
  86964. attachElement(element: HTMLElement, noPreventDefault?: boolean): void;
  86965. /**
  86966. * Detach the current manager inputs controls from a specific dom element.
  86967. * @param element Defines the dom element to collect the events from
  86968. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  86969. */
  86970. detachElement(element: HTMLElement, disconnect?: boolean): void;
  86971. /**
  86972. * Rebuild the dynamic inputCheck function from the current list of
  86973. * defined inputs in the manager.
  86974. */
  86975. rebuildInputCheck(): void;
  86976. /**
  86977. * Remove all attached input methods from a camera
  86978. */
  86979. clear(): void;
  86980. /**
  86981. * Serialize the current input manager attached to a camera.
  86982. * This ensures than once parsed,
  86983. * the input associated to the camera will be identical to the current ones
  86984. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  86985. */
  86986. serialize(serializedCamera: any): void;
  86987. /**
  86988. * Parses an input manager serialized JSON to restore the previous list of inputs
  86989. * and states associated to a camera.
  86990. * @param parsedCamera Defines the JSON to parse
  86991. */
  86992. parse(parsedCamera: any): void;
  86993. }
  86994. }
  86995. declare module BABYLON {
  86996. /**
  86997. * Class used to store data that will be store in GPU memory
  86998. */
  86999. export class Buffer {
  87000. private _engine;
  87001. private _buffer;
  87002. /** @hidden */
  87003. _data: Nullable<DataArray>;
  87004. private _updatable;
  87005. private _instanced;
  87006. private _divisor;
  87007. /**
  87008. * Gets the byte stride.
  87009. */
  87010. readonly byteStride: number;
  87011. /**
  87012. * Constructor
  87013. * @param engine the engine
  87014. * @param data the data to use for this buffer
  87015. * @param updatable whether the data is updatable
  87016. * @param stride the stride (optional)
  87017. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87018. * @param instanced whether the buffer is instanced (optional)
  87019. * @param useBytes set to true if the stride in in bytes (optional)
  87020. * @param divisor sets an optional divisor for instances (1 by default)
  87021. */
  87022. constructor(engine: any, data: DataArray, updatable: boolean, stride?: number, postponeInternalCreation?: boolean, instanced?: boolean, useBytes?: boolean, divisor?: number);
  87023. /**
  87024. * Create a new VertexBuffer based on the current buffer
  87025. * @param kind defines the vertex buffer kind (position, normal, etc.)
  87026. * @param offset defines offset in the buffer (0 by default)
  87027. * @param size defines the size in floats of attributes (position is 3 for instance)
  87028. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  87029. * @param instanced defines if the vertex buffer contains indexed data
  87030. * @param useBytes defines if the offset and stride are in bytes *
  87031. * @param divisor sets an optional divisor for instances (1 by default)
  87032. * @returns the new vertex buffer
  87033. */
  87034. createVertexBuffer(kind: string, offset: number, size: number, stride?: number, instanced?: boolean, useBytes?: boolean, divisor?: number): VertexBuffer;
  87035. /**
  87036. * Gets a boolean indicating if the Buffer is updatable?
  87037. * @returns true if the buffer is updatable
  87038. */
  87039. isUpdatable(): boolean;
  87040. /**
  87041. * Gets current buffer's data
  87042. * @returns a DataArray or null
  87043. */
  87044. getData(): Nullable<DataArray>;
  87045. /**
  87046. * Gets underlying native buffer
  87047. * @returns underlying native buffer
  87048. */
  87049. getBuffer(): Nullable<DataBuffer>;
  87050. /**
  87051. * Gets the stride in float32 units (i.e. byte stride / 4).
  87052. * May not be an integer if the byte stride is not divisible by 4.
  87053. * @returns the stride in float32 units
  87054. * @deprecated Please use byteStride instead.
  87055. */
  87056. getStrideSize(): number;
  87057. /**
  87058. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87059. * @param data defines the data to store
  87060. */
  87061. create(data?: Nullable<DataArray>): void;
  87062. /** @hidden */
  87063. _rebuild(): void;
  87064. /**
  87065. * Update current buffer data
  87066. * @param data defines the data to store
  87067. */
  87068. update(data: DataArray): void;
  87069. /**
  87070. * Updates the data directly.
  87071. * @param data the new data
  87072. * @param offset the new offset
  87073. * @param vertexCount the vertex count (optional)
  87074. * @param useBytes set to true if the offset is in bytes
  87075. */
  87076. updateDirectly(data: DataArray, offset: number, vertexCount?: number, useBytes?: boolean): void;
  87077. /**
  87078. * Release all resources
  87079. */
  87080. dispose(): void;
  87081. }
  87082. /**
  87083. * Specialized buffer used to store vertex data
  87084. */
  87085. export class VertexBuffer {
  87086. /** @hidden */
  87087. _buffer: Buffer;
  87088. private _kind;
  87089. private _size;
  87090. private _ownsBuffer;
  87091. private _instanced;
  87092. private _instanceDivisor;
  87093. /**
  87094. * The byte type.
  87095. */
  87096. static readonly BYTE: number;
  87097. /**
  87098. * The unsigned byte type.
  87099. */
  87100. static readonly UNSIGNED_BYTE: number;
  87101. /**
  87102. * The short type.
  87103. */
  87104. static readonly SHORT: number;
  87105. /**
  87106. * The unsigned short type.
  87107. */
  87108. static readonly UNSIGNED_SHORT: number;
  87109. /**
  87110. * The integer type.
  87111. */
  87112. static readonly INT: number;
  87113. /**
  87114. * The unsigned integer type.
  87115. */
  87116. static readonly UNSIGNED_INT: number;
  87117. /**
  87118. * The float type.
  87119. */
  87120. static readonly FLOAT: number;
  87121. /**
  87122. * Gets or sets the instance divisor when in instanced mode
  87123. */
  87124. get instanceDivisor(): number;
  87125. set instanceDivisor(value: number);
  87126. /**
  87127. * Gets the byte stride.
  87128. */
  87129. readonly byteStride: number;
  87130. /**
  87131. * Gets the byte offset.
  87132. */
  87133. readonly byteOffset: number;
  87134. /**
  87135. * Gets whether integer data values should be normalized into a certain range when being casted to a float.
  87136. */
  87137. readonly normalized: boolean;
  87138. /**
  87139. * Gets the data type of each component in the array.
  87140. */
  87141. readonly type: number;
  87142. /**
  87143. * Constructor
  87144. * @param engine the engine
  87145. * @param data the data to use for this vertex buffer
  87146. * @param kind the vertex buffer kind
  87147. * @param updatable whether the data is updatable
  87148. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  87149. * @param stride the stride (optional)
  87150. * @param instanced whether the buffer is instanced (optional)
  87151. * @param offset the offset of the data (optional)
  87152. * @param size the number of components (optional)
  87153. * @param type the type of the component (optional)
  87154. * @param normalized whether the data contains normalized data (optional)
  87155. * @param useBytes set to true if stride and offset are in bytes (optional)
  87156. * @param divisor defines the instance divisor to use (1 by default)
  87157. */
  87158. 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);
  87159. /** @hidden */
  87160. _rebuild(): void;
  87161. /**
  87162. * Returns the kind of the VertexBuffer (string)
  87163. * @returns a string
  87164. */
  87165. getKind(): string;
  87166. /**
  87167. * Gets a boolean indicating if the VertexBuffer is updatable?
  87168. * @returns true if the buffer is updatable
  87169. */
  87170. isUpdatable(): boolean;
  87171. /**
  87172. * Gets current buffer's data
  87173. * @returns a DataArray or null
  87174. */
  87175. getData(): Nullable<DataArray>;
  87176. /**
  87177. * Gets underlying native buffer
  87178. * @returns underlying native buffer
  87179. */
  87180. getBuffer(): Nullable<DataBuffer>;
  87181. /**
  87182. * Gets the stride in float32 units (i.e. byte stride / 4).
  87183. * May not be an integer if the byte stride is not divisible by 4.
  87184. * @returns the stride in float32 units
  87185. * @deprecated Please use byteStride instead.
  87186. */
  87187. getStrideSize(): number;
  87188. /**
  87189. * Returns the offset as a multiple of the type byte length.
  87190. * @returns the offset in bytes
  87191. * @deprecated Please use byteOffset instead.
  87192. */
  87193. getOffset(): number;
  87194. /**
  87195. * Returns the number of components per vertex attribute (integer)
  87196. * @returns the size in float
  87197. */
  87198. getSize(): number;
  87199. /**
  87200. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  87201. * @returns true if this buffer is instanced
  87202. */
  87203. getIsInstanced(): boolean;
  87204. /**
  87205. * Returns the instancing divisor, zero for non-instanced (integer).
  87206. * @returns a number
  87207. */
  87208. getInstanceDivisor(): number;
  87209. /**
  87210. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  87211. * @param data defines the data to store
  87212. */
  87213. create(data?: DataArray): void;
  87214. /**
  87215. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  87216. * This function will create a new buffer if the current one is not updatable
  87217. * @param data defines the data to store
  87218. */
  87219. update(data: DataArray): void;
  87220. /**
  87221. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  87222. * Returns the directly updated WebGLBuffer.
  87223. * @param data the new data
  87224. * @param offset the new offset
  87225. * @param useBytes set to true if the offset is in bytes
  87226. */
  87227. updateDirectly(data: DataArray, offset: number, useBytes?: boolean): void;
  87228. /**
  87229. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  87230. */
  87231. dispose(): void;
  87232. /**
  87233. * Enumerates each value of this vertex buffer as numbers.
  87234. * @param count the number of values to enumerate
  87235. * @param callback the callback function called for each value
  87236. */
  87237. forEach(count: number, callback: (value: number, index: number) => void): void;
  87238. /**
  87239. * Positions
  87240. */
  87241. static readonly PositionKind: string;
  87242. /**
  87243. * Normals
  87244. */
  87245. static readonly NormalKind: string;
  87246. /**
  87247. * Tangents
  87248. */
  87249. static readonly TangentKind: string;
  87250. /**
  87251. * Texture coordinates
  87252. */
  87253. static readonly UVKind: string;
  87254. /**
  87255. * Texture coordinates 2
  87256. */
  87257. static readonly UV2Kind: string;
  87258. /**
  87259. * Texture coordinates 3
  87260. */
  87261. static readonly UV3Kind: string;
  87262. /**
  87263. * Texture coordinates 4
  87264. */
  87265. static readonly UV4Kind: string;
  87266. /**
  87267. * Texture coordinates 5
  87268. */
  87269. static readonly UV5Kind: string;
  87270. /**
  87271. * Texture coordinates 6
  87272. */
  87273. static readonly UV6Kind: string;
  87274. /**
  87275. * Colors
  87276. */
  87277. static readonly ColorKind: string;
  87278. /**
  87279. * Matrix indices (for bones)
  87280. */
  87281. static readonly MatricesIndicesKind: string;
  87282. /**
  87283. * Matrix weights (for bones)
  87284. */
  87285. static readonly MatricesWeightsKind: string;
  87286. /**
  87287. * Additional matrix indices (for bones)
  87288. */
  87289. static readonly MatricesIndicesExtraKind: string;
  87290. /**
  87291. * Additional matrix weights (for bones)
  87292. */
  87293. static readonly MatricesWeightsExtraKind: string;
  87294. /**
  87295. * Deduces the stride given a kind.
  87296. * @param kind The kind string to deduce
  87297. * @returns The deduced stride
  87298. */
  87299. static DeduceStride(kind: string): number;
  87300. /**
  87301. * Gets the byte length of the given type.
  87302. * @param type the type
  87303. * @returns the number of bytes
  87304. */
  87305. static GetTypeByteLength(type: number): number;
  87306. /**
  87307. * Enumerates each value of the given parameters as numbers.
  87308. * @param data the data to enumerate
  87309. * @param byteOffset the byte offset of the data
  87310. * @param byteStride the byte stride of the data
  87311. * @param componentCount the number of components per element
  87312. * @param componentType the type of the component
  87313. * @param count the number of values to enumerate
  87314. * @param normalized whether the data is normalized
  87315. * @param callback the callback function called for each value
  87316. */
  87317. static ForEach(data: DataArray, byteOffset: number, byteStride: number, componentCount: number, componentType: number, count: number, normalized: boolean, callback: (value: number, index: number) => void): void;
  87318. private static _GetFloatValue;
  87319. }
  87320. }
  87321. declare module BABYLON {
  87322. /**
  87323. * The options Interface for creating a Capsule Mesh
  87324. */
  87325. export interface ICreateCapsuleOptions {
  87326. /** The Orientation of the capsule. Default : Vector3.Up() */
  87327. orientation?: Vector3;
  87328. /** Number of sub segments on the tube section of the capsule running parallel to orientation. */
  87329. subdivisions: number;
  87330. /** Number of cylindrical segments on the capsule. */
  87331. tessellation: number;
  87332. /** Height or Length of the capsule. */
  87333. height: number;
  87334. /** Radius of the capsule. */
  87335. radius: number;
  87336. /** Number of sub segments on the cap sections of the capsule running parallel to orientation. */
  87337. capSubdivisions: number;
  87338. /** Overwrite for the top radius. */
  87339. radiusTop?: number;
  87340. /** Overwrite for the bottom radius. */
  87341. radiusBottom?: number;
  87342. /** Overwrite for the top capSubdivisions. */
  87343. topCapSubdivisions?: number;
  87344. /** Overwrite for the bottom capSubdivisions. */
  87345. bottomCapSubdivisions?: number;
  87346. }
  87347. /**
  87348. * Class containing static functions to help procedurally build meshes
  87349. */
  87350. export class CapsuleBuilder {
  87351. /**
  87352. * Creates a capsule or a pill mesh
  87353. * @param name defines the name of the mesh
  87354. * @param options The constructors options.
  87355. * @param scene The scene the mesh is scoped to.
  87356. * @returns Capsule Mesh
  87357. */
  87358. static CreateCapsule(name: string, options: ICreateCapsuleOptions | undefined, scene: any): Mesh;
  87359. }
  87360. }
  87361. declare module BABYLON {
  87362. /**
  87363. * @hidden
  87364. */
  87365. export class IntersectionInfo {
  87366. bu: Nullable<number>;
  87367. bv: Nullable<number>;
  87368. distance: number;
  87369. faceId: number;
  87370. subMeshId: number;
  87371. constructor(bu: Nullable<number>, bv: Nullable<number>, distance: number);
  87372. }
  87373. }
  87374. declare module BABYLON {
  87375. /**
  87376. * Class used to store bounding sphere information
  87377. */
  87378. export class BoundingSphere {
  87379. /**
  87380. * Gets the center of the bounding sphere in local space
  87381. */
  87382. readonly center: Vector3;
  87383. /**
  87384. * Radius of the bounding sphere in local space
  87385. */
  87386. radius: number;
  87387. /**
  87388. * Gets the center of the bounding sphere in world space
  87389. */
  87390. readonly centerWorld: Vector3;
  87391. /**
  87392. * Radius of the bounding sphere in world space
  87393. */
  87394. radiusWorld: number;
  87395. /**
  87396. * Gets the minimum vector in local space
  87397. */
  87398. readonly minimum: Vector3;
  87399. /**
  87400. * Gets the maximum vector in local space
  87401. */
  87402. readonly maximum: Vector3;
  87403. private _worldMatrix;
  87404. private static readonly TmpVector3;
  87405. /**
  87406. * Creates a new bounding sphere
  87407. * @param min defines the minimum vector (in local space)
  87408. * @param max defines the maximum vector (in local space)
  87409. * @param worldMatrix defines the new world matrix
  87410. */
  87411. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87412. /**
  87413. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  87414. * @param min defines the new minimum vector (in local space)
  87415. * @param max defines the new maximum vector (in local space)
  87416. * @param worldMatrix defines the new world matrix
  87417. */
  87418. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87419. /**
  87420. * Scale the current bounding sphere by applying a scale factor
  87421. * @param factor defines the scale factor to apply
  87422. * @returns the current bounding box
  87423. */
  87424. scale(factor: number): BoundingSphere;
  87425. /**
  87426. * Gets the world matrix of the bounding box
  87427. * @returns a matrix
  87428. */
  87429. getWorldMatrix(): DeepImmutable<Matrix>;
  87430. /** @hidden */
  87431. _update(worldMatrix: DeepImmutable<Matrix>): void;
  87432. /**
  87433. * Tests if the bounding sphere is intersecting the frustum planes
  87434. * @param frustumPlanes defines the frustum planes to test
  87435. * @returns true if there is an intersection
  87436. */
  87437. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87438. /**
  87439. * Tests if the bounding sphere center is in between the frustum planes.
  87440. * Used for optimistic fast inclusion.
  87441. * @param frustumPlanes defines the frustum planes to test
  87442. * @returns true if the sphere center is in between the frustum planes
  87443. */
  87444. isCenterInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87445. /**
  87446. * Tests if a point is inside the bounding sphere
  87447. * @param point defines the point to test
  87448. * @returns true if the point is inside the bounding sphere
  87449. */
  87450. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87451. /**
  87452. * Checks if two sphere intersct
  87453. * @param sphere0 sphere 0
  87454. * @param sphere1 sphere 1
  87455. * @returns true if the speres intersect
  87456. */
  87457. static Intersects(sphere0: DeepImmutable<BoundingSphere>, sphere1: DeepImmutable<BoundingSphere>): boolean;
  87458. }
  87459. }
  87460. declare module BABYLON {
  87461. /**
  87462. * Class used to store bounding box information
  87463. */
  87464. export class BoundingBox implements ICullable {
  87465. /**
  87466. * Gets the 8 vectors representing the bounding box in local space
  87467. */
  87468. readonly vectors: Vector3[];
  87469. /**
  87470. * Gets the center of the bounding box in local space
  87471. */
  87472. readonly center: Vector3;
  87473. /**
  87474. * Gets the center of the bounding box in world space
  87475. */
  87476. readonly centerWorld: Vector3;
  87477. /**
  87478. * Gets the extend size in local space
  87479. */
  87480. readonly extendSize: Vector3;
  87481. /**
  87482. * Gets the extend size in world space
  87483. */
  87484. readonly extendSizeWorld: Vector3;
  87485. /**
  87486. * Gets the OBB (object bounding box) directions
  87487. */
  87488. readonly directions: Vector3[];
  87489. /**
  87490. * Gets the 8 vectors representing the bounding box in world space
  87491. */
  87492. readonly vectorsWorld: Vector3[];
  87493. /**
  87494. * Gets the minimum vector in world space
  87495. */
  87496. readonly minimumWorld: Vector3;
  87497. /**
  87498. * Gets the maximum vector in world space
  87499. */
  87500. readonly maximumWorld: Vector3;
  87501. /**
  87502. * Gets the minimum vector in local space
  87503. */
  87504. readonly minimum: Vector3;
  87505. /**
  87506. * Gets the maximum vector in local space
  87507. */
  87508. readonly maximum: Vector3;
  87509. private _worldMatrix;
  87510. private static readonly TmpVector3;
  87511. /**
  87512. * @hidden
  87513. */
  87514. _tag: number;
  87515. /**
  87516. * Creates a new bounding box
  87517. * @param min defines the minimum vector (in local space)
  87518. * @param max defines the maximum vector (in local space)
  87519. * @param worldMatrix defines the new world matrix
  87520. */
  87521. constructor(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87522. /**
  87523. * Recreates the entire bounding box from scratch as if we call the constructor in place
  87524. * @param min defines the new minimum vector (in local space)
  87525. * @param max defines the new maximum vector (in local space)
  87526. * @param worldMatrix defines the new world matrix
  87527. */
  87528. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87529. /**
  87530. * Scale the current bounding box by applying a scale factor
  87531. * @param factor defines the scale factor to apply
  87532. * @returns the current bounding box
  87533. */
  87534. scale(factor: number): BoundingBox;
  87535. /**
  87536. * Gets the world matrix of the bounding box
  87537. * @returns a matrix
  87538. */
  87539. getWorldMatrix(): DeepImmutable<Matrix>;
  87540. /** @hidden */
  87541. _update(world: DeepImmutable<Matrix>): void;
  87542. /**
  87543. * Tests if the bounding box is intersecting the frustum planes
  87544. * @param frustumPlanes defines the frustum planes to test
  87545. * @returns true if there is an intersection
  87546. */
  87547. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87548. /**
  87549. * Tests if the bounding box is entirely inside the frustum planes
  87550. * @param frustumPlanes defines the frustum planes to test
  87551. * @returns true if there is an inclusion
  87552. */
  87553. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87554. /**
  87555. * Tests if a point is inside the bounding box
  87556. * @param point defines the point to test
  87557. * @returns true if the point is inside the bounding box
  87558. */
  87559. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87560. /**
  87561. * Tests if the bounding box intersects with a bounding sphere
  87562. * @param sphere defines the sphere to test
  87563. * @returns true if there is an intersection
  87564. */
  87565. intersectsSphere(sphere: DeepImmutable<BoundingSphere>): boolean;
  87566. /**
  87567. * Tests if the bounding box intersects with a box defined by a min and max vectors
  87568. * @param min defines the min vector to use
  87569. * @param max defines the max vector to use
  87570. * @returns true if there is an intersection
  87571. */
  87572. intersectsMinMax(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>): boolean;
  87573. /**
  87574. * Tests if two bounding boxes are intersections
  87575. * @param box0 defines the first box to test
  87576. * @param box1 defines the second box to test
  87577. * @returns true if there is an intersection
  87578. */
  87579. static Intersects(box0: DeepImmutable<BoundingBox>, box1: DeepImmutable<BoundingBox>): boolean;
  87580. /**
  87581. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  87582. * @param minPoint defines the minimum vector of the bounding box
  87583. * @param maxPoint defines the maximum vector of the bounding box
  87584. * @param sphereCenter defines the sphere center
  87585. * @param sphereRadius defines the sphere radius
  87586. * @returns true if there is an intersection
  87587. */
  87588. static IntersectsSphere(minPoint: DeepImmutable<Vector3>, maxPoint: DeepImmutable<Vector3>, sphereCenter: DeepImmutable<Vector3>, sphereRadius: number): boolean;
  87589. /**
  87590. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  87591. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87592. * @param frustumPlanes defines the frustum planes to test
  87593. * @return true if there is an inclusion
  87594. */
  87595. static IsCompletelyInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87596. /**
  87597. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  87598. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  87599. * @param frustumPlanes defines the frustum planes to test
  87600. * @return true if there is an intersection
  87601. */
  87602. static IsInFrustum(boundingVectors: Array<DeepImmutable<Vector3>>, frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87603. }
  87604. }
  87605. declare module BABYLON {
  87606. /** @hidden */
  87607. export class Collider {
  87608. /** Define if a collision was found */
  87609. collisionFound: boolean;
  87610. /**
  87611. * Define last intersection point in local space
  87612. */
  87613. intersectionPoint: Vector3;
  87614. /**
  87615. * Define last collided mesh
  87616. */
  87617. collidedMesh: Nullable<AbstractMesh>;
  87618. private _collisionPoint;
  87619. private _planeIntersectionPoint;
  87620. private _tempVector;
  87621. private _tempVector2;
  87622. private _tempVector3;
  87623. private _tempVector4;
  87624. private _edge;
  87625. private _baseToVertex;
  87626. private _destinationPoint;
  87627. private _slidePlaneNormal;
  87628. private _displacementVector;
  87629. /** @hidden */
  87630. _radius: Vector3;
  87631. /** @hidden */
  87632. _retry: number;
  87633. private _velocity;
  87634. private _basePoint;
  87635. private _epsilon;
  87636. /** @hidden */
  87637. _velocityWorldLength: number;
  87638. /** @hidden */
  87639. _basePointWorld: Vector3;
  87640. private _velocityWorld;
  87641. private _normalizedVelocity;
  87642. /** @hidden */
  87643. _initialVelocity: Vector3;
  87644. /** @hidden */
  87645. _initialPosition: Vector3;
  87646. private _nearestDistance;
  87647. private _collisionMask;
  87648. get collisionMask(): number;
  87649. set collisionMask(mask: number);
  87650. /**
  87651. * Gets the plane normal used to compute the sliding response (in local space)
  87652. */
  87653. get slidePlaneNormal(): Vector3;
  87654. /** @hidden */
  87655. _initialize(source: Vector3, dir: Vector3, e: number): void;
  87656. /** @hidden */
  87657. _checkPointInTriangle(point: Vector3, pa: Vector3, pb: Vector3, pc: Vector3, n: Vector3): boolean;
  87658. /** @hidden */
  87659. _canDoCollision(sphereCenter: Vector3, sphereRadius: number, vecMin: Vector3, vecMax: Vector3): boolean;
  87660. /** @hidden */
  87661. _testTriangle(faceIndex: number, trianglePlaneArray: Array<Plane>, p1: Vector3, p2: Vector3, p3: Vector3, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87662. /** @hidden */
  87663. _collide(trianglePlaneArray: Array<Plane>, pts: Vector3[], indices: IndicesArray, indexStart: number, indexEnd: number, decal: number, hasMaterial: boolean, hostMesh: AbstractMesh): void;
  87664. /** @hidden */
  87665. _getResponse(pos: Vector3, vel: Vector3): void;
  87666. }
  87667. }
  87668. declare module BABYLON {
  87669. /**
  87670. * Interface for cullable objects
  87671. * @see https://doc.babylonjs.com/babylon101/materials#back-face-culling
  87672. */
  87673. export interface ICullable {
  87674. /**
  87675. * Checks if the object or part of the object is in the frustum
  87676. * @param frustumPlanes Camera near/planes
  87677. * @returns true if the object is in frustum otherwise false
  87678. */
  87679. isInFrustum(frustumPlanes: Plane[]): boolean;
  87680. /**
  87681. * Checks if a cullable object (mesh...) is in the camera frustum
  87682. * Unlike isInFrustum this cheks the full bounding box
  87683. * @param frustumPlanes Camera near/planes
  87684. * @returns true if the object is in frustum otherwise false
  87685. */
  87686. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  87687. }
  87688. /**
  87689. * Info for a bounding data of a mesh
  87690. */
  87691. export class BoundingInfo implements ICullable {
  87692. /**
  87693. * Bounding box for the mesh
  87694. */
  87695. readonly boundingBox: BoundingBox;
  87696. /**
  87697. * Bounding sphere for the mesh
  87698. */
  87699. readonly boundingSphere: BoundingSphere;
  87700. private _isLocked;
  87701. private static readonly TmpVector3;
  87702. /**
  87703. * Constructs bounding info
  87704. * @param minimum min vector of the bounding box/sphere
  87705. * @param maximum max vector of the bounding box/sphere
  87706. * @param worldMatrix defines the new world matrix
  87707. */
  87708. constructor(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>);
  87709. /**
  87710. * Recreates the entire bounding info from scratch as if we call the constructor in place
  87711. * @param min defines the new minimum vector (in local space)
  87712. * @param max defines the new maximum vector (in local space)
  87713. * @param worldMatrix defines the new world matrix
  87714. */
  87715. reConstruct(min: DeepImmutable<Vector3>, max: DeepImmutable<Vector3>, worldMatrix?: DeepImmutable<Matrix>): void;
  87716. /**
  87717. * min vector of the bounding box/sphere
  87718. */
  87719. get minimum(): Vector3;
  87720. /**
  87721. * max vector of the bounding box/sphere
  87722. */
  87723. get maximum(): Vector3;
  87724. /**
  87725. * If the info is locked and won't be updated to avoid perf overhead
  87726. */
  87727. get isLocked(): boolean;
  87728. set isLocked(value: boolean);
  87729. /**
  87730. * Updates the bounding sphere and box
  87731. * @param world world matrix to be used to update
  87732. */
  87733. update(world: DeepImmutable<Matrix>): void;
  87734. /**
  87735. * Recreate the bounding info to be centered around a specific point given a specific extend.
  87736. * @param center New center of the bounding info
  87737. * @param extend New extend of the bounding info
  87738. * @returns the current bounding info
  87739. */
  87740. centerOn(center: DeepImmutable<Vector3>, extend: DeepImmutable<Vector3>): BoundingInfo;
  87741. /**
  87742. * Scale the current bounding info by applying a scale factor
  87743. * @param factor defines the scale factor to apply
  87744. * @returns the current bounding info
  87745. */
  87746. scale(factor: number): BoundingInfo;
  87747. /**
  87748. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  87749. * @param frustumPlanes defines the frustum to test
  87750. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  87751. * @returns true if the bounding info is in the frustum planes
  87752. */
  87753. isInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>, strategy?: number): boolean;
  87754. /**
  87755. * Gets the world distance between the min and max points of the bounding box
  87756. */
  87757. get diagonalLength(): number;
  87758. /**
  87759. * Checks if a cullable object (mesh...) is in the camera frustum
  87760. * Unlike isInFrustum this cheks the full bounding box
  87761. * @param frustumPlanes Camera near/planes
  87762. * @returns true if the object is in frustum otherwise false
  87763. */
  87764. isCompletelyInFrustum(frustumPlanes: Array<DeepImmutable<Plane>>): boolean;
  87765. /** @hidden */
  87766. _checkCollision(collider: Collider): boolean;
  87767. /**
  87768. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  87769. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87770. * @param point the point to check intersection with
  87771. * @returns if the point intersects
  87772. */
  87773. intersectsPoint(point: DeepImmutable<Vector3>): boolean;
  87774. /**
  87775. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  87776. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  87777. * @param boundingInfo the bounding info to check intersection with
  87778. * @param precise if the intersection should be done using OBB
  87779. * @returns if the bounding info intersects
  87780. */
  87781. intersects(boundingInfo: DeepImmutable<BoundingInfo>, precise: boolean): boolean;
  87782. }
  87783. }
  87784. declare module BABYLON {
  87785. /**
  87786. * Extracts minimum and maximum values from a list of indexed positions
  87787. * @param positions defines the positions to use
  87788. * @param indices defines the indices to the positions
  87789. * @param indexStart defines the start index
  87790. * @param indexCount defines the end index
  87791. * @param bias defines bias value to add to the result
  87792. * @return minimum and maximum values
  87793. */
  87794. export function extractMinAndMaxIndexed(positions: FloatArray, indices: IndicesArray, indexStart: number, indexCount: number, bias?: Nullable<Vector2>): {
  87795. minimum: Vector3;
  87796. maximum: Vector3;
  87797. };
  87798. /**
  87799. * Extracts minimum and maximum values from a list of positions
  87800. * @param positions defines the positions to use
  87801. * @param start defines the start index in the positions array
  87802. * @param count defines the number of positions to handle
  87803. * @param bias defines bias value to add to the result
  87804. * @param stride defines the stride size to use (distance between two positions in the positions array)
  87805. * @return minimum and maximum values
  87806. */
  87807. export function extractMinAndMax(positions: FloatArray, start: number, count: number, bias?: Nullable<Vector2>, stride?: number): {
  87808. minimum: Vector3;
  87809. maximum: Vector3;
  87810. };
  87811. }
  87812. declare module BABYLON {
  87813. /** @hidden */
  87814. export class WebGLDataBuffer extends DataBuffer {
  87815. private _buffer;
  87816. constructor(resource: WebGLBuffer);
  87817. get underlyingResource(): any;
  87818. }
  87819. }
  87820. declare module BABYLON {
  87821. /** @hidden */
  87822. export class WebGLPipelineContext implements IPipelineContext {
  87823. engine: ThinEngine;
  87824. program: Nullable<WebGLProgram>;
  87825. context?: WebGLRenderingContext;
  87826. vertexShader?: WebGLShader;
  87827. fragmentShader?: WebGLShader;
  87828. isParallelCompiled: boolean;
  87829. onCompiled?: () => void;
  87830. transformFeedback?: WebGLTransformFeedback | null;
  87831. vertexCompilationError: Nullable<string>;
  87832. fragmentCompilationError: Nullable<string>;
  87833. programLinkError: Nullable<string>;
  87834. programValidationError: Nullable<string>;
  87835. get isAsync(): boolean;
  87836. get isReady(): boolean;
  87837. _handlesSpectorRebuildCallback(onCompiled: (program: WebGLProgram) => void): void;
  87838. _getVertexShaderCode(): string | null;
  87839. _getFragmentShaderCode(): string | null;
  87840. }
  87841. }
  87842. declare module BABYLON {
  87843. interface ThinEngine {
  87844. /**
  87845. * Create an uniform buffer
  87846. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87847. * @param elements defines the content of the uniform buffer
  87848. * @returns the webGL uniform buffer
  87849. */
  87850. createUniformBuffer(elements: FloatArray): DataBuffer;
  87851. /**
  87852. * Create a dynamic uniform buffer
  87853. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87854. * @param elements defines the content of the uniform buffer
  87855. * @returns the webGL uniform buffer
  87856. */
  87857. createDynamicUniformBuffer(elements: FloatArray): DataBuffer;
  87858. /**
  87859. * Update an existing uniform buffer
  87860. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  87861. * @param uniformBuffer defines the target uniform buffer
  87862. * @param elements defines the content to update
  87863. * @param offset defines the offset in the uniform buffer where update should start
  87864. * @param count defines the size of the data to update
  87865. */
  87866. updateUniformBuffer(uniformBuffer: DataBuffer, elements: FloatArray, offset?: number, count?: number): void;
  87867. /**
  87868. * Bind an uniform buffer to the current webGL context
  87869. * @param buffer defines the buffer to bind
  87870. */
  87871. bindUniformBuffer(buffer: Nullable<DataBuffer>): void;
  87872. /**
  87873. * Bind a buffer to the current webGL context at a given location
  87874. * @param buffer defines the buffer to bind
  87875. * @param location defines the index where to bind the buffer
  87876. */
  87877. bindUniformBufferBase(buffer: DataBuffer, location: number): void;
  87878. /**
  87879. * Bind a specific block at a given index in a specific shader program
  87880. * @param pipelineContext defines the pipeline context to use
  87881. * @param blockName defines the block name
  87882. * @param index defines the index where to bind the block
  87883. */
  87884. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  87885. }
  87886. }
  87887. declare module BABYLON {
  87888. /**
  87889. * Uniform buffer objects.
  87890. *
  87891. * Handles blocks of uniform on the GPU.
  87892. *
  87893. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87894. *
  87895. * For more information, please refer to :
  87896. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87897. */
  87898. export class UniformBuffer {
  87899. private _engine;
  87900. private _buffer;
  87901. private _data;
  87902. private _bufferData;
  87903. private _dynamic?;
  87904. private _uniformLocations;
  87905. private _uniformSizes;
  87906. private _uniformLocationPointer;
  87907. private _needSync;
  87908. private _noUBO;
  87909. private _currentEffect;
  87910. /** @hidden */
  87911. _alreadyBound: boolean;
  87912. private static _MAX_UNIFORM_SIZE;
  87913. private static _tempBuffer;
  87914. /**
  87915. * Lambda to Update a 3x3 Matrix in a uniform buffer.
  87916. * This is dynamic to allow compat with webgl 1 and 2.
  87917. * You will need to pass the name of the uniform as well as the value.
  87918. */
  87919. updateMatrix3x3: (name: string, matrix: Float32Array) => void;
  87920. /**
  87921. * Lambda to Update a 2x2 Matrix in a uniform buffer.
  87922. * This is dynamic to allow compat with webgl 1 and 2.
  87923. * You will need to pass the name of the uniform as well as the value.
  87924. */
  87925. updateMatrix2x2: (name: string, matrix: Float32Array) => void;
  87926. /**
  87927. * Lambda to Update a single float in a uniform buffer.
  87928. * This is dynamic to allow compat with webgl 1 and 2.
  87929. * You will need to pass the name of the uniform as well as the value.
  87930. */
  87931. updateFloat: (name: string, x: number) => void;
  87932. /**
  87933. * Lambda to Update a vec2 of float in a uniform buffer.
  87934. * This is dynamic to allow compat with webgl 1 and 2.
  87935. * You will need to pass the name of the uniform as well as the value.
  87936. */
  87937. updateFloat2: (name: string, x: number, y: number, suffix?: string) => void;
  87938. /**
  87939. * Lambda to Update a vec3 of float in a uniform buffer.
  87940. * This is dynamic to allow compat with webgl 1 and 2.
  87941. * You will need to pass the name of the uniform as well as the value.
  87942. */
  87943. updateFloat3: (name: string, x: number, y: number, z: number, suffix?: string) => void;
  87944. /**
  87945. * Lambda to Update a vec4 of float in a uniform buffer.
  87946. * This is dynamic to allow compat with webgl 1 and 2.
  87947. * You will need to pass the name of the uniform as well as the value.
  87948. */
  87949. updateFloat4: (name: string, x: number, y: number, z: number, w: number, suffix?: string) => void;
  87950. /**
  87951. * Lambda to Update a 4x4 Matrix in a uniform buffer.
  87952. * This is dynamic to allow compat with webgl 1 and 2.
  87953. * You will need to pass the name of the uniform as well as the value.
  87954. */
  87955. updateMatrix: (name: string, mat: Matrix) => void;
  87956. /**
  87957. * Lambda to Update vec3 of float from a Vector in a uniform buffer.
  87958. * This is dynamic to allow compat with webgl 1 and 2.
  87959. * You will need to pass the name of the uniform as well as the value.
  87960. */
  87961. updateVector3: (name: string, vector: Vector3) => void;
  87962. /**
  87963. * Lambda to Update vec4 of float from a Vector in a uniform buffer.
  87964. * This is dynamic to allow compat with webgl 1 and 2.
  87965. * You will need to pass the name of the uniform as well as the value.
  87966. */
  87967. updateVector4: (name: string, vector: Vector4) => void;
  87968. /**
  87969. * Lambda to Update vec3 of float from a Color in a uniform buffer.
  87970. * This is dynamic to allow compat with webgl 1 and 2.
  87971. * You will need to pass the name of the uniform as well as the value.
  87972. */
  87973. updateColor3: (name: string, color: Color3, suffix?: string) => void;
  87974. /**
  87975. * Lambda to Update vec4 of float from a Color in a uniform buffer.
  87976. * This is dynamic to allow compat with webgl 1 and 2.
  87977. * You will need to pass the name of the uniform as well as the value.
  87978. */
  87979. updateColor4: (name: string, color: Color3, alpha: number, suffix?: string) => void;
  87980. /**
  87981. * Instantiates a new Uniform buffer objects.
  87982. *
  87983. * Handles blocks of uniform on the GPU.
  87984. *
  87985. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  87986. *
  87987. * For more information, please refer to :
  87988. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  87989. * @param engine Define the engine the buffer is associated with
  87990. * @param data Define the data contained in the buffer
  87991. * @param dynamic Define if the buffer is updatable
  87992. */
  87993. constructor(engine: Engine, data?: number[], dynamic?: boolean);
  87994. /**
  87995. * Indicates if the buffer is using the WebGL2 UBO implementation,
  87996. * or just falling back on setUniformXXX calls.
  87997. */
  87998. get useUbo(): boolean;
  87999. /**
  88000. * Indicates if the WebGL underlying uniform buffer is in sync
  88001. * with the javascript cache data.
  88002. */
  88003. get isSync(): boolean;
  88004. /**
  88005. * Indicates if the WebGL underlying uniform buffer is dynamic.
  88006. * Also, a dynamic UniformBuffer will disable cache verification and always
  88007. * update the underlying WebGL uniform buffer to the GPU.
  88008. * @returns if Dynamic, otherwise false
  88009. */
  88010. isDynamic(): boolean;
  88011. /**
  88012. * The data cache on JS side.
  88013. * @returns the underlying data as a float array
  88014. */
  88015. getData(): Float32Array;
  88016. /**
  88017. * The underlying WebGL Uniform buffer.
  88018. * @returns the webgl buffer
  88019. */
  88020. getBuffer(): Nullable<DataBuffer>;
  88021. /**
  88022. * std140 layout specifies how to align data within an UBO structure.
  88023. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  88024. * for specs.
  88025. */
  88026. private _fillAlignment;
  88027. /**
  88028. * Adds an uniform in the buffer.
  88029. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  88030. * for the layout to be correct !
  88031. * @param name Name of the uniform, as used in the uniform block in the shader.
  88032. * @param size Data size, or data directly.
  88033. */
  88034. addUniform(name: string, size: number | number[]): void;
  88035. /**
  88036. * Adds a Matrix 4x4 to the uniform buffer.
  88037. * @param name Name of the uniform, as used in the uniform block in the shader.
  88038. * @param mat A 4x4 matrix.
  88039. */
  88040. addMatrix(name: string, mat: Matrix): void;
  88041. /**
  88042. * Adds a vec2 to the uniform buffer.
  88043. * @param name Name of the uniform, as used in the uniform block in the shader.
  88044. * @param x Define the x component value of the vec2
  88045. * @param y Define the y component value of the vec2
  88046. */
  88047. addFloat2(name: string, x: number, y: number): void;
  88048. /**
  88049. * Adds a vec3 to the uniform buffer.
  88050. * @param name Name of the uniform, as used in the uniform block in the shader.
  88051. * @param x Define the x component value of the vec3
  88052. * @param y Define the y component value of the vec3
  88053. * @param z Define the z component value of the vec3
  88054. */
  88055. addFloat3(name: string, x: number, y: number, z: number): void;
  88056. /**
  88057. * Adds a vec3 to the uniform buffer.
  88058. * @param name Name of the uniform, as used in the uniform block in the shader.
  88059. * @param color Define the vec3 from a Color
  88060. */
  88061. addColor3(name: string, color: Color3): void;
  88062. /**
  88063. * Adds a vec4 to the uniform buffer.
  88064. * @param name Name of the uniform, as used in the uniform block in the shader.
  88065. * @param color Define the rgb components from a Color
  88066. * @param alpha Define the a component of the vec4
  88067. */
  88068. addColor4(name: string, color: Color3, alpha: number): void;
  88069. /**
  88070. * Adds a vec3 to the uniform buffer.
  88071. * @param name Name of the uniform, as used in the uniform block in the shader.
  88072. * @param vector Define the vec3 components from a Vector
  88073. */
  88074. addVector3(name: string, vector: Vector3): void;
  88075. /**
  88076. * Adds a Matrix 3x3 to the uniform buffer.
  88077. * @param name Name of the uniform, as used in the uniform block in the shader.
  88078. */
  88079. addMatrix3x3(name: string): void;
  88080. /**
  88081. * Adds a Matrix 2x2 to the uniform buffer.
  88082. * @param name Name of the uniform, as used in the uniform block in the shader.
  88083. */
  88084. addMatrix2x2(name: string): void;
  88085. /**
  88086. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  88087. */
  88088. create(): void;
  88089. /** @hidden */
  88090. _rebuild(): void;
  88091. /**
  88092. * Updates the WebGL Uniform Buffer on the GPU.
  88093. * If the `dynamic` flag is set to true, no cache comparison is done.
  88094. * Otherwise, the buffer will be updated only if the cache differs.
  88095. */
  88096. update(): void;
  88097. /**
  88098. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  88099. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88100. * @param data Define the flattened data
  88101. * @param size Define the size of the data.
  88102. */
  88103. updateUniform(uniformName: string, data: FloatArray, size: number): void;
  88104. private _valueCache;
  88105. private _cacheMatrix;
  88106. private _updateMatrix3x3ForUniform;
  88107. private _updateMatrix3x3ForEffect;
  88108. private _updateMatrix2x2ForEffect;
  88109. private _updateMatrix2x2ForUniform;
  88110. private _updateFloatForEffect;
  88111. private _updateFloatForUniform;
  88112. private _updateFloat2ForEffect;
  88113. private _updateFloat2ForUniform;
  88114. private _updateFloat3ForEffect;
  88115. private _updateFloat3ForUniform;
  88116. private _updateFloat4ForEffect;
  88117. private _updateFloat4ForUniform;
  88118. private _updateMatrixForEffect;
  88119. private _updateMatrixForUniform;
  88120. private _updateVector3ForEffect;
  88121. private _updateVector3ForUniform;
  88122. private _updateVector4ForEffect;
  88123. private _updateVector4ForUniform;
  88124. private _updateColor3ForEffect;
  88125. private _updateColor3ForUniform;
  88126. private _updateColor4ForEffect;
  88127. private _updateColor4ForUniform;
  88128. /**
  88129. * Sets a sampler uniform on the effect.
  88130. * @param name Define the name of the sampler.
  88131. * @param texture Define the texture to set in the sampler
  88132. */
  88133. setTexture(name: string, texture: Nullable<BaseTexture>): void;
  88134. /**
  88135. * Directly updates the value of the uniform in the cache AND on the GPU.
  88136. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  88137. * @param data Define the flattened data
  88138. */
  88139. updateUniformDirectly(uniformName: string, data: FloatArray): void;
  88140. /**
  88141. * Binds this uniform buffer to an effect.
  88142. * @param effect Define the effect to bind the buffer to
  88143. * @param name Name of the uniform block in the shader.
  88144. */
  88145. bindToEffect(effect: Effect, name: string): void;
  88146. /**
  88147. * Disposes the uniform buffer.
  88148. */
  88149. dispose(): void;
  88150. }
  88151. }
  88152. declare module BABYLON {
  88153. /**
  88154. * Enum that determines the text-wrapping mode to use.
  88155. */
  88156. export enum InspectableType {
  88157. /**
  88158. * Checkbox for booleans
  88159. */
  88160. Checkbox = 0,
  88161. /**
  88162. * Sliders for numbers
  88163. */
  88164. Slider = 1,
  88165. /**
  88166. * Vector3
  88167. */
  88168. Vector3 = 2,
  88169. /**
  88170. * Quaternions
  88171. */
  88172. Quaternion = 3,
  88173. /**
  88174. * Color3
  88175. */
  88176. Color3 = 4,
  88177. /**
  88178. * String
  88179. */
  88180. String = 5
  88181. }
  88182. /**
  88183. * Interface used to define custom inspectable properties.
  88184. * This interface is used by the inspector to display custom property grids
  88185. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  88186. */
  88187. export interface IInspectable {
  88188. /**
  88189. * Gets the label to display
  88190. */
  88191. label: string;
  88192. /**
  88193. * Gets the name of the property to edit
  88194. */
  88195. propertyName: string;
  88196. /**
  88197. * Gets the type of the editor to use
  88198. */
  88199. type: InspectableType;
  88200. /**
  88201. * Gets the minimum value of the property when using in "slider" mode
  88202. */
  88203. min?: number;
  88204. /**
  88205. * Gets the maximum value of the property when using in "slider" mode
  88206. */
  88207. max?: number;
  88208. /**
  88209. * Gets the setp to use when using in "slider" mode
  88210. */
  88211. step?: number;
  88212. }
  88213. }
  88214. declare module BABYLON {
  88215. /**
  88216. * Class used to provide helper for timing
  88217. */
  88218. export class TimingTools {
  88219. /**
  88220. * Polyfill for setImmediate
  88221. * @param action defines the action to execute after the current execution block
  88222. */
  88223. static SetImmediate(action: () => void): void;
  88224. }
  88225. }
  88226. declare module BABYLON {
  88227. /**
  88228. * Class used to enable instatition of objects by class name
  88229. */
  88230. export class InstantiationTools {
  88231. /**
  88232. * Use this object to register external classes like custom textures or material
  88233. * to allow the laoders to instantiate them
  88234. */
  88235. static RegisteredExternalClasses: {
  88236. [key: string]: Object;
  88237. };
  88238. /**
  88239. * Tries to instantiate a new object from a given class name
  88240. * @param className defines the class name to instantiate
  88241. * @returns the new object or null if the system was not able to do the instantiation
  88242. */
  88243. static Instantiate(className: string): any;
  88244. }
  88245. }
  88246. declare module BABYLON {
  88247. /**
  88248. * Define options used to create a depth texture
  88249. */
  88250. export class DepthTextureCreationOptions {
  88251. /** Specifies whether or not a stencil should be allocated in the texture */
  88252. generateStencil?: boolean;
  88253. /** Specifies whether or not bilinear filtering is enable on the texture */
  88254. bilinearFiltering?: boolean;
  88255. /** Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode */
  88256. comparisonFunction?: number;
  88257. /** Specifies if the created texture is a cube texture */
  88258. isCube?: boolean;
  88259. }
  88260. }
  88261. declare module BABYLON {
  88262. interface ThinEngine {
  88263. /**
  88264. * Creates a depth stencil cube texture.
  88265. * This is only available in WebGL 2.
  88266. * @param size The size of face edge in the cube texture.
  88267. * @param options The options defining the cube texture.
  88268. * @returns The cube texture
  88269. */
  88270. _createDepthStencilCubeTexture(size: number, options: DepthTextureCreationOptions): InternalTexture;
  88271. /**
  88272. * Creates a cube texture
  88273. * @param rootUrl defines the url where the files to load is located
  88274. * @param scene defines the current scene
  88275. * @param files defines the list of files to load (1 per face)
  88276. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88277. * @param onLoad defines an optional callback raised when the texture is loaded
  88278. * @param onError defines an optional callback raised if there is an issue to load the texture
  88279. * @param format defines the format of the data
  88280. * @param forcedExtension defines the extension to use to pick the right loader
  88281. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88282. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88283. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88284. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  88285. * @returns the cube texture as an InternalTexture
  88286. */
  88287. 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;
  88288. /**
  88289. * Creates a cube texture
  88290. * @param rootUrl defines the url where the files to load is located
  88291. * @param scene defines the current scene
  88292. * @param files defines the list of files to load (1 per face)
  88293. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88294. * @param onLoad defines an optional callback raised when the texture is loaded
  88295. * @param onError defines an optional callback raised if there is an issue to load the texture
  88296. * @param format defines the format of the data
  88297. * @param forcedExtension defines the extension to use to pick the right loader
  88298. * @returns the cube texture as an InternalTexture
  88299. */
  88300. 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;
  88301. /**
  88302. * Creates a cube texture
  88303. * @param rootUrl defines the url where the files to load is located
  88304. * @param scene defines the current scene
  88305. * @param files defines the list of files to load (1 per face)
  88306. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  88307. * @param onLoad defines an optional callback raised when the texture is loaded
  88308. * @param onError defines an optional callback raised if there is an issue to load the texture
  88309. * @param format defines the format of the data
  88310. * @param forcedExtension defines the extension to use to pick the right loader
  88311. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  88312. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88313. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88314. * @returns the cube texture as an InternalTexture
  88315. */
  88316. 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;
  88317. /** @hidden */
  88318. _partialLoadFile(url: string, index: number, loadedFiles: ArrayBuffer[], onfinish: (files: ArrayBuffer[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>): void;
  88319. /** @hidden */
  88320. _cascadeLoadFiles(scene: Nullable<Scene>, onfinish: (images: ArrayBuffer[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>): void;
  88321. /** @hidden */
  88322. _cascadeLoadImgs(scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, files: string[], onError: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88323. /** @hidden */
  88324. _partialLoadImg(url: string, index: number, loadedImages: HTMLImageElement[], scene: Nullable<Scene>, onfinish: (images: HTMLImageElement[]) => void, onErrorCallBack: Nullable<(message?: string, exception?: any) => void>, mimeType?: string): void;
  88325. /**
  88326. * @hidden
  88327. */
  88328. _setCubeMapTextureParams(loadMipmap: boolean): void;
  88329. }
  88330. }
  88331. declare module BABYLON {
  88332. /**
  88333. * Class for creating a cube texture
  88334. */
  88335. export class CubeTexture extends BaseTexture {
  88336. private _delayedOnLoad;
  88337. /**
  88338. * Observable triggered once the texture has been loaded.
  88339. */
  88340. onLoadObservable: Observable<CubeTexture>;
  88341. /**
  88342. * The url of the texture
  88343. */
  88344. url: string;
  88345. /**
  88346. * Gets or sets the center of the bounding box associated with the cube texture.
  88347. * It must define where the camera used to render the texture was set
  88348. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88349. */
  88350. boundingBoxPosition: Vector3;
  88351. private _boundingBoxSize;
  88352. /**
  88353. * Gets or sets the size of the bounding box associated with the cube texture
  88354. * When defined, the cubemap will switch to local mode
  88355. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  88356. * @example https://www.babylonjs-playground.com/#RNASML
  88357. */
  88358. set boundingBoxSize(value: Vector3);
  88359. /**
  88360. * Returns the bounding box size
  88361. * @see https://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  88362. */
  88363. get boundingBoxSize(): Vector3;
  88364. protected _rotationY: number;
  88365. /**
  88366. * Sets texture matrix rotation angle around Y axis in radians.
  88367. */
  88368. set rotationY(value: number);
  88369. /**
  88370. * Gets texture matrix rotation angle around Y axis radians.
  88371. */
  88372. get rotationY(): number;
  88373. /**
  88374. * Are mip maps generated for this texture or not.
  88375. */
  88376. get noMipmap(): boolean;
  88377. private _noMipmap;
  88378. private _files;
  88379. protected _forcedExtension: Nullable<string>;
  88380. private _extensions;
  88381. private _textureMatrix;
  88382. private _format;
  88383. private _createPolynomials;
  88384. /**
  88385. * Creates a cube texture from an array of image urls
  88386. * @param files defines an array of image urls
  88387. * @param scene defines the hosting scene
  88388. * @param noMipmap specifies if mip maps are not used
  88389. * @returns a cube texture
  88390. */
  88391. static CreateFromImages(files: string[], scene: Scene, noMipmap?: boolean): CubeTexture;
  88392. /**
  88393. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  88394. * @param url defines the url of the prefiltered texture
  88395. * @param scene defines the scene the texture is attached to
  88396. * @param forcedExtension defines the extension of the file if different from the url
  88397. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88398. * @return the prefiltered texture
  88399. */
  88400. static CreateFromPrefilteredData(url: string, scene: Scene, forcedExtension?: any, createPolynomials?: boolean): CubeTexture;
  88401. /**
  88402. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  88403. * as prefiltered data.
  88404. * @param rootUrl defines the url of the texture or the root name of the six images
  88405. * @param null defines the scene or engine the texture is attached to
  88406. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  88407. * @param noMipmap defines if mipmaps should be created or not
  88408. * @param files defines the six files to load for the different faces in that order: px, py, pz, nx, ny, nz
  88409. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  88410. * @param onError defines a callback triggered in case of error during load
  88411. * @param format defines the internal format to use for the texture once loaded
  88412. * @param prefiltered defines whether or not the texture is created from prefiltered data
  88413. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  88414. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  88415. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  88416. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  88417. * @return the cube texture
  88418. */
  88419. 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);
  88420. /**
  88421. * Get the current class name of the texture useful for serialization or dynamic coding.
  88422. * @returns "CubeTexture"
  88423. */
  88424. getClassName(): string;
  88425. /**
  88426. * Update the url (and optional buffer) of this texture if url was null during construction.
  88427. * @param url the url of the texture
  88428. * @param forcedExtension defines the extension to use
  88429. * @param onLoad callback called when the texture is loaded (defaults to null)
  88430. * @param prefiltered Defines whether the updated texture is prefiltered or not
  88431. */
  88432. updateURL(url: string, forcedExtension?: string, onLoad?: () => void, prefiltered?: boolean): void;
  88433. /**
  88434. * Delays loading of the cube texture
  88435. * @param forcedExtension defines the extension to use
  88436. */
  88437. delayLoad(forcedExtension?: string): void;
  88438. /**
  88439. * Returns the reflection texture matrix
  88440. * @returns the reflection texture matrix
  88441. */
  88442. getReflectionTextureMatrix(): Matrix;
  88443. /**
  88444. * Sets the reflection texture matrix
  88445. * @param value Reflection texture matrix
  88446. */
  88447. setReflectionTextureMatrix(value: Matrix): void;
  88448. /**
  88449. * Parses text to create a cube texture
  88450. * @param parsedTexture define the serialized text to read from
  88451. * @param scene defines the hosting scene
  88452. * @param rootUrl defines the root url of the cube texture
  88453. * @returns a cube texture
  88454. */
  88455. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): CubeTexture;
  88456. /**
  88457. * Makes a clone, or deep copy, of the cube texture
  88458. * @returns a new cube texture
  88459. */
  88460. clone(): CubeTexture;
  88461. }
  88462. }
  88463. declare module BABYLON {
  88464. /**
  88465. * Manages the defines for the Material
  88466. */
  88467. export class MaterialDefines {
  88468. /** @hidden */
  88469. protected _keys: string[];
  88470. private _isDirty;
  88471. /** @hidden */
  88472. _renderId: number;
  88473. /** @hidden */
  88474. _areLightsDirty: boolean;
  88475. /** @hidden */
  88476. _areLightsDisposed: boolean;
  88477. /** @hidden */
  88478. _areAttributesDirty: boolean;
  88479. /** @hidden */
  88480. _areTexturesDirty: boolean;
  88481. /** @hidden */
  88482. _areFresnelDirty: boolean;
  88483. /** @hidden */
  88484. _areMiscDirty: boolean;
  88485. /** @hidden */
  88486. _arePrePassDirty: boolean;
  88487. /** @hidden */
  88488. _areImageProcessingDirty: boolean;
  88489. /** @hidden */
  88490. _normals: boolean;
  88491. /** @hidden */
  88492. _uvs: boolean;
  88493. /** @hidden */
  88494. _needNormals: boolean;
  88495. /** @hidden */
  88496. _needUVs: boolean;
  88497. [id: string]: any;
  88498. /**
  88499. * Specifies if the material needs to be re-calculated
  88500. */
  88501. get isDirty(): boolean;
  88502. /**
  88503. * Marks the material to indicate that it has been re-calculated
  88504. */
  88505. markAsProcessed(): void;
  88506. /**
  88507. * Marks the material to indicate that it needs to be re-calculated
  88508. */
  88509. markAsUnprocessed(): void;
  88510. /**
  88511. * Marks the material to indicate all of its defines need to be re-calculated
  88512. */
  88513. markAllAsDirty(): void;
  88514. /**
  88515. * Marks the material to indicate that image processing needs to be re-calculated
  88516. */
  88517. markAsImageProcessingDirty(): void;
  88518. /**
  88519. * Marks the material to indicate the lights need to be re-calculated
  88520. * @param disposed Defines whether the light is dirty due to dispose or not
  88521. */
  88522. markAsLightDirty(disposed?: boolean): void;
  88523. /**
  88524. * Marks the attribute state as changed
  88525. */
  88526. markAsAttributesDirty(): void;
  88527. /**
  88528. * Marks the texture state as changed
  88529. */
  88530. markAsTexturesDirty(): void;
  88531. /**
  88532. * Marks the fresnel state as changed
  88533. */
  88534. markAsFresnelDirty(): void;
  88535. /**
  88536. * Marks the misc state as changed
  88537. */
  88538. markAsMiscDirty(): void;
  88539. /**
  88540. * Marks the prepass state as changed
  88541. */
  88542. markAsPrePassDirty(): void;
  88543. /**
  88544. * Rebuilds the material defines
  88545. */
  88546. rebuild(): void;
  88547. /**
  88548. * Specifies if two material defines are equal
  88549. * @param other - A material define instance to compare to
  88550. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  88551. */
  88552. isEqual(other: MaterialDefines): boolean;
  88553. /**
  88554. * Clones this instance's defines to another instance
  88555. * @param other - material defines to clone values to
  88556. */
  88557. cloneTo(other: MaterialDefines): void;
  88558. /**
  88559. * Resets the material define values
  88560. */
  88561. reset(): void;
  88562. /**
  88563. * Converts the material define values to a string
  88564. * @returns - String of material define information
  88565. */
  88566. toString(): string;
  88567. }
  88568. }
  88569. declare module BABYLON {
  88570. /**
  88571. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  88572. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  88573. * 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;
  88574. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  88575. */
  88576. export class ColorCurves {
  88577. private _dirty;
  88578. private _tempColor;
  88579. private _globalCurve;
  88580. private _highlightsCurve;
  88581. private _midtonesCurve;
  88582. private _shadowsCurve;
  88583. private _positiveCurve;
  88584. private _negativeCurve;
  88585. private _globalHue;
  88586. private _globalDensity;
  88587. private _globalSaturation;
  88588. private _globalExposure;
  88589. /**
  88590. * Gets the global Hue value.
  88591. * 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).
  88592. */
  88593. get globalHue(): number;
  88594. /**
  88595. * Sets the global Hue value.
  88596. * 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).
  88597. */
  88598. set globalHue(value: number);
  88599. /**
  88600. * Gets the global Density value.
  88601. * 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.
  88602. * Values less than zero provide a filter of opposite hue.
  88603. */
  88604. get globalDensity(): number;
  88605. /**
  88606. * Sets the global Density value.
  88607. * 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.
  88608. * Values less than zero provide a filter of opposite hue.
  88609. */
  88610. set globalDensity(value: number);
  88611. /**
  88612. * Gets the global Saturation value.
  88613. * 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.
  88614. */
  88615. get globalSaturation(): number;
  88616. /**
  88617. * Sets the global Saturation value.
  88618. * 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.
  88619. */
  88620. set globalSaturation(value: number);
  88621. /**
  88622. * Gets the global Exposure value.
  88623. * 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.
  88624. */
  88625. get globalExposure(): number;
  88626. /**
  88627. * Sets the global Exposure value.
  88628. * 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.
  88629. */
  88630. set globalExposure(value: number);
  88631. private _highlightsHue;
  88632. private _highlightsDensity;
  88633. private _highlightsSaturation;
  88634. private _highlightsExposure;
  88635. /**
  88636. * Gets the highlights Hue value.
  88637. * 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).
  88638. */
  88639. get highlightsHue(): number;
  88640. /**
  88641. * Sets the highlights Hue value.
  88642. * 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).
  88643. */
  88644. set highlightsHue(value: number);
  88645. /**
  88646. * Gets the highlights Density value.
  88647. * 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.
  88648. * Values less than zero provide a filter of opposite hue.
  88649. */
  88650. get highlightsDensity(): number;
  88651. /**
  88652. * Sets the highlights Density value.
  88653. * 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.
  88654. * Values less than zero provide a filter of opposite hue.
  88655. */
  88656. set highlightsDensity(value: number);
  88657. /**
  88658. * Gets the highlights Saturation value.
  88659. * 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.
  88660. */
  88661. get highlightsSaturation(): number;
  88662. /**
  88663. * Sets the highlights Saturation value.
  88664. * 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.
  88665. */
  88666. set highlightsSaturation(value: number);
  88667. /**
  88668. * Gets the highlights Exposure value.
  88669. * 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.
  88670. */
  88671. get highlightsExposure(): number;
  88672. /**
  88673. * Sets the highlights Exposure value.
  88674. * 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.
  88675. */
  88676. set highlightsExposure(value: number);
  88677. private _midtonesHue;
  88678. private _midtonesDensity;
  88679. private _midtonesSaturation;
  88680. private _midtonesExposure;
  88681. /**
  88682. * Gets the midtones Hue value.
  88683. * 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).
  88684. */
  88685. get midtonesHue(): number;
  88686. /**
  88687. * Sets the midtones Hue value.
  88688. * 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).
  88689. */
  88690. set midtonesHue(value: number);
  88691. /**
  88692. * Gets the midtones Density value.
  88693. * 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.
  88694. * Values less than zero provide a filter of opposite hue.
  88695. */
  88696. get midtonesDensity(): number;
  88697. /**
  88698. * Sets the midtones Density value.
  88699. * 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.
  88700. * Values less than zero provide a filter of opposite hue.
  88701. */
  88702. set midtonesDensity(value: number);
  88703. /**
  88704. * Gets the midtones Saturation value.
  88705. * 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.
  88706. */
  88707. get midtonesSaturation(): number;
  88708. /**
  88709. * Sets the midtones Saturation value.
  88710. * 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.
  88711. */
  88712. set midtonesSaturation(value: number);
  88713. /**
  88714. * Gets the midtones Exposure value.
  88715. * 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.
  88716. */
  88717. get midtonesExposure(): number;
  88718. /**
  88719. * Sets the midtones Exposure value.
  88720. * 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.
  88721. */
  88722. set midtonesExposure(value: number);
  88723. private _shadowsHue;
  88724. private _shadowsDensity;
  88725. private _shadowsSaturation;
  88726. private _shadowsExposure;
  88727. /**
  88728. * Gets the shadows Hue value.
  88729. * 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).
  88730. */
  88731. get shadowsHue(): number;
  88732. /**
  88733. * Sets the shadows Hue value.
  88734. * 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).
  88735. */
  88736. set shadowsHue(value: number);
  88737. /**
  88738. * Gets the shadows Density value.
  88739. * 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.
  88740. * Values less than zero provide a filter of opposite hue.
  88741. */
  88742. get shadowsDensity(): number;
  88743. /**
  88744. * Sets the shadows Density value.
  88745. * 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.
  88746. * Values less than zero provide a filter of opposite hue.
  88747. */
  88748. set shadowsDensity(value: number);
  88749. /**
  88750. * Gets the shadows Saturation value.
  88751. * 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.
  88752. */
  88753. get shadowsSaturation(): number;
  88754. /**
  88755. * Sets the shadows Saturation value.
  88756. * 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.
  88757. */
  88758. set shadowsSaturation(value: number);
  88759. /**
  88760. * Gets the shadows Exposure value.
  88761. * 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.
  88762. */
  88763. get shadowsExposure(): number;
  88764. /**
  88765. * Sets the shadows Exposure value.
  88766. * 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.
  88767. */
  88768. set shadowsExposure(value: number);
  88769. /**
  88770. * Returns the class name
  88771. * @returns The class name
  88772. */
  88773. getClassName(): string;
  88774. /**
  88775. * Binds the color curves to the shader.
  88776. * @param colorCurves The color curve to bind
  88777. * @param effect The effect to bind to
  88778. * @param positiveUniform The positive uniform shader parameter
  88779. * @param neutralUniform The neutral uniform shader parameter
  88780. * @param negativeUniform The negative uniform shader parameter
  88781. */
  88782. static Bind(colorCurves: ColorCurves, effect: Effect, positiveUniform?: string, neutralUniform?: string, negativeUniform?: string): void;
  88783. /**
  88784. * Prepare the list of uniforms associated with the ColorCurves effects.
  88785. * @param uniformsList The list of uniforms used in the effect
  88786. */
  88787. static PrepareUniforms(uniformsList: string[]): void;
  88788. /**
  88789. * Returns color grading data based on a hue, density, saturation and exposure value.
  88790. * @param filterHue The hue of the color filter.
  88791. * @param filterDensity The density of the color filter.
  88792. * @param saturation The saturation.
  88793. * @param exposure The exposure.
  88794. * @param result The result data container.
  88795. */
  88796. private getColorGradingDataToRef;
  88797. /**
  88798. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  88799. * @param value The input slider value in range [-100,100].
  88800. * @returns Adjusted value.
  88801. */
  88802. private static applyColorGradingSliderNonlinear;
  88803. /**
  88804. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  88805. * @param hue The hue (H) input.
  88806. * @param saturation The saturation (S) input.
  88807. * @param brightness The brightness (B) input.
  88808. * @result An RGBA color represented as Vector4.
  88809. */
  88810. private static fromHSBToRef;
  88811. /**
  88812. * Returns a value clamped between min and max
  88813. * @param value The value to clamp
  88814. * @param min The minimum of value
  88815. * @param max The maximum of value
  88816. * @returns The clamped value.
  88817. */
  88818. private static clamp;
  88819. /**
  88820. * Clones the current color curve instance.
  88821. * @return The cloned curves
  88822. */
  88823. clone(): ColorCurves;
  88824. /**
  88825. * Serializes the current color curve instance to a json representation.
  88826. * @return a JSON representation
  88827. */
  88828. serialize(): any;
  88829. /**
  88830. * Parses the color curve from a json representation.
  88831. * @param source the JSON source to parse
  88832. * @return The parsed curves
  88833. */
  88834. static Parse(source: any): ColorCurves;
  88835. }
  88836. }
  88837. declare module BABYLON {
  88838. /**
  88839. * Interface to follow in your material defines to integrate easily the
  88840. * Image proccessing functions.
  88841. * @hidden
  88842. */
  88843. export interface IImageProcessingConfigurationDefines {
  88844. IMAGEPROCESSING: boolean;
  88845. VIGNETTE: boolean;
  88846. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88847. VIGNETTEBLENDMODEOPAQUE: boolean;
  88848. TONEMAPPING: boolean;
  88849. TONEMAPPING_ACES: boolean;
  88850. CONTRAST: boolean;
  88851. EXPOSURE: boolean;
  88852. COLORCURVES: boolean;
  88853. COLORGRADING: boolean;
  88854. COLORGRADING3D: boolean;
  88855. SAMPLER3DGREENDEPTH: boolean;
  88856. SAMPLER3DBGRMAP: boolean;
  88857. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88858. }
  88859. /**
  88860. * @hidden
  88861. */
  88862. export class ImageProcessingConfigurationDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  88863. IMAGEPROCESSING: boolean;
  88864. VIGNETTE: boolean;
  88865. VIGNETTEBLENDMODEMULTIPLY: boolean;
  88866. VIGNETTEBLENDMODEOPAQUE: boolean;
  88867. TONEMAPPING: boolean;
  88868. TONEMAPPING_ACES: boolean;
  88869. CONTRAST: boolean;
  88870. COLORCURVES: boolean;
  88871. COLORGRADING: boolean;
  88872. COLORGRADING3D: boolean;
  88873. SAMPLER3DGREENDEPTH: boolean;
  88874. SAMPLER3DBGRMAP: boolean;
  88875. IMAGEPROCESSINGPOSTPROCESS: boolean;
  88876. EXPOSURE: boolean;
  88877. constructor();
  88878. }
  88879. /**
  88880. * This groups together the common properties used for image processing either in direct forward pass
  88881. * or through post processing effect depending on the use of the image processing pipeline in your scene
  88882. * or not.
  88883. */
  88884. export class ImageProcessingConfiguration {
  88885. /**
  88886. * Default tone mapping applied in BabylonJS.
  88887. */
  88888. static readonly TONEMAPPING_STANDARD: number;
  88889. /**
  88890. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  88891. * to other engines rendering to increase portability.
  88892. */
  88893. static readonly TONEMAPPING_ACES: number;
  88894. /**
  88895. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  88896. */
  88897. colorCurves: Nullable<ColorCurves>;
  88898. private _colorCurvesEnabled;
  88899. /**
  88900. * Gets wether the color curves effect is enabled.
  88901. */
  88902. get colorCurvesEnabled(): boolean;
  88903. /**
  88904. * Sets wether the color curves effect is enabled.
  88905. */
  88906. set colorCurvesEnabled(value: boolean);
  88907. private _colorGradingTexture;
  88908. /**
  88909. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88910. */
  88911. get colorGradingTexture(): Nullable<BaseTexture>;
  88912. /**
  88913. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  88914. */
  88915. set colorGradingTexture(value: Nullable<BaseTexture>);
  88916. private _colorGradingEnabled;
  88917. /**
  88918. * Gets wether the color grading effect is enabled.
  88919. */
  88920. get colorGradingEnabled(): boolean;
  88921. /**
  88922. * Sets wether the color grading effect is enabled.
  88923. */
  88924. set colorGradingEnabled(value: boolean);
  88925. private _colorGradingWithGreenDepth;
  88926. /**
  88927. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  88928. */
  88929. get colorGradingWithGreenDepth(): boolean;
  88930. /**
  88931. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  88932. */
  88933. set colorGradingWithGreenDepth(value: boolean);
  88934. private _colorGradingBGR;
  88935. /**
  88936. * Gets wether the color grading texture contains BGR values.
  88937. */
  88938. get colorGradingBGR(): boolean;
  88939. /**
  88940. * Sets wether the color grading texture contains BGR values.
  88941. */
  88942. set colorGradingBGR(value: boolean);
  88943. /** @hidden */
  88944. _exposure: number;
  88945. /**
  88946. * Gets the Exposure used in the effect.
  88947. */
  88948. get exposure(): number;
  88949. /**
  88950. * Sets the Exposure used in the effect.
  88951. */
  88952. set exposure(value: number);
  88953. private _toneMappingEnabled;
  88954. /**
  88955. * Gets wether the tone mapping effect is enabled.
  88956. */
  88957. get toneMappingEnabled(): boolean;
  88958. /**
  88959. * Sets wether the tone mapping effect is enabled.
  88960. */
  88961. set toneMappingEnabled(value: boolean);
  88962. private _toneMappingType;
  88963. /**
  88964. * Gets the type of tone mapping effect.
  88965. */
  88966. get toneMappingType(): number;
  88967. /**
  88968. * Sets the type of tone mapping effect used in BabylonJS.
  88969. */
  88970. set toneMappingType(value: number);
  88971. protected _contrast: number;
  88972. /**
  88973. * Gets the contrast used in the effect.
  88974. */
  88975. get contrast(): number;
  88976. /**
  88977. * Sets the contrast used in the effect.
  88978. */
  88979. set contrast(value: number);
  88980. /**
  88981. * Vignette stretch size.
  88982. */
  88983. vignetteStretch: number;
  88984. /**
  88985. * Vignette centre X Offset.
  88986. */
  88987. vignetteCentreX: number;
  88988. /**
  88989. * Vignette centre Y Offset.
  88990. */
  88991. vignetteCentreY: number;
  88992. /**
  88993. * Vignette weight or intensity of the vignette effect.
  88994. */
  88995. vignetteWeight: number;
  88996. /**
  88997. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  88998. * if vignetteEnabled is set to true.
  88999. */
  89000. vignetteColor: Color4;
  89001. /**
  89002. * Camera field of view used by the Vignette effect.
  89003. */
  89004. vignetteCameraFov: number;
  89005. private _vignetteBlendMode;
  89006. /**
  89007. * Gets the vignette blend mode allowing different kind of effect.
  89008. */
  89009. get vignetteBlendMode(): number;
  89010. /**
  89011. * Sets the vignette blend mode allowing different kind of effect.
  89012. */
  89013. set vignetteBlendMode(value: number);
  89014. private _vignetteEnabled;
  89015. /**
  89016. * Gets wether the vignette effect is enabled.
  89017. */
  89018. get vignetteEnabled(): boolean;
  89019. /**
  89020. * Sets wether the vignette effect is enabled.
  89021. */
  89022. set vignetteEnabled(value: boolean);
  89023. private _applyByPostProcess;
  89024. /**
  89025. * Gets wether the image processing is applied through a post process or not.
  89026. */
  89027. get applyByPostProcess(): boolean;
  89028. /**
  89029. * Sets wether the image processing is applied through a post process or not.
  89030. */
  89031. set applyByPostProcess(value: boolean);
  89032. private _isEnabled;
  89033. /**
  89034. * Gets wether the image processing is enabled or not.
  89035. */
  89036. get isEnabled(): boolean;
  89037. /**
  89038. * Sets wether the image processing is enabled or not.
  89039. */
  89040. set isEnabled(value: boolean);
  89041. /**
  89042. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  89043. */
  89044. onUpdateParameters: Observable<ImageProcessingConfiguration>;
  89045. /**
  89046. * Method called each time the image processing information changes requires to recompile the effect.
  89047. */
  89048. protected _updateParameters(): void;
  89049. /**
  89050. * Gets the current class name.
  89051. * @return "ImageProcessingConfiguration"
  89052. */
  89053. getClassName(): string;
  89054. /**
  89055. * Prepare the list of uniforms associated with the Image Processing effects.
  89056. * @param uniforms The list of uniforms used in the effect
  89057. * @param defines the list of defines currently in use
  89058. */
  89059. static PrepareUniforms(uniforms: string[], defines: IImageProcessingConfigurationDefines): void;
  89060. /**
  89061. * Prepare the list of samplers associated with the Image Processing effects.
  89062. * @param samplersList The list of uniforms used in the effect
  89063. * @param defines the list of defines currently in use
  89064. */
  89065. static PrepareSamplers(samplersList: string[], defines: IImageProcessingConfigurationDefines): void;
  89066. /**
  89067. * Prepare the list of defines associated to the shader.
  89068. * @param defines the list of defines to complete
  89069. * @param forPostProcess Define if we are currently in post process mode or not
  89070. */
  89071. prepareDefines(defines: IImageProcessingConfigurationDefines, forPostProcess?: boolean): void;
  89072. /**
  89073. * Returns true if all the image processing information are ready.
  89074. * @returns True if ready, otherwise, false
  89075. */
  89076. isReady(): boolean;
  89077. /**
  89078. * Binds the image processing to the shader.
  89079. * @param effect The effect to bind to
  89080. * @param overrideAspectRatio Override the aspect ratio of the effect
  89081. */
  89082. bind(effect: Effect, overrideAspectRatio?: number): void;
  89083. /**
  89084. * Clones the current image processing instance.
  89085. * @return The cloned image processing
  89086. */
  89087. clone(): ImageProcessingConfiguration;
  89088. /**
  89089. * Serializes the current image processing instance to a json representation.
  89090. * @return a JSON representation
  89091. */
  89092. serialize(): any;
  89093. /**
  89094. * Parses the image processing from a json representation.
  89095. * @param source the JSON source to parse
  89096. * @return The parsed image processing
  89097. */
  89098. static Parse(source: any): ImageProcessingConfiguration;
  89099. private static _VIGNETTEMODE_MULTIPLY;
  89100. private static _VIGNETTEMODE_OPAQUE;
  89101. /**
  89102. * Used to apply the vignette as a mix with the pixel color.
  89103. */
  89104. static get VIGNETTEMODE_MULTIPLY(): number;
  89105. /**
  89106. * Used to apply the vignette as a replacement of the pixel color.
  89107. */
  89108. static get VIGNETTEMODE_OPAQUE(): number;
  89109. }
  89110. }
  89111. declare module BABYLON {
  89112. /** @hidden */
  89113. export var postprocessVertexShader: {
  89114. name: string;
  89115. shader: string;
  89116. };
  89117. }
  89118. declare module BABYLON {
  89119. /**
  89120. * Type used to define a render target texture size (either with a number or with a rect width and height)
  89121. */
  89122. export type RenderTargetTextureSize = number | {
  89123. width: number;
  89124. height: number;
  89125. layers?: number;
  89126. };
  89127. interface ThinEngine {
  89128. /**
  89129. * Creates a new render target texture
  89130. * @param size defines the size of the texture
  89131. * @param options defines the options used to create the texture
  89132. * @returns a new render target texture stored in an InternalTexture
  89133. */
  89134. createRenderTargetTexture(size: RenderTargetTextureSize, options: boolean | RenderTargetCreationOptions): InternalTexture;
  89135. /**
  89136. * Creates a depth stencil texture.
  89137. * This is only available in WebGL 2 or with the depth texture extension available.
  89138. * @param size The size of face edge in the texture.
  89139. * @param options The options defining the texture.
  89140. * @returns The texture
  89141. */
  89142. createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89143. /** @hidden */
  89144. _createDepthStencilTexture(size: RenderTargetTextureSize, options: DepthTextureCreationOptions): InternalTexture;
  89145. }
  89146. }
  89147. declare module BABYLON {
  89148. /**
  89149. * Defines the kind of connection point for node based material
  89150. */
  89151. export enum NodeMaterialBlockConnectionPointTypes {
  89152. /** Float */
  89153. Float = 1,
  89154. /** Int */
  89155. Int = 2,
  89156. /** Vector2 */
  89157. Vector2 = 4,
  89158. /** Vector3 */
  89159. Vector3 = 8,
  89160. /** Vector4 */
  89161. Vector4 = 16,
  89162. /** Color3 */
  89163. Color3 = 32,
  89164. /** Color4 */
  89165. Color4 = 64,
  89166. /** Matrix */
  89167. Matrix = 128,
  89168. /** Custom object */
  89169. Object = 256,
  89170. /** Detect type based on connection */
  89171. AutoDetect = 1024,
  89172. /** Output type that will be defined by input type */
  89173. BasedOnInput = 2048
  89174. }
  89175. }
  89176. declare module BABYLON {
  89177. /**
  89178. * Enum used to define the target of a block
  89179. */
  89180. export enum NodeMaterialBlockTargets {
  89181. /** Vertex shader */
  89182. Vertex = 1,
  89183. /** Fragment shader */
  89184. Fragment = 2,
  89185. /** Neutral */
  89186. Neutral = 4,
  89187. /** Vertex and Fragment */
  89188. VertexAndFragment = 3
  89189. }
  89190. }
  89191. declare module BABYLON {
  89192. /**
  89193. * Enum defining the mode of a NodeMaterialBlockConnectionPoint
  89194. */
  89195. export enum NodeMaterialBlockConnectionPointMode {
  89196. /** Value is an uniform */
  89197. Uniform = 0,
  89198. /** Value is a mesh attribute */
  89199. Attribute = 1,
  89200. /** Value is a varying between vertex and fragment shaders */
  89201. Varying = 2,
  89202. /** Mode is undefined */
  89203. Undefined = 3
  89204. }
  89205. }
  89206. declare module BABYLON {
  89207. /**
  89208. * Enum used to define system values e.g. values automatically provided by the system
  89209. */
  89210. export enum NodeMaterialSystemValues {
  89211. /** World */
  89212. World = 1,
  89213. /** View */
  89214. View = 2,
  89215. /** Projection */
  89216. Projection = 3,
  89217. /** ViewProjection */
  89218. ViewProjection = 4,
  89219. /** WorldView */
  89220. WorldView = 5,
  89221. /** WorldViewProjection */
  89222. WorldViewProjection = 6,
  89223. /** CameraPosition */
  89224. CameraPosition = 7,
  89225. /** Fog Color */
  89226. FogColor = 8,
  89227. /** Delta time */
  89228. DeltaTime = 9
  89229. }
  89230. }
  89231. declare module BABYLON {
  89232. /** Defines supported spaces */
  89233. export enum Space {
  89234. /** Local (object) space */
  89235. LOCAL = 0,
  89236. /** World space */
  89237. WORLD = 1,
  89238. /** Bone space */
  89239. BONE = 2
  89240. }
  89241. /** Defines the 3 main axes */
  89242. export class Axis {
  89243. /** X axis */
  89244. static X: Vector3;
  89245. /** Y axis */
  89246. static Y: Vector3;
  89247. /** Z axis */
  89248. static Z: Vector3;
  89249. }
  89250. }
  89251. declare module BABYLON {
  89252. /**
  89253. * Represents a camera frustum
  89254. */
  89255. export class Frustum {
  89256. /**
  89257. * Gets the planes representing the frustum
  89258. * @param transform matrix to be applied to the returned planes
  89259. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  89260. */
  89261. static GetPlanes(transform: DeepImmutable<Matrix>): Plane[];
  89262. /**
  89263. * Gets the near frustum plane transformed by the transform matrix
  89264. * @param transform transformation matrix to be applied to the resulting frustum plane
  89265. * @param frustumPlane the resuling frustum plane
  89266. */
  89267. static GetNearPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89268. /**
  89269. * Gets the far frustum plane transformed by the transform matrix
  89270. * @param transform transformation matrix to be applied to the resulting frustum plane
  89271. * @param frustumPlane the resuling frustum plane
  89272. */
  89273. static GetFarPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89274. /**
  89275. * Gets the left frustum plane transformed by the transform matrix
  89276. * @param transform transformation matrix to be applied to the resulting frustum plane
  89277. * @param frustumPlane the resuling frustum plane
  89278. */
  89279. static GetLeftPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89280. /**
  89281. * Gets the right frustum plane transformed by the transform matrix
  89282. * @param transform transformation matrix to be applied to the resulting frustum plane
  89283. * @param frustumPlane the resuling frustum plane
  89284. */
  89285. static GetRightPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89286. /**
  89287. * Gets the top frustum plane transformed by the transform matrix
  89288. * @param transform transformation matrix to be applied to the resulting frustum plane
  89289. * @param frustumPlane the resuling frustum plane
  89290. */
  89291. static GetTopPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89292. /**
  89293. * Gets the bottom frustum plane transformed by the transform matrix
  89294. * @param transform transformation matrix to be applied to the resulting frustum plane
  89295. * @param frustumPlane the resuling frustum plane
  89296. */
  89297. static GetBottomPlaneToRef(transform: DeepImmutable<Matrix>, frustumPlane: Plane): void;
  89298. /**
  89299. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  89300. * @param transform transformation matrix to be applied to the resulting frustum planes
  89301. * @param frustumPlanes the resuling frustum planes
  89302. */
  89303. static GetPlanesToRef(transform: DeepImmutable<Matrix>, frustumPlanes: Plane[]): void;
  89304. }
  89305. }
  89306. declare module BABYLON {
  89307. /**
  89308. * Interface for the size containing width and height
  89309. */
  89310. export interface ISize {
  89311. /**
  89312. * Width
  89313. */
  89314. width: number;
  89315. /**
  89316. * Heighht
  89317. */
  89318. height: number;
  89319. }
  89320. /**
  89321. * Size containing widht and height
  89322. */
  89323. export class Size implements ISize {
  89324. /**
  89325. * Width
  89326. */
  89327. width: number;
  89328. /**
  89329. * Height
  89330. */
  89331. height: number;
  89332. /**
  89333. * Creates a Size object from the given width and height (floats).
  89334. * @param width width of the new size
  89335. * @param height height of the new size
  89336. */
  89337. constructor(width: number, height: number);
  89338. /**
  89339. * Returns a string with the Size width and height
  89340. * @returns a string with the Size width and height
  89341. */
  89342. toString(): string;
  89343. /**
  89344. * "Size"
  89345. * @returns the string "Size"
  89346. */
  89347. getClassName(): string;
  89348. /**
  89349. * Returns the Size hash code.
  89350. * @returns a hash code for a unique width and height
  89351. */
  89352. getHashCode(): number;
  89353. /**
  89354. * Updates the current size from the given one.
  89355. * @param src the given size
  89356. */
  89357. copyFrom(src: Size): void;
  89358. /**
  89359. * Updates in place the current Size from the given floats.
  89360. * @param width width of the new size
  89361. * @param height height of the new size
  89362. * @returns the updated Size.
  89363. */
  89364. copyFromFloats(width: number, height: number): Size;
  89365. /**
  89366. * Updates in place the current Size from the given floats.
  89367. * @param width width to set
  89368. * @param height height to set
  89369. * @returns the updated Size.
  89370. */
  89371. set(width: number, height: number): Size;
  89372. /**
  89373. * Multiplies the width and height by numbers
  89374. * @param w factor to multiple the width by
  89375. * @param h factor to multiple the height by
  89376. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  89377. */
  89378. multiplyByFloats(w: number, h: number): Size;
  89379. /**
  89380. * Clones the size
  89381. * @returns a new Size copied from the given one.
  89382. */
  89383. clone(): Size;
  89384. /**
  89385. * True if the current Size and the given one width and height are strictly equal.
  89386. * @param other the other size to compare against
  89387. * @returns True if the current Size and the given one width and height are strictly equal.
  89388. */
  89389. equals(other: Size): boolean;
  89390. /**
  89391. * The surface of the Size : width * height (float).
  89392. */
  89393. get surface(): number;
  89394. /**
  89395. * Create a new size of zero
  89396. * @returns a new Size set to (0.0, 0.0)
  89397. */
  89398. static Zero(): Size;
  89399. /**
  89400. * Sums the width and height of two sizes
  89401. * @param otherSize size to add to this size
  89402. * @returns a new Size set as the addition result of the current Size and the given one.
  89403. */
  89404. add(otherSize: Size): Size;
  89405. /**
  89406. * Subtracts the width and height of two
  89407. * @param otherSize size to subtract to this size
  89408. * @returns a new Size set as the subtraction result of the given one from the current Size.
  89409. */
  89410. subtract(otherSize: Size): Size;
  89411. /**
  89412. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  89413. * @param start starting size to lerp between
  89414. * @param end end size to lerp between
  89415. * @param amount amount to lerp between the start and end values
  89416. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  89417. */
  89418. static Lerp(start: Size, end: Size, amount: number): Size;
  89419. }
  89420. }
  89421. declare module BABYLON {
  89422. /**
  89423. * Contains position and normal vectors for a vertex
  89424. */
  89425. export class PositionNormalVertex {
  89426. /** the position of the vertex (defaut: 0,0,0) */
  89427. position: Vector3;
  89428. /** the normal of the vertex (defaut: 0,1,0) */
  89429. normal: Vector3;
  89430. /**
  89431. * Creates a PositionNormalVertex
  89432. * @param position the position of the vertex (defaut: 0,0,0)
  89433. * @param normal the normal of the vertex (defaut: 0,1,0)
  89434. */
  89435. constructor(
  89436. /** the position of the vertex (defaut: 0,0,0) */
  89437. position?: Vector3,
  89438. /** the normal of the vertex (defaut: 0,1,0) */
  89439. normal?: Vector3);
  89440. /**
  89441. * Clones the PositionNormalVertex
  89442. * @returns the cloned PositionNormalVertex
  89443. */
  89444. clone(): PositionNormalVertex;
  89445. }
  89446. /**
  89447. * Contains position, normal and uv vectors for a vertex
  89448. */
  89449. export class PositionNormalTextureVertex {
  89450. /** the position of the vertex (defaut: 0,0,0) */
  89451. position: Vector3;
  89452. /** the normal of the vertex (defaut: 0,1,0) */
  89453. normal: Vector3;
  89454. /** the uv of the vertex (default: 0,0) */
  89455. uv: Vector2;
  89456. /**
  89457. * Creates a PositionNormalTextureVertex
  89458. * @param position the position of the vertex (defaut: 0,0,0)
  89459. * @param normal the normal of the vertex (defaut: 0,1,0)
  89460. * @param uv the uv of the vertex (default: 0,0)
  89461. */
  89462. constructor(
  89463. /** the position of the vertex (defaut: 0,0,0) */
  89464. position?: Vector3,
  89465. /** the normal of the vertex (defaut: 0,1,0) */
  89466. normal?: Vector3,
  89467. /** the uv of the vertex (default: 0,0) */
  89468. uv?: Vector2);
  89469. /**
  89470. * Clones the PositionNormalTextureVertex
  89471. * @returns the cloned PositionNormalTextureVertex
  89472. */
  89473. clone(): PositionNormalTextureVertex;
  89474. }
  89475. }
  89476. declare module BABYLON {
  89477. /**
  89478. * Enum defining the type of animations supported by InputBlock
  89479. */
  89480. export enum AnimatedInputBlockTypes {
  89481. /** No animation */
  89482. None = 0,
  89483. /** Time based animation. Will only work for floats */
  89484. Time = 1
  89485. }
  89486. }
  89487. declare module BABYLON {
  89488. /**
  89489. * Interface describing all the common properties and methods a shadow light needs to implement.
  89490. * This helps both the shadow generator and materials to genrate the corresponding shadow maps
  89491. * as well as binding the different shadow properties to the effects.
  89492. */
  89493. export interface IShadowLight extends Light {
  89494. /**
  89495. * The light id in the scene (used in scene.findLighById for instance)
  89496. */
  89497. id: string;
  89498. /**
  89499. * The position the shdow will be casted from.
  89500. */
  89501. position: Vector3;
  89502. /**
  89503. * In 2d mode (needCube being false), the direction used to cast the shadow.
  89504. */
  89505. direction: Vector3;
  89506. /**
  89507. * The transformed position. Position of the light in world space taking parenting in account.
  89508. */
  89509. transformedPosition: Vector3;
  89510. /**
  89511. * The transformed direction. Direction of the light in world space taking parenting in account.
  89512. */
  89513. transformedDirection: Vector3;
  89514. /**
  89515. * The friendly name of the light in the scene.
  89516. */
  89517. name: string;
  89518. /**
  89519. * Defines the shadow projection clipping minimum z value.
  89520. */
  89521. shadowMinZ: number;
  89522. /**
  89523. * Defines the shadow projection clipping maximum z value.
  89524. */
  89525. shadowMaxZ: number;
  89526. /**
  89527. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89528. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89529. */
  89530. computeTransformedInformation(): boolean;
  89531. /**
  89532. * Gets the scene the light belongs to.
  89533. * @returns The scene
  89534. */
  89535. getScene(): Scene;
  89536. /**
  89537. * Callback defining a custom Projection Matrix Builder.
  89538. * This can be used to override the default projection matrix computation.
  89539. */
  89540. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89541. /**
  89542. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89543. * @param matrix The materix to updated with the projection information
  89544. * @param viewMatrix The transform matrix of the light
  89545. * @param renderList The list of mesh to render in the map
  89546. * @returns The current light
  89547. */
  89548. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89549. /**
  89550. * Gets the current depth scale used in ESM.
  89551. * @returns The scale
  89552. */
  89553. getDepthScale(): number;
  89554. /**
  89555. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89556. * @returns true if a cube texture needs to be use
  89557. */
  89558. needCube(): boolean;
  89559. /**
  89560. * Detects if the projection matrix requires to be recomputed this frame.
  89561. * @returns true if it requires to be recomputed otherwise, false.
  89562. */
  89563. needProjectionMatrixCompute(): boolean;
  89564. /**
  89565. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89566. */
  89567. forceProjectionMatrixCompute(): void;
  89568. /**
  89569. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89570. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89571. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89572. */
  89573. getShadowDirection(faceIndex?: number): Vector3;
  89574. /**
  89575. * Gets the minZ used for shadow according to both the scene and the light.
  89576. * @param activeCamera The camera we are returning the min for
  89577. * @returns the depth min z
  89578. */
  89579. getDepthMinZ(activeCamera: Camera): number;
  89580. /**
  89581. * Gets the maxZ used for shadow according to both the scene and the light.
  89582. * @param activeCamera The camera we are returning the max for
  89583. * @returns the depth max z
  89584. */
  89585. getDepthMaxZ(activeCamera: Camera): number;
  89586. }
  89587. /**
  89588. * Base implementation IShadowLight
  89589. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  89590. */
  89591. export abstract class ShadowLight extends Light implements IShadowLight {
  89592. protected abstract _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  89593. protected _position: Vector3;
  89594. protected _setPosition(value: Vector3): void;
  89595. /**
  89596. * Sets the position the shadow will be casted from. Also use as the light position for both
  89597. * point and spot lights.
  89598. */
  89599. get position(): Vector3;
  89600. /**
  89601. * Sets the position the shadow will be casted from. Also use as the light position for both
  89602. * point and spot lights.
  89603. */
  89604. set position(value: Vector3);
  89605. protected _direction: Vector3;
  89606. protected _setDirection(value: Vector3): void;
  89607. /**
  89608. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  89609. * Also use as the light direction on spot and directional lights.
  89610. */
  89611. get direction(): Vector3;
  89612. /**
  89613. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  89614. * Also use as the light direction on spot and directional lights.
  89615. */
  89616. set direction(value: Vector3);
  89617. protected _shadowMinZ: number;
  89618. /**
  89619. * Gets the shadow projection clipping minimum z value.
  89620. */
  89621. get shadowMinZ(): number;
  89622. /**
  89623. * Sets the shadow projection clipping minimum z value.
  89624. */
  89625. set shadowMinZ(value: number);
  89626. protected _shadowMaxZ: number;
  89627. /**
  89628. * Sets the shadow projection clipping maximum z value.
  89629. */
  89630. get shadowMaxZ(): number;
  89631. /**
  89632. * Gets the shadow projection clipping maximum z value.
  89633. */
  89634. set shadowMaxZ(value: number);
  89635. /**
  89636. * Callback defining a custom Projection Matrix Builder.
  89637. * This can be used to override the default projection matrix computation.
  89638. */
  89639. customProjectionMatrixBuilder: (viewMatrix: Matrix, renderList: Array<AbstractMesh>, result: Matrix) => void;
  89640. /**
  89641. * The transformed position. Position of the light in world space taking parenting in account.
  89642. */
  89643. transformedPosition: Vector3;
  89644. /**
  89645. * The transformed direction. Direction of the light in world space taking parenting in account.
  89646. */
  89647. transformedDirection: Vector3;
  89648. private _needProjectionMatrixCompute;
  89649. /**
  89650. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  89651. * @returns true if the information has been computed, false if it does not need to (no parenting)
  89652. */
  89653. computeTransformedInformation(): boolean;
  89654. /**
  89655. * Return the depth scale used for the shadow map.
  89656. * @returns the depth scale.
  89657. */
  89658. getDepthScale(): number;
  89659. /**
  89660. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  89661. * @param faceIndex The index of the face we are computed the direction to generate shadow
  89662. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  89663. */
  89664. getShadowDirection(faceIndex?: number): Vector3;
  89665. /**
  89666. * Returns the ShadowLight absolute position in the World.
  89667. * @returns the position vector in world space
  89668. */
  89669. getAbsolutePosition(): Vector3;
  89670. /**
  89671. * Sets the ShadowLight direction toward the passed target.
  89672. * @param target The point to target in local space
  89673. * @returns the updated ShadowLight direction
  89674. */
  89675. setDirectionToTarget(target: Vector3): Vector3;
  89676. /**
  89677. * Returns the light rotation in euler definition.
  89678. * @returns the x y z rotation in local space.
  89679. */
  89680. getRotation(): Vector3;
  89681. /**
  89682. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  89683. * @returns true if a cube texture needs to be use
  89684. */
  89685. needCube(): boolean;
  89686. /**
  89687. * Detects if the projection matrix requires to be recomputed this frame.
  89688. * @returns true if it requires to be recomputed otherwise, false.
  89689. */
  89690. needProjectionMatrixCompute(): boolean;
  89691. /**
  89692. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  89693. */
  89694. forceProjectionMatrixCompute(): void;
  89695. /** @hidden */
  89696. _initCache(): void;
  89697. /** @hidden */
  89698. _isSynchronized(): boolean;
  89699. /**
  89700. * Computes the world matrix of the node
  89701. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  89702. * @returns the world matrix
  89703. */
  89704. computeWorldMatrix(force?: boolean): Matrix;
  89705. /**
  89706. * Gets the minZ used for shadow according to both the scene and the light.
  89707. * @param activeCamera The camera we are returning the min for
  89708. * @returns the depth min z
  89709. */
  89710. getDepthMinZ(activeCamera: Camera): number;
  89711. /**
  89712. * Gets the maxZ used for shadow according to both the scene and the light.
  89713. * @param activeCamera The camera we are returning the max for
  89714. * @returns the depth max z
  89715. */
  89716. getDepthMaxZ(activeCamera: Camera): number;
  89717. /**
  89718. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  89719. * @param matrix The materix to updated with the projection information
  89720. * @param viewMatrix The transform matrix of the light
  89721. * @param renderList The list of mesh to render in the map
  89722. * @returns The current light
  89723. */
  89724. setShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): IShadowLight;
  89725. }
  89726. }
  89727. declare module BABYLON {
  89728. /** @hidden */
  89729. export var packingFunctions: {
  89730. name: string;
  89731. shader: string;
  89732. };
  89733. }
  89734. declare module BABYLON {
  89735. /** @hidden */
  89736. export var bayerDitherFunctions: {
  89737. name: string;
  89738. shader: string;
  89739. };
  89740. }
  89741. declare module BABYLON {
  89742. /** @hidden */
  89743. export var shadowMapFragmentDeclaration: {
  89744. name: string;
  89745. shader: string;
  89746. };
  89747. }
  89748. declare module BABYLON {
  89749. /** @hidden */
  89750. export var clipPlaneFragmentDeclaration: {
  89751. name: string;
  89752. shader: string;
  89753. };
  89754. }
  89755. declare module BABYLON {
  89756. /** @hidden */
  89757. export var clipPlaneFragment: {
  89758. name: string;
  89759. shader: string;
  89760. };
  89761. }
  89762. declare module BABYLON {
  89763. /** @hidden */
  89764. export var shadowMapFragment: {
  89765. name: string;
  89766. shader: string;
  89767. };
  89768. }
  89769. declare module BABYLON {
  89770. /** @hidden */
  89771. export var shadowMapPixelShader: {
  89772. name: string;
  89773. shader: string;
  89774. };
  89775. }
  89776. declare module BABYLON {
  89777. /** @hidden */
  89778. export var bonesDeclaration: {
  89779. name: string;
  89780. shader: string;
  89781. };
  89782. }
  89783. declare module BABYLON {
  89784. /** @hidden */
  89785. export var morphTargetsVertexGlobalDeclaration: {
  89786. name: string;
  89787. shader: string;
  89788. };
  89789. }
  89790. declare module BABYLON {
  89791. /** @hidden */
  89792. export var morphTargetsVertexDeclaration: {
  89793. name: string;
  89794. shader: string;
  89795. };
  89796. }
  89797. declare module BABYLON {
  89798. /** @hidden */
  89799. export var instancesDeclaration: {
  89800. name: string;
  89801. shader: string;
  89802. };
  89803. }
  89804. declare module BABYLON {
  89805. /** @hidden */
  89806. export var helperFunctions: {
  89807. name: string;
  89808. shader: string;
  89809. };
  89810. }
  89811. declare module BABYLON {
  89812. /** @hidden */
  89813. export var shadowMapVertexDeclaration: {
  89814. name: string;
  89815. shader: string;
  89816. };
  89817. }
  89818. declare module BABYLON {
  89819. /** @hidden */
  89820. export var clipPlaneVertexDeclaration: {
  89821. name: string;
  89822. shader: string;
  89823. };
  89824. }
  89825. declare module BABYLON {
  89826. /** @hidden */
  89827. export var morphTargetsVertex: {
  89828. name: string;
  89829. shader: string;
  89830. };
  89831. }
  89832. declare module BABYLON {
  89833. /** @hidden */
  89834. export var instancesVertex: {
  89835. name: string;
  89836. shader: string;
  89837. };
  89838. }
  89839. declare module BABYLON {
  89840. /** @hidden */
  89841. export var bonesVertex: {
  89842. name: string;
  89843. shader: string;
  89844. };
  89845. }
  89846. declare module BABYLON {
  89847. /** @hidden */
  89848. export var shadowMapVertexNormalBias: {
  89849. name: string;
  89850. shader: string;
  89851. };
  89852. }
  89853. declare module BABYLON {
  89854. /** @hidden */
  89855. export var shadowMapVertexMetric: {
  89856. name: string;
  89857. shader: string;
  89858. };
  89859. }
  89860. declare module BABYLON {
  89861. /** @hidden */
  89862. export var clipPlaneVertex: {
  89863. name: string;
  89864. shader: string;
  89865. };
  89866. }
  89867. declare module BABYLON {
  89868. /** @hidden */
  89869. export var shadowMapVertexShader: {
  89870. name: string;
  89871. shader: string;
  89872. };
  89873. }
  89874. declare module BABYLON {
  89875. /** @hidden */
  89876. export var depthBoxBlurPixelShader: {
  89877. name: string;
  89878. shader: string;
  89879. };
  89880. }
  89881. declare module BABYLON {
  89882. /** @hidden */
  89883. export var shadowMapFragmentSoftTransparentShadow: {
  89884. name: string;
  89885. shader: string;
  89886. };
  89887. }
  89888. declare module BABYLON {
  89889. /**
  89890. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  89891. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  89892. */
  89893. export class EffectFallbacks implements IEffectFallbacks {
  89894. private _defines;
  89895. private _currentRank;
  89896. private _maxRank;
  89897. private _mesh;
  89898. /**
  89899. * Removes the fallback from the bound mesh.
  89900. */
  89901. unBindMesh(): void;
  89902. /**
  89903. * Adds a fallback on the specified property.
  89904. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89905. * @param define The name of the define in the shader
  89906. */
  89907. addFallback(rank: number, define: string): void;
  89908. /**
  89909. * Sets the mesh to use CPU skinning when needing to fallback.
  89910. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  89911. * @param mesh The mesh to use the fallbacks.
  89912. */
  89913. addCPUSkinningFallback(rank: number, mesh: AbstractMesh): void;
  89914. /**
  89915. * Checks to see if more fallbacks are still availible.
  89916. */
  89917. get hasMoreFallbacks(): boolean;
  89918. /**
  89919. * Removes the defines that should be removed when falling back.
  89920. * @param currentDefines defines the current define statements for the shader.
  89921. * @param effect defines the current effect we try to compile
  89922. * @returns The resulting defines with defines of the current rank removed.
  89923. */
  89924. reduce(currentDefines: string, effect: Effect): string;
  89925. }
  89926. }
  89927. declare module BABYLON {
  89928. /**
  89929. * Interface used to define Action
  89930. */
  89931. export interface IAction {
  89932. /**
  89933. * Trigger for the action
  89934. */
  89935. trigger: number;
  89936. /** Options of the trigger */
  89937. triggerOptions: any;
  89938. /**
  89939. * Gets the trigger parameters
  89940. * @returns the trigger parameters
  89941. */
  89942. getTriggerParameter(): any;
  89943. /**
  89944. * Internal only - executes current action event
  89945. * @hidden
  89946. */
  89947. _executeCurrent(evt?: ActionEvent): void;
  89948. /**
  89949. * Serialize placeholder for child classes
  89950. * @param parent of child
  89951. * @returns the serialized object
  89952. */
  89953. serialize(parent: any): any;
  89954. /**
  89955. * Internal only
  89956. * @hidden
  89957. */
  89958. _prepare(): void;
  89959. /**
  89960. * Internal only - manager for action
  89961. * @hidden
  89962. */
  89963. _actionManager: Nullable<AbstractActionManager>;
  89964. /**
  89965. * Adds action to chain of actions, may be a DoNothingAction
  89966. * @param action defines the next action to execute
  89967. * @returns The action passed in
  89968. * @see https://www.babylonjs-playground.com/#1T30HR#0
  89969. */
  89970. then(action: IAction): IAction;
  89971. }
  89972. /**
  89973. * The action to be carried out following a trigger
  89974. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  89975. */
  89976. export class Action implements IAction {
  89977. /** the trigger, with or without parameters, for the action */
  89978. triggerOptions: any;
  89979. /**
  89980. * Trigger for the action
  89981. */
  89982. trigger: number;
  89983. /**
  89984. * Internal only - manager for action
  89985. * @hidden
  89986. */
  89987. _actionManager: ActionManager;
  89988. private _nextActiveAction;
  89989. private _child;
  89990. private _condition?;
  89991. private _triggerParameter;
  89992. /**
  89993. * An event triggered prior to action being executed.
  89994. */
  89995. onBeforeExecuteObservable: Observable<Action>;
  89996. /**
  89997. * Creates a new Action
  89998. * @param triggerOptions the trigger, with or without parameters, for the action
  89999. * @param condition an optional determinant of action
  90000. */
  90001. constructor(
  90002. /** the trigger, with or without parameters, for the action */
  90003. triggerOptions: any, condition?: Condition);
  90004. /**
  90005. * Internal only
  90006. * @hidden
  90007. */
  90008. _prepare(): void;
  90009. /**
  90010. * Gets the trigger parameters
  90011. * @returns the trigger parameters
  90012. */
  90013. getTriggerParameter(): any;
  90014. /**
  90015. * Internal only - executes current action event
  90016. * @hidden
  90017. */
  90018. _executeCurrent(evt?: ActionEvent): void;
  90019. /**
  90020. * Execute placeholder for child classes
  90021. * @param evt optional action event
  90022. */
  90023. execute(evt?: ActionEvent): void;
  90024. /**
  90025. * Skips to next active action
  90026. */
  90027. skipToNextActiveAction(): void;
  90028. /**
  90029. * Adds action to chain of actions, may be a DoNothingAction
  90030. * @param action defines the next action to execute
  90031. * @returns The action passed in
  90032. * @see https://www.babylonjs-playground.com/#1T30HR#0
  90033. */
  90034. then(action: Action): Action;
  90035. /**
  90036. * Internal only
  90037. * @hidden
  90038. */
  90039. _getProperty(propertyPath: string): string;
  90040. /**
  90041. * Internal only
  90042. * @hidden
  90043. */
  90044. _getEffectiveTarget(target: any, propertyPath: string): any;
  90045. /**
  90046. * Serialize placeholder for child classes
  90047. * @param parent of child
  90048. * @returns the serialized object
  90049. */
  90050. serialize(parent: any): any;
  90051. /**
  90052. * Internal only called by serialize
  90053. * @hidden
  90054. */
  90055. protected _serialize(serializedAction: any, parent?: any): any;
  90056. /**
  90057. * Internal only
  90058. * @hidden
  90059. */
  90060. static _SerializeValueAsString: (value: any) => string;
  90061. /**
  90062. * Internal only
  90063. * @hidden
  90064. */
  90065. static _GetTargetProperty: (target: Scene | Node) => {
  90066. name: string;
  90067. targetType: string;
  90068. value: string;
  90069. };
  90070. }
  90071. }
  90072. declare module BABYLON {
  90073. /**
  90074. * A Condition applied to an Action
  90075. */
  90076. export class Condition {
  90077. /**
  90078. * Internal only - manager for action
  90079. * @hidden
  90080. */
  90081. _actionManager: ActionManager;
  90082. /**
  90083. * Internal only
  90084. * @hidden
  90085. */
  90086. _evaluationId: number;
  90087. /**
  90088. * Internal only
  90089. * @hidden
  90090. */
  90091. _currentResult: boolean;
  90092. /**
  90093. * Creates a new Condition
  90094. * @param actionManager the manager of the action the condition is applied to
  90095. */
  90096. constructor(actionManager: ActionManager);
  90097. /**
  90098. * Check if the current condition is valid
  90099. * @returns a boolean
  90100. */
  90101. isValid(): boolean;
  90102. /**
  90103. * Internal only
  90104. * @hidden
  90105. */
  90106. _getProperty(propertyPath: string): string;
  90107. /**
  90108. * Internal only
  90109. * @hidden
  90110. */
  90111. _getEffectiveTarget(target: any, propertyPath: string): any;
  90112. /**
  90113. * Serialize placeholder for child classes
  90114. * @returns the serialized object
  90115. */
  90116. serialize(): any;
  90117. /**
  90118. * Internal only
  90119. * @hidden
  90120. */
  90121. protected _serialize(serializedCondition: any): any;
  90122. }
  90123. /**
  90124. * Defines specific conditional operators as extensions of Condition
  90125. */
  90126. export class ValueCondition extends Condition {
  90127. /** path to specify the property of the target the conditional operator uses */
  90128. propertyPath: string;
  90129. /** the value compared by the conditional operator against the current value of the property */
  90130. value: any;
  90131. /** the conditional operator, default ValueCondition.IsEqual */
  90132. operator: number;
  90133. /**
  90134. * Internal only
  90135. * @hidden
  90136. */
  90137. private static _IsEqual;
  90138. /**
  90139. * Internal only
  90140. * @hidden
  90141. */
  90142. private static _IsDifferent;
  90143. /**
  90144. * Internal only
  90145. * @hidden
  90146. */
  90147. private static _IsGreater;
  90148. /**
  90149. * Internal only
  90150. * @hidden
  90151. */
  90152. private static _IsLesser;
  90153. /**
  90154. * returns the number for IsEqual
  90155. */
  90156. static get IsEqual(): number;
  90157. /**
  90158. * Returns the number for IsDifferent
  90159. */
  90160. static get IsDifferent(): number;
  90161. /**
  90162. * Returns the number for IsGreater
  90163. */
  90164. static get IsGreater(): number;
  90165. /**
  90166. * Returns the number for IsLesser
  90167. */
  90168. static get IsLesser(): number;
  90169. /**
  90170. * Internal only The action manager for the condition
  90171. * @hidden
  90172. */
  90173. _actionManager: ActionManager;
  90174. /**
  90175. * Internal only
  90176. * @hidden
  90177. */
  90178. private _target;
  90179. /**
  90180. * Internal only
  90181. * @hidden
  90182. */
  90183. private _effectiveTarget;
  90184. /**
  90185. * Internal only
  90186. * @hidden
  90187. */
  90188. private _property;
  90189. /**
  90190. * Creates a new ValueCondition
  90191. * @param actionManager manager for the action the condition applies to
  90192. * @param target for the action
  90193. * @param propertyPath path to specify the property of the target the conditional operator uses
  90194. * @param value the value compared by the conditional operator against the current value of the property
  90195. * @param operator the conditional operator, default ValueCondition.IsEqual
  90196. */
  90197. constructor(actionManager: ActionManager, target: any,
  90198. /** path to specify the property of the target the conditional operator uses */
  90199. propertyPath: string,
  90200. /** the value compared by the conditional operator against the current value of the property */
  90201. value: any,
  90202. /** the conditional operator, default ValueCondition.IsEqual */
  90203. operator?: number);
  90204. /**
  90205. * Compares the given value with the property value for the specified conditional operator
  90206. * @returns the result of the comparison
  90207. */
  90208. isValid(): boolean;
  90209. /**
  90210. * Serialize the ValueCondition into a JSON compatible object
  90211. * @returns serialization object
  90212. */
  90213. serialize(): any;
  90214. /**
  90215. * Gets the name of the conditional operator for the ValueCondition
  90216. * @param operator the conditional operator
  90217. * @returns the name
  90218. */
  90219. static GetOperatorName(operator: number): string;
  90220. }
  90221. /**
  90222. * Defines a predicate condition as an extension of Condition
  90223. */
  90224. export class PredicateCondition extends Condition {
  90225. /** defines the predicate function used to validate the condition */
  90226. predicate: () => boolean;
  90227. /**
  90228. * Internal only - manager for action
  90229. * @hidden
  90230. */
  90231. _actionManager: ActionManager;
  90232. /**
  90233. * Creates a new PredicateCondition
  90234. * @param actionManager manager for the action the condition applies to
  90235. * @param predicate defines the predicate function used to validate the condition
  90236. */
  90237. constructor(actionManager: ActionManager,
  90238. /** defines the predicate function used to validate the condition */
  90239. predicate: () => boolean);
  90240. /**
  90241. * @returns the validity of the predicate condition
  90242. */
  90243. isValid(): boolean;
  90244. }
  90245. /**
  90246. * Defines a state condition as an extension of Condition
  90247. */
  90248. export class StateCondition extends Condition {
  90249. /** Value to compare with target state */
  90250. value: string;
  90251. /**
  90252. * Internal only - manager for action
  90253. * @hidden
  90254. */
  90255. _actionManager: ActionManager;
  90256. /**
  90257. * Internal only
  90258. * @hidden
  90259. */
  90260. private _target;
  90261. /**
  90262. * Creates a new StateCondition
  90263. * @param actionManager manager for the action the condition applies to
  90264. * @param target of the condition
  90265. * @param value to compare with target state
  90266. */
  90267. constructor(actionManager: ActionManager, target: any,
  90268. /** Value to compare with target state */
  90269. value: string);
  90270. /**
  90271. * Gets a boolean indicating if the current condition is met
  90272. * @returns the validity of the state
  90273. */
  90274. isValid(): boolean;
  90275. /**
  90276. * Serialize the StateCondition into a JSON compatible object
  90277. * @returns serialization object
  90278. */
  90279. serialize(): any;
  90280. }
  90281. }
  90282. declare module BABYLON {
  90283. /**
  90284. * This defines an action responsible to toggle a boolean once triggered.
  90285. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90286. */
  90287. export class SwitchBooleanAction extends Action {
  90288. /**
  90289. * The path to the boolean property in the target object
  90290. */
  90291. propertyPath: string;
  90292. private _target;
  90293. private _effectiveTarget;
  90294. private _property;
  90295. /**
  90296. * Instantiate the action
  90297. * @param triggerOptions defines the trigger options
  90298. * @param target defines the object containing the boolean
  90299. * @param propertyPath defines the path to the boolean property in the target object
  90300. * @param condition defines the trigger related conditions
  90301. */
  90302. constructor(triggerOptions: any, target: any, propertyPath: string, condition?: Condition);
  90303. /** @hidden */
  90304. _prepare(): void;
  90305. /**
  90306. * Execute the action toggle the boolean value.
  90307. */
  90308. execute(): void;
  90309. /**
  90310. * Serializes the actions and its related information.
  90311. * @param parent defines the object to serialize in
  90312. * @returns the serialized object
  90313. */
  90314. serialize(parent: any): any;
  90315. }
  90316. /**
  90317. * This defines an action responsible to set a the state field of the target
  90318. * to a desired value once triggered.
  90319. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90320. */
  90321. export class SetStateAction extends Action {
  90322. /**
  90323. * The value to store in the state field.
  90324. */
  90325. value: string;
  90326. private _target;
  90327. /**
  90328. * Instantiate the action
  90329. * @param triggerOptions defines the trigger options
  90330. * @param target defines the object containing the state property
  90331. * @param value defines the value to store in the state field
  90332. * @param condition defines the trigger related conditions
  90333. */
  90334. constructor(triggerOptions: any, target: any, value: string, condition?: Condition);
  90335. /**
  90336. * Execute the action and store the value on the target state property.
  90337. */
  90338. execute(): void;
  90339. /**
  90340. * Serializes the actions and its related information.
  90341. * @param parent defines the object to serialize in
  90342. * @returns the serialized object
  90343. */
  90344. serialize(parent: any): any;
  90345. }
  90346. /**
  90347. * This defines an action responsible to set a property of the target
  90348. * to a desired value once triggered.
  90349. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90350. */
  90351. export class SetValueAction extends Action {
  90352. /**
  90353. * The path of the property to set in the target.
  90354. */
  90355. propertyPath: string;
  90356. /**
  90357. * The value to set in the property
  90358. */
  90359. value: any;
  90360. private _target;
  90361. private _effectiveTarget;
  90362. private _property;
  90363. /**
  90364. * Instantiate the action
  90365. * @param triggerOptions defines the trigger options
  90366. * @param target defines the object containing the property
  90367. * @param propertyPath defines the path of the property to set in the target
  90368. * @param value defines the value to set in the property
  90369. * @param condition defines the trigger related conditions
  90370. */
  90371. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90372. /** @hidden */
  90373. _prepare(): void;
  90374. /**
  90375. * Execute the action and set the targetted property to the desired value.
  90376. */
  90377. execute(): void;
  90378. /**
  90379. * Serializes the actions and its related information.
  90380. * @param parent defines the object to serialize in
  90381. * @returns the serialized object
  90382. */
  90383. serialize(parent: any): any;
  90384. }
  90385. /**
  90386. * This defines an action responsible to increment the target value
  90387. * to a desired value once triggered.
  90388. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90389. */
  90390. export class IncrementValueAction extends Action {
  90391. /**
  90392. * The path of the property to increment in the target.
  90393. */
  90394. propertyPath: string;
  90395. /**
  90396. * The value we should increment the property by.
  90397. */
  90398. value: any;
  90399. private _target;
  90400. private _effectiveTarget;
  90401. private _property;
  90402. /**
  90403. * Instantiate the action
  90404. * @param triggerOptions defines the trigger options
  90405. * @param target defines the object containing the property
  90406. * @param propertyPath defines the path of the property to increment in the target
  90407. * @param value defines the value value we should increment the property by
  90408. * @param condition defines the trigger related conditions
  90409. */
  90410. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, condition?: Condition);
  90411. /** @hidden */
  90412. _prepare(): void;
  90413. /**
  90414. * Execute the action and increment the target of the value amount.
  90415. */
  90416. execute(): void;
  90417. /**
  90418. * Serializes the actions and its related information.
  90419. * @param parent defines the object to serialize in
  90420. * @returns the serialized object
  90421. */
  90422. serialize(parent: any): any;
  90423. }
  90424. /**
  90425. * This defines an action responsible to start an animation once triggered.
  90426. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90427. */
  90428. export class PlayAnimationAction extends Action {
  90429. /**
  90430. * Where the animation should start (animation frame)
  90431. */
  90432. from: number;
  90433. /**
  90434. * Where the animation should stop (animation frame)
  90435. */
  90436. to: number;
  90437. /**
  90438. * Define if the animation should loop or stop after the first play.
  90439. */
  90440. loop?: boolean;
  90441. private _target;
  90442. /**
  90443. * Instantiate the action
  90444. * @param triggerOptions defines the trigger options
  90445. * @param target defines the target animation or animation name
  90446. * @param from defines from where the animation should start (animation frame)
  90447. * @param end defines where the animation should stop (animation frame)
  90448. * @param loop defines if the animation should loop or stop after the first play
  90449. * @param condition defines the trigger related conditions
  90450. */
  90451. constructor(triggerOptions: any, target: any, from: number, to: number, loop?: boolean, condition?: Condition);
  90452. /** @hidden */
  90453. _prepare(): void;
  90454. /**
  90455. * Execute the action and play the animation.
  90456. */
  90457. execute(): void;
  90458. /**
  90459. * Serializes the actions and its related information.
  90460. * @param parent defines the object to serialize in
  90461. * @returns the serialized object
  90462. */
  90463. serialize(parent: any): any;
  90464. }
  90465. /**
  90466. * This defines an action responsible to stop an animation once triggered.
  90467. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90468. */
  90469. export class StopAnimationAction extends Action {
  90470. private _target;
  90471. /**
  90472. * Instantiate the action
  90473. * @param triggerOptions defines the trigger options
  90474. * @param target defines the target animation or animation name
  90475. * @param condition defines the trigger related conditions
  90476. */
  90477. constructor(triggerOptions: any, target: any, condition?: Condition);
  90478. /** @hidden */
  90479. _prepare(): void;
  90480. /**
  90481. * Execute the action and stop the animation.
  90482. */
  90483. execute(): void;
  90484. /**
  90485. * Serializes the actions and its related information.
  90486. * @param parent defines the object to serialize in
  90487. * @returns the serialized object
  90488. */
  90489. serialize(parent: any): any;
  90490. }
  90491. /**
  90492. * This defines an action responsible that does nothing once triggered.
  90493. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90494. */
  90495. export class DoNothingAction extends Action {
  90496. /**
  90497. * Instantiate the action
  90498. * @param triggerOptions defines the trigger options
  90499. * @param condition defines the trigger related conditions
  90500. */
  90501. constructor(triggerOptions?: any, condition?: Condition);
  90502. /**
  90503. * Execute the action and do nothing.
  90504. */
  90505. execute(): void;
  90506. /**
  90507. * Serializes the actions and its related information.
  90508. * @param parent defines the object to serialize in
  90509. * @returns the serialized object
  90510. */
  90511. serialize(parent: any): any;
  90512. }
  90513. /**
  90514. * This defines an action responsible to trigger several actions once triggered.
  90515. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90516. */
  90517. export class CombineAction extends Action {
  90518. /**
  90519. * The list of aggregated animations to run.
  90520. */
  90521. children: Action[];
  90522. /**
  90523. * Instantiate the action
  90524. * @param triggerOptions defines the trigger options
  90525. * @param children defines the list of aggregated animations to run
  90526. * @param condition defines the trigger related conditions
  90527. */
  90528. constructor(triggerOptions: any, children: Action[], condition?: Condition);
  90529. /** @hidden */
  90530. _prepare(): void;
  90531. /**
  90532. * Execute the action and executes all the aggregated actions.
  90533. */
  90534. execute(evt: ActionEvent): void;
  90535. /**
  90536. * Serializes the actions and its related information.
  90537. * @param parent defines the object to serialize in
  90538. * @returns the serialized object
  90539. */
  90540. serialize(parent: any): any;
  90541. }
  90542. /**
  90543. * This defines an action responsible to run code (external event) once triggered.
  90544. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90545. */
  90546. export class ExecuteCodeAction extends Action {
  90547. /**
  90548. * The callback function to run.
  90549. */
  90550. func: (evt: ActionEvent) => void;
  90551. /**
  90552. * Instantiate the action
  90553. * @param triggerOptions defines the trigger options
  90554. * @param func defines the callback function to run
  90555. * @param condition defines the trigger related conditions
  90556. */
  90557. constructor(triggerOptions: any, func: (evt: ActionEvent) => void, condition?: Condition);
  90558. /**
  90559. * Execute the action and run the attached code.
  90560. */
  90561. execute(evt: ActionEvent): void;
  90562. }
  90563. /**
  90564. * This defines an action responsible to set the parent property of the target once triggered.
  90565. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90566. */
  90567. export class SetParentAction extends Action {
  90568. private _parent;
  90569. private _target;
  90570. /**
  90571. * Instantiate the action
  90572. * @param triggerOptions defines the trigger options
  90573. * @param target defines the target containing the parent property
  90574. * @param parent defines from where the animation should start (animation frame)
  90575. * @param condition defines the trigger related conditions
  90576. */
  90577. constructor(triggerOptions: any, target: any, parent: any, condition?: Condition);
  90578. /** @hidden */
  90579. _prepare(): void;
  90580. /**
  90581. * Execute the action and set the parent property.
  90582. */
  90583. execute(): void;
  90584. /**
  90585. * Serializes the actions and its related information.
  90586. * @param parent defines the object to serialize in
  90587. * @returns the serialized object
  90588. */
  90589. serialize(parent: any): any;
  90590. }
  90591. }
  90592. declare module BABYLON {
  90593. /**
  90594. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  90595. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  90596. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  90597. */
  90598. export class ActionManager extends AbstractActionManager {
  90599. /**
  90600. * Nothing
  90601. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90602. */
  90603. static readonly NothingTrigger: number;
  90604. /**
  90605. * On pick
  90606. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90607. */
  90608. static readonly OnPickTrigger: number;
  90609. /**
  90610. * On left pick
  90611. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90612. */
  90613. static readonly OnLeftPickTrigger: number;
  90614. /**
  90615. * On right pick
  90616. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90617. */
  90618. static readonly OnRightPickTrigger: number;
  90619. /**
  90620. * On center pick
  90621. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90622. */
  90623. static readonly OnCenterPickTrigger: number;
  90624. /**
  90625. * On pick down
  90626. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90627. */
  90628. static readonly OnPickDownTrigger: number;
  90629. /**
  90630. * On double pick
  90631. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90632. */
  90633. static readonly OnDoublePickTrigger: number;
  90634. /**
  90635. * On pick up
  90636. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90637. */
  90638. static readonly OnPickUpTrigger: number;
  90639. /**
  90640. * On pick out.
  90641. * This trigger will only be raised if you also declared a OnPickDown
  90642. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90643. */
  90644. static readonly OnPickOutTrigger: number;
  90645. /**
  90646. * On long press
  90647. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90648. */
  90649. static readonly OnLongPressTrigger: number;
  90650. /**
  90651. * On pointer over
  90652. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90653. */
  90654. static readonly OnPointerOverTrigger: number;
  90655. /**
  90656. * On pointer out
  90657. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90658. */
  90659. static readonly OnPointerOutTrigger: number;
  90660. /**
  90661. * On every frame
  90662. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90663. */
  90664. static readonly OnEveryFrameTrigger: number;
  90665. /**
  90666. * On intersection enter
  90667. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90668. */
  90669. static readonly OnIntersectionEnterTrigger: number;
  90670. /**
  90671. * On intersection exit
  90672. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90673. */
  90674. static readonly OnIntersectionExitTrigger: number;
  90675. /**
  90676. * On key down
  90677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90678. */
  90679. static readonly OnKeyDownTrigger: number;
  90680. /**
  90681. * On key up
  90682. * @see https://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  90683. */
  90684. static readonly OnKeyUpTrigger: number;
  90685. private _scene;
  90686. /**
  90687. * Creates a new action manager
  90688. * @param scene defines the hosting scene
  90689. */
  90690. constructor(scene: Scene);
  90691. /**
  90692. * Releases all associated resources
  90693. */
  90694. dispose(): void;
  90695. /**
  90696. * Gets hosting scene
  90697. * @returns the hosting scene
  90698. */
  90699. getScene(): Scene;
  90700. /**
  90701. * Does this action manager handles actions of any of the given triggers
  90702. * @param triggers defines the triggers to be tested
  90703. * @return a boolean indicating whether one (or more) of the triggers is handled
  90704. */
  90705. hasSpecificTriggers(triggers: number[]): boolean;
  90706. /**
  90707. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  90708. * speed.
  90709. * @param triggerA defines the trigger to be tested
  90710. * @param triggerB defines the trigger to be tested
  90711. * @return a boolean indicating whether one (or more) of the triggers is handled
  90712. */
  90713. hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  90714. /**
  90715. * Does this action manager handles actions of a given trigger
  90716. * @param trigger defines the trigger to be tested
  90717. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  90718. * @return whether the trigger is handled
  90719. */
  90720. hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  90721. /**
  90722. * Does this action manager has pointer triggers
  90723. */
  90724. get hasPointerTriggers(): boolean;
  90725. /**
  90726. * Does this action manager has pick triggers
  90727. */
  90728. get hasPickTriggers(): boolean;
  90729. /**
  90730. * Registers an action to this action manager
  90731. * @param action defines the action to be registered
  90732. * @return the action amended (prepared) after registration
  90733. */
  90734. registerAction(action: IAction): Nullable<IAction>;
  90735. /**
  90736. * Unregisters an action to this action manager
  90737. * @param action defines the action to be unregistered
  90738. * @return a boolean indicating whether the action has been unregistered
  90739. */
  90740. unregisterAction(action: IAction): Boolean;
  90741. /**
  90742. * Process a specific trigger
  90743. * @param trigger defines the trigger to process
  90744. * @param evt defines the event details to be processed
  90745. */
  90746. processTrigger(trigger: number, evt?: IActionEvent): void;
  90747. /** @hidden */
  90748. _getEffectiveTarget(target: any, propertyPath: string): any;
  90749. /** @hidden */
  90750. _getProperty(propertyPath: string): string;
  90751. /**
  90752. * Serialize this manager to a JSON object
  90753. * @param name defines the property name to store this manager
  90754. * @returns a JSON representation of this manager
  90755. */
  90756. serialize(name: string): any;
  90757. /**
  90758. * Creates a new ActionManager from a JSON data
  90759. * @param parsedActions defines the JSON data to read from
  90760. * @param object defines the hosting mesh
  90761. * @param scene defines the hosting scene
  90762. */
  90763. static Parse(parsedActions: any, object: Nullable<AbstractMesh>, scene: Scene): void;
  90764. /**
  90765. * Get a trigger name by index
  90766. * @param trigger defines the trigger index
  90767. * @returns a trigger name
  90768. */
  90769. static GetTriggerName(trigger: number): string;
  90770. }
  90771. }
  90772. declare module BABYLON {
  90773. /**
  90774. * Class used to represent a sprite
  90775. * @see https://doc.babylonjs.com/babylon101/sprites
  90776. */
  90777. export class Sprite implements IAnimatable {
  90778. /** defines the name */
  90779. name: string;
  90780. /** Gets or sets the current world position */
  90781. position: Vector3;
  90782. /** Gets or sets the main color */
  90783. color: Color4;
  90784. /** Gets or sets the width */
  90785. width: number;
  90786. /** Gets or sets the height */
  90787. height: number;
  90788. /** Gets or sets rotation angle */
  90789. angle: number;
  90790. /** Gets or sets the cell index in the sprite sheet */
  90791. cellIndex: number;
  90792. /** Gets or sets the cell reference in the sprite sheet, uses sprite's filename when added to sprite sheet */
  90793. cellRef: string;
  90794. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  90795. invertU: boolean;
  90796. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  90797. invertV: boolean;
  90798. /** Gets or sets a boolean indicating that this sprite should be disposed after animation ends */
  90799. disposeWhenFinishedAnimating: boolean;
  90800. /** Gets the list of attached animations */
  90801. animations: Nullable<Array<Animation>>;
  90802. /** Gets or sets a boolean indicating if the sprite can be picked */
  90803. isPickable: boolean;
  90804. /** Gets or sets a boolean indicating that sprite texture alpha will be used for precise picking (false by default) */
  90805. useAlphaForPicking: boolean;
  90806. /** @hidden */
  90807. _xOffset: number;
  90808. /** @hidden */
  90809. _yOffset: number;
  90810. /** @hidden */
  90811. _xSize: number;
  90812. /** @hidden */
  90813. _ySize: number;
  90814. /**
  90815. * Gets or sets the associated action manager
  90816. */
  90817. actionManager: Nullable<ActionManager>;
  90818. /**
  90819. * An event triggered when the control has been disposed
  90820. */
  90821. onDisposeObservable: Observable<Sprite>;
  90822. private _animationStarted;
  90823. private _loopAnimation;
  90824. private _fromIndex;
  90825. private _toIndex;
  90826. private _delay;
  90827. private _direction;
  90828. private _manager;
  90829. private _time;
  90830. private _onAnimationEnd;
  90831. /**
  90832. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  90833. */
  90834. isVisible: boolean;
  90835. /**
  90836. * Gets or sets the sprite size
  90837. */
  90838. get size(): number;
  90839. set size(value: number);
  90840. /**
  90841. * Returns a boolean indicating if the animation is started
  90842. */
  90843. get animationStarted(): boolean;
  90844. /**
  90845. * Gets or sets the unique id of the sprite
  90846. */
  90847. uniqueId: number;
  90848. /**
  90849. * Gets the manager of this sprite
  90850. */
  90851. get manager(): ISpriteManager;
  90852. /**
  90853. * Creates a new Sprite
  90854. * @param name defines the name
  90855. * @param manager defines the manager
  90856. */
  90857. constructor(
  90858. /** defines the name */
  90859. name: string, manager: ISpriteManager);
  90860. /**
  90861. * Returns the string "Sprite"
  90862. * @returns "Sprite"
  90863. */
  90864. getClassName(): string;
  90865. /** Gets or sets the initial key for the animation (setting it will restart the animation) */
  90866. get fromIndex(): number;
  90867. set fromIndex(value: number);
  90868. /** Gets or sets the end key for the animation (setting it will restart the animation) */
  90869. get toIndex(): number;
  90870. set toIndex(value: number);
  90871. /** Gets or sets a boolean indicating if the animation is looping (setting it will restart the animation) */
  90872. get loopAnimation(): boolean;
  90873. set loopAnimation(value: boolean);
  90874. /** Gets or sets the delay between cell changes (setting it will restart the animation) */
  90875. get delay(): number;
  90876. set delay(value: number);
  90877. /**
  90878. * Starts an animation
  90879. * @param from defines the initial key
  90880. * @param to defines the end key
  90881. * @param loop defines if the animation must loop
  90882. * @param delay defines the start delay (in ms)
  90883. * @param onAnimationEnd defines a callback to call when animation ends
  90884. */
  90885. playAnimation(from: number, to: number, loop: boolean, delay: number, onAnimationEnd?: Nullable<() => void>): void;
  90886. /** Stops current animation (if any) */
  90887. stopAnimation(): void;
  90888. /** @hidden */
  90889. _animate(deltaTime: number): void;
  90890. /** Release associated resources */
  90891. dispose(): void;
  90892. /**
  90893. * Serializes the sprite to a JSON object
  90894. * @returns the JSON object
  90895. */
  90896. serialize(): any;
  90897. /**
  90898. * Parses a JSON object to create a new sprite
  90899. * @param parsedSprite The JSON object to parse
  90900. * @param manager defines the hosting manager
  90901. * @returns the new sprite
  90902. */
  90903. static Parse(parsedSprite: any, manager: SpriteManager): Sprite;
  90904. }
  90905. }
  90906. declare module BABYLON {
  90907. /**
  90908. * Information about the result of picking within a scene
  90909. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  90910. */
  90911. export class PickingInfo {
  90912. /** @hidden */
  90913. _pickingUnavailable: boolean;
  90914. /**
  90915. * If the pick collided with an object
  90916. */
  90917. hit: boolean;
  90918. /**
  90919. * Distance away where the pick collided
  90920. */
  90921. distance: number;
  90922. /**
  90923. * The location of pick collision
  90924. */
  90925. pickedPoint: Nullable<Vector3>;
  90926. /**
  90927. * The mesh corresponding the the pick collision
  90928. */
  90929. pickedMesh: Nullable<AbstractMesh>;
  90930. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calculating the texture coordinates of the collision.*/
  90931. bu: number;
  90932. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calculating the texture coordinates of the collision.*/
  90933. bv: number;
  90934. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90935. faceId: number;
  90936. /** The index of the face on the subMesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  90937. subMeshFaceId: number;
  90938. /** Id of the the submesh that was picked */
  90939. subMeshId: number;
  90940. /** If a sprite was picked, this will be the sprite the pick collided with */
  90941. pickedSprite: Nullable<Sprite>;
  90942. /** If we are pikcing a mesh with thin instance, this will give you the picked thin instance */
  90943. thinInstanceIndex: number;
  90944. /**
  90945. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  90946. */
  90947. originMesh: Nullable<AbstractMesh>;
  90948. /**
  90949. * The ray that was used to perform the picking.
  90950. */
  90951. ray: Nullable<Ray>;
  90952. /**
  90953. * Gets the normal correspodning to the face the pick collided with
  90954. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  90955. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  90956. * @returns The normal correspodning to the face the pick collided with
  90957. */
  90958. getNormal(useWorldCoordinates?: boolean, useVerticesNormals?: boolean): Nullable<Vector3>;
  90959. /**
  90960. * Gets the texture coordinates of where the pick occured
  90961. * @returns the vector containing the coordnates of the texture
  90962. */
  90963. getTextureCoordinates(): Nullable<Vector2>;
  90964. }
  90965. }
  90966. declare module BABYLON {
  90967. /**
  90968. * Class representing a ray with position and direction
  90969. */
  90970. export class Ray {
  90971. /** origin point */
  90972. origin: Vector3;
  90973. /** direction */
  90974. direction: Vector3;
  90975. /** length of the ray */
  90976. length: number;
  90977. private static readonly _TmpVector3;
  90978. private _tmpRay;
  90979. /**
  90980. * Creates a new ray
  90981. * @param origin origin point
  90982. * @param direction direction
  90983. * @param length length of the ray
  90984. */
  90985. constructor(
  90986. /** origin point */
  90987. origin: Vector3,
  90988. /** direction */
  90989. direction: Vector3,
  90990. /** length of the ray */
  90991. length?: number);
  90992. /**
  90993. * Checks if the ray intersects a box
  90994. * This does not account for the ray lenght by design to improve perfs.
  90995. * @param minimum bound of the box
  90996. * @param maximum bound of the box
  90997. * @param intersectionTreshold extra extend to be added to the box in all direction
  90998. * @returns if the box was hit
  90999. */
  91000. intersectsBoxMinMax(minimum: DeepImmutable<Vector3>, maximum: DeepImmutable<Vector3>, intersectionTreshold?: number): boolean;
  91001. /**
  91002. * Checks if the ray intersects a box
  91003. * This does not account for the ray lenght by design to improve perfs.
  91004. * @param box the bounding box to check
  91005. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  91006. * @returns if the box was hit
  91007. */
  91008. intersectsBox(box: DeepImmutable<BoundingBox>, intersectionTreshold?: number): boolean;
  91009. /**
  91010. * If the ray hits a sphere
  91011. * @param sphere the bounding sphere to check
  91012. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  91013. * @returns true if it hits the sphere
  91014. */
  91015. intersectsSphere(sphere: DeepImmutable<BoundingSphere>, intersectionTreshold?: number): boolean;
  91016. /**
  91017. * If the ray hits a triange
  91018. * @param vertex0 triangle vertex
  91019. * @param vertex1 triangle vertex
  91020. * @param vertex2 triangle vertex
  91021. * @returns intersection information if hit
  91022. */
  91023. intersectsTriangle(vertex0: DeepImmutable<Vector3>, vertex1: DeepImmutable<Vector3>, vertex2: DeepImmutable<Vector3>): Nullable<IntersectionInfo>;
  91024. /**
  91025. * Checks if ray intersects a plane
  91026. * @param plane the plane to check
  91027. * @returns the distance away it was hit
  91028. */
  91029. intersectsPlane(plane: DeepImmutable<Plane>): Nullable<number>;
  91030. /**
  91031. * Calculate the intercept of a ray on a given axis
  91032. * @param axis to check 'x' | 'y' | 'z'
  91033. * @param offset from axis interception (i.e. an offset of 1y is intercepted above ground)
  91034. * @returns a vector containing the coordinates where 'axis' is equal to zero (else offset), or null if there is no intercept.
  91035. */
  91036. intersectsAxis(axis: string, offset?: number): Nullable<Vector3>;
  91037. /**
  91038. * Checks if ray intersects a mesh
  91039. * @param mesh the mesh to check
  91040. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91041. * @returns picking info of the intersecton
  91042. */
  91043. intersectsMesh(mesh: DeepImmutable<AbstractMesh>, fastCheck?: boolean): PickingInfo;
  91044. /**
  91045. * Checks if ray intersects a mesh
  91046. * @param meshes the meshes to check
  91047. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91048. * @param results array to store result in
  91049. * @returns Array of picking infos
  91050. */
  91051. intersectsMeshes(meshes: Array<DeepImmutable<AbstractMesh>>, fastCheck?: boolean, results?: Array<PickingInfo>): Array<PickingInfo>;
  91052. private _comparePickingInfo;
  91053. private static smallnum;
  91054. private static rayl;
  91055. /**
  91056. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  91057. * @param sega the first point of the segment to test the intersection against
  91058. * @param segb the second point of the segment to test the intersection against
  91059. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  91060. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  91061. */
  91062. intersectionSegment(sega: DeepImmutable<Vector3>, segb: DeepImmutable<Vector3>, threshold: number): number;
  91063. /**
  91064. * Update the ray from viewport position
  91065. * @param x position
  91066. * @param y y position
  91067. * @param viewportWidth viewport width
  91068. * @param viewportHeight viewport height
  91069. * @param world world matrix
  91070. * @param view view matrix
  91071. * @param projection projection matrix
  91072. * @returns this ray updated
  91073. */
  91074. update(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91075. /**
  91076. * Creates a ray with origin and direction of 0,0,0
  91077. * @returns the new ray
  91078. */
  91079. static Zero(): Ray;
  91080. /**
  91081. * Creates a new ray from screen space and viewport
  91082. * @param x position
  91083. * @param y y position
  91084. * @param viewportWidth viewport width
  91085. * @param viewportHeight viewport height
  91086. * @param world world matrix
  91087. * @param view view matrix
  91088. * @param projection projection matrix
  91089. * @returns new ray
  91090. */
  91091. static CreateNew(x: number, y: number, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): Ray;
  91092. /**
  91093. * 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
  91094. * transformed to the given world matrix.
  91095. * @param origin The origin point
  91096. * @param end The end point
  91097. * @param world a matrix to transform the ray to. Default is the identity matrix.
  91098. * @returns the new ray
  91099. */
  91100. static CreateNewFromTo(origin: Vector3, end: Vector3, world?: DeepImmutable<Matrix>): Ray;
  91101. /**
  91102. * Transforms a ray by a matrix
  91103. * @param ray ray to transform
  91104. * @param matrix matrix to apply
  91105. * @returns the resulting new ray
  91106. */
  91107. static Transform(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>): Ray;
  91108. /**
  91109. * Transforms a ray by a matrix
  91110. * @param ray ray to transform
  91111. * @param matrix matrix to apply
  91112. * @param result ray to store result in
  91113. */
  91114. static TransformToRef(ray: DeepImmutable<Ray>, matrix: DeepImmutable<Matrix>, result: Ray): void;
  91115. /**
  91116. * Unproject a ray from screen space to object space
  91117. * @param sourceX defines the screen space x coordinate to use
  91118. * @param sourceY defines the screen space y coordinate to use
  91119. * @param viewportWidth defines the current width of the viewport
  91120. * @param viewportHeight defines the current height of the viewport
  91121. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  91122. * @param view defines the view matrix to use
  91123. * @param projection defines the projection matrix to use
  91124. */
  91125. unprojectRayToRef(sourceX: float, sourceY: float, viewportWidth: number, viewportHeight: number, world: DeepImmutable<Matrix>, view: DeepImmutable<Matrix>, projection: DeepImmutable<Matrix>): void;
  91126. }
  91127. /**
  91128. * Type used to define predicate used to select faces when a mesh intersection is detected
  91129. */
  91130. export type TrianglePickingPredicate = (p0: Vector3, p1: Vector3, p2: Vector3, ray: Ray) => boolean;
  91131. interface Scene {
  91132. /** @hidden */
  91133. _tempPickingRay: Nullable<Ray>;
  91134. /** @hidden */
  91135. _cachedRayForTransform: Ray;
  91136. /** @hidden */
  91137. _pickWithRayInverseMatrix: Matrix;
  91138. /** @hidden */
  91139. _internalPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91140. /** @hidden */
  91141. _internalMultiPick(rayFunction: (world: Matrix) => Ray, predicate?: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  91142. /** @hidden */
  91143. _internalPickForMesh(pickingInfo: Nullable<PickingInfo>, rayFunction: (world: Matrix) => Ray, mesh: AbstractMesh, world: Matrix, fastCheck?: boolean, onlyBoundingInfo?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  91144. }
  91145. }
  91146. declare module BABYLON {
  91147. /**
  91148. * Groups all the scene component constants in one place to ease maintenance.
  91149. * @hidden
  91150. */
  91151. export class SceneComponentConstants {
  91152. static readonly NAME_EFFECTLAYER: string;
  91153. static readonly NAME_LAYER: string;
  91154. static readonly NAME_LENSFLARESYSTEM: string;
  91155. static readonly NAME_BOUNDINGBOXRENDERER: string;
  91156. static readonly NAME_PARTICLESYSTEM: string;
  91157. static readonly NAME_GAMEPAD: string;
  91158. static readonly NAME_SIMPLIFICATIONQUEUE: string;
  91159. static readonly NAME_GEOMETRYBUFFERRENDERER: string;
  91160. static readonly NAME_PREPASSRENDERER: string;
  91161. static readonly NAME_DEPTHRENDERER: string;
  91162. static readonly NAME_POSTPROCESSRENDERPIPELINEMANAGER: string;
  91163. static readonly NAME_SPRITE: string;
  91164. static readonly NAME_SUBSURFACE: string;
  91165. static readonly NAME_OUTLINERENDERER: string;
  91166. static readonly NAME_PROCEDURALTEXTURE: string;
  91167. static readonly NAME_SHADOWGENERATOR: string;
  91168. static readonly NAME_OCTREE: string;
  91169. static readonly NAME_PHYSICSENGINE: string;
  91170. static readonly NAME_AUDIO: string;
  91171. static readonly STEP_ISREADYFORMESH_EFFECTLAYER: number;
  91172. static readonly STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91173. static readonly STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER: number;
  91174. static readonly STEP_ACTIVEMESH_BOUNDINGBOXRENDERER: number;
  91175. static readonly STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER: number;
  91176. static readonly STEP_BEFORECAMERADRAW_EFFECTLAYER: number;
  91177. static readonly STEP_BEFORECAMERADRAW_LAYER: number;
  91178. static readonly STEP_BEFORECAMERADRAW_PREPASS: number;
  91179. static readonly STEP_BEFORERENDERTARGETDRAW_LAYER: number;
  91180. static readonly STEP_BEFORERENDERINGMESH_OUTLINE: number;
  91181. static readonly STEP_AFTERRENDERINGMESH_OUTLINE: number;
  91182. static readonly STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW: number;
  91183. static readonly STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER: number;
  91184. static readonly STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE: number;
  91185. static readonly STEP_BEFORECAMERAUPDATE_GAMEPAD: number;
  91186. static readonly STEP_BEFORECLEAR_PROCEDURALTEXTURE: number;
  91187. static readonly STEP_AFTERRENDERTARGETDRAW_LAYER: number;
  91188. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER: number;
  91189. static readonly STEP_AFTERCAMERADRAW_LENSFLARESYSTEM: number;
  91190. static readonly STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW: number;
  91191. static readonly STEP_AFTERCAMERADRAW_LAYER: number;
  91192. static readonly STEP_AFTERCAMERADRAW_PREPASS: number;
  91193. static readonly STEP_AFTERRENDER_AUDIO: number;
  91194. static readonly STEP_GATHERRENDERTARGETS_DEPTHRENDERER: number;
  91195. static readonly STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER: number;
  91196. static readonly STEP_GATHERRENDERTARGETS_SHADOWGENERATOR: number;
  91197. static readonly STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER: number;
  91198. static readonly STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER: number;
  91199. static readonly STEP_BEFORECLEARSTAGE_PREPASS: number;
  91200. static readonly STEP_POINTERMOVE_SPRITE: number;
  91201. static readonly STEP_POINTERDOWN_SPRITE: number;
  91202. static readonly STEP_POINTERUP_SPRITE: number;
  91203. }
  91204. /**
  91205. * This represents a scene component.
  91206. *
  91207. * This is used to decouple the dependency the scene is having on the different workloads like
  91208. * layers, post processes...
  91209. */
  91210. export interface ISceneComponent {
  91211. /**
  91212. * The name of the component. Each component must have a unique name.
  91213. */
  91214. name: string;
  91215. /**
  91216. * The scene the component belongs to.
  91217. */
  91218. scene: Scene;
  91219. /**
  91220. * Register the component to one instance of a scene.
  91221. */
  91222. register(): void;
  91223. /**
  91224. * Rebuilds the elements related to this component in case of
  91225. * context lost for instance.
  91226. */
  91227. rebuild(): void;
  91228. /**
  91229. * Disposes the component and the associated ressources.
  91230. */
  91231. dispose(): void;
  91232. }
  91233. /**
  91234. * This represents a SERIALIZABLE scene component.
  91235. *
  91236. * This extends Scene Component to add Serialization methods on top.
  91237. */
  91238. export interface ISceneSerializableComponent extends ISceneComponent {
  91239. /**
  91240. * Adds all the elements from the container to the scene
  91241. * @param container the container holding the elements
  91242. */
  91243. addFromContainer(container: AbstractScene): void;
  91244. /**
  91245. * Removes all the elements in the container from the scene
  91246. * @param container contains the elements to remove
  91247. * @param dispose if the removed element should be disposed (default: false)
  91248. */
  91249. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  91250. /**
  91251. * Serializes the component data to the specified json object
  91252. * @param serializationObject The object to serialize to
  91253. */
  91254. serialize(serializationObject: any): void;
  91255. }
  91256. /**
  91257. * Strong typing of a Mesh related stage step action
  91258. */
  91259. export type MeshStageAction = (mesh: AbstractMesh, hardwareInstancedRendering: boolean) => boolean;
  91260. /**
  91261. * Strong typing of a Evaluate Sub Mesh related stage step action
  91262. */
  91263. export type EvaluateSubMeshStageAction = (mesh: AbstractMesh, subMesh: SubMesh) => void;
  91264. /**
  91265. * Strong typing of a Active Mesh related stage step action
  91266. */
  91267. export type ActiveMeshStageAction = (sourceMesh: AbstractMesh, mesh: AbstractMesh) => void;
  91268. /**
  91269. * Strong typing of a Camera related stage step action
  91270. */
  91271. export type CameraStageAction = (camera: Camera) => void;
  91272. /**
  91273. * Strong typing of a Camera Frame buffer related stage step action
  91274. */
  91275. export type CameraStageFrameBufferAction = (camera: Camera) => boolean;
  91276. /**
  91277. * Strong typing of a Render Target related stage step action
  91278. */
  91279. export type RenderTargetStageAction = (renderTarget: RenderTargetTexture) => void;
  91280. /**
  91281. * Strong typing of a RenderingGroup related stage step action
  91282. */
  91283. export type RenderingGroupStageAction = (renderingGroupId: number) => void;
  91284. /**
  91285. * Strong typing of a Mesh Render related stage step action
  91286. */
  91287. export type RenderingMeshStageAction = (mesh: Mesh, subMesh: SubMesh, batch: _InstancesBatch) => void;
  91288. /**
  91289. * Strong typing of a simple stage step action
  91290. */
  91291. export type SimpleStageAction = () => void;
  91292. /**
  91293. * Strong typing of a render target action.
  91294. */
  91295. export type RenderTargetsStageAction = (renderTargets: SmartArrayNoDuplicate<RenderTargetTexture>) => void;
  91296. /**
  91297. * Strong typing of a pointer move action.
  91298. */
  91299. export type PointerMoveStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, isMeshPicked: boolean, element: HTMLElement) => Nullable<PickingInfo>;
  91300. /**
  91301. * Strong typing of a pointer up/down action.
  91302. */
  91303. export type PointerUpDownStageAction = (unTranslatedPointerX: number, unTranslatedPointerY: number, pickResult: Nullable<PickingInfo>, evt: PointerEvent) => Nullable<PickingInfo>;
  91304. /**
  91305. * Representation of a stage in the scene (Basically a list of ordered steps)
  91306. * @hidden
  91307. */
  91308. export class Stage<T extends Function> extends Array<{
  91309. index: number;
  91310. component: ISceneComponent;
  91311. action: T;
  91312. }> {
  91313. /**
  91314. * Hide ctor from the rest of the world.
  91315. * @param items The items to add.
  91316. */
  91317. private constructor();
  91318. /**
  91319. * Creates a new Stage.
  91320. * @returns A new instance of a Stage
  91321. */
  91322. static Create<T extends Function>(): Stage<T>;
  91323. /**
  91324. * Registers a step in an ordered way in the targeted stage.
  91325. * @param index Defines the position to register the step in
  91326. * @param component Defines the component attached to the step
  91327. * @param action Defines the action to launch during the step
  91328. */
  91329. registerStep(index: number, component: ISceneComponent, action: T): void;
  91330. /**
  91331. * Clears all the steps from the stage.
  91332. */
  91333. clear(): void;
  91334. }
  91335. }
  91336. declare module BABYLON {
  91337. interface Scene {
  91338. /** @hidden */
  91339. _pointerOverSprite: Nullable<Sprite>;
  91340. /** @hidden */
  91341. _pickedDownSprite: Nullable<Sprite>;
  91342. /** @hidden */
  91343. _tempSpritePickingRay: Nullable<Ray>;
  91344. /**
  91345. * All of the sprite managers added to this scene
  91346. * @see https://doc.babylonjs.com/babylon101/sprites
  91347. */
  91348. spriteManagers: Array<ISpriteManager>;
  91349. /**
  91350. * An event triggered when sprites rendering is about to start
  91351. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91352. */
  91353. onBeforeSpritesRenderingObservable: Observable<Scene>;
  91354. /**
  91355. * An event triggered when sprites rendering is done
  91356. * Note: This event can be trigger more than once per frame (because sprites can be rendered by render target textures as well)
  91357. */
  91358. onAfterSpritesRenderingObservable: Observable<Scene>;
  91359. /** @hidden */
  91360. _internalPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91361. /** Launch a ray to try to pick a sprite in the scene
  91362. * @param x position on screen
  91363. * @param y position on screen
  91364. * @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
  91365. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91366. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91367. * @returns a PickingInfo
  91368. */
  91369. pickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91370. /** Use the given ray to pick a sprite in the scene
  91371. * @param ray The ray (in world space) to use to pick meshes
  91372. * @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
  91373. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91374. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91375. * @returns a PickingInfo
  91376. */
  91377. pickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean, camera?: Camera): Nullable<PickingInfo>;
  91378. /** @hidden */
  91379. _internalMultiPickSprites(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91380. /** Launch a ray to try to pick sprites in the scene
  91381. * @param x position on screen
  91382. * @param y position on screen
  91383. * @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
  91384. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  91385. * @returns a PickingInfo array
  91386. */
  91387. multiPickSprite(x: number, y: number, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91388. /** Use the given ray to pick sprites in the scene
  91389. * @param ray The ray (in world space) to use to pick meshes
  91390. * @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
  91391. * @param camera camera to use. Can be set to null. In this case, the scene.activeCamera will be used
  91392. * @returns a PickingInfo array
  91393. */
  91394. multiPickSpriteWithRay(ray: Ray, predicate?: (sprite: Sprite) => boolean, camera?: Camera): Nullable<PickingInfo[]>;
  91395. /**
  91396. * Force the sprite under the pointer
  91397. * @param sprite defines the sprite to use
  91398. */
  91399. setPointerOverSprite(sprite: Nullable<Sprite>): void;
  91400. /**
  91401. * Gets the sprite under the pointer
  91402. * @returns a Sprite or null if no sprite is under the pointer
  91403. */
  91404. getPointerOverSprite(): Nullable<Sprite>;
  91405. }
  91406. /**
  91407. * Defines the sprite scene component responsible to manage sprites
  91408. * in a given scene.
  91409. */
  91410. export class SpriteSceneComponent implements ISceneComponent {
  91411. /**
  91412. * The component name helpfull to identify the component in the list of scene components.
  91413. */
  91414. readonly name: string;
  91415. /**
  91416. * The scene the component belongs to.
  91417. */
  91418. scene: Scene;
  91419. /** @hidden */
  91420. private _spritePredicate;
  91421. /**
  91422. * Creates a new instance of the component for the given scene
  91423. * @param scene Defines the scene to register the component in
  91424. */
  91425. constructor(scene: Scene);
  91426. /**
  91427. * Registers the component in a given scene
  91428. */
  91429. register(): void;
  91430. /**
  91431. * Rebuilds the elements related to this component in case of
  91432. * context lost for instance.
  91433. */
  91434. rebuild(): void;
  91435. /**
  91436. * Disposes the component and the associated ressources.
  91437. */
  91438. dispose(): void;
  91439. private _pickSpriteButKeepRay;
  91440. private _pointerMove;
  91441. private _pointerDown;
  91442. private _pointerUp;
  91443. }
  91444. }
  91445. declare module BABYLON {
  91446. /** @hidden */
  91447. export var fogFragmentDeclaration: {
  91448. name: string;
  91449. shader: string;
  91450. };
  91451. }
  91452. declare module BABYLON {
  91453. /** @hidden */
  91454. export var fogFragment: {
  91455. name: string;
  91456. shader: string;
  91457. };
  91458. }
  91459. declare module BABYLON {
  91460. /** @hidden */
  91461. export var spritesPixelShader: {
  91462. name: string;
  91463. shader: string;
  91464. };
  91465. }
  91466. declare module BABYLON {
  91467. /** @hidden */
  91468. export var fogVertexDeclaration: {
  91469. name: string;
  91470. shader: string;
  91471. };
  91472. }
  91473. declare module BABYLON {
  91474. /** @hidden */
  91475. export var spritesVertexShader: {
  91476. name: string;
  91477. shader: string;
  91478. };
  91479. }
  91480. declare module BABYLON {
  91481. /**
  91482. * Defines the minimum interface to fullfil in order to be a sprite manager.
  91483. */
  91484. export interface ISpriteManager extends IDisposable {
  91485. /**
  91486. * Gets manager's name
  91487. */
  91488. name: string;
  91489. /**
  91490. * Restricts the camera to viewing objects with the same layerMask.
  91491. * A camera with a layerMask of 1 will render spriteManager.layerMask & camera.layerMask!== 0
  91492. */
  91493. layerMask: number;
  91494. /**
  91495. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  91496. */
  91497. isPickable: boolean;
  91498. /**
  91499. * Gets the hosting scene
  91500. */
  91501. scene: Scene;
  91502. /**
  91503. * Specifies the rendering group id for this mesh (0 by default)
  91504. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  91505. */
  91506. renderingGroupId: number;
  91507. /**
  91508. * Defines the list of sprites managed by the manager.
  91509. */
  91510. sprites: Array<Sprite>;
  91511. /**
  91512. * Gets or sets the spritesheet texture
  91513. */
  91514. texture: Texture;
  91515. /** Defines the default width of a cell in the spritesheet */
  91516. cellWidth: number;
  91517. /** Defines the default height of a cell in the spritesheet */
  91518. cellHeight: number;
  91519. /**
  91520. * Tests the intersection of a sprite with a specific ray.
  91521. * @param ray The ray we are sending to test the collision
  91522. * @param camera The camera space we are sending rays in
  91523. * @param predicate A predicate allowing excluding sprites from the list of object to test
  91524. * @param fastCheck defines if the first intersection will be used (and not the closest)
  91525. * @returns picking info or null.
  91526. */
  91527. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91528. /**
  91529. * Intersects the sprites with a ray
  91530. * @param ray defines the ray to intersect with
  91531. * @param camera defines the current active camera
  91532. * @param predicate defines a predicate used to select candidate sprites
  91533. * @returns null if no hit or a PickingInfo array
  91534. */
  91535. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91536. /**
  91537. * Renders the list of sprites on screen.
  91538. */
  91539. render(): void;
  91540. }
  91541. /**
  91542. * Class used to manage multiple sprites on the same spritesheet
  91543. * @see https://doc.babylonjs.com/babylon101/sprites
  91544. */
  91545. export class SpriteManager implements ISpriteManager {
  91546. /** defines the manager's name */
  91547. name: string;
  91548. /** Define the Url to load snippets */
  91549. static SnippetUrl: string;
  91550. /** Snippet ID if the manager was created from the snippet server */
  91551. snippetId: string;
  91552. /** Gets the list of sprites */
  91553. sprites: Sprite[];
  91554. /** Gets or sets the rendering group id (0 by default) */
  91555. renderingGroupId: number;
  91556. /** Gets or sets camera layer mask */
  91557. layerMask: number;
  91558. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  91559. fogEnabled: boolean;
  91560. /** Gets or sets a boolean indicating if the sprites are pickable */
  91561. isPickable: boolean;
  91562. /** Defines the default width of a cell in the spritesheet */
  91563. cellWidth: number;
  91564. /** Defines the default height of a cell in the spritesheet */
  91565. cellHeight: number;
  91566. /** Associative array from JSON sprite data file */
  91567. private _cellData;
  91568. /** Array of sprite names from JSON sprite data file */
  91569. private _spriteMap;
  91570. /** True when packed cell data from JSON file is ready*/
  91571. private _packedAndReady;
  91572. private _textureContent;
  91573. private _useInstancing;
  91574. /**
  91575. * An event triggered when the manager is disposed.
  91576. */
  91577. onDisposeObservable: Observable<SpriteManager>;
  91578. private _onDisposeObserver;
  91579. /**
  91580. * Callback called when the manager is disposed
  91581. */
  91582. set onDispose(callback: () => void);
  91583. private _capacity;
  91584. private _fromPacked;
  91585. private _spriteTexture;
  91586. private _epsilon;
  91587. private _scene;
  91588. private _vertexData;
  91589. private _buffer;
  91590. private _vertexBuffers;
  91591. private _spriteBuffer;
  91592. private _indexBuffer;
  91593. private _effectBase;
  91594. private _effectFog;
  91595. private _vertexBufferSize;
  91596. /**
  91597. * Gets or sets the unique id of the sprite
  91598. */
  91599. uniqueId: number;
  91600. /**
  91601. * Gets the array of sprites
  91602. */
  91603. get children(): Sprite[];
  91604. /**
  91605. * Gets the hosting scene
  91606. */
  91607. get scene(): Scene;
  91608. /**
  91609. * Gets the capacity of the manager
  91610. */
  91611. get capacity(): number;
  91612. /**
  91613. * Gets or sets the spritesheet texture
  91614. */
  91615. get texture(): Texture;
  91616. set texture(value: Texture);
  91617. private _blendMode;
  91618. /**
  91619. * Blend mode use to render the particle, it can be any of
  91620. * the static Constants.ALPHA_x properties provided in this class.
  91621. * Default value is Constants.ALPHA_COMBINE
  91622. */
  91623. get blendMode(): number;
  91624. set blendMode(blendMode: number);
  91625. /** Disables writing to the depth buffer when rendering the sprites.
  91626. * It can be handy to disable depth writing when using textures without alpha channel
  91627. * and setting some specific blend modes.
  91628. */
  91629. disableDepthWrite: boolean;
  91630. /**
  91631. * Creates a new sprite manager
  91632. * @param name defines the manager's name
  91633. * @param imgUrl defines the sprite sheet url
  91634. * @param capacity defines the maximum allowed number of sprites
  91635. * @param cellSize defines the size of a sprite cell
  91636. * @param scene defines the hosting scene
  91637. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  91638. * @param samplingMode defines the smapling mode to use with spritesheet
  91639. * @param fromPacked set to false; do not alter
  91640. * @param spriteJSON null otherwise a JSON object defining sprite sheet data; do not alter
  91641. */
  91642. constructor(
  91643. /** defines the manager's name */
  91644. name: string, imgUrl: string, capacity: number, cellSize: any, scene: Scene, epsilon?: number, samplingMode?: number, fromPacked?: boolean, spriteJSON?: any | null);
  91645. /**
  91646. * Returns the string "SpriteManager"
  91647. * @returns "SpriteManager"
  91648. */
  91649. getClassName(): string;
  91650. private _makePacked;
  91651. private _appendSpriteVertex;
  91652. private _checkTextureAlpha;
  91653. /**
  91654. * Intersects the sprites with a ray
  91655. * @param ray defines the ray to intersect with
  91656. * @param camera defines the current active camera
  91657. * @param predicate defines a predicate used to select candidate sprites
  91658. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  91659. * @returns null if no hit or a PickingInfo
  91660. */
  91661. intersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean, fastCheck?: boolean): Nullable<PickingInfo>;
  91662. /**
  91663. * Intersects the sprites with a ray
  91664. * @param ray defines the ray to intersect with
  91665. * @param camera defines the current active camera
  91666. * @param predicate defines a predicate used to select candidate sprites
  91667. * @returns null if no hit or a PickingInfo array
  91668. */
  91669. multiIntersects(ray: Ray, camera: Camera, predicate?: (sprite: Sprite) => boolean): Nullable<PickingInfo[]>;
  91670. /**
  91671. * Render all child sprites
  91672. */
  91673. render(): void;
  91674. /**
  91675. * Release associated resources
  91676. */
  91677. dispose(): void;
  91678. /**
  91679. * Serializes the sprite manager to a JSON object
  91680. * @param serializeTexture defines if the texture must be serialized as well
  91681. * @returns the JSON object
  91682. */
  91683. serialize(serializeTexture?: boolean): any;
  91684. /**
  91685. * Parses a JSON object to create a new sprite manager.
  91686. * @param parsedManager The JSON object to parse
  91687. * @param scene The scene to create the sprite managerin
  91688. * @param rootUrl The root url to use to load external dependencies like texture
  91689. * @returns the new sprite manager
  91690. */
  91691. static Parse(parsedManager: any, scene: Scene, rootUrl: string): SpriteManager;
  91692. /**
  91693. * Creates a sprite manager from a snippet saved in a remote file
  91694. * @param name defines the name of the sprite manager to create (can be null or empty to use the one from the json data)
  91695. * @param url defines the url to load from
  91696. * @param scene defines the hosting scene
  91697. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91698. * @returns a promise that will resolve to the new sprite manager
  91699. */
  91700. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91701. /**
  91702. * Creates a sprite manager from a snippet saved by the sprite editor
  91703. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  91704. * @param scene defines the hosting scene
  91705. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  91706. * @returns a promise that will resolve to the new sprite manager
  91707. */
  91708. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<SpriteManager>;
  91709. }
  91710. }
  91711. declare module BABYLON {
  91712. /** Interface used by value gradients (color, factor, ...) */
  91713. export interface IValueGradient {
  91714. /**
  91715. * Gets or sets the gradient value (between 0 and 1)
  91716. */
  91717. gradient: number;
  91718. }
  91719. /** Class used to store color4 gradient */
  91720. export class ColorGradient implements IValueGradient {
  91721. /**
  91722. * Gets or sets the gradient value (between 0 and 1)
  91723. */
  91724. gradient: number;
  91725. /**
  91726. * Gets or sets first associated color
  91727. */
  91728. color1: Color4;
  91729. /**
  91730. * Gets or sets second associated color
  91731. */
  91732. color2?: Color4 | undefined;
  91733. /**
  91734. * Creates a new color4 gradient
  91735. * @param gradient gets or sets the gradient value (between 0 and 1)
  91736. * @param color1 gets or sets first associated color
  91737. * @param color2 gets or sets first second color
  91738. */
  91739. constructor(
  91740. /**
  91741. * Gets or sets the gradient value (between 0 and 1)
  91742. */
  91743. gradient: number,
  91744. /**
  91745. * Gets or sets first associated color
  91746. */
  91747. color1: Color4,
  91748. /**
  91749. * Gets or sets second associated color
  91750. */
  91751. color2?: Color4 | undefined);
  91752. /**
  91753. * Will get a color picked randomly between color1 and color2.
  91754. * If color2 is undefined then color1 will be used
  91755. * @param result defines the target Color4 to store the result in
  91756. */
  91757. getColorToRef(result: Color4): void;
  91758. }
  91759. /** Class used to store color 3 gradient */
  91760. export class Color3Gradient implements IValueGradient {
  91761. /**
  91762. * Gets or sets the gradient value (between 0 and 1)
  91763. */
  91764. gradient: number;
  91765. /**
  91766. * Gets or sets the associated color
  91767. */
  91768. color: Color3;
  91769. /**
  91770. * Creates a new color3 gradient
  91771. * @param gradient gets or sets the gradient value (between 0 and 1)
  91772. * @param color gets or sets associated color
  91773. */
  91774. constructor(
  91775. /**
  91776. * Gets or sets the gradient value (between 0 and 1)
  91777. */
  91778. gradient: number,
  91779. /**
  91780. * Gets or sets the associated color
  91781. */
  91782. color: Color3);
  91783. }
  91784. /** Class used to store factor gradient */
  91785. export class FactorGradient implements IValueGradient {
  91786. /**
  91787. * Gets or sets the gradient value (between 0 and 1)
  91788. */
  91789. gradient: number;
  91790. /**
  91791. * Gets or sets first associated factor
  91792. */
  91793. factor1: number;
  91794. /**
  91795. * Gets or sets second associated factor
  91796. */
  91797. factor2?: number | undefined;
  91798. /**
  91799. * Creates a new factor gradient
  91800. * @param gradient gets or sets the gradient value (between 0 and 1)
  91801. * @param factor1 gets or sets first associated factor
  91802. * @param factor2 gets or sets second associated factor
  91803. */
  91804. constructor(
  91805. /**
  91806. * Gets or sets the gradient value (between 0 and 1)
  91807. */
  91808. gradient: number,
  91809. /**
  91810. * Gets or sets first associated factor
  91811. */
  91812. factor1: number,
  91813. /**
  91814. * Gets or sets second associated factor
  91815. */
  91816. factor2?: number | undefined);
  91817. /**
  91818. * Will get a number picked randomly between factor1 and factor2.
  91819. * If factor2 is undefined then factor1 will be used
  91820. * @returns the picked number
  91821. */
  91822. getFactor(): number;
  91823. }
  91824. /**
  91825. * Helper used to simplify some generic gradient tasks
  91826. */
  91827. export class GradientHelper {
  91828. /**
  91829. * Gets the current gradient from an array of IValueGradient
  91830. * @param ratio defines the current ratio to get
  91831. * @param gradients defines the array of IValueGradient
  91832. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  91833. */
  91834. static GetCurrentGradient(ratio: number, gradients: IValueGradient[], updateFunc: (current: IValueGradient, next: IValueGradient, scale: number) => void): void;
  91835. }
  91836. }
  91837. declare module BABYLON {
  91838. interface ThinEngine {
  91839. /**
  91840. * Creates a raw texture
  91841. * @param data defines the data to store in the texture
  91842. * @param width defines the width of the texture
  91843. * @param height defines the height of the texture
  91844. * @param format defines the format of the data
  91845. * @param generateMipMaps defines if the engine should generate the mip levels
  91846. * @param invertY defines if data must be stored with Y axis inverted
  91847. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  91848. * @param compression defines the compression used (null by default)
  91849. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91850. * @returns the raw texture inside an InternalTexture
  91851. */
  91852. createRawTexture(data: Nullable<ArrayBufferView>, width: number, height: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, type: number): InternalTexture;
  91853. /**
  91854. * Update a raw texture
  91855. * @param texture defines the texture to update
  91856. * @param data defines the data to store in the texture
  91857. * @param format defines the format of the data
  91858. * @param invertY defines if data must be stored with Y axis inverted
  91859. */
  91860. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91861. /**
  91862. * Update a raw texture
  91863. * @param texture defines the texture to update
  91864. * @param data defines the data to store in the texture
  91865. * @param format defines the format of the data
  91866. * @param invertY defines if data must be stored with Y axis inverted
  91867. * @param compression defines the compression used (null by default)
  91868. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91869. */
  91870. updateRawTexture(texture: Nullable<InternalTexture>, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, type: number): void;
  91871. /**
  91872. * Creates a new raw cube texture
  91873. * @param data defines the array of data to use to create each face
  91874. * @param size defines the size of the textures
  91875. * @param format defines the format of the data
  91876. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91877. * @param generateMipMaps defines if the engine should generate the mip levels
  91878. * @param invertY defines if data must be stored with Y axis inverted
  91879. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91880. * @param compression defines the compression used (null by default)
  91881. * @returns the cube texture as an InternalTexture
  91882. */
  91883. createRawCubeTexture(data: Nullable<ArrayBufferView[]>, size: number, format: number, type: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>): InternalTexture;
  91884. /**
  91885. * Update a raw cube texture
  91886. * @param texture defines the texture to udpdate
  91887. * @param data defines the data to store
  91888. * @param format defines the data format
  91889. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91890. * @param invertY defines if data must be stored with Y axis inverted
  91891. */
  91892. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean): void;
  91893. /**
  91894. * Update a raw cube texture
  91895. * @param texture defines the texture to udpdate
  91896. * @param data defines the data to store
  91897. * @param format defines the data format
  91898. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91899. * @param invertY defines if data must be stored with Y axis inverted
  91900. * @param compression defines the compression used (null by default)
  91901. */
  91902. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>): void;
  91903. /**
  91904. * Update a raw cube texture
  91905. * @param texture defines the texture to udpdate
  91906. * @param data defines the data to store
  91907. * @param format defines the data format
  91908. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  91909. * @param invertY defines if data must be stored with Y axis inverted
  91910. * @param compression defines the compression used (null by default)
  91911. * @param level defines which level of the texture to update
  91912. */
  91913. updateRawCubeTexture(texture: InternalTexture, data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression: Nullable<string>, level: number): void;
  91914. /**
  91915. * Creates a new raw cube texture from a specified url
  91916. * @param url defines the url where the data is located
  91917. * @param scene defines the current scene
  91918. * @param size defines the size of the textures
  91919. * @param format defines the format of the data
  91920. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91921. * @param noMipmap defines if the engine should avoid generating the mip levels
  91922. * @param callback defines a callback used to extract texture data from loaded data
  91923. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91924. * @param onLoad defines a callback called when texture is loaded
  91925. * @param onError defines a callback called if there is an error
  91926. * @returns the cube texture as an InternalTexture
  91927. */
  91928. 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;
  91929. /**
  91930. * Creates a new raw cube texture from a specified url
  91931. * @param url defines the url where the data is located
  91932. * @param scene defines the current scene
  91933. * @param size defines the size of the textures
  91934. * @param format defines the format of the data
  91935. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  91936. * @param noMipmap defines if the engine should avoid generating the mip levels
  91937. * @param callback defines a callback used to extract texture data from loaded data
  91938. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  91939. * @param onLoad defines a callback called when texture is loaded
  91940. * @param onError defines a callback called if there is an error
  91941. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91942. * @param invertY defines if data must be stored with Y axis inverted
  91943. * @returns the cube texture as an InternalTexture
  91944. */
  91945. 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;
  91946. /**
  91947. * Creates a new raw 3D texture
  91948. * @param data defines the data used to create the texture
  91949. * @param width defines the width of the texture
  91950. * @param height defines the height of the texture
  91951. * @param depth defines the depth of the texture
  91952. * @param format defines the format of the texture
  91953. * @param generateMipMaps defines if the engine must generate mip levels
  91954. * @param invertY defines if data must be stored with Y axis inverted
  91955. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91956. * @param compression defines the compressed used (can be null)
  91957. * @param textureType defines the compressed used (can be null)
  91958. * @returns a new raw 3D texture (stored in an InternalTexture)
  91959. */
  91960. createRawTexture3D(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91961. /**
  91962. * Update a raw 3D texture
  91963. * @param texture defines the texture to update
  91964. * @param data defines the data to store
  91965. * @param format defines the data format
  91966. * @param invertY defines if data must be stored with Y axis inverted
  91967. */
  91968. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  91969. /**
  91970. * Update a raw 3D texture
  91971. * @param texture defines the texture to update
  91972. * @param data defines the data to store
  91973. * @param format defines the data format
  91974. * @param invertY defines if data must be stored with Y axis inverted
  91975. * @param compression defines the used compression (can be null)
  91976. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  91977. */
  91978. updateRawTexture3D(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  91979. /**
  91980. * Creates a new raw 2D array texture
  91981. * @param data defines the data used to create the texture
  91982. * @param width defines the width of the texture
  91983. * @param height defines the height of the texture
  91984. * @param depth defines the number of layers of the texture
  91985. * @param format defines the format of the texture
  91986. * @param generateMipMaps defines if the engine must generate mip levels
  91987. * @param invertY defines if data must be stored with Y axis inverted
  91988. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  91989. * @param compression defines the compressed used (can be null)
  91990. * @param textureType defines the compressed used (can be null)
  91991. * @returns a new raw 2D array texture (stored in an InternalTexture)
  91992. */
  91993. createRawTexture2DArray(data: Nullable<ArrayBufferView>, width: number, height: number, depth: number, format: number, generateMipMaps: boolean, invertY: boolean, samplingMode: number, compression: Nullable<string>, textureType: number): InternalTexture;
  91994. /**
  91995. * Update a raw 2D array texture
  91996. * @param texture defines the texture to update
  91997. * @param data defines the data to store
  91998. * @param format defines the data format
  91999. * @param invertY defines if data must be stored with Y axis inverted
  92000. */
  92001. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean): void;
  92002. /**
  92003. * Update a raw 2D array texture
  92004. * @param texture defines the texture to update
  92005. * @param data defines the data to store
  92006. * @param format defines the data format
  92007. * @param invertY defines if data must be stored with Y axis inverted
  92008. * @param compression defines the used compression (can be null)
  92009. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  92010. */
  92011. updateRawTexture2DArray(texture: InternalTexture, data: Nullable<ArrayBufferView>, format: number, invertY: boolean, compression: Nullable<string>, textureType: number): void;
  92012. }
  92013. }
  92014. declare module BABYLON {
  92015. /**
  92016. * Raw texture can help creating a texture directly from an array of data.
  92017. * This can be super useful if you either get the data from an uncompressed source or
  92018. * if you wish to create your texture pixel by pixel.
  92019. */
  92020. export class RawTexture extends Texture {
  92021. /**
  92022. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92023. */
  92024. format: number;
  92025. /**
  92026. * Instantiates a new RawTexture.
  92027. * Raw texture can help creating a texture directly from an array of data.
  92028. * This can be super useful if you either get the data from an uncompressed source or
  92029. * if you wish to create your texture pixel by pixel.
  92030. * @param data define the array of data to use to create the texture
  92031. * @param width define the width of the texture
  92032. * @param height define the height of the texture
  92033. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92034. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92035. * @param generateMipMaps define whether mip maps should be generated or not
  92036. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92037. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92038. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92039. */
  92040. constructor(data: ArrayBufferView, width: number, height: number,
  92041. /**
  92042. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  92043. */
  92044. format: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number);
  92045. /**
  92046. * Updates the texture underlying data.
  92047. * @param data Define the new data of the texture
  92048. */
  92049. update(data: ArrayBufferView): void;
  92050. /**
  92051. * Creates a luminance texture from some data.
  92052. * @param data Define the texture data
  92053. * @param width Define the width of the texture
  92054. * @param height Define the height of the texture
  92055. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92056. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92057. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92058. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92059. * @returns the luminance texture
  92060. */
  92061. static CreateLuminanceTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92062. /**
  92063. * Creates a luminance alpha texture from some data.
  92064. * @param data Define the texture data
  92065. * @param width Define the width of the texture
  92066. * @param height Define the height of the texture
  92067. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92068. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92069. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92070. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92071. * @returns the luminance alpha texture
  92072. */
  92073. static CreateLuminanceAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92074. /**
  92075. * Creates an alpha texture from some data.
  92076. * @param data Define the texture data
  92077. * @param width Define the width of the texture
  92078. * @param height Define the height of the texture
  92079. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92080. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92081. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92082. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92083. * @returns the alpha texture
  92084. */
  92085. static CreateAlphaTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number): RawTexture;
  92086. /**
  92087. * Creates a RGB texture from some data.
  92088. * @param data Define the texture data
  92089. * @param width Define the width of the texture
  92090. * @param height Define the height of the texture
  92091. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92092. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92093. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92094. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92095. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92096. * @returns the RGB alpha texture
  92097. */
  92098. static CreateRGBTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92099. /**
  92100. * Creates a RGBA texture from some data.
  92101. * @param data Define the texture data
  92102. * @param width Define the width of the texture
  92103. * @param height Define the height of the texture
  92104. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92105. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92106. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92107. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92108. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92109. * @returns the RGBA texture
  92110. */
  92111. static CreateRGBATexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92112. /**
  92113. * Creates a R texture from some data.
  92114. * @param data Define the texture data
  92115. * @param width Define the width of the texture
  92116. * @param height Define the height of the texture
  92117. * @param sceneOrEngine defines the scene or engine the texture will belong to
  92118. * @param generateMipMaps Define whether or not to create mip maps for the texture
  92119. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  92120. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  92121. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  92122. * @returns the R texture
  92123. */
  92124. static CreateRTexture(data: ArrayBufferView, width: number, height: number, sceneOrEngine: Nullable<Scene | ThinEngine>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, type?: number): RawTexture;
  92125. }
  92126. }
  92127. declare module BABYLON {
  92128. interface ThinEngine {
  92129. /**
  92130. * Update a dynamic index buffer
  92131. * @param indexBuffer defines the target index buffer
  92132. * @param indices defines the data to update
  92133. * @param offset defines the offset in the target index buffer where update should start
  92134. */
  92135. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  92136. /**
  92137. * Updates a dynamic vertex buffer.
  92138. * @param vertexBuffer the vertex buffer to update
  92139. * @param data the data used to update the vertex buffer
  92140. * @param byteOffset the byte offset of the data
  92141. * @param byteLength the byte length of the data
  92142. */
  92143. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  92144. }
  92145. }
  92146. declare module BABYLON {
  92147. interface AbstractScene {
  92148. /**
  92149. * The list of procedural textures added to the scene
  92150. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92151. */
  92152. proceduralTextures: Array<ProceduralTexture>;
  92153. }
  92154. /**
  92155. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  92156. * in a given scene.
  92157. */
  92158. export class ProceduralTextureSceneComponent implements ISceneComponent {
  92159. /**
  92160. * The component name helpfull to identify the component in the list of scene components.
  92161. */
  92162. readonly name: string;
  92163. /**
  92164. * The scene the component belongs to.
  92165. */
  92166. scene: Scene;
  92167. /**
  92168. * Creates a new instance of the component for the given scene
  92169. * @param scene Defines the scene to register the component in
  92170. */
  92171. constructor(scene: Scene);
  92172. /**
  92173. * Registers the component in a given scene
  92174. */
  92175. register(): void;
  92176. /**
  92177. * Rebuilds the elements related to this component in case of
  92178. * context lost for instance.
  92179. */
  92180. rebuild(): void;
  92181. /**
  92182. * Disposes the component and the associated ressources.
  92183. */
  92184. dispose(): void;
  92185. private _beforeClear;
  92186. }
  92187. }
  92188. declare module BABYLON {
  92189. interface ThinEngine {
  92190. /**
  92191. * Creates a new render target cube texture
  92192. * @param size defines the size of the texture
  92193. * @param options defines the options used to create the texture
  92194. * @returns a new render target cube texture stored in an InternalTexture
  92195. */
  92196. createRenderTargetCubeTexture(size: number, options?: Partial<RenderTargetCreationOptions>): InternalTexture;
  92197. }
  92198. }
  92199. declare module BABYLON {
  92200. /** @hidden */
  92201. export var proceduralVertexShader: {
  92202. name: string;
  92203. shader: string;
  92204. };
  92205. }
  92206. declare module BABYLON {
  92207. /**
  92208. * 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.
  92209. * This is the base class of any Procedural texture and contains most of the shareable code.
  92210. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92211. */
  92212. export class ProceduralTexture extends Texture {
  92213. /**
  92214. * Define if the texture is enabled or not (disabled texture will not render)
  92215. */
  92216. isEnabled: boolean;
  92217. /**
  92218. * Define if the texture must be cleared before rendering (default is true)
  92219. */
  92220. autoClear: boolean;
  92221. /**
  92222. * Callback called when the texture is generated
  92223. */
  92224. onGenerated: () => void;
  92225. /**
  92226. * Event raised when the texture is generated
  92227. */
  92228. onGeneratedObservable: Observable<ProceduralTexture>;
  92229. /**
  92230. * Event raised before the texture is generated
  92231. */
  92232. onBeforeGenerationObservable: Observable<ProceduralTexture>;
  92233. /**
  92234. * Gets or sets the node material used to create this texture (null if the texture was manually created)
  92235. */
  92236. nodeMaterialSource: Nullable<NodeMaterial>;
  92237. /** @hidden */
  92238. _generateMipMaps: boolean;
  92239. /** @hidden **/
  92240. _effect: Effect;
  92241. /** @hidden */
  92242. _textures: {
  92243. [key: string]: Texture;
  92244. };
  92245. /** @hidden */
  92246. protected _fallbackTexture: Nullable<Texture>;
  92247. private _size;
  92248. private _currentRefreshId;
  92249. private _frameId;
  92250. private _refreshRate;
  92251. private _vertexBuffers;
  92252. private _indexBuffer;
  92253. private _uniforms;
  92254. private _samplers;
  92255. private _fragment;
  92256. private _floats;
  92257. private _ints;
  92258. private _floatsArrays;
  92259. private _colors3;
  92260. private _colors4;
  92261. private _vectors2;
  92262. private _vectors3;
  92263. private _matrices;
  92264. private _fallbackTextureUsed;
  92265. private _fullEngine;
  92266. private _cachedDefines;
  92267. private _contentUpdateId;
  92268. private _contentData;
  92269. /**
  92270. * Instantiates a new procedural texture.
  92271. * 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.
  92272. * This is the base class of any Procedural texture and contains most of the shareable code.
  92273. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  92274. * @param name Define the name of the texture
  92275. * @param size Define the size of the texture to create
  92276. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  92277. * @param scene Define the scene the texture belongs to
  92278. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  92279. * @param generateMipMaps Define if the texture should creates mip maps or not
  92280. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  92281. * @param textureType The FBO internal texture type
  92282. */
  92283. constructor(name: string, size: RenderTargetTextureSize, fragment: any, scene: Nullable<Scene>, fallbackTexture?: Nullable<Texture>, generateMipMaps?: boolean, isCube?: boolean, textureType?: number);
  92284. /**
  92285. * The effect that is created when initializing the post process.
  92286. * @returns The created effect corresponding the the postprocess.
  92287. */
  92288. getEffect(): Effect;
  92289. /**
  92290. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  92291. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  92292. */
  92293. getContent(): Nullable<ArrayBufferView>;
  92294. private _createIndexBuffer;
  92295. /** @hidden */
  92296. _rebuild(): void;
  92297. /**
  92298. * Resets the texture in order to recreate its associated resources.
  92299. * This can be called in case of context loss
  92300. */
  92301. reset(): void;
  92302. protected _getDefines(): string;
  92303. /**
  92304. * Is the texture ready to be used ? (rendered at least once)
  92305. * @returns true if ready, otherwise, false.
  92306. */
  92307. isReady(): boolean;
  92308. /**
  92309. * Resets the refresh counter of the texture and start bak from scratch.
  92310. * Could be useful to regenerate the texture if it is setup to render only once.
  92311. */
  92312. resetRefreshCounter(): void;
  92313. /**
  92314. * Set the fragment shader to use in order to render the texture.
  92315. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  92316. */
  92317. setFragment(fragment: any): void;
  92318. /**
  92319. * Define the refresh rate of the texture or the rendering frequency.
  92320. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  92321. */
  92322. get refreshRate(): number;
  92323. set refreshRate(value: number);
  92324. /** @hidden */
  92325. _shouldRender(): boolean;
  92326. /**
  92327. * Get the size the texture is rendering at.
  92328. * @returns the size (on cube texture it is always squared)
  92329. */
  92330. getRenderSize(): RenderTargetTextureSize;
  92331. /**
  92332. * Resize the texture to new value.
  92333. * @param size Define the new size the texture should have
  92334. * @param generateMipMaps Define whether the new texture should create mip maps
  92335. */
  92336. resize(size: number, generateMipMaps: boolean): void;
  92337. private _checkUniform;
  92338. /**
  92339. * Set a texture in the shader program used to render.
  92340. * @param name Define the name of the uniform samplers as defined in the shader
  92341. * @param texture Define the texture to bind to this sampler
  92342. * @return the texture itself allowing "fluent" like uniform updates
  92343. */
  92344. setTexture(name: string, texture: Texture): ProceduralTexture;
  92345. /**
  92346. * Set a float in the shader.
  92347. * @param name Define the name of the uniform as defined in the shader
  92348. * @param value Define the value to give to the uniform
  92349. * @return the texture itself allowing "fluent" like uniform updates
  92350. */
  92351. setFloat(name: string, value: number): ProceduralTexture;
  92352. /**
  92353. * Set a int in the shader.
  92354. * @param name Define the name of the uniform as defined in the shader
  92355. * @param value Define the value to give to the uniform
  92356. * @return the texture itself allowing "fluent" like uniform updates
  92357. */
  92358. setInt(name: string, value: number): ProceduralTexture;
  92359. /**
  92360. * Set an array of floats in the shader.
  92361. * @param name Define the name of the uniform as defined in the shader
  92362. * @param value Define the value to give to the uniform
  92363. * @return the texture itself allowing "fluent" like uniform updates
  92364. */
  92365. setFloats(name: string, value: number[]): ProceduralTexture;
  92366. /**
  92367. * Set a vec3 in the shader from a Color3.
  92368. * @param name Define the name of the uniform as defined in the shader
  92369. * @param value Define the value to give to the uniform
  92370. * @return the texture itself allowing "fluent" like uniform updates
  92371. */
  92372. setColor3(name: string, value: Color3): ProceduralTexture;
  92373. /**
  92374. * Set a vec4 in the shader from a Color4.
  92375. * @param name Define the name of the uniform as defined in the shader
  92376. * @param value Define the value to give to the uniform
  92377. * @return the texture itself allowing "fluent" like uniform updates
  92378. */
  92379. setColor4(name: string, value: Color4): ProceduralTexture;
  92380. /**
  92381. * Set a vec2 in the shader from a Vector2.
  92382. * @param name Define the name of the uniform as defined in the shader
  92383. * @param value Define the value to give to the uniform
  92384. * @return the texture itself allowing "fluent" like uniform updates
  92385. */
  92386. setVector2(name: string, value: Vector2): ProceduralTexture;
  92387. /**
  92388. * Set a vec3 in the shader from a Vector3.
  92389. * @param name Define the name of the uniform as defined in the shader
  92390. * @param value Define the value to give to the uniform
  92391. * @return the texture itself allowing "fluent" like uniform updates
  92392. */
  92393. setVector3(name: string, value: Vector3): ProceduralTexture;
  92394. /**
  92395. * Set a mat4 in the shader from a MAtrix.
  92396. * @param name Define the name of the uniform as defined in the shader
  92397. * @param value Define the value to give to the uniform
  92398. * @return the texture itself allowing "fluent" like uniform updates
  92399. */
  92400. setMatrix(name: string, value: Matrix): ProceduralTexture;
  92401. /**
  92402. * Render the texture to its associated render target.
  92403. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  92404. */
  92405. render(useCameraPostProcess?: boolean): void;
  92406. /**
  92407. * Clone the texture.
  92408. * @returns the cloned texture
  92409. */
  92410. clone(): ProceduralTexture;
  92411. /**
  92412. * Dispose the texture and release its asoociated resources.
  92413. */
  92414. dispose(): void;
  92415. }
  92416. }
  92417. declare module BABYLON {
  92418. /**
  92419. * This represents the base class for particle system in Babylon.
  92420. * 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.
  92421. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  92422. * @example https://doc.babylonjs.com/babylon101/particles
  92423. */
  92424. export class BaseParticleSystem {
  92425. /**
  92426. * Source color is added to the destination color without alpha affecting the result
  92427. */
  92428. static BLENDMODE_ONEONE: number;
  92429. /**
  92430. * Blend current color and particle color using particle’s alpha
  92431. */
  92432. static BLENDMODE_STANDARD: number;
  92433. /**
  92434. * Add current color and particle color multiplied by particle’s alpha
  92435. */
  92436. static BLENDMODE_ADD: number;
  92437. /**
  92438. * Multiply current color with particle color
  92439. */
  92440. static BLENDMODE_MULTIPLY: number;
  92441. /**
  92442. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  92443. */
  92444. static BLENDMODE_MULTIPLYADD: number;
  92445. /**
  92446. * List of animations used by the particle system.
  92447. */
  92448. animations: Animation[];
  92449. /**
  92450. * Gets or sets the unique id of the particle system
  92451. */
  92452. uniqueId: number;
  92453. /**
  92454. * The id of the Particle system.
  92455. */
  92456. id: string;
  92457. /**
  92458. * The friendly name of the Particle system.
  92459. */
  92460. name: string;
  92461. /**
  92462. * Snippet ID if the particle system was created from the snippet server
  92463. */
  92464. snippetId: string;
  92465. /**
  92466. * The rendering group used by the Particle system to chose when to render.
  92467. */
  92468. renderingGroupId: number;
  92469. /**
  92470. * The emitter represents the Mesh or position we are attaching the particle system to.
  92471. */
  92472. emitter: Nullable<AbstractMesh | Vector3>;
  92473. /**
  92474. * The maximum number of particles to emit per frame
  92475. */
  92476. emitRate: number;
  92477. /**
  92478. * If you want to launch only a few particles at once, that can be done, as well.
  92479. */
  92480. manualEmitCount: number;
  92481. /**
  92482. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  92483. */
  92484. updateSpeed: number;
  92485. /**
  92486. * The amount of time the particle system is running (depends of the overall update speed).
  92487. */
  92488. targetStopDuration: number;
  92489. /**
  92490. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  92491. */
  92492. disposeOnStop: boolean;
  92493. /**
  92494. * Minimum power of emitting particles.
  92495. */
  92496. minEmitPower: number;
  92497. /**
  92498. * Maximum power of emitting particles.
  92499. */
  92500. maxEmitPower: number;
  92501. /**
  92502. * Minimum life time of emitting particles.
  92503. */
  92504. minLifeTime: number;
  92505. /**
  92506. * Maximum life time of emitting particles.
  92507. */
  92508. maxLifeTime: number;
  92509. /**
  92510. * Minimum Size of emitting particles.
  92511. */
  92512. minSize: number;
  92513. /**
  92514. * Maximum Size of emitting particles.
  92515. */
  92516. maxSize: number;
  92517. /**
  92518. * Minimum scale of emitting particles on X axis.
  92519. */
  92520. minScaleX: number;
  92521. /**
  92522. * Maximum scale of emitting particles on X axis.
  92523. */
  92524. maxScaleX: number;
  92525. /**
  92526. * Minimum scale of emitting particles on Y axis.
  92527. */
  92528. minScaleY: number;
  92529. /**
  92530. * Maximum scale of emitting particles on Y axis.
  92531. */
  92532. maxScaleY: number;
  92533. /**
  92534. * Gets or sets the minimal initial rotation in radians.
  92535. */
  92536. minInitialRotation: number;
  92537. /**
  92538. * Gets or sets the maximal initial rotation in radians.
  92539. */
  92540. maxInitialRotation: number;
  92541. /**
  92542. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  92543. */
  92544. minAngularSpeed: number;
  92545. /**
  92546. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  92547. */
  92548. maxAngularSpeed: number;
  92549. /**
  92550. * The texture used to render each particle. (this can be a spritesheet)
  92551. */
  92552. particleTexture: Nullable<BaseTexture>;
  92553. /**
  92554. * The layer mask we are rendering the particles through.
  92555. */
  92556. layerMask: number;
  92557. /**
  92558. * This can help using your own shader to render the particle system.
  92559. * The according effect will be created
  92560. */
  92561. customShader: any;
  92562. /**
  92563. * By default particle system starts as soon as they are created. This prevents the
  92564. * automatic start to happen and let you decide when to start emitting particles.
  92565. */
  92566. preventAutoStart: boolean;
  92567. private _noiseTexture;
  92568. /**
  92569. * Gets or sets a texture used to add random noise to particle positions
  92570. */
  92571. get noiseTexture(): Nullable<ProceduralTexture>;
  92572. set noiseTexture(value: Nullable<ProceduralTexture>);
  92573. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  92574. noiseStrength: Vector3;
  92575. /**
  92576. * Callback triggered when the particle animation is ending.
  92577. */
  92578. onAnimationEnd: Nullable<() => void>;
  92579. /**
  92580. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  92581. */
  92582. blendMode: number;
  92583. /**
  92584. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  92585. * to override the particles.
  92586. */
  92587. forceDepthWrite: boolean;
  92588. /** 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 */
  92589. preWarmCycles: number;
  92590. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  92591. preWarmStepOffset: number;
  92592. /**
  92593. * 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)
  92594. */
  92595. spriteCellChangeSpeed: number;
  92596. /**
  92597. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  92598. */
  92599. startSpriteCellID: number;
  92600. /**
  92601. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  92602. */
  92603. endSpriteCellID: number;
  92604. /**
  92605. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  92606. */
  92607. spriteCellWidth: number;
  92608. /**
  92609. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  92610. */
  92611. spriteCellHeight: number;
  92612. /**
  92613. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  92614. */
  92615. spriteRandomStartCell: boolean;
  92616. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  92617. translationPivot: Vector2;
  92618. /** @hidden */
  92619. protected _isAnimationSheetEnabled: boolean;
  92620. /**
  92621. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  92622. */
  92623. beginAnimationOnStart: boolean;
  92624. /**
  92625. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  92626. */
  92627. beginAnimationFrom: number;
  92628. /**
  92629. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  92630. */
  92631. beginAnimationTo: number;
  92632. /**
  92633. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  92634. */
  92635. beginAnimationLoop: boolean;
  92636. /**
  92637. * Gets or sets a world offset applied to all particles
  92638. */
  92639. worldOffset: Vector3;
  92640. /**
  92641. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  92642. */
  92643. get isAnimationSheetEnabled(): boolean;
  92644. set isAnimationSheetEnabled(value: boolean);
  92645. /**
  92646. * Get hosting scene
  92647. * @returns the scene
  92648. */
  92649. getScene(): Nullable<Scene>;
  92650. /**
  92651. * You can use gravity if you want to give an orientation to your particles.
  92652. */
  92653. gravity: Vector3;
  92654. protected _colorGradients: Nullable<Array<ColorGradient>>;
  92655. protected _sizeGradients: Nullable<Array<FactorGradient>>;
  92656. protected _lifeTimeGradients: Nullable<Array<FactorGradient>>;
  92657. protected _angularSpeedGradients: Nullable<Array<FactorGradient>>;
  92658. protected _velocityGradients: Nullable<Array<FactorGradient>>;
  92659. protected _limitVelocityGradients: Nullable<Array<FactorGradient>>;
  92660. protected _dragGradients: Nullable<Array<FactorGradient>>;
  92661. protected _emitRateGradients: Nullable<Array<FactorGradient>>;
  92662. protected _startSizeGradients: Nullable<Array<FactorGradient>>;
  92663. protected _rampGradients: Nullable<Array<Color3Gradient>>;
  92664. protected _colorRemapGradients: Nullable<Array<FactorGradient>>;
  92665. protected _alphaRemapGradients: Nullable<Array<FactorGradient>>;
  92666. protected _hasTargetStopDurationDependantGradient(): boolean | null;
  92667. /**
  92668. * Defines the delay in milliseconds before starting the system (0 by default)
  92669. */
  92670. startDelay: number;
  92671. /**
  92672. * Gets the current list of drag gradients.
  92673. * You must use addDragGradient and removeDragGradient to udpate this list
  92674. * @returns the list of drag gradients
  92675. */
  92676. getDragGradients(): Nullable<Array<FactorGradient>>;
  92677. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  92678. limitVelocityDamping: number;
  92679. /**
  92680. * Gets the current list of limit velocity gradients.
  92681. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  92682. * @returns the list of limit velocity gradients
  92683. */
  92684. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  92685. /**
  92686. * Gets the current list of color gradients.
  92687. * You must use addColorGradient and removeColorGradient to udpate this list
  92688. * @returns the list of color gradients
  92689. */
  92690. getColorGradients(): Nullable<Array<ColorGradient>>;
  92691. /**
  92692. * Gets the current list of size gradients.
  92693. * You must use addSizeGradient and removeSizeGradient to udpate this list
  92694. * @returns the list of size gradients
  92695. */
  92696. getSizeGradients(): Nullable<Array<FactorGradient>>;
  92697. /**
  92698. * Gets the current list of color remap gradients.
  92699. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  92700. * @returns the list of color remap gradients
  92701. */
  92702. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  92703. /**
  92704. * Gets the current list of alpha remap gradients.
  92705. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  92706. * @returns the list of alpha remap gradients
  92707. */
  92708. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  92709. /**
  92710. * Gets the current list of life time gradients.
  92711. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  92712. * @returns the list of life time gradients
  92713. */
  92714. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  92715. /**
  92716. * Gets the current list of angular speed gradients.
  92717. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  92718. * @returns the list of angular speed gradients
  92719. */
  92720. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  92721. /**
  92722. * Gets the current list of velocity gradients.
  92723. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  92724. * @returns the list of velocity gradients
  92725. */
  92726. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  92727. /**
  92728. * Gets the current list of start size gradients.
  92729. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  92730. * @returns the list of start size gradients
  92731. */
  92732. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  92733. /**
  92734. * Gets the current list of emit rate gradients.
  92735. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  92736. * @returns the list of emit rate gradients
  92737. */
  92738. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  92739. /**
  92740. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92741. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92742. */
  92743. get direction1(): Vector3;
  92744. set direction1(value: Vector3);
  92745. /**
  92746. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  92747. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92748. */
  92749. get direction2(): Vector3;
  92750. set direction2(value: Vector3);
  92751. /**
  92752. * 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.
  92753. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92754. */
  92755. get minEmitBox(): Vector3;
  92756. set minEmitBox(value: Vector3);
  92757. /**
  92758. * 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.
  92759. * This only works when particleEmitterTyps is a BoxParticleEmitter
  92760. */
  92761. get maxEmitBox(): Vector3;
  92762. set maxEmitBox(value: Vector3);
  92763. /**
  92764. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92765. */
  92766. color1: Color4;
  92767. /**
  92768. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  92769. */
  92770. color2: Color4;
  92771. /**
  92772. * Color the particle will have at the end of its lifetime
  92773. */
  92774. colorDead: Color4;
  92775. /**
  92776. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  92777. */
  92778. textureMask: Color4;
  92779. /**
  92780. * The particle emitter type defines the emitter used by the particle system.
  92781. * It can be for example box, sphere, or cone...
  92782. */
  92783. particleEmitterType: IParticleEmitterType;
  92784. /** @hidden */
  92785. _isSubEmitter: boolean;
  92786. /**
  92787. * Gets or sets the billboard mode to use when isBillboardBased = true.
  92788. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  92789. */
  92790. billboardMode: number;
  92791. protected _isBillboardBased: boolean;
  92792. /**
  92793. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  92794. */
  92795. get isBillboardBased(): boolean;
  92796. set isBillboardBased(value: boolean);
  92797. /**
  92798. * The scene the particle system belongs to.
  92799. */
  92800. protected _scene: Nullable<Scene>;
  92801. /**
  92802. * The engine the particle system belongs to.
  92803. */
  92804. protected _engine: ThinEngine;
  92805. /**
  92806. * Local cache of defines for image processing.
  92807. */
  92808. protected _imageProcessingConfigurationDefines: ImageProcessingConfigurationDefines;
  92809. /**
  92810. * Default configuration related to image processing available in the standard Material.
  92811. */
  92812. protected _imageProcessingConfiguration: Nullable<ImageProcessingConfiguration>;
  92813. /**
  92814. * Gets the image processing configuration used either in this material.
  92815. */
  92816. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  92817. /**
  92818. * Sets the Default image processing configuration used either in the this material.
  92819. *
  92820. * If sets to null, the scene one is in use.
  92821. */
  92822. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  92823. /**
  92824. * Attaches a new image processing configuration to the Standard Material.
  92825. * @param configuration
  92826. */
  92827. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  92828. /** @hidden */
  92829. protected _reset(): void;
  92830. /** @hidden */
  92831. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: Nullable<RawTexture>): BaseParticleSystem;
  92832. /**
  92833. * Instantiates a particle system.
  92834. * 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.
  92835. * @param name The name of the particle system
  92836. */
  92837. constructor(name: string);
  92838. /**
  92839. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  92840. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92841. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92842. * @returns the emitter
  92843. */
  92844. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  92845. /**
  92846. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  92847. * @param radius The radius of the hemisphere to emit from
  92848. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92849. * @returns the emitter
  92850. */
  92851. createHemisphericEmitter(radius?: number, radiusRange?: number): HemisphericParticleEmitter;
  92852. /**
  92853. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  92854. * @param radius The radius of the sphere to emit from
  92855. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  92856. * @returns the emitter
  92857. */
  92858. createSphereEmitter(radius?: number, radiusRange?: number): SphereParticleEmitter;
  92859. /**
  92860. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  92861. * @param radius The radius of the sphere to emit from
  92862. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  92863. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  92864. * @returns the emitter
  92865. */
  92866. createDirectedSphereEmitter(radius?: number, direction1?: Vector3, direction2?: Vector3): SphereDirectedParticleEmitter;
  92867. /**
  92868. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  92869. * @param radius The radius of the emission cylinder
  92870. * @param height The height of the emission cylinder
  92871. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  92872. * @param directionRandomizer How much to randomize the particle direction [0-1]
  92873. * @returns the emitter
  92874. */
  92875. createCylinderEmitter(radius?: number, height?: number, radiusRange?: number, directionRandomizer?: number): CylinderParticleEmitter;
  92876. /**
  92877. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  92878. * @param radius The radius of the cylinder to emit from
  92879. * @param height The height of the emission cylinder
  92880. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  92881. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  92882. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  92883. * @returns the emitter
  92884. */
  92885. createDirectedCylinderEmitter(radius?: number, height?: number, radiusRange?: number, direction1?: Vector3, direction2?: Vector3): CylinderDirectedParticleEmitter;
  92886. /**
  92887. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  92888. * @param radius The radius of the cone to emit from
  92889. * @param angle The base angle of the cone
  92890. * @returns the emitter
  92891. */
  92892. createConeEmitter(radius?: number, angle?: number): ConeParticleEmitter;
  92893. /**
  92894. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  92895. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  92896. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  92897. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92898. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  92899. * @returns the emitter
  92900. */
  92901. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  92902. }
  92903. }
  92904. declare module BABYLON {
  92905. /**
  92906. * Type of sub emitter
  92907. */
  92908. export enum SubEmitterType {
  92909. /**
  92910. * Attached to the particle over it's lifetime
  92911. */
  92912. ATTACHED = 0,
  92913. /**
  92914. * Created when the particle dies
  92915. */
  92916. END = 1
  92917. }
  92918. /**
  92919. * Sub emitter class used to emit particles from an existing particle
  92920. */
  92921. export class SubEmitter {
  92922. /**
  92923. * the particle system to be used by the sub emitter
  92924. */
  92925. particleSystem: ParticleSystem;
  92926. /**
  92927. * Type of the submitter (Default: END)
  92928. */
  92929. type: SubEmitterType;
  92930. /**
  92931. * 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)
  92932. * Note: This only is supported when using an emitter of type Mesh
  92933. */
  92934. inheritDirection: boolean;
  92935. /**
  92936. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  92937. */
  92938. inheritedVelocityAmount: number;
  92939. /**
  92940. * Creates a sub emitter
  92941. * @param particleSystem the particle system to be used by the sub emitter
  92942. */
  92943. constructor(
  92944. /**
  92945. * the particle system to be used by the sub emitter
  92946. */
  92947. particleSystem: ParticleSystem);
  92948. /**
  92949. * Clones the sub emitter
  92950. * @returns the cloned sub emitter
  92951. */
  92952. clone(): SubEmitter;
  92953. /**
  92954. * Serialize current object to a JSON object
  92955. * @returns the serialized object
  92956. */
  92957. serialize(): any;
  92958. /** @hidden */
  92959. static _ParseParticleSystem(system: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): ParticleSystem;
  92960. /**
  92961. * Creates a new SubEmitter from a serialized JSON version
  92962. * @param serializationObject defines the JSON object to read from
  92963. * @param sceneOrEngine defines the hosting scene or the hosting engine
  92964. * @param rootUrl defines the rootUrl for data loading
  92965. * @returns a new SubEmitter
  92966. */
  92967. static Parse(serializationObject: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string): SubEmitter;
  92968. /** Release associated resources */
  92969. dispose(): void;
  92970. }
  92971. }
  92972. declare module BABYLON {
  92973. /** @hidden */
  92974. export var imageProcessingDeclaration: {
  92975. name: string;
  92976. shader: string;
  92977. };
  92978. }
  92979. declare module BABYLON {
  92980. /** @hidden */
  92981. export var imageProcessingFunctions: {
  92982. name: string;
  92983. shader: string;
  92984. };
  92985. }
  92986. declare module BABYLON {
  92987. /** @hidden */
  92988. export var particlesPixelShader: {
  92989. name: string;
  92990. shader: string;
  92991. };
  92992. }
  92993. declare module BABYLON {
  92994. /** @hidden */
  92995. export var particlesVertexShader: {
  92996. name: string;
  92997. shader: string;
  92998. };
  92999. }
  93000. declare module BABYLON {
  93001. /**
  93002. * Interface used to define entities containing multiple clip planes
  93003. */
  93004. export interface IClipPlanesHolder {
  93005. /**
  93006. * Gets or sets the active clipplane 1
  93007. */
  93008. clipPlane: Nullable<Plane>;
  93009. /**
  93010. * Gets or sets the active clipplane 2
  93011. */
  93012. clipPlane2: Nullable<Plane>;
  93013. /**
  93014. * Gets or sets the active clipplane 3
  93015. */
  93016. clipPlane3: Nullable<Plane>;
  93017. /**
  93018. * Gets or sets the active clipplane 4
  93019. */
  93020. clipPlane4: Nullable<Plane>;
  93021. /**
  93022. * Gets or sets the active clipplane 5
  93023. */
  93024. clipPlane5: Nullable<Plane>;
  93025. /**
  93026. * Gets or sets the active clipplane 6
  93027. */
  93028. clipPlane6: Nullable<Plane>;
  93029. }
  93030. }
  93031. declare module BABYLON {
  93032. /**
  93033. * "Static Class" containing a few commonly used helper while dealing with material for rendering purpose.
  93034. *
  93035. * It is complementary with MaterialHelper but provides completely independent functions (for tree shaking sake)
  93036. *
  93037. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  93038. */
  93039. export class ThinMaterialHelper {
  93040. /**
  93041. * Binds the clip plane information from the holder to the effect.
  93042. * @param effect The effect we are binding the data to
  93043. * @param holder The entity containing the clip plane information
  93044. */
  93045. static BindClipPlane(effect: Effect, holder: IClipPlanesHolder): void;
  93046. }
  93047. }
  93048. declare module BABYLON {
  93049. interface ThinEngine {
  93050. /**
  93051. * Sets alpha constants used by some alpha blending modes
  93052. * @param r defines the red component
  93053. * @param g defines the green component
  93054. * @param b defines the blue component
  93055. * @param a defines the alpha component
  93056. */
  93057. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  93058. /**
  93059. * Sets the current alpha mode
  93060. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  93061. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  93062. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93063. */
  93064. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  93065. /**
  93066. * Gets the current alpha mode
  93067. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  93068. * @returns the current alpha mode
  93069. */
  93070. getAlphaMode(): number;
  93071. /**
  93072. * Sets the current alpha equation
  93073. * @param equation defines the equation to use (one of the Engine.ALPHA_EQUATION_XXX)
  93074. */
  93075. setAlphaEquation(equation: number): void;
  93076. /**
  93077. * Gets the current alpha equation.
  93078. * @returns the current alpha equation
  93079. */
  93080. getAlphaEquation(): number;
  93081. }
  93082. }
  93083. declare module BABYLON {
  93084. /**
  93085. * This represents a particle system in Babylon.
  93086. * 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.
  93087. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  93088. * @example https://doc.babylonjs.com/babylon101/particles
  93089. */
  93090. export class ParticleSystem extends BaseParticleSystem implements IDisposable, IAnimatable, IParticleSystem {
  93091. /**
  93092. * Billboard mode will only apply to Y axis
  93093. */
  93094. static readonly BILLBOARDMODE_Y: number;
  93095. /**
  93096. * Billboard mode will apply to all axes
  93097. */
  93098. static readonly BILLBOARDMODE_ALL: number;
  93099. /**
  93100. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  93101. */
  93102. static readonly BILLBOARDMODE_STRETCHED: number;
  93103. /**
  93104. * This function can be defined to provide custom update for active particles.
  93105. * This function will be called instead of regular update (age, position, color, etc.).
  93106. * Do not forget that this function will be called on every frame so try to keep it simple and fast :)
  93107. */
  93108. updateFunction: (particles: Particle[]) => void;
  93109. private _emitterWorldMatrix;
  93110. /**
  93111. * This function can be defined to specify initial direction for every new particle.
  93112. * It by default use the emitterType defined function
  93113. */
  93114. startDirectionFunction: (worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93115. /**
  93116. * This function can be defined to specify initial position for every new particle.
  93117. * It by default use the emitterType defined function
  93118. */
  93119. startPositionFunction: (worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean) => void;
  93120. /**
  93121. * @hidden
  93122. */
  93123. _inheritedVelocityOffset: Vector3;
  93124. /**
  93125. * An event triggered when the system is disposed
  93126. */
  93127. onDisposeObservable: Observable<IParticleSystem>;
  93128. private _onDisposeObserver;
  93129. /**
  93130. * Sets a callback that will be triggered when the system is disposed
  93131. */
  93132. set onDispose(callback: () => void);
  93133. private _particles;
  93134. private _epsilon;
  93135. private _capacity;
  93136. private _stockParticles;
  93137. private _newPartsExcess;
  93138. private _vertexData;
  93139. private _vertexBuffer;
  93140. private _vertexBuffers;
  93141. private _spriteBuffer;
  93142. private _indexBuffer;
  93143. private _effect;
  93144. private _customEffect;
  93145. private _cachedDefines;
  93146. private _scaledColorStep;
  93147. private _colorDiff;
  93148. private _scaledDirection;
  93149. private _scaledGravity;
  93150. private _currentRenderId;
  93151. private _alive;
  93152. private _useInstancing;
  93153. private _started;
  93154. private _stopped;
  93155. private _actualFrame;
  93156. private _scaledUpdateSpeed;
  93157. private _vertexBufferSize;
  93158. /** @hidden */
  93159. _currentEmitRateGradient: Nullable<FactorGradient>;
  93160. /** @hidden */
  93161. _currentEmitRate1: number;
  93162. /** @hidden */
  93163. _currentEmitRate2: number;
  93164. /** @hidden */
  93165. _currentStartSizeGradient: Nullable<FactorGradient>;
  93166. /** @hidden */
  93167. _currentStartSize1: number;
  93168. /** @hidden */
  93169. _currentStartSize2: number;
  93170. private readonly _rawTextureWidth;
  93171. private _rampGradientsTexture;
  93172. private _useRampGradients;
  93173. /** Gets or sets a matrix to use to compute projection */
  93174. defaultProjectionMatrix: Matrix;
  93175. /** Gets or sets a matrix to use to compute view */
  93176. defaultViewMatrix: Matrix;
  93177. /** Gets or sets a boolean indicating that ramp gradients must be used
  93178. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  93179. */
  93180. get useRampGradients(): boolean;
  93181. set useRampGradients(value: boolean);
  93182. /**
  93183. * 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.
  93184. * 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: [])
  93185. */
  93186. subEmitters: Array<ParticleSystem | SubEmitter | Array<SubEmitter>>;
  93187. private _subEmitters;
  93188. /**
  93189. * @hidden
  93190. * If the particle systems emitter should be disposed when the particle system is disposed
  93191. */
  93192. _disposeEmitterOnDispose: boolean;
  93193. /**
  93194. * The current active Sub-systems, this property is used by the root particle system only.
  93195. */
  93196. activeSubSystems: Array<ParticleSystem>;
  93197. /**
  93198. * Specifies if the particles are updated in emitter local space or world space
  93199. */
  93200. isLocal: boolean;
  93201. private _rootParticleSystem;
  93202. /**
  93203. * Gets the current list of active particles
  93204. */
  93205. get particles(): Particle[];
  93206. /**
  93207. * Gets the number of particles active at the same time.
  93208. * @returns The number of active particles.
  93209. */
  93210. getActiveCount(): number;
  93211. /**
  93212. * Returns the string "ParticleSystem"
  93213. * @returns a string containing the class name
  93214. */
  93215. getClassName(): string;
  93216. /**
  93217. * Gets a boolean indicating that the system is stopping
  93218. * @returns true if the system is currently stopping
  93219. */
  93220. isStopping(): boolean;
  93221. /**
  93222. * Gets the custom effect used to render the particles
  93223. * @param blendMode Blend mode for which the effect should be retrieved
  93224. * @returns The effect
  93225. */
  93226. getCustomEffect(blendMode?: number): Nullable<Effect>;
  93227. /**
  93228. * Sets the custom effect used to render the particles
  93229. * @param effect The effect to set
  93230. * @param blendMode Blend mode for which the effect should be set
  93231. */
  93232. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  93233. /** @hidden */
  93234. private _onBeforeDrawParticlesObservable;
  93235. /**
  93236. * Observable that will be called just before the particles are drawn
  93237. */
  93238. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  93239. /**
  93240. * Gets the name of the particle vertex shader
  93241. */
  93242. get vertexShaderName(): string;
  93243. /**
  93244. * Instantiates a particle system.
  93245. * 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.
  93246. * @param name The name of the particle system
  93247. * @param capacity The max number of particles alive at the same time
  93248. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  93249. * @param customEffect a custom effect used to change the way particles are rendered by default
  93250. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  93251. * @param epsilon Offset used to render the particles
  93252. */
  93253. constructor(name: string, capacity: number, sceneOrEngine: Scene | ThinEngine, customEffect?: Nullable<Effect>, isAnimationSheetEnabled?: boolean, epsilon?: number);
  93254. private _addFactorGradient;
  93255. private _removeFactorGradient;
  93256. /**
  93257. * Adds a new life time gradient
  93258. * @param gradient defines the gradient to use (between 0 and 1)
  93259. * @param factor defines the life time factor to affect to the specified gradient
  93260. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93261. * @returns the current particle system
  93262. */
  93263. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93264. /**
  93265. * Remove a specific life time gradient
  93266. * @param gradient defines the gradient to remove
  93267. * @returns the current particle system
  93268. */
  93269. removeLifeTimeGradient(gradient: number): IParticleSystem;
  93270. /**
  93271. * Adds a new size gradient
  93272. * @param gradient defines the gradient to use (between 0 and 1)
  93273. * @param factor defines the size factor to affect to the specified gradient
  93274. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93275. * @returns the current particle system
  93276. */
  93277. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93278. /**
  93279. * Remove a specific size gradient
  93280. * @param gradient defines the gradient to remove
  93281. * @returns the current particle system
  93282. */
  93283. removeSizeGradient(gradient: number): IParticleSystem;
  93284. /**
  93285. * Adds a new color remap gradient
  93286. * @param gradient defines the gradient to use (between 0 and 1)
  93287. * @param min defines the color remap minimal range
  93288. * @param max defines the color remap maximal range
  93289. * @returns the current particle system
  93290. */
  93291. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93292. /**
  93293. * Remove a specific color remap gradient
  93294. * @param gradient defines the gradient to remove
  93295. * @returns the current particle system
  93296. */
  93297. removeColorRemapGradient(gradient: number): IParticleSystem;
  93298. /**
  93299. * Adds a new alpha remap gradient
  93300. * @param gradient defines the gradient to use (between 0 and 1)
  93301. * @param min defines the alpha remap minimal range
  93302. * @param max defines the alpha remap maximal range
  93303. * @returns the current particle system
  93304. */
  93305. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  93306. /**
  93307. * Remove a specific alpha remap gradient
  93308. * @param gradient defines the gradient to remove
  93309. * @returns the current particle system
  93310. */
  93311. removeAlphaRemapGradient(gradient: number): IParticleSystem;
  93312. /**
  93313. * Adds a new angular speed gradient
  93314. * @param gradient defines the gradient to use (between 0 and 1)
  93315. * @param factor defines the angular speed to affect to the specified gradient
  93316. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93317. * @returns the current particle system
  93318. */
  93319. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93320. /**
  93321. * Remove a specific angular speed gradient
  93322. * @param gradient defines the gradient to remove
  93323. * @returns the current particle system
  93324. */
  93325. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  93326. /**
  93327. * Adds a new velocity gradient
  93328. * @param gradient defines the gradient to use (between 0 and 1)
  93329. * @param factor defines the velocity to affect to the specified gradient
  93330. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93331. * @returns the current particle system
  93332. */
  93333. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93334. /**
  93335. * Remove a specific velocity gradient
  93336. * @param gradient defines the gradient to remove
  93337. * @returns the current particle system
  93338. */
  93339. removeVelocityGradient(gradient: number): IParticleSystem;
  93340. /**
  93341. * Adds a new limit velocity gradient
  93342. * @param gradient defines the gradient to use (between 0 and 1)
  93343. * @param factor defines the limit velocity value to affect to the specified gradient
  93344. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93345. * @returns the current particle system
  93346. */
  93347. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93348. /**
  93349. * Remove a specific limit velocity gradient
  93350. * @param gradient defines the gradient to remove
  93351. * @returns the current particle system
  93352. */
  93353. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  93354. /**
  93355. * Adds a new drag gradient
  93356. * @param gradient defines the gradient to use (between 0 and 1)
  93357. * @param factor defines the drag value to affect to the specified gradient
  93358. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93359. * @returns the current particle system
  93360. */
  93361. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93362. /**
  93363. * Remove a specific drag gradient
  93364. * @param gradient defines the gradient to remove
  93365. * @returns the current particle system
  93366. */
  93367. removeDragGradient(gradient: number): IParticleSystem;
  93368. /**
  93369. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  93370. * @param gradient defines the gradient to use (between 0 and 1)
  93371. * @param factor defines the emit rate value to affect to the specified gradient
  93372. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93373. * @returns the current particle system
  93374. */
  93375. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93376. /**
  93377. * Remove a specific emit rate gradient
  93378. * @param gradient defines the gradient to remove
  93379. * @returns the current particle system
  93380. */
  93381. removeEmitRateGradient(gradient: number): IParticleSystem;
  93382. /**
  93383. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  93384. * @param gradient defines the gradient to use (between 0 and 1)
  93385. * @param factor defines the start size value to affect to the specified gradient
  93386. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  93387. * @returns the current particle system
  93388. */
  93389. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  93390. /**
  93391. * Remove a specific start size gradient
  93392. * @param gradient defines the gradient to remove
  93393. * @returns the current particle system
  93394. */
  93395. removeStartSizeGradient(gradient: number): IParticleSystem;
  93396. private _createRampGradientTexture;
  93397. /**
  93398. * Gets the current list of ramp gradients.
  93399. * You must use addRampGradient and removeRampGradient to udpate this list
  93400. * @returns the list of ramp gradients
  93401. */
  93402. getRampGradients(): Nullable<Array<Color3Gradient>>;
  93403. /** Force the system to rebuild all gradients that need to be resync */
  93404. forceRefreshGradients(): void;
  93405. private _syncRampGradientTexture;
  93406. /**
  93407. * Adds a new ramp gradient used to remap particle colors
  93408. * @param gradient defines the gradient to use (between 0 and 1)
  93409. * @param color defines the color to affect to the specified gradient
  93410. * @returns the current particle system
  93411. */
  93412. addRampGradient(gradient: number, color: Color3): ParticleSystem;
  93413. /**
  93414. * Remove a specific ramp gradient
  93415. * @param gradient defines the gradient to remove
  93416. * @returns the current particle system
  93417. */
  93418. removeRampGradient(gradient: number): ParticleSystem;
  93419. /**
  93420. * Adds a new color gradient
  93421. * @param gradient defines the gradient to use (between 0 and 1)
  93422. * @param color1 defines the color to affect to the specified gradient
  93423. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  93424. * @returns this particle system
  93425. */
  93426. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  93427. /**
  93428. * Remove a specific color gradient
  93429. * @param gradient defines the gradient to remove
  93430. * @returns this particle system
  93431. */
  93432. removeColorGradient(gradient: number): IParticleSystem;
  93433. private _fetchR;
  93434. protected _reset(): void;
  93435. private _resetEffect;
  93436. private _createVertexBuffers;
  93437. private _createIndexBuffer;
  93438. /**
  93439. * Gets the maximum number of particles active at the same time.
  93440. * @returns The max number of active particles.
  93441. */
  93442. getCapacity(): number;
  93443. /**
  93444. * Gets whether there are still active particles in the system.
  93445. * @returns True if it is alive, otherwise false.
  93446. */
  93447. isAlive(): boolean;
  93448. /**
  93449. * Gets if the system has been started. (Note: this will still be true after stop is called)
  93450. * @returns True if it has been started, otherwise false.
  93451. */
  93452. isStarted(): boolean;
  93453. private _prepareSubEmitterInternalArray;
  93454. /**
  93455. * Starts the particle system and begins to emit
  93456. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  93457. */
  93458. start(delay?: number): void;
  93459. /**
  93460. * Stops the particle system.
  93461. * @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.
  93462. */
  93463. stop(stopSubEmitters?: boolean): void;
  93464. /**
  93465. * Remove all active particles
  93466. */
  93467. reset(): void;
  93468. /**
  93469. * @hidden (for internal use only)
  93470. */
  93471. _appendParticleVertex(index: number, particle: Particle, offsetX: number, offsetY: number): void;
  93472. /**
  93473. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  93474. * Its lifetime will start back at 0.
  93475. */
  93476. recycleParticle: (particle: Particle) => void;
  93477. private _stopSubEmitters;
  93478. private _createParticle;
  93479. private _removeFromRoot;
  93480. private _emitFromParticle;
  93481. private _update;
  93482. /** @hidden */
  93483. static _GetAttributeNamesOrOptions(isAnimationSheetEnabled?: boolean, isBillboardBased?: boolean, useRampGradients?: boolean): string[];
  93484. /** @hidden */
  93485. static _GetEffectCreationOptions(isAnimationSheetEnabled?: boolean): string[];
  93486. /**
  93487. * Fill the defines array according to the current settings of the particle system
  93488. * @param defines Array to be updated
  93489. * @param blendMode blend mode to take into account when updating the array
  93490. */
  93491. fillDefines(defines: Array<string>, blendMode: number): void;
  93492. /**
  93493. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  93494. * @param uniforms Uniforms array to fill
  93495. * @param attributes Attributes array to fill
  93496. * @param samplers Samplers array to fill
  93497. */
  93498. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  93499. /** @hidden */
  93500. private _getEffect;
  93501. /**
  93502. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  93503. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  93504. */
  93505. animate(preWarmOnly?: boolean): void;
  93506. private _appendParticleVertices;
  93507. /**
  93508. * Rebuilds the particle system.
  93509. */
  93510. rebuild(): void;
  93511. /**
  93512. * Is this system ready to be used/rendered
  93513. * @return true if the system is ready
  93514. */
  93515. isReady(): boolean;
  93516. private _render;
  93517. /**
  93518. * Renders the particle system in its current state.
  93519. * @returns the current number of particles
  93520. */
  93521. render(): number;
  93522. /**
  93523. * Disposes the particle system and free the associated resources
  93524. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  93525. */
  93526. dispose(disposeTexture?: boolean): void;
  93527. /**
  93528. * Clones the particle system.
  93529. * @param name The name of the cloned object
  93530. * @param newEmitter The new emitter to use
  93531. * @returns the cloned particle system
  93532. */
  93533. clone(name: string, newEmitter: any): ParticleSystem;
  93534. /**
  93535. * Serializes the particle system to a JSON object
  93536. * @param serializeTexture defines if the texture must be serialized as well
  93537. * @returns the JSON object
  93538. */
  93539. serialize(serializeTexture?: boolean): any;
  93540. /** @hidden */
  93541. static _Serialize(serializationObject: any, particleSystem: IParticleSystem, serializeTexture: boolean): void;
  93542. /** @hidden */
  93543. static _Parse(parsedParticleSystem: any, particleSystem: IParticleSystem, sceneOrEngine: Scene | ThinEngine, rootUrl: string): void;
  93544. /**
  93545. * Parses a JSON object to create a particle system.
  93546. * @param parsedParticleSystem The JSON object to parse
  93547. * @param sceneOrEngine The scene or the engine to create the particle system in
  93548. * @param rootUrl The root url to use to load external dependencies like texture
  93549. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  93550. * @returns the Parsed particle system
  93551. */
  93552. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): ParticleSystem;
  93553. }
  93554. }
  93555. declare module BABYLON {
  93556. /**
  93557. * A particle represents one of the element emitted by a particle system.
  93558. * This is mainly define by its coordinates, direction, velocity and age.
  93559. */
  93560. export class Particle {
  93561. /**
  93562. * The particle system the particle belongs to.
  93563. */
  93564. particleSystem: ParticleSystem;
  93565. private static _Count;
  93566. /**
  93567. * Unique ID of the particle
  93568. */
  93569. id: number;
  93570. /**
  93571. * The world position of the particle in the scene.
  93572. */
  93573. position: Vector3;
  93574. /**
  93575. * The world direction of the particle in the scene.
  93576. */
  93577. direction: Vector3;
  93578. /**
  93579. * The color of the particle.
  93580. */
  93581. color: Color4;
  93582. /**
  93583. * The color change of the particle per step.
  93584. */
  93585. colorStep: Color4;
  93586. /**
  93587. * Defines how long will the life of the particle be.
  93588. */
  93589. lifeTime: number;
  93590. /**
  93591. * The current age of the particle.
  93592. */
  93593. age: number;
  93594. /**
  93595. * The current size of the particle.
  93596. */
  93597. size: number;
  93598. /**
  93599. * The current scale of the particle.
  93600. */
  93601. scale: Vector2;
  93602. /**
  93603. * The current angle of the particle.
  93604. */
  93605. angle: number;
  93606. /**
  93607. * Defines how fast is the angle changing.
  93608. */
  93609. angularSpeed: number;
  93610. /**
  93611. * Defines the cell index used by the particle to be rendered from a sprite.
  93612. */
  93613. cellIndex: number;
  93614. /**
  93615. * The information required to support color remapping
  93616. */
  93617. remapData: Vector4;
  93618. /** @hidden */
  93619. _randomCellOffset?: number;
  93620. /** @hidden */
  93621. _initialDirection: Nullable<Vector3>;
  93622. /** @hidden */
  93623. _attachedSubEmitters: Nullable<Array<SubEmitter>>;
  93624. /** @hidden */
  93625. _initialStartSpriteCellID: number;
  93626. /** @hidden */
  93627. _initialEndSpriteCellID: number;
  93628. /** @hidden */
  93629. _currentColorGradient: Nullable<ColorGradient>;
  93630. /** @hidden */
  93631. _currentColor1: Color4;
  93632. /** @hidden */
  93633. _currentColor2: Color4;
  93634. /** @hidden */
  93635. _currentSizeGradient: Nullable<FactorGradient>;
  93636. /** @hidden */
  93637. _currentSize1: number;
  93638. /** @hidden */
  93639. _currentSize2: number;
  93640. /** @hidden */
  93641. _currentAngularSpeedGradient: Nullable<FactorGradient>;
  93642. /** @hidden */
  93643. _currentAngularSpeed1: number;
  93644. /** @hidden */
  93645. _currentAngularSpeed2: number;
  93646. /** @hidden */
  93647. _currentVelocityGradient: Nullable<FactorGradient>;
  93648. /** @hidden */
  93649. _currentVelocity1: number;
  93650. /** @hidden */
  93651. _currentVelocity2: number;
  93652. /** @hidden */
  93653. _currentLimitVelocityGradient: Nullable<FactorGradient>;
  93654. /** @hidden */
  93655. _currentLimitVelocity1: number;
  93656. /** @hidden */
  93657. _currentLimitVelocity2: number;
  93658. /** @hidden */
  93659. _currentDragGradient: Nullable<FactorGradient>;
  93660. /** @hidden */
  93661. _currentDrag1: number;
  93662. /** @hidden */
  93663. _currentDrag2: number;
  93664. /** @hidden */
  93665. _randomNoiseCoordinates1: Vector3;
  93666. /** @hidden */
  93667. _randomNoiseCoordinates2: Vector3;
  93668. /** @hidden */
  93669. _localPosition?: Vector3;
  93670. /**
  93671. * Creates a new instance Particle
  93672. * @param particleSystem the particle system the particle belongs to
  93673. */
  93674. constructor(
  93675. /**
  93676. * The particle system the particle belongs to.
  93677. */
  93678. particleSystem: ParticleSystem);
  93679. private updateCellInfoFromSystem;
  93680. /**
  93681. * Defines how the sprite cell index is updated for the particle
  93682. */
  93683. updateCellIndex(): void;
  93684. /** @hidden */
  93685. _inheritParticleInfoToSubEmitter(subEmitter: SubEmitter): void;
  93686. /** @hidden */
  93687. _inheritParticleInfoToSubEmitters(): void;
  93688. /** @hidden */
  93689. _reset(): void;
  93690. /**
  93691. * Copy the properties of particle to another one.
  93692. * @param other the particle to copy the information to.
  93693. */
  93694. copyTo(other: Particle): void;
  93695. }
  93696. }
  93697. declare module BABYLON {
  93698. /**
  93699. * Particle emitter represents a volume emitting particles.
  93700. * This is the responsibility of the implementation to define the volume shape like cone/sphere/box.
  93701. */
  93702. export interface IParticleEmitterType {
  93703. /**
  93704. * Called by the particle System when the direction is computed for the created particle.
  93705. * @param worldMatrix is the world matrix of the particle system
  93706. * @param directionToUpdate is the direction vector to update with the result
  93707. * @param particle is the particle we are computed the direction for
  93708. * @param isLocal defines if the direction should be set in local space
  93709. */
  93710. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93711. /**
  93712. * Called by the particle System when the position is computed for the created particle.
  93713. * @param worldMatrix is the world matrix of the particle system
  93714. * @param positionToUpdate is the position vector to update with the result
  93715. * @param particle is the particle we are computed the position for
  93716. * @param isLocal defines if the position should be set in local space
  93717. */
  93718. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93719. /**
  93720. * Clones the current emitter and returns a copy of it
  93721. * @returns the new emitter
  93722. */
  93723. clone(): IParticleEmitterType;
  93724. /**
  93725. * Called by the GPUParticleSystem to setup the update shader
  93726. * @param effect defines the update shader
  93727. */
  93728. applyToShader(effect: Effect): void;
  93729. /**
  93730. * Returns a string to use to update the GPU particles update shader
  93731. * @returns the effect defines string
  93732. */
  93733. getEffectDefines(): string;
  93734. /**
  93735. * Returns a string representing the class name
  93736. * @returns a string containing the class name
  93737. */
  93738. getClassName(): string;
  93739. /**
  93740. * Serializes the particle system to a JSON object.
  93741. * @returns the JSON object
  93742. */
  93743. serialize(): any;
  93744. /**
  93745. * Parse properties from a JSON object
  93746. * @param serializationObject defines the JSON object
  93747. * @param scene defines the hosting scene
  93748. */
  93749. parse(serializationObject: any, scene: Nullable<Scene>): void;
  93750. }
  93751. }
  93752. declare module BABYLON {
  93753. /**
  93754. * Particle emitter emitting particles from the inside of a box.
  93755. * It emits the particles randomly between 2 given directions.
  93756. */
  93757. export class BoxParticleEmitter implements IParticleEmitterType {
  93758. /**
  93759. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93760. */
  93761. direction1: Vector3;
  93762. /**
  93763. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  93764. */
  93765. direction2: Vector3;
  93766. /**
  93767. * 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.
  93768. */
  93769. minEmitBox: Vector3;
  93770. /**
  93771. * 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.
  93772. */
  93773. maxEmitBox: Vector3;
  93774. /**
  93775. * Creates a new instance BoxParticleEmitter
  93776. */
  93777. constructor();
  93778. /**
  93779. * Called by the particle System when the direction is computed for the created particle.
  93780. * @param worldMatrix is the world matrix of the particle system
  93781. * @param directionToUpdate is the direction vector to update with the result
  93782. * @param particle is the particle we are computed the direction for
  93783. * @param isLocal defines if the direction should be set in local space
  93784. */
  93785. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93786. /**
  93787. * Called by the particle System when the position is computed for the created particle.
  93788. * @param worldMatrix is the world matrix of the particle system
  93789. * @param positionToUpdate is the position vector to update with the result
  93790. * @param particle is the particle we are computed the position for
  93791. * @param isLocal defines if the position should be set in local space
  93792. */
  93793. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93794. /**
  93795. * Clones the current emitter and returns a copy of it
  93796. * @returns the new emitter
  93797. */
  93798. clone(): BoxParticleEmitter;
  93799. /**
  93800. * Called by the GPUParticleSystem to setup the update shader
  93801. * @param effect defines the update shader
  93802. */
  93803. applyToShader(effect: Effect): void;
  93804. /**
  93805. * Returns a string to use to update the GPU particles update shader
  93806. * @returns a string containng the defines string
  93807. */
  93808. getEffectDefines(): string;
  93809. /**
  93810. * Returns the string "BoxParticleEmitter"
  93811. * @returns a string containing the class name
  93812. */
  93813. getClassName(): string;
  93814. /**
  93815. * Serializes the particle system to a JSON object.
  93816. * @returns the JSON object
  93817. */
  93818. serialize(): any;
  93819. /**
  93820. * Parse properties from a JSON object
  93821. * @param serializationObject defines the JSON object
  93822. */
  93823. parse(serializationObject: any): void;
  93824. }
  93825. }
  93826. declare module BABYLON {
  93827. /**
  93828. * Particle emitter emitting particles from the inside of a cone.
  93829. * It emits the particles alongside the cone volume from the base to the particle.
  93830. * The emission direction might be randomized.
  93831. */
  93832. export class ConeParticleEmitter implements IParticleEmitterType {
  93833. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93834. directionRandomizer: number;
  93835. private _radius;
  93836. private _angle;
  93837. private _height;
  93838. /**
  93839. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  93840. */
  93841. radiusRange: number;
  93842. /**
  93843. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  93844. */
  93845. heightRange: number;
  93846. /**
  93847. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  93848. */
  93849. emitFromSpawnPointOnly: boolean;
  93850. /**
  93851. * Gets or sets the radius of the emission cone
  93852. */
  93853. get radius(): number;
  93854. set radius(value: number);
  93855. /**
  93856. * Gets or sets the angle of the emission cone
  93857. */
  93858. get angle(): number;
  93859. set angle(value: number);
  93860. private _buildHeight;
  93861. /**
  93862. * Creates a new instance ConeParticleEmitter
  93863. * @param radius the radius of the emission cone (1 by default)
  93864. * @param angle the cone base angle (PI by default)
  93865. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  93866. */
  93867. constructor(radius?: number, angle?: number,
  93868. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  93869. directionRandomizer?: number);
  93870. /**
  93871. * Called by the particle System when the direction is computed for the created particle.
  93872. * @param worldMatrix is the world matrix of the particle system
  93873. * @param directionToUpdate is the direction vector to update with the result
  93874. * @param particle is the particle we are computed the direction for
  93875. * @param isLocal defines if the direction should be set in local space
  93876. */
  93877. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93878. /**
  93879. * Called by the particle System when the position is computed for the created particle.
  93880. * @param worldMatrix is the world matrix of the particle system
  93881. * @param positionToUpdate is the position vector to update with the result
  93882. * @param particle is the particle we are computed the position for
  93883. * @param isLocal defines if the position should be set in local space
  93884. */
  93885. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93886. /**
  93887. * Clones the current emitter and returns a copy of it
  93888. * @returns the new emitter
  93889. */
  93890. clone(): ConeParticleEmitter;
  93891. /**
  93892. * Called by the GPUParticleSystem to setup the update shader
  93893. * @param effect defines the update shader
  93894. */
  93895. applyToShader(effect: Effect): void;
  93896. /**
  93897. * Returns a string to use to update the GPU particles update shader
  93898. * @returns a string containng the defines string
  93899. */
  93900. getEffectDefines(): string;
  93901. /**
  93902. * Returns the string "ConeParticleEmitter"
  93903. * @returns a string containing the class name
  93904. */
  93905. getClassName(): string;
  93906. /**
  93907. * Serializes the particle system to a JSON object.
  93908. * @returns the JSON object
  93909. */
  93910. serialize(): any;
  93911. /**
  93912. * Parse properties from a JSON object
  93913. * @param serializationObject defines the JSON object
  93914. */
  93915. parse(serializationObject: any): void;
  93916. }
  93917. }
  93918. declare module BABYLON {
  93919. /**
  93920. * Particle emitter emitting particles from the inside of a cylinder.
  93921. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  93922. */
  93923. export class CylinderParticleEmitter implements IParticleEmitterType {
  93924. /**
  93925. * The radius of the emission cylinder.
  93926. */
  93927. radius: number;
  93928. /**
  93929. * The height of the emission cylinder.
  93930. */
  93931. height: number;
  93932. /**
  93933. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93934. */
  93935. radiusRange: number;
  93936. /**
  93937. * How much to randomize the particle direction [0-1].
  93938. */
  93939. directionRandomizer: number;
  93940. /**
  93941. * Creates a new instance CylinderParticleEmitter
  93942. * @param radius the radius of the emission cylinder (1 by default)
  93943. * @param height the height of the emission cylinder (1 by default)
  93944. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  93945. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  93946. */
  93947. constructor(
  93948. /**
  93949. * The radius of the emission cylinder.
  93950. */
  93951. radius?: number,
  93952. /**
  93953. * The height of the emission cylinder.
  93954. */
  93955. height?: number,
  93956. /**
  93957. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  93958. */
  93959. radiusRange?: number,
  93960. /**
  93961. * How much to randomize the particle direction [0-1].
  93962. */
  93963. directionRandomizer?: number);
  93964. /**
  93965. * Called by the particle System when the direction is computed for the created particle.
  93966. * @param worldMatrix is the world matrix of the particle system
  93967. * @param directionToUpdate is the direction vector to update with the result
  93968. * @param particle is the particle we are computed the direction for
  93969. * @param isLocal defines if the direction should be set in local space
  93970. */
  93971. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93972. /**
  93973. * Called by the particle System when the position is computed for the created particle.
  93974. * @param worldMatrix is the world matrix of the particle system
  93975. * @param positionToUpdate is the position vector to update with the result
  93976. * @param particle is the particle we are computed the position for
  93977. * @param isLocal defines if the position should be set in local space
  93978. */
  93979. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  93980. /**
  93981. * Clones the current emitter and returns a copy of it
  93982. * @returns the new emitter
  93983. */
  93984. clone(): CylinderParticleEmitter;
  93985. /**
  93986. * Called by the GPUParticleSystem to setup the update shader
  93987. * @param effect defines the update shader
  93988. */
  93989. applyToShader(effect: Effect): void;
  93990. /**
  93991. * Returns a string to use to update the GPU particles update shader
  93992. * @returns a string containng the defines string
  93993. */
  93994. getEffectDefines(): string;
  93995. /**
  93996. * Returns the string "CylinderParticleEmitter"
  93997. * @returns a string containing the class name
  93998. */
  93999. getClassName(): string;
  94000. /**
  94001. * Serializes the particle system to a JSON object.
  94002. * @returns the JSON object
  94003. */
  94004. serialize(): any;
  94005. /**
  94006. * Parse properties from a JSON object
  94007. * @param serializationObject defines the JSON object
  94008. */
  94009. parse(serializationObject: any): void;
  94010. }
  94011. /**
  94012. * Particle emitter emitting particles from the inside of a cylinder.
  94013. * It emits the particles randomly between two vectors.
  94014. */
  94015. export class CylinderDirectedParticleEmitter extends CylinderParticleEmitter {
  94016. /**
  94017. * The min limit of the emission direction.
  94018. */
  94019. direction1: Vector3;
  94020. /**
  94021. * The max limit of the emission direction.
  94022. */
  94023. direction2: Vector3;
  94024. /**
  94025. * Creates a new instance CylinderDirectedParticleEmitter
  94026. * @param radius the radius of the emission cylinder (1 by default)
  94027. * @param height the height of the emission cylinder (1 by default)
  94028. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94029. * @param direction1 the min limit of the emission direction (up vector by default)
  94030. * @param direction2 the max limit of the emission direction (up vector by default)
  94031. */
  94032. constructor(radius?: number, height?: number, radiusRange?: number,
  94033. /**
  94034. * The min limit of the emission direction.
  94035. */
  94036. direction1?: Vector3,
  94037. /**
  94038. * The max limit of the emission direction.
  94039. */
  94040. direction2?: Vector3);
  94041. /**
  94042. * Called by the particle System when the direction is computed for the created particle.
  94043. * @param worldMatrix is the world matrix of the particle system
  94044. * @param directionToUpdate is the direction vector to update with the result
  94045. * @param particle is the particle we are computed the direction for
  94046. */
  94047. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94048. /**
  94049. * Clones the current emitter and returns a copy of it
  94050. * @returns the new emitter
  94051. */
  94052. clone(): CylinderDirectedParticleEmitter;
  94053. /**
  94054. * Called by the GPUParticleSystem to setup the update shader
  94055. * @param effect defines the update shader
  94056. */
  94057. applyToShader(effect: Effect): void;
  94058. /**
  94059. * Returns a string to use to update the GPU particles update shader
  94060. * @returns a string containng the defines string
  94061. */
  94062. getEffectDefines(): string;
  94063. /**
  94064. * Returns the string "CylinderDirectedParticleEmitter"
  94065. * @returns a string containing the class name
  94066. */
  94067. getClassName(): string;
  94068. /**
  94069. * Serializes the particle system to a JSON object.
  94070. * @returns the JSON object
  94071. */
  94072. serialize(): any;
  94073. /**
  94074. * Parse properties from a JSON object
  94075. * @param serializationObject defines the JSON object
  94076. */
  94077. parse(serializationObject: any): void;
  94078. }
  94079. }
  94080. declare module BABYLON {
  94081. /**
  94082. * Particle emitter emitting particles from the inside of a hemisphere.
  94083. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  94084. */
  94085. export class HemisphericParticleEmitter implements IParticleEmitterType {
  94086. /**
  94087. * The radius of the emission hemisphere.
  94088. */
  94089. radius: number;
  94090. /**
  94091. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94092. */
  94093. radiusRange: number;
  94094. /**
  94095. * How much to randomize the particle direction [0-1].
  94096. */
  94097. directionRandomizer: number;
  94098. /**
  94099. * Creates a new instance HemisphericParticleEmitter
  94100. * @param radius the radius of the emission hemisphere (1 by default)
  94101. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94102. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94103. */
  94104. constructor(
  94105. /**
  94106. * The radius of the emission hemisphere.
  94107. */
  94108. radius?: number,
  94109. /**
  94110. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94111. */
  94112. radiusRange?: number,
  94113. /**
  94114. * How much to randomize the particle direction [0-1].
  94115. */
  94116. directionRandomizer?: number);
  94117. /**
  94118. * Called by the particle System when the direction is computed for the created particle.
  94119. * @param worldMatrix is the world matrix of the particle system
  94120. * @param directionToUpdate is the direction vector to update with the result
  94121. * @param particle is the particle we are computed the direction for
  94122. * @param isLocal defines if the direction should be set in local space
  94123. */
  94124. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94125. /**
  94126. * Called by the particle System when the position is computed for the created particle.
  94127. * @param worldMatrix is the world matrix of the particle system
  94128. * @param positionToUpdate is the position vector to update with the result
  94129. * @param particle is the particle we are computed the position for
  94130. * @param isLocal defines if the position should be set in local space
  94131. */
  94132. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94133. /**
  94134. * Clones the current emitter and returns a copy of it
  94135. * @returns the new emitter
  94136. */
  94137. clone(): HemisphericParticleEmitter;
  94138. /**
  94139. * Called by the GPUParticleSystem to setup the update shader
  94140. * @param effect defines the update shader
  94141. */
  94142. applyToShader(effect: Effect): void;
  94143. /**
  94144. * Returns a string to use to update the GPU particles update shader
  94145. * @returns a string containng the defines string
  94146. */
  94147. getEffectDefines(): string;
  94148. /**
  94149. * Returns the string "HemisphericParticleEmitter"
  94150. * @returns a string containing the class name
  94151. */
  94152. getClassName(): string;
  94153. /**
  94154. * Serializes the particle system to a JSON object.
  94155. * @returns the JSON object
  94156. */
  94157. serialize(): any;
  94158. /**
  94159. * Parse properties from a JSON object
  94160. * @param serializationObject defines the JSON object
  94161. */
  94162. parse(serializationObject: any): void;
  94163. }
  94164. }
  94165. declare module BABYLON {
  94166. /**
  94167. * Particle emitter emitting particles from a point.
  94168. * It emits the particles randomly between 2 given directions.
  94169. */
  94170. export class PointParticleEmitter implements IParticleEmitterType {
  94171. /**
  94172. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94173. */
  94174. direction1: Vector3;
  94175. /**
  94176. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94177. */
  94178. direction2: Vector3;
  94179. /**
  94180. * Creates a new instance PointParticleEmitter
  94181. */
  94182. constructor();
  94183. /**
  94184. * Called by the particle System when the direction is computed for the created particle.
  94185. * @param worldMatrix is the world matrix of the particle system
  94186. * @param directionToUpdate is the direction vector to update with the result
  94187. * @param particle is the particle we are computed the direction for
  94188. * @param isLocal defines if the direction should be set in local space
  94189. */
  94190. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94191. /**
  94192. * Called by the particle System when the position is computed for the created particle.
  94193. * @param worldMatrix is the world matrix of the particle system
  94194. * @param positionToUpdate is the position vector to update with the result
  94195. * @param particle is the particle we are computed the position for
  94196. * @param isLocal defines if the position should be set in local space
  94197. */
  94198. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94199. /**
  94200. * Clones the current emitter and returns a copy of it
  94201. * @returns the new emitter
  94202. */
  94203. clone(): PointParticleEmitter;
  94204. /**
  94205. * Called by the GPUParticleSystem to setup the update shader
  94206. * @param effect defines the update shader
  94207. */
  94208. applyToShader(effect: Effect): void;
  94209. /**
  94210. * Returns a string to use to update the GPU particles update shader
  94211. * @returns a string containng the defines string
  94212. */
  94213. getEffectDefines(): string;
  94214. /**
  94215. * Returns the string "PointParticleEmitter"
  94216. * @returns a string containing the class name
  94217. */
  94218. getClassName(): string;
  94219. /**
  94220. * Serializes the particle system to a JSON object.
  94221. * @returns the JSON object
  94222. */
  94223. serialize(): any;
  94224. /**
  94225. * Parse properties from a JSON object
  94226. * @param serializationObject defines the JSON object
  94227. */
  94228. parse(serializationObject: any): void;
  94229. }
  94230. }
  94231. declare module BABYLON {
  94232. /**
  94233. * Particle emitter emitting particles from the inside of a sphere.
  94234. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  94235. */
  94236. export class SphereParticleEmitter implements IParticleEmitterType {
  94237. /**
  94238. * The radius of the emission sphere.
  94239. */
  94240. radius: number;
  94241. /**
  94242. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94243. */
  94244. radiusRange: number;
  94245. /**
  94246. * How much to randomize the particle direction [0-1].
  94247. */
  94248. directionRandomizer: number;
  94249. /**
  94250. * Creates a new instance SphereParticleEmitter
  94251. * @param radius the radius of the emission sphere (1 by default)
  94252. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  94253. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  94254. */
  94255. constructor(
  94256. /**
  94257. * The radius of the emission sphere.
  94258. */
  94259. radius?: number,
  94260. /**
  94261. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  94262. */
  94263. radiusRange?: number,
  94264. /**
  94265. * How much to randomize the particle direction [0-1].
  94266. */
  94267. directionRandomizer?: number);
  94268. /**
  94269. * Called by the particle System when the direction is computed for the created particle.
  94270. * @param worldMatrix is the world matrix of the particle system
  94271. * @param directionToUpdate is the direction vector to update with the result
  94272. * @param particle is the particle we are computed the direction for
  94273. * @param isLocal defines if the direction should be set in local space
  94274. */
  94275. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94276. /**
  94277. * Called by the particle System when the position is computed for the created particle.
  94278. * @param worldMatrix is the world matrix of the particle system
  94279. * @param positionToUpdate is the position vector to update with the result
  94280. * @param particle is the particle we are computed the position for
  94281. * @param isLocal defines if the position should be set in local space
  94282. */
  94283. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94284. /**
  94285. * Clones the current emitter and returns a copy of it
  94286. * @returns the new emitter
  94287. */
  94288. clone(): SphereParticleEmitter;
  94289. /**
  94290. * Called by the GPUParticleSystem to setup the update shader
  94291. * @param effect defines the update shader
  94292. */
  94293. applyToShader(effect: Effect): void;
  94294. /**
  94295. * Returns a string to use to update the GPU particles update shader
  94296. * @returns a string containng the defines string
  94297. */
  94298. getEffectDefines(): string;
  94299. /**
  94300. * Returns the string "SphereParticleEmitter"
  94301. * @returns a string containing the class name
  94302. */
  94303. getClassName(): string;
  94304. /**
  94305. * Serializes the particle system to a JSON object.
  94306. * @returns the JSON object
  94307. */
  94308. serialize(): any;
  94309. /**
  94310. * Parse properties from a JSON object
  94311. * @param serializationObject defines the JSON object
  94312. */
  94313. parse(serializationObject: any): void;
  94314. }
  94315. /**
  94316. * Particle emitter emitting particles from the inside of a sphere.
  94317. * It emits the particles randomly between two vectors.
  94318. */
  94319. export class SphereDirectedParticleEmitter extends SphereParticleEmitter {
  94320. /**
  94321. * The min limit of the emission direction.
  94322. */
  94323. direction1: Vector3;
  94324. /**
  94325. * The max limit of the emission direction.
  94326. */
  94327. direction2: Vector3;
  94328. /**
  94329. * Creates a new instance SphereDirectedParticleEmitter
  94330. * @param radius the radius of the emission sphere (1 by default)
  94331. * @param direction1 the min limit of the emission direction (up vector by default)
  94332. * @param direction2 the max limit of the emission direction (up vector by default)
  94333. */
  94334. constructor(radius?: number,
  94335. /**
  94336. * The min limit of the emission direction.
  94337. */
  94338. direction1?: Vector3,
  94339. /**
  94340. * The max limit of the emission direction.
  94341. */
  94342. direction2?: Vector3);
  94343. /**
  94344. * Called by the particle System when the direction is computed for the created particle.
  94345. * @param worldMatrix is the world matrix of the particle system
  94346. * @param directionToUpdate is the direction vector to update with the result
  94347. * @param particle is the particle we are computed the direction for
  94348. */
  94349. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle): void;
  94350. /**
  94351. * Clones the current emitter and returns a copy of it
  94352. * @returns the new emitter
  94353. */
  94354. clone(): SphereDirectedParticleEmitter;
  94355. /**
  94356. * Called by the GPUParticleSystem to setup the update shader
  94357. * @param effect defines the update shader
  94358. */
  94359. applyToShader(effect: Effect): void;
  94360. /**
  94361. * Returns a string to use to update the GPU particles update shader
  94362. * @returns a string containng the defines string
  94363. */
  94364. getEffectDefines(): string;
  94365. /**
  94366. * Returns the string "SphereDirectedParticleEmitter"
  94367. * @returns a string containing the class name
  94368. */
  94369. getClassName(): string;
  94370. /**
  94371. * Serializes the particle system to a JSON object.
  94372. * @returns the JSON object
  94373. */
  94374. serialize(): any;
  94375. /**
  94376. * Parse properties from a JSON object
  94377. * @param serializationObject defines the JSON object
  94378. */
  94379. parse(serializationObject: any): void;
  94380. }
  94381. }
  94382. declare module BABYLON {
  94383. /**
  94384. * Particle emitter emitting particles from a custom list of positions.
  94385. */
  94386. export class CustomParticleEmitter implements IParticleEmitterType {
  94387. /**
  94388. * Gets or sets the position generator that will create the inital position of each particle.
  94389. * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94390. */
  94391. particlePositionGenerator: (index: number, particle: Nullable<Particle>, outPosition: Vector3) => void;
  94392. /**
  94393. * Gets or sets the destination generator that will create the final destination of each particle.
  94394. * * Index will be provided when used with GPU particle. Particle will be provided when used with CPU particles
  94395. */
  94396. particleDestinationGenerator: (index: number, particle: Nullable<Particle>, outDestination: Vector3) => void;
  94397. /**
  94398. * Creates a new instance CustomParticleEmitter
  94399. */
  94400. constructor();
  94401. /**
  94402. * Called by the particle System when the direction is computed for the created particle.
  94403. * @param worldMatrix is the world matrix of the particle system
  94404. * @param directionToUpdate is the direction vector to update with the result
  94405. * @param particle is the particle we are computed the direction for
  94406. * @param isLocal defines if the direction should be set in local space
  94407. */
  94408. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94409. /**
  94410. * Called by the particle System when the position is computed for the created particle.
  94411. * @param worldMatrix is the world matrix of the particle system
  94412. * @param positionToUpdate is the position vector to update with the result
  94413. * @param particle is the particle we are computed the position for
  94414. * @param isLocal defines if the position should be set in local space
  94415. */
  94416. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94417. /**
  94418. * Clones the current emitter and returns a copy of it
  94419. * @returns the new emitter
  94420. */
  94421. clone(): CustomParticleEmitter;
  94422. /**
  94423. * Called by the GPUParticleSystem to setup the update shader
  94424. * @param effect defines the update shader
  94425. */
  94426. applyToShader(effect: Effect): void;
  94427. /**
  94428. * Returns a string to use to update the GPU particles update shader
  94429. * @returns a string containng the defines string
  94430. */
  94431. getEffectDefines(): string;
  94432. /**
  94433. * Returns the string "PointParticleEmitter"
  94434. * @returns a string containing the class name
  94435. */
  94436. getClassName(): string;
  94437. /**
  94438. * Serializes the particle system to a JSON object.
  94439. * @returns the JSON object
  94440. */
  94441. serialize(): any;
  94442. /**
  94443. * Parse properties from a JSON object
  94444. * @param serializationObject defines the JSON object
  94445. */
  94446. parse(serializationObject: any): void;
  94447. }
  94448. }
  94449. declare module BABYLON {
  94450. /**
  94451. * Particle emitter emitting particles from the inside of a box.
  94452. * It emits the particles randomly between 2 given directions.
  94453. */
  94454. export class MeshParticleEmitter implements IParticleEmitterType {
  94455. private _indices;
  94456. private _positions;
  94457. private _normals;
  94458. private _storedNormal;
  94459. private _mesh;
  94460. /**
  94461. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94462. */
  94463. direction1: Vector3;
  94464. /**
  94465. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  94466. */
  94467. direction2: Vector3;
  94468. /**
  94469. * Gets or sets a boolean indicating that particle directions must be built from mesh face normals
  94470. */
  94471. useMeshNormalsForDirection: boolean;
  94472. /** Defines the mesh to use as source */
  94473. get mesh(): Nullable<AbstractMesh>;
  94474. set mesh(value: Nullable<AbstractMesh>);
  94475. /**
  94476. * Creates a new instance MeshParticleEmitter
  94477. * @param mesh defines the mesh to use as source
  94478. */
  94479. constructor(mesh?: Nullable<AbstractMesh>);
  94480. /**
  94481. * Called by the particle System when the direction is computed for the created particle.
  94482. * @param worldMatrix is the world matrix of the particle system
  94483. * @param directionToUpdate is the direction vector to update with the result
  94484. * @param particle is the particle we are computed the direction for
  94485. * @param isLocal defines if the direction should be set in local space
  94486. */
  94487. startDirectionFunction(worldMatrix: Matrix, directionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94488. /**
  94489. * Called by the particle System when the position is computed for the created particle.
  94490. * @param worldMatrix is the world matrix of the particle system
  94491. * @param positionToUpdate is the position vector to update with the result
  94492. * @param particle is the particle we are computed the position for
  94493. * @param isLocal defines if the position should be set in local space
  94494. */
  94495. startPositionFunction(worldMatrix: Matrix, positionToUpdate: Vector3, particle: Particle, isLocal: boolean): void;
  94496. /**
  94497. * Clones the current emitter and returns a copy of it
  94498. * @returns the new emitter
  94499. */
  94500. clone(): MeshParticleEmitter;
  94501. /**
  94502. * Called by the GPUParticleSystem to setup the update shader
  94503. * @param effect defines the update shader
  94504. */
  94505. applyToShader(effect: Effect): void;
  94506. /**
  94507. * Returns a string to use to update the GPU particles update shader
  94508. * @returns a string containng the defines string
  94509. */
  94510. getEffectDefines(): string;
  94511. /**
  94512. * Returns the string "BoxParticleEmitter"
  94513. * @returns a string containing the class name
  94514. */
  94515. getClassName(): string;
  94516. /**
  94517. * Serializes the particle system to a JSON object.
  94518. * @returns the JSON object
  94519. */
  94520. serialize(): any;
  94521. /**
  94522. * Parse properties from a JSON object
  94523. * @param serializationObject defines the JSON object
  94524. * @param scene defines the hosting scene
  94525. */
  94526. parse(serializationObject: any, scene: Nullable<Scene>): void;
  94527. }
  94528. }
  94529. declare module BABYLON {
  94530. /**
  94531. * Interface representing a particle system in Babylon.js.
  94532. * This groups the common functionalities that needs to be implemented in order to create a particle system.
  94533. * A particle system represents a way to manage particles from their emission to their animation and rendering.
  94534. */
  94535. export interface IParticleSystem {
  94536. /**
  94537. * List of animations used by the particle system.
  94538. */
  94539. animations: Animation[];
  94540. /**
  94541. * The id of the Particle system.
  94542. */
  94543. id: string;
  94544. /**
  94545. * The name of the Particle system.
  94546. */
  94547. name: string;
  94548. /**
  94549. * The emitter represents the Mesh or position we are attaching the particle system to.
  94550. */
  94551. emitter: Nullable<AbstractMesh | Vector3>;
  94552. /**
  94553. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  94554. */
  94555. isBillboardBased: boolean;
  94556. /**
  94557. * The rendering group used by the Particle system to chose when to render.
  94558. */
  94559. renderingGroupId: number;
  94560. /**
  94561. * The layer mask we are rendering the particles through.
  94562. */
  94563. layerMask: number;
  94564. /**
  94565. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  94566. */
  94567. updateSpeed: number;
  94568. /**
  94569. * The amount of time the particle system is running (depends of the overall update speed).
  94570. */
  94571. targetStopDuration: number;
  94572. /**
  94573. * The texture used to render each particle. (this can be a spritesheet)
  94574. */
  94575. particleTexture: Nullable<BaseTexture>;
  94576. /**
  94577. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE, ParticleSystem.BLENDMODE_STANDARD or ParticleSystem.BLENDMODE_ADD.
  94578. */
  94579. blendMode: number;
  94580. /**
  94581. * Minimum life time of emitting particles.
  94582. */
  94583. minLifeTime: number;
  94584. /**
  94585. * Maximum life time of emitting particles.
  94586. */
  94587. maxLifeTime: number;
  94588. /**
  94589. * Minimum Size of emitting particles.
  94590. */
  94591. minSize: number;
  94592. /**
  94593. * Maximum Size of emitting particles.
  94594. */
  94595. maxSize: number;
  94596. /**
  94597. * Minimum scale of emitting particles on X axis.
  94598. */
  94599. minScaleX: number;
  94600. /**
  94601. * Maximum scale of emitting particles on X axis.
  94602. */
  94603. maxScaleX: number;
  94604. /**
  94605. * Minimum scale of emitting particles on Y axis.
  94606. */
  94607. minScaleY: number;
  94608. /**
  94609. * Maximum scale of emitting particles on Y axis.
  94610. */
  94611. maxScaleY: number;
  94612. /**
  94613. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94614. */
  94615. color1: Color4;
  94616. /**
  94617. * Random color of each particle after it has been emitted, between color1 and color2 vectors.
  94618. */
  94619. color2: Color4;
  94620. /**
  94621. * Color the particle will have at the end of its lifetime.
  94622. */
  94623. colorDead: Color4;
  94624. /**
  94625. * The maximum number of particles to emit per frame until we reach the activeParticleCount value
  94626. */
  94627. emitRate: number;
  94628. /**
  94629. * You can use gravity if you want to give an orientation to your particles.
  94630. */
  94631. gravity: Vector3;
  94632. /**
  94633. * Minimum power of emitting particles.
  94634. */
  94635. minEmitPower: number;
  94636. /**
  94637. * Maximum power of emitting particles.
  94638. */
  94639. maxEmitPower: number;
  94640. /**
  94641. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  94642. */
  94643. minAngularSpeed: number;
  94644. /**
  94645. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  94646. */
  94647. maxAngularSpeed: number;
  94648. /**
  94649. * Gets or sets the minimal initial rotation in radians.
  94650. */
  94651. minInitialRotation: number;
  94652. /**
  94653. * Gets or sets the maximal initial rotation in radians.
  94654. */
  94655. maxInitialRotation: number;
  94656. /**
  94657. * The particle emitter type defines the emitter used by the particle system.
  94658. * It can be for example box, sphere, or cone...
  94659. */
  94660. particleEmitterType: Nullable<IParticleEmitterType>;
  94661. /**
  94662. * Defines the delay in milliseconds before starting the system (0 by default)
  94663. */
  94664. startDelay: number;
  94665. /**
  94666. * 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
  94667. */
  94668. preWarmCycles: number;
  94669. /**
  94670. * Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1)
  94671. */
  94672. preWarmStepOffset: number;
  94673. /**
  94674. * 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)
  94675. */
  94676. spriteCellChangeSpeed: number;
  94677. /**
  94678. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  94679. */
  94680. startSpriteCellID: number;
  94681. /**
  94682. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  94683. */
  94684. endSpriteCellID: number;
  94685. /**
  94686. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  94687. */
  94688. spriteCellWidth: number;
  94689. /**
  94690. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  94691. */
  94692. spriteCellHeight: number;
  94693. /**
  94694. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  94695. */
  94696. spriteRandomStartCell: boolean;
  94697. /**
  94698. * Gets or sets a boolean indicating if a spritesheet is used to animate the particles texture
  94699. */
  94700. isAnimationSheetEnabled: boolean;
  94701. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  94702. translationPivot: Vector2;
  94703. /**
  94704. * Gets or sets a texture used to add random noise to particle positions
  94705. */
  94706. noiseTexture: Nullable<BaseTexture>;
  94707. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  94708. noiseStrength: Vector3;
  94709. /**
  94710. * Gets or sets the billboard mode to use when isBillboardBased = true.
  94711. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  94712. */
  94713. billboardMode: number;
  94714. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  94715. limitVelocityDamping: number;
  94716. /**
  94717. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  94718. */
  94719. beginAnimationOnStart: boolean;
  94720. /**
  94721. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  94722. */
  94723. beginAnimationFrom: number;
  94724. /**
  94725. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  94726. */
  94727. beginAnimationTo: number;
  94728. /**
  94729. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  94730. */
  94731. beginAnimationLoop: boolean;
  94732. /**
  94733. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  94734. */
  94735. disposeOnStop: boolean;
  94736. /**
  94737. * Specifies if the particles are updated in emitter local space or world space
  94738. */
  94739. isLocal: boolean;
  94740. /** Snippet ID if the particle system was created from the snippet server */
  94741. snippetId: string;
  94742. /** Gets or sets a matrix to use to compute projection */
  94743. defaultProjectionMatrix: Matrix;
  94744. /**
  94745. * Gets the maximum number of particles active at the same time.
  94746. * @returns The max number of active particles.
  94747. */
  94748. getCapacity(): number;
  94749. /**
  94750. * Gets the number of particles active at the same time.
  94751. * @returns The number of active particles.
  94752. */
  94753. getActiveCount(): number;
  94754. /**
  94755. * Gets if the system has been started. (Note: this will still be true after stop is called)
  94756. * @returns True if it has been started, otherwise false.
  94757. */
  94758. isStarted(): boolean;
  94759. /**
  94760. * Animates the particle system for this frame.
  94761. */
  94762. animate(): void;
  94763. /**
  94764. * Renders the particle system in its current state.
  94765. * @returns the current number of particles
  94766. */
  94767. render(): number;
  94768. /**
  94769. * Dispose the particle system and frees its associated resources.
  94770. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  94771. */
  94772. dispose(disposeTexture?: boolean): void;
  94773. /**
  94774. * An event triggered when the system is disposed
  94775. */
  94776. onDisposeObservable: Observable<IParticleSystem>;
  94777. /**
  94778. * Clones the particle system.
  94779. * @param name The name of the cloned object
  94780. * @param newEmitter The new emitter to use
  94781. * @returns the cloned particle system
  94782. */
  94783. clone(name: string, newEmitter: any): Nullable<IParticleSystem>;
  94784. /**
  94785. * Serializes the particle system to a JSON object
  94786. * @param serializeTexture defines if the texture must be serialized as well
  94787. * @returns the JSON object
  94788. */
  94789. serialize(serializeTexture: boolean): any;
  94790. /**
  94791. * Rebuild the particle system
  94792. */
  94793. rebuild(): void;
  94794. /** Force the system to rebuild all gradients that need to be resync */
  94795. forceRefreshGradients(): void;
  94796. /**
  94797. * Starts the particle system and begins to emit
  94798. * @param delay defines the delay in milliseconds before starting the system (0 by default)
  94799. */
  94800. start(delay?: number): void;
  94801. /**
  94802. * Stops the particle system.
  94803. */
  94804. stop(): void;
  94805. /**
  94806. * Remove all active particles
  94807. */
  94808. reset(): void;
  94809. /**
  94810. * Gets a boolean indicating that the system is stopping
  94811. * @returns true if the system is currently stopping
  94812. */
  94813. isStopping(): boolean;
  94814. /**
  94815. * Is this system ready to be used/rendered
  94816. * @return true if the system is ready
  94817. */
  94818. isReady(): boolean;
  94819. /**
  94820. * Returns the string "ParticleSystem"
  94821. * @returns a string containing the class name
  94822. */
  94823. getClassName(): string;
  94824. /**
  94825. * Gets the custom effect used to render the particles
  94826. * @param blendMode Blend mode for which the effect should be retrieved
  94827. * @returns The effect
  94828. */
  94829. getCustomEffect(blendMode: number): Nullable<Effect>;
  94830. /**
  94831. * Sets the custom effect used to render the particles
  94832. * @param effect The effect to set
  94833. * @param blendMode Blend mode for which the effect should be set
  94834. */
  94835. setCustomEffect(effect: Nullable<Effect>, blendMode: number): void;
  94836. /**
  94837. * Fill the defines array according to the current settings of the particle system
  94838. * @param defines Array to be updated
  94839. * @param blendMode blend mode to take into account when updating the array
  94840. */
  94841. fillDefines(defines: Array<string>, blendMode: number): void;
  94842. /**
  94843. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  94844. * @param uniforms Uniforms array to fill
  94845. * @param attributes Attributes array to fill
  94846. * @param samplers Samplers array to fill
  94847. */
  94848. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  94849. /**
  94850. * Observable that will be called just before the particles are drawn
  94851. */
  94852. onBeforeDrawParticlesObservable: Observable<Nullable<Effect>>;
  94853. /**
  94854. * Gets the name of the particle vertex shader
  94855. */
  94856. vertexShaderName: string;
  94857. /**
  94858. * Adds a new color gradient
  94859. * @param gradient defines the gradient to use (between 0 and 1)
  94860. * @param color1 defines the color to affect to the specified gradient
  94861. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  94862. * @returns the current particle system
  94863. */
  94864. addColorGradient(gradient: number, color1: Color4, color2?: Color4): IParticleSystem;
  94865. /**
  94866. * Remove a specific color gradient
  94867. * @param gradient defines the gradient to remove
  94868. * @returns the current particle system
  94869. */
  94870. removeColorGradient(gradient: number): IParticleSystem;
  94871. /**
  94872. * Adds a new size gradient
  94873. * @param gradient defines the gradient to use (between 0 and 1)
  94874. * @param factor defines the size factor to affect to the specified gradient
  94875. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94876. * @returns the current particle system
  94877. */
  94878. addSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94879. /**
  94880. * Remove a specific size gradient
  94881. * @param gradient defines the gradient to remove
  94882. * @returns the current particle system
  94883. */
  94884. removeSizeGradient(gradient: number): IParticleSystem;
  94885. /**
  94886. * Gets the current list of color gradients.
  94887. * You must use addColorGradient and removeColorGradient to udpate this list
  94888. * @returns the list of color gradients
  94889. */
  94890. getColorGradients(): Nullable<Array<ColorGradient>>;
  94891. /**
  94892. * Gets the current list of size gradients.
  94893. * You must use addSizeGradient and removeSizeGradient to udpate this list
  94894. * @returns the list of size gradients
  94895. */
  94896. getSizeGradients(): Nullable<Array<FactorGradient>>;
  94897. /**
  94898. * Gets the current list of angular speed gradients.
  94899. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  94900. * @returns the list of angular speed gradients
  94901. */
  94902. getAngularSpeedGradients(): Nullable<Array<FactorGradient>>;
  94903. /**
  94904. * Adds a new angular speed gradient
  94905. * @param gradient defines the gradient to use (between 0 and 1)
  94906. * @param factor defines the angular speed to affect to the specified gradient
  94907. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94908. * @returns the current particle system
  94909. */
  94910. addAngularSpeedGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94911. /**
  94912. * Remove a specific angular speed gradient
  94913. * @param gradient defines the gradient to remove
  94914. * @returns the current particle system
  94915. */
  94916. removeAngularSpeedGradient(gradient: number): IParticleSystem;
  94917. /**
  94918. * Gets the current list of velocity gradients.
  94919. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  94920. * @returns the list of velocity gradients
  94921. */
  94922. getVelocityGradients(): Nullable<Array<FactorGradient>>;
  94923. /**
  94924. * Adds a new velocity gradient
  94925. * @param gradient defines the gradient to use (between 0 and 1)
  94926. * @param factor defines the velocity to affect to the specified gradient
  94927. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94928. * @returns the current particle system
  94929. */
  94930. addVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94931. /**
  94932. * Remove a specific velocity gradient
  94933. * @param gradient defines the gradient to remove
  94934. * @returns the current particle system
  94935. */
  94936. removeVelocityGradient(gradient: number): IParticleSystem;
  94937. /**
  94938. * Gets the current list of limit velocity gradients.
  94939. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  94940. * @returns the list of limit velocity gradients
  94941. */
  94942. getLimitVelocityGradients(): Nullable<Array<FactorGradient>>;
  94943. /**
  94944. * Adds a new limit velocity gradient
  94945. * @param gradient defines the gradient to use (between 0 and 1)
  94946. * @param factor defines the limit velocity to affect to the specified gradient
  94947. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94948. * @returns the current particle system
  94949. */
  94950. addLimitVelocityGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94951. /**
  94952. * Remove a specific limit velocity gradient
  94953. * @param gradient defines the gradient to remove
  94954. * @returns the current particle system
  94955. */
  94956. removeLimitVelocityGradient(gradient: number): IParticleSystem;
  94957. /**
  94958. * Adds a new drag gradient
  94959. * @param gradient defines the gradient to use (between 0 and 1)
  94960. * @param factor defines the drag to affect to the specified gradient
  94961. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94962. * @returns the current particle system
  94963. */
  94964. addDragGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94965. /**
  94966. * Remove a specific drag gradient
  94967. * @param gradient defines the gradient to remove
  94968. * @returns the current particle system
  94969. */
  94970. removeDragGradient(gradient: number): IParticleSystem;
  94971. /**
  94972. * Gets the current list of drag gradients.
  94973. * You must use addDragGradient and removeDragGradient to udpate this list
  94974. * @returns the list of drag gradients
  94975. */
  94976. getDragGradients(): Nullable<Array<FactorGradient>>;
  94977. /**
  94978. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  94979. * @param gradient defines the gradient to use (between 0 and 1)
  94980. * @param factor defines the emit rate to affect to the specified gradient
  94981. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  94982. * @returns the current particle system
  94983. */
  94984. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  94985. /**
  94986. * Remove a specific emit rate gradient
  94987. * @param gradient defines the gradient to remove
  94988. * @returns the current particle system
  94989. */
  94990. removeEmitRateGradient(gradient: number): IParticleSystem;
  94991. /**
  94992. * Gets the current list of emit rate gradients.
  94993. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  94994. * @returns the list of emit rate gradients
  94995. */
  94996. getEmitRateGradients(): Nullable<Array<FactorGradient>>;
  94997. /**
  94998. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  94999. * @param gradient defines the gradient to use (between 0 and 1)
  95000. * @param factor defines the start size to affect to the specified gradient
  95001. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95002. * @returns the current particle system
  95003. */
  95004. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95005. /**
  95006. * Remove a specific start size gradient
  95007. * @param gradient defines the gradient to remove
  95008. * @returns the current particle system
  95009. */
  95010. removeStartSizeGradient(gradient: number): IParticleSystem;
  95011. /**
  95012. * Gets the current list of start size gradients.
  95013. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  95014. * @returns the list of start size gradients
  95015. */
  95016. getStartSizeGradients(): Nullable<Array<FactorGradient>>;
  95017. /**
  95018. * Adds a new life time gradient
  95019. * @param gradient defines the gradient to use (between 0 and 1)
  95020. * @param factor defines the life time factor to affect to the specified gradient
  95021. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  95022. * @returns the current particle system
  95023. */
  95024. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  95025. /**
  95026. * Remove a specific life time gradient
  95027. * @param gradient defines the gradient to remove
  95028. * @returns the current particle system
  95029. */
  95030. removeLifeTimeGradient(gradient: number): IParticleSystem;
  95031. /**
  95032. * Gets the current list of life time gradients.
  95033. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  95034. * @returns the list of life time gradients
  95035. */
  95036. getLifeTimeGradients(): Nullable<Array<FactorGradient>>;
  95037. /**
  95038. * Gets the current list of color gradients.
  95039. * You must use addColorGradient and removeColorGradient to udpate this list
  95040. * @returns the list of color gradients
  95041. */
  95042. getColorGradients(): Nullable<Array<ColorGradient>>;
  95043. /**
  95044. * Adds a new ramp gradient used to remap particle colors
  95045. * @param gradient defines the gradient to use (between 0 and 1)
  95046. * @param color defines the color to affect to the specified gradient
  95047. * @returns the current particle system
  95048. */
  95049. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  95050. /**
  95051. * Gets the current list of ramp gradients.
  95052. * You must use addRampGradient and removeRampGradient to udpate this list
  95053. * @returns the list of ramp gradients
  95054. */
  95055. getRampGradients(): Nullable<Array<Color3Gradient>>;
  95056. /** Gets or sets a boolean indicating that ramp gradients must be used
  95057. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  95058. */
  95059. useRampGradients: boolean;
  95060. /**
  95061. * Adds a new color remap gradient
  95062. * @param gradient defines the gradient to use (between 0 and 1)
  95063. * @param min defines the color remap minimal range
  95064. * @param max defines the color remap maximal range
  95065. * @returns the current particle system
  95066. */
  95067. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95068. /**
  95069. * Gets the current list of color remap gradients.
  95070. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  95071. * @returns the list of color remap gradients
  95072. */
  95073. getColorRemapGradients(): Nullable<Array<FactorGradient>>;
  95074. /**
  95075. * Adds a new alpha remap gradient
  95076. * @param gradient defines the gradient to use (between 0 and 1)
  95077. * @param min defines the alpha remap minimal range
  95078. * @param max defines the alpha remap maximal range
  95079. * @returns the current particle system
  95080. */
  95081. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  95082. /**
  95083. * Gets the current list of alpha remap gradients.
  95084. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  95085. * @returns the list of alpha remap gradients
  95086. */
  95087. getAlphaRemapGradients(): Nullable<Array<FactorGradient>>;
  95088. /**
  95089. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  95090. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95091. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95092. * @returns the emitter
  95093. */
  95094. createPointEmitter(direction1: Vector3, direction2: Vector3): PointParticleEmitter;
  95095. /**
  95096. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  95097. * @param radius The radius of the hemisphere to emit from
  95098. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95099. * @returns the emitter
  95100. */
  95101. createHemisphericEmitter(radius: number, radiusRange: number): HemisphericParticleEmitter;
  95102. /**
  95103. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  95104. * @param radius The radius of the sphere to emit from
  95105. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  95106. * @returns the emitter
  95107. */
  95108. createSphereEmitter(radius: number, radiusRange: number): SphereParticleEmitter;
  95109. /**
  95110. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  95111. * @param radius The radius of the sphere to emit from
  95112. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  95113. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  95114. * @returns the emitter
  95115. */
  95116. createDirectedSphereEmitter(radius: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95117. /**
  95118. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  95119. * @param radius The radius of the emission cylinder
  95120. * @param height The height of the emission cylinder
  95121. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  95122. * @param directionRandomizer How much to randomize the particle direction [0-1]
  95123. * @returns the emitter
  95124. */
  95125. createCylinderEmitter(radius: number, height: number, radiusRange: number, directionRandomizer: number): CylinderParticleEmitter;
  95126. /**
  95127. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  95128. * @param radius The radius of the cylinder to emit from
  95129. * @param height The height of the emission cylinder
  95130. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  95131. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  95132. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  95133. * @returns the emitter
  95134. */
  95135. createDirectedCylinderEmitter(radius: number, height: number, radiusRange: number, direction1: Vector3, direction2: Vector3): SphereDirectedParticleEmitter;
  95136. /**
  95137. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  95138. * @param radius The radius of the cone to emit from
  95139. * @param angle The base angle of the cone
  95140. * @returns the emitter
  95141. */
  95142. createConeEmitter(radius: number, angle: number): ConeParticleEmitter;
  95143. /**
  95144. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  95145. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  95146. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  95147. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95148. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  95149. * @returns the emitter
  95150. */
  95151. createBoxEmitter(direction1: Vector3, direction2: Vector3, minEmitBox: Vector3, maxEmitBox: Vector3): BoxParticleEmitter;
  95152. /**
  95153. * Get hosting scene
  95154. * @returns the scene
  95155. */
  95156. getScene(): Nullable<Scene>;
  95157. }
  95158. }
  95159. declare module BABYLON {
  95160. /**
  95161. * 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.
  95162. * @see https://doc.babylonjs.com/how_to/transformnode
  95163. */
  95164. export class TransformNode extends Node {
  95165. /**
  95166. * Object will not rotate to face the camera
  95167. */
  95168. static BILLBOARDMODE_NONE: number;
  95169. /**
  95170. * Object will rotate to face the camera but only on the x axis
  95171. */
  95172. static BILLBOARDMODE_X: number;
  95173. /**
  95174. * Object will rotate to face the camera but only on the y axis
  95175. */
  95176. static BILLBOARDMODE_Y: number;
  95177. /**
  95178. * Object will rotate to face the camera but only on the z axis
  95179. */
  95180. static BILLBOARDMODE_Z: number;
  95181. /**
  95182. * Object will rotate to face the camera
  95183. */
  95184. static BILLBOARDMODE_ALL: number;
  95185. /**
  95186. * Object will rotate to face the camera's position instead of orientation
  95187. */
  95188. static BILLBOARDMODE_USE_POSITION: number;
  95189. private static _TmpRotation;
  95190. private static _TmpScaling;
  95191. private static _TmpTranslation;
  95192. private _forward;
  95193. private _forwardInverted;
  95194. private _up;
  95195. private _right;
  95196. private _rightInverted;
  95197. private _position;
  95198. private _rotation;
  95199. private _rotationQuaternion;
  95200. protected _scaling: Vector3;
  95201. protected _isDirty: boolean;
  95202. private _transformToBoneReferal;
  95203. private _isAbsoluteSynced;
  95204. private _billboardMode;
  95205. /**
  95206. * Gets or sets the billboard mode. Default is 0.
  95207. *
  95208. * | Value | Type | Description |
  95209. * | --- | --- | --- |
  95210. * | 0 | BILLBOARDMODE_NONE | |
  95211. * | 1 | BILLBOARDMODE_X | |
  95212. * | 2 | BILLBOARDMODE_Y | |
  95213. * | 4 | BILLBOARDMODE_Z | |
  95214. * | 7 | BILLBOARDMODE_ALL | |
  95215. *
  95216. */
  95217. get billboardMode(): number;
  95218. set billboardMode(value: number);
  95219. private _preserveParentRotationForBillboard;
  95220. /**
  95221. * Gets or sets a boolean indicating that parent rotation should be preserved when using billboards.
  95222. * This could be useful for glTF objects where parent rotation helps converting from right handed to left handed
  95223. */
  95224. get preserveParentRotationForBillboard(): boolean;
  95225. set preserveParentRotationForBillboard(value: boolean);
  95226. /**
  95227. * 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
  95228. */
  95229. scalingDeterminant: number;
  95230. private _infiniteDistance;
  95231. /**
  95232. * Gets or sets the distance of the object to max, often used by skybox
  95233. */
  95234. get infiniteDistance(): boolean;
  95235. set infiniteDistance(value: boolean);
  95236. /**
  95237. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  95238. * By default the system will update normals to compensate
  95239. */
  95240. ignoreNonUniformScaling: boolean;
  95241. /**
  95242. * 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
  95243. */
  95244. reIntegrateRotationIntoRotationQuaternion: boolean;
  95245. /** @hidden */
  95246. _poseMatrix: Nullable<Matrix>;
  95247. /** @hidden */
  95248. _localMatrix: Matrix;
  95249. private _usePivotMatrix;
  95250. private _absolutePosition;
  95251. private _absoluteScaling;
  95252. private _absoluteRotationQuaternion;
  95253. private _pivotMatrix;
  95254. private _pivotMatrixInverse;
  95255. /** @hidden */
  95256. _postMultiplyPivotMatrix: boolean;
  95257. protected _isWorldMatrixFrozen: boolean;
  95258. /** @hidden */
  95259. _indexInSceneTransformNodesArray: number;
  95260. /**
  95261. * An event triggered after the world matrix is updated
  95262. */
  95263. onAfterWorldMatrixUpdateObservable: Observable<TransformNode>;
  95264. constructor(name: string, scene?: Nullable<Scene>, isPure?: boolean);
  95265. /**
  95266. * Gets a string identifying the name of the class
  95267. * @returns "TransformNode" string
  95268. */
  95269. getClassName(): string;
  95270. /**
  95271. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  95272. */
  95273. get position(): Vector3;
  95274. set position(newPosition: Vector3);
  95275. /**
  95276. * 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)).
  95277. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  95278. */
  95279. get rotation(): Vector3;
  95280. set rotation(newRotation: Vector3);
  95281. /**
  95282. * 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)).
  95283. */
  95284. get scaling(): Vector3;
  95285. set scaling(newScaling: Vector3);
  95286. /**
  95287. * 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).
  95288. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  95289. */
  95290. get rotationQuaternion(): Nullable<Quaternion>;
  95291. set rotationQuaternion(quaternion: Nullable<Quaternion>);
  95292. /**
  95293. * The forward direction of that transform in world space.
  95294. */
  95295. get forward(): Vector3;
  95296. /**
  95297. * The up direction of that transform in world space.
  95298. */
  95299. get up(): Vector3;
  95300. /**
  95301. * The right direction of that transform in world space.
  95302. */
  95303. get right(): Vector3;
  95304. /**
  95305. * Copies the parameter passed Matrix into the mesh Pose matrix.
  95306. * @param matrix the matrix to copy the pose from
  95307. * @returns this TransformNode.
  95308. */
  95309. updatePoseMatrix(matrix: Matrix): TransformNode;
  95310. /**
  95311. * Returns the mesh Pose matrix.
  95312. * @returns the pose matrix
  95313. */
  95314. getPoseMatrix(): Matrix;
  95315. /** @hidden */
  95316. _isSynchronized(): boolean;
  95317. /** @hidden */
  95318. _initCache(): void;
  95319. /**
  95320. * Flag the transform node as dirty (Forcing it to update everything)
  95321. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  95322. * @returns this transform node
  95323. */
  95324. markAsDirty(property: string): TransformNode;
  95325. /**
  95326. * Returns the current mesh absolute position.
  95327. * Returns a Vector3.
  95328. */
  95329. get absolutePosition(): Vector3;
  95330. /**
  95331. * Returns the current mesh absolute scaling.
  95332. * Returns a Vector3.
  95333. */
  95334. get absoluteScaling(): Vector3;
  95335. /**
  95336. * Returns the current mesh absolute rotation.
  95337. * Returns a Quaternion.
  95338. */
  95339. get absoluteRotationQuaternion(): Quaternion;
  95340. /**
  95341. * Sets a new matrix to apply before all other transformation
  95342. * @param matrix defines the transform matrix
  95343. * @returns the current TransformNode
  95344. */
  95345. setPreTransformMatrix(matrix: Matrix): TransformNode;
  95346. /**
  95347. * Sets a new pivot matrix to the current node
  95348. * @param matrix defines the new pivot matrix to use
  95349. * @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
  95350. * @returns the current TransformNode
  95351. */
  95352. setPivotMatrix(matrix: DeepImmutable<Matrix>, postMultiplyPivotMatrix?: boolean): TransformNode;
  95353. /**
  95354. * Returns the mesh pivot matrix.
  95355. * Default : Identity.
  95356. * @returns the matrix
  95357. */
  95358. getPivotMatrix(): Matrix;
  95359. /**
  95360. * Instantiate (when possible) or clone that node with its hierarchy
  95361. * @param newParent defines the new parent to use for the instance (or clone)
  95362. * @param options defines options to configure how copy is done
  95363. * @param onNewNodeCreated defines an option callback to call when a clone or an instance is created
  95364. * @returns an instance (or a clone) of the current node with its hiearchy
  95365. */
  95366. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  95367. doNotInstantiate: boolean;
  95368. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  95369. /**
  95370. * Prevents the World matrix to be computed any longer
  95371. * @param newWorldMatrix defines an optional matrix to use as world matrix
  95372. * @returns the TransformNode.
  95373. */
  95374. freezeWorldMatrix(newWorldMatrix?: Nullable<Matrix>): TransformNode;
  95375. /**
  95376. * Allows back the World matrix computation.
  95377. * @returns the TransformNode.
  95378. */
  95379. unfreezeWorldMatrix(): this;
  95380. /**
  95381. * True if the World matrix has been frozen.
  95382. */
  95383. get isWorldMatrixFrozen(): boolean;
  95384. /**
  95385. * Retuns the mesh absolute position in the World.
  95386. * @returns a Vector3.
  95387. */
  95388. getAbsolutePosition(): Vector3;
  95389. /**
  95390. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  95391. * @param absolutePosition the absolute position to set
  95392. * @returns the TransformNode.
  95393. */
  95394. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  95395. /**
  95396. * Sets the mesh position in its local space.
  95397. * @param vector3 the position to set in localspace
  95398. * @returns the TransformNode.
  95399. */
  95400. setPositionWithLocalVector(vector3: Vector3): TransformNode;
  95401. /**
  95402. * Returns the mesh position in the local space from the current World matrix values.
  95403. * @returns a new Vector3.
  95404. */
  95405. getPositionExpressedInLocalSpace(): Vector3;
  95406. /**
  95407. * Translates the mesh along the passed Vector3 in its local space.
  95408. * @param vector3 the distance to translate in localspace
  95409. * @returns the TransformNode.
  95410. */
  95411. locallyTranslate(vector3: Vector3): TransformNode;
  95412. private static _lookAtVectorCache;
  95413. /**
  95414. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  95415. * @param targetPoint the position (must be in same space as current mesh) to look at
  95416. * @param yawCor optional yaw (y-axis) correction in radians
  95417. * @param pitchCor optional pitch (x-axis) correction in radians
  95418. * @param rollCor optional roll (z-axis) correction in radians
  95419. * @param space the choosen space of the target
  95420. * @returns the TransformNode.
  95421. */
  95422. lookAt(targetPoint: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number, space?: Space): TransformNode;
  95423. /**
  95424. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95425. * This Vector3 is expressed in the World space.
  95426. * @param localAxis axis to rotate
  95427. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  95428. */
  95429. getDirection(localAxis: Vector3): Vector3;
  95430. /**
  95431. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  95432. * localAxis is expressed in the mesh local space.
  95433. * result is computed in the Wordl space from the mesh World matrix.
  95434. * @param localAxis axis to rotate
  95435. * @param result the resulting transformnode
  95436. * @returns this TransformNode.
  95437. */
  95438. getDirectionToRef(localAxis: Vector3, result: Vector3): TransformNode;
  95439. /**
  95440. * Sets this transform node rotation to the given local axis.
  95441. * @param localAxis the axis in local space
  95442. * @param yawCor optional yaw (y-axis) correction in radians
  95443. * @param pitchCor optional pitch (x-axis) correction in radians
  95444. * @param rollCor optional roll (z-axis) correction in radians
  95445. * @returns this TransformNode
  95446. */
  95447. setDirection(localAxis: Vector3, yawCor?: number, pitchCor?: number, rollCor?: number): TransformNode;
  95448. /**
  95449. * Sets a new pivot point to the current node
  95450. * @param point defines the new pivot point to use
  95451. * @param space defines if the point is in world or local space (local by default)
  95452. * @returns the current TransformNode
  95453. */
  95454. setPivotPoint(point: Vector3, space?: Space): TransformNode;
  95455. /**
  95456. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  95457. * @returns the pivot point
  95458. */
  95459. getPivotPoint(): Vector3;
  95460. /**
  95461. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  95462. * @param result the vector3 to store the result
  95463. * @returns this TransformNode.
  95464. */
  95465. getPivotPointToRef(result: Vector3): TransformNode;
  95466. /**
  95467. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  95468. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  95469. */
  95470. getAbsolutePivotPoint(): Vector3;
  95471. /**
  95472. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  95473. * @param result vector3 to store the result
  95474. * @returns this TransformNode.
  95475. */
  95476. getAbsolutePivotPointToRef(result: Vector3): TransformNode;
  95477. /**
  95478. * Defines the passed node as the parent of the current node.
  95479. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  95480. * @see https://doc.babylonjs.com/how_to/parenting
  95481. * @param node the node ot set as the parent
  95482. * @returns this TransformNode.
  95483. */
  95484. setParent(node: Nullable<Node>): TransformNode;
  95485. private _nonUniformScaling;
  95486. /**
  95487. * True if the scaling property of this object is non uniform eg. (1,2,1)
  95488. */
  95489. get nonUniformScaling(): boolean;
  95490. /** @hidden */
  95491. _updateNonUniformScalingState(value: boolean): boolean;
  95492. /**
  95493. * Attach the current TransformNode to another TransformNode associated with a bone
  95494. * @param bone Bone affecting the TransformNode
  95495. * @param affectedTransformNode TransformNode associated with the bone
  95496. * @returns this object
  95497. */
  95498. attachToBone(bone: Bone, affectedTransformNode: TransformNode): TransformNode;
  95499. /**
  95500. * Detach the transform node if its associated with a bone
  95501. * @returns this object
  95502. */
  95503. detachFromBone(): TransformNode;
  95504. private static _rotationAxisCache;
  95505. /**
  95506. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  95507. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95508. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95509. * The passed axis is also normalized.
  95510. * @param axis the axis to rotate around
  95511. * @param amount the amount to rotate in radians
  95512. * @param space Space to rotate in (Default: local)
  95513. * @returns the TransformNode.
  95514. */
  95515. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  95516. /**
  95517. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  95518. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  95519. * The passed axis is also normalized. .
  95520. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  95521. * @param point the point to rotate around
  95522. * @param axis the axis to rotate around
  95523. * @param amount the amount to rotate in radians
  95524. * @returns the TransformNode
  95525. */
  95526. rotateAround(point: Vector3, axis: Vector3, amount: number): TransformNode;
  95527. /**
  95528. * Translates the mesh along the axis vector for the passed distance in the given space.
  95529. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  95530. * @param axis the axis to translate in
  95531. * @param distance the distance to translate
  95532. * @param space Space to rotate in (Default: local)
  95533. * @returns the TransformNode.
  95534. */
  95535. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  95536. /**
  95537. * Adds a rotation step to the mesh current rotation.
  95538. * x, y, z are Euler angles expressed in radians.
  95539. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  95540. * This means this rotation is made in the mesh local space only.
  95541. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  95542. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  95543. * ```javascript
  95544. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  95545. * ```
  95546. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  95547. * 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.
  95548. * @param x Rotation to add
  95549. * @param y Rotation to add
  95550. * @param z Rotation to add
  95551. * @returns the TransformNode.
  95552. */
  95553. addRotation(x: number, y: number, z: number): TransformNode;
  95554. /**
  95555. * @hidden
  95556. */
  95557. protected _getEffectiveParent(): Nullable<Node>;
  95558. /**
  95559. * Computes the world matrix of the node
  95560. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  95561. * @returns the world matrix
  95562. */
  95563. computeWorldMatrix(force?: boolean): Matrix;
  95564. /**
  95565. * Resets this nodeTransform's local matrix to Matrix.Identity().
  95566. * @param independentOfChildren indicates if all child nodeTransform's world-space transform should be preserved.
  95567. */
  95568. resetLocalMatrix(independentOfChildren?: boolean): void;
  95569. protected _afterComputeWorldMatrix(): void;
  95570. /**
  95571. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  95572. * @param func callback function to add
  95573. *
  95574. * @returns the TransformNode.
  95575. */
  95576. registerAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95577. /**
  95578. * Removes a registered callback function.
  95579. * @param func callback function to remove
  95580. * @returns the TransformNode.
  95581. */
  95582. unregisterAfterWorldMatrixUpdate(func: (mesh: TransformNode) => void): TransformNode;
  95583. /**
  95584. * Gets the position of the current mesh in camera space
  95585. * @param camera defines the camera to use
  95586. * @returns a position
  95587. */
  95588. getPositionInCameraSpace(camera?: Nullable<Camera>): Vector3;
  95589. /**
  95590. * Returns the distance from the mesh to the active camera
  95591. * @param camera defines the camera to use
  95592. * @returns the distance
  95593. */
  95594. getDistanceToCamera(camera?: Nullable<Camera>): number;
  95595. /**
  95596. * Clone the current transform node
  95597. * @param name Name of the new clone
  95598. * @param newParent New parent for the clone
  95599. * @param doNotCloneChildren Do not clone children hierarchy
  95600. * @returns the new transform node
  95601. */
  95602. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<TransformNode>;
  95603. /**
  95604. * Serializes the objects information.
  95605. * @param currentSerializationObject defines the object to serialize in
  95606. * @returns the serialized object
  95607. */
  95608. serialize(currentSerializationObject?: any): any;
  95609. /**
  95610. * Returns a new TransformNode object parsed from the source provided.
  95611. * @param parsedTransformNode is the source.
  95612. * @param scene the scne the object belongs to
  95613. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  95614. * @returns a new TransformNode object parsed from the source provided.
  95615. */
  95616. static Parse(parsedTransformNode: any, scene: Scene, rootUrl: string): TransformNode;
  95617. /**
  95618. * Get all child-transformNodes of this node
  95619. * @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
  95620. * @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
  95621. * @returns an array of TransformNode
  95622. */
  95623. getChildTransformNodes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): TransformNode[];
  95624. /**
  95625. * Releases resources associated with this transform node.
  95626. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  95627. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  95628. */
  95629. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  95630. /**
  95631. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  95632. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  95633. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  95634. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  95635. * @returns the current mesh
  95636. */
  95637. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): TransformNode;
  95638. private _syncAbsoluteScalingAndRotation;
  95639. }
  95640. }
  95641. declare module BABYLON {
  95642. /**
  95643. * Class used to override all child animations of a given target
  95644. */
  95645. export class AnimationPropertiesOverride {
  95646. /**
  95647. * Gets or sets a value indicating if animation blending must be used
  95648. */
  95649. enableBlending: boolean;
  95650. /**
  95651. * Gets or sets the blending speed to use when enableBlending is true
  95652. */
  95653. blendingSpeed: number;
  95654. /**
  95655. * Gets or sets the default loop mode to use
  95656. */
  95657. loopMode: number;
  95658. }
  95659. }
  95660. declare module BABYLON {
  95661. /**
  95662. * Class used to store bone information
  95663. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  95664. */
  95665. export class Bone extends Node {
  95666. /**
  95667. * defines the bone name
  95668. */
  95669. name: string;
  95670. private static _tmpVecs;
  95671. private static _tmpQuat;
  95672. private static _tmpMats;
  95673. /**
  95674. * Gets the list of child bones
  95675. */
  95676. children: Bone[];
  95677. /** Gets the animations associated with this bone */
  95678. animations: Animation[];
  95679. /**
  95680. * Gets or sets bone length
  95681. */
  95682. length: number;
  95683. /**
  95684. * @hidden Internal only
  95685. * Set this value to map this bone to a different index in the transform matrices
  95686. * Set this value to -1 to exclude the bone from the transform matrices
  95687. */
  95688. _index: Nullable<number>;
  95689. private _skeleton;
  95690. private _localMatrix;
  95691. private _restPose;
  95692. private _bindPose;
  95693. private _baseMatrix;
  95694. private _absoluteTransform;
  95695. private _invertedAbsoluteTransform;
  95696. private _parent;
  95697. private _scalingDeterminant;
  95698. private _worldTransform;
  95699. private _localScaling;
  95700. private _localRotation;
  95701. private _localPosition;
  95702. private _needToDecompose;
  95703. private _needToCompose;
  95704. /** @hidden */
  95705. _linkedTransformNode: Nullable<TransformNode>;
  95706. /** @hidden */
  95707. _waitingTransformNodeId: Nullable<string>;
  95708. /** @hidden */
  95709. get _matrix(): Matrix;
  95710. /** @hidden */
  95711. set _matrix(value: Matrix);
  95712. /**
  95713. * Create a new bone
  95714. * @param name defines the bone name
  95715. * @param skeleton defines the parent skeleton
  95716. * @param parentBone defines the parent (can be null if the bone is the root)
  95717. * @param localMatrix defines the local matrix
  95718. * @param restPose defines the rest pose matrix
  95719. * @param baseMatrix defines the base matrix
  95720. * @param index defines index of the bone in the hiearchy
  95721. */
  95722. constructor(
  95723. /**
  95724. * defines the bone name
  95725. */
  95726. name: string, skeleton: Skeleton, parentBone?: Nullable<Bone>, localMatrix?: Nullable<Matrix>, restPose?: Nullable<Matrix>, baseMatrix?: Nullable<Matrix>, index?: Nullable<number>);
  95727. /**
  95728. * Gets the current object class name.
  95729. * @return the class name
  95730. */
  95731. getClassName(): string;
  95732. /**
  95733. * Gets the parent skeleton
  95734. * @returns a skeleton
  95735. */
  95736. getSkeleton(): Skeleton;
  95737. /**
  95738. * Gets parent bone
  95739. * @returns a bone or null if the bone is the root of the bone hierarchy
  95740. */
  95741. getParent(): Nullable<Bone>;
  95742. /**
  95743. * Returns an array containing the root bones
  95744. * @returns an array containing the root bones
  95745. */
  95746. getChildren(): Array<Bone>;
  95747. /**
  95748. * Gets the node index in matrix array generated for rendering
  95749. * @returns the node index
  95750. */
  95751. getIndex(): number;
  95752. /**
  95753. * Sets the parent bone
  95754. * @param parent defines the parent (can be null if the bone is the root)
  95755. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95756. */
  95757. setParent(parent: Nullable<Bone>, updateDifferenceMatrix?: boolean): void;
  95758. /**
  95759. * Gets the local matrix
  95760. * @returns a matrix
  95761. */
  95762. getLocalMatrix(): Matrix;
  95763. /**
  95764. * Gets the base matrix (initial matrix which remains unchanged)
  95765. * @returns a matrix
  95766. */
  95767. getBaseMatrix(): Matrix;
  95768. /**
  95769. * Gets the rest pose matrix
  95770. * @returns a matrix
  95771. */
  95772. getRestPose(): Matrix;
  95773. /**
  95774. * Sets the rest pose matrix
  95775. * @param matrix the local-space rest pose to set for this bone
  95776. */
  95777. setRestPose(matrix: Matrix): void;
  95778. /**
  95779. * Gets the bind pose matrix
  95780. * @returns the bind pose matrix
  95781. */
  95782. getBindPose(): Matrix;
  95783. /**
  95784. * Sets the bind pose matrix
  95785. * @param matrix the local-space bind pose to set for this bone
  95786. */
  95787. setBindPose(matrix: Matrix): void;
  95788. /**
  95789. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  95790. */
  95791. getWorldMatrix(): Matrix;
  95792. /**
  95793. * Sets the local matrix to rest pose matrix
  95794. */
  95795. returnToRest(): void;
  95796. /**
  95797. * Gets the inverse of the absolute transform matrix.
  95798. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  95799. * @returns a matrix
  95800. */
  95801. getInvertedAbsoluteTransform(): Matrix;
  95802. /**
  95803. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  95804. * @returns a matrix
  95805. */
  95806. getAbsoluteTransform(): Matrix;
  95807. /**
  95808. * Links with the given transform node.
  95809. * The local matrix of this bone is copied from the transform node every frame.
  95810. * @param transformNode defines the transform node to link to
  95811. */
  95812. linkTransformNode(transformNode: Nullable<TransformNode>): void;
  95813. /**
  95814. * Gets the node used to drive the bone's transformation
  95815. * @returns a transform node or null
  95816. */
  95817. getTransformNode(): Nullable<TransformNode>;
  95818. /** Gets or sets current position (in local space) */
  95819. get position(): Vector3;
  95820. set position(newPosition: Vector3);
  95821. /** Gets or sets current rotation (in local space) */
  95822. get rotation(): Vector3;
  95823. set rotation(newRotation: Vector3);
  95824. /** Gets or sets current rotation quaternion (in local space) */
  95825. get rotationQuaternion(): Quaternion;
  95826. set rotationQuaternion(newRotation: Quaternion);
  95827. /** Gets or sets current scaling (in local space) */
  95828. get scaling(): Vector3;
  95829. set scaling(newScaling: Vector3);
  95830. /**
  95831. * Gets the animation properties override
  95832. */
  95833. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  95834. private _decompose;
  95835. private _compose;
  95836. /**
  95837. * Update the base and local matrices
  95838. * @param matrix defines the new base or local matrix
  95839. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  95840. * @param updateLocalMatrix defines if the local matrix should be updated
  95841. */
  95842. updateMatrix(matrix: Matrix, updateDifferenceMatrix?: boolean, updateLocalMatrix?: boolean): void;
  95843. /** @hidden */
  95844. _updateDifferenceMatrix(rootMatrix?: Matrix, updateChildren?: boolean): void;
  95845. /**
  95846. * Flag the bone as dirty (Forcing it to update everything)
  95847. */
  95848. markAsDirty(): void;
  95849. /** @hidden */
  95850. _markAsDirtyAndCompose(): void;
  95851. private _markAsDirtyAndDecompose;
  95852. /**
  95853. * Translate the bone in local or world space
  95854. * @param vec The amount to translate the bone
  95855. * @param space The space that the translation is in
  95856. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95857. */
  95858. translate(vec: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95859. /**
  95860. * Set the postion of the bone in local or world space
  95861. * @param position The position to set the bone
  95862. * @param space The space that the position is in
  95863. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95864. */
  95865. setPosition(position: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95866. /**
  95867. * Set the absolute position of the bone (world space)
  95868. * @param position The position to set the bone
  95869. * @param mesh The mesh that this bone is attached to
  95870. */
  95871. setAbsolutePosition(position: Vector3, mesh?: AbstractMesh): void;
  95872. /**
  95873. * Scale the bone on the x, y and z axes (in local space)
  95874. * @param x The amount to scale the bone on the x axis
  95875. * @param y The amount to scale the bone on the y axis
  95876. * @param z The amount to scale the bone on the z axis
  95877. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  95878. */
  95879. scale(x: number, y: number, z: number, scaleChildren?: boolean): void;
  95880. /**
  95881. * Set the bone scaling in local space
  95882. * @param scale defines the scaling vector
  95883. */
  95884. setScale(scale: Vector3): void;
  95885. /**
  95886. * Gets the current scaling in local space
  95887. * @returns the current scaling vector
  95888. */
  95889. getScale(): Vector3;
  95890. /**
  95891. * Gets the current scaling in local space and stores it in a target vector
  95892. * @param result defines the target vector
  95893. */
  95894. getScaleToRef(result: Vector3): void;
  95895. /**
  95896. * Set the yaw, pitch, and roll of the bone in local or world space
  95897. * @param yaw The rotation of the bone on the y axis
  95898. * @param pitch The rotation of the bone on the x axis
  95899. * @param roll The rotation of the bone on the z axis
  95900. * @param space The space that the axes of rotation are in
  95901. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95902. */
  95903. setYawPitchRoll(yaw: number, pitch: number, roll: number, space?: Space, mesh?: AbstractMesh): void;
  95904. /**
  95905. * Add a rotation to the bone on an axis in local or world space
  95906. * @param axis The axis to rotate the bone on
  95907. * @param amount The amount to rotate the bone
  95908. * @param space The space that the axis is in
  95909. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95910. */
  95911. rotate(axis: Vector3, amount: number, space?: Space, mesh?: AbstractMesh): void;
  95912. /**
  95913. * Set the rotation of the bone to a particular axis angle in local or world space
  95914. * @param axis The axis to rotate the bone on
  95915. * @param angle The angle that the bone should be rotated to
  95916. * @param space The space that the axis is in
  95917. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95918. */
  95919. setAxisAngle(axis: Vector3, angle: number, space?: Space, mesh?: AbstractMesh): void;
  95920. /**
  95921. * Set the euler rotation of the bone in local or world space
  95922. * @param rotation The euler rotation that the bone should be set to
  95923. * @param space The space that the rotation is in
  95924. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95925. */
  95926. setRotation(rotation: Vector3, space?: Space, mesh?: AbstractMesh): void;
  95927. /**
  95928. * Set the quaternion rotation of the bone in local or world space
  95929. * @param quat The quaternion rotation that the bone should be set to
  95930. * @param space The space that the rotation is in
  95931. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95932. */
  95933. setRotationQuaternion(quat: Quaternion, space?: Space, mesh?: AbstractMesh): void;
  95934. /**
  95935. * Set the rotation matrix of the bone in local or world space
  95936. * @param rotMat The rotation matrix that the bone should be set to
  95937. * @param space The space that the rotation is in
  95938. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95939. */
  95940. setRotationMatrix(rotMat: Matrix, space?: Space, mesh?: AbstractMesh): void;
  95941. private _rotateWithMatrix;
  95942. private _getNegativeRotationToRef;
  95943. /**
  95944. * Get the position of the bone in local or world space
  95945. * @param space The space that the returned position is in
  95946. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95947. * @returns The position of the bone
  95948. */
  95949. getPosition(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95950. /**
  95951. * Copy the position of the bone to a vector3 in local or world space
  95952. * @param space The space that the returned position is in
  95953. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95954. * @param result The vector3 to copy the position to
  95955. */
  95956. getPositionToRef(space: Space | undefined, mesh: Nullable<AbstractMesh>, result: Vector3): void;
  95957. /**
  95958. * Get the absolute position of the bone (world space)
  95959. * @param mesh The mesh that this bone is attached to
  95960. * @returns The absolute position of the bone
  95961. */
  95962. getAbsolutePosition(mesh?: Nullable<AbstractMesh>): Vector3;
  95963. /**
  95964. * Copy the absolute position of the bone (world space) to the result param
  95965. * @param mesh The mesh that this bone is attached to
  95966. * @param result The vector3 to copy the absolute position to
  95967. */
  95968. getAbsolutePositionToRef(mesh: AbstractMesh, result: Vector3): void;
  95969. /**
  95970. * Compute the absolute transforms of this bone and its children
  95971. */
  95972. computeAbsoluteTransforms(): void;
  95973. /**
  95974. * Get the world direction from an axis that is in the local space of the bone
  95975. * @param localAxis The local direction that is used to compute the world direction
  95976. * @param mesh The mesh that this bone is attached to
  95977. * @returns The world direction
  95978. */
  95979. getDirection(localAxis: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  95980. /**
  95981. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  95982. * @param localAxis The local direction that is used to compute the world direction
  95983. * @param mesh The mesh that this bone is attached to
  95984. * @param result The vector3 that the world direction will be copied to
  95985. */
  95986. getDirectionToRef(localAxis: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  95987. /**
  95988. * Get the euler rotation of the bone in local or world space
  95989. * @param space The space that the rotation should be in
  95990. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95991. * @returns The euler rotation
  95992. */
  95993. getRotation(space?: Space, mesh?: Nullable<AbstractMesh>): Vector3;
  95994. /**
  95995. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  95996. * @param space The space that the rotation should be in
  95997. * @param mesh The mesh that this bone is attached to. This is only used in world space
  95998. * @param result The vector3 that the rotation should be copied to
  95999. */
  96000. getRotationToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96001. /**
  96002. * Get the quaternion rotation of the bone in either local or world space
  96003. * @param space The space that the rotation should be in
  96004. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96005. * @returns The quaternion rotation
  96006. */
  96007. getRotationQuaternion(space?: Space, mesh?: Nullable<AbstractMesh>): Quaternion;
  96008. /**
  96009. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  96010. * @param space The space that the rotation should be in
  96011. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96012. * @param result The quaternion that the rotation should be copied to
  96013. */
  96014. getRotationQuaternionToRef(space: Space | undefined, mesh: AbstractMesh | null | undefined, result: Quaternion): void;
  96015. /**
  96016. * Get the rotation matrix of the bone in local or world space
  96017. * @param space The space that the rotation should be in
  96018. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96019. * @returns The rotation matrix
  96020. */
  96021. getRotationMatrix(space: Space | undefined, mesh: AbstractMesh): Matrix;
  96022. /**
  96023. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  96024. * @param space The space that the rotation should be in
  96025. * @param mesh The mesh that this bone is attached to. This is only used in world space
  96026. * @param result The quaternion that the rotation should be copied to
  96027. */
  96028. getRotationMatrixToRef(space: Space | undefined, mesh: AbstractMesh, result: Matrix): void;
  96029. /**
  96030. * Get the world position of a point that is in the local space of the bone
  96031. * @param position The local position
  96032. * @param mesh The mesh that this bone is attached to
  96033. * @returns The world position
  96034. */
  96035. getAbsolutePositionFromLocal(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96036. /**
  96037. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  96038. * @param position The local position
  96039. * @param mesh The mesh that this bone is attached to
  96040. * @param result The vector3 that the world position should be copied to
  96041. */
  96042. getAbsolutePositionFromLocalToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96043. /**
  96044. * Get the local position of a point that is in world space
  96045. * @param position The world position
  96046. * @param mesh The mesh that this bone is attached to
  96047. * @returns The local position
  96048. */
  96049. getLocalPositionFromAbsolute(position: Vector3, mesh?: Nullable<AbstractMesh>): Vector3;
  96050. /**
  96051. * Get the local position of a point that is in world space and copy it to the result param
  96052. * @param position The world position
  96053. * @param mesh The mesh that this bone is attached to
  96054. * @param result The vector3 that the local position should be copied to
  96055. */
  96056. getLocalPositionFromAbsoluteToRef(position: Vector3, mesh: AbstractMesh | null | undefined, result: Vector3): void;
  96057. /**
  96058. * Set the current local matrix as the restPose for this bone.
  96059. */
  96060. setCurrentPoseAsRest(): void;
  96061. }
  96062. }
  96063. declare module BABYLON {
  96064. /**
  96065. * Defines a runtime animation
  96066. */
  96067. export class RuntimeAnimation {
  96068. private _events;
  96069. /**
  96070. * The current frame of the runtime animation
  96071. */
  96072. private _currentFrame;
  96073. /**
  96074. * The animation used by the runtime animation
  96075. */
  96076. private _animation;
  96077. /**
  96078. * The target of the runtime animation
  96079. */
  96080. private _target;
  96081. /**
  96082. * The initiating animatable
  96083. */
  96084. private _host;
  96085. /**
  96086. * The original value of the runtime animation
  96087. */
  96088. private _originalValue;
  96089. /**
  96090. * The original blend value of the runtime animation
  96091. */
  96092. private _originalBlendValue;
  96093. /**
  96094. * The offsets cache of the runtime animation
  96095. */
  96096. private _offsetsCache;
  96097. /**
  96098. * The high limits cache of the runtime animation
  96099. */
  96100. private _highLimitsCache;
  96101. /**
  96102. * Specifies if the runtime animation has been stopped
  96103. */
  96104. private _stopped;
  96105. /**
  96106. * The blending factor of the runtime animation
  96107. */
  96108. private _blendingFactor;
  96109. /**
  96110. * The BabylonJS scene
  96111. */
  96112. private _scene;
  96113. /**
  96114. * The current value of the runtime animation
  96115. */
  96116. private _currentValue;
  96117. /** @hidden */
  96118. _animationState: _IAnimationState;
  96119. /**
  96120. * The active target of the runtime animation
  96121. */
  96122. private _activeTargets;
  96123. private _currentActiveTarget;
  96124. private _directTarget;
  96125. /**
  96126. * The target path of the runtime animation
  96127. */
  96128. private _targetPath;
  96129. /**
  96130. * The weight of the runtime animation
  96131. */
  96132. private _weight;
  96133. /**
  96134. * The ratio offset of the runtime animation
  96135. */
  96136. private _ratioOffset;
  96137. /**
  96138. * The previous delay of the runtime animation
  96139. */
  96140. private _previousDelay;
  96141. /**
  96142. * The previous ratio of the runtime animation
  96143. */
  96144. private _previousRatio;
  96145. private _enableBlending;
  96146. private _keys;
  96147. private _minFrame;
  96148. private _maxFrame;
  96149. private _minValue;
  96150. private _maxValue;
  96151. private _targetIsArray;
  96152. /**
  96153. * Gets the current frame of the runtime animation
  96154. */
  96155. get currentFrame(): number;
  96156. /**
  96157. * Gets the weight of the runtime animation
  96158. */
  96159. get weight(): number;
  96160. /**
  96161. * Gets the current value of the runtime animation
  96162. */
  96163. get currentValue(): any;
  96164. /**
  96165. * Gets the target path of the runtime animation
  96166. */
  96167. get targetPath(): string;
  96168. /**
  96169. * Gets the actual target of the runtime animation
  96170. */
  96171. get target(): any;
  96172. /**
  96173. * Gets the additive state of the runtime animation
  96174. */
  96175. get isAdditive(): boolean;
  96176. /** @hidden */
  96177. _onLoop: () => void;
  96178. /**
  96179. * Create a new RuntimeAnimation object
  96180. * @param target defines the target of the animation
  96181. * @param animation defines the source animation object
  96182. * @param scene defines the hosting scene
  96183. * @param host defines the initiating Animatable
  96184. */
  96185. constructor(target: any, animation: Animation, scene: Scene, host: Animatable);
  96186. private _preparePath;
  96187. /**
  96188. * Gets the animation from the runtime animation
  96189. */
  96190. get animation(): Animation;
  96191. /**
  96192. * Resets the runtime animation to the beginning
  96193. * @param restoreOriginal defines whether to restore the target property to the original value
  96194. */
  96195. reset(restoreOriginal?: boolean): void;
  96196. /**
  96197. * Specifies if the runtime animation is stopped
  96198. * @returns Boolean specifying if the runtime animation is stopped
  96199. */
  96200. isStopped(): boolean;
  96201. /**
  96202. * Disposes of the runtime animation
  96203. */
  96204. dispose(): void;
  96205. /**
  96206. * Apply the interpolated value to the target
  96207. * @param currentValue defines the value computed by the animation
  96208. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  96209. */
  96210. setValue(currentValue: any, weight: number): void;
  96211. private _getOriginalValues;
  96212. private _setValue;
  96213. /**
  96214. * Gets the loop pmode of the runtime animation
  96215. * @returns Loop Mode
  96216. */
  96217. private _getCorrectLoopMode;
  96218. /**
  96219. * Move the current animation to a given frame
  96220. * @param frame defines the frame to move to
  96221. */
  96222. goToFrame(frame: number): void;
  96223. /**
  96224. * @hidden Internal use only
  96225. */
  96226. _prepareForSpeedRatioChange(newSpeedRatio: number): void;
  96227. /**
  96228. * Execute the current animation
  96229. * @param delay defines the delay to add to the current frame
  96230. * @param from defines the lower bound of the animation range
  96231. * @param to defines the upper bound of the animation range
  96232. * @param loop defines if the current animation must loop
  96233. * @param speedRatio defines the current speed ratio
  96234. * @param weight defines the weight of the animation (default is -1 so no weight)
  96235. * @param onLoop optional callback called when animation loops
  96236. * @returns a boolean indicating if the animation is running
  96237. */
  96238. animate(delay: number, from: number, to: number, loop: boolean, speedRatio: number, weight?: number): boolean;
  96239. }
  96240. }
  96241. declare module BABYLON {
  96242. /**
  96243. * Class used to store an actual running animation
  96244. */
  96245. export class Animatable {
  96246. /** defines the target object */
  96247. target: any;
  96248. /** defines the starting frame number (default is 0) */
  96249. fromFrame: number;
  96250. /** defines the ending frame number (default is 100) */
  96251. toFrame: number;
  96252. /** defines if the animation must loop (default is false) */
  96253. loopAnimation: boolean;
  96254. /** defines a callback to call when animation ends if it is not looping */
  96255. onAnimationEnd?: (() => void) | null | undefined;
  96256. /** defines a callback to call when animation loops */
  96257. onAnimationLoop?: (() => void) | null | undefined;
  96258. /** defines whether the animation should be evaluated additively */
  96259. isAdditive: boolean;
  96260. private _localDelayOffset;
  96261. private _pausedDelay;
  96262. private _runtimeAnimations;
  96263. private _paused;
  96264. private _scene;
  96265. private _speedRatio;
  96266. private _weight;
  96267. private _syncRoot;
  96268. /**
  96269. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  96270. * This will only apply for non looping animation (default is true)
  96271. */
  96272. disposeOnEnd: boolean;
  96273. /**
  96274. * Gets a boolean indicating if the animation has started
  96275. */
  96276. animationStarted: boolean;
  96277. /**
  96278. * Observer raised when the animation ends
  96279. */
  96280. onAnimationEndObservable: Observable<Animatable>;
  96281. /**
  96282. * Observer raised when the animation loops
  96283. */
  96284. onAnimationLoopObservable: Observable<Animatable>;
  96285. /**
  96286. * Gets the root Animatable used to synchronize and normalize animations
  96287. */
  96288. get syncRoot(): Nullable<Animatable>;
  96289. /**
  96290. * Gets the current frame of the first RuntimeAnimation
  96291. * Used to synchronize Animatables
  96292. */
  96293. get masterFrame(): number;
  96294. /**
  96295. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  96296. */
  96297. get weight(): number;
  96298. set weight(value: number);
  96299. /**
  96300. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  96301. */
  96302. get speedRatio(): number;
  96303. set speedRatio(value: number);
  96304. /**
  96305. * Creates a new Animatable
  96306. * @param scene defines the hosting scene
  96307. * @param target defines the target object
  96308. * @param fromFrame defines the starting frame number (default is 0)
  96309. * @param toFrame defines the ending frame number (default is 100)
  96310. * @param loopAnimation defines if the animation must loop (default is false)
  96311. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  96312. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  96313. * @param animations defines a group of animation to add to the new Animatable
  96314. * @param onAnimationLoop defines a callback to call when animation loops
  96315. * @param isAdditive defines whether the animation should be evaluated additively
  96316. */
  96317. constructor(scene: Scene,
  96318. /** defines the target object */
  96319. target: any,
  96320. /** defines the starting frame number (default is 0) */
  96321. fromFrame?: number,
  96322. /** defines the ending frame number (default is 100) */
  96323. toFrame?: number,
  96324. /** defines if the animation must loop (default is false) */
  96325. loopAnimation?: boolean, speedRatio?: number,
  96326. /** defines a callback to call when animation ends if it is not looping */
  96327. onAnimationEnd?: (() => void) | null | undefined, animations?: Animation[],
  96328. /** defines a callback to call when animation loops */
  96329. onAnimationLoop?: (() => void) | null | undefined,
  96330. /** defines whether the animation should be evaluated additively */
  96331. isAdditive?: boolean);
  96332. /**
  96333. * Synchronize and normalize current Animatable with a source Animatable
  96334. * This is useful when using animation weights and when animations are not of the same length
  96335. * @param root defines the root Animatable to synchronize with
  96336. * @returns the current Animatable
  96337. */
  96338. syncWith(root: Animatable): Animatable;
  96339. /**
  96340. * Gets the list of runtime animations
  96341. * @returns an array of RuntimeAnimation
  96342. */
  96343. getAnimations(): RuntimeAnimation[];
  96344. /**
  96345. * Adds more animations to the current animatable
  96346. * @param target defines the target of the animations
  96347. * @param animations defines the new animations to add
  96348. */
  96349. appendAnimations(target: any, animations: Animation[]): void;
  96350. /**
  96351. * Gets the source animation for a specific property
  96352. * @param property defines the propertyu to look for
  96353. * @returns null or the source animation for the given property
  96354. */
  96355. getAnimationByTargetProperty(property: string): Nullable<Animation>;
  96356. /**
  96357. * Gets the runtime animation for a specific property
  96358. * @param property defines the propertyu to look for
  96359. * @returns null or the runtime animation for the given property
  96360. */
  96361. getRuntimeAnimationByTargetProperty(property: string): Nullable<RuntimeAnimation>;
  96362. /**
  96363. * Resets the animatable to its original state
  96364. */
  96365. reset(): void;
  96366. /**
  96367. * Allows the animatable to blend with current running animations
  96368. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96369. * @param blendingSpeed defines the blending speed to use
  96370. */
  96371. enableBlending(blendingSpeed: number): void;
  96372. /**
  96373. * Disable animation blending
  96374. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96375. */
  96376. disableBlending(): void;
  96377. /**
  96378. * Jump directly to a given frame
  96379. * @param frame defines the frame to jump to
  96380. */
  96381. goToFrame(frame: number): void;
  96382. /**
  96383. * Pause the animation
  96384. */
  96385. pause(): void;
  96386. /**
  96387. * Restart the animation
  96388. */
  96389. restart(): void;
  96390. private _raiseOnAnimationEnd;
  96391. /**
  96392. * Stop and delete the current animation
  96393. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  96394. * @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)
  96395. */
  96396. stop(animationName?: string, targetMask?: (target: any) => boolean): void;
  96397. /**
  96398. * Wait asynchronously for the animation to end
  96399. * @returns a promise which will be fullfilled when the animation ends
  96400. */
  96401. waitAsync(): Promise<Animatable>;
  96402. /** @hidden */
  96403. _animate(delay: number): boolean;
  96404. }
  96405. interface Scene {
  96406. /** @hidden */
  96407. _registerTargetForLateAnimationBinding(runtimeAnimation: RuntimeAnimation, originalValue: any): void;
  96408. /** @hidden */
  96409. _processLateAnimationBindingsForMatrices(holder: {
  96410. totalWeight: number;
  96411. totalAdditiveWeight: number;
  96412. animations: RuntimeAnimation[];
  96413. additiveAnimations: RuntimeAnimation[];
  96414. originalValue: Matrix;
  96415. }): any;
  96416. /** @hidden */
  96417. _processLateAnimationBindingsForQuaternions(holder: {
  96418. totalWeight: number;
  96419. totalAdditiveWeight: number;
  96420. animations: RuntimeAnimation[];
  96421. additiveAnimations: RuntimeAnimation[];
  96422. originalValue: Quaternion;
  96423. }, refQuaternion: Quaternion): Quaternion;
  96424. /** @hidden */
  96425. _processLateAnimationBindings(): void;
  96426. /**
  96427. * Will start the animation sequence of a given target
  96428. * @param target defines the target
  96429. * @param from defines from which frame should animation start
  96430. * @param to defines until which frame should animation run.
  96431. * @param weight defines the weight to apply to the animation (1.0 by default)
  96432. * @param loop defines if the animation loops
  96433. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96434. * @param onAnimationEnd defines the function to be executed when the animation ends
  96435. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96436. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96437. * @param onAnimationLoop defines the callback to call when an animation loops
  96438. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96439. * @returns the animatable object created for this animation
  96440. */
  96441. 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;
  96442. /**
  96443. * Will start the animation sequence of a given target
  96444. * @param target defines the target
  96445. * @param from defines from which frame should animation start
  96446. * @param to defines until which frame should animation run.
  96447. * @param loop defines if the animation loops
  96448. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96449. * @param onAnimationEnd defines the function to be executed when the animation ends
  96450. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96451. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96452. * @param targetMask defines if the target should be animate if animations are present (this is called recursively on descendant animatables regardless of return value)
  96453. * @param onAnimationLoop defines the callback to call when an animation loops
  96454. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96455. * @returns the animatable object created for this animation
  96456. */
  96457. 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;
  96458. /**
  96459. * Will start the animation sequence of a given target and its hierarchy
  96460. * @param target defines the target
  96461. * @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.
  96462. * @param from defines from which frame should animation start
  96463. * @param to defines until which frame should animation run.
  96464. * @param loop defines if the animation loops
  96465. * @param speedRatio defines the speed in which to run the animation (1.0 by default)
  96466. * @param onAnimationEnd defines the function to be executed when the animation ends
  96467. * @param animatable defines an animatable object. If not provided a new one will be created from the given params
  96468. * @param stopCurrent defines if the current animations must be stopped first (true by default)
  96469. * @param targetMask defines if the target should be animated if animations are present (this is called recursively on descendant animatables regardless of return value)
  96470. * @param onAnimationLoop defines the callback to call when an animation loops
  96471. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96472. * @returns the list of created animatables
  96473. */
  96474. 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[];
  96475. /**
  96476. * Begin a new animation on a given node
  96477. * @param target defines the target where the animation will take place
  96478. * @param animations defines the list of animations to start
  96479. * @param from defines the initial value
  96480. * @param to defines the final value
  96481. * @param loop defines if you want animation to loop (off by default)
  96482. * @param speedRatio defines the speed ratio to apply to all animations
  96483. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96484. * @param onAnimationLoop defines the callback to call when an animation loops
  96485. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96486. * @returns the list of created animatables
  96487. */
  96488. beginDirectAnimation(target: any, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable;
  96489. /**
  96490. * Begin a new animation on a given node and its hierarchy
  96491. * @param target defines the root node where the animation will take place
  96492. * @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.
  96493. * @param animations defines the list of animations to start
  96494. * @param from defines the initial value
  96495. * @param to defines the final value
  96496. * @param loop defines if you want animation to loop (off by default)
  96497. * @param speedRatio defines the speed ratio to apply to all animations
  96498. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  96499. * @param onAnimationLoop defines the callback to call when an animation loops
  96500. * @param isAdditive defines whether the animation should be evaluated additively (false by default)
  96501. * @returns the list of animatables created for all nodes
  96502. */
  96503. beginDirectHierarchyAnimation(target: Node, directDescendantsOnly: boolean, animations: Animation[], from: number, to: number, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void, onAnimationLoop?: () => void, isAdditive?: boolean): Animatable[];
  96504. /**
  96505. * Gets the animatable associated with a specific target
  96506. * @param target defines the target of the animatable
  96507. * @returns the required animatable if found
  96508. */
  96509. getAnimatableByTarget(target: any): Nullable<Animatable>;
  96510. /**
  96511. * Gets all animatables associated with a given target
  96512. * @param target defines the target to look animatables for
  96513. * @returns an array of Animatables
  96514. */
  96515. getAllAnimatablesByTarget(target: any): Array<Animatable>;
  96516. /**
  96517. * Stops and removes all animations that have been applied to the scene
  96518. */
  96519. stopAllAnimations(): void;
  96520. /**
  96521. * Gets the current delta time used by animation engine
  96522. */
  96523. deltaTime: number;
  96524. }
  96525. interface Bone {
  96526. /**
  96527. * Copy an animation range from another bone
  96528. * @param source defines the source bone
  96529. * @param rangeName defines the range name to copy
  96530. * @param frameOffset defines the frame offset
  96531. * @param rescaleAsRequired defines if rescaling must be applied if required
  96532. * @param skelDimensionsRatio defines the scaling ratio
  96533. * @returns true if operation was successful
  96534. */
  96535. copyAnimationRange(source: Bone, rangeName: string, frameOffset: number, rescaleAsRequired: boolean, skelDimensionsRatio: Nullable<Vector3>): boolean;
  96536. }
  96537. }
  96538. declare module BABYLON {
  96539. /**
  96540. * Class used to handle skinning animations
  96541. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  96542. */
  96543. export class Skeleton implements IAnimatable {
  96544. /** defines the skeleton name */
  96545. name: string;
  96546. /** defines the skeleton Id */
  96547. id: string;
  96548. /**
  96549. * Defines the list of child bones
  96550. */
  96551. bones: Bone[];
  96552. /**
  96553. * Defines an estimate of the dimension of the skeleton at rest
  96554. */
  96555. dimensionsAtRest: Vector3;
  96556. /**
  96557. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  96558. */
  96559. needInitialSkinMatrix: boolean;
  96560. /**
  96561. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  96562. */
  96563. overrideMesh: Nullable<AbstractMesh>;
  96564. /**
  96565. * Gets the list of animations attached to this skeleton
  96566. */
  96567. animations: Array<Animation>;
  96568. private _scene;
  96569. private _isDirty;
  96570. private _transformMatrices;
  96571. private _transformMatrixTexture;
  96572. private _meshesWithPoseMatrix;
  96573. private _animatables;
  96574. private _identity;
  96575. private _synchronizedWithMesh;
  96576. private _ranges;
  96577. private _lastAbsoluteTransformsUpdateId;
  96578. private _canUseTextureForBones;
  96579. private _uniqueId;
  96580. /** @hidden */
  96581. _numBonesWithLinkedTransformNode: number;
  96582. /** @hidden */
  96583. _hasWaitingData: Nullable<boolean>;
  96584. /** @hidden */
  96585. _waitingOverrideMeshId: Nullable<string>;
  96586. /**
  96587. * Specifies if the skeleton should be serialized
  96588. */
  96589. doNotSerialize: boolean;
  96590. private _useTextureToStoreBoneMatrices;
  96591. /**
  96592. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  96593. * Please note that this option is not available if the hardware does not support it
  96594. */
  96595. get useTextureToStoreBoneMatrices(): boolean;
  96596. set useTextureToStoreBoneMatrices(value: boolean);
  96597. private _animationPropertiesOverride;
  96598. /**
  96599. * Gets or sets the animation properties override
  96600. */
  96601. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  96602. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  96603. /**
  96604. * List of inspectable custom properties (used by the Inspector)
  96605. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  96606. */
  96607. inspectableCustomProperties: IInspectable[];
  96608. /**
  96609. * An observable triggered before computing the skeleton's matrices
  96610. */
  96611. onBeforeComputeObservable: Observable<Skeleton>;
  96612. /**
  96613. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  96614. */
  96615. get isUsingTextureForMatrices(): boolean;
  96616. /**
  96617. * Gets the unique ID of this skeleton
  96618. */
  96619. get uniqueId(): number;
  96620. /**
  96621. * Creates a new skeleton
  96622. * @param name defines the skeleton name
  96623. * @param id defines the skeleton Id
  96624. * @param scene defines the hosting scene
  96625. */
  96626. constructor(
  96627. /** defines the skeleton name */
  96628. name: string,
  96629. /** defines the skeleton Id */
  96630. id: string, scene: Scene);
  96631. /**
  96632. * Gets the current object class name.
  96633. * @return the class name
  96634. */
  96635. getClassName(): string;
  96636. /**
  96637. * Returns an array containing the root bones
  96638. * @returns an array containing the root bones
  96639. */
  96640. getChildren(): Array<Bone>;
  96641. /**
  96642. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  96643. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96644. * @returns a Float32Array containing matrices data
  96645. */
  96646. getTransformMatrices(mesh: AbstractMesh): Float32Array;
  96647. /**
  96648. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  96649. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  96650. * @returns a raw texture containing the data
  96651. */
  96652. getTransformMatrixTexture(mesh: AbstractMesh): Nullable<RawTexture>;
  96653. /**
  96654. * Gets the current hosting scene
  96655. * @returns a scene object
  96656. */
  96657. getScene(): Scene;
  96658. /**
  96659. * Gets a string representing the current skeleton data
  96660. * @param fullDetails defines a boolean indicating if we want a verbose version
  96661. * @returns a string representing the current skeleton data
  96662. */
  96663. toString(fullDetails?: boolean): string;
  96664. /**
  96665. * Get bone's index searching by name
  96666. * @param name defines bone's name to search for
  96667. * @return the indice of the bone. Returns -1 if not found
  96668. */
  96669. getBoneIndexByName(name: string): number;
  96670. /**
  96671. * Creater a new animation range
  96672. * @param name defines the name of the range
  96673. * @param from defines the start key
  96674. * @param to defines the end key
  96675. */
  96676. createAnimationRange(name: string, from: number, to: number): void;
  96677. /**
  96678. * Delete a specific animation range
  96679. * @param name defines the name of the range
  96680. * @param deleteFrames defines if frames must be removed as well
  96681. */
  96682. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  96683. /**
  96684. * Gets a specific animation range
  96685. * @param name defines the name of the range to look for
  96686. * @returns the requested animation range or null if not found
  96687. */
  96688. getAnimationRange(name: string): Nullable<AnimationRange>;
  96689. /**
  96690. * Gets the list of all animation ranges defined on this skeleton
  96691. * @returns an array
  96692. */
  96693. getAnimationRanges(): Nullable<AnimationRange>[];
  96694. /**
  96695. * Copy animation range from a source skeleton.
  96696. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  96697. * @param source defines the source skeleton
  96698. * @param name defines the name of the range to copy
  96699. * @param rescaleAsRequired defines if rescaling must be applied if required
  96700. * @returns true if operation was successful
  96701. */
  96702. copyAnimationRange(source: Skeleton, name: string, rescaleAsRequired?: boolean): boolean;
  96703. /**
  96704. * Forces the skeleton to go to rest pose
  96705. */
  96706. returnToRest(): void;
  96707. private _getHighestAnimationFrame;
  96708. /**
  96709. * Begin a specific animation range
  96710. * @param name defines the name of the range to start
  96711. * @param loop defines if looping must be turned on (false by default)
  96712. * @param speedRatio defines the speed ratio to apply (1 by default)
  96713. * @param onAnimationEnd defines a callback which will be called when animation will end
  96714. * @returns a new animatable
  96715. */
  96716. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  96717. /**
  96718. * Convert the keyframes for a range of animation on a skeleton to be relative to a given reference frame.
  96719. * @param skeleton defines the Skeleton containing the animation range to convert
  96720. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  96721. * @param range defines the name of the AnimationRange belonging to the Skeleton to convert
  96722. * @returns the original skeleton
  96723. */
  96724. static MakeAnimationAdditive(skeleton: Skeleton, referenceFrame: number | undefined, range: string): Nullable<Skeleton>;
  96725. /** @hidden */
  96726. _markAsDirty(): void;
  96727. /** @hidden */
  96728. _registerMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96729. /** @hidden */
  96730. _unregisterMeshWithPoseMatrix(mesh: AbstractMesh): void;
  96731. private _computeTransformMatrices;
  96732. /**
  96733. * Build all resources required to render a skeleton
  96734. */
  96735. prepare(): void;
  96736. /**
  96737. * Gets the list of animatables currently running for this skeleton
  96738. * @returns an array of animatables
  96739. */
  96740. getAnimatables(): IAnimatable[];
  96741. /**
  96742. * Clone the current skeleton
  96743. * @param name defines the name of the new skeleton
  96744. * @param id defines the id of the new skeleton
  96745. * @returns the new skeleton
  96746. */
  96747. clone(name: string, id?: string): Skeleton;
  96748. /**
  96749. * Enable animation blending for this skeleton
  96750. * @param blendingSpeed defines the blending speed to apply
  96751. * @see https://doc.babylonjs.com/babylon101/animations#animation-blending
  96752. */
  96753. enableBlending(blendingSpeed?: number): void;
  96754. /**
  96755. * Releases all resources associated with the current skeleton
  96756. */
  96757. dispose(): void;
  96758. /**
  96759. * Serialize the skeleton in a JSON object
  96760. * @returns a JSON object
  96761. */
  96762. serialize(): any;
  96763. /**
  96764. * Creates a new skeleton from serialized data
  96765. * @param parsedSkeleton defines the serialized data
  96766. * @param scene defines the hosting scene
  96767. * @returns a new skeleton
  96768. */
  96769. static Parse(parsedSkeleton: any, scene: Scene): Skeleton;
  96770. /**
  96771. * Compute all node absolute transforms
  96772. * @param forceUpdate defines if computation must be done even if cache is up to date
  96773. */
  96774. computeAbsoluteTransforms(forceUpdate?: boolean): void;
  96775. /**
  96776. * Gets the root pose matrix
  96777. * @returns a matrix
  96778. */
  96779. getPoseMatrix(): Nullable<Matrix>;
  96780. /**
  96781. * Sorts bones per internal index
  96782. */
  96783. sortBones(): void;
  96784. private _sortBones;
  96785. /**
  96786. * Set the current local matrix as the restPose for all bones in the skeleton.
  96787. */
  96788. setCurrentPoseAsRest(): void;
  96789. }
  96790. }
  96791. declare module BABYLON {
  96792. /**
  96793. * Creates an instance based on a source mesh.
  96794. */
  96795. export class InstancedMesh extends AbstractMesh {
  96796. private _sourceMesh;
  96797. private _currentLOD;
  96798. /** @hidden */
  96799. _indexInSourceMeshInstanceArray: number;
  96800. constructor(name: string, source: Mesh);
  96801. /**
  96802. * Returns the string "InstancedMesh".
  96803. */
  96804. getClassName(): string;
  96805. /** Gets the list of lights affecting that mesh */
  96806. get lightSources(): Light[];
  96807. _resyncLightSources(): void;
  96808. _resyncLightSource(light: Light): void;
  96809. _removeLightSource(light: Light, dispose: boolean): void;
  96810. /**
  96811. * If the source mesh receives shadows
  96812. */
  96813. get receiveShadows(): boolean;
  96814. /**
  96815. * The material of the source mesh
  96816. */
  96817. get material(): Nullable<Material>;
  96818. /**
  96819. * Visibility of the source mesh
  96820. */
  96821. get visibility(): number;
  96822. /**
  96823. * Skeleton of the source mesh
  96824. */
  96825. get skeleton(): Nullable<Skeleton>;
  96826. /**
  96827. * Rendering ground id of the source mesh
  96828. */
  96829. get renderingGroupId(): number;
  96830. set renderingGroupId(value: number);
  96831. /**
  96832. * Returns the total number of vertices (integer).
  96833. */
  96834. getTotalVertices(): number;
  96835. /**
  96836. * Returns a positive integer : the total number of indices in this mesh geometry.
  96837. * @returns the numner of indices or zero if the mesh has no geometry.
  96838. */
  96839. getTotalIndices(): number;
  96840. /**
  96841. * The source mesh of the instance
  96842. */
  96843. get sourceMesh(): Mesh;
  96844. /**
  96845. * Creates a new InstancedMesh object from the mesh model.
  96846. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  96847. * @param name defines the name of the new instance
  96848. * @returns a new InstancedMesh
  96849. */
  96850. createInstance(name: string): InstancedMesh;
  96851. /**
  96852. * Is this node ready to be used/rendered
  96853. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  96854. * @return {boolean} is it ready
  96855. */
  96856. isReady(completeCheck?: boolean): boolean;
  96857. /**
  96858. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  96859. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  96860. * @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.
  96861. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  96862. */
  96863. getVerticesData(kind: string, copyWhenShared?: boolean): Nullable<FloatArray>;
  96864. /**
  96865. * Sets the vertex data of the mesh geometry for the requested `kind`.
  96866. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  96867. * The `data` are either a numeric array either a Float32Array.
  96868. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  96869. * 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).
  96870. * Note that a new underlying VertexBuffer object is created each call.
  96871. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  96872. *
  96873. * Possible `kind` values :
  96874. * - VertexBuffer.PositionKind
  96875. * - VertexBuffer.UVKind
  96876. * - VertexBuffer.UV2Kind
  96877. * - VertexBuffer.UV3Kind
  96878. * - VertexBuffer.UV4Kind
  96879. * - VertexBuffer.UV5Kind
  96880. * - VertexBuffer.UV6Kind
  96881. * - VertexBuffer.ColorKind
  96882. * - VertexBuffer.MatricesIndicesKind
  96883. * - VertexBuffer.MatricesIndicesExtraKind
  96884. * - VertexBuffer.MatricesWeightsKind
  96885. * - VertexBuffer.MatricesWeightsExtraKind
  96886. *
  96887. * Returns the Mesh.
  96888. */
  96889. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  96890. /**
  96891. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  96892. * If the mesh has no geometry, it is simply returned as it is.
  96893. * The `data` are either a numeric array either a Float32Array.
  96894. * No new underlying VertexBuffer object is created.
  96895. * 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.
  96896. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  96897. *
  96898. * Possible `kind` values :
  96899. * - VertexBuffer.PositionKind
  96900. * - VertexBuffer.UVKind
  96901. * - VertexBuffer.UV2Kind
  96902. * - VertexBuffer.UV3Kind
  96903. * - VertexBuffer.UV4Kind
  96904. * - VertexBuffer.UV5Kind
  96905. * - VertexBuffer.UV6Kind
  96906. * - VertexBuffer.ColorKind
  96907. * - VertexBuffer.MatricesIndicesKind
  96908. * - VertexBuffer.MatricesIndicesExtraKind
  96909. * - VertexBuffer.MatricesWeightsKind
  96910. * - VertexBuffer.MatricesWeightsExtraKind
  96911. *
  96912. * Returns the Mesh.
  96913. */
  96914. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): Mesh;
  96915. /**
  96916. * Sets the mesh indices.
  96917. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  96918. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  96919. * This method creates a new index buffer each call.
  96920. * Returns the Mesh.
  96921. */
  96922. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>): Mesh;
  96923. /**
  96924. * Boolean : True if the mesh owns the requested kind of data.
  96925. */
  96926. isVerticesDataPresent(kind: string): boolean;
  96927. /**
  96928. * Returns an array of indices (IndicesArray).
  96929. */
  96930. getIndices(): Nullable<IndicesArray>;
  96931. get _positions(): Nullable<Vector3[]>;
  96932. /**
  96933. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  96934. * This means the mesh underlying bounding box and sphere are recomputed.
  96935. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  96936. * @returns the current mesh
  96937. */
  96938. refreshBoundingInfo(applySkeleton?: boolean): InstancedMesh;
  96939. /** @hidden */
  96940. _preActivate(): InstancedMesh;
  96941. /** @hidden */
  96942. _activate(renderId: number, intermediateRendering: boolean): boolean;
  96943. /** @hidden */
  96944. _postActivate(): void;
  96945. getWorldMatrix(): Matrix;
  96946. get isAnInstance(): boolean;
  96947. /**
  96948. * Returns the current associated LOD AbstractMesh.
  96949. */
  96950. getLOD(camera: Camera): AbstractMesh;
  96951. /** @hidden */
  96952. _preActivateForIntermediateRendering(renderId: number): Mesh;
  96953. /** @hidden */
  96954. _syncSubMeshes(): InstancedMesh;
  96955. /** @hidden */
  96956. _generatePointsArray(): boolean;
  96957. /** @hidden */
  96958. _updateBoundingInfo(): AbstractMesh;
  96959. /**
  96960. * Creates a new InstancedMesh from the current mesh.
  96961. * - name (string) : the cloned mesh name
  96962. * - newParent (optional Node) : the optional Node to parent the clone to.
  96963. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  96964. *
  96965. * Returns the clone.
  96966. */
  96967. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): InstancedMesh;
  96968. /**
  96969. * Disposes the InstancedMesh.
  96970. * Returns nothing.
  96971. */
  96972. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  96973. }
  96974. interface Mesh {
  96975. /**
  96976. * Register a custom buffer that will be instanced
  96977. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  96978. * @param kind defines the buffer kind
  96979. * @param stride defines the stride in floats
  96980. */
  96981. registerInstancedBuffer(kind: string, stride: number): void;
  96982. /**
  96983. * true to use the edge renderer for all instances of this mesh
  96984. */
  96985. edgesShareWithInstances: boolean;
  96986. /** @hidden */
  96987. _userInstancedBuffersStorage: {
  96988. data: {
  96989. [key: string]: Float32Array;
  96990. };
  96991. sizes: {
  96992. [key: string]: number;
  96993. };
  96994. vertexBuffers: {
  96995. [key: string]: Nullable<VertexBuffer>;
  96996. };
  96997. strides: {
  96998. [key: string]: number;
  96999. };
  97000. };
  97001. }
  97002. interface AbstractMesh {
  97003. /**
  97004. * Object used to store instanced buffers defined by user
  97005. * @see https://doc.babylonjs.com/how_to/how_to_use_instances#custom-buffers
  97006. */
  97007. instancedBuffers: {
  97008. [key: string]: any;
  97009. };
  97010. }
  97011. }
  97012. declare module BABYLON {
  97013. /**
  97014. * Defines the options associated with the creation of a shader material.
  97015. */
  97016. export interface IShaderMaterialOptions {
  97017. /**
  97018. * Does the material work in alpha blend mode
  97019. */
  97020. needAlphaBlending: boolean;
  97021. /**
  97022. * Does the material work in alpha test mode
  97023. */
  97024. needAlphaTesting: boolean;
  97025. /**
  97026. * The list of attribute names used in the shader
  97027. */
  97028. attributes: string[];
  97029. /**
  97030. * The list of unifrom names used in the shader
  97031. */
  97032. uniforms: string[];
  97033. /**
  97034. * The list of UBO names used in the shader
  97035. */
  97036. uniformBuffers: string[];
  97037. /**
  97038. * The list of sampler names used in the shader
  97039. */
  97040. samplers: string[];
  97041. /**
  97042. * The list of defines used in the shader
  97043. */
  97044. defines: string[];
  97045. }
  97046. /**
  97047. * 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.
  97048. *
  97049. * This returned material effects how the mesh will look based on the code in the shaders.
  97050. *
  97051. * @see https://doc.babylonjs.com/how_to/shader_material
  97052. */
  97053. export class ShaderMaterial extends Material {
  97054. private _shaderPath;
  97055. private _options;
  97056. private _textures;
  97057. private _textureArrays;
  97058. private _floats;
  97059. private _ints;
  97060. private _floatsArrays;
  97061. private _colors3;
  97062. private _colors3Arrays;
  97063. private _colors4;
  97064. private _colors4Arrays;
  97065. private _vectors2;
  97066. private _vectors3;
  97067. private _vectors4;
  97068. private _matrices;
  97069. private _matrixArrays;
  97070. private _matrices3x3;
  97071. private _matrices2x2;
  97072. private _vectors2Arrays;
  97073. private _vectors3Arrays;
  97074. private _vectors4Arrays;
  97075. private _cachedWorldViewMatrix;
  97076. private _cachedWorldViewProjectionMatrix;
  97077. private _renderId;
  97078. private _multiview;
  97079. private _cachedDefines;
  97080. /** Define the Url to load snippets */
  97081. static SnippetUrl: string;
  97082. /** Snippet ID if the material was created from the snippet server */
  97083. snippetId: string;
  97084. /**
  97085. * Instantiate a new shader material.
  97086. * 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.
  97087. * This returned material effects how the mesh will look based on the code in the shaders.
  97088. * @see https://doc.babylonjs.com/how_to/shader_material
  97089. * @param name Define the name of the material in the scene
  97090. * @param scene Define the scene the material belongs to
  97091. * @param shaderPath Defines the route to the shader code in one of three ways:
  97092. * * object: { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  97093. * * object: { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in script tags
  97094. * * object: { vertexSource: "vertex shader code string", fragmentSource: "fragment shader code string" } using with strings containing the shaders code
  97095. * * string: "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  97096. * @param options Define the options used to create the shader
  97097. */
  97098. constructor(name: string, scene: Scene, shaderPath: any, options?: Partial<IShaderMaterialOptions>);
  97099. /**
  97100. * Gets the shader path used to define the shader code
  97101. * It can be modified to trigger a new compilation
  97102. */
  97103. get shaderPath(): any;
  97104. /**
  97105. * Sets the shader path used to define the shader code
  97106. * It can be modified to trigger a new compilation
  97107. */
  97108. set shaderPath(shaderPath: any);
  97109. /**
  97110. * Gets the options used to compile the shader.
  97111. * They can be modified to trigger a new compilation
  97112. */
  97113. get options(): IShaderMaterialOptions;
  97114. /**
  97115. * Gets the current class name of the material e.g. "ShaderMaterial"
  97116. * Mainly use in serialization.
  97117. * @returns the class name
  97118. */
  97119. getClassName(): string;
  97120. /**
  97121. * Specifies if the material will require alpha blending
  97122. * @returns a boolean specifying if alpha blending is needed
  97123. */
  97124. needAlphaBlending(): boolean;
  97125. /**
  97126. * Specifies if this material should be rendered in alpha test mode
  97127. * @returns a boolean specifying if an alpha test is needed.
  97128. */
  97129. needAlphaTesting(): boolean;
  97130. private _checkUniform;
  97131. /**
  97132. * Set a texture in the shader.
  97133. * @param name Define the name of the uniform samplers as defined in the shader
  97134. * @param texture Define the texture to bind to this sampler
  97135. * @return the material itself allowing "fluent" like uniform updates
  97136. */
  97137. setTexture(name: string, texture: BaseTexture): ShaderMaterial;
  97138. /**
  97139. * Set a texture array in the shader.
  97140. * @param name Define the name of the uniform sampler array as defined in the shader
  97141. * @param textures Define the list of textures to bind to this sampler
  97142. * @return the material itself allowing "fluent" like uniform updates
  97143. */
  97144. setTextureArray(name: string, textures: BaseTexture[]): ShaderMaterial;
  97145. /**
  97146. * Set a float in the shader.
  97147. * @param name Define the name of the uniform as defined in the shader
  97148. * @param value Define the value to give to the uniform
  97149. * @return the material itself allowing "fluent" like uniform updates
  97150. */
  97151. setFloat(name: string, value: number): ShaderMaterial;
  97152. /**
  97153. * Set a int in the shader.
  97154. * @param name Define the name of the uniform as defined in the shader
  97155. * @param value Define the value to give to the uniform
  97156. * @return the material itself allowing "fluent" like uniform updates
  97157. */
  97158. setInt(name: string, value: number): ShaderMaterial;
  97159. /**
  97160. * Set an array of floats in the shader.
  97161. * @param name Define the name of the uniform as defined in the shader
  97162. * @param value Define the value to give to the uniform
  97163. * @return the material itself allowing "fluent" like uniform updates
  97164. */
  97165. setFloats(name: string, value: number[]): ShaderMaterial;
  97166. /**
  97167. * Set a vec3 in the shader from a Color3.
  97168. * @param name Define the name of the uniform as defined in the shader
  97169. * @param value Define the value to give to the uniform
  97170. * @return the material itself allowing "fluent" like uniform updates
  97171. */
  97172. setColor3(name: string, value: Color3): ShaderMaterial;
  97173. /**
  97174. * Set a vec3 array in the shader from a Color3 array.
  97175. * @param name Define the name of the uniform as defined in the shader
  97176. * @param value Define the value to give to the uniform
  97177. * @return the material itself allowing "fluent" like uniform updates
  97178. */
  97179. setColor3Array(name: string, value: Color3[]): ShaderMaterial;
  97180. /**
  97181. * Set a vec4 in the shader from a Color4.
  97182. * @param name Define the name of the uniform as defined in the shader
  97183. * @param value Define the value to give to the uniform
  97184. * @return the material itself allowing "fluent" like uniform updates
  97185. */
  97186. setColor4(name: string, value: Color4): ShaderMaterial;
  97187. /**
  97188. * Set a vec4 array in the shader from a Color4 array.
  97189. * @param name Define the name of the uniform as defined in the shader
  97190. * @param value Define the value to give to the uniform
  97191. * @return the material itself allowing "fluent" like uniform updates
  97192. */
  97193. setColor4Array(name: string, value: Color4[]): ShaderMaterial;
  97194. /**
  97195. * Set a vec2 in the shader from a Vector2.
  97196. * @param name Define the name of the uniform as defined in the shader
  97197. * @param value Define the value to give to the uniform
  97198. * @return the material itself allowing "fluent" like uniform updates
  97199. */
  97200. setVector2(name: string, value: Vector2): ShaderMaterial;
  97201. /**
  97202. * Set a vec3 in the shader from a Vector3.
  97203. * @param name Define the name of the uniform as defined in the shader
  97204. * @param value Define the value to give to the uniform
  97205. * @return the material itself allowing "fluent" like uniform updates
  97206. */
  97207. setVector3(name: string, value: Vector3): ShaderMaterial;
  97208. /**
  97209. * Set a vec4 in the shader from a Vector4.
  97210. * @param name Define the name of the uniform as defined in the shader
  97211. * @param value Define the value to give to the uniform
  97212. * @return the material itself allowing "fluent" like uniform updates
  97213. */
  97214. setVector4(name: string, value: Vector4): ShaderMaterial;
  97215. /**
  97216. * Set a mat4 in the shader from a Matrix.
  97217. * @param name Define the name of the uniform as defined in the shader
  97218. * @param value Define the value to give to the uniform
  97219. * @return the material itself allowing "fluent" like uniform updates
  97220. */
  97221. setMatrix(name: string, value: Matrix): ShaderMaterial;
  97222. /**
  97223. * Set a float32Array in the shader from a matrix array.
  97224. * @param name Define the name of the uniform as defined in the shader
  97225. * @param value Define the value to give to the uniform
  97226. * @return the material itself allowing "fluent" like uniform updates
  97227. */
  97228. setMatrices(name: string, value: Matrix[]): ShaderMaterial;
  97229. /**
  97230. * Set a mat3 in the shader from a Float32Array.
  97231. * @param name Define the name of the uniform as defined in the shader
  97232. * @param value Define the value to give to the uniform
  97233. * @return the material itself allowing "fluent" like uniform updates
  97234. */
  97235. setMatrix3x3(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97236. /**
  97237. * Set a mat2 in the shader from a Float32Array.
  97238. * @param name Define the name of the uniform as defined in the shader
  97239. * @param value Define the value to give to the uniform
  97240. * @return the material itself allowing "fluent" like uniform updates
  97241. */
  97242. setMatrix2x2(name: string, value: Float32Array | Array<number>): ShaderMaterial;
  97243. /**
  97244. * Set a vec2 array in the shader from a number array.
  97245. * @param name Define the name of the uniform as defined in the shader
  97246. * @param value Define the value to give to the uniform
  97247. * @return the material itself allowing "fluent" like uniform updates
  97248. */
  97249. setArray2(name: string, value: number[]): ShaderMaterial;
  97250. /**
  97251. * Set a vec3 array in the shader from a number array.
  97252. * @param name Define the name of the uniform as defined in the shader
  97253. * @param value Define the value to give to the uniform
  97254. * @return the material itself allowing "fluent" like uniform updates
  97255. */
  97256. setArray3(name: string, value: number[]): ShaderMaterial;
  97257. /**
  97258. * Set a vec4 array in the shader from a number array.
  97259. * @param name Define the name of the uniform as defined in the shader
  97260. * @param value Define the value to give to the uniform
  97261. * @return the material itself allowing "fluent" like uniform updates
  97262. */
  97263. setArray4(name: string, value: number[]): ShaderMaterial;
  97264. private _checkCache;
  97265. /**
  97266. * Specifies that the submesh is ready to be used
  97267. * @param mesh defines the mesh to check
  97268. * @param subMesh defines which submesh to check
  97269. * @param useInstances specifies that instances should be used
  97270. * @returns a boolean indicating that the submesh is ready or not
  97271. */
  97272. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  97273. /**
  97274. * Checks if the material is ready to render the requested mesh
  97275. * @param mesh Define the mesh to render
  97276. * @param useInstances Define whether or not the material is used with instances
  97277. * @returns true if ready, otherwise false
  97278. */
  97279. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  97280. /**
  97281. * Binds the world matrix to the material
  97282. * @param world defines the world transformation matrix
  97283. * @param effectOverride - If provided, use this effect instead of internal effect
  97284. */
  97285. bindOnlyWorldMatrix(world: Matrix, effectOverride?: Nullable<Effect>): void;
  97286. /**
  97287. * Binds the submesh to this material by preparing the effect and shader to draw
  97288. * @param world defines the world transformation matrix
  97289. * @param mesh defines the mesh containing the submesh
  97290. * @param subMesh defines the submesh to bind the material to
  97291. */
  97292. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  97293. /**
  97294. * Binds the material to the mesh
  97295. * @param world defines the world transformation matrix
  97296. * @param mesh defines the mesh to bind the material to
  97297. * @param effectOverride - If provided, use this effect instead of internal effect
  97298. */
  97299. bind(world: Matrix, mesh?: Mesh, effectOverride?: Nullable<Effect>): void;
  97300. protected _afterBind(mesh?: Mesh): void;
  97301. /**
  97302. * Gets the active textures from the material
  97303. * @returns an array of textures
  97304. */
  97305. getActiveTextures(): BaseTexture[];
  97306. /**
  97307. * Specifies if the material uses a texture
  97308. * @param texture defines the texture to check against the material
  97309. * @returns a boolean specifying if the material uses the texture
  97310. */
  97311. hasTexture(texture: BaseTexture): boolean;
  97312. /**
  97313. * Makes a duplicate of the material, and gives it a new name
  97314. * @param name defines the new name for the duplicated material
  97315. * @returns the cloned material
  97316. */
  97317. clone(name: string): ShaderMaterial;
  97318. /**
  97319. * Disposes the material
  97320. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  97321. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  97322. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  97323. */
  97324. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  97325. /**
  97326. * Serializes this material in a JSON representation
  97327. * @returns the serialized material object
  97328. */
  97329. serialize(): any;
  97330. /**
  97331. * Creates a shader material from parsed shader material data
  97332. * @param source defines the JSON represnetation of the material
  97333. * @param scene defines the hosting scene
  97334. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97335. * @returns a new material
  97336. */
  97337. static Parse(source: any, scene: Scene, rootUrl: string): ShaderMaterial;
  97338. /**
  97339. * Creates a new ShaderMaterial from a snippet saved in a remote file
  97340. * @param name defines the name of the ShaderMaterial to create (can be null or empty to use the one from the json data)
  97341. * @param url defines the url to load from
  97342. * @param scene defines the hosting scene
  97343. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97344. * @returns a promise that will resolve to the new ShaderMaterial
  97345. */
  97346. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97347. /**
  97348. * Creates a ShaderMaterial from a snippet saved by the Inspector
  97349. * @param snippetId defines the snippet to load
  97350. * @param scene defines the hosting scene
  97351. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  97352. * @returns a promise that will resolve to the new ShaderMaterial
  97353. */
  97354. static CreateFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string): Promise<ShaderMaterial>;
  97355. }
  97356. }
  97357. declare module BABYLON {
  97358. /** @hidden */
  97359. export var colorPixelShader: {
  97360. name: string;
  97361. shader: string;
  97362. };
  97363. }
  97364. declare module BABYLON {
  97365. /** @hidden */
  97366. export var colorVertexShader: {
  97367. name: string;
  97368. shader: string;
  97369. };
  97370. }
  97371. declare module BABYLON {
  97372. /**
  97373. * Line mesh
  97374. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  97375. */
  97376. export class LinesMesh extends Mesh {
  97377. /**
  97378. * If vertex color should be applied to the mesh
  97379. */
  97380. readonly useVertexColor?: boolean | undefined;
  97381. /**
  97382. * If vertex alpha should be applied to the mesh
  97383. */
  97384. readonly useVertexAlpha?: boolean | undefined;
  97385. /**
  97386. * Color of the line (Default: White)
  97387. */
  97388. color: Color3;
  97389. /**
  97390. * Alpha of the line (Default: 1)
  97391. */
  97392. alpha: number;
  97393. /**
  97394. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97395. * This margin is expressed in world space coordinates, so its value may vary.
  97396. * Default value is 0.1
  97397. */
  97398. intersectionThreshold: number;
  97399. private _colorShader;
  97400. private color4;
  97401. /**
  97402. * Creates a new LinesMesh
  97403. * @param name defines the name
  97404. * @param scene defines the hosting scene
  97405. * @param parent defines the parent mesh if any
  97406. * @param source defines the optional source LinesMesh used to clone data from
  97407. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  97408. * When false, achieved by calling a clone(), also passing False.
  97409. * This will make creation of children, recursive.
  97410. * @param useVertexColor defines if this LinesMesh supports vertex color
  97411. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  97412. */
  97413. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<LinesMesh>, doNotCloneChildren?: boolean,
  97414. /**
  97415. * If vertex color should be applied to the mesh
  97416. */
  97417. useVertexColor?: boolean | undefined,
  97418. /**
  97419. * If vertex alpha should be applied to the mesh
  97420. */
  97421. useVertexAlpha?: boolean | undefined);
  97422. private _addClipPlaneDefine;
  97423. private _removeClipPlaneDefine;
  97424. isReady(): boolean;
  97425. /**
  97426. * Returns the string "LineMesh"
  97427. */
  97428. getClassName(): string;
  97429. /**
  97430. * @hidden
  97431. */
  97432. get material(): Material;
  97433. /**
  97434. * @hidden
  97435. */
  97436. set material(value: Material);
  97437. /**
  97438. * @hidden
  97439. */
  97440. get checkCollisions(): boolean;
  97441. /** @hidden */
  97442. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  97443. /** @hidden */
  97444. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  97445. /**
  97446. * Disposes of the line mesh
  97447. * @param doNotRecurse If children should be disposed
  97448. */
  97449. dispose(doNotRecurse?: boolean): void;
  97450. /**
  97451. * Returns a new LineMesh object cloned from the current one.
  97452. */
  97453. clone(name: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean): LinesMesh;
  97454. /**
  97455. * Creates a new InstancedLinesMesh object from the mesh model.
  97456. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  97457. * @param name defines the name of the new instance
  97458. * @returns a new InstancedLinesMesh
  97459. */
  97460. createInstance(name: string): InstancedLinesMesh;
  97461. }
  97462. /**
  97463. * Creates an instance based on a source LinesMesh
  97464. */
  97465. export class InstancedLinesMesh extends InstancedMesh {
  97466. /**
  97467. * The intersection Threshold is the margin applied when intersection a segment of the LinesMesh with a Ray.
  97468. * This margin is expressed in world space coordinates, so its value may vary.
  97469. * Initilized with the intersectionThreshold value of the source LinesMesh
  97470. */
  97471. intersectionThreshold: number;
  97472. constructor(name: string, source: LinesMesh);
  97473. /**
  97474. * Returns the string "InstancedLinesMesh".
  97475. */
  97476. getClassName(): string;
  97477. }
  97478. }
  97479. declare module BABYLON {
  97480. /** @hidden */
  97481. export var linePixelShader: {
  97482. name: string;
  97483. shader: string;
  97484. };
  97485. }
  97486. declare module BABYLON {
  97487. /** @hidden */
  97488. export var lineVertexShader: {
  97489. name: string;
  97490. shader: string;
  97491. };
  97492. }
  97493. declare module BABYLON {
  97494. interface Scene {
  97495. /** @hidden */
  97496. _edgeRenderLineShader: Nullable<ShaderMaterial>;
  97497. }
  97498. interface AbstractMesh {
  97499. /**
  97500. * Gets the edgesRenderer associated with the mesh
  97501. */
  97502. edgesRenderer: Nullable<EdgesRenderer>;
  97503. }
  97504. interface LinesMesh {
  97505. /**
  97506. * Enables the edge rendering mode on the mesh.
  97507. * This mode makes the mesh edges visible
  97508. * @param epsilon defines the maximal distance between two angles to detect a face
  97509. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97510. * @returns the currentAbstractMesh
  97511. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97512. */
  97513. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  97514. }
  97515. interface InstancedLinesMesh {
  97516. /**
  97517. * Enables the edge rendering mode on the mesh.
  97518. * This mode makes the mesh edges visible
  97519. * @param epsilon defines the maximal distance between two angles to detect a face
  97520. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  97521. * @returns the current InstancedLinesMesh
  97522. * @see https://www.babylonjs-playground.com/#19O9TU#0
  97523. */
  97524. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): InstancedLinesMesh;
  97525. }
  97526. /**
  97527. * Defines the minimum contract an Edges renderer should follow.
  97528. */
  97529. export interface IEdgesRenderer extends IDisposable {
  97530. /**
  97531. * Gets or sets a boolean indicating if the edgesRenderer is active
  97532. */
  97533. isEnabled: boolean;
  97534. /**
  97535. * Renders the edges of the attached mesh,
  97536. */
  97537. render(): void;
  97538. /**
  97539. * Checks wether or not the edges renderer is ready to render.
  97540. * @return true if ready, otherwise false.
  97541. */
  97542. isReady(): boolean;
  97543. /**
  97544. * List of instances to render in case the source mesh has instances
  97545. */
  97546. customInstances: SmartArray<Matrix>;
  97547. }
  97548. /**
  97549. * Defines the additional options of the edges renderer
  97550. */
  97551. export interface IEdgesRendererOptions {
  97552. /**
  97553. * Gets or sets a boolean indicating that the alternate edge finder algorithm must be used
  97554. * If not defined, the default value is true
  97555. */
  97556. useAlternateEdgeFinder?: boolean;
  97557. /**
  97558. * Gets or sets a boolean indicating that the vertex merger fast processing must be used.
  97559. * If not defined, the default value is true.
  97560. * 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)
  97561. * This option is used only if useAlternateEdgeFinder = true
  97562. */
  97563. useFastVertexMerger?: boolean;
  97564. /**
  97565. * During edges processing, the vertices are merged if they are close enough: epsilonVertexMerge is the limit whithin which vertices are considered to be equal.
  97566. * The default value is 1e-6
  97567. * This option is used only if useAlternateEdgeFinder = true
  97568. */
  97569. epsilonVertexMerge?: number;
  97570. /**
  97571. * 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
  97572. * 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.
  97573. * This option is used only if useAlternateEdgeFinder = true
  97574. */
  97575. applyTessellation?: boolean;
  97576. /**
  97577. * 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
  97578. * The default value is 1e-6
  97579. * This option is used only if useAlternateEdgeFinder = true
  97580. */
  97581. epsilonVertexAligned?: number;
  97582. }
  97583. /**
  97584. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  97585. */
  97586. export class EdgesRenderer implements IEdgesRenderer {
  97587. /**
  97588. * Define the size of the edges with an orthographic camera
  97589. */
  97590. edgesWidthScalerForOrthographic: number;
  97591. /**
  97592. * Define the size of the edges with a perspective camera
  97593. */
  97594. edgesWidthScalerForPerspective: number;
  97595. protected _source: AbstractMesh;
  97596. protected _linesPositions: number[];
  97597. protected _linesNormals: number[];
  97598. protected _linesIndices: number[];
  97599. protected _epsilon: number;
  97600. protected _indicesCount: number;
  97601. protected _lineShader: ShaderMaterial;
  97602. protected _ib: DataBuffer;
  97603. protected _buffers: {
  97604. [key: string]: Nullable<VertexBuffer>;
  97605. };
  97606. protected _buffersForInstances: {
  97607. [key: string]: Nullable<VertexBuffer>;
  97608. };
  97609. protected _checkVerticesInsteadOfIndices: boolean;
  97610. protected _options: Nullable<IEdgesRendererOptions>;
  97611. private _meshRebuildObserver;
  97612. private _meshDisposeObserver;
  97613. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  97614. isEnabled: boolean;
  97615. /**
  97616. * List of instances to render in case the source mesh has instances
  97617. */
  97618. customInstances: SmartArray<Matrix>;
  97619. private static GetShader;
  97620. /**
  97621. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  97622. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  97623. * @param source Mesh used to create edges
  97624. * @param epsilon sum of angles in adjacency to check for edge
  97625. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices. Note that this parameter is not used if options.useAlternateEdgeFinder = true
  97626. * @param generateEdgesLines - should generate Lines or only prepare resources.
  97627. * @param options The options to apply when generating the edges
  97628. */
  97629. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean, generateEdgesLines?: boolean, options?: IEdgesRendererOptions);
  97630. protected _prepareRessources(): void;
  97631. /** @hidden */
  97632. _rebuild(): void;
  97633. /**
  97634. * Releases the required resources for the edges renderer
  97635. */
  97636. dispose(): void;
  97637. protected _processEdgeForAdjacencies(pa: number, pb: number, p0: number, p1: number, p2: number): number;
  97638. protected _processEdgeForAdjacenciesWithVertices(pa: Vector3, pb: Vector3, p0: Vector3, p1: Vector3, p2: Vector3): number;
  97639. /**
  97640. * Checks if the pair of p0 and p1 is en edge
  97641. * @param faceIndex
  97642. * @param edge
  97643. * @param faceNormals
  97644. * @param p0
  97645. * @param p1
  97646. * @private
  97647. */
  97648. protected _checkEdge(faceIndex: number, edge: number, faceNormals: Array<Vector3>, p0: Vector3, p1: Vector3): void;
  97649. /**
  97650. * push line into the position, normal and index buffer
  97651. * @protected
  97652. */
  97653. protected createLine(p0: Vector3, p1: Vector3, offset: number): void;
  97654. /**
  97655. * See https://playground.babylonjs.com/#R3JR6V#1 for a visual display of the algorithm
  97656. */
  97657. private _tessellateTriangle;
  97658. private _generateEdgesLinesAlternate;
  97659. /**
  97660. * Generates lines edges from adjacencjes
  97661. * @private
  97662. */
  97663. _generateEdgesLines(): void;
  97664. /**
  97665. * Checks wether or not the edges renderer is ready to render.
  97666. * @return true if ready, otherwise false.
  97667. */
  97668. isReady(): boolean;
  97669. /**
  97670. * Renders the edges of the attached mesh,
  97671. */
  97672. render(): void;
  97673. }
  97674. /**
  97675. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  97676. */
  97677. export class LineEdgesRenderer extends EdgesRenderer {
  97678. /**
  97679. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  97680. * @param source LineMesh used to generate edges
  97681. * @param epsilon not important (specified angle for edge detection)
  97682. * @param checkVerticesInsteadOfIndices not important for LineMesh
  97683. */
  97684. constructor(source: AbstractMesh, epsilon?: number, checkVerticesInsteadOfIndices?: boolean);
  97685. /**
  97686. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  97687. */
  97688. _generateEdgesLines(): void;
  97689. }
  97690. }
  97691. declare module BABYLON {
  97692. /**
  97693. * This represents the object necessary to create a rendering group.
  97694. * This is exclusively used and created by the rendering manager.
  97695. * To modify the behavior, you use the available helpers in your scene or meshes.
  97696. * @hidden
  97697. */
  97698. export class RenderingGroup {
  97699. index: number;
  97700. private static _zeroVector;
  97701. private _scene;
  97702. private _opaqueSubMeshes;
  97703. private _transparentSubMeshes;
  97704. private _alphaTestSubMeshes;
  97705. private _depthOnlySubMeshes;
  97706. private _particleSystems;
  97707. private _spriteManagers;
  97708. private _opaqueSortCompareFn;
  97709. private _alphaTestSortCompareFn;
  97710. private _transparentSortCompareFn;
  97711. private _renderOpaque;
  97712. private _renderAlphaTest;
  97713. private _renderTransparent;
  97714. /** @hidden */
  97715. _edgesRenderers: SmartArrayNoDuplicate<IEdgesRenderer>;
  97716. onBeforeTransparentRendering: () => void;
  97717. /**
  97718. * Set the opaque sort comparison function.
  97719. * If null the sub meshes will be render in the order they were created
  97720. */
  97721. set opaqueSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97722. /**
  97723. * Set the alpha test sort comparison function.
  97724. * If null the sub meshes will be render in the order they were created
  97725. */
  97726. set alphaTestSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97727. /**
  97728. * Set the transparent sort comparison function.
  97729. * If null the sub meshes will be render in the order they were created
  97730. */
  97731. set transparentSortCompareFn(value: Nullable<(a: SubMesh, b: SubMesh) => number>);
  97732. /**
  97733. * Creates a new rendering group.
  97734. * @param index The rendering group index
  97735. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  97736. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  97737. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  97738. */
  97739. 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>);
  97740. /**
  97741. * Render all the sub meshes contained in the group.
  97742. * @param customRenderFunction Used to override the default render behaviour of the group.
  97743. * @returns true if rendered some submeshes.
  97744. */
  97745. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, renderSprites: boolean, renderParticles: boolean, activeMeshes: Nullable<AbstractMesh[]>): void;
  97746. /**
  97747. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  97748. * @param subMeshes The submeshes to render
  97749. */
  97750. private renderOpaqueSorted;
  97751. /**
  97752. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  97753. * @param subMeshes The submeshes to render
  97754. */
  97755. private renderAlphaTestSorted;
  97756. /**
  97757. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  97758. * @param subMeshes The submeshes to render
  97759. */
  97760. private renderTransparentSorted;
  97761. /**
  97762. * Renders the submeshes in a specified order.
  97763. * @param subMeshes The submeshes to sort before render
  97764. * @param sortCompareFn The comparison function use to sort
  97765. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  97766. * @param transparent Specifies to activate blending if true
  97767. */
  97768. private static renderSorted;
  97769. /**
  97770. * Renders the submeshes in the order they were dispatched (no sort applied).
  97771. * @param subMeshes The submeshes to render
  97772. */
  97773. private static renderUnsorted;
  97774. /**
  97775. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97776. * are rendered back to front if in the same alpha index.
  97777. *
  97778. * @param a The first submesh
  97779. * @param b The second submesh
  97780. * @returns The result of the comparison
  97781. */
  97782. static defaultTransparentSortCompare(a: SubMesh, b: SubMesh): number;
  97783. /**
  97784. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97785. * are rendered back to front.
  97786. *
  97787. * @param a The first submesh
  97788. * @param b The second submesh
  97789. * @returns The result of the comparison
  97790. */
  97791. static backToFrontSortCompare(a: SubMesh, b: SubMesh): number;
  97792. /**
  97793. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  97794. * are rendered front to back (prevent overdraw).
  97795. *
  97796. * @param a The first submesh
  97797. * @param b The second submesh
  97798. * @returns The result of the comparison
  97799. */
  97800. static frontToBackSortCompare(a: SubMesh, b: SubMesh): number;
  97801. /**
  97802. * Resets the different lists of submeshes to prepare a new frame.
  97803. */
  97804. prepare(): void;
  97805. dispose(): void;
  97806. /**
  97807. * Inserts the submesh in its correct queue depending on its material.
  97808. * @param subMesh The submesh to dispatch
  97809. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97810. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97811. */
  97812. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97813. dispatchSprites(spriteManager: ISpriteManager): void;
  97814. dispatchParticles(particleSystem: IParticleSystem): void;
  97815. private _renderParticles;
  97816. private _renderSprites;
  97817. }
  97818. }
  97819. declare module BABYLON {
  97820. /**
  97821. * Interface describing the different options available in the rendering manager
  97822. * regarding Auto Clear between groups.
  97823. */
  97824. export interface IRenderingManagerAutoClearSetup {
  97825. /**
  97826. * Defines whether or not autoclear is enable.
  97827. */
  97828. autoClear: boolean;
  97829. /**
  97830. * Defines whether or not to autoclear the depth buffer.
  97831. */
  97832. depth: boolean;
  97833. /**
  97834. * Defines whether or not to autoclear the stencil buffer.
  97835. */
  97836. stencil: boolean;
  97837. }
  97838. /**
  97839. * This class is used by the onRenderingGroupObservable
  97840. */
  97841. export class RenderingGroupInfo {
  97842. /**
  97843. * The Scene that being rendered
  97844. */
  97845. scene: Scene;
  97846. /**
  97847. * The camera currently used for the rendering pass
  97848. */
  97849. camera: Nullable<Camera>;
  97850. /**
  97851. * The ID of the renderingGroup being processed
  97852. */
  97853. renderingGroupId: number;
  97854. }
  97855. /**
  97856. * This is the manager responsible of all the rendering for meshes sprites and particles.
  97857. * It is enable to manage the different groups as well as the different necessary sort functions.
  97858. * This should not be used directly aside of the few static configurations
  97859. */
  97860. export class RenderingManager {
  97861. /**
  97862. * The max id used for rendering groups (not included)
  97863. */
  97864. static MAX_RENDERINGGROUPS: number;
  97865. /**
  97866. * The min id used for rendering groups (included)
  97867. */
  97868. static MIN_RENDERINGGROUPS: number;
  97869. /**
  97870. * Used to globally prevent autoclearing scenes.
  97871. */
  97872. static AUTOCLEAR: boolean;
  97873. /**
  97874. * @hidden
  97875. */
  97876. _useSceneAutoClearSetup: boolean;
  97877. private _scene;
  97878. private _renderingGroups;
  97879. private _depthStencilBufferAlreadyCleaned;
  97880. private _autoClearDepthStencil;
  97881. private _customOpaqueSortCompareFn;
  97882. private _customAlphaTestSortCompareFn;
  97883. private _customTransparentSortCompareFn;
  97884. private _renderingGroupInfo;
  97885. /**
  97886. * Instantiates a new rendering group for a particular scene
  97887. * @param scene Defines the scene the groups belongs to
  97888. */
  97889. constructor(scene: Scene);
  97890. private _clearDepthStencilBuffer;
  97891. /**
  97892. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  97893. * @hidden
  97894. */
  97895. render(customRenderFunction: Nullable<(opaqueSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>) => void>, activeMeshes: Nullable<AbstractMesh[]>, renderParticles: boolean, renderSprites: boolean): void;
  97896. /**
  97897. * Resets the different information of the group to prepare a new frame
  97898. * @hidden
  97899. */
  97900. reset(): void;
  97901. /**
  97902. * Dispose and release the group and its associated resources.
  97903. * @hidden
  97904. */
  97905. dispose(): void;
  97906. /**
  97907. * Clear the info related to rendering groups preventing retention points during dispose.
  97908. */
  97909. freeRenderingGroups(): void;
  97910. private _prepareRenderingGroup;
  97911. /**
  97912. * Add a sprite manager to the rendering manager in order to render it this frame.
  97913. * @param spriteManager Define the sprite manager to render
  97914. */
  97915. dispatchSprites(spriteManager: ISpriteManager): void;
  97916. /**
  97917. * Add a particle system to the rendering manager in order to render it this frame.
  97918. * @param particleSystem Define the particle system to render
  97919. */
  97920. dispatchParticles(particleSystem: IParticleSystem): void;
  97921. /**
  97922. * Add a submesh to the manager in order to render it this frame
  97923. * @param subMesh The submesh to dispatch
  97924. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  97925. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  97926. */
  97927. dispatch(subMesh: SubMesh, mesh?: AbstractMesh, material?: Nullable<Material>): void;
  97928. /**
  97929. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  97930. * This allowed control for front to back rendering or reversly depending of the special needs.
  97931. *
  97932. * @param renderingGroupId The rendering group id corresponding to its index
  97933. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  97934. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  97935. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  97936. */
  97937. 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;
  97938. /**
  97939. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  97940. *
  97941. * @param renderingGroupId The rendering group id corresponding to its index
  97942. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  97943. * @param depth Automatically clears depth between groups if true and autoClear is true.
  97944. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  97945. */
  97946. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  97947. /**
  97948. * Gets the current auto clear configuration for one rendering group of the rendering
  97949. * manager.
  97950. * @param index the rendering group index to get the information for
  97951. * @returns The auto clear setup for the requested rendering group
  97952. */
  97953. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  97954. }
  97955. }
  97956. declare module BABYLON {
  97957. /**
  97958. * Defines the options associated with the creation of a custom shader for a shadow generator.
  97959. */
  97960. export interface ICustomShaderOptions {
  97961. /**
  97962. * Gets or sets the custom shader name to use
  97963. */
  97964. shaderName: string;
  97965. /**
  97966. * The list of attribute names used in the shader
  97967. */
  97968. attributes?: string[];
  97969. /**
  97970. * The list of unifrom names used in the shader
  97971. */
  97972. uniforms?: string[];
  97973. /**
  97974. * The list of sampler names used in the shader
  97975. */
  97976. samplers?: string[];
  97977. /**
  97978. * The list of defines used in the shader
  97979. */
  97980. defines?: string[];
  97981. }
  97982. /**
  97983. * Interface to implement to create a shadow generator compatible with BJS.
  97984. */
  97985. export interface IShadowGenerator {
  97986. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  97987. id: string;
  97988. /**
  97989. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  97990. * @returns The render target texture if present otherwise, null
  97991. */
  97992. getShadowMap(): Nullable<RenderTargetTexture>;
  97993. /**
  97994. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  97995. * @param subMesh The submesh we want to render in the shadow map
  97996. * @param useInstances Defines wether will draw in the map using instances
  97997. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  97998. * @returns true if ready otherwise, false
  97999. */
  98000. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98001. /**
  98002. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98003. * @param defines Defines of the material we want to update
  98004. * @param lightIndex Index of the light in the enabled light list of the material
  98005. */
  98006. prepareDefines(defines: MaterialDefines, lightIndex: number): void;
  98007. /**
  98008. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98009. * defined in the generator but impacting the effect).
  98010. * It implies the unifroms available on the materials are the standard BJS ones.
  98011. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98012. * @param effect The effect we are binfing the information for
  98013. */
  98014. bindShadowLight(lightIndex: string, effect: Effect): void;
  98015. /**
  98016. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98017. * (eq to shadow prjection matrix * light transform matrix)
  98018. * @returns The transform matrix used to create the shadow map
  98019. */
  98020. getTransformMatrix(): Matrix;
  98021. /**
  98022. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98023. * Cube and 2D textures for instance.
  98024. */
  98025. recreateShadowMap(): void;
  98026. /**
  98027. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98028. * @param onCompiled Callback triggered at the and of the effects compilation
  98029. * @param options Sets of optional options forcing the compilation with different modes
  98030. */
  98031. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98032. useInstances: boolean;
  98033. }>): void;
  98034. /**
  98035. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98036. * @param options Sets of optional options forcing the compilation with different modes
  98037. * @returns A promise that resolves when the compilation completes
  98038. */
  98039. forceCompilationAsync(options?: Partial<{
  98040. useInstances: boolean;
  98041. }>): Promise<void>;
  98042. /**
  98043. * Serializes the shadow generator setup to a json object.
  98044. * @returns The serialized JSON object
  98045. */
  98046. serialize(): any;
  98047. /**
  98048. * Disposes the Shadow map and related Textures and effects.
  98049. */
  98050. dispose(): void;
  98051. }
  98052. /**
  98053. * Default implementation IShadowGenerator.
  98054. * This is the main object responsible of generating shadows in the framework.
  98055. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  98056. */
  98057. export class ShadowGenerator implements IShadowGenerator {
  98058. /**
  98059. * Name of the shadow generator class
  98060. */
  98061. static CLASSNAME: string;
  98062. /**
  98063. * Shadow generator mode None: no filtering applied.
  98064. */
  98065. static readonly FILTER_NONE: number;
  98066. /**
  98067. * Shadow generator mode ESM: Exponential Shadow Mapping.
  98068. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98069. */
  98070. static readonly FILTER_EXPONENTIALSHADOWMAP: number;
  98071. /**
  98072. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  98073. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  98074. */
  98075. static readonly FILTER_POISSONSAMPLING: number;
  98076. /**
  98077. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  98078. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98079. */
  98080. static readonly FILTER_BLUREXPONENTIALSHADOWMAP: number;
  98081. /**
  98082. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  98083. * edge artifacts on steep falloff.
  98084. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98085. */
  98086. static readonly FILTER_CLOSEEXPONENTIALSHADOWMAP: number;
  98087. /**
  98088. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  98089. * edge artifacts on steep falloff.
  98090. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  98091. */
  98092. static readonly FILTER_BLURCLOSEEXPONENTIALSHADOWMAP: number;
  98093. /**
  98094. * Shadow generator mode PCF: Percentage Closer Filtering
  98095. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98096. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  98097. */
  98098. static readonly FILTER_PCF: number;
  98099. /**
  98100. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  98101. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  98102. * Contact Hardening
  98103. */
  98104. static readonly FILTER_PCSS: number;
  98105. /**
  98106. * Reserved for PCF and PCSS
  98107. * Highest Quality.
  98108. *
  98109. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  98110. *
  98111. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  98112. */
  98113. static readonly QUALITY_HIGH: number;
  98114. /**
  98115. * Reserved for PCF and PCSS
  98116. * Good tradeoff for quality/perf cross devices
  98117. *
  98118. * Execute PCF on a 3*3 kernel.
  98119. *
  98120. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  98121. */
  98122. static readonly QUALITY_MEDIUM: number;
  98123. /**
  98124. * Reserved for PCF and PCSS
  98125. * The lowest quality but the fastest.
  98126. *
  98127. * Execute PCF on a 1*1 kernel.
  98128. *
  98129. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  98130. */
  98131. static readonly QUALITY_LOW: number;
  98132. /** Gets or set the id of the shadow generator. It will be the one from the light if not defined */
  98133. id: string;
  98134. /** Gets or sets the custom shader name to use */
  98135. customShaderOptions: ICustomShaderOptions;
  98136. /**
  98137. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  98138. */
  98139. onBeforeShadowMapRenderObservable: Observable<Effect>;
  98140. /**
  98141. * Observable triggered after the shadow is rendered. Can be used to restore internal effect state
  98142. */
  98143. onAfterShadowMapRenderObservable: Observable<Effect>;
  98144. /**
  98145. * Observable triggered before a mesh is rendered in the shadow map.
  98146. * Can be used to update internal effect state (that you can get from the onBeforeShadowMapRenderObservable)
  98147. */
  98148. onBeforeShadowMapRenderMeshObservable: Observable<Mesh>;
  98149. /**
  98150. * Observable triggered after a mesh is rendered in the shadow map.
  98151. * Can be used to update internal effect state (that you can get from the onAfterShadowMapRenderObservable)
  98152. */
  98153. onAfterShadowMapRenderMeshObservable: Observable<Mesh>;
  98154. protected _bias: number;
  98155. /**
  98156. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  98157. */
  98158. get bias(): number;
  98159. /**
  98160. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  98161. */
  98162. set bias(bias: number);
  98163. protected _normalBias: number;
  98164. /**
  98165. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98166. */
  98167. get normalBias(): number;
  98168. /**
  98169. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  98170. */
  98171. set normalBias(normalBias: number);
  98172. protected _blurBoxOffset: number;
  98173. /**
  98174. * Gets the blur box offset: offset applied during the blur pass.
  98175. * Only useful if useKernelBlur = false
  98176. */
  98177. get blurBoxOffset(): number;
  98178. /**
  98179. * Sets the blur box offset: offset applied during the blur pass.
  98180. * Only useful if useKernelBlur = false
  98181. */
  98182. set blurBoxOffset(value: number);
  98183. protected _blurScale: number;
  98184. /**
  98185. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  98186. * 2 means half of the size.
  98187. */
  98188. get blurScale(): number;
  98189. /**
  98190. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  98191. * 2 means half of the size.
  98192. */
  98193. set blurScale(value: number);
  98194. protected _blurKernel: number;
  98195. /**
  98196. * Gets the blur kernel: kernel size of the blur pass.
  98197. * Only useful if useKernelBlur = true
  98198. */
  98199. get blurKernel(): number;
  98200. /**
  98201. * Sets the blur kernel: kernel size of the blur pass.
  98202. * Only useful if useKernelBlur = true
  98203. */
  98204. set blurKernel(value: number);
  98205. protected _useKernelBlur: boolean;
  98206. /**
  98207. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  98208. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98209. */
  98210. get useKernelBlur(): boolean;
  98211. /**
  98212. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  98213. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  98214. */
  98215. set useKernelBlur(value: boolean);
  98216. protected _depthScale: number;
  98217. /**
  98218. * Gets the depth scale used in ESM mode.
  98219. */
  98220. get depthScale(): number;
  98221. /**
  98222. * Sets the depth scale used in ESM mode.
  98223. * This can override the scale stored on the light.
  98224. */
  98225. set depthScale(value: number);
  98226. protected _validateFilter(filter: number): number;
  98227. protected _filter: number;
  98228. /**
  98229. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  98230. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98231. */
  98232. get filter(): number;
  98233. /**
  98234. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  98235. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  98236. */
  98237. set filter(value: number);
  98238. /**
  98239. * Gets if the current filter is set to Poisson Sampling.
  98240. */
  98241. get usePoissonSampling(): boolean;
  98242. /**
  98243. * Sets the current filter to Poisson Sampling.
  98244. */
  98245. set usePoissonSampling(value: boolean);
  98246. /**
  98247. * Gets if the current filter is set to ESM.
  98248. */
  98249. get useExponentialShadowMap(): boolean;
  98250. /**
  98251. * Sets the current filter is to ESM.
  98252. */
  98253. set useExponentialShadowMap(value: boolean);
  98254. /**
  98255. * Gets if the current filter is set to filtered ESM.
  98256. */
  98257. get useBlurExponentialShadowMap(): boolean;
  98258. /**
  98259. * Gets if the current filter is set to filtered ESM.
  98260. */
  98261. set useBlurExponentialShadowMap(value: boolean);
  98262. /**
  98263. * Gets if the current filter is set to "close ESM" (using the inverse of the
  98264. * exponential to prevent steep falloff artifacts).
  98265. */
  98266. get useCloseExponentialShadowMap(): boolean;
  98267. /**
  98268. * Sets the current filter to "close ESM" (using the inverse of the
  98269. * exponential to prevent steep falloff artifacts).
  98270. */
  98271. set useCloseExponentialShadowMap(value: boolean);
  98272. /**
  98273. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  98274. * exponential to prevent steep falloff artifacts).
  98275. */
  98276. get useBlurCloseExponentialShadowMap(): boolean;
  98277. /**
  98278. * Sets the current filter to filtered "close ESM" (using the inverse of the
  98279. * exponential to prevent steep falloff artifacts).
  98280. */
  98281. set useBlurCloseExponentialShadowMap(value: boolean);
  98282. /**
  98283. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  98284. */
  98285. get usePercentageCloserFiltering(): boolean;
  98286. /**
  98287. * Sets the current filter to "PCF" (percentage closer filtering).
  98288. */
  98289. set usePercentageCloserFiltering(value: boolean);
  98290. protected _filteringQuality: number;
  98291. /**
  98292. * Gets the PCF or PCSS Quality.
  98293. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98294. */
  98295. get filteringQuality(): number;
  98296. /**
  98297. * Sets the PCF or PCSS Quality.
  98298. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  98299. */
  98300. set filteringQuality(filteringQuality: number);
  98301. /**
  98302. * Gets if the current filter is set to "PCSS" (contact hardening).
  98303. */
  98304. get useContactHardeningShadow(): boolean;
  98305. /**
  98306. * Sets the current filter to "PCSS" (contact hardening).
  98307. */
  98308. set useContactHardeningShadow(value: boolean);
  98309. protected _contactHardeningLightSizeUVRatio: number;
  98310. /**
  98311. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98312. * Using a ratio helps keeping shape stability independently of the map size.
  98313. *
  98314. * It does not account for the light projection as it was having too much
  98315. * instability during the light setup or during light position changes.
  98316. *
  98317. * Only valid if useContactHardeningShadow is true.
  98318. */
  98319. get contactHardeningLightSizeUVRatio(): number;
  98320. /**
  98321. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  98322. * Using a ratio helps keeping shape stability independently of the map size.
  98323. *
  98324. * It does not account for the light projection as it was having too much
  98325. * instability during the light setup or during light position changes.
  98326. *
  98327. * Only valid if useContactHardeningShadow is true.
  98328. */
  98329. set contactHardeningLightSizeUVRatio(contactHardeningLightSizeUVRatio: number);
  98330. protected _darkness: number;
  98331. /** Gets or sets the actual darkness of a shadow */
  98332. get darkness(): number;
  98333. set darkness(value: number);
  98334. /**
  98335. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  98336. * 0 means strongest and 1 would means no shadow.
  98337. * @returns the darkness.
  98338. */
  98339. getDarkness(): number;
  98340. /**
  98341. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  98342. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  98343. * @returns the shadow generator allowing fluent coding.
  98344. */
  98345. setDarkness(darkness: number): ShadowGenerator;
  98346. protected _transparencyShadow: boolean;
  98347. /** Gets or sets the ability to have transparent shadow */
  98348. get transparencyShadow(): boolean;
  98349. set transparencyShadow(value: boolean);
  98350. /**
  98351. * Sets the ability to have transparent shadow (boolean).
  98352. * @param transparent True if transparent else False
  98353. * @returns the shadow generator allowing fluent coding
  98354. */
  98355. setTransparencyShadow(transparent: boolean): ShadowGenerator;
  98356. /**
  98357. * Enables or disables shadows with varying strength based on the transparency
  98358. * When it is enabled, the strength of the shadow is taken equal to mesh.visibility
  98359. * If you enabled an alpha texture on your material, the alpha value red from the texture is also combined to compute the strength:
  98360. * mesh.visibility * alphaTexture.a
  98361. * Note that by definition transparencyShadow must be set to true for enableSoftTransparentShadow to work!
  98362. */
  98363. enableSoftTransparentShadow: boolean;
  98364. protected _shadowMap: Nullable<RenderTargetTexture>;
  98365. protected _shadowMap2: Nullable<RenderTargetTexture>;
  98366. /**
  98367. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  98368. * @returns The render target texture if present otherwise, null
  98369. */
  98370. getShadowMap(): Nullable<RenderTargetTexture>;
  98371. /**
  98372. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  98373. * @returns The render target texture if the shadow map is present otherwise, null
  98374. */
  98375. getShadowMapForRendering(): Nullable<RenderTargetTexture>;
  98376. /**
  98377. * Gets the class name of that object
  98378. * @returns "ShadowGenerator"
  98379. */
  98380. getClassName(): string;
  98381. /**
  98382. * Helper function to add a mesh and its descendants to the list of shadow casters.
  98383. * @param mesh Mesh to add
  98384. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  98385. * @returns the Shadow Generator itself
  98386. */
  98387. addShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98388. /**
  98389. * Helper function to remove a mesh and its descendants from the list of shadow casters
  98390. * @param mesh Mesh to remove
  98391. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  98392. * @returns the Shadow Generator itself
  98393. */
  98394. removeShadowCaster(mesh: AbstractMesh, includeDescendants?: boolean): ShadowGenerator;
  98395. /**
  98396. * Controls the extent to which the shadows fade out at the edge of the frustum
  98397. */
  98398. frustumEdgeFalloff: number;
  98399. protected _light: IShadowLight;
  98400. /**
  98401. * Returns the associated light object.
  98402. * @returns the light generating the shadow
  98403. */
  98404. getLight(): IShadowLight;
  98405. /**
  98406. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  98407. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  98408. * It might on the other hand introduce peter panning.
  98409. */
  98410. forceBackFacesOnly: boolean;
  98411. protected _scene: Scene;
  98412. protected _lightDirection: Vector3;
  98413. protected _effect: Effect;
  98414. protected _viewMatrix: Matrix;
  98415. protected _projectionMatrix: Matrix;
  98416. protected _transformMatrix: Matrix;
  98417. protected _cachedPosition: Vector3;
  98418. protected _cachedDirection: Vector3;
  98419. protected _cachedDefines: string;
  98420. protected _currentRenderID: number;
  98421. protected _boxBlurPostprocess: Nullable<PostProcess>;
  98422. protected _kernelBlurXPostprocess: Nullable<PostProcess>;
  98423. protected _kernelBlurYPostprocess: Nullable<PostProcess>;
  98424. protected _blurPostProcesses: PostProcess[];
  98425. protected _mapSize: number;
  98426. protected _currentFaceIndex: number;
  98427. protected _currentFaceIndexCache: number;
  98428. protected _textureType: number;
  98429. protected _defaultTextureMatrix: Matrix;
  98430. protected _storedUniqueId: Nullable<number>;
  98431. /** @hidden */
  98432. static _SceneComponentInitialization: (scene: Scene) => void;
  98433. /**
  98434. * Creates a ShadowGenerator object.
  98435. * A ShadowGenerator is the required tool to use the shadows.
  98436. * Each light casting shadows needs to use its own ShadowGenerator.
  98437. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  98438. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  98439. * @param light The light object generating the shadows.
  98440. * @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.
  98441. */
  98442. constructor(mapSize: number, light: IShadowLight, usefulFloatFirst?: boolean);
  98443. protected _initializeGenerator(): void;
  98444. protected _createTargetRenderTexture(): void;
  98445. protected _initializeShadowMap(): void;
  98446. protected _initializeBlurRTTAndPostProcesses(): void;
  98447. protected _renderForShadowMap(opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>): void;
  98448. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  98449. protected _renderSubMeshForShadowMap(subMesh: SubMesh, isTransparent?: boolean): void;
  98450. protected _applyFilterValues(): void;
  98451. /**
  98452. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98453. * @param onCompiled Callback triggered at the and of the effects compilation
  98454. * @param options Sets of optional options forcing the compilation with different modes
  98455. */
  98456. forceCompilation(onCompiled?: (generator: IShadowGenerator) => void, options?: Partial<{
  98457. useInstances: boolean;
  98458. }>): void;
  98459. /**
  98460. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  98461. * @param options Sets of optional options forcing the compilation with different modes
  98462. * @returns A promise that resolves when the compilation completes
  98463. */
  98464. forceCompilationAsync(options?: Partial<{
  98465. useInstances: boolean;
  98466. }>): Promise<void>;
  98467. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  98468. private _prepareShadowDefines;
  98469. /**
  98470. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  98471. * @param subMesh The submesh we want to render in the shadow map
  98472. * @param useInstances Defines wether will draw in the map using instances
  98473. * @param isTransparent Indicates that isReady is called for a transparent subMesh
  98474. * @returns true if ready otherwise, false
  98475. */
  98476. isReady(subMesh: SubMesh, useInstances: boolean, isTransparent: boolean): boolean;
  98477. /**
  98478. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  98479. * @param defines Defines of the material we want to update
  98480. * @param lightIndex Index of the light in the enabled light list of the material
  98481. */
  98482. prepareDefines(defines: any, lightIndex: number): void;
  98483. /**
  98484. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  98485. * defined in the generator but impacting the effect).
  98486. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  98487. * @param effect The effect we are binfing the information for
  98488. */
  98489. bindShadowLight(lightIndex: string, effect: Effect): void;
  98490. /**
  98491. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  98492. * (eq to shadow prjection matrix * light transform matrix)
  98493. * @returns The transform matrix used to create the shadow map
  98494. */
  98495. getTransformMatrix(): Matrix;
  98496. /**
  98497. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  98498. * Cube and 2D textures for instance.
  98499. */
  98500. recreateShadowMap(): void;
  98501. protected _disposeBlurPostProcesses(): void;
  98502. protected _disposeRTTandPostProcesses(): void;
  98503. /**
  98504. * Disposes the ShadowGenerator.
  98505. * Returns nothing.
  98506. */
  98507. dispose(): void;
  98508. /**
  98509. * Serializes the shadow generator setup to a json object.
  98510. * @returns The serialized JSON object
  98511. */
  98512. serialize(): any;
  98513. /**
  98514. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  98515. * @param parsedShadowGenerator The JSON object to parse
  98516. * @param scene The scene to create the shadow map for
  98517. * @param constr A function that builds a shadow generator or undefined to create an instance of the default shadow generator
  98518. * @returns The parsed shadow generator
  98519. */
  98520. static Parse(parsedShadowGenerator: any, scene: Scene, constr?: (mapSize: number, light: IShadowLight) => ShadowGenerator): ShadowGenerator;
  98521. }
  98522. }
  98523. declare module BABYLON {
  98524. /**
  98525. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  98526. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  98527. * 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.
  98528. */
  98529. export abstract class Light extends Node {
  98530. /**
  98531. * Falloff Default: light is falling off following the material specification:
  98532. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  98533. */
  98534. static readonly FALLOFF_DEFAULT: number;
  98535. /**
  98536. * Falloff Physical: light is falling off following the inverse squared distance law.
  98537. */
  98538. static readonly FALLOFF_PHYSICAL: number;
  98539. /**
  98540. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  98541. * to enhance interoperability with other engines.
  98542. */
  98543. static readonly FALLOFF_GLTF: number;
  98544. /**
  98545. * Falloff Standard: light is falling off like in the standard material
  98546. * to enhance interoperability with other materials.
  98547. */
  98548. static readonly FALLOFF_STANDARD: number;
  98549. /**
  98550. * If every light affecting the material is in this lightmapMode,
  98551. * material.lightmapTexture adds or multiplies
  98552. * (depends on material.useLightmapAsShadowmap)
  98553. * after every other light calculations.
  98554. */
  98555. static readonly LIGHTMAP_DEFAULT: number;
  98556. /**
  98557. * material.lightmapTexture as only diffuse lighting from this light
  98558. * adds only specular lighting from this light
  98559. * adds dynamic shadows
  98560. */
  98561. static readonly LIGHTMAP_SPECULAR: number;
  98562. /**
  98563. * material.lightmapTexture as only lighting
  98564. * no light calculation from this light
  98565. * only adds dynamic shadows from this light
  98566. */
  98567. static readonly LIGHTMAP_SHADOWSONLY: number;
  98568. /**
  98569. * Each light type uses the default quantity according to its type:
  98570. * point/spot lights use luminous intensity
  98571. * directional lights use illuminance
  98572. */
  98573. static readonly INTENSITYMODE_AUTOMATIC: number;
  98574. /**
  98575. * lumen (lm)
  98576. */
  98577. static readonly INTENSITYMODE_LUMINOUSPOWER: number;
  98578. /**
  98579. * candela (lm/sr)
  98580. */
  98581. static readonly INTENSITYMODE_LUMINOUSINTENSITY: number;
  98582. /**
  98583. * lux (lm/m^2)
  98584. */
  98585. static readonly INTENSITYMODE_ILLUMINANCE: number;
  98586. /**
  98587. * nit (cd/m^2)
  98588. */
  98589. static readonly INTENSITYMODE_LUMINANCE: number;
  98590. /**
  98591. * Light type const id of the point light.
  98592. */
  98593. static readonly LIGHTTYPEID_POINTLIGHT: number;
  98594. /**
  98595. * Light type const id of the directional light.
  98596. */
  98597. static readonly LIGHTTYPEID_DIRECTIONALLIGHT: number;
  98598. /**
  98599. * Light type const id of the spot light.
  98600. */
  98601. static readonly LIGHTTYPEID_SPOTLIGHT: number;
  98602. /**
  98603. * Light type const id of the hemispheric light.
  98604. */
  98605. static readonly LIGHTTYPEID_HEMISPHERICLIGHT: number;
  98606. /**
  98607. * Diffuse gives the basic color to an object.
  98608. */
  98609. diffuse: Color3;
  98610. /**
  98611. * Specular produces a highlight color on an object.
  98612. * Note: This is note affecting PBR materials.
  98613. */
  98614. specular: Color3;
  98615. /**
  98616. * Defines the falloff type for this light. This lets overrriding how punctual light are
  98617. * falling off base on range or angle.
  98618. * This can be set to any values in Light.FALLOFF_x.
  98619. *
  98620. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  98621. * other types of materials.
  98622. */
  98623. falloffType: number;
  98624. /**
  98625. * Strength of the light.
  98626. * Note: By default it is define in the framework own unit.
  98627. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  98628. */
  98629. intensity: number;
  98630. private _range;
  98631. protected _inverseSquaredRange: number;
  98632. /**
  98633. * Defines how far from the source the light is impacting in scene units.
  98634. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98635. */
  98636. get range(): number;
  98637. /**
  98638. * Defines how far from the source the light is impacting in scene units.
  98639. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  98640. */
  98641. set range(value: number);
  98642. /**
  98643. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  98644. * of light.
  98645. */
  98646. private _photometricScale;
  98647. private _intensityMode;
  98648. /**
  98649. * Gets the photometric scale used to interpret the intensity.
  98650. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98651. */
  98652. get intensityMode(): number;
  98653. /**
  98654. * Sets the photometric scale used to interpret the intensity.
  98655. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  98656. */
  98657. set intensityMode(value: number);
  98658. private _radius;
  98659. /**
  98660. * Gets the light radius used by PBR Materials to simulate soft area lights.
  98661. */
  98662. get radius(): number;
  98663. /**
  98664. * sets the light radius used by PBR Materials to simulate soft area lights.
  98665. */
  98666. set radius(value: number);
  98667. private _renderPriority;
  98668. /**
  98669. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  98670. * exceeding the number allowed of the materials.
  98671. */
  98672. renderPriority: number;
  98673. private _shadowEnabled;
  98674. /**
  98675. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98676. * the current shadow generator.
  98677. */
  98678. get shadowEnabled(): boolean;
  98679. /**
  98680. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  98681. * the current shadow generator.
  98682. */
  98683. set shadowEnabled(value: boolean);
  98684. private _includedOnlyMeshes;
  98685. /**
  98686. * Gets the only meshes impacted by this light.
  98687. */
  98688. get includedOnlyMeshes(): AbstractMesh[];
  98689. /**
  98690. * Sets the only meshes impacted by this light.
  98691. */
  98692. set includedOnlyMeshes(value: AbstractMesh[]);
  98693. private _excludedMeshes;
  98694. /**
  98695. * Gets the meshes not impacted by this light.
  98696. */
  98697. get excludedMeshes(): AbstractMesh[];
  98698. /**
  98699. * Sets the meshes not impacted by this light.
  98700. */
  98701. set excludedMeshes(value: AbstractMesh[]);
  98702. private _excludeWithLayerMask;
  98703. /**
  98704. * Gets the layer id use to find what meshes are not impacted by the light.
  98705. * Inactive if 0
  98706. */
  98707. get excludeWithLayerMask(): number;
  98708. /**
  98709. * Sets the layer id use to find what meshes are not impacted by the light.
  98710. * Inactive if 0
  98711. */
  98712. set excludeWithLayerMask(value: number);
  98713. private _includeOnlyWithLayerMask;
  98714. /**
  98715. * Gets the layer id use to find what meshes are impacted by the light.
  98716. * Inactive if 0
  98717. */
  98718. get includeOnlyWithLayerMask(): number;
  98719. /**
  98720. * Sets the layer id use to find what meshes are impacted by the light.
  98721. * Inactive if 0
  98722. */
  98723. set includeOnlyWithLayerMask(value: number);
  98724. private _lightmapMode;
  98725. /**
  98726. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98727. */
  98728. get lightmapMode(): number;
  98729. /**
  98730. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  98731. */
  98732. set lightmapMode(value: number);
  98733. /**
  98734. * Shadow generator associted to the light.
  98735. * @hidden Internal use only.
  98736. */
  98737. _shadowGenerator: Nullable<IShadowGenerator>;
  98738. /**
  98739. * @hidden Internal use only.
  98740. */
  98741. _excludedMeshesIds: string[];
  98742. /**
  98743. * @hidden Internal use only.
  98744. */
  98745. _includedOnlyMeshesIds: string[];
  98746. /**
  98747. * The current light unifom buffer.
  98748. * @hidden Internal use only.
  98749. */
  98750. _uniformBuffer: UniformBuffer;
  98751. /** @hidden */
  98752. _renderId: number;
  98753. /**
  98754. * Creates a Light object in the scene.
  98755. * Documentation : https://doc.babylonjs.com/babylon101/lights
  98756. * @param name The firendly name of the light
  98757. * @param scene The scene the light belongs too
  98758. */
  98759. constructor(name: string, scene: Scene);
  98760. protected abstract _buildUniformLayout(): void;
  98761. /**
  98762. * Sets the passed Effect "effect" with the Light information.
  98763. * @param effect The effect to update
  98764. * @param lightIndex The index of the light in the effect to update
  98765. * @returns The light
  98766. */
  98767. abstract transferToEffect(effect: Effect, lightIndex: string): Light;
  98768. /**
  98769. * Sets the passed Effect "effect" with the Light textures.
  98770. * @param effect The effect to update
  98771. * @param lightIndex The index of the light in the effect to update
  98772. * @returns The light
  98773. */
  98774. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  98775. /**
  98776. * Binds the lights information from the scene to the effect for the given mesh.
  98777. * @param lightIndex Light index
  98778. * @param scene The scene where the light belongs to
  98779. * @param effect The effect we are binding the data to
  98780. * @param useSpecular Defines if specular is supported
  98781. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  98782. */
  98783. _bindLight(lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  98784. /**
  98785. * Sets the passed Effect "effect" with the Light information.
  98786. * @param effect The effect to update
  98787. * @param lightDataUniformName The uniform used to store light data (position or direction)
  98788. * @returns The light
  98789. */
  98790. abstract transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  98791. /**
  98792. * Returns the string "Light".
  98793. * @returns the class name
  98794. */
  98795. getClassName(): string;
  98796. /** @hidden */
  98797. readonly _isLight: boolean;
  98798. /**
  98799. * Converts the light information to a readable string for debug purpose.
  98800. * @param fullDetails Supports for multiple levels of logging within scene loading
  98801. * @returns the human readable light info
  98802. */
  98803. toString(fullDetails?: boolean): string;
  98804. /** @hidden */
  98805. protected _syncParentEnabledState(): void;
  98806. /**
  98807. * Set the enabled state of this node.
  98808. * @param value - the new enabled state
  98809. */
  98810. setEnabled(value: boolean): void;
  98811. /**
  98812. * Returns the Light associated shadow generator if any.
  98813. * @return the associated shadow generator.
  98814. */
  98815. getShadowGenerator(): Nullable<IShadowGenerator>;
  98816. /**
  98817. * Returns a Vector3, the absolute light position in the World.
  98818. * @returns the world space position of the light
  98819. */
  98820. getAbsolutePosition(): Vector3;
  98821. /**
  98822. * Specifies if the light will affect the passed mesh.
  98823. * @param mesh The mesh to test against the light
  98824. * @return true the mesh is affected otherwise, false.
  98825. */
  98826. canAffectMesh(mesh: AbstractMesh): boolean;
  98827. /**
  98828. * Sort function to order lights for rendering.
  98829. * @param a First Light object to compare to second.
  98830. * @param b Second Light object to compare first.
  98831. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  98832. */
  98833. static CompareLightsPriority(a: Light, b: Light): number;
  98834. /**
  98835. * Releases resources associated with this node.
  98836. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  98837. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  98838. */
  98839. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  98840. /**
  98841. * Returns the light type ID (integer).
  98842. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  98843. */
  98844. getTypeID(): number;
  98845. /**
  98846. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  98847. * @returns the scaled intensity in intensity mode unit
  98848. */
  98849. getScaledIntensity(): number;
  98850. /**
  98851. * Returns a new Light object, named "name", from the current one.
  98852. * @param name The name of the cloned light
  98853. * @param newParent The parent of this light, if it has one
  98854. * @returns the new created light
  98855. */
  98856. clone(name: string, newParent?: Nullable<Node>): Nullable<Light>;
  98857. /**
  98858. * Serializes the current light into a Serialization object.
  98859. * @returns the serialized object.
  98860. */
  98861. serialize(): any;
  98862. /**
  98863. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  98864. * This new light is named "name" and added to the passed scene.
  98865. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  98866. * @param name The friendly name of the light
  98867. * @param scene The scene the new light will belong to
  98868. * @returns the constructor function
  98869. */
  98870. static GetConstructorFromName(type: number, name: string, scene: Scene): Nullable<() => Light>;
  98871. /**
  98872. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  98873. * @param parsedLight The JSON representation of the light
  98874. * @param scene The scene to create the parsed light in
  98875. * @returns the created light after parsing
  98876. */
  98877. static Parse(parsedLight: any, scene: Scene): Nullable<Light>;
  98878. private _hookArrayForExcluded;
  98879. private _hookArrayForIncludedOnly;
  98880. private _resyncMeshes;
  98881. /**
  98882. * Forces the meshes to update their light related information in their rendering used effects
  98883. * @hidden Internal Use Only
  98884. */
  98885. _markMeshesAsLightDirty(): void;
  98886. /**
  98887. * Recomputes the cached photometric scale if needed.
  98888. */
  98889. private _computePhotometricScale;
  98890. /**
  98891. * Returns the Photometric Scale according to the light type and intensity mode.
  98892. */
  98893. private _getPhotometricScale;
  98894. /**
  98895. * Reorder the light in the scene according to their defined priority.
  98896. * @hidden Internal Use Only
  98897. */
  98898. _reorderLightsInScene(): void;
  98899. /**
  98900. * Prepares the list of defines specific to the light type.
  98901. * @param defines the list of defines
  98902. * @param lightIndex defines the index of the light for the effect
  98903. */
  98904. abstract prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  98905. }
  98906. }
  98907. declare module BABYLON {
  98908. /**
  98909. * Configuration needed for prepass-capable materials
  98910. */
  98911. export class PrePassConfiguration {
  98912. /**
  98913. * Previous world matrices of meshes carrying this material
  98914. * Used for computing velocity
  98915. */
  98916. previousWorldMatrices: {
  98917. [index: number]: Matrix;
  98918. };
  98919. /**
  98920. * Previous view project matrix
  98921. * Used for computing velocity
  98922. */
  98923. previousViewProjection: Matrix;
  98924. /**
  98925. * Previous bones of meshes carrying this material
  98926. * Used for computing velocity
  98927. */
  98928. previousBones: {
  98929. [index: number]: Float32Array;
  98930. };
  98931. /**
  98932. * Add the required uniforms to the current list.
  98933. * @param uniforms defines the current uniform list.
  98934. */
  98935. static AddUniforms(uniforms: string[]): void;
  98936. /**
  98937. * Add the required samplers to the current list.
  98938. * @param samplers defines the current sampler list.
  98939. */
  98940. static AddSamplers(samplers: string[]): void;
  98941. /**
  98942. * Binds the material data.
  98943. * @param effect defines the effect to update
  98944. * @param scene defines the scene the material belongs to.
  98945. * @param mesh The mesh
  98946. * @param world World matrix of this mesh
  98947. * @param isFrozen Is the material frozen
  98948. */
  98949. bindForSubMesh(effect: Effect, scene: Scene, mesh: Mesh, world: Matrix, isFrozen: boolean): void;
  98950. }
  98951. }
  98952. declare module BABYLON {
  98953. /**
  98954. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  98955. * This is the base of the follow, arc rotate cameras and Free camera
  98956. * @see https://doc.babylonjs.com/features/cameras
  98957. */
  98958. export class TargetCamera extends Camera {
  98959. private static _RigCamTransformMatrix;
  98960. private static _TargetTransformMatrix;
  98961. private static _TargetFocalPoint;
  98962. private _tmpUpVector;
  98963. private _tmpTargetVector;
  98964. /**
  98965. * Define the current direction the camera is moving to
  98966. */
  98967. cameraDirection: Vector3;
  98968. /**
  98969. * Define the current rotation the camera is rotating to
  98970. */
  98971. cameraRotation: Vector2;
  98972. /** Gets or sets a boolean indicating that the scaling of the parent hierarchy will not be taken in account by the camera */
  98973. ignoreParentScaling: boolean;
  98974. /**
  98975. * When set, the up vector of the camera will be updated by the rotation of the camera
  98976. */
  98977. updateUpVectorFromRotation: boolean;
  98978. private _tmpQuaternion;
  98979. /**
  98980. * Define the current rotation of the camera
  98981. */
  98982. rotation: Vector3;
  98983. /**
  98984. * Define the current rotation of the camera as a quaternion to prevent Gimbal lock
  98985. */
  98986. rotationQuaternion: Quaternion;
  98987. /**
  98988. * Define the current speed of the camera
  98989. */
  98990. speed: number;
  98991. /**
  98992. * Add constraint to the camera to prevent it to move freely in all directions and
  98993. * around all axis.
  98994. */
  98995. noRotationConstraint: boolean;
  98996. /**
  98997. * Reverses mouselook direction to 'natural' panning as opposed to traditional direct
  98998. * panning
  98999. */
  99000. invertRotation: boolean;
  99001. /**
  99002. * Speed multiplier for inverse camera panning
  99003. */
  99004. inverseRotationSpeed: number;
  99005. /**
  99006. * Define the current target of the camera as an object or a position.
  99007. */
  99008. lockedTarget: any;
  99009. /** @hidden */
  99010. _currentTarget: Vector3;
  99011. /** @hidden */
  99012. _initialFocalDistance: number;
  99013. /** @hidden */
  99014. _viewMatrix: Matrix;
  99015. /** @hidden */
  99016. _camMatrix: Matrix;
  99017. /** @hidden */
  99018. _cameraTransformMatrix: Matrix;
  99019. /** @hidden */
  99020. _cameraRotationMatrix: Matrix;
  99021. /** @hidden */
  99022. _referencePoint: Vector3;
  99023. /** @hidden */
  99024. _transformedReferencePoint: Vector3;
  99025. /** @hidden */
  99026. _reset: () => void;
  99027. private _defaultUp;
  99028. /**
  99029. * Instantiates a target camera that takes a mesh or position as a target and continues to look at it while it moves.
  99030. * This is the base of the follow, arc rotate cameras and Free camera
  99031. * @see https://doc.babylonjs.com/features/cameras
  99032. * @param name Defines the name of the camera in the scene
  99033. * @param position Defines the start position of the camera in the scene
  99034. * @param scene Defines the scene the camera belongs to
  99035. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99036. */
  99037. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99038. /**
  99039. * Gets the position in front of the camera at a given distance.
  99040. * @param distance The distance from the camera we want the position to be
  99041. * @returns the position
  99042. */
  99043. getFrontPosition(distance: number): Vector3;
  99044. /** @hidden */
  99045. _getLockedTargetPosition(): Nullable<Vector3>;
  99046. private _storedPosition;
  99047. private _storedRotation;
  99048. private _storedRotationQuaternion;
  99049. /**
  99050. * Store current camera state of the camera (fov, position, rotation, etc..)
  99051. * @returns the camera
  99052. */
  99053. storeState(): Camera;
  99054. /**
  99055. * Restored camera state. You must call storeState() first
  99056. * @returns whether it was successful or not
  99057. * @hidden
  99058. */
  99059. _restoreStateValues(): boolean;
  99060. /** @hidden */
  99061. _initCache(): void;
  99062. /** @hidden */
  99063. _updateCache(ignoreParentClass?: boolean): void;
  99064. /** @hidden */
  99065. _isSynchronizedViewMatrix(): boolean;
  99066. /** @hidden */
  99067. _computeLocalCameraSpeed(): number;
  99068. /**
  99069. * Defines the target the camera should look at.
  99070. * @param target Defines the new target as a Vector or a mesh
  99071. */
  99072. setTarget(target: Vector3): void;
  99073. /**
  99074. * Defines the target point of the camera.
  99075. * The camera looks towards it form the radius distance.
  99076. */
  99077. get target(): Vector3;
  99078. set target(value: Vector3);
  99079. /**
  99080. * Return the current target position of the camera. This value is expressed in local space.
  99081. * @returns the target position
  99082. */
  99083. getTarget(): Vector3;
  99084. /** @hidden */
  99085. _decideIfNeedsToMove(): boolean;
  99086. /** @hidden */
  99087. _updatePosition(): void;
  99088. /** @hidden */
  99089. _checkInputs(): void;
  99090. protected _updateCameraRotationMatrix(): void;
  99091. /**
  99092. * 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)
  99093. * @returns the current camera
  99094. */
  99095. private _rotateUpVectorWithCameraRotationMatrix;
  99096. private _cachedRotationZ;
  99097. private _cachedQuaternionRotationZ;
  99098. /** @hidden */
  99099. _getViewMatrix(): Matrix;
  99100. protected _computeViewMatrix(position: Vector3, target: Vector3, up: Vector3): void;
  99101. /**
  99102. * @hidden
  99103. */
  99104. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  99105. /**
  99106. * @hidden
  99107. */
  99108. _updateRigCameras(): void;
  99109. private _getRigCamPositionAndTarget;
  99110. /**
  99111. * Gets the current object class name.
  99112. * @return the class name
  99113. */
  99114. getClassName(): string;
  99115. }
  99116. }
  99117. declare module BABYLON {
  99118. /**
  99119. * Gather the list of keyboard event types as constants.
  99120. */
  99121. export class KeyboardEventTypes {
  99122. /**
  99123. * The keydown event is fired when a key becomes active (pressed).
  99124. */
  99125. static readonly KEYDOWN: number;
  99126. /**
  99127. * The keyup event is fired when a key has been released.
  99128. */
  99129. static readonly KEYUP: number;
  99130. }
  99131. /**
  99132. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99133. */
  99134. export class KeyboardInfo {
  99135. /**
  99136. * Defines the type of event (KeyboardEventTypes)
  99137. */
  99138. type: number;
  99139. /**
  99140. * Defines the related dom event
  99141. */
  99142. event: KeyboardEvent;
  99143. /**
  99144. * Instantiates a new keyboard info.
  99145. * This class is used to store keyboard related info for the onKeyboardObservable event.
  99146. * @param type Defines the type of event (KeyboardEventTypes)
  99147. * @param event Defines the related dom event
  99148. */
  99149. constructor(
  99150. /**
  99151. * Defines the type of event (KeyboardEventTypes)
  99152. */
  99153. type: number,
  99154. /**
  99155. * Defines the related dom event
  99156. */
  99157. event: KeyboardEvent);
  99158. }
  99159. /**
  99160. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99161. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  99162. */
  99163. export class KeyboardInfoPre extends KeyboardInfo {
  99164. /**
  99165. * Defines the type of event (KeyboardEventTypes)
  99166. */
  99167. type: number;
  99168. /**
  99169. * Defines the related dom event
  99170. */
  99171. event: KeyboardEvent;
  99172. /**
  99173. * Defines whether the engine should skip the next onKeyboardObservable associated to this pre.
  99174. */
  99175. skipOnPointerObservable: boolean;
  99176. /**
  99177. * Instantiates a new keyboard pre info.
  99178. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  99179. * @param type Defines the type of event (KeyboardEventTypes)
  99180. * @param event Defines the related dom event
  99181. */
  99182. constructor(
  99183. /**
  99184. * Defines the type of event (KeyboardEventTypes)
  99185. */
  99186. type: number,
  99187. /**
  99188. * Defines the related dom event
  99189. */
  99190. event: KeyboardEvent);
  99191. }
  99192. }
  99193. declare module BABYLON {
  99194. /**
  99195. * Manage the keyboard inputs to control the movement of a free camera.
  99196. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99197. */
  99198. export class FreeCameraKeyboardMoveInput implements ICameraInput<FreeCamera> {
  99199. /**
  99200. * Defines the camera the input is attached to.
  99201. */
  99202. camera: FreeCamera;
  99203. /**
  99204. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99205. */
  99206. keysUp: number[];
  99207. /**
  99208. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99209. */
  99210. keysUpward: number[];
  99211. /**
  99212. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99213. */
  99214. keysDown: number[];
  99215. /**
  99216. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99217. */
  99218. keysDownward: number[];
  99219. /**
  99220. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99221. */
  99222. keysLeft: number[];
  99223. /**
  99224. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99225. */
  99226. keysRight: number[];
  99227. private _keys;
  99228. private _onCanvasBlurObserver;
  99229. private _onKeyboardObserver;
  99230. private _engine;
  99231. private _scene;
  99232. /**
  99233. * Attach the input controls to a specific dom element to get the input from.
  99234. * @param element Defines the element the controls should be listened from
  99235. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99236. */
  99237. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99238. /**
  99239. * Detach the current controls from the specified dom element.
  99240. * @param element Defines the element to stop listening the inputs from
  99241. */
  99242. detachControl(element: Nullable<HTMLElement>): void;
  99243. /**
  99244. * Update the current camera state depending on the inputs that have been used this frame.
  99245. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99246. */
  99247. checkInputs(): void;
  99248. /**
  99249. * Gets the class name of the current intput.
  99250. * @returns the class name
  99251. */
  99252. getClassName(): string;
  99253. /** @hidden */
  99254. _onLostFocus(): void;
  99255. /**
  99256. * Get the friendly name associated with the input class.
  99257. * @returns the input friendly name
  99258. */
  99259. getSimpleName(): string;
  99260. }
  99261. }
  99262. declare module BABYLON {
  99263. /**
  99264. * Gather the list of pointer event types as constants.
  99265. */
  99266. export class PointerEventTypes {
  99267. /**
  99268. * 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.
  99269. */
  99270. static readonly POINTERDOWN: number;
  99271. /**
  99272. * The pointerup event is fired when a pointer is no longer active.
  99273. */
  99274. static readonly POINTERUP: number;
  99275. /**
  99276. * The pointermove event is fired when a pointer changes coordinates.
  99277. */
  99278. static readonly POINTERMOVE: number;
  99279. /**
  99280. * The pointerwheel event is fired when a mouse wheel has been rotated.
  99281. */
  99282. static readonly POINTERWHEEL: number;
  99283. /**
  99284. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  99285. */
  99286. static readonly POINTERPICK: number;
  99287. /**
  99288. * The pointertap event is fired when a the object has been touched and released without drag.
  99289. */
  99290. static readonly POINTERTAP: number;
  99291. /**
  99292. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  99293. */
  99294. static readonly POINTERDOUBLETAP: number;
  99295. }
  99296. /**
  99297. * Base class of pointer info types.
  99298. */
  99299. export class PointerInfoBase {
  99300. /**
  99301. * Defines the type of event (PointerEventTypes)
  99302. */
  99303. type: number;
  99304. /**
  99305. * Defines the related dom event
  99306. */
  99307. event: PointerEvent | MouseWheelEvent;
  99308. /**
  99309. * Instantiates the base class of pointers info.
  99310. * @param type Defines the type of event (PointerEventTypes)
  99311. * @param event Defines the related dom event
  99312. */
  99313. constructor(
  99314. /**
  99315. * Defines the type of event (PointerEventTypes)
  99316. */
  99317. type: number,
  99318. /**
  99319. * Defines the related dom event
  99320. */
  99321. event: PointerEvent | MouseWheelEvent);
  99322. }
  99323. /**
  99324. * This class is used to store pointer related info for the onPrePointerObservable event.
  99325. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  99326. */
  99327. export class PointerInfoPre extends PointerInfoBase {
  99328. /**
  99329. * Ray from a pointer if availible (eg. 6dof controller)
  99330. */
  99331. ray: Nullable<Ray>;
  99332. /**
  99333. * Defines the local position of the pointer on the canvas.
  99334. */
  99335. localPosition: Vector2;
  99336. /**
  99337. * Defines whether the engine should skip the next OnPointerObservable associated to this pre.
  99338. */
  99339. skipOnPointerObservable: boolean;
  99340. /**
  99341. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  99342. * @param type Defines the type of event (PointerEventTypes)
  99343. * @param event Defines the related dom event
  99344. * @param localX Defines the local x coordinates of the pointer when the event occured
  99345. * @param localY Defines the local y coordinates of the pointer when the event occured
  99346. */
  99347. constructor(type: number, event: PointerEvent | MouseWheelEvent, localX: number, localY: number);
  99348. }
  99349. /**
  99350. * This type contains all the data related to a pointer event in Babylon.js.
  99351. * 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.
  99352. */
  99353. export class PointerInfo extends PointerInfoBase {
  99354. /**
  99355. * Defines the picking info associated to the info (if any)\
  99356. */
  99357. pickInfo: Nullable<PickingInfo>;
  99358. /**
  99359. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  99360. * @param type Defines the type of event (PointerEventTypes)
  99361. * @param event Defines the related dom event
  99362. * @param pickInfo Defines the picking info associated to the info (if any)\
  99363. */
  99364. constructor(type: number, event: PointerEvent | MouseWheelEvent,
  99365. /**
  99366. * Defines the picking info associated to the info (if any)\
  99367. */
  99368. pickInfo: Nullable<PickingInfo>);
  99369. }
  99370. /**
  99371. * Data relating to a touch event on the screen.
  99372. */
  99373. export interface PointerTouch {
  99374. /**
  99375. * X coordinate of touch.
  99376. */
  99377. x: number;
  99378. /**
  99379. * Y coordinate of touch.
  99380. */
  99381. y: number;
  99382. /**
  99383. * Id of touch. Unique for each finger.
  99384. */
  99385. pointerId: number;
  99386. /**
  99387. * Event type passed from DOM.
  99388. */
  99389. type: any;
  99390. }
  99391. }
  99392. declare module BABYLON {
  99393. /**
  99394. * Manage the mouse inputs to control the movement of a free camera.
  99395. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99396. */
  99397. export class FreeCameraMouseInput implements ICameraInput<FreeCamera> {
  99398. /**
  99399. * Define if touch is enabled in the mouse input
  99400. */
  99401. touchEnabled: boolean;
  99402. /**
  99403. * Defines the camera the input is attached to.
  99404. */
  99405. camera: FreeCamera;
  99406. /**
  99407. * Defines the buttons associated with the input to handle camera move.
  99408. */
  99409. buttons: number[];
  99410. /**
  99411. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  99412. */
  99413. angularSensibility: number;
  99414. private _pointerInput;
  99415. private _onMouseMove;
  99416. private _observer;
  99417. private previousPosition;
  99418. /**
  99419. * Observable for when a pointer move event occurs containing the move offset
  99420. */
  99421. onPointerMovedObservable: Observable<{
  99422. offsetX: number;
  99423. offsetY: number;
  99424. }>;
  99425. /**
  99426. * @hidden
  99427. * If the camera should be rotated automatically based on pointer movement
  99428. */
  99429. _allowCameraRotation: boolean;
  99430. /**
  99431. * Manage the mouse inputs to control the movement of a free camera.
  99432. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99433. * @param touchEnabled Defines if touch is enabled or not
  99434. */
  99435. constructor(
  99436. /**
  99437. * Define if touch is enabled in the mouse input
  99438. */
  99439. touchEnabled?: boolean);
  99440. /**
  99441. * Attach the input controls to a specific dom element to get the input from.
  99442. * @param element Defines the element the controls should be listened from
  99443. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99444. */
  99445. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99446. /**
  99447. * Called on JS contextmenu event.
  99448. * Override this method to provide functionality.
  99449. */
  99450. protected onContextMenu(evt: PointerEvent): void;
  99451. /**
  99452. * Detach the current controls from the specified dom element.
  99453. * @param element Defines the element to stop listening the inputs from
  99454. */
  99455. detachControl(element: Nullable<HTMLElement>): void;
  99456. /**
  99457. * Gets the class name of the current intput.
  99458. * @returns the class name
  99459. */
  99460. getClassName(): string;
  99461. /**
  99462. * Get the friendly name associated with the input class.
  99463. * @returns the input friendly name
  99464. */
  99465. getSimpleName(): string;
  99466. }
  99467. }
  99468. declare module BABYLON {
  99469. /**
  99470. * Manage the touch inputs to control the movement of a free camera.
  99471. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99472. */
  99473. export class FreeCameraTouchInput implements ICameraInput<FreeCamera> {
  99474. /**
  99475. * Define if mouse events can be treated as touch events
  99476. */
  99477. allowMouse: boolean;
  99478. /**
  99479. * Defines the camera the input is attached to.
  99480. */
  99481. camera: FreeCamera;
  99482. /**
  99483. * Defines the touch sensibility for rotation.
  99484. * The higher the faster.
  99485. */
  99486. touchAngularSensibility: number;
  99487. /**
  99488. * Defines the touch sensibility for move.
  99489. * The higher the faster.
  99490. */
  99491. touchMoveSensibility: number;
  99492. private _offsetX;
  99493. private _offsetY;
  99494. private _pointerPressed;
  99495. private _pointerInput;
  99496. private _observer;
  99497. private _onLostFocus;
  99498. /**
  99499. * Manage the touch inputs to control the movement of a free camera.
  99500. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99501. * @param allowMouse Defines if mouse events can be treated as touch events
  99502. */
  99503. constructor(
  99504. /**
  99505. * Define if mouse events can be treated as touch events
  99506. */
  99507. allowMouse?: boolean);
  99508. /**
  99509. * Attach the input controls to a specific dom element to get the input from.
  99510. * @param element Defines the element the controls should be listened from
  99511. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99512. */
  99513. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99514. /**
  99515. * Detach the current controls from the specified dom element.
  99516. * @param element Defines the element to stop listening the inputs from
  99517. */
  99518. detachControl(element: Nullable<HTMLElement>): void;
  99519. /**
  99520. * Update the current camera state depending on the inputs that have been used this frame.
  99521. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  99522. */
  99523. checkInputs(): void;
  99524. /**
  99525. * Gets the class name of the current intput.
  99526. * @returns the class name
  99527. */
  99528. getClassName(): string;
  99529. /**
  99530. * Get the friendly name associated with the input class.
  99531. * @returns the input friendly name
  99532. */
  99533. getSimpleName(): string;
  99534. }
  99535. }
  99536. declare module BABYLON {
  99537. /**
  99538. * Default Inputs manager for the FreeCamera.
  99539. * It groups all the default supported inputs for ease of use.
  99540. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  99541. */
  99542. export class FreeCameraInputsManager extends CameraInputsManager<FreeCamera> {
  99543. /**
  99544. * @hidden
  99545. */
  99546. _mouseInput: Nullable<FreeCameraMouseInput>;
  99547. /**
  99548. * Instantiates a new FreeCameraInputsManager.
  99549. * @param camera Defines the camera the inputs belong to
  99550. */
  99551. constructor(camera: FreeCamera);
  99552. /**
  99553. * Add keyboard input support to the input manager.
  99554. * @returns the current input manager
  99555. */
  99556. addKeyboard(): FreeCameraInputsManager;
  99557. /**
  99558. * Add mouse input support to the input manager.
  99559. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  99560. * @returns the current input manager
  99561. */
  99562. addMouse(touchEnabled?: boolean): FreeCameraInputsManager;
  99563. /**
  99564. * Removes the mouse input support from the manager
  99565. * @returns the current input manager
  99566. */
  99567. removeMouse(): FreeCameraInputsManager;
  99568. /**
  99569. * Add touch input support to the input manager.
  99570. * @returns the current input manager
  99571. */
  99572. addTouch(): FreeCameraInputsManager;
  99573. /**
  99574. * Remove all attached input methods from a camera
  99575. */
  99576. clear(): void;
  99577. }
  99578. }
  99579. declare module BABYLON {
  99580. /**
  99581. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99582. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  99583. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99584. */
  99585. export class FreeCamera extends TargetCamera {
  99586. /**
  99587. * Define the collision ellipsoid of the camera.
  99588. * This is helpful to simulate a camera body like the player body around the camera
  99589. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  99590. */
  99591. ellipsoid: Vector3;
  99592. /**
  99593. * Define an offset for the position of the ellipsoid around the camera.
  99594. * This can be helpful to determine the center of the body near the gravity center of the body
  99595. * instead of its head.
  99596. */
  99597. ellipsoidOffset: Vector3;
  99598. /**
  99599. * Enable or disable collisions of the camera with the rest of the scene objects.
  99600. */
  99601. checkCollisions: boolean;
  99602. /**
  99603. * Enable or disable gravity on the camera.
  99604. */
  99605. applyGravity: boolean;
  99606. /**
  99607. * Define the input manager associated to the camera.
  99608. */
  99609. inputs: FreeCameraInputsManager;
  99610. /**
  99611. * Gets the input sensibility for a mouse input. (default is 2000.0)
  99612. * Higher values reduce sensitivity.
  99613. */
  99614. get angularSensibility(): number;
  99615. /**
  99616. * Sets the input sensibility for a mouse input. (default is 2000.0)
  99617. * Higher values reduce sensitivity.
  99618. */
  99619. set angularSensibility(value: number);
  99620. /**
  99621. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  99622. */
  99623. get keysUp(): number[];
  99624. set keysUp(value: number[]);
  99625. /**
  99626. * Gets or Set the list of keyboard keys used to control the upward move of the camera.
  99627. */
  99628. get keysUpward(): number[];
  99629. set keysUpward(value: number[]);
  99630. /**
  99631. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  99632. */
  99633. get keysDown(): number[];
  99634. set keysDown(value: number[]);
  99635. /**
  99636. * Gets or Set the list of keyboard keys used to control the downward move of the camera.
  99637. */
  99638. get keysDownward(): number[];
  99639. set keysDownward(value: number[]);
  99640. /**
  99641. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  99642. */
  99643. get keysLeft(): number[];
  99644. set keysLeft(value: number[]);
  99645. /**
  99646. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  99647. */
  99648. get keysRight(): number[];
  99649. set keysRight(value: number[]);
  99650. /**
  99651. * Event raised when the camera collide with a mesh in the scene.
  99652. */
  99653. onCollide: (collidedMesh: AbstractMesh) => void;
  99654. private _collider;
  99655. private _needMoveForGravity;
  99656. private _oldPosition;
  99657. private _diffPosition;
  99658. private _newPosition;
  99659. /** @hidden */
  99660. _localDirection: Vector3;
  99661. /** @hidden */
  99662. _transformedDirection: Vector3;
  99663. /**
  99664. * Instantiates a Free Camera.
  99665. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  99666. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  99667. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  99668. * @param name Define the name of the camera in the scene
  99669. * @param position Define the start position of the camera in the scene
  99670. * @param scene Define the scene the camera belongs to
  99671. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  99672. */
  99673. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  99674. /**
  99675. * Attached controls to the current camera.
  99676. * @param element Defines the element the controls should be listened from
  99677. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  99678. */
  99679. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  99680. /**
  99681. * Detach the current controls from the camera.
  99682. * The camera will stop reacting to inputs.
  99683. * @param element Defines the element to stop listening the inputs from
  99684. */
  99685. detachControl(element: HTMLElement): void;
  99686. private _collisionMask;
  99687. /**
  99688. * Define a collision mask to limit the list of object the camera can collide with
  99689. */
  99690. get collisionMask(): number;
  99691. set collisionMask(mask: number);
  99692. /** @hidden */
  99693. _collideWithWorld(displacement: Vector3): void;
  99694. private _onCollisionPositionChange;
  99695. /** @hidden */
  99696. _checkInputs(): void;
  99697. /** @hidden */
  99698. _decideIfNeedsToMove(): boolean;
  99699. /** @hidden */
  99700. _updatePosition(): void;
  99701. /**
  99702. * Destroy the camera and release the current resources hold by it.
  99703. */
  99704. dispose(): void;
  99705. /**
  99706. * Gets the current object class name.
  99707. * @return the class name
  99708. */
  99709. getClassName(): string;
  99710. }
  99711. }
  99712. declare module BABYLON {
  99713. /**
  99714. * Represents a gamepad control stick position
  99715. */
  99716. export class StickValues {
  99717. /**
  99718. * The x component of the control stick
  99719. */
  99720. x: number;
  99721. /**
  99722. * The y component of the control stick
  99723. */
  99724. y: number;
  99725. /**
  99726. * Initializes the gamepad x and y control stick values
  99727. * @param x The x component of the gamepad control stick value
  99728. * @param y The y component of the gamepad control stick value
  99729. */
  99730. constructor(
  99731. /**
  99732. * The x component of the control stick
  99733. */
  99734. x: number,
  99735. /**
  99736. * The y component of the control stick
  99737. */
  99738. y: number);
  99739. }
  99740. /**
  99741. * An interface which manages callbacks for gamepad button changes
  99742. */
  99743. export interface GamepadButtonChanges {
  99744. /**
  99745. * Called when a gamepad has been changed
  99746. */
  99747. changed: boolean;
  99748. /**
  99749. * Called when a gamepad press event has been triggered
  99750. */
  99751. pressChanged: boolean;
  99752. /**
  99753. * Called when a touch event has been triggered
  99754. */
  99755. touchChanged: boolean;
  99756. /**
  99757. * Called when a value has changed
  99758. */
  99759. valueChanged: boolean;
  99760. }
  99761. /**
  99762. * Represents a gamepad
  99763. */
  99764. export class Gamepad {
  99765. /**
  99766. * The id of the gamepad
  99767. */
  99768. id: string;
  99769. /**
  99770. * The index of the gamepad
  99771. */
  99772. index: number;
  99773. /**
  99774. * The browser gamepad
  99775. */
  99776. browserGamepad: any;
  99777. /**
  99778. * Specifies what type of gamepad this represents
  99779. */
  99780. type: number;
  99781. private _leftStick;
  99782. private _rightStick;
  99783. /** @hidden */
  99784. _isConnected: boolean;
  99785. private _leftStickAxisX;
  99786. private _leftStickAxisY;
  99787. private _rightStickAxisX;
  99788. private _rightStickAxisY;
  99789. /**
  99790. * Triggered when the left control stick has been changed
  99791. */
  99792. private _onleftstickchanged;
  99793. /**
  99794. * Triggered when the right control stick has been changed
  99795. */
  99796. private _onrightstickchanged;
  99797. /**
  99798. * Represents a gamepad controller
  99799. */
  99800. static GAMEPAD: number;
  99801. /**
  99802. * Represents a generic controller
  99803. */
  99804. static GENERIC: number;
  99805. /**
  99806. * Represents an XBox controller
  99807. */
  99808. static XBOX: number;
  99809. /**
  99810. * Represents a pose-enabled controller
  99811. */
  99812. static POSE_ENABLED: number;
  99813. /**
  99814. * Represents an Dual Shock controller
  99815. */
  99816. static DUALSHOCK: number;
  99817. /**
  99818. * Specifies whether the left control stick should be Y-inverted
  99819. */
  99820. protected _invertLeftStickY: boolean;
  99821. /**
  99822. * Specifies if the gamepad has been connected
  99823. */
  99824. get isConnected(): boolean;
  99825. /**
  99826. * Initializes the gamepad
  99827. * @param id The id of the gamepad
  99828. * @param index The index of the gamepad
  99829. * @param browserGamepad The browser gamepad
  99830. * @param leftStickX The x component of the left joystick
  99831. * @param leftStickY The y component of the left joystick
  99832. * @param rightStickX The x component of the right joystick
  99833. * @param rightStickY The y component of the right joystick
  99834. */
  99835. constructor(
  99836. /**
  99837. * The id of the gamepad
  99838. */
  99839. id: string,
  99840. /**
  99841. * The index of the gamepad
  99842. */
  99843. index: number,
  99844. /**
  99845. * The browser gamepad
  99846. */
  99847. browserGamepad: any, leftStickX?: number, leftStickY?: number, rightStickX?: number, rightStickY?: number);
  99848. /**
  99849. * Callback triggered when the left joystick has changed
  99850. * @param callback
  99851. */
  99852. onleftstickchanged(callback: (values: StickValues) => void): void;
  99853. /**
  99854. * Callback triggered when the right joystick has changed
  99855. * @param callback
  99856. */
  99857. onrightstickchanged(callback: (values: StickValues) => void): void;
  99858. /**
  99859. * Gets the left joystick
  99860. */
  99861. get leftStick(): StickValues;
  99862. /**
  99863. * Sets the left joystick values
  99864. */
  99865. set leftStick(newValues: StickValues);
  99866. /**
  99867. * Gets the right joystick
  99868. */
  99869. get rightStick(): StickValues;
  99870. /**
  99871. * Sets the right joystick value
  99872. */
  99873. set rightStick(newValues: StickValues);
  99874. /**
  99875. * Updates the gamepad joystick positions
  99876. */
  99877. update(): void;
  99878. /**
  99879. * Disposes the gamepad
  99880. */
  99881. dispose(): void;
  99882. }
  99883. /**
  99884. * Represents a generic gamepad
  99885. */
  99886. export class GenericPad extends Gamepad {
  99887. private _buttons;
  99888. private _onbuttondown;
  99889. private _onbuttonup;
  99890. /**
  99891. * Observable triggered when a button has been pressed
  99892. */
  99893. onButtonDownObservable: Observable<number>;
  99894. /**
  99895. * Observable triggered when a button has been released
  99896. */
  99897. onButtonUpObservable: Observable<number>;
  99898. /**
  99899. * Callback triggered when a button has been pressed
  99900. * @param callback Called when a button has been pressed
  99901. */
  99902. onbuttondown(callback: (buttonPressed: number) => void): void;
  99903. /**
  99904. * Callback triggered when a button has been released
  99905. * @param callback Called when a button has been released
  99906. */
  99907. onbuttonup(callback: (buttonReleased: number) => void): void;
  99908. /**
  99909. * Initializes the generic gamepad
  99910. * @param id The id of the generic gamepad
  99911. * @param index The index of the generic gamepad
  99912. * @param browserGamepad The browser gamepad
  99913. */
  99914. constructor(id: string, index: number, browserGamepad: any);
  99915. private _setButtonValue;
  99916. /**
  99917. * Updates the generic gamepad
  99918. */
  99919. update(): void;
  99920. /**
  99921. * Disposes the generic gamepad
  99922. */
  99923. dispose(): void;
  99924. }
  99925. }
  99926. declare module BABYLON {
  99927. /**
  99928. * Defines the types of pose enabled controllers that are supported
  99929. */
  99930. export enum PoseEnabledControllerType {
  99931. /**
  99932. * HTC Vive
  99933. */
  99934. VIVE = 0,
  99935. /**
  99936. * Oculus Rift
  99937. */
  99938. OCULUS = 1,
  99939. /**
  99940. * Windows mixed reality
  99941. */
  99942. WINDOWS = 2,
  99943. /**
  99944. * Samsung gear VR
  99945. */
  99946. GEAR_VR = 3,
  99947. /**
  99948. * Google Daydream
  99949. */
  99950. DAYDREAM = 4,
  99951. /**
  99952. * Generic
  99953. */
  99954. GENERIC = 5
  99955. }
  99956. /**
  99957. * Defines the MutableGamepadButton interface for the state of a gamepad button
  99958. */
  99959. export interface MutableGamepadButton {
  99960. /**
  99961. * Value of the button/trigger
  99962. */
  99963. value: number;
  99964. /**
  99965. * If the button/trigger is currently touched
  99966. */
  99967. touched: boolean;
  99968. /**
  99969. * If the button/trigger is currently pressed
  99970. */
  99971. pressed: boolean;
  99972. }
  99973. /**
  99974. * Defines the ExtendedGamepadButton interface for a gamepad button which includes state provided by a pose controller
  99975. * @hidden
  99976. */
  99977. export interface ExtendedGamepadButton extends GamepadButton {
  99978. /**
  99979. * If the button/trigger is currently pressed
  99980. */
  99981. readonly pressed: boolean;
  99982. /**
  99983. * If the button/trigger is currently touched
  99984. */
  99985. readonly touched: boolean;
  99986. /**
  99987. * Value of the button/trigger
  99988. */
  99989. readonly value: number;
  99990. }
  99991. /** @hidden */
  99992. export interface _GamePadFactory {
  99993. /**
  99994. * Returns whether or not the current gamepad can be created for this type of controller.
  99995. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  99996. * @returns true if it can be created, otherwise false
  99997. */
  99998. canCreate(gamepadInfo: any): boolean;
  99999. /**
  100000. * Creates a new instance of the Gamepad.
  100001. * @param gamepadInfo Defines the gamepad info as received from the controller APIs.
  100002. * @returns the new gamepad instance
  100003. */
  100004. create(gamepadInfo: any): Gamepad;
  100005. }
  100006. /**
  100007. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100008. */
  100009. export class PoseEnabledControllerHelper {
  100010. /** @hidden */
  100011. static _ControllerFactories: _GamePadFactory[];
  100012. /** @hidden */
  100013. static _DefaultControllerFactory: Nullable<(gamepadInfo: any) => Gamepad>;
  100014. /**
  100015. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  100016. * @param vrGamepad the gamepad to initialized
  100017. * @returns a vr controller of the type the gamepad identified as
  100018. */
  100019. static InitiateController(vrGamepad: any): Gamepad;
  100020. }
  100021. /**
  100022. * Defines the PoseEnabledController object that contains state of a vr capable controller
  100023. */
  100024. export class PoseEnabledController extends Gamepad implements PoseControlled {
  100025. /**
  100026. * If the controller is used in a webXR session
  100027. */
  100028. isXR: boolean;
  100029. private _deviceRoomPosition;
  100030. private _deviceRoomRotationQuaternion;
  100031. /**
  100032. * The device position in babylon space
  100033. */
  100034. devicePosition: Vector3;
  100035. /**
  100036. * The device rotation in babylon space
  100037. */
  100038. deviceRotationQuaternion: Quaternion;
  100039. /**
  100040. * The scale factor of the device in babylon space
  100041. */
  100042. deviceScaleFactor: number;
  100043. /**
  100044. * (Likely devicePosition should be used instead) The device position in its room space
  100045. */
  100046. position: Vector3;
  100047. /**
  100048. * (Likely deviceRotationQuaternion should be used instead) The device rotation in its room space
  100049. */
  100050. rotationQuaternion: Quaternion;
  100051. /**
  100052. * The type of controller (Eg. Windows mixed reality)
  100053. */
  100054. controllerType: PoseEnabledControllerType;
  100055. protected _calculatedPosition: Vector3;
  100056. private _calculatedRotation;
  100057. /**
  100058. * The raw pose from the device
  100059. */
  100060. rawPose: DevicePose;
  100061. private _trackPosition;
  100062. private _maxRotationDistFromHeadset;
  100063. private _draggedRoomRotation;
  100064. /**
  100065. * @hidden
  100066. */
  100067. _disableTrackPosition(fixedPosition: Vector3): void;
  100068. /**
  100069. * Internal, the mesh attached to the controller
  100070. * @hidden
  100071. */
  100072. _mesh: Nullable<AbstractMesh>;
  100073. private _poseControlledCamera;
  100074. private _leftHandSystemQuaternion;
  100075. /**
  100076. * Internal, matrix used to convert room space to babylon space
  100077. * @hidden
  100078. */
  100079. _deviceToWorld: Matrix;
  100080. /**
  100081. * Node to be used when casting a ray from the controller
  100082. * @hidden
  100083. */
  100084. _pointingPoseNode: Nullable<TransformNode>;
  100085. /**
  100086. * Name of the child mesh that can be used to cast a ray from the controller
  100087. */
  100088. static readonly POINTING_POSE: string;
  100089. /**
  100090. * Creates a new PoseEnabledController from a gamepad
  100091. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  100092. */
  100093. constructor(browserGamepad: any);
  100094. private _workingMatrix;
  100095. /**
  100096. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  100097. */
  100098. update(): void;
  100099. /**
  100100. * Updates only the pose device and mesh without doing any button event checking
  100101. */
  100102. protected _updatePoseAndMesh(): void;
  100103. /**
  100104. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  100105. * @param poseData raw pose fromthe device
  100106. */
  100107. updateFromDevice(poseData: DevicePose): void;
  100108. /**
  100109. * @hidden
  100110. */
  100111. _meshAttachedObservable: Observable<AbstractMesh>;
  100112. /**
  100113. * Attaches a mesh to the controller
  100114. * @param mesh the mesh to be attached
  100115. */
  100116. attachToMesh(mesh: AbstractMesh): void;
  100117. /**
  100118. * Attaches the controllers mesh to a camera
  100119. * @param camera the camera the mesh should be attached to
  100120. */
  100121. attachToPoseControlledCamera(camera: TargetCamera): void;
  100122. /**
  100123. * Disposes of the controller
  100124. */
  100125. dispose(): void;
  100126. /**
  100127. * The mesh that is attached to the controller
  100128. */
  100129. get mesh(): Nullable<AbstractMesh>;
  100130. /**
  100131. * Gets the ray of the controller in the direction the controller is pointing
  100132. * @param length the length the resulting ray should be
  100133. * @returns a ray in the direction the controller is pointing
  100134. */
  100135. getForwardRay(length?: number): Ray;
  100136. }
  100137. }
  100138. declare module BABYLON {
  100139. /**
  100140. * Defines the WebVRController object that represents controllers tracked in 3D space
  100141. */
  100142. export abstract class WebVRController extends PoseEnabledController {
  100143. /**
  100144. * Internal, the default controller model for the controller
  100145. */
  100146. protected _defaultModel: Nullable<AbstractMesh>;
  100147. /**
  100148. * Fired when the trigger state has changed
  100149. */
  100150. onTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  100151. /**
  100152. * Fired when the main button state has changed
  100153. */
  100154. onMainButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100155. /**
  100156. * Fired when the secondary button state has changed
  100157. */
  100158. onSecondaryButtonStateChangedObservable: Observable<ExtendedGamepadButton>;
  100159. /**
  100160. * Fired when the pad state has changed
  100161. */
  100162. onPadStateChangedObservable: Observable<ExtendedGamepadButton>;
  100163. /**
  100164. * Fired when controllers stick values have changed
  100165. */
  100166. onPadValuesChangedObservable: Observable<StickValues>;
  100167. /**
  100168. * Array of button availible on the controller
  100169. */
  100170. protected _buttons: Array<MutableGamepadButton>;
  100171. private _onButtonStateChange;
  100172. /**
  100173. * Fired when a controller button's state has changed
  100174. * @param callback the callback containing the button that was modified
  100175. */
  100176. onButtonStateChange(callback: (controlledIndex: number, buttonIndex: number, state: ExtendedGamepadButton) => void): void;
  100177. /**
  100178. * X and Y axis corresponding to the controllers joystick
  100179. */
  100180. pad: StickValues;
  100181. /**
  100182. * 'left' or 'right', see https://w3c.github.io/gamepad/extensions.html#gamepadhand-enum
  100183. */
  100184. hand: string;
  100185. /**
  100186. * The default controller model for the controller
  100187. */
  100188. get defaultModel(): Nullable<AbstractMesh>;
  100189. /**
  100190. * Creates a new WebVRController from a gamepad
  100191. * @param vrGamepad the gamepad that the WebVRController should be created from
  100192. */
  100193. constructor(vrGamepad: any);
  100194. /**
  100195. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  100196. */
  100197. update(): void;
  100198. /**
  100199. * Function to be called when a button is modified
  100200. */
  100201. protected abstract _handleButtonChange(buttonIdx: number, value: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  100202. /**
  100203. * Loads a mesh and attaches it to the controller
  100204. * @param scene the scene the mesh should be added to
  100205. * @param meshLoaded callback for when the mesh has been loaded
  100206. */
  100207. abstract initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  100208. private _setButtonValue;
  100209. private _changes;
  100210. private _checkChanges;
  100211. /**
  100212. * Disposes of th webVRCOntroller
  100213. */
  100214. dispose(): void;
  100215. }
  100216. }
  100217. declare module BABYLON {
  100218. /**
  100219. * The HemisphericLight simulates the ambient environment light,
  100220. * so the passed direction is the light reflection direction, not the incoming direction.
  100221. */
  100222. export class HemisphericLight extends Light {
  100223. /**
  100224. * The groundColor is the light in the opposite direction to the one specified during creation.
  100225. * 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.
  100226. */
  100227. groundColor: Color3;
  100228. /**
  100229. * The light reflection direction, not the incoming direction.
  100230. */
  100231. direction: Vector3;
  100232. /**
  100233. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  100234. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  100235. * The HemisphericLight can't cast shadows.
  100236. * Documentation : https://doc.babylonjs.com/babylon101/lights
  100237. * @param name The friendly name of the light
  100238. * @param direction The direction of the light reflection
  100239. * @param scene The scene the light belongs to
  100240. */
  100241. constructor(name: string, direction: Vector3, scene: Scene);
  100242. protected _buildUniformLayout(): void;
  100243. /**
  100244. * Returns the string "HemisphericLight".
  100245. * @return The class name
  100246. */
  100247. getClassName(): string;
  100248. /**
  100249. * Sets the HemisphericLight direction towards the passed target (Vector3).
  100250. * Returns the updated direction.
  100251. * @param target The target the direction should point to
  100252. * @return The computed direction
  100253. */
  100254. setDirectionToTarget(target: Vector3): Vector3;
  100255. /**
  100256. * Returns the shadow generator associated to the light.
  100257. * @returns Always null for hemispheric lights because it does not support shadows.
  100258. */
  100259. getShadowGenerator(): Nullable<IShadowGenerator>;
  100260. /**
  100261. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  100262. * @param effect The effect to update
  100263. * @param lightIndex The index of the light in the effect to update
  100264. * @returns The hemispheric light
  100265. */
  100266. transferToEffect(effect: Effect, lightIndex: string): HemisphericLight;
  100267. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  100268. /**
  100269. * Computes the world matrix of the node
  100270. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  100271. * @param useWasUpdatedFlag defines a reserved property
  100272. * @returns the world matrix
  100273. */
  100274. computeWorldMatrix(): Matrix;
  100275. /**
  100276. * Returns the integer 3.
  100277. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  100278. */
  100279. getTypeID(): number;
  100280. /**
  100281. * Prepares the list of defines specific to the light type.
  100282. * @param defines the list of defines
  100283. * @param lightIndex defines the index of the light for the effect
  100284. */
  100285. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  100286. }
  100287. }
  100288. declare module BABYLON {
  100289. /** @hidden */
  100290. export var vrMultiviewToSingleviewPixelShader: {
  100291. name: string;
  100292. shader: string;
  100293. };
  100294. }
  100295. declare module BABYLON {
  100296. /**
  100297. * Renders to multiple views with a single draw call
  100298. * @see https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/
  100299. */
  100300. export class MultiviewRenderTarget extends RenderTargetTexture {
  100301. /**
  100302. * Creates a multiview render target
  100303. * @param scene scene used with the render target
  100304. * @param size the size of the render target (used for each view)
  100305. */
  100306. constructor(scene: Scene, size?: number | {
  100307. width: number;
  100308. height: number;
  100309. } | {
  100310. ratio: number;
  100311. });
  100312. /**
  100313. * @hidden
  100314. * @param faceIndex the face index, if its a cube texture
  100315. */
  100316. _bindFrameBuffer(faceIndex?: number): void;
  100317. /**
  100318. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  100319. * @returns the view count
  100320. */
  100321. getViewCount(): number;
  100322. }
  100323. }
  100324. declare module BABYLON {
  100325. interface Engine {
  100326. /**
  100327. * Creates a new multiview render target
  100328. * @param width defines the width of the texture
  100329. * @param height defines the height of the texture
  100330. * @returns the created multiview texture
  100331. */
  100332. createMultiviewRenderTargetTexture(width: number, height: number): InternalTexture;
  100333. /**
  100334. * Binds a multiview framebuffer to be drawn to
  100335. * @param multiviewTexture texture to bind
  100336. */
  100337. bindMultiviewFramebuffer(multiviewTexture: InternalTexture): void;
  100338. }
  100339. interface Camera {
  100340. /**
  100341. * @hidden
  100342. * 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)
  100343. */
  100344. _useMultiviewToSingleView: boolean;
  100345. /**
  100346. * @hidden
  100347. * 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)
  100348. */
  100349. _multiviewTexture: Nullable<RenderTargetTexture>;
  100350. /**
  100351. * @hidden
  100352. * ensures the multiview texture of the camera exists and has the specified width/height
  100353. * @param width height to set on the multiview texture
  100354. * @param height width to set on the multiview texture
  100355. */
  100356. _resizeOrCreateMultiviewTexture(width: number, height: number): void;
  100357. }
  100358. interface Scene {
  100359. /** @hidden */
  100360. _transformMatrixR: Matrix;
  100361. /** @hidden */
  100362. _multiviewSceneUbo: Nullable<UniformBuffer>;
  100363. /** @hidden */
  100364. _createMultiviewUbo(): void;
  100365. /** @hidden */
  100366. _updateMultiviewUbo(viewR?: Matrix, projectionR?: Matrix): void;
  100367. /** @hidden */
  100368. _renderMultiviewToSingleView(camera: Camera): void;
  100369. }
  100370. }
  100371. declare module BABYLON {
  100372. /**
  100373. * VRMultiviewToSingleview used to convert multiview texture arrays to standard textures for scenarios such as webVR
  100374. * This will not be used for webXR as it supports displaying texture arrays directly
  100375. */
  100376. export class VRMultiviewToSingleviewPostProcess extends PostProcess {
  100377. /**
  100378. * Gets a string identifying the name of the class
  100379. * @returns "VRMultiviewToSingleviewPostProcess" string
  100380. */
  100381. getClassName(): string;
  100382. /**
  100383. * Initializes a VRMultiviewToSingleview
  100384. * @param name name of the post process
  100385. * @param camera camera to be applied to
  100386. * @param scaleFactor scaling factor to the size of the output texture
  100387. */
  100388. constructor(name: string, camera: Camera, scaleFactor: number);
  100389. }
  100390. }
  100391. declare module BABYLON {
  100392. /**
  100393. * Interface used to define additional presentation attributes
  100394. */
  100395. export interface IVRPresentationAttributes {
  100396. /**
  100397. * Defines a boolean indicating that we want to get 72hz mode on Oculus Browser (default is off eg. 60hz)
  100398. */
  100399. highRefreshRate: boolean;
  100400. /**
  100401. * Enables foveation in VR to improve perf. 0 none, 1 low, 2 medium, 3 high (Default is 1)
  100402. */
  100403. foveationLevel: number;
  100404. }
  100405. interface Engine {
  100406. /** @hidden */
  100407. _vrDisplay: any;
  100408. /** @hidden */
  100409. _vrSupported: boolean;
  100410. /** @hidden */
  100411. _oldSize: Size;
  100412. /** @hidden */
  100413. _oldHardwareScaleFactor: number;
  100414. /** @hidden */
  100415. _vrExclusivePointerMode: boolean;
  100416. /** @hidden */
  100417. _webVRInitPromise: Promise<IDisplayChangedEventArgs>;
  100418. /** @hidden */
  100419. _onVRDisplayPointerRestricted: () => void;
  100420. /** @hidden */
  100421. _onVRDisplayPointerUnrestricted: () => void;
  100422. /** @hidden */
  100423. _onVrDisplayConnect: Nullable<(display: any) => void>;
  100424. /** @hidden */
  100425. _onVrDisplayDisconnect: Nullable<() => void>;
  100426. /** @hidden */
  100427. _onVrDisplayPresentChange: Nullable<() => void>;
  100428. /**
  100429. * Observable signaled when VR display mode changes
  100430. */
  100431. onVRDisplayChangedObservable: Observable<IDisplayChangedEventArgs>;
  100432. /**
  100433. * Observable signaled when VR request present is complete
  100434. */
  100435. onVRRequestPresentComplete: Observable<boolean>;
  100436. /**
  100437. * Observable signaled when VR request present starts
  100438. */
  100439. onVRRequestPresentStart: Observable<Engine>;
  100440. /**
  100441. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  100442. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  100443. */
  100444. isInVRExclusivePointerMode: boolean;
  100445. /**
  100446. * Gets a boolean indicating if a webVR device was detected
  100447. * @returns true if a webVR device was detected
  100448. */
  100449. isVRDevicePresent(): boolean;
  100450. /**
  100451. * Gets the current webVR device
  100452. * @returns the current webVR device (or null)
  100453. */
  100454. getVRDevice(): any;
  100455. /**
  100456. * Initializes a webVR display and starts listening to display change events
  100457. * The onVRDisplayChangedObservable will be notified upon these changes
  100458. * @returns A promise containing a VRDisplay and if vr is supported
  100459. */
  100460. initWebVRAsync(): Promise<IDisplayChangedEventArgs>;
  100461. /** @hidden */
  100462. _getVRDisplaysAsync(): Promise<IDisplayChangedEventArgs>;
  100463. /**
  100464. * Gets or sets the presentation attributes used to configure VR rendering
  100465. */
  100466. vrPresentationAttributes?: IVRPresentationAttributes;
  100467. /**
  100468. * Call this function to switch to webVR mode
  100469. * Will do nothing if webVR is not supported or if there is no webVR device
  100470. * @param options the webvr options provided to the camera. mainly used for multiview
  100471. * @see https://doc.babylonjs.com/how_to/webvr_camera
  100472. */
  100473. enableVR(options: WebVROptions): void;
  100474. /** @hidden */
  100475. _onVRFullScreenTriggered(): void;
  100476. }
  100477. }
  100478. declare module BABYLON {
  100479. /**
  100480. * This is a copy of VRPose. See https://developer.mozilla.org/en-US/docs/Web/API/VRPose
  100481. * IMPORTANT!! The data is right-hand data.
  100482. * @export
  100483. * @interface DevicePose
  100484. */
  100485. export interface DevicePose {
  100486. /**
  100487. * The position of the device, values in array are [x,y,z].
  100488. */
  100489. readonly position: Nullable<Float32Array>;
  100490. /**
  100491. * The linearVelocity of the device, values in array are [x,y,z].
  100492. */
  100493. readonly linearVelocity: Nullable<Float32Array>;
  100494. /**
  100495. * The linearAcceleration of the device, values in array are [x,y,z].
  100496. */
  100497. readonly linearAcceleration: Nullable<Float32Array>;
  100498. /**
  100499. * The orientation of the device in a quaternion array, values in array are [x,y,z,w].
  100500. */
  100501. readonly orientation: Nullable<Float32Array>;
  100502. /**
  100503. * The angularVelocity of the device, values in array are [x,y,z].
  100504. */
  100505. readonly angularVelocity: Nullable<Float32Array>;
  100506. /**
  100507. * The angularAcceleration of the device, values in array are [x,y,z].
  100508. */
  100509. readonly angularAcceleration: Nullable<Float32Array>;
  100510. }
  100511. /**
  100512. * Interface representing a pose controlled object in Babylon.
  100513. * A pose controlled object has both regular pose values as well as pose values
  100514. * from an external device such as a VR head mounted display
  100515. */
  100516. export interface PoseControlled {
  100517. /**
  100518. * The position of the object in babylon space.
  100519. */
  100520. position: Vector3;
  100521. /**
  100522. * The rotation quaternion of the object in babylon space.
  100523. */
  100524. rotationQuaternion: Quaternion;
  100525. /**
  100526. * The position of the device in babylon space.
  100527. */
  100528. devicePosition?: Vector3;
  100529. /**
  100530. * The rotation quaternion of the device in babylon space.
  100531. */
  100532. deviceRotationQuaternion: Quaternion;
  100533. /**
  100534. * The raw pose coming from the device.
  100535. */
  100536. rawPose: Nullable<DevicePose>;
  100537. /**
  100538. * The scale of the device to be used when translating from device space to babylon space.
  100539. */
  100540. deviceScaleFactor: number;
  100541. /**
  100542. * Updates the poseControlled values based on the input device pose.
  100543. * @param poseData the pose data to update the object with
  100544. */
  100545. updateFromDevice(poseData: DevicePose): void;
  100546. }
  100547. /**
  100548. * Set of options to customize the webVRCamera
  100549. */
  100550. export interface WebVROptions {
  100551. /**
  100552. * Sets if the webVR camera should be tracked to the vrDevice. (default: true)
  100553. */
  100554. trackPosition?: boolean;
  100555. /**
  100556. * Sets the scale of the vrDevice in babylon space. (default: 1)
  100557. */
  100558. positionScale?: number;
  100559. /**
  100560. * If there are more than one VRDisplays, this will choose the display matching this name. (default: pick first vrDisplay)
  100561. */
  100562. displayName?: string;
  100563. /**
  100564. * Should the native controller meshes be initialized. (default: true)
  100565. */
  100566. controllerMeshes?: boolean;
  100567. /**
  100568. * Creating a default HemiLight only on controllers. (default: true)
  100569. */
  100570. defaultLightingOnControllers?: boolean;
  100571. /**
  100572. * If you don't want to use the default VR button of the helper. (default: false)
  100573. */
  100574. useCustomVRButton?: boolean;
  100575. /**
  100576. * If you'd like to provide your own button to the VRHelper. (default: standard babylon vr button)
  100577. */
  100578. customVRButton?: HTMLButtonElement;
  100579. /**
  100580. * To change the length of the ray for gaze/controllers. Will be scaled by positionScale. (default: 100)
  100581. */
  100582. rayLength?: number;
  100583. /**
  100584. * To change the default offset from the ground to account for user's height in meters. Will be scaled by positionScale. (default: 1.7)
  100585. */
  100586. defaultHeight?: number;
  100587. /**
  100588. * If multiview should be used if availible (default: false)
  100589. */
  100590. useMultiview?: boolean;
  100591. }
  100592. /**
  100593. * This represents a WebVR camera.
  100594. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  100595. * @example https://doc.babylonjs.com/how_to/webvr_camera
  100596. */
  100597. export class WebVRFreeCamera extends FreeCamera implements PoseControlled {
  100598. private webVROptions;
  100599. /**
  100600. * @hidden
  100601. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  100602. */
  100603. _vrDevice: any;
  100604. /**
  100605. * The rawPose of the vrDevice.
  100606. */
  100607. rawPose: Nullable<DevicePose>;
  100608. private _onVREnabled;
  100609. private _specsVersion;
  100610. private _attached;
  100611. private _frameData;
  100612. protected _descendants: Array<Node>;
  100613. private _deviceRoomPosition;
  100614. /** @hidden */
  100615. _deviceRoomRotationQuaternion: Quaternion;
  100616. private _standingMatrix;
  100617. /**
  100618. * Represents device position in babylon space.
  100619. */
  100620. devicePosition: Vector3;
  100621. /**
  100622. * Represents device rotation in babylon space.
  100623. */
  100624. deviceRotationQuaternion: Quaternion;
  100625. /**
  100626. * The scale of the device to be used when translating from device space to babylon space.
  100627. */
  100628. deviceScaleFactor: number;
  100629. private _deviceToWorld;
  100630. private _worldToDevice;
  100631. /**
  100632. * References to the webVR controllers for the vrDevice.
  100633. */
  100634. controllers: Array<WebVRController>;
  100635. /**
  100636. * Emits an event when a controller is attached.
  100637. */
  100638. onControllersAttachedObservable: Observable<WebVRController[]>;
  100639. /**
  100640. * Emits an event when a controller's mesh has been loaded;
  100641. */
  100642. onControllerMeshLoadedObservable: Observable<WebVRController>;
  100643. /**
  100644. * Emits an event when the HMD's pose has been updated.
  100645. */
  100646. onPoseUpdatedFromDeviceObservable: Observable<any>;
  100647. private _poseSet;
  100648. /**
  100649. * If the rig cameras be used as parent instead of this camera.
  100650. */
  100651. rigParenting: boolean;
  100652. private _lightOnControllers;
  100653. private _defaultHeight?;
  100654. /**
  100655. * Instantiates a WebVRFreeCamera.
  100656. * @param name The name of the WebVRFreeCamera
  100657. * @param position The starting anchor position for the camera
  100658. * @param scene The scene the camera belongs to
  100659. * @param webVROptions a set of customizable options for the webVRCamera
  100660. */
  100661. constructor(name: string, position: Vector3, scene: Scene, webVROptions?: WebVROptions);
  100662. /**
  100663. * Gets the device distance from the ground in meters.
  100664. * @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.
  100665. */
  100666. deviceDistanceToRoomGround(): number;
  100667. /**
  100668. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100669. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  100670. */
  100671. useStandingMatrix(callback?: (bool: boolean) => void): void;
  100672. /**
  100673. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  100674. * @returns A promise with a boolean set to if the standing matrix is supported.
  100675. */
  100676. useStandingMatrixAsync(): Promise<boolean>;
  100677. /**
  100678. * Disposes the camera
  100679. */
  100680. dispose(): void;
  100681. /**
  100682. * Gets a vrController by name.
  100683. * @param name The name of the controller to retreive
  100684. * @returns the controller matching the name specified or null if not found
  100685. */
  100686. getControllerByName(name: string): Nullable<WebVRController>;
  100687. private _leftController;
  100688. /**
  100689. * The controller corresponding to the users left hand.
  100690. */
  100691. get leftController(): Nullable<WebVRController>;
  100692. private _rightController;
  100693. /**
  100694. * The controller corresponding to the users right hand.
  100695. */
  100696. get rightController(): Nullable<WebVRController>;
  100697. /**
  100698. * Casts a ray forward from the vrCamera's gaze.
  100699. * @param length Length of the ray (default: 100)
  100700. * @returns the ray corresponding to the gaze
  100701. */
  100702. getForwardRay(length?: number): Ray;
  100703. /**
  100704. * @hidden
  100705. * Updates the camera based on device's frame data
  100706. */
  100707. _checkInputs(): void;
  100708. /**
  100709. * Updates the poseControlled values based on the input device pose.
  100710. * @param poseData Pose coming from the device
  100711. */
  100712. updateFromDevice(poseData: DevicePose): void;
  100713. private _htmlElementAttached;
  100714. private _detachIfAttached;
  100715. /**
  100716. * WebVR's attach control will start broadcasting frames to the device.
  100717. * Note that in certain browsers (chrome for example) this function must be called
  100718. * within a user-interaction callback. Example:
  100719. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  100720. *
  100721. * @param element html element to attach the vrDevice to
  100722. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  100723. */
  100724. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  100725. /**
  100726. * Detaches the camera from the html element and disables VR
  100727. *
  100728. * @param element html element to detach from
  100729. */
  100730. detachControl(element: HTMLElement): void;
  100731. /**
  100732. * @returns the name of this class
  100733. */
  100734. getClassName(): string;
  100735. /**
  100736. * Calls resetPose on the vrDisplay
  100737. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  100738. */
  100739. resetToCurrentRotation(): void;
  100740. /**
  100741. * @hidden
  100742. * Updates the rig cameras (left and right eye)
  100743. */
  100744. _updateRigCameras(): void;
  100745. private _workingVector;
  100746. private _oneVector;
  100747. private _workingMatrix;
  100748. private updateCacheCalled;
  100749. private _correctPositionIfNotTrackPosition;
  100750. /**
  100751. * @hidden
  100752. * Updates the cached values of the camera
  100753. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  100754. */
  100755. _updateCache(ignoreParentClass?: boolean): void;
  100756. /**
  100757. * @hidden
  100758. * Get current device position in babylon world
  100759. */
  100760. _computeDevicePosition(): void;
  100761. /**
  100762. * Updates the current device position and rotation in the babylon world
  100763. */
  100764. update(): void;
  100765. /**
  100766. * @hidden
  100767. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  100768. * @returns an identity matrix
  100769. */
  100770. _getViewMatrix(): Matrix;
  100771. private _tmpMatrix;
  100772. /**
  100773. * This function is called by the two RIG cameras.
  100774. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  100775. * @hidden
  100776. */
  100777. _getWebVRViewMatrix(): Matrix;
  100778. /** @hidden */
  100779. _getWebVRProjectionMatrix(): Matrix;
  100780. private _onGamepadConnectedObserver;
  100781. private _onGamepadDisconnectedObserver;
  100782. private _updateCacheWhenTrackingDisabledObserver;
  100783. /**
  100784. * Initializes the controllers and their meshes
  100785. */
  100786. initControllers(): void;
  100787. }
  100788. }
  100789. declare module BABYLON {
  100790. /**
  100791. * "Static Class" containing the most commonly used helper while dealing with material for rendering purpose.
  100792. *
  100793. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  100794. *
  100795. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  100796. */
  100797. export class MaterialHelper {
  100798. /**
  100799. * Bind the current view position to an effect.
  100800. * @param effect The effect to be bound
  100801. * @param scene The scene the eyes position is used from
  100802. * @param variableName name of the shader variable that will hold the eye position
  100803. */
  100804. static BindEyePosition(effect: Effect, scene: Scene, variableName?: string): void;
  100805. /**
  100806. * Helps preparing the defines values about the UVs in used in the effect.
  100807. * UVs are shared as much as we can accross channels in the shaders.
  100808. * @param texture The texture we are preparing the UVs for
  100809. * @param defines The defines to update
  100810. * @param key The channel key "diffuse", "specular"... used in the shader
  100811. */
  100812. static PrepareDefinesForMergedUV(texture: BaseTexture, defines: any, key: string): void;
  100813. /**
  100814. * Binds a texture matrix value to its corrsponding uniform
  100815. * @param texture The texture to bind the matrix for
  100816. * @param uniformBuffer The uniform buffer receivin the data
  100817. * @param key The channel key "diffuse", "specular"... used in the shader
  100818. */
  100819. static BindTextureMatrix(texture: BaseTexture, uniformBuffer: UniformBuffer, key: string): void;
  100820. /**
  100821. * Gets the current status of the fog (should it be enabled?)
  100822. * @param mesh defines the mesh to evaluate for fog support
  100823. * @param scene defines the hosting scene
  100824. * @returns true if fog must be enabled
  100825. */
  100826. static GetFogState(mesh: AbstractMesh, scene: Scene): boolean;
  100827. /**
  100828. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  100829. * @param mesh defines the current mesh
  100830. * @param scene defines the current scene
  100831. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  100832. * @param pointsCloud defines if point cloud rendering has to be turned on
  100833. * @param fogEnabled defines if fog has to be turned on
  100834. * @param alphaTest defines if alpha testing has to be turned on
  100835. * @param defines defines the current list of defines
  100836. */
  100837. static PrepareDefinesForMisc(mesh: AbstractMesh, scene: Scene, useLogarithmicDepth: boolean, pointsCloud: boolean, fogEnabled: boolean, alphaTest: boolean, defines: any): void;
  100838. /**
  100839. * Helper used to prepare the list of defines associated with frame values for shader compilation
  100840. * @param scene defines the current scene
  100841. * @param engine defines the current engine
  100842. * @param defines specifies the list of active defines
  100843. * @param useInstances defines if instances have to be turned on
  100844. * @param useClipPlane defines if clip plane have to be turned on
  100845. * @param useInstances defines if instances have to be turned on
  100846. * @param useThinInstances defines if thin instances have to be turned on
  100847. */
  100848. static PrepareDefinesForFrameBoundValues(scene: Scene, engine: Engine, defines: any, useInstances: boolean, useClipPlane?: Nullable<boolean>, useThinInstances?: boolean): void;
  100849. /**
  100850. * Prepares the defines for bones
  100851. * @param mesh The mesh containing the geometry data we will draw
  100852. * @param defines The defines to update
  100853. */
  100854. static PrepareDefinesForBones(mesh: AbstractMesh, defines: any): void;
  100855. /**
  100856. * Prepares the defines for morph targets
  100857. * @param mesh The mesh containing the geometry data we will draw
  100858. * @param defines The defines to update
  100859. */
  100860. static PrepareDefinesForMorphTargets(mesh: AbstractMesh, defines: any): void;
  100861. /**
  100862. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  100863. * @param mesh The mesh containing the geometry data we will draw
  100864. * @param defines The defines to update
  100865. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  100866. * @param useBones Precise whether bones should be used or not (override mesh info)
  100867. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  100868. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  100869. * @returns false if defines are considered not dirty and have not been checked
  100870. */
  100871. static PrepareDefinesForAttributes(mesh: AbstractMesh, defines: any, useVertexColor: boolean, useBones: boolean, useMorphTargets?: boolean, useVertexAlpha?: boolean): boolean;
  100872. /**
  100873. * Prepares the defines related to multiview
  100874. * @param scene The scene we are intending to draw
  100875. * @param defines The defines to update
  100876. */
  100877. static PrepareDefinesForMultiview(scene: Scene, defines: any): void;
  100878. /**
  100879. * Prepares the defines related to the prepass
  100880. * @param scene The scene we are intending to draw
  100881. * @param defines The defines to update
  100882. * @param canRenderToMRT Indicates if this material renders to several textures in the prepass
  100883. */
  100884. static PrepareDefinesForPrePass(scene: Scene, defines: any, canRenderToMRT: boolean): void;
  100885. /**
  100886. * Prepares the defines related to the light information passed in parameter
  100887. * @param scene The scene we are intending to draw
  100888. * @param mesh The mesh the effect is compiling for
  100889. * @param light The light the effect is compiling for
  100890. * @param lightIndex The index of the light
  100891. * @param defines The defines to update
  100892. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100893. * @param state Defines the current state regarding what is needed (normals, etc...)
  100894. */
  100895. static PrepareDefinesForLight(scene: Scene, mesh: AbstractMesh, light: Light, lightIndex: number, defines: any, specularSupported: boolean, state: {
  100896. needNormals: boolean;
  100897. needRebuild: boolean;
  100898. shadowEnabled: boolean;
  100899. specularEnabled: boolean;
  100900. lightmapMode: boolean;
  100901. }): void;
  100902. /**
  100903. * Prepares the defines related to the light information passed in parameter
  100904. * @param scene The scene we are intending to draw
  100905. * @param mesh The mesh the effect is compiling for
  100906. * @param defines The defines to update
  100907. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  100908. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  100909. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  100910. * @returns true if normals will be required for the rest of the effect
  100911. */
  100912. static PrepareDefinesForLights(scene: Scene, mesh: AbstractMesh, defines: any, specularSupported: boolean, maxSimultaneousLights?: number, disableLighting?: boolean): boolean;
  100913. /**
  100914. * Prepares the uniforms and samplers list to be used in the effect (for a specific light)
  100915. * @param lightIndex defines the light index
  100916. * @param uniformsList The uniform list
  100917. * @param samplersList The sampler list
  100918. * @param projectedLightTexture defines if projected texture must be used
  100919. * @param uniformBuffersList defines an optional list of uniform buffers
  100920. */
  100921. static PrepareUniformsAndSamplersForLight(lightIndex: number, uniformsList: string[], samplersList: string[], projectedLightTexture?: any, uniformBuffersList?: Nullable<string[]>): void;
  100922. /**
  100923. * Prepares the uniforms and samplers list to be used in the effect
  100924. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  100925. * @param samplersList The sampler list
  100926. * @param defines The defines helping in the list generation
  100927. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  100928. */
  100929. static PrepareUniformsAndSamplersList(uniformsListOrOptions: string[] | IEffectCreationOptions, samplersList?: string[], defines?: any, maxSimultaneousLights?: number): void;
  100930. /**
  100931. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  100932. * @param defines The defines to update while falling back
  100933. * @param fallbacks The authorized effect fallbacks
  100934. * @param maxSimultaneousLights The maximum number of lights allowed
  100935. * @param rank the current rank of the Effect
  100936. * @returns The newly affected rank
  100937. */
  100938. static HandleFallbacksForShadows(defines: any, fallbacks: EffectFallbacks, maxSimultaneousLights?: number, rank?: number): number;
  100939. private static _TmpMorphInfluencers;
  100940. /**
  100941. * Prepares the list of attributes required for morph targets according to the effect defines.
  100942. * @param attribs The current list of supported attribs
  100943. * @param mesh The mesh to prepare the morph targets attributes for
  100944. * @param influencers The number of influencers
  100945. */
  100946. static PrepareAttributesForMorphTargetsInfluencers(attribs: string[], mesh: AbstractMesh, influencers: number): void;
  100947. /**
  100948. * Prepares the list of attributes required for morph targets according to the effect defines.
  100949. * @param attribs The current list of supported attribs
  100950. * @param mesh The mesh to prepare the morph targets attributes for
  100951. * @param defines The current Defines of the effect
  100952. */
  100953. static PrepareAttributesForMorphTargets(attribs: string[], mesh: AbstractMesh, defines: any): void;
  100954. /**
  100955. * Prepares the list of attributes required for bones according to the effect defines.
  100956. * @param attribs The current list of supported attribs
  100957. * @param mesh The mesh to prepare the bones attributes for
  100958. * @param defines The current Defines of the effect
  100959. * @param fallbacks The current efffect fallback strategy
  100960. */
  100961. static PrepareAttributesForBones(attribs: string[], mesh: AbstractMesh, defines: any, fallbacks: EffectFallbacks): void;
  100962. /**
  100963. * Check and prepare the list of attributes required for instances according to the effect defines.
  100964. * @param attribs The current list of supported attribs
  100965. * @param defines The current MaterialDefines of the effect
  100966. */
  100967. static PrepareAttributesForInstances(attribs: string[], defines: MaterialDefines): void;
  100968. /**
  100969. * Add the list of attributes required for instances to the attribs array.
  100970. * @param attribs The current list of supported attribs
  100971. */
  100972. static PushAttributesForInstances(attribs: string[]): void;
  100973. /**
  100974. * Binds the light information to the effect.
  100975. * @param light The light containing the generator
  100976. * @param effect The effect we are binding the data to
  100977. * @param lightIndex The light index in the effect used to render
  100978. */
  100979. static BindLightProperties(light: Light, effect: Effect, lightIndex: number): void;
  100980. /**
  100981. * Binds the lights information from the scene to the effect for the given mesh.
  100982. * @param light Light to bind
  100983. * @param lightIndex Light index
  100984. * @param scene The scene where the light belongs to
  100985. * @param effect The effect we are binding the data to
  100986. * @param useSpecular Defines if specular is supported
  100987. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100988. */
  100989. static BindLight(light: Light, lightIndex: number, scene: Scene, effect: Effect, useSpecular: boolean, rebuildInParallel?: boolean): void;
  100990. /**
  100991. * Binds the lights information from the scene to the effect for the given mesh.
  100992. * @param scene The scene the lights belongs to
  100993. * @param mesh The mesh we are binding the information to render
  100994. * @param effect The effect we are binding the data to
  100995. * @param defines The generated defines for the effect
  100996. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  100997. * @param rebuildInParallel Specifies whether the shader is rebuilding in parallel
  100998. */
  100999. static BindLights(scene: Scene, mesh: AbstractMesh, effect: Effect, defines: any, maxSimultaneousLights?: number, rebuildInParallel?: boolean): void;
  101000. private static _tempFogColor;
  101001. /**
  101002. * Binds the fog information from the scene to the effect for the given mesh.
  101003. * @param scene The scene the lights belongs to
  101004. * @param mesh The mesh we are binding the information to render
  101005. * @param effect The effect we are binding the data to
  101006. * @param linearSpace Defines if the fog effect is applied in linear space
  101007. */
  101008. static BindFogParameters(scene: Scene, mesh: AbstractMesh, effect: Effect, linearSpace?: boolean): void;
  101009. /**
  101010. * Binds the bones information from the mesh to the effect.
  101011. * @param mesh The mesh we are binding the information to render
  101012. * @param effect The effect we are binding the data to
  101013. * @param prePassConfiguration Configuration for the prepass, in case prepass is activated
  101014. */
  101015. static BindBonesParameters(mesh?: AbstractMesh, effect?: Effect, prePassConfiguration?: PrePassConfiguration): void;
  101016. private static _CopyBonesTransformationMatrices;
  101017. /**
  101018. * Binds the morph targets information from the mesh to the effect.
  101019. * @param abstractMesh The mesh we are binding the information to render
  101020. * @param effect The effect we are binding the data to
  101021. */
  101022. static BindMorphTargetParameters(abstractMesh: AbstractMesh, effect: Effect): void;
  101023. /**
  101024. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  101025. * @param defines The generated defines used in the effect
  101026. * @param effect The effect we are binding the data to
  101027. * @param scene The scene we are willing to render with logarithmic scale for
  101028. */
  101029. static BindLogDepth(defines: any, effect: Effect, scene: Scene): void;
  101030. /**
  101031. * Binds the clip plane information from the scene to the effect.
  101032. * @param scene The scene the clip plane information are extracted from
  101033. * @param effect The effect we are binding the data to
  101034. */
  101035. static BindClipPlane(effect: Effect, scene: Scene): void;
  101036. }
  101037. }
  101038. declare module BABYLON {
  101039. /**
  101040. * Block used to expose an input value
  101041. */
  101042. export class InputBlock extends NodeMaterialBlock {
  101043. private _mode;
  101044. private _associatedVariableName;
  101045. private _storedValue;
  101046. private _valueCallback;
  101047. private _type;
  101048. private _animationType;
  101049. /** Gets or set a value used to limit the range of float values */
  101050. min: number;
  101051. /** Gets or set a value used to limit the range of float values */
  101052. max: number;
  101053. /** Gets or set a value indicating that this input can only get 0 and 1 values */
  101054. isBoolean: boolean;
  101055. /** Gets or sets a value used by the Node Material editor to determine how to configure the current value if it is a matrix */
  101056. matrixMode: number;
  101057. /** @hidden */
  101058. _systemValue: Nullable<NodeMaterialSystemValues>;
  101059. /** Gets or sets a boolean indicating that the value of this input will not change after a build */
  101060. isConstant: boolean;
  101061. /** Gets or sets the group to use to display this block in the Inspector */
  101062. groupInInspector: string;
  101063. /** Gets an observable raised when the value is changed */
  101064. onValueChangedObservable: Observable<InputBlock>;
  101065. /**
  101066. * Gets or sets the connection point type (default is float)
  101067. */
  101068. get type(): NodeMaterialBlockConnectionPointTypes;
  101069. /**
  101070. * Creates a new InputBlock
  101071. * @param name defines the block name
  101072. * @param target defines the target of that block (Vertex by default)
  101073. * @param type defines the type of the input (can be set to NodeMaterialBlockConnectionPointTypes.AutoDetect)
  101074. */
  101075. constructor(name: string, target?: NodeMaterialBlockTargets, type?: NodeMaterialBlockConnectionPointTypes);
  101076. /**
  101077. * Validates if a name is a reserve word.
  101078. * @param newName the new name to be given to the node.
  101079. * @returns false if the name is a reserve word, else true.
  101080. */
  101081. validateBlockName(newName: string): boolean;
  101082. /**
  101083. * Gets the output component
  101084. */
  101085. get output(): NodeMaterialConnectionPoint;
  101086. /**
  101087. * Set the source of this connection point to a vertex attribute
  101088. * @param attributeName defines the attribute name (position, uv, normal, etc...). If not specified it will take the connection point name
  101089. * @returns the current connection point
  101090. */
  101091. setAsAttribute(attributeName?: string): InputBlock;
  101092. /**
  101093. * Set the source of this connection point to a system value
  101094. * @param value define the system value to use (world, view, etc...) or null to switch to manual value
  101095. * @returns the current connection point
  101096. */
  101097. setAsSystemValue(value: Nullable<NodeMaterialSystemValues>): InputBlock;
  101098. /**
  101099. * Gets or sets the value of that point.
  101100. * Please note that this value will be ignored if valueCallback is defined
  101101. */
  101102. get value(): any;
  101103. set value(value: any);
  101104. /**
  101105. * Gets or sets a callback used to get the value of that point.
  101106. * Please note that setting this value will force the connection point to ignore the value property
  101107. */
  101108. get valueCallback(): () => any;
  101109. set valueCallback(value: () => any);
  101110. /**
  101111. * Gets or sets the associated variable name in the shader
  101112. */
  101113. get associatedVariableName(): string;
  101114. set associatedVariableName(value: string);
  101115. /** Gets or sets the type of animation applied to the input */
  101116. get animationType(): AnimatedInputBlockTypes;
  101117. set animationType(value: AnimatedInputBlockTypes);
  101118. /**
  101119. * Gets a boolean indicating that this connection point not defined yet
  101120. */
  101121. get isUndefined(): boolean;
  101122. /**
  101123. * Gets or sets a boolean indicating that this connection point is coming from an uniform.
  101124. * In this case the connection point name must be the name of the uniform to use.
  101125. * Can only be set on inputs
  101126. */
  101127. get isUniform(): boolean;
  101128. set isUniform(value: boolean);
  101129. /**
  101130. * Gets or sets a boolean indicating that this connection point is coming from an attribute.
  101131. * In this case the connection point name must be the name of the attribute to use
  101132. * Can only be set on inputs
  101133. */
  101134. get isAttribute(): boolean;
  101135. set isAttribute(value: boolean);
  101136. /**
  101137. * Gets or sets a boolean indicating that this connection point is generating a varying variable.
  101138. * Can only be set on exit points
  101139. */
  101140. get isVarying(): boolean;
  101141. set isVarying(value: boolean);
  101142. /**
  101143. * Gets a boolean indicating that the current connection point is a system value
  101144. */
  101145. get isSystemValue(): boolean;
  101146. /**
  101147. * Gets or sets the current well known value or null if not defined as a system value
  101148. */
  101149. get systemValue(): Nullable<NodeMaterialSystemValues>;
  101150. set systemValue(value: Nullable<NodeMaterialSystemValues>);
  101151. /**
  101152. * Gets the current class name
  101153. * @returns the class name
  101154. */
  101155. getClassName(): string;
  101156. /**
  101157. * Animate the input if animationType !== None
  101158. * @param scene defines the rendering scene
  101159. */
  101160. animate(scene: Scene): void;
  101161. private _emitDefine;
  101162. initialize(state: NodeMaterialBuildState): void;
  101163. /**
  101164. * Set the input block to its default value (based on its type)
  101165. */
  101166. setDefaultValue(): void;
  101167. private _emitConstant;
  101168. /** @hidden */
  101169. get _noContextSwitch(): boolean;
  101170. private _emit;
  101171. /** @hidden */
  101172. _transmitWorld(effect: Effect, world: Matrix, worldView: Matrix, worldViewProjection: Matrix): void;
  101173. /** @hidden */
  101174. _transmit(effect: Effect, scene: Scene): void;
  101175. protected _buildBlock(state: NodeMaterialBuildState): void;
  101176. protected _dumpPropertiesCode(): string;
  101177. dispose(): void;
  101178. serialize(): any;
  101179. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101180. }
  101181. }
  101182. declare module BABYLON {
  101183. /**
  101184. * Enum used to define the compatibility state between two connection points
  101185. */
  101186. export enum NodeMaterialConnectionPointCompatibilityStates {
  101187. /** Points are compatibles */
  101188. Compatible = 0,
  101189. /** Points are incompatible because of their types */
  101190. TypeIncompatible = 1,
  101191. /** Points are incompatible because of their targets (vertex vs fragment) */
  101192. TargetIncompatible = 2
  101193. }
  101194. /**
  101195. * Defines the direction of a connection point
  101196. */
  101197. export enum NodeMaterialConnectionPointDirection {
  101198. /** Input */
  101199. Input = 0,
  101200. /** Output */
  101201. Output = 1
  101202. }
  101203. /**
  101204. * Defines a connection point for a block
  101205. */
  101206. export class NodeMaterialConnectionPoint {
  101207. /** @hidden */
  101208. _ownerBlock: NodeMaterialBlock;
  101209. /** @hidden */
  101210. _connectedPoint: Nullable<NodeMaterialConnectionPoint>;
  101211. private _endpoints;
  101212. private _associatedVariableName;
  101213. private _direction;
  101214. /** @hidden */
  101215. _typeConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101216. /** @hidden */
  101217. _linkedConnectionSource: Nullable<NodeMaterialConnectionPoint>;
  101218. private _type;
  101219. /** @hidden */
  101220. _enforceAssociatedVariableName: boolean;
  101221. /** Gets the direction of the point */
  101222. get direction(): NodeMaterialConnectionPointDirection;
  101223. /** Indicates that this connection point needs dual validation before being connected to another point */
  101224. needDualDirectionValidation: boolean;
  101225. /**
  101226. * Gets or sets the additional types supported by this connection point
  101227. */
  101228. acceptedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101229. /**
  101230. * Gets or sets the additional types excluded by this connection point
  101231. */
  101232. excludedConnectionPointTypes: NodeMaterialBlockConnectionPointTypes[];
  101233. /**
  101234. * Observable triggered when this point is connected
  101235. */
  101236. onConnectionObservable: Observable<NodeMaterialConnectionPoint>;
  101237. /**
  101238. * Gets or sets the associated variable name in the shader
  101239. */
  101240. get associatedVariableName(): string;
  101241. set associatedVariableName(value: string);
  101242. /** Get the inner type (ie AutoDetect for instance instead of the inferred one) */
  101243. get innerType(): NodeMaterialBlockConnectionPointTypes;
  101244. /**
  101245. * Gets or sets the connection point type (default is float)
  101246. */
  101247. get type(): NodeMaterialBlockConnectionPointTypes;
  101248. set type(value: NodeMaterialBlockConnectionPointTypes);
  101249. /**
  101250. * Gets or sets the connection point name
  101251. */
  101252. name: string;
  101253. /**
  101254. * Gets or sets the connection point name
  101255. */
  101256. displayName: string;
  101257. /**
  101258. * Gets or sets a boolean indicating that this connection point can be omitted
  101259. */
  101260. isOptional: boolean;
  101261. /**
  101262. * Gets or sets a boolean indicating that this connection point is exposed on a frame
  101263. */
  101264. isExposedOnFrame: boolean;
  101265. /**
  101266. * Gets or sets number indicating the position that the port is exposed to on a frame
  101267. */
  101268. exposedPortPosition: number;
  101269. /**
  101270. * Gets or sets a string indicating that this uniform must be defined under a #ifdef
  101271. */
  101272. define: string;
  101273. /** @hidden */
  101274. _prioritizeVertex: boolean;
  101275. private _target;
  101276. /** Gets or sets the target of that connection point */
  101277. get target(): NodeMaterialBlockTargets;
  101278. set target(value: NodeMaterialBlockTargets);
  101279. /**
  101280. * Gets a boolean indicating that the current point is connected to another NodeMaterialBlock
  101281. */
  101282. get isConnected(): boolean;
  101283. /**
  101284. * Gets a boolean indicating that the current point is connected to an input block
  101285. */
  101286. get isConnectedToInputBlock(): boolean;
  101287. /**
  101288. * Gets a the connected input block (if any)
  101289. */
  101290. get connectInputBlock(): Nullable<InputBlock>;
  101291. /** Get the other side of the connection (if any) */
  101292. get connectedPoint(): Nullable<NodeMaterialConnectionPoint>;
  101293. /** Get the block that owns this connection point */
  101294. get ownerBlock(): NodeMaterialBlock;
  101295. /** Get the block connected on the other side of this connection (if any) */
  101296. get sourceBlock(): Nullable<NodeMaterialBlock>;
  101297. /** Get the block connected on the endpoints of this connection (if any) */
  101298. get connectedBlocks(): Array<NodeMaterialBlock>;
  101299. /** Gets the list of connected endpoints */
  101300. get endpoints(): NodeMaterialConnectionPoint[];
  101301. /** Gets a boolean indicating if that output point is connected to at least one input */
  101302. get hasEndpoints(): boolean;
  101303. /** Gets a boolean indicating that this connection will be used in the vertex shader */
  101304. get isConnectedInVertexShader(): boolean;
  101305. /** Gets a boolean indicating that this connection will be used in the fragment shader */
  101306. get isConnectedInFragmentShader(): boolean;
  101307. /**
  101308. * Creates a block suitable to be used as an input for this input point.
  101309. * If null is returned, a block based on the point type will be created.
  101310. * @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
  101311. */
  101312. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101313. /**
  101314. * Creates a new connection point
  101315. * @param name defines the connection point name
  101316. * @param ownerBlock defines the block hosting this connection point
  101317. * @param direction defines the direction of the connection point
  101318. */
  101319. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection);
  101320. /**
  101321. * Gets the current class name e.g. "NodeMaterialConnectionPoint"
  101322. * @returns the class name
  101323. */
  101324. getClassName(): string;
  101325. /**
  101326. * Gets a boolean indicating if the current point can be connected to another point
  101327. * @param connectionPoint defines the other connection point
  101328. * @returns a boolean
  101329. */
  101330. canConnectTo(connectionPoint: NodeMaterialConnectionPoint): boolean;
  101331. /**
  101332. * Gets a number indicating if the current point can be connected to another point
  101333. * @param connectionPoint defines the other connection point
  101334. * @returns a number defining the compatibility state
  101335. */
  101336. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101337. /**
  101338. * Connect this point to another connection point
  101339. * @param connectionPoint defines the other connection point
  101340. * @param ignoreConstraints defines if the system will ignore connection type constraints (default is false)
  101341. * @returns the current connection point
  101342. */
  101343. connectTo(connectionPoint: NodeMaterialConnectionPoint, ignoreConstraints?: boolean): NodeMaterialConnectionPoint;
  101344. /**
  101345. * Disconnect this point from one of his endpoint
  101346. * @param endpoint defines the other connection point
  101347. * @returns the current connection point
  101348. */
  101349. disconnectFrom(endpoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPoint;
  101350. /**
  101351. * Serializes this point in a JSON representation
  101352. * @param isInput defines if the connection point is an input (default is true)
  101353. * @returns the serialized point object
  101354. */
  101355. serialize(isInput?: boolean): any;
  101356. /**
  101357. * Release resources
  101358. */
  101359. dispose(): void;
  101360. }
  101361. }
  101362. declare module BABYLON {
  101363. /**
  101364. * Enum used to define the material modes
  101365. */
  101366. export enum NodeMaterialModes {
  101367. /** Regular material */
  101368. Material = 0,
  101369. /** For post process */
  101370. PostProcess = 1,
  101371. /** For particle system */
  101372. Particle = 2,
  101373. /** For procedural texture */
  101374. ProceduralTexture = 3
  101375. }
  101376. }
  101377. declare module BABYLON {
  101378. /**
  101379. * Block used to read a texture from a sampler
  101380. */
  101381. export class TextureBlock extends NodeMaterialBlock {
  101382. private _defineName;
  101383. private _linearDefineName;
  101384. private _gammaDefineName;
  101385. private _tempTextureRead;
  101386. private _samplerName;
  101387. private _transformedUVName;
  101388. private _textureTransformName;
  101389. private _textureInfoName;
  101390. private _mainUVName;
  101391. private _mainUVDefineName;
  101392. private _fragmentOnly;
  101393. /**
  101394. * Gets or sets the texture associated with the node
  101395. */
  101396. texture: Nullable<Texture>;
  101397. /**
  101398. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101399. */
  101400. convertToGammaSpace: boolean;
  101401. /**
  101402. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101403. */
  101404. convertToLinearSpace: boolean;
  101405. /**
  101406. * Create a new TextureBlock
  101407. * @param name defines the block name
  101408. */
  101409. constructor(name: string, fragmentOnly?: boolean);
  101410. /**
  101411. * Gets the current class name
  101412. * @returns the class name
  101413. */
  101414. getClassName(): string;
  101415. /**
  101416. * Gets the uv input component
  101417. */
  101418. get uv(): NodeMaterialConnectionPoint;
  101419. /**
  101420. * Gets the rgba output component
  101421. */
  101422. get rgba(): NodeMaterialConnectionPoint;
  101423. /**
  101424. * Gets the rgb output component
  101425. */
  101426. get rgb(): NodeMaterialConnectionPoint;
  101427. /**
  101428. * Gets the r output component
  101429. */
  101430. get r(): NodeMaterialConnectionPoint;
  101431. /**
  101432. * Gets the g output component
  101433. */
  101434. get g(): NodeMaterialConnectionPoint;
  101435. /**
  101436. * Gets the b output component
  101437. */
  101438. get b(): NodeMaterialConnectionPoint;
  101439. /**
  101440. * Gets the a output component
  101441. */
  101442. get a(): NodeMaterialConnectionPoint;
  101443. get target(): NodeMaterialBlockTargets;
  101444. autoConfigure(material: NodeMaterial): void;
  101445. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  101446. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101447. isReady(): boolean;
  101448. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101449. private get _isMixed();
  101450. private _injectVertexCode;
  101451. private _writeTextureRead;
  101452. private _writeOutput;
  101453. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101454. protected _dumpPropertiesCode(): string;
  101455. serialize(): any;
  101456. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101457. }
  101458. }
  101459. declare module BABYLON {
  101460. /** @hidden */
  101461. export var reflectionFunction: {
  101462. name: string;
  101463. shader: string;
  101464. };
  101465. }
  101466. declare module BABYLON {
  101467. /**
  101468. * Base block used to read a reflection texture from a sampler
  101469. */
  101470. export abstract class ReflectionTextureBaseBlock extends NodeMaterialBlock {
  101471. /** @hidden */
  101472. _define3DName: string;
  101473. /** @hidden */
  101474. _defineCubicName: string;
  101475. /** @hidden */
  101476. _defineExplicitName: string;
  101477. /** @hidden */
  101478. _defineProjectionName: string;
  101479. /** @hidden */
  101480. _defineLocalCubicName: string;
  101481. /** @hidden */
  101482. _defineSphericalName: string;
  101483. /** @hidden */
  101484. _definePlanarName: string;
  101485. /** @hidden */
  101486. _defineEquirectangularName: string;
  101487. /** @hidden */
  101488. _defineMirroredEquirectangularFixedName: string;
  101489. /** @hidden */
  101490. _defineEquirectangularFixedName: string;
  101491. /** @hidden */
  101492. _defineSkyboxName: string;
  101493. /** @hidden */
  101494. _defineOppositeZ: string;
  101495. /** @hidden */
  101496. _cubeSamplerName: string;
  101497. /** @hidden */
  101498. _2DSamplerName: string;
  101499. protected _positionUVWName: string;
  101500. protected _directionWName: string;
  101501. protected _reflectionVectorName: string;
  101502. /** @hidden */
  101503. _reflectionCoordsName: string;
  101504. /** @hidden */
  101505. _reflectionMatrixName: string;
  101506. protected _reflectionColorName: string;
  101507. /**
  101508. * Gets or sets the texture associated with the node
  101509. */
  101510. texture: Nullable<BaseTexture>;
  101511. /**
  101512. * Create a new ReflectionTextureBaseBlock
  101513. * @param name defines the block name
  101514. */
  101515. constructor(name: string);
  101516. /**
  101517. * Gets the current class name
  101518. * @returns the class name
  101519. */
  101520. getClassName(): string;
  101521. /**
  101522. * Gets the world position input component
  101523. */
  101524. abstract get position(): NodeMaterialConnectionPoint;
  101525. /**
  101526. * Gets the world position input component
  101527. */
  101528. abstract get worldPosition(): NodeMaterialConnectionPoint;
  101529. /**
  101530. * Gets the world normal input component
  101531. */
  101532. abstract get worldNormal(): NodeMaterialConnectionPoint;
  101533. /**
  101534. * Gets the world input component
  101535. */
  101536. abstract get world(): NodeMaterialConnectionPoint;
  101537. /**
  101538. * Gets the camera (or eye) position component
  101539. */
  101540. abstract get cameraPosition(): NodeMaterialConnectionPoint;
  101541. /**
  101542. * Gets the view input component
  101543. */
  101544. abstract get view(): NodeMaterialConnectionPoint;
  101545. protected _getTexture(): Nullable<BaseTexture>;
  101546. autoConfigure(material: NodeMaterial): void;
  101547. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101548. isReady(): boolean;
  101549. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  101550. /**
  101551. * Gets the code to inject in the vertex shader
  101552. * @param state current state of the node material building
  101553. * @returns the shader code
  101554. */
  101555. handleVertexSide(state: NodeMaterialBuildState): string;
  101556. /**
  101557. * Handles the inits for the fragment code path
  101558. * @param state node material build state
  101559. */
  101560. handleFragmentSideInits(state: NodeMaterialBuildState): void;
  101561. /**
  101562. * Generates the reflection coords code for the fragment code path
  101563. * @param worldNormalVarName name of the world normal variable
  101564. * @param worldPos name of the world position variable. If not provided, will use the world position connected to this block
  101565. * @param onlyReflectionVector if true, generates code only for the reflection vector computation, not for the reflection coordinates
  101566. * @returns the shader code
  101567. */
  101568. handleFragmentSideCodeReflectionCoords(worldNormalVarName: string, worldPos?: string, onlyReflectionVector?: boolean): string;
  101569. /**
  101570. * Generates the reflection color code for the fragment code path
  101571. * @param lodVarName name of the lod variable
  101572. * @param swizzleLookupTexture swizzle to use for the final color variable
  101573. * @returns the shader code
  101574. */
  101575. handleFragmentSideCodeReflectionColor(lodVarName?: string, swizzleLookupTexture?: string): string;
  101576. /**
  101577. * Generates the code corresponding to the connected output points
  101578. * @param state node material build state
  101579. * @param varName name of the variable to output
  101580. * @returns the shader code
  101581. */
  101582. writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  101583. protected _buildBlock(state: NodeMaterialBuildState): this;
  101584. protected _dumpPropertiesCode(): string;
  101585. serialize(): any;
  101586. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101587. }
  101588. }
  101589. declare module BABYLON {
  101590. /**
  101591. * Defines a connection point to be used for points with a custom object type
  101592. */
  101593. export class NodeMaterialConnectionPointCustomObject<T extends NodeMaterialBlock> extends NodeMaterialConnectionPoint {
  101594. private _blockType;
  101595. private _blockName;
  101596. private _nameForCheking?;
  101597. /**
  101598. * Creates a new connection point
  101599. * @param name defines the connection point name
  101600. * @param ownerBlock defines the block hosting this connection point
  101601. * @param direction defines the direction of the connection point
  101602. */
  101603. constructor(name: string, ownerBlock: NodeMaterialBlock, direction: NodeMaterialConnectionPointDirection, _blockType: new (...args: any[]) => T, _blockName: string, _nameForCheking?: string | undefined);
  101604. /**
  101605. * Gets a number indicating if the current point can be connected to another point
  101606. * @param connectionPoint defines the other connection point
  101607. * @returns a number defining the compatibility state
  101608. */
  101609. checkCompatibilityState(connectionPoint: NodeMaterialConnectionPoint): NodeMaterialConnectionPointCompatibilityStates;
  101610. /**
  101611. * Creates a block suitable to be used as an input for this input point.
  101612. * If null is returned, a block based on the point type will be created.
  101613. * @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
  101614. */
  101615. createCustomInputBlock(): Nullable<[NodeMaterialBlock, string]>;
  101616. }
  101617. }
  101618. declare module BABYLON {
  101619. /**
  101620. * Enum defining the type of properties that can be edited in the property pages in the NME
  101621. */
  101622. export enum PropertyTypeForEdition {
  101623. /** property is a boolean */
  101624. Boolean = 0,
  101625. /** property is a float */
  101626. Float = 1,
  101627. /** property is a Vector2 */
  101628. Vector2 = 2,
  101629. /** property is a list of values */
  101630. List = 3
  101631. }
  101632. /**
  101633. * Interface that defines an option in a variable of type list
  101634. */
  101635. export interface IEditablePropertyListOption {
  101636. /** label of the option */
  101637. "label": string;
  101638. /** value of the option */
  101639. "value": number;
  101640. }
  101641. /**
  101642. * Interface that defines the options available for an editable property
  101643. */
  101644. export interface IEditablePropertyOption {
  101645. /** min value */
  101646. "min"?: number;
  101647. /** max value */
  101648. "max"?: number;
  101649. /** notifiers: indicates which actions to take when the property is changed */
  101650. "notifiers"?: {
  101651. /** the material should be rebuilt */
  101652. "rebuild"?: boolean;
  101653. /** the preview should be updated */
  101654. "update"?: boolean;
  101655. };
  101656. /** list of the options for a variable of type list */
  101657. "options"?: IEditablePropertyListOption[];
  101658. }
  101659. /**
  101660. * Interface that describes an editable property
  101661. */
  101662. export interface IPropertyDescriptionForEdition {
  101663. /** name of the property */
  101664. "propertyName": string;
  101665. /** display name of the property */
  101666. "displayName": string;
  101667. /** type of the property */
  101668. "type": PropertyTypeForEdition;
  101669. /** group of the property - all properties with the same group value will be displayed in a specific section */
  101670. "groupName": string;
  101671. /** options for the property */
  101672. "options": IEditablePropertyOption;
  101673. }
  101674. /**
  101675. * Decorator that flags a property in a node material block as being editable
  101676. */
  101677. export function editableInPropertyPage(displayName: string, propertyType?: PropertyTypeForEdition, groupName?: string, options?: IEditablePropertyOption): (target: any, propertyKey: string) => void;
  101678. }
  101679. declare module BABYLON {
  101680. /**
  101681. * Block used to implement the refraction part of the sub surface module of the PBR material
  101682. */
  101683. export class RefractionBlock extends NodeMaterialBlock {
  101684. /** @hidden */
  101685. _define3DName: string;
  101686. /** @hidden */
  101687. _refractionMatrixName: string;
  101688. /** @hidden */
  101689. _defineLODRefractionAlpha: string;
  101690. /** @hidden */
  101691. _defineLinearSpecularRefraction: string;
  101692. /** @hidden */
  101693. _defineOppositeZ: string;
  101694. /** @hidden */
  101695. _cubeSamplerName: string;
  101696. /** @hidden */
  101697. _2DSamplerName: string;
  101698. /** @hidden */
  101699. _vRefractionMicrosurfaceInfosName: string;
  101700. /** @hidden */
  101701. _vRefractionInfosName: string;
  101702. private _scene;
  101703. /**
  101704. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  101705. * Materials half opaque for instance using refraction could benefit from this control.
  101706. */
  101707. linkRefractionWithTransparency: boolean;
  101708. /**
  101709. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  101710. */
  101711. invertRefractionY: boolean;
  101712. /**
  101713. * Gets or sets the texture associated with the node
  101714. */
  101715. texture: Nullable<BaseTexture>;
  101716. /**
  101717. * Create a new RefractionBlock
  101718. * @param name defines the block name
  101719. */
  101720. constructor(name: string);
  101721. /**
  101722. * Gets the current class name
  101723. * @returns the class name
  101724. */
  101725. getClassName(): string;
  101726. /**
  101727. * Gets the intensity input component
  101728. */
  101729. get intensity(): NodeMaterialConnectionPoint;
  101730. /**
  101731. * Gets the index of refraction input component
  101732. */
  101733. get indexOfRefraction(): NodeMaterialConnectionPoint;
  101734. /**
  101735. * Gets the tint at distance input component
  101736. */
  101737. get tintAtDistance(): NodeMaterialConnectionPoint;
  101738. /**
  101739. * Gets the view input component
  101740. */
  101741. get view(): NodeMaterialConnectionPoint;
  101742. /**
  101743. * Gets the refraction object output component
  101744. */
  101745. get refraction(): NodeMaterialConnectionPoint;
  101746. /**
  101747. * Returns true if the block has a texture
  101748. */
  101749. get hasTexture(): boolean;
  101750. protected _getTexture(): Nullable<BaseTexture>;
  101751. autoConfigure(material: NodeMaterial): void;
  101752. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101753. isReady(): boolean;
  101754. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  101755. /**
  101756. * Gets the main code of the block (fragment side)
  101757. * @param state current state of the node material building
  101758. * @returns the shader code
  101759. */
  101760. getCode(state: NodeMaterialBuildState): string;
  101761. protected _buildBlock(state: NodeMaterialBuildState): this;
  101762. protected _dumpPropertiesCode(): string;
  101763. serialize(): any;
  101764. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101765. }
  101766. }
  101767. declare module BABYLON {
  101768. /**
  101769. * Base block used as input for post process
  101770. */
  101771. export class CurrentScreenBlock extends NodeMaterialBlock {
  101772. private _samplerName;
  101773. private _linearDefineName;
  101774. private _gammaDefineName;
  101775. private _mainUVName;
  101776. private _tempTextureRead;
  101777. /**
  101778. * Gets or sets the texture associated with the node
  101779. */
  101780. texture: Nullable<BaseTexture>;
  101781. /**
  101782. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101783. */
  101784. convertToGammaSpace: boolean;
  101785. /**
  101786. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101787. */
  101788. convertToLinearSpace: boolean;
  101789. /**
  101790. * Create a new CurrentScreenBlock
  101791. * @param name defines the block name
  101792. */
  101793. constructor(name: string);
  101794. /**
  101795. * Gets the current class name
  101796. * @returns the class name
  101797. */
  101798. getClassName(): string;
  101799. /**
  101800. * Gets the uv input component
  101801. */
  101802. get uv(): NodeMaterialConnectionPoint;
  101803. /**
  101804. * Gets the rgba output component
  101805. */
  101806. get rgba(): NodeMaterialConnectionPoint;
  101807. /**
  101808. * Gets the rgb output component
  101809. */
  101810. get rgb(): NodeMaterialConnectionPoint;
  101811. /**
  101812. * Gets the r output component
  101813. */
  101814. get r(): NodeMaterialConnectionPoint;
  101815. /**
  101816. * Gets the g output component
  101817. */
  101818. get g(): NodeMaterialConnectionPoint;
  101819. /**
  101820. * Gets the b output component
  101821. */
  101822. get b(): NodeMaterialConnectionPoint;
  101823. /**
  101824. * Gets the a output component
  101825. */
  101826. get a(): NodeMaterialConnectionPoint;
  101827. /**
  101828. * Initialize the block and prepare the context for build
  101829. * @param state defines the state that will be used for the build
  101830. */
  101831. initialize(state: NodeMaterialBuildState): void;
  101832. get target(): NodeMaterialBlockTargets;
  101833. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101834. isReady(): boolean;
  101835. private _injectVertexCode;
  101836. private _writeTextureRead;
  101837. private _writeOutput;
  101838. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101839. serialize(): any;
  101840. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101841. }
  101842. }
  101843. declare module BABYLON {
  101844. /**
  101845. * Base block used for the particle texture
  101846. */
  101847. export class ParticleTextureBlock extends NodeMaterialBlock {
  101848. private _samplerName;
  101849. private _linearDefineName;
  101850. private _gammaDefineName;
  101851. private _tempTextureRead;
  101852. /**
  101853. * Gets or sets the texture associated with the node
  101854. */
  101855. texture: Nullable<BaseTexture>;
  101856. /**
  101857. * Gets or sets a boolean indicating if content needs to be converted to gamma space
  101858. */
  101859. convertToGammaSpace: boolean;
  101860. /**
  101861. * Gets or sets a boolean indicating if content needs to be converted to linear space
  101862. */
  101863. convertToLinearSpace: boolean;
  101864. /**
  101865. * Create a new ParticleTextureBlock
  101866. * @param name defines the block name
  101867. */
  101868. constructor(name: string);
  101869. /**
  101870. * Gets the current class name
  101871. * @returns the class name
  101872. */
  101873. getClassName(): string;
  101874. /**
  101875. * Gets the uv input component
  101876. */
  101877. get uv(): NodeMaterialConnectionPoint;
  101878. /**
  101879. * Gets the rgba output component
  101880. */
  101881. get rgba(): NodeMaterialConnectionPoint;
  101882. /**
  101883. * Gets the rgb output component
  101884. */
  101885. get rgb(): NodeMaterialConnectionPoint;
  101886. /**
  101887. * Gets the r output component
  101888. */
  101889. get r(): NodeMaterialConnectionPoint;
  101890. /**
  101891. * Gets the g output component
  101892. */
  101893. get g(): NodeMaterialConnectionPoint;
  101894. /**
  101895. * Gets the b output component
  101896. */
  101897. get b(): NodeMaterialConnectionPoint;
  101898. /**
  101899. * Gets the a output component
  101900. */
  101901. get a(): NodeMaterialConnectionPoint;
  101902. /**
  101903. * Initialize the block and prepare the context for build
  101904. * @param state defines the state that will be used for the build
  101905. */
  101906. initialize(state: NodeMaterialBuildState): void;
  101907. autoConfigure(material: NodeMaterial): void;
  101908. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  101909. isReady(): boolean;
  101910. private _writeOutput;
  101911. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  101912. serialize(): any;
  101913. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  101914. }
  101915. }
  101916. declare module BABYLON {
  101917. /**
  101918. * Class used to store shared data between 2 NodeMaterialBuildState
  101919. */
  101920. export class NodeMaterialBuildStateSharedData {
  101921. /**
  101922. * Gets the list of emitted varyings
  101923. */
  101924. temps: string[];
  101925. /**
  101926. * Gets the list of emitted varyings
  101927. */
  101928. varyings: string[];
  101929. /**
  101930. * Gets the varying declaration string
  101931. */
  101932. varyingDeclaration: string;
  101933. /**
  101934. * Input blocks
  101935. */
  101936. inputBlocks: InputBlock[];
  101937. /**
  101938. * Input blocks
  101939. */
  101940. textureBlocks: (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  101941. /**
  101942. * Bindable blocks (Blocks that need to set data to the effect)
  101943. */
  101944. bindableBlocks: NodeMaterialBlock[];
  101945. /**
  101946. * List of blocks that can provide a compilation fallback
  101947. */
  101948. blocksWithFallbacks: NodeMaterialBlock[];
  101949. /**
  101950. * List of blocks that can provide a define update
  101951. */
  101952. blocksWithDefines: NodeMaterialBlock[];
  101953. /**
  101954. * List of blocks that can provide a repeatable content
  101955. */
  101956. repeatableContentBlocks: NodeMaterialBlock[];
  101957. /**
  101958. * List of blocks that can provide a dynamic list of uniforms
  101959. */
  101960. dynamicUniformBlocks: NodeMaterialBlock[];
  101961. /**
  101962. * List of blocks that can block the isReady function for the material
  101963. */
  101964. blockingBlocks: NodeMaterialBlock[];
  101965. /**
  101966. * Gets the list of animated inputs
  101967. */
  101968. animatedInputs: InputBlock[];
  101969. /**
  101970. * Build Id used to avoid multiple recompilations
  101971. */
  101972. buildId: number;
  101973. /** List of emitted variables */
  101974. variableNames: {
  101975. [key: string]: number;
  101976. };
  101977. /** List of emitted defines */
  101978. defineNames: {
  101979. [key: string]: number;
  101980. };
  101981. /** Should emit comments? */
  101982. emitComments: boolean;
  101983. /** Emit build activity */
  101984. verbose: boolean;
  101985. /** Gets or sets the hosting scene */
  101986. scene: Scene;
  101987. /**
  101988. * Gets the compilation hints emitted at compilation time
  101989. */
  101990. hints: {
  101991. needWorldViewMatrix: boolean;
  101992. needWorldViewProjectionMatrix: boolean;
  101993. needAlphaBlending: boolean;
  101994. needAlphaTesting: boolean;
  101995. };
  101996. /**
  101997. * List of compilation checks
  101998. */
  101999. checks: {
  102000. emitVertex: boolean;
  102001. emitFragment: boolean;
  102002. notConnectedNonOptionalInputs: NodeMaterialConnectionPoint[];
  102003. };
  102004. /**
  102005. * Is vertex program allowed to be empty?
  102006. */
  102007. allowEmptyVertexProgram: boolean;
  102008. /** Creates a new shared data */
  102009. constructor();
  102010. /**
  102011. * Emits console errors and exceptions if there is a failing check
  102012. */
  102013. emitErrors(): void;
  102014. }
  102015. }
  102016. declare module BABYLON {
  102017. /**
  102018. * Class used to store node based material build state
  102019. */
  102020. export class NodeMaterialBuildState {
  102021. /** Gets or sets a boolean indicating if the current state can emit uniform buffers */
  102022. supportUniformBuffers: boolean;
  102023. /**
  102024. * Gets the list of emitted attributes
  102025. */
  102026. attributes: string[];
  102027. /**
  102028. * Gets the list of emitted uniforms
  102029. */
  102030. uniforms: string[];
  102031. /**
  102032. * Gets the list of emitted constants
  102033. */
  102034. constants: string[];
  102035. /**
  102036. * Gets the list of emitted samplers
  102037. */
  102038. samplers: string[];
  102039. /**
  102040. * Gets the list of emitted functions
  102041. */
  102042. functions: {
  102043. [key: string]: string;
  102044. };
  102045. /**
  102046. * Gets the list of emitted extensions
  102047. */
  102048. extensions: {
  102049. [key: string]: string;
  102050. };
  102051. /**
  102052. * Gets the target of the compilation state
  102053. */
  102054. target: NodeMaterialBlockTargets;
  102055. /**
  102056. * Gets the list of emitted counters
  102057. */
  102058. counters: {
  102059. [key: string]: number;
  102060. };
  102061. /**
  102062. * Shared data between multiple NodeMaterialBuildState instances
  102063. */
  102064. sharedData: NodeMaterialBuildStateSharedData;
  102065. /** @hidden */
  102066. _vertexState: NodeMaterialBuildState;
  102067. /** @hidden */
  102068. _attributeDeclaration: string;
  102069. /** @hidden */
  102070. _uniformDeclaration: string;
  102071. /** @hidden */
  102072. _constantDeclaration: string;
  102073. /** @hidden */
  102074. _samplerDeclaration: string;
  102075. /** @hidden */
  102076. _varyingTransfer: string;
  102077. /** @hidden */
  102078. _injectAtEnd: string;
  102079. private _repeatableContentAnchorIndex;
  102080. /** @hidden */
  102081. _builtCompilationString: string;
  102082. /**
  102083. * Gets the emitted compilation strings
  102084. */
  102085. compilationString: string;
  102086. /**
  102087. * Finalize the compilation strings
  102088. * @param state defines the current compilation state
  102089. */
  102090. finalize(state: NodeMaterialBuildState): void;
  102091. /** @hidden */
  102092. get _repeatableContentAnchor(): string;
  102093. /** @hidden */
  102094. _getFreeVariableName(prefix: string): string;
  102095. /** @hidden */
  102096. _getFreeDefineName(prefix: string): string;
  102097. /** @hidden */
  102098. _excludeVariableName(name: string): void;
  102099. /** @hidden */
  102100. _emit2DSampler(name: string): void;
  102101. /** @hidden */
  102102. _getGLType(type: NodeMaterialBlockConnectionPointTypes): string;
  102103. /** @hidden */
  102104. _emitExtension(name: string, extension: string, define?: string): void;
  102105. /** @hidden */
  102106. _emitFunction(name: string, code: string, comments: string): void;
  102107. /** @hidden */
  102108. _emitCodeFromInclude(includeName: string, comments: string, options?: {
  102109. replaceStrings?: {
  102110. search: RegExp;
  102111. replace: string;
  102112. }[];
  102113. repeatKey?: string;
  102114. }): string;
  102115. /** @hidden */
  102116. _emitFunctionFromInclude(includeName: string, comments: string, options?: {
  102117. repeatKey?: string;
  102118. removeAttributes?: boolean;
  102119. removeUniforms?: boolean;
  102120. removeVaryings?: boolean;
  102121. removeIfDef?: boolean;
  102122. replaceStrings?: {
  102123. search: RegExp;
  102124. replace: string;
  102125. }[];
  102126. }, storeKey?: string): void;
  102127. /** @hidden */
  102128. _registerTempVariable(name: string): boolean;
  102129. /** @hidden */
  102130. _emitVaryingFromString(name: string, type: string, define?: string, notDefine?: boolean): boolean;
  102131. /** @hidden */
  102132. _emitUniformFromString(name: string, type: string, define?: string, notDefine?: boolean): void;
  102133. /** @hidden */
  102134. _emitFloat(value: number): string;
  102135. }
  102136. }
  102137. declare module BABYLON {
  102138. /**
  102139. * Helper class used to generate session unique ID
  102140. */
  102141. export class UniqueIdGenerator {
  102142. private static _UniqueIdCounter;
  102143. /**
  102144. * Gets an unique (relatively to the current scene) Id
  102145. */
  102146. static get UniqueId(): number;
  102147. }
  102148. }
  102149. declare module BABYLON {
  102150. /**
  102151. * Defines a block that can be used inside a node based material
  102152. */
  102153. export class NodeMaterialBlock {
  102154. private _buildId;
  102155. private _buildTarget;
  102156. private _target;
  102157. private _isFinalMerger;
  102158. private _isInput;
  102159. private _name;
  102160. protected _isUnique: boolean;
  102161. /** Gets or sets a boolean indicating that only one input can be connected at a time */
  102162. inputsAreExclusive: boolean;
  102163. /** @hidden */
  102164. _codeVariableName: string;
  102165. /** @hidden */
  102166. _inputs: NodeMaterialConnectionPoint[];
  102167. /** @hidden */
  102168. _outputs: NodeMaterialConnectionPoint[];
  102169. /** @hidden */
  102170. _preparationId: number;
  102171. /**
  102172. * Gets the name of the block
  102173. */
  102174. get name(): string;
  102175. /**
  102176. * Sets the name of the block. Will check if the name is valid.
  102177. */
  102178. set name(newName: string);
  102179. /**
  102180. * Gets or sets the unique id of the node
  102181. */
  102182. uniqueId: number;
  102183. /**
  102184. * Gets or sets the comments associated with this block
  102185. */
  102186. comments: string;
  102187. /**
  102188. * Gets a boolean indicating that this block can only be used once per NodeMaterial
  102189. */
  102190. get isUnique(): boolean;
  102191. /**
  102192. * Gets a boolean indicating that this block is an end block (e.g. it is generating a system value)
  102193. */
  102194. get isFinalMerger(): boolean;
  102195. /**
  102196. * Gets a boolean indicating that this block is an input (e.g. it sends data to the shader)
  102197. */
  102198. get isInput(): boolean;
  102199. /**
  102200. * Gets or sets the build Id
  102201. */
  102202. get buildId(): number;
  102203. set buildId(value: number);
  102204. /**
  102205. * Gets or sets the target of the block
  102206. */
  102207. get target(): NodeMaterialBlockTargets;
  102208. set target(value: NodeMaterialBlockTargets);
  102209. /**
  102210. * Gets the list of input points
  102211. */
  102212. get inputs(): NodeMaterialConnectionPoint[];
  102213. /** Gets the list of output points */
  102214. get outputs(): NodeMaterialConnectionPoint[];
  102215. /**
  102216. * Find an input by its name
  102217. * @param name defines the name of the input to look for
  102218. * @returns the input or null if not found
  102219. */
  102220. getInputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102221. /**
  102222. * Find an output by its name
  102223. * @param name defines the name of the outputto look for
  102224. * @returns the output or null if not found
  102225. */
  102226. getOutputByName(name: string): Nullable<NodeMaterialConnectionPoint>;
  102227. /** Gets or sets a boolean indicating that this input can be edited in the Inspector (false by default) */
  102228. visibleInInspector: boolean;
  102229. /**
  102230. * Creates a new NodeMaterialBlock
  102231. * @param name defines the block name
  102232. * @param target defines the target of that block (Vertex by default)
  102233. * @param isFinalMerger defines a boolean indicating that this block is an end block (e.g. it is generating a system value). Default is false
  102234. * @param isInput defines a boolean indicating that this block is an input (e.g. it sends data to the shader). Default is false
  102235. */
  102236. constructor(name: string, target?: NodeMaterialBlockTargets, isFinalMerger?: boolean, isInput?: boolean);
  102237. /**
  102238. * Initialize the block and prepare the context for build
  102239. * @param state defines the state that will be used for the build
  102240. */
  102241. initialize(state: NodeMaterialBuildState): void;
  102242. /**
  102243. * Bind data to effect. Will only be called for blocks with isBindable === true
  102244. * @param effect defines the effect to bind data to
  102245. * @param nodeMaterial defines the hosting NodeMaterial
  102246. * @param mesh defines the mesh that will be rendered
  102247. * @param subMesh defines the submesh that will be rendered
  102248. */
  102249. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  102250. protected _declareOutput(output: NodeMaterialConnectionPoint, state: NodeMaterialBuildState): string;
  102251. protected _writeVariable(currentPoint: NodeMaterialConnectionPoint): string;
  102252. protected _writeFloat(value: number): string;
  102253. /**
  102254. * Gets the current class name e.g. "NodeMaterialBlock"
  102255. * @returns the class name
  102256. */
  102257. getClassName(): string;
  102258. /**
  102259. * Register a new input. Must be called inside a block constructor
  102260. * @param name defines the connection point name
  102261. * @param type defines the connection point type
  102262. * @param isOptional defines a boolean indicating that this input can be omitted
  102263. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102264. * @param point an already created connection point. If not provided, create a new one
  102265. * @returns the current block
  102266. */
  102267. registerInput(name: string, type: NodeMaterialBlockConnectionPointTypes, isOptional?: boolean, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102268. /**
  102269. * Register a new output. Must be called inside a block constructor
  102270. * @param name defines the connection point name
  102271. * @param type defines the connection point type
  102272. * @param target defines the target to use to limit the connection point (will be VertexAndFragment by default)
  102273. * @param point an already created connection point. If not provided, create a new one
  102274. * @returns the current block
  102275. */
  102276. registerOutput(name: string, type: NodeMaterialBlockConnectionPointTypes, target?: NodeMaterialBlockTargets, point?: NodeMaterialConnectionPoint): this;
  102277. /**
  102278. * Will return the first available input e.g. the first one which is not an uniform or an attribute
  102279. * @param forOutput defines an optional connection point to check compatibility with
  102280. * @returns the first available input or null
  102281. */
  102282. getFirstAvailableInput(forOutput?: Nullable<NodeMaterialConnectionPoint>): Nullable<NodeMaterialConnectionPoint>;
  102283. /**
  102284. * Will return the first available output e.g. the first one which is not yet connected and not a varying
  102285. * @param forBlock defines an optional block to check compatibility with
  102286. * @returns the first available input or null
  102287. */
  102288. getFirstAvailableOutput(forBlock?: Nullable<NodeMaterialBlock>): Nullable<NodeMaterialConnectionPoint>;
  102289. /**
  102290. * Gets the sibling of the given output
  102291. * @param current defines the current output
  102292. * @returns the next output in the list or null
  102293. */
  102294. getSiblingOutput(current: NodeMaterialConnectionPoint): Nullable<NodeMaterialConnectionPoint>;
  102295. /**
  102296. * Connect current block with another block
  102297. * @param other defines the block to connect with
  102298. * @param options define the various options to help pick the right connections
  102299. * @returns the current block
  102300. */
  102301. connectTo(other: NodeMaterialBlock, options?: {
  102302. input?: string;
  102303. output?: string;
  102304. outputSwizzle?: string;
  102305. }): this | undefined;
  102306. protected _buildBlock(state: NodeMaterialBuildState): void;
  102307. /**
  102308. * Add uniforms, samplers and uniform buffers at compilation time
  102309. * @param state defines the state to update
  102310. * @param nodeMaterial defines the node material requesting the update
  102311. * @param defines defines the material defines to update
  102312. * @param uniformBuffers defines the list of uniform buffer names
  102313. */
  102314. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  102315. /**
  102316. * Add potential fallbacks if shader compilation fails
  102317. * @param mesh defines the mesh to be rendered
  102318. * @param fallbacks defines the current prioritized list of fallbacks
  102319. */
  102320. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  102321. /**
  102322. * Initialize defines for shader compilation
  102323. * @param mesh defines the mesh to be rendered
  102324. * @param nodeMaterial defines the node material requesting the update
  102325. * @param defines defines the material defines to update
  102326. * @param useInstances specifies that instances should be used
  102327. */
  102328. initializeDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): void;
  102329. /**
  102330. * Update defines for shader compilation
  102331. * @param mesh defines the mesh to be rendered
  102332. * @param nodeMaterial defines the node material requesting the update
  102333. * @param defines defines the material defines to update
  102334. * @param useInstances specifies that instances should be used
  102335. * @param subMesh defines which submesh to render
  102336. */
  102337. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102338. /**
  102339. * Lets the block try to connect some inputs automatically
  102340. * @param material defines the hosting NodeMaterial
  102341. */
  102342. autoConfigure(material: NodeMaterial): void;
  102343. /**
  102344. * Function called when a block is declared as repeatable content generator
  102345. * @param vertexShaderState defines the current compilation state for the vertex shader
  102346. * @param fragmentShaderState defines the current compilation state for the fragment shader
  102347. * @param mesh defines the mesh to be rendered
  102348. * @param defines defines the material defines to update
  102349. */
  102350. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  102351. /**
  102352. * Checks if the block is ready
  102353. * @param mesh defines the mesh to be rendered
  102354. * @param nodeMaterial defines the node material requesting the update
  102355. * @param defines defines the material defines to update
  102356. * @param useInstances specifies that instances should be used
  102357. * @returns true if the block is ready
  102358. */
  102359. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean): boolean;
  102360. protected _linkConnectionTypes(inputIndex0: number, inputIndex1: number): void;
  102361. private _processBuild;
  102362. /**
  102363. * Validates the new name for the block node.
  102364. * @param newName the new name to be given to the node.
  102365. * @returns false if the name is a reserve word, else true.
  102366. */
  102367. validateBlockName(newName: string): boolean;
  102368. /**
  102369. * Compile the current node and generate the shader code
  102370. * @param state defines the current compilation state (uniforms, samplers, current string)
  102371. * @param activeBlocks defines the list of active blocks (i.e. blocks to compile)
  102372. * @returns true if already built
  102373. */
  102374. build(state: NodeMaterialBuildState, activeBlocks: NodeMaterialBlock[]): boolean;
  102375. protected _inputRename(name: string): string;
  102376. protected _outputRename(name: string): string;
  102377. protected _dumpPropertiesCode(): string;
  102378. /** @hidden */
  102379. _dumpCode(uniqueNames: string[], alreadyDumped: NodeMaterialBlock[]): string;
  102380. /** @hidden */
  102381. _dumpCodeForOutputConnections(alreadyDumped: NodeMaterialBlock[]): string;
  102382. /**
  102383. * Clone the current block to a new identical block
  102384. * @param scene defines the hosting scene
  102385. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  102386. * @returns a copy of the current block
  102387. */
  102388. clone(scene: Scene, rootUrl?: string): Nullable<NodeMaterialBlock>;
  102389. /**
  102390. * Serializes this block in a JSON representation
  102391. * @returns the serialized block object
  102392. */
  102393. serialize(): any;
  102394. /** @hidden */
  102395. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102396. private _deserializePortDisplayNamesAndExposedOnFrame;
  102397. /**
  102398. * Release resources
  102399. */
  102400. dispose(): void;
  102401. }
  102402. }
  102403. declare module BABYLON {
  102404. /**
  102405. * Base class of materials working in push mode in babylon JS
  102406. * @hidden
  102407. */
  102408. export class PushMaterial extends Material {
  102409. protected _activeEffect: Effect;
  102410. protected _normalMatrix: Matrix;
  102411. constructor(name: string, scene: Scene);
  102412. getEffect(): Effect;
  102413. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  102414. protected _isReadyForSubMesh(subMesh: SubMesh): boolean;
  102415. /**
  102416. * Binds the given world matrix to the active effect
  102417. *
  102418. * @param world the matrix to bind
  102419. */
  102420. bindOnlyWorldMatrix(world: Matrix): void;
  102421. /**
  102422. * Binds the given normal matrix to the active effect
  102423. *
  102424. * @param normalMatrix the matrix to bind
  102425. */
  102426. bindOnlyNormalMatrix(normalMatrix: Matrix): void;
  102427. bind(world: Matrix, mesh?: Mesh): void;
  102428. protected _afterBind(mesh: Mesh, effect?: Nullable<Effect>): void;
  102429. protected _mustRebind(scene: Scene, effect: Effect, visibility?: number): boolean;
  102430. }
  102431. }
  102432. declare module BABYLON {
  102433. /**
  102434. * Root class for all node material optimizers
  102435. */
  102436. export class NodeMaterialOptimizer {
  102437. /**
  102438. * Function used to optimize a NodeMaterial graph
  102439. * @param vertexOutputNodes defines the list of output nodes for the vertex shader
  102440. * @param fragmentOutputNodes defines the list of output nodes for the fragment shader
  102441. */
  102442. optimize(vertexOutputNodes: NodeMaterialBlock[], fragmentOutputNodes: NodeMaterialBlock[]): void;
  102443. }
  102444. }
  102445. declare module BABYLON {
  102446. /**
  102447. * Block used to transform a vector (2, 3 or 4) with a matrix. It will generate a Vector4
  102448. */
  102449. export class TransformBlock extends NodeMaterialBlock {
  102450. /**
  102451. * Defines the value to use to complement W value to transform it to a Vector4
  102452. */
  102453. complementW: number;
  102454. /**
  102455. * Defines the value to use to complement z value to transform it to a Vector4
  102456. */
  102457. complementZ: number;
  102458. /**
  102459. * Creates a new TransformBlock
  102460. * @param name defines the block name
  102461. */
  102462. constructor(name: string);
  102463. /**
  102464. * Gets the current class name
  102465. * @returns the class name
  102466. */
  102467. getClassName(): string;
  102468. /**
  102469. * Gets the vector input
  102470. */
  102471. get vector(): NodeMaterialConnectionPoint;
  102472. /**
  102473. * Gets the output component
  102474. */
  102475. get output(): NodeMaterialConnectionPoint;
  102476. /**
  102477. * Gets the xyz output component
  102478. */
  102479. get xyz(): NodeMaterialConnectionPoint;
  102480. /**
  102481. * Gets the matrix transform input
  102482. */
  102483. get transform(): NodeMaterialConnectionPoint;
  102484. protected _buildBlock(state: NodeMaterialBuildState): this;
  102485. /**
  102486. * Update defines for shader compilation
  102487. * @param mesh defines the mesh to be rendered
  102488. * @param nodeMaterial defines the node material requesting the update
  102489. * @param defines defines the material defines to update
  102490. * @param useInstances specifies that instances should be used
  102491. * @param subMesh defines which submesh to render
  102492. */
  102493. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  102494. serialize(): any;
  102495. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102496. protected _dumpPropertiesCode(): string;
  102497. }
  102498. }
  102499. declare module BABYLON {
  102500. /**
  102501. * Block used to output the vertex position
  102502. */
  102503. export class VertexOutputBlock extends NodeMaterialBlock {
  102504. /**
  102505. * Creates a new VertexOutputBlock
  102506. * @param name defines the block name
  102507. */
  102508. constructor(name: string);
  102509. /**
  102510. * Gets the current class name
  102511. * @returns the class name
  102512. */
  102513. getClassName(): string;
  102514. /**
  102515. * Gets the vector input component
  102516. */
  102517. get vector(): NodeMaterialConnectionPoint;
  102518. protected _buildBlock(state: NodeMaterialBuildState): this;
  102519. }
  102520. }
  102521. declare module BABYLON {
  102522. /**
  102523. * Block used to output the final color
  102524. */
  102525. export class FragmentOutputBlock extends NodeMaterialBlock {
  102526. /**
  102527. * Create a new FragmentOutputBlock
  102528. * @param name defines the block name
  102529. */
  102530. constructor(name: string);
  102531. /**
  102532. * Gets the current class name
  102533. * @returns the class name
  102534. */
  102535. getClassName(): string;
  102536. /**
  102537. * Gets the rgba input component
  102538. */
  102539. get rgba(): NodeMaterialConnectionPoint;
  102540. /**
  102541. * Gets the rgb input component
  102542. */
  102543. get rgb(): NodeMaterialConnectionPoint;
  102544. /**
  102545. * Gets the a input component
  102546. */
  102547. get a(): NodeMaterialConnectionPoint;
  102548. protected _buildBlock(state: NodeMaterialBuildState): this;
  102549. }
  102550. }
  102551. declare module BABYLON {
  102552. /**
  102553. * Block used for the particle ramp gradient section
  102554. */
  102555. export class ParticleRampGradientBlock extends NodeMaterialBlock {
  102556. /**
  102557. * Create a new ParticleRampGradientBlock
  102558. * @param name defines the block name
  102559. */
  102560. constructor(name: string);
  102561. /**
  102562. * Gets the current class name
  102563. * @returns the class name
  102564. */
  102565. getClassName(): string;
  102566. /**
  102567. * Gets the color input component
  102568. */
  102569. get color(): NodeMaterialConnectionPoint;
  102570. /**
  102571. * Gets the rampColor output component
  102572. */
  102573. get rampColor(): NodeMaterialConnectionPoint;
  102574. /**
  102575. * Initialize the block and prepare the context for build
  102576. * @param state defines the state that will be used for the build
  102577. */
  102578. initialize(state: NodeMaterialBuildState): void;
  102579. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102580. }
  102581. }
  102582. declare module BABYLON {
  102583. /**
  102584. * Block used for the particle blend multiply section
  102585. */
  102586. export class ParticleBlendMultiplyBlock extends NodeMaterialBlock {
  102587. /**
  102588. * Create a new ParticleBlendMultiplyBlock
  102589. * @param name defines the block name
  102590. */
  102591. constructor(name: string);
  102592. /**
  102593. * Gets the current class name
  102594. * @returns the class name
  102595. */
  102596. getClassName(): string;
  102597. /**
  102598. * Gets the color input component
  102599. */
  102600. get color(): NodeMaterialConnectionPoint;
  102601. /**
  102602. * Gets the alphaTexture input component
  102603. */
  102604. get alphaTexture(): NodeMaterialConnectionPoint;
  102605. /**
  102606. * Gets the alphaColor input component
  102607. */
  102608. get alphaColor(): NodeMaterialConnectionPoint;
  102609. /**
  102610. * Gets the blendColor output component
  102611. */
  102612. get blendColor(): NodeMaterialConnectionPoint;
  102613. /**
  102614. * Initialize the block and prepare the context for build
  102615. * @param state defines the state that will be used for the build
  102616. */
  102617. initialize(state: NodeMaterialBuildState): void;
  102618. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102619. }
  102620. }
  102621. declare module BABYLON {
  102622. /**
  102623. * Block used to create a Vector2/3/4 out of individual inputs (one for each component)
  102624. */
  102625. export class VectorMergerBlock extends NodeMaterialBlock {
  102626. /**
  102627. * Create a new VectorMergerBlock
  102628. * @param name defines the block name
  102629. */
  102630. constructor(name: string);
  102631. /**
  102632. * Gets the current class name
  102633. * @returns the class name
  102634. */
  102635. getClassName(): string;
  102636. /**
  102637. * Gets the xyz component (input)
  102638. */
  102639. get xyzIn(): NodeMaterialConnectionPoint;
  102640. /**
  102641. * Gets the xy component (input)
  102642. */
  102643. get xyIn(): NodeMaterialConnectionPoint;
  102644. /**
  102645. * Gets the x component (input)
  102646. */
  102647. get x(): NodeMaterialConnectionPoint;
  102648. /**
  102649. * Gets the y component (input)
  102650. */
  102651. get y(): NodeMaterialConnectionPoint;
  102652. /**
  102653. * Gets the z component (input)
  102654. */
  102655. get z(): NodeMaterialConnectionPoint;
  102656. /**
  102657. * Gets the w component (input)
  102658. */
  102659. get w(): NodeMaterialConnectionPoint;
  102660. /**
  102661. * Gets the xyzw component (output)
  102662. */
  102663. get xyzw(): NodeMaterialConnectionPoint;
  102664. /**
  102665. * Gets the xyz component (output)
  102666. */
  102667. get xyzOut(): NodeMaterialConnectionPoint;
  102668. /**
  102669. * Gets the xy component (output)
  102670. */
  102671. get xyOut(): NodeMaterialConnectionPoint;
  102672. /**
  102673. * Gets the xy component (output)
  102674. * @deprecated Please use xyOut instead.
  102675. */
  102676. get xy(): NodeMaterialConnectionPoint;
  102677. /**
  102678. * Gets the xyz component (output)
  102679. * @deprecated Please use xyzOut instead.
  102680. */
  102681. get xyz(): NodeMaterialConnectionPoint;
  102682. protected _buildBlock(state: NodeMaterialBuildState): this;
  102683. }
  102684. }
  102685. declare module BABYLON {
  102686. /**
  102687. * Block used to remap a float from a range to a new one
  102688. */
  102689. export class RemapBlock extends NodeMaterialBlock {
  102690. /**
  102691. * Gets or sets the source range
  102692. */
  102693. sourceRange: Vector2;
  102694. /**
  102695. * Gets or sets the target range
  102696. */
  102697. targetRange: Vector2;
  102698. /**
  102699. * Creates a new RemapBlock
  102700. * @param name defines the block name
  102701. */
  102702. constructor(name: string);
  102703. /**
  102704. * Gets the current class name
  102705. * @returns the class name
  102706. */
  102707. getClassName(): string;
  102708. /**
  102709. * Gets the input component
  102710. */
  102711. get input(): NodeMaterialConnectionPoint;
  102712. /**
  102713. * Gets the source min input component
  102714. */
  102715. get sourceMin(): NodeMaterialConnectionPoint;
  102716. /**
  102717. * Gets the source max input component
  102718. */
  102719. get sourceMax(): NodeMaterialConnectionPoint;
  102720. /**
  102721. * Gets the target min input component
  102722. */
  102723. get targetMin(): NodeMaterialConnectionPoint;
  102724. /**
  102725. * Gets the target max input component
  102726. */
  102727. get targetMax(): NodeMaterialConnectionPoint;
  102728. /**
  102729. * Gets the output component
  102730. */
  102731. get output(): NodeMaterialConnectionPoint;
  102732. protected _buildBlock(state: NodeMaterialBuildState): this;
  102733. protected _dumpPropertiesCode(): string;
  102734. serialize(): any;
  102735. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102736. }
  102737. }
  102738. declare module BABYLON {
  102739. /**
  102740. * Block used to multiply 2 values
  102741. */
  102742. export class MultiplyBlock extends NodeMaterialBlock {
  102743. /**
  102744. * Creates a new MultiplyBlock
  102745. * @param name defines the block name
  102746. */
  102747. constructor(name: string);
  102748. /**
  102749. * Gets the current class name
  102750. * @returns the class name
  102751. */
  102752. getClassName(): string;
  102753. /**
  102754. * Gets the left operand input component
  102755. */
  102756. get left(): NodeMaterialConnectionPoint;
  102757. /**
  102758. * Gets the right operand input component
  102759. */
  102760. get right(): NodeMaterialConnectionPoint;
  102761. /**
  102762. * Gets the output component
  102763. */
  102764. get output(): NodeMaterialConnectionPoint;
  102765. protected _buildBlock(state: NodeMaterialBuildState): this;
  102766. }
  102767. }
  102768. declare module BABYLON {
  102769. /**
  102770. * Block used to expand a Color3/4 into 4 outputs (one for each component)
  102771. */
  102772. export class ColorSplitterBlock extends NodeMaterialBlock {
  102773. /**
  102774. * Create a new ColorSplitterBlock
  102775. * @param name defines the block name
  102776. */
  102777. constructor(name: string);
  102778. /**
  102779. * Gets the current class name
  102780. * @returns the class name
  102781. */
  102782. getClassName(): string;
  102783. /**
  102784. * Gets the rgba component (input)
  102785. */
  102786. get rgba(): NodeMaterialConnectionPoint;
  102787. /**
  102788. * Gets the rgb component (input)
  102789. */
  102790. get rgbIn(): NodeMaterialConnectionPoint;
  102791. /**
  102792. * Gets the rgb component (output)
  102793. */
  102794. get rgbOut(): NodeMaterialConnectionPoint;
  102795. /**
  102796. * Gets the r component (output)
  102797. */
  102798. get r(): NodeMaterialConnectionPoint;
  102799. /**
  102800. * Gets the g component (output)
  102801. */
  102802. get g(): NodeMaterialConnectionPoint;
  102803. /**
  102804. * Gets the b component (output)
  102805. */
  102806. get b(): NodeMaterialConnectionPoint;
  102807. /**
  102808. * Gets the a component (output)
  102809. */
  102810. get a(): NodeMaterialConnectionPoint;
  102811. protected _inputRename(name: string): string;
  102812. protected _outputRename(name: string): string;
  102813. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  102814. }
  102815. }
  102816. declare module BABYLON {
  102817. /**
  102818. * Operations supported by the Trigonometry block
  102819. */
  102820. export enum TrigonometryBlockOperations {
  102821. /** Cos */
  102822. Cos = 0,
  102823. /** Sin */
  102824. Sin = 1,
  102825. /** Abs */
  102826. Abs = 2,
  102827. /** Exp */
  102828. Exp = 3,
  102829. /** Exp2 */
  102830. Exp2 = 4,
  102831. /** Round */
  102832. Round = 5,
  102833. /** Floor */
  102834. Floor = 6,
  102835. /** Ceiling */
  102836. Ceiling = 7,
  102837. /** Square root */
  102838. Sqrt = 8,
  102839. /** Log */
  102840. Log = 9,
  102841. /** Tangent */
  102842. Tan = 10,
  102843. /** Arc tangent */
  102844. ArcTan = 11,
  102845. /** Arc cosinus */
  102846. ArcCos = 12,
  102847. /** Arc sinus */
  102848. ArcSin = 13,
  102849. /** Fraction */
  102850. Fract = 14,
  102851. /** Sign */
  102852. Sign = 15,
  102853. /** To radians (from degrees) */
  102854. Radians = 16,
  102855. /** To degrees (from radians) */
  102856. Degrees = 17
  102857. }
  102858. /**
  102859. * Block used to apply trigonometry operation to floats
  102860. */
  102861. export class TrigonometryBlock extends NodeMaterialBlock {
  102862. /**
  102863. * Gets or sets the operation applied by the block
  102864. */
  102865. operation: TrigonometryBlockOperations;
  102866. /**
  102867. * Creates a new TrigonometryBlock
  102868. * @param name defines the block name
  102869. */
  102870. constructor(name: string);
  102871. /**
  102872. * Gets the current class name
  102873. * @returns the class name
  102874. */
  102875. getClassName(): string;
  102876. /**
  102877. * Gets the input component
  102878. */
  102879. get input(): NodeMaterialConnectionPoint;
  102880. /**
  102881. * Gets the output component
  102882. */
  102883. get output(): NodeMaterialConnectionPoint;
  102884. protected _buildBlock(state: NodeMaterialBuildState): this;
  102885. serialize(): any;
  102886. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  102887. protected _dumpPropertiesCode(): string;
  102888. }
  102889. }
  102890. declare module BABYLON {
  102891. /**
  102892. * Interface used to configure the node material editor
  102893. */
  102894. export interface INodeMaterialEditorOptions {
  102895. /** Define the URl to load node editor script */
  102896. editorURL?: string;
  102897. }
  102898. /** @hidden */
  102899. export class NodeMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines {
  102900. NORMAL: boolean;
  102901. TANGENT: boolean;
  102902. UV1: boolean;
  102903. /** BONES */
  102904. NUM_BONE_INFLUENCERS: number;
  102905. BonesPerMesh: number;
  102906. BONETEXTURE: boolean;
  102907. /** MORPH TARGETS */
  102908. MORPHTARGETS: boolean;
  102909. MORPHTARGETS_NORMAL: boolean;
  102910. MORPHTARGETS_TANGENT: boolean;
  102911. MORPHTARGETS_UV: boolean;
  102912. NUM_MORPH_INFLUENCERS: number;
  102913. /** IMAGE PROCESSING */
  102914. IMAGEPROCESSING: boolean;
  102915. VIGNETTE: boolean;
  102916. VIGNETTEBLENDMODEMULTIPLY: boolean;
  102917. VIGNETTEBLENDMODEOPAQUE: boolean;
  102918. TONEMAPPING: boolean;
  102919. TONEMAPPING_ACES: boolean;
  102920. CONTRAST: boolean;
  102921. EXPOSURE: boolean;
  102922. COLORCURVES: boolean;
  102923. COLORGRADING: boolean;
  102924. COLORGRADING3D: boolean;
  102925. SAMPLER3DGREENDEPTH: boolean;
  102926. SAMPLER3DBGRMAP: boolean;
  102927. IMAGEPROCESSINGPOSTPROCESS: boolean;
  102928. /** MISC. */
  102929. BUMPDIRECTUV: number;
  102930. constructor();
  102931. setValue(name: string, value: any, markAsUnprocessedIfDirty?: boolean): void;
  102932. }
  102933. /**
  102934. * Class used to configure NodeMaterial
  102935. */
  102936. export interface INodeMaterialOptions {
  102937. /**
  102938. * Defines if blocks should emit comments
  102939. */
  102940. emitComments: boolean;
  102941. }
  102942. /**
  102943. * Class used to create a node based material built by assembling shader blocks
  102944. */
  102945. export class NodeMaterial extends PushMaterial {
  102946. private static _BuildIdGenerator;
  102947. private _options;
  102948. private _vertexCompilationState;
  102949. private _fragmentCompilationState;
  102950. private _sharedData;
  102951. private _buildId;
  102952. private _buildWasSuccessful;
  102953. private _cachedWorldViewMatrix;
  102954. private _cachedWorldViewProjectionMatrix;
  102955. private _optimizers;
  102956. private _animationFrame;
  102957. /** Define the Url to load node editor script */
  102958. static EditorURL: string;
  102959. /** Define the Url to load snippets */
  102960. static SnippetUrl: string;
  102961. /** Gets or sets a boolean indicating that node materials should not deserialize textures from json / snippet content */
  102962. static IgnoreTexturesAtLoadTime: boolean;
  102963. private BJSNODEMATERIALEDITOR;
  102964. /** Get the inspector from bundle or global */
  102965. private _getGlobalNodeMaterialEditor;
  102966. /**
  102967. * Snippet ID if the material was created from the snippet server
  102968. */
  102969. snippetId: string;
  102970. /**
  102971. * Gets or sets data used by visual editor
  102972. * @see https://nme.babylonjs.com
  102973. */
  102974. editorData: any;
  102975. /**
  102976. * 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)
  102977. */
  102978. ignoreAlpha: boolean;
  102979. /**
  102980. * Defines the maximum number of lights that can be used in the material
  102981. */
  102982. maxSimultaneousLights: number;
  102983. /**
  102984. * Observable raised when the material is built
  102985. */
  102986. onBuildObservable: Observable<NodeMaterial>;
  102987. /**
  102988. * Gets or sets the root nodes of the material vertex shader
  102989. */
  102990. _vertexOutputNodes: NodeMaterialBlock[];
  102991. /**
  102992. * Gets or sets the root nodes of the material fragment (pixel) shader
  102993. */
  102994. _fragmentOutputNodes: NodeMaterialBlock[];
  102995. /** Gets or sets options to control the node material overall behavior */
  102996. get options(): INodeMaterialOptions;
  102997. set options(options: INodeMaterialOptions);
  102998. /**
  102999. * Default configuration related to image processing available in the standard Material.
  103000. */
  103001. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103002. /**
  103003. * Gets the image processing configuration used either in this material.
  103004. */
  103005. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103006. /**
  103007. * Sets the Default image processing configuration used either in the this material.
  103008. *
  103009. * If sets to null, the scene one is in use.
  103010. */
  103011. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103012. /**
  103013. * Gets an array of blocks that needs to be serialized even if they are not yet connected
  103014. */
  103015. attachedBlocks: NodeMaterialBlock[];
  103016. /**
  103017. * Specifies the mode of the node material
  103018. * @hidden
  103019. */
  103020. _mode: NodeMaterialModes;
  103021. /**
  103022. * Gets the mode property
  103023. */
  103024. get mode(): NodeMaterialModes;
  103025. /**
  103026. * Create a new node based material
  103027. * @param name defines the material name
  103028. * @param scene defines the hosting scene
  103029. * @param options defines creation option
  103030. */
  103031. constructor(name: string, scene?: Scene, options?: Partial<INodeMaterialOptions>);
  103032. /**
  103033. * Gets the current class name of the material e.g. "NodeMaterial"
  103034. * @returns the class name
  103035. */
  103036. getClassName(): string;
  103037. /**
  103038. * Keep track of the image processing observer to allow dispose and replace.
  103039. */
  103040. private _imageProcessingObserver;
  103041. /**
  103042. * Attaches a new image processing configuration to the Standard Material.
  103043. * @param configuration
  103044. */
  103045. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  103046. /**
  103047. * Get a block by its name
  103048. * @param name defines the name of the block to retrieve
  103049. * @returns the required block or null if not found
  103050. */
  103051. getBlockByName(name: string): Nullable<NodeMaterialBlock>;
  103052. /**
  103053. * Get a block by its name
  103054. * @param predicate defines the predicate used to find the good candidate
  103055. * @returns the required block or null if not found
  103056. */
  103057. getBlockByPredicate(predicate: (block: NodeMaterialBlock) => boolean): Nullable<NodeMaterialBlock>;
  103058. /**
  103059. * Get an input block by its name
  103060. * @param predicate defines the predicate used to find the good candidate
  103061. * @returns the required input block or null if not found
  103062. */
  103063. getInputBlockByPredicate(predicate: (block: InputBlock) => boolean): Nullable<InputBlock>;
  103064. /**
  103065. * Gets the list of input blocks attached to this material
  103066. * @returns an array of InputBlocks
  103067. */
  103068. getInputBlocks(): InputBlock[];
  103069. /**
  103070. * Adds a new optimizer to the list of optimizers
  103071. * @param optimizer defines the optimizers to add
  103072. * @returns the current material
  103073. */
  103074. registerOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103075. /**
  103076. * Remove an optimizer from the list of optimizers
  103077. * @param optimizer defines the optimizers to remove
  103078. * @returns the current material
  103079. */
  103080. unregisterOptimizer(optimizer: NodeMaterialOptimizer): this | undefined;
  103081. /**
  103082. * Add a new block to the list of output nodes
  103083. * @param node defines the node to add
  103084. * @returns the current material
  103085. */
  103086. addOutputNode(node: NodeMaterialBlock): this;
  103087. /**
  103088. * Remove a block from the list of root nodes
  103089. * @param node defines the node to remove
  103090. * @returns the current material
  103091. */
  103092. removeOutputNode(node: NodeMaterialBlock): this;
  103093. private _addVertexOutputNode;
  103094. private _removeVertexOutputNode;
  103095. private _addFragmentOutputNode;
  103096. private _removeFragmentOutputNode;
  103097. /**
  103098. * Specifies if the material will require alpha blending
  103099. * @returns a boolean specifying if alpha blending is needed
  103100. */
  103101. needAlphaBlending(): boolean;
  103102. /**
  103103. * Specifies if this material should be rendered in alpha test mode
  103104. * @returns a boolean specifying if an alpha test is needed.
  103105. */
  103106. needAlphaTesting(): boolean;
  103107. private _initializeBlock;
  103108. private _resetDualBlocks;
  103109. /**
  103110. * Remove a block from the current node material
  103111. * @param block defines the block to remove
  103112. */
  103113. removeBlock(block: NodeMaterialBlock): void;
  103114. /**
  103115. * Build the material and generates the inner effect
  103116. * @param verbose defines if the build should log activity
  103117. */
  103118. build(verbose?: boolean): void;
  103119. /**
  103120. * Runs an otpimization phase to try to improve the shader code
  103121. */
  103122. optimize(): void;
  103123. private _prepareDefinesForAttributes;
  103124. /**
  103125. * Create a post process from the material
  103126. * @param camera The camera to apply the render pass to.
  103127. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  103128. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  103129. * @param engine The engine which the post process will be applied. (default: current engine)
  103130. * @param reusable If the post process can be reused on the same frame. (default: false)
  103131. * @param textureType Type of textures used when performing the post process. (default: 0)
  103132. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  103133. * @returns the post process created
  103134. */
  103135. createPostProcess(camera: Nullable<Camera>, options?: number | PostProcessOptions, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, textureFormat?: number): Nullable<PostProcess>;
  103136. /**
  103137. * Create the post process effect from the material
  103138. * @param postProcess The post process to create the effect for
  103139. */
  103140. createEffectForPostProcess(postProcess: PostProcess): void;
  103141. private _createEffectForPostProcess;
  103142. /**
  103143. * Create a new procedural texture based on this node material
  103144. * @param size defines the size of the texture
  103145. * @param scene defines the hosting scene
  103146. * @returns the new procedural texture attached to this node material
  103147. */
  103148. createProceduralTexture(size: number | {
  103149. width: number;
  103150. height: number;
  103151. layers?: number;
  103152. }, scene: Scene): Nullable<ProceduralTexture>;
  103153. private _createEffectForParticles;
  103154. private _checkInternals;
  103155. /**
  103156. * Create the effect to be used as the custom effect for a particle system
  103157. * @param particleSystem Particle system to create the effect for
  103158. * @param onCompiled defines a function to call when the effect creation is successful
  103159. * @param onError defines a function to call when the effect creation has failed
  103160. */
  103161. createEffectForParticles(particleSystem: IParticleSystem, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  103162. private _processDefines;
  103163. /**
  103164. * Get if the submesh is ready to be used and all its information available.
  103165. * Child classes can use it to update shaders
  103166. * @param mesh defines the mesh to check
  103167. * @param subMesh defines which submesh to check
  103168. * @param useInstances specifies that instances should be used
  103169. * @returns a boolean indicating that the submesh is ready or not
  103170. */
  103171. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  103172. /**
  103173. * Get a string representing the shaders built by the current node graph
  103174. */
  103175. get compiledShaders(): string;
  103176. /**
  103177. * Binds the world matrix to the material
  103178. * @param world defines the world transformation matrix
  103179. */
  103180. bindOnlyWorldMatrix(world: Matrix): void;
  103181. /**
  103182. * Binds the submesh to this material by preparing the effect and shader to draw
  103183. * @param world defines the world transformation matrix
  103184. * @param mesh defines the mesh containing the submesh
  103185. * @param subMesh defines the submesh to bind the material to
  103186. */
  103187. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  103188. /**
  103189. * Gets the active textures from the material
  103190. * @returns an array of textures
  103191. */
  103192. getActiveTextures(): BaseTexture[];
  103193. /**
  103194. * Gets the list of texture blocks
  103195. * @returns an array of texture blocks
  103196. */
  103197. getTextureBlocks(): (TextureBlock | ReflectionTextureBaseBlock | RefractionBlock | CurrentScreenBlock | ParticleTextureBlock)[];
  103198. /**
  103199. * Specifies if the material uses a texture
  103200. * @param texture defines the texture to check against the material
  103201. * @returns a boolean specifying if the material uses the texture
  103202. */
  103203. hasTexture(texture: BaseTexture): boolean;
  103204. /**
  103205. * Disposes the material
  103206. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  103207. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  103208. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  103209. */
  103210. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  103211. /** Creates the node editor window. */
  103212. private _createNodeEditor;
  103213. /**
  103214. * Launch the node material editor
  103215. * @param config Define the configuration of the editor
  103216. * @return a promise fulfilled when the node editor is visible
  103217. */
  103218. edit(config?: INodeMaterialEditorOptions): Promise<void>;
  103219. /**
  103220. * Clear the current material
  103221. */
  103222. clear(): void;
  103223. /**
  103224. * Clear the current material and set it to a default state
  103225. */
  103226. setToDefault(): void;
  103227. /**
  103228. * Clear the current material and set it to a default state for post process
  103229. */
  103230. setToDefaultPostProcess(): void;
  103231. /**
  103232. * Clear the current material and set it to a default state for procedural texture
  103233. */
  103234. setToDefaultProceduralTexture(): void;
  103235. /**
  103236. * Clear the current material and set it to a default state for particle
  103237. */
  103238. setToDefaultParticle(): void;
  103239. /**
  103240. * Loads the current Node Material from a url pointing to a file save by the Node Material Editor
  103241. * @param url defines the url to load from
  103242. * @returns a promise that will fullfil when the material is fully loaded
  103243. */
  103244. loadAsync(url: string): Promise<void>;
  103245. private _gatherBlocks;
  103246. /**
  103247. * Generate a string containing the code declaration required to create an equivalent of this material
  103248. * @returns a string
  103249. */
  103250. generateCode(): string;
  103251. /**
  103252. * Serializes this material in a JSON representation
  103253. * @returns the serialized material object
  103254. */
  103255. serialize(selectedBlocks?: NodeMaterialBlock[]): any;
  103256. private _restoreConnections;
  103257. /**
  103258. * Clear the current graph and load a new one from a serialization object
  103259. * @param source defines the JSON representation of the material
  103260. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103261. * @param merge defines whether or not the source must be merged or replace the current content
  103262. */
  103263. loadFromSerialization(source: any, rootUrl?: string, merge?: boolean): void;
  103264. /**
  103265. * Makes a duplicate of the current material.
  103266. * @param name - name to use for the new material.
  103267. */
  103268. clone(name: string): NodeMaterial;
  103269. /**
  103270. * Creates a node material from parsed material data
  103271. * @param source defines the JSON representation of the material
  103272. * @param scene defines the hosting scene
  103273. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103274. * @returns a new node material
  103275. */
  103276. static Parse(source: any, scene: Scene, rootUrl?: string): NodeMaterial;
  103277. /**
  103278. * Creates a node material from a snippet saved in a remote file
  103279. * @param name defines the name of the material to create
  103280. * @param url defines the url to load from
  103281. * @param scene defines the hosting scene
  103282. * @returns a promise that will resolve to the new node material
  103283. */
  103284. static ParseFromFileAsync(name: string, url: string, scene: Scene): Promise<NodeMaterial>;
  103285. /**
  103286. * Creates a node material from a snippet saved by the node material editor
  103287. * @param snippetId defines the snippet to load
  103288. * @param scene defines the hosting scene
  103289. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  103290. * @param nodeMaterial defines a node material to update (instead of creating a new one)
  103291. * @returns a promise that will resolve to the new node material
  103292. */
  103293. static ParseFromSnippetAsync(snippetId: string, scene: Scene, rootUrl?: string, nodeMaterial?: NodeMaterial): Promise<NodeMaterial>;
  103294. /**
  103295. * Creates a new node material set to default basic configuration
  103296. * @param name defines the name of the material
  103297. * @param scene defines the hosting scene
  103298. * @returns a new NodeMaterial
  103299. */
  103300. static CreateDefault(name: string, scene?: Scene): NodeMaterial;
  103301. }
  103302. }
  103303. declare module BABYLON {
  103304. interface ThinEngine {
  103305. /**
  103306. * Unbind a list of render target textures from the webGL context
  103307. * This is used only when drawBuffer extension or webGL2 are active
  103308. * @param textures defines the render target textures to unbind
  103309. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  103310. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  103311. */
  103312. unBindMultiColorAttachmentFramebuffer(textures: InternalTexture[], disableGenerateMipMaps: boolean, onBeforeUnbind?: () => void): void;
  103313. /**
  103314. * Create a multi render target texture
  103315. * @see https://doc.babylonjs.com/features/webgl2#multiple-render-target
  103316. * @param size defines the size of the texture
  103317. * @param options defines the creation options
  103318. * @returns the cube texture as an InternalTexture
  103319. */
  103320. createMultipleRenderTarget(size: any, options: IMultiRenderTargetOptions): InternalTexture[];
  103321. /**
  103322. * Update the sample count for a given multiple render target texture
  103323. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  103324. * @param textures defines the textures to update
  103325. * @param samples defines the sample count to set
  103326. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  103327. */
  103328. updateMultipleRenderTargetTextureSampleCount(textures: Nullable<InternalTexture[]>, samples: number): number;
  103329. /**
  103330. * Select a subsets of attachments to draw to.
  103331. * @param attachments gl attachments
  103332. */
  103333. bindAttachments(attachments: number[]): void;
  103334. }
  103335. }
  103336. declare module BABYLON {
  103337. /**
  103338. * Creation options of the multi render target texture.
  103339. */
  103340. export interface IMultiRenderTargetOptions {
  103341. /**
  103342. * Define if the texture needs to create mip maps after render.
  103343. */
  103344. generateMipMaps?: boolean;
  103345. /**
  103346. * Define the types of all the draw buffers we want to create
  103347. */
  103348. types?: number[];
  103349. /**
  103350. * Define the sampling modes of all the draw buffers we want to create
  103351. */
  103352. samplingModes?: number[];
  103353. /**
  103354. * Define if a depth buffer is required
  103355. */
  103356. generateDepthBuffer?: boolean;
  103357. /**
  103358. * Define if a stencil buffer is required
  103359. */
  103360. generateStencilBuffer?: boolean;
  103361. /**
  103362. * Define if a depth texture is required instead of a depth buffer
  103363. */
  103364. generateDepthTexture?: boolean;
  103365. /**
  103366. * Define the number of desired draw buffers
  103367. */
  103368. textureCount?: number;
  103369. /**
  103370. * Define if aspect ratio should be adapted to the texture or stay the scene one
  103371. */
  103372. doNotChangeAspectRatio?: boolean;
  103373. /**
  103374. * Define the default type of the buffers we are creating
  103375. */
  103376. defaultType?: number;
  103377. }
  103378. /**
  103379. * A multi render target, like a render target provides the ability to render to a texture.
  103380. * Unlike the render target, it can render to several draw buffers in one draw.
  103381. * This is specially interesting in deferred rendering or for any effects requiring more than
  103382. * just one color from a single pass.
  103383. */
  103384. export class MultiRenderTarget extends RenderTargetTexture {
  103385. private _internalTextures;
  103386. private _textures;
  103387. private _multiRenderTargetOptions;
  103388. private _count;
  103389. /**
  103390. * Get if draw buffers are currently supported by the used hardware and browser.
  103391. */
  103392. get isSupported(): boolean;
  103393. /**
  103394. * Get the list of textures generated by the multi render target.
  103395. */
  103396. get textures(): Texture[];
  103397. /**
  103398. * Gets the number of textures in this MRT. This number can be different from `_textures.length` in case a depth texture is generated.
  103399. */
  103400. get count(): number;
  103401. /**
  103402. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  103403. */
  103404. get depthTexture(): Texture;
  103405. /**
  103406. * Set the wrapping mode on U of all the textures we are rendering to.
  103407. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103408. */
  103409. set wrapU(wrap: number);
  103410. /**
  103411. * Set the wrapping mode on V of all the textures we are rendering to.
  103412. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  103413. */
  103414. set wrapV(wrap: number);
  103415. /**
  103416. * Instantiate a new multi render target texture.
  103417. * A multi render target, like a render target provides the ability to render to a texture.
  103418. * Unlike the render target, it can render to several draw buffers in one draw.
  103419. * This is specially interesting in deferred rendering or for any effects requiring more than
  103420. * just one color from a single pass.
  103421. * @param name Define the name of the texture
  103422. * @param size Define the size of the buffers to render to
  103423. * @param count Define the number of target we are rendering into
  103424. * @param scene Define the scene the texture belongs to
  103425. * @param options Define the options used to create the multi render target
  103426. */
  103427. constructor(name: string, size: any, count: number, scene: Scene, options?: IMultiRenderTargetOptions);
  103428. private _initTypes;
  103429. /** @hidden */
  103430. _rebuild(forceFullRebuild?: boolean): void;
  103431. private _createInternalTextures;
  103432. private _createTextures;
  103433. /**
  103434. * Define the number of samples used if MSAA is enabled.
  103435. */
  103436. get samples(): number;
  103437. set samples(value: number);
  103438. /**
  103439. * Resize all the textures in the multi render target.
  103440. * Be careful as it will recreate all the data in the new texture.
  103441. * @param size Define the new size
  103442. */
  103443. resize(size: any): void;
  103444. /**
  103445. * Changes the number of render targets in this MRT
  103446. * Be careful as it will recreate all the data in the new texture.
  103447. * @param count new texture count
  103448. * @param options Specifies texture types and sampling modes for new textures
  103449. */
  103450. updateCount(count: number, options?: IMultiRenderTargetOptions): void;
  103451. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  103452. /**
  103453. * Dispose the render targets and their associated resources
  103454. */
  103455. dispose(): void;
  103456. /**
  103457. * Release all the underlying texture used as draw buffers.
  103458. */
  103459. releaseInternalTextures(): void;
  103460. }
  103461. }
  103462. declare module BABYLON {
  103463. /** @hidden */
  103464. export var imageProcessingPixelShader: {
  103465. name: string;
  103466. shader: string;
  103467. };
  103468. }
  103469. declare module BABYLON {
  103470. /**
  103471. * ImageProcessingPostProcess
  103472. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  103473. */
  103474. export class ImageProcessingPostProcess extends PostProcess {
  103475. /**
  103476. * Default configuration related to image processing available in the PBR Material.
  103477. */
  103478. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  103479. /**
  103480. * Gets the image processing configuration used either in this material.
  103481. */
  103482. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  103483. /**
  103484. * Sets the Default image processing configuration used either in the this material.
  103485. *
  103486. * If sets to null, the scene one is in use.
  103487. */
  103488. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  103489. /**
  103490. * Keep track of the image processing observer to allow dispose and replace.
  103491. */
  103492. private _imageProcessingObserver;
  103493. /**
  103494. * Attaches a new image processing configuration to the PBR Material.
  103495. * @param configuration
  103496. */
  103497. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>, doNotBuild?: boolean): void;
  103498. /**
  103499. * If the post process is supported.
  103500. */
  103501. get isSupported(): boolean;
  103502. /**
  103503. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103504. */
  103505. get colorCurves(): Nullable<ColorCurves>;
  103506. /**
  103507. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  103508. */
  103509. set colorCurves(value: Nullable<ColorCurves>);
  103510. /**
  103511. * Gets wether the color curves effect is enabled.
  103512. */
  103513. get colorCurvesEnabled(): boolean;
  103514. /**
  103515. * Sets wether the color curves effect is enabled.
  103516. */
  103517. set colorCurvesEnabled(value: boolean);
  103518. /**
  103519. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103520. */
  103521. get colorGradingTexture(): Nullable<BaseTexture>;
  103522. /**
  103523. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  103524. */
  103525. set colorGradingTexture(value: Nullable<BaseTexture>);
  103526. /**
  103527. * Gets wether the color grading effect is enabled.
  103528. */
  103529. get colorGradingEnabled(): boolean;
  103530. /**
  103531. * Gets wether the color grading effect is enabled.
  103532. */
  103533. set colorGradingEnabled(value: boolean);
  103534. /**
  103535. * Gets exposure used in the effect.
  103536. */
  103537. get exposure(): number;
  103538. /**
  103539. * Sets exposure used in the effect.
  103540. */
  103541. set exposure(value: number);
  103542. /**
  103543. * Gets wether tonemapping is enabled or not.
  103544. */
  103545. get toneMappingEnabled(): boolean;
  103546. /**
  103547. * Sets wether tonemapping is enabled or not
  103548. */
  103549. set toneMappingEnabled(value: boolean);
  103550. /**
  103551. * Gets the type of tone mapping effect.
  103552. */
  103553. get toneMappingType(): number;
  103554. /**
  103555. * Sets the type of tone mapping effect.
  103556. */
  103557. set toneMappingType(value: number);
  103558. /**
  103559. * Gets contrast used in the effect.
  103560. */
  103561. get contrast(): number;
  103562. /**
  103563. * Sets contrast used in the effect.
  103564. */
  103565. set contrast(value: number);
  103566. /**
  103567. * Gets Vignette stretch size.
  103568. */
  103569. get vignetteStretch(): number;
  103570. /**
  103571. * Sets Vignette stretch size.
  103572. */
  103573. set vignetteStretch(value: number);
  103574. /**
  103575. * Gets Vignette centre X Offset.
  103576. */
  103577. get vignetteCentreX(): number;
  103578. /**
  103579. * Sets Vignette centre X Offset.
  103580. */
  103581. set vignetteCentreX(value: number);
  103582. /**
  103583. * Gets Vignette centre Y Offset.
  103584. */
  103585. get vignetteCentreY(): number;
  103586. /**
  103587. * Sets Vignette centre Y Offset.
  103588. */
  103589. set vignetteCentreY(value: number);
  103590. /**
  103591. * Gets Vignette weight or intensity of the vignette effect.
  103592. */
  103593. get vignetteWeight(): number;
  103594. /**
  103595. * Sets Vignette weight or intensity of the vignette effect.
  103596. */
  103597. set vignetteWeight(value: number);
  103598. /**
  103599. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103600. * if vignetteEnabled is set to true.
  103601. */
  103602. get vignetteColor(): Color4;
  103603. /**
  103604. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  103605. * if vignetteEnabled is set to true.
  103606. */
  103607. set vignetteColor(value: Color4);
  103608. /**
  103609. * Gets Camera field of view used by the Vignette effect.
  103610. */
  103611. get vignetteCameraFov(): number;
  103612. /**
  103613. * Sets Camera field of view used by the Vignette effect.
  103614. */
  103615. set vignetteCameraFov(value: number);
  103616. /**
  103617. * Gets the vignette blend mode allowing different kind of effect.
  103618. */
  103619. get vignetteBlendMode(): number;
  103620. /**
  103621. * Sets the vignette blend mode allowing different kind of effect.
  103622. */
  103623. set vignetteBlendMode(value: number);
  103624. /**
  103625. * Gets wether the vignette effect is enabled.
  103626. */
  103627. get vignetteEnabled(): boolean;
  103628. /**
  103629. * Sets wether the vignette effect is enabled.
  103630. */
  103631. set vignetteEnabled(value: boolean);
  103632. private _fromLinearSpace;
  103633. /**
  103634. * Gets wether the input of the processing is in Gamma or Linear Space.
  103635. */
  103636. get fromLinearSpace(): boolean;
  103637. /**
  103638. * Sets wether the input of the processing is in Gamma or Linear Space.
  103639. */
  103640. set fromLinearSpace(value: boolean);
  103641. /**
  103642. * Defines cache preventing GC.
  103643. */
  103644. private _defines;
  103645. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, imageProcessingConfiguration?: ImageProcessingConfiguration);
  103646. /**
  103647. * "ImageProcessingPostProcess"
  103648. * @returns "ImageProcessingPostProcess"
  103649. */
  103650. getClassName(): string;
  103651. /**
  103652. * @hidden
  103653. */
  103654. _updateParameters(): void;
  103655. dispose(camera?: Camera): void;
  103656. }
  103657. }
  103658. declare module BABYLON {
  103659. /**
  103660. * Interface for defining prepass effects in the prepass post-process pipeline
  103661. */
  103662. export interface PrePassEffectConfiguration {
  103663. /**
  103664. * Name of the effect
  103665. */
  103666. name: string;
  103667. /**
  103668. * Post process to attach for this effect
  103669. */
  103670. postProcess?: PostProcess;
  103671. /**
  103672. * Textures required in the MRT
  103673. */
  103674. texturesRequired: number[];
  103675. /**
  103676. * Is the effect enabled
  103677. */
  103678. enabled: boolean;
  103679. /**
  103680. * Disposes the effect configuration
  103681. */
  103682. dispose?: () => void;
  103683. /**
  103684. * Creates the associated post process
  103685. */
  103686. createPostProcess?: () => PostProcess;
  103687. }
  103688. }
  103689. declare module BABYLON {
  103690. /**
  103691. * Renders a pre pass of the scene
  103692. * This means every mesh in the scene will be rendered to a render target texture
  103693. * And then this texture will be composited to the rendering canvas with post processes
  103694. * It is necessary for effects like subsurface scattering or deferred shading
  103695. */
  103696. export class PrePassRenderer {
  103697. /** @hidden */
  103698. static _SceneComponentInitialization: (scene: Scene) => void;
  103699. private _textureFormats;
  103700. /**
  103701. * To save performance, we can excluded skinned meshes from the prepass
  103702. */
  103703. excludedSkinnedMesh: AbstractMesh[];
  103704. private _textureIndices;
  103705. private _scene;
  103706. private _engine;
  103707. private _isDirty;
  103708. /**
  103709. * Number of textures in the multi render target texture where the scene is directly rendered
  103710. */
  103711. mrtCount: number;
  103712. /**
  103713. * The render target where the scene is directly rendered
  103714. */
  103715. prePassRT: MultiRenderTarget;
  103716. private _multiRenderAttachments;
  103717. private _defaultAttachments;
  103718. private _clearAttachments;
  103719. private _postProcesses;
  103720. private readonly _clearColor;
  103721. /**
  103722. * Image processing post process for composition
  103723. */
  103724. imageProcessingPostProcess: ImageProcessingPostProcess;
  103725. /**
  103726. * Configuration for prepass effects
  103727. */
  103728. private _effectConfigurations;
  103729. private _mrtFormats;
  103730. private _mrtLayout;
  103731. private _enabled;
  103732. /**
  103733. * Indicates if the prepass is enabled
  103734. */
  103735. get enabled(): boolean;
  103736. /**
  103737. * How many samples are used for MSAA of the scene render target
  103738. */
  103739. get samples(): number;
  103740. set samples(n: number);
  103741. /**
  103742. * Instanciates a prepass renderer
  103743. * @param scene The scene
  103744. */
  103745. constructor(scene: Scene);
  103746. private _initializeAttachments;
  103747. private _createCompositionEffect;
  103748. /**
  103749. * Indicates if rendering a prepass is supported
  103750. */
  103751. get isSupported(): boolean;
  103752. /**
  103753. * Sets the proper output textures to draw in the engine.
  103754. * @param effect The effect that is drawn. It can be or not be compatible with drawing to several output textures.
  103755. */
  103756. bindAttachmentsForEffect(effect: Effect): void;
  103757. /**
  103758. * @hidden
  103759. */
  103760. _beforeCameraDraw(): void;
  103761. /**
  103762. * @hidden
  103763. */
  103764. _afterCameraDraw(): void;
  103765. private _checkRTSize;
  103766. private _bindFrameBuffer;
  103767. /**
  103768. * Clears the scene render target (in the sense of settings pixels to the scene clear color value)
  103769. */
  103770. clear(): void;
  103771. private _setState;
  103772. /**
  103773. * Adds an effect configuration to the prepass.
  103774. * If an effect has already been added, it won't add it twice and will return the configuration
  103775. * already present.
  103776. * @param cfg the effect configuration
  103777. * @return the effect configuration now used by the prepass
  103778. */
  103779. addEffectConfiguration(cfg: PrePassEffectConfiguration): PrePassEffectConfiguration;
  103780. /**
  103781. * Returns the index of a texture in the multi render target texture array.
  103782. * @param type Texture type
  103783. * @return The index
  103784. */
  103785. getIndex(type: number): number;
  103786. private _enable;
  103787. private _disable;
  103788. private _resetLayout;
  103789. private _resetPostProcessChain;
  103790. private _bindPostProcessChain;
  103791. /**
  103792. * Marks the prepass renderer as dirty, triggering a check if the prepass is necessary for the next rendering.
  103793. */
  103794. markAsDirty(): void;
  103795. /**
  103796. * Enables a texture on the MultiRenderTarget for prepass
  103797. */
  103798. private _enableTextures;
  103799. private _update;
  103800. private _markAllMaterialsAsPrePassDirty;
  103801. /**
  103802. * Disposes the prepass renderer.
  103803. */
  103804. dispose(): void;
  103805. }
  103806. }
  103807. declare module BABYLON {
  103808. /**
  103809. * Size options for a post process
  103810. */
  103811. export type PostProcessOptions = {
  103812. width: number;
  103813. height: number;
  103814. };
  103815. /**
  103816. * PostProcess can be used to apply a shader to a texture after it has been rendered
  103817. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  103818. */
  103819. export class PostProcess {
  103820. /**
  103821. * Gets or sets the unique id of the post process
  103822. */
  103823. uniqueId: number;
  103824. /** Name of the PostProcess. */
  103825. name: string;
  103826. /**
  103827. * Width of the texture to apply the post process on
  103828. */
  103829. width: number;
  103830. /**
  103831. * Height of the texture to apply the post process on
  103832. */
  103833. height: number;
  103834. /**
  103835. * Gets the node material used to create this postprocess (null if the postprocess was manually created)
  103836. */
  103837. nodeMaterialSource: Nullable<NodeMaterial>;
  103838. /**
  103839. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  103840. * @hidden
  103841. */
  103842. _outputTexture: Nullable<InternalTexture>;
  103843. /**
  103844. * Sampling mode used by the shader
  103845. * See https://doc.babylonjs.com/classes/3.1/texture
  103846. */
  103847. renderTargetSamplingMode: number;
  103848. /**
  103849. * Clear color to use when screen clearing
  103850. */
  103851. clearColor: Color4;
  103852. /**
  103853. * If the buffer needs to be cleared before applying the post process. (default: true)
  103854. * Should be set to false if shader will overwrite all previous pixels.
  103855. */
  103856. autoClear: boolean;
  103857. /**
  103858. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  103859. */
  103860. alphaMode: number;
  103861. /**
  103862. * Sets the setAlphaBlendConstants of the babylon engine
  103863. */
  103864. alphaConstants: Color4;
  103865. /**
  103866. * Animations to be used for the post processing
  103867. */
  103868. animations: Animation[];
  103869. /**
  103870. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  103871. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  103872. */
  103873. enablePixelPerfectMode: boolean;
  103874. /**
  103875. * Force the postprocess to be applied without taking in account viewport
  103876. */
  103877. forceFullscreenViewport: boolean;
  103878. /**
  103879. * List of inspectable custom properties (used by the Inspector)
  103880. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  103881. */
  103882. inspectableCustomProperties: IInspectable[];
  103883. /**
  103884. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  103885. *
  103886. * | Value | Type | Description |
  103887. * | ----- | ----------------------------------- | ----------- |
  103888. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  103889. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  103890. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](https://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  103891. *
  103892. */
  103893. scaleMode: number;
  103894. /**
  103895. * Force textures to be a power of two (default: false)
  103896. */
  103897. alwaysForcePOT: boolean;
  103898. private _samples;
  103899. /**
  103900. * Number of sample textures (default: 1)
  103901. */
  103902. get samples(): number;
  103903. set samples(n: number);
  103904. /**
  103905. * Modify the scale of the post process to be the same as the viewport (default: false)
  103906. */
  103907. adaptScaleToCurrentViewport: boolean;
  103908. private _camera;
  103909. protected _scene: Scene;
  103910. private _engine;
  103911. private _options;
  103912. private _reusable;
  103913. private _textureType;
  103914. private _textureFormat;
  103915. /**
  103916. * Smart array of input and output textures for the post process.
  103917. * @hidden
  103918. */
  103919. _textures: SmartArray<InternalTexture>;
  103920. /**
  103921. * The index in _textures that corresponds to the output texture.
  103922. * @hidden
  103923. */
  103924. _currentRenderTextureInd: number;
  103925. private _effect;
  103926. private _samplers;
  103927. private _fragmentUrl;
  103928. private _vertexUrl;
  103929. private _parameters;
  103930. private _scaleRatio;
  103931. protected _indexParameters: any;
  103932. private _shareOutputWithPostProcess;
  103933. private _texelSize;
  103934. private _forcedOutputTexture;
  103935. /**
  103936. * Prepass configuration in case this post process needs a texture from prepass
  103937. * @hidden
  103938. */
  103939. _prePassEffectConfiguration: PrePassEffectConfiguration;
  103940. /**
  103941. * Returns the fragment url or shader name used in the post process.
  103942. * @returns the fragment url or name in the shader store.
  103943. */
  103944. getEffectName(): string;
  103945. /**
  103946. * An event triggered when the postprocess is activated.
  103947. */
  103948. onActivateObservable: Observable<Camera>;
  103949. private _onActivateObserver;
  103950. /**
  103951. * A function that is added to the onActivateObservable
  103952. */
  103953. set onActivate(callback: Nullable<(camera: Camera) => void>);
  103954. /**
  103955. * An event triggered when the postprocess changes its size.
  103956. */
  103957. onSizeChangedObservable: Observable<PostProcess>;
  103958. private _onSizeChangedObserver;
  103959. /**
  103960. * A function that is added to the onSizeChangedObservable
  103961. */
  103962. set onSizeChanged(callback: (postProcess: PostProcess) => void);
  103963. /**
  103964. * An event triggered when the postprocess applies its effect.
  103965. */
  103966. onApplyObservable: Observable<Effect>;
  103967. private _onApplyObserver;
  103968. /**
  103969. * A function that is added to the onApplyObservable
  103970. */
  103971. set onApply(callback: (effect: Effect) => void);
  103972. /**
  103973. * An event triggered before rendering the postprocess
  103974. */
  103975. onBeforeRenderObservable: Observable<Effect>;
  103976. private _onBeforeRenderObserver;
  103977. /**
  103978. * A function that is added to the onBeforeRenderObservable
  103979. */
  103980. set onBeforeRender(callback: (effect: Effect) => void);
  103981. /**
  103982. * An event triggered after rendering the postprocess
  103983. */
  103984. onAfterRenderObservable: Observable<Effect>;
  103985. private _onAfterRenderObserver;
  103986. /**
  103987. * A function that is added to the onAfterRenderObservable
  103988. */
  103989. set onAfterRender(callback: (efect: Effect) => void);
  103990. /**
  103991. * 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
  103992. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  103993. */
  103994. get inputTexture(): InternalTexture;
  103995. set inputTexture(value: InternalTexture);
  103996. /**
  103997. * Since inputTexture should always be defined, if we previously manually set `inputTexture`,
  103998. * the only way to unset it is to use this function to restore its internal state
  103999. */
  104000. restoreDefaultInputTexture(): void;
  104001. /**
  104002. * Gets the camera which post process is applied to.
  104003. * @returns The camera the post process is applied to.
  104004. */
  104005. getCamera(): Camera;
  104006. /**
  104007. * Gets the texel size of the postprocess.
  104008. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  104009. */
  104010. get texelSize(): Vector2;
  104011. /**
  104012. * Creates a new instance PostProcess
  104013. * @param name The name of the PostProcess.
  104014. * @param fragmentUrl The url of the fragment shader to be used.
  104015. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  104016. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  104017. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104018. * @param camera The camera to apply the render pass to.
  104019. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104020. * @param engine The engine which the post process will be applied. (default: current engine)
  104021. * @param reusable If the post process can be reused on the same frame. (default: false)
  104022. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  104023. * @param textureType Type of textures used when performing the post process. (default: 0)
  104024. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  104025. * @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
  104026. * @param blockCompilation If the shader should not be compiled immediatly. (default: false)
  104027. * @param textureFormat Format of textures used when performing the post process. (default: TEXTUREFORMAT_RGBA)
  104028. */
  104029. 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);
  104030. /**
  104031. * Gets a string identifying the name of the class
  104032. * @returns "PostProcess" string
  104033. */
  104034. getClassName(): string;
  104035. /**
  104036. * Gets the engine which this post process belongs to.
  104037. * @returns The engine the post process was enabled with.
  104038. */
  104039. getEngine(): Engine;
  104040. /**
  104041. * The effect that is created when initializing the post process.
  104042. * @returns The created effect corresponding the the postprocess.
  104043. */
  104044. getEffect(): Effect;
  104045. /**
  104046. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  104047. * @param postProcess The post process to share the output with.
  104048. * @returns This post process.
  104049. */
  104050. shareOutputWith(postProcess: PostProcess): PostProcess;
  104051. /**
  104052. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  104053. * This should be called if the post process that shares output with this post process is disabled/disposed.
  104054. */
  104055. useOwnOutput(): void;
  104056. /**
  104057. * Updates the effect with the current post process compile time values and recompiles the shader.
  104058. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104059. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104060. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104061. * @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
  104062. * @param onCompiled Called when the shader has been compiled.
  104063. * @param onError Called if there is an error when compiling a shader.
  104064. * @param vertexUrl The url of the vertex shader to be used (default: the one given at construction time)
  104065. * @param fragmentUrl The url of the fragment shader to be used (default: the one given at construction time)
  104066. */
  104067. 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;
  104068. /**
  104069. * The post process is reusable if it can be used multiple times within one frame.
  104070. * @returns If the post process is reusable
  104071. */
  104072. isReusable(): boolean;
  104073. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  104074. markTextureDirty(): void;
  104075. /**
  104076. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  104077. * 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.
  104078. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  104079. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  104080. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  104081. * @returns The target texture that was bound to be written to.
  104082. */
  104083. activate(camera: Nullable<Camera>, sourceTexture?: Nullable<InternalTexture>, forceDepthStencil?: boolean): InternalTexture;
  104084. /**
  104085. * If the post process is supported.
  104086. */
  104087. get isSupported(): boolean;
  104088. /**
  104089. * The aspect ratio of the output texture.
  104090. */
  104091. get aspectRatio(): number;
  104092. /**
  104093. * Get a value indicating if the post-process is ready to be used
  104094. * @returns true if the post-process is ready (shader is compiled)
  104095. */
  104096. isReady(): boolean;
  104097. /**
  104098. * Binds all textures and uniforms to the shader, this will be run on every pass.
  104099. * @returns the effect corresponding to this post process. Null if not compiled or not ready.
  104100. */
  104101. apply(): Nullable<Effect>;
  104102. private _disposeTextures;
  104103. /**
  104104. * Sets the required values to the prepass renderer.
  104105. * @param prePassRenderer defines the prepass renderer to setup.
  104106. * @returns true if the pre pass is needed.
  104107. */
  104108. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  104109. /**
  104110. * Disposes the post process.
  104111. * @param camera The camera to dispose the post process on.
  104112. */
  104113. dispose(camera?: Camera): void;
  104114. /**
  104115. * Serializes the particle system to a JSON object
  104116. * @returns the JSON object
  104117. */
  104118. serialize(): any;
  104119. /**
  104120. * Creates a material from parsed material data
  104121. * @param parsedPostProcess defines parsed post process data
  104122. * @param scene defines the hosting scene
  104123. * @param rootUrl defines the root URL to use to load textures
  104124. * @returns a new post process
  104125. */
  104126. static Parse(parsedPostProcess: any, scene: Scene, rootUrl: string): Nullable<PostProcess>;
  104127. }
  104128. }
  104129. declare module BABYLON {
  104130. /** @hidden */
  104131. export var kernelBlurVaryingDeclaration: {
  104132. name: string;
  104133. shader: string;
  104134. };
  104135. }
  104136. declare module BABYLON {
  104137. /** @hidden */
  104138. export var kernelBlurFragment: {
  104139. name: string;
  104140. shader: string;
  104141. };
  104142. }
  104143. declare module BABYLON {
  104144. /** @hidden */
  104145. export var kernelBlurFragment2: {
  104146. name: string;
  104147. shader: string;
  104148. };
  104149. }
  104150. declare module BABYLON {
  104151. /** @hidden */
  104152. export var kernelBlurPixelShader: {
  104153. name: string;
  104154. shader: string;
  104155. };
  104156. }
  104157. declare module BABYLON {
  104158. /** @hidden */
  104159. export var kernelBlurVertex: {
  104160. name: string;
  104161. shader: string;
  104162. };
  104163. }
  104164. declare module BABYLON {
  104165. /** @hidden */
  104166. export var kernelBlurVertexShader: {
  104167. name: string;
  104168. shader: string;
  104169. };
  104170. }
  104171. declare module BABYLON {
  104172. /**
  104173. * The Blur Post Process which blurs an image based on a kernel and direction.
  104174. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  104175. */
  104176. export class BlurPostProcess extends PostProcess {
  104177. private blockCompilation;
  104178. protected _kernel: number;
  104179. protected _idealKernel: number;
  104180. protected _packedFloat: boolean;
  104181. private _staticDefines;
  104182. /** The direction in which to blur the image. */
  104183. direction: Vector2;
  104184. /**
  104185. * Sets the length in pixels of the blur sample region
  104186. */
  104187. set kernel(v: number);
  104188. /**
  104189. * Gets the length in pixels of the blur sample region
  104190. */
  104191. get kernel(): number;
  104192. /**
  104193. * Sets wether or not the blur needs to unpack/repack floats
  104194. */
  104195. set packedFloat(v: boolean);
  104196. /**
  104197. * Gets wether or not the blur is unpacking/repacking floats
  104198. */
  104199. get packedFloat(): boolean;
  104200. /**
  104201. * Gets a string identifying the name of the class
  104202. * @returns "BlurPostProcess" string
  104203. */
  104204. getClassName(): string;
  104205. /**
  104206. * Creates a new instance BlurPostProcess
  104207. * @param name The name of the effect.
  104208. * @param direction The direction in which to blur the image.
  104209. * @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.
  104210. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  104211. * @param camera The camera to apply the render pass to.
  104212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  104213. * @param engine The engine which the post process will be applied. (default: current engine)
  104214. * @param reusable If the post process can be reused on the same frame. (default: false)
  104215. * @param textureType Type of textures used when performing the post process. (default: 0)
  104216. * @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)
  104217. */
  104218. 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);
  104219. /**
  104220. * Updates the effect with the current post process compile time values and recompiles the shader.
  104221. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  104222. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  104223. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  104224. * @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
  104225. * @param onCompiled Called when the shader has been compiled.
  104226. * @param onError Called if there is an error when compiling a shader.
  104227. */
  104228. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104229. protected _updateParameters(onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  104230. /**
  104231. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  104232. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  104233. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  104234. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  104235. * The gaps between physical kernels are compensated for in the weighting of the samples
  104236. * @param idealKernel Ideal blur kernel.
  104237. * @return Nearest best kernel.
  104238. */
  104239. protected _nearestBestKernel(idealKernel: number): number;
  104240. /**
  104241. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  104242. * @param x The point on the Gaussian distribution to sample.
  104243. * @return the value of the Gaussian function at x.
  104244. */
  104245. protected _gaussianWeight(x: number): number;
  104246. /**
  104247. * Generates a string that can be used as a floating point number in GLSL.
  104248. * @param x Value to print.
  104249. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  104250. * @return GLSL float string.
  104251. */
  104252. protected _glslFloat(x: number, decimalFigures?: number): string;
  104253. /** @hidden */
  104254. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlurPostProcess>;
  104255. }
  104256. }
  104257. declare module BABYLON {
  104258. /**
  104259. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104260. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104261. * You can then easily use it as a reflectionTexture on a flat surface.
  104262. * In case the surface is not a plane, please consider relying on reflection probes.
  104263. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104264. */
  104265. export class MirrorTexture extends RenderTargetTexture {
  104266. private scene;
  104267. /**
  104268. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  104269. * 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.
  104270. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104271. */
  104272. mirrorPlane: Plane;
  104273. /**
  104274. * Define the blur ratio used to blur the reflection if needed.
  104275. */
  104276. set blurRatio(value: number);
  104277. get blurRatio(): number;
  104278. /**
  104279. * Define the adaptive blur kernel used to blur the reflection if needed.
  104280. * This will autocompute the closest best match for the `blurKernel`
  104281. */
  104282. set adaptiveBlurKernel(value: number);
  104283. /**
  104284. * Define the blur kernel used to blur the reflection if needed.
  104285. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104286. */
  104287. set blurKernel(value: number);
  104288. /**
  104289. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  104290. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104291. */
  104292. set blurKernelX(value: number);
  104293. get blurKernelX(): number;
  104294. /**
  104295. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  104296. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  104297. */
  104298. set blurKernelY(value: number);
  104299. get blurKernelY(): number;
  104300. private _autoComputeBlurKernel;
  104301. protected _onRatioRescale(): void;
  104302. private _updateGammaSpace;
  104303. private _imageProcessingConfigChangeObserver;
  104304. private _transformMatrix;
  104305. private _mirrorMatrix;
  104306. private _savedViewMatrix;
  104307. private _blurX;
  104308. private _blurY;
  104309. private _adaptiveBlurKernel;
  104310. private _blurKernelX;
  104311. private _blurKernelY;
  104312. private _blurRatio;
  104313. /**
  104314. * Instantiates a Mirror Texture.
  104315. * Mirror texture can be used to simulate the view from a mirror in a scene.
  104316. * It will dynamically be rendered every frame to adapt to the camera point of view.
  104317. * You can then easily use it as a reflectionTexture on a flat surface.
  104318. * In case the surface is not a plane, please consider relying on reflection probes.
  104319. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  104320. * @param name
  104321. * @param size
  104322. * @param scene
  104323. * @param generateMipMaps
  104324. * @param type
  104325. * @param samplingMode
  104326. * @param generateDepthBuffer
  104327. */
  104328. constructor(name: string, size: number | {
  104329. width: number;
  104330. height: number;
  104331. } | {
  104332. ratio: number;
  104333. }, scene: Scene, generateMipMaps?: boolean, type?: number, samplingMode?: number, generateDepthBuffer?: boolean);
  104334. private _preparePostProcesses;
  104335. /**
  104336. * Clone the mirror texture.
  104337. * @returns the cloned texture
  104338. */
  104339. clone(): MirrorTexture;
  104340. /**
  104341. * Serialize the texture to a JSON representation you could use in Parse later on
  104342. * @returns the serialized JSON representation
  104343. */
  104344. serialize(): any;
  104345. /**
  104346. * Dispose the texture and release its associated resources.
  104347. */
  104348. dispose(): void;
  104349. }
  104350. }
  104351. declare module BABYLON {
  104352. /**
  104353. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104354. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104355. */
  104356. export class Texture extends BaseTexture {
  104357. /**
  104358. * Gets or sets a general boolean used to indicate that textures containing direct data (buffers) must be saved as part of the serialization process
  104359. */
  104360. static SerializeBuffers: boolean;
  104361. /** @hidden */
  104362. static _CubeTextureParser: (jsonTexture: any, scene: Scene, rootUrl: string) => CubeTexture;
  104363. /** @hidden */
  104364. static _CreateMirror: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => MirrorTexture;
  104365. /** @hidden */
  104366. static _CreateRenderTargetTexture: (name: string, renderTargetSize: number, scene: Scene, generateMipMaps: boolean) => RenderTargetTexture;
  104367. /** nearest is mag = nearest and min = nearest and mip = linear */
  104368. static readonly NEAREST_SAMPLINGMODE: number;
  104369. /** nearest is mag = nearest and min = nearest and mip = linear */
  104370. static readonly NEAREST_NEAREST_MIPLINEAR: number;
  104371. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104372. static readonly BILINEAR_SAMPLINGMODE: number;
  104373. /** Bilinear is mag = linear and min = linear and mip = nearest */
  104374. static readonly LINEAR_LINEAR_MIPNEAREST: number;
  104375. /** Trilinear is mag = linear and min = linear and mip = linear */
  104376. static readonly TRILINEAR_SAMPLINGMODE: number;
  104377. /** Trilinear is mag = linear and min = linear and mip = linear */
  104378. static readonly LINEAR_LINEAR_MIPLINEAR: number;
  104379. /** mag = nearest and min = nearest and mip = nearest */
  104380. static readonly NEAREST_NEAREST_MIPNEAREST: number;
  104381. /** mag = nearest and min = linear and mip = nearest */
  104382. static readonly NEAREST_LINEAR_MIPNEAREST: number;
  104383. /** mag = nearest and min = linear and mip = linear */
  104384. static readonly NEAREST_LINEAR_MIPLINEAR: number;
  104385. /** mag = nearest and min = linear and mip = none */
  104386. static readonly NEAREST_LINEAR: number;
  104387. /** mag = nearest and min = nearest and mip = none */
  104388. static readonly NEAREST_NEAREST: number;
  104389. /** mag = linear and min = nearest and mip = nearest */
  104390. static readonly LINEAR_NEAREST_MIPNEAREST: number;
  104391. /** mag = linear and min = nearest and mip = linear */
  104392. static readonly LINEAR_NEAREST_MIPLINEAR: number;
  104393. /** mag = linear and min = linear and mip = none */
  104394. static readonly LINEAR_LINEAR: number;
  104395. /** mag = linear and min = nearest and mip = none */
  104396. static readonly LINEAR_NEAREST: number;
  104397. /** Explicit coordinates mode */
  104398. static readonly EXPLICIT_MODE: number;
  104399. /** Spherical coordinates mode */
  104400. static readonly SPHERICAL_MODE: number;
  104401. /** Planar coordinates mode */
  104402. static readonly PLANAR_MODE: number;
  104403. /** Cubic coordinates mode */
  104404. static readonly CUBIC_MODE: number;
  104405. /** Projection coordinates mode */
  104406. static readonly PROJECTION_MODE: number;
  104407. /** Inverse Cubic coordinates mode */
  104408. static readonly SKYBOX_MODE: number;
  104409. /** Inverse Cubic coordinates mode */
  104410. static readonly INVCUBIC_MODE: number;
  104411. /** Equirectangular coordinates mode */
  104412. static readonly EQUIRECTANGULAR_MODE: number;
  104413. /** Equirectangular Fixed coordinates mode */
  104414. static readonly FIXED_EQUIRECTANGULAR_MODE: number;
  104415. /** Equirectangular Fixed Mirrored coordinates mode */
  104416. static readonly FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  104417. /** Texture is not repeating outside of 0..1 UVs */
  104418. static readonly CLAMP_ADDRESSMODE: number;
  104419. /** Texture is repeating outside of 0..1 UVs */
  104420. static readonly WRAP_ADDRESSMODE: number;
  104421. /** Texture is repeating and mirrored */
  104422. static readonly MIRROR_ADDRESSMODE: number;
  104423. /**
  104424. * 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
  104425. */
  104426. static UseSerializedUrlIfAny: boolean;
  104427. /**
  104428. * Define the url of the texture.
  104429. */
  104430. url: Nullable<string>;
  104431. /**
  104432. * Define an offset on the texture to offset the u coordinates of the UVs
  104433. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104434. */
  104435. uOffset: number;
  104436. /**
  104437. * Define an offset on the texture to offset the v coordinates of the UVs
  104438. * @see https://doc.babylonjs.com/how_to/more_materials#offsetting
  104439. */
  104440. vOffset: number;
  104441. /**
  104442. * Define an offset on the texture to scale the u coordinates of the UVs
  104443. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104444. */
  104445. uScale: number;
  104446. /**
  104447. * Define an offset on the texture to scale the v coordinates of the UVs
  104448. * @see https://doc.babylonjs.com/how_to/more_materials#tiling
  104449. */
  104450. vScale: number;
  104451. /**
  104452. * Define an offset on the texture to rotate around the u coordinates of the UVs
  104453. * @see https://doc.babylonjs.com/how_to/more_materials
  104454. */
  104455. uAng: number;
  104456. /**
  104457. * Define an offset on the texture to rotate around the v coordinates of the UVs
  104458. * @see https://doc.babylonjs.com/how_to/more_materials
  104459. */
  104460. vAng: number;
  104461. /**
  104462. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  104463. * @see https://doc.babylonjs.com/how_to/more_materials
  104464. */
  104465. wAng: number;
  104466. /**
  104467. * Defines the center of rotation (U)
  104468. */
  104469. uRotationCenter: number;
  104470. /**
  104471. * Defines the center of rotation (V)
  104472. */
  104473. vRotationCenter: number;
  104474. /**
  104475. * Defines the center of rotation (W)
  104476. */
  104477. wRotationCenter: number;
  104478. /**
  104479. * Are mip maps generated for this texture or not.
  104480. */
  104481. get noMipmap(): boolean;
  104482. /**
  104483. * List of inspectable custom properties (used by the Inspector)
  104484. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  104485. */
  104486. inspectableCustomProperties: Nullable<IInspectable[]>;
  104487. private _noMipmap;
  104488. /** @hidden */
  104489. _invertY: boolean;
  104490. private _rowGenerationMatrix;
  104491. private _cachedTextureMatrix;
  104492. private _projectionModeMatrix;
  104493. private _t0;
  104494. private _t1;
  104495. private _t2;
  104496. private _cachedUOffset;
  104497. private _cachedVOffset;
  104498. private _cachedUScale;
  104499. private _cachedVScale;
  104500. private _cachedUAng;
  104501. private _cachedVAng;
  104502. private _cachedWAng;
  104503. private _cachedProjectionMatrixId;
  104504. private _cachedCoordinatesMode;
  104505. /** @hidden */
  104506. protected _initialSamplingMode: number;
  104507. /** @hidden */
  104508. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  104509. private _deleteBuffer;
  104510. protected _format: Nullable<number>;
  104511. private _delayedOnLoad;
  104512. private _delayedOnError;
  104513. private _mimeType?;
  104514. /** Returns the texture mime type if it was defined by a loader (undefined else) */
  104515. get mimeType(): string | undefined;
  104516. /**
  104517. * Observable triggered once the texture has been loaded.
  104518. */
  104519. onLoadObservable: Observable<Texture>;
  104520. protected _isBlocking: boolean;
  104521. /**
  104522. * Is the texture preventing material to render while loading.
  104523. * If false, a default texture will be used instead of the loading one during the preparation step.
  104524. */
  104525. set isBlocking(value: boolean);
  104526. get isBlocking(): boolean;
  104527. /**
  104528. * Get the current sampling mode associated with the texture.
  104529. */
  104530. get samplingMode(): number;
  104531. /**
  104532. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  104533. */
  104534. get invertY(): boolean;
  104535. /**
  104536. * Instantiates a new texture.
  104537. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  104538. * @see https://doc.babylonjs.com/babylon101/materials#texture
  104539. * @param url defines the url of the picture to load as a texture
  104540. * @param sceneOrEngine defines the scene or engine the texture will belong to
  104541. * @param noMipmap defines if the texture will require mip maps or not
  104542. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  104543. * @param samplingMode defines the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104544. * @param onLoad defines a callback triggered when the texture has been loaded
  104545. * @param onError defines a callback triggered when an error occurred during the loading session
  104546. * @param buffer defines the buffer to load the texture from in case the texture is loaded from a buffer representation
  104547. * @param deleteBuffer defines if the buffer we are loading the texture from should be deleted after load
  104548. * @param format defines the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104549. * @param mimeType defines an optional mime type information
  104550. */
  104551. 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);
  104552. /**
  104553. * Update the url (and optional buffer) of this texture if url was null during construction.
  104554. * @param url the url of the texture
  104555. * @param buffer the buffer of the texture (defaults to null)
  104556. * @param onLoad callback called when the texture is loaded (defaults to null)
  104557. */
  104558. updateURL(url: string, buffer?: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob>, onLoad?: () => void): void;
  104559. /**
  104560. * Finish the loading sequence of a texture flagged as delayed load.
  104561. * @hidden
  104562. */
  104563. delayLoad(): void;
  104564. private _prepareRowForTextureGeneration;
  104565. /**
  104566. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  104567. * @returns the transform matrix of the texture.
  104568. */
  104569. getTextureMatrix(uBase?: number): Matrix;
  104570. /**
  104571. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  104572. * @returns The reflection texture transform
  104573. */
  104574. getReflectionTextureMatrix(): Matrix;
  104575. /**
  104576. * Clones the texture.
  104577. * @returns the cloned texture
  104578. */
  104579. clone(): Texture;
  104580. /**
  104581. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  104582. * @returns The JSON representation of the texture
  104583. */
  104584. serialize(): any;
  104585. /**
  104586. * Get the current class name of the texture useful for serialization or dynamic coding.
  104587. * @returns "Texture"
  104588. */
  104589. getClassName(): string;
  104590. /**
  104591. * Dispose the texture and release its associated resources.
  104592. */
  104593. dispose(): void;
  104594. /**
  104595. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  104596. * @param parsedTexture Define the JSON representation of the texture
  104597. * @param scene Define the scene the parsed texture should be instantiated in
  104598. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  104599. * @returns The parsed texture if successful
  104600. */
  104601. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<BaseTexture>;
  104602. /**
  104603. * Creates a texture from its base 64 representation.
  104604. * @param data Define the base64 payload without the data: prefix
  104605. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104606. * @param scene Define the scene the texture should belong to
  104607. * @param noMipmap Forces the texture to not create mip map information if true
  104608. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104609. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104610. * @param onLoad define a callback triggered when the texture has been loaded
  104611. * @param onError define a callback triggered when an error occurred during the loading session
  104612. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104613. * @returns the created texture
  104614. */
  104615. static CreateFromBase64String(data: string, name: string, scene: Scene, noMipmap?: boolean, invertY?: boolean, samplingMode?: number, onLoad?: Nullable<() => void>, onError?: Nullable<() => void>, format?: number): Texture;
  104616. /**
  104617. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  104618. * @param data Define the base64 payload without the data: prefix
  104619. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  104620. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  104621. * @param scene Define the scene the texture should belong to
  104622. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  104623. * @param noMipmap Forces the texture to not create mip map information if true
  104624. * @param invertY define if the texture needs to be inverted on the y axis during loading
  104625. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  104626. * @param onLoad define a callback triggered when the texture has been loaded
  104627. * @param onError define a callback triggered when an error occurred during the loading session
  104628. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  104629. * @returns the created texture
  104630. */
  104631. 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;
  104632. }
  104633. }
  104634. declare module BABYLON {
  104635. /**
  104636. * PostProcessManager is used to manage one or more post processes or post process pipelines
  104637. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  104638. */
  104639. export class PostProcessManager {
  104640. private _scene;
  104641. private _indexBuffer;
  104642. private _vertexBuffers;
  104643. /**
  104644. * Creates a new instance PostProcess
  104645. * @param scene The scene that the post process is associated with.
  104646. */
  104647. constructor(scene: Scene);
  104648. private _prepareBuffers;
  104649. private _buildIndexBuffer;
  104650. /**
  104651. * Rebuilds the vertex buffers of the manager.
  104652. * @hidden
  104653. */
  104654. _rebuild(): void;
  104655. /**
  104656. * Prepares a frame to be run through a post process.
  104657. * @param sourceTexture The input texture to the post procesess. (default: null)
  104658. * @param postProcesses An array of post processes to be run. (default: null)
  104659. * @returns True if the post processes were able to be run.
  104660. * @hidden
  104661. */
  104662. _prepareFrame(sourceTexture?: Nullable<InternalTexture>, postProcesses?: Nullable<PostProcess[]>): boolean;
  104663. /**
  104664. * Manually render a set of post processes to a texture.
  104665. * Please note, the frame buffer won't be unbound after the call in case you have more render to do.
  104666. * @param postProcesses An array of post processes to be run.
  104667. * @param targetTexture The target texture to render to.
  104668. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  104669. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  104670. * @param lodLevel defines which lod of the texture to render to
  104671. * @param doNotBindFrambuffer If set to true, assumes that the framebuffer has been bound previously
  104672. */
  104673. directRender(postProcesses: PostProcess[], targetTexture?: Nullable<InternalTexture>, forceFullscreenViewport?: boolean, faceIndex?: number, lodLevel?: number, doNotBindFrambuffer?: boolean): void;
  104674. /**
  104675. * Finalize the result of the output of the postprocesses.
  104676. * @param doNotPresent If true the result will not be displayed to the screen.
  104677. * @param targetTexture The target texture to render to.
  104678. * @param faceIndex The index of the face to bind the target texture to.
  104679. * @param postProcesses The array of post processes to render.
  104680. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  104681. * @hidden
  104682. */
  104683. _finalizeFrame(doNotPresent?: boolean, targetTexture?: InternalTexture, faceIndex?: number, postProcesses?: Array<PostProcess>, forceFullscreenViewport?: boolean): void;
  104684. /**
  104685. * Disposes of the post process manager.
  104686. */
  104687. dispose(): void;
  104688. }
  104689. }
  104690. declare module BABYLON {
  104691. /**
  104692. * This Helps creating a texture that will be created from a camera in your scene.
  104693. * It is basically a dynamic texture that could be used to create special effects for instance.
  104694. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  104695. */
  104696. export class RenderTargetTexture extends Texture {
  104697. /**
  104698. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  104699. */
  104700. static readonly REFRESHRATE_RENDER_ONCE: number;
  104701. /**
  104702. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  104703. */
  104704. static readonly REFRESHRATE_RENDER_ONEVERYFRAME: number;
  104705. /**
  104706. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  104707. * the central point of your effect and can save a lot of performances.
  104708. */
  104709. static readonly REFRESHRATE_RENDER_ONEVERYTWOFRAMES: number;
  104710. /**
  104711. * Use this predicate to dynamically define the list of mesh you want to render.
  104712. * If set, the renderList property will be overwritten.
  104713. */
  104714. renderListPredicate: (AbstractMesh: AbstractMesh) => boolean;
  104715. private _renderList;
  104716. /**
  104717. * Use this list to define the list of mesh you want to render.
  104718. */
  104719. get renderList(): Nullable<Array<AbstractMesh>>;
  104720. set renderList(value: Nullable<Array<AbstractMesh>>);
  104721. /**
  104722. * Use this function to overload the renderList array at rendering time.
  104723. * Return null to render with the curent renderList, else return the list of meshes to use for rendering.
  104724. * For 2DArray RTT, layerOrFace is the index of the layer that is going to be rendered, else it is the faceIndex of
  104725. * the cube (if the RTT is a cube, else layerOrFace=0).
  104726. * The renderList passed to the function is the current render list (the one that will be used if the function returns null).
  104727. * The length of this list is passed through renderListLength: don't use renderList.length directly because the array can
  104728. * hold dummy elements!
  104729. */
  104730. getCustomRenderList: (layerOrFace: number, renderList: Nullable<Immutable<Array<AbstractMesh>>>, renderListLength: number) => Nullable<Array<AbstractMesh>>;
  104731. private _hookArray;
  104732. /**
  104733. * Define if particles should be rendered in your texture.
  104734. */
  104735. renderParticles: boolean;
  104736. /**
  104737. * Define if sprites should be rendered in your texture.
  104738. */
  104739. renderSprites: boolean;
  104740. /**
  104741. * Define the camera used to render the texture.
  104742. */
  104743. activeCamera: Nullable<Camera>;
  104744. /**
  104745. * Override the mesh isReady function with your own one.
  104746. */
  104747. customIsReadyFunction: (mesh: AbstractMesh, refreshRate: number) => boolean;
  104748. /**
  104749. * Override the render function of the texture with your own one.
  104750. */
  104751. customRenderFunction: (opaqueSubMeshes: SmartArray<SubMesh>, alphaTestSubMeshes: SmartArray<SubMesh>, transparentSubMeshes: SmartArray<SubMesh>, depthOnlySubMeshes: SmartArray<SubMesh>, beforeTransparents?: () => void) => void;
  104752. /**
  104753. * Define if camera post processes should be use while rendering the texture.
  104754. */
  104755. useCameraPostProcesses: boolean;
  104756. /**
  104757. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  104758. */
  104759. ignoreCameraViewport: boolean;
  104760. private _postProcessManager;
  104761. private _postProcesses;
  104762. private _resizeObserver;
  104763. /**
  104764. * An event triggered when the texture is unbind.
  104765. */
  104766. onBeforeBindObservable: Observable<RenderTargetTexture>;
  104767. /**
  104768. * An event triggered when the texture is unbind.
  104769. */
  104770. onAfterUnbindObservable: Observable<RenderTargetTexture>;
  104771. private _onAfterUnbindObserver;
  104772. /**
  104773. * Set a after unbind callback in the texture.
  104774. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  104775. */
  104776. set onAfterUnbind(callback: () => void);
  104777. /**
  104778. * An event triggered before rendering the texture
  104779. */
  104780. onBeforeRenderObservable: Observable<number>;
  104781. private _onBeforeRenderObserver;
  104782. /**
  104783. * Set a before render callback in the texture.
  104784. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  104785. */
  104786. set onBeforeRender(callback: (faceIndex: number) => void);
  104787. /**
  104788. * An event triggered after rendering the texture
  104789. */
  104790. onAfterRenderObservable: Observable<number>;
  104791. private _onAfterRenderObserver;
  104792. /**
  104793. * Set a after render callback in the texture.
  104794. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  104795. */
  104796. set onAfterRender(callback: (faceIndex: number) => void);
  104797. /**
  104798. * An event triggered after the texture clear
  104799. */
  104800. onClearObservable: Observable<Engine>;
  104801. private _onClearObserver;
  104802. /**
  104803. * Set a clear callback in the texture.
  104804. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  104805. */
  104806. set onClear(callback: (Engine: Engine) => void);
  104807. /**
  104808. * An event triggered when the texture is resized.
  104809. */
  104810. onResizeObservable: Observable<RenderTargetTexture>;
  104811. /**
  104812. * Define the clear color of the Render Target if it should be different from the scene.
  104813. */
  104814. clearColor: Color4;
  104815. protected _size: number | {
  104816. width: number;
  104817. height: number;
  104818. layers?: number;
  104819. };
  104820. protected _initialSizeParameter: number | {
  104821. width: number;
  104822. height: number;
  104823. } | {
  104824. ratio: number;
  104825. };
  104826. protected _sizeRatio: Nullable<number>;
  104827. /** @hidden */
  104828. _generateMipMaps: boolean;
  104829. protected _renderingManager: RenderingManager;
  104830. /** @hidden */
  104831. _waitingRenderList?: string[];
  104832. protected _doNotChangeAspectRatio: boolean;
  104833. protected _currentRefreshId: number;
  104834. protected _refreshRate: number;
  104835. protected _textureMatrix: Matrix;
  104836. protected _samples: number;
  104837. protected _renderTargetOptions: RenderTargetCreationOptions;
  104838. /**
  104839. * Gets render target creation options that were used.
  104840. */
  104841. get renderTargetOptions(): RenderTargetCreationOptions;
  104842. protected _onRatioRescale(): void;
  104843. /**
  104844. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  104845. * It must define where the camera used to render the texture is set
  104846. */
  104847. boundingBoxPosition: Vector3;
  104848. private _boundingBoxSize;
  104849. /**
  104850. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  104851. * When defined, the cubemap will switch to local mode
  104852. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  104853. * @example https://www.babylonjs-playground.com/#RNASML
  104854. */
  104855. set boundingBoxSize(value: Vector3);
  104856. get boundingBoxSize(): Vector3;
  104857. /**
  104858. * In case the RTT has been created with a depth texture, get the associated
  104859. * depth texture.
  104860. * Otherwise, return null.
  104861. */
  104862. get depthStencilTexture(): Nullable<InternalTexture>;
  104863. /**
  104864. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  104865. * or used a shadow, depth texture...
  104866. * @param name The friendly name of the texture
  104867. * @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)
  104868. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  104869. * @param generateMipMaps True if mip maps need to be generated after render.
  104870. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  104871. * @param type The type of the buffer in the RTT (int, half float, float...)
  104872. * @param isCube True if a cube texture needs to be created
  104873. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  104874. * @param generateDepthBuffer True to generate a depth buffer
  104875. * @param generateStencilBuffer True to generate a stencil buffer
  104876. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  104877. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  104878. * @param delayAllocation if the texture allocation should be delayed (default: false)
  104879. */
  104880. constructor(name: string, size: number | {
  104881. width: number;
  104882. height: number;
  104883. layers?: number;
  104884. } | {
  104885. ratio: number;
  104886. }, scene: Nullable<Scene>, generateMipMaps?: boolean, doNotChangeAspectRatio?: boolean, type?: number, isCube?: boolean, samplingMode?: number, generateDepthBuffer?: boolean, generateStencilBuffer?: boolean, isMulti?: boolean, format?: number, delayAllocation?: boolean);
  104887. /**
  104888. * Creates a depth stencil texture.
  104889. * This is only available in WebGL 2 or with the depth texture extension available.
  104890. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  104891. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  104892. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  104893. */
  104894. createDepthStencilTexture(comparisonFunction?: number, bilinearFiltering?: boolean, generateStencil?: boolean): void;
  104895. private _processSizeParameter;
  104896. /**
  104897. * Define the number of samples to use in case of MSAA.
  104898. * It defaults to one meaning no MSAA has been enabled.
  104899. */
  104900. get samples(): number;
  104901. set samples(value: number);
  104902. /**
  104903. * Resets the refresh counter of the texture and start bak from scratch.
  104904. * Could be useful to regenerate the texture if it is setup to render only once.
  104905. */
  104906. resetRefreshCounter(): void;
  104907. /**
  104908. * Define the refresh rate of the texture or the rendering frequency.
  104909. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  104910. */
  104911. get refreshRate(): number;
  104912. set refreshRate(value: number);
  104913. /**
  104914. * Adds a post process to the render target rendering passes.
  104915. * @param postProcess define the post process to add
  104916. */
  104917. addPostProcess(postProcess: PostProcess): void;
  104918. /**
  104919. * Clear all the post processes attached to the render target
  104920. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  104921. */
  104922. clearPostProcesses(dispose?: boolean): void;
  104923. /**
  104924. * Remove one of the post process from the list of attached post processes to the texture
  104925. * @param postProcess define the post process to remove from the list
  104926. */
  104927. removePostProcess(postProcess: PostProcess): void;
  104928. /** @hidden */
  104929. _shouldRender(): boolean;
  104930. /**
  104931. * Gets the actual render size of the texture.
  104932. * @returns the width of the render size
  104933. */
  104934. getRenderSize(): number;
  104935. /**
  104936. * Gets the actual render width of the texture.
  104937. * @returns the width of the render size
  104938. */
  104939. getRenderWidth(): number;
  104940. /**
  104941. * Gets the actual render height of the texture.
  104942. * @returns the height of the render size
  104943. */
  104944. getRenderHeight(): number;
  104945. /**
  104946. * Gets the actual number of layers of the texture.
  104947. * @returns the number of layers
  104948. */
  104949. getRenderLayers(): number;
  104950. /**
  104951. * Get if the texture can be rescaled or not.
  104952. */
  104953. get canRescale(): boolean;
  104954. /**
  104955. * Resize the texture using a ratio.
  104956. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  104957. */
  104958. scale(ratio: number): void;
  104959. /**
  104960. * Get the texture reflection matrix used to rotate/transform the reflection.
  104961. * @returns the reflection matrix
  104962. */
  104963. getReflectionTextureMatrix(): Matrix;
  104964. /**
  104965. * Resize the texture to a new desired size.
  104966. * Be carrefull as it will recreate all the data in the new texture.
  104967. * @param size Define the new size. It can be:
  104968. * - a number for squared texture,
  104969. * - an object containing { width: number, height: number }
  104970. * - or an object containing a ratio { ratio: number }
  104971. */
  104972. resize(size: number | {
  104973. width: number;
  104974. height: number;
  104975. } | {
  104976. ratio: number;
  104977. }): void;
  104978. private _defaultRenderListPrepared;
  104979. /**
  104980. * Renders all the objects from the render list into the texture.
  104981. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  104982. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  104983. */
  104984. render(useCameraPostProcess?: boolean, dumpForDebug?: boolean): void;
  104985. private _bestReflectionRenderTargetDimension;
  104986. private _prepareRenderingManager;
  104987. /**
  104988. * @hidden
  104989. * @param faceIndex face index to bind to if this is a cubetexture
  104990. * @param layer defines the index of the texture to bind in the array
  104991. */
  104992. _bindFrameBuffer(faceIndex?: number, layer?: number): void;
  104993. protected unbindFrameBuffer(engine: Engine, faceIndex: number): void;
  104994. private renderToTarget;
  104995. /**
  104996. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  104997. * This allowed control for front to back rendering or reversly depending of the special needs.
  104998. *
  104999. * @param renderingGroupId The rendering group id corresponding to its index
  105000. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  105001. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  105002. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  105003. */
  105004. 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;
  105005. /**
  105006. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  105007. *
  105008. * @param renderingGroupId The rendering group id corresponding to its index
  105009. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  105010. */
  105011. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  105012. /**
  105013. * Clones the texture.
  105014. * @returns the cloned texture
  105015. */
  105016. clone(): RenderTargetTexture;
  105017. /**
  105018. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  105019. * @returns The JSON representation of the texture
  105020. */
  105021. serialize(): any;
  105022. /**
  105023. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  105024. */
  105025. disposeFramebufferObjects(): void;
  105026. /**
  105027. * Dispose the texture and release its associated resources.
  105028. */
  105029. dispose(): void;
  105030. /** @hidden */
  105031. _rebuild(): void;
  105032. /**
  105033. * Clear the info related to rendering groups preventing retention point in material dispose.
  105034. */
  105035. freeRenderingGroups(): void;
  105036. /**
  105037. * Gets the number of views the corresponding to the texture (eg. a MultiviewRenderTarget will have > 1)
  105038. * @returns the view count
  105039. */
  105040. getViewCount(): number;
  105041. }
  105042. }
  105043. declare module BABYLON {
  105044. /**
  105045. * Class used to manipulate GUIDs
  105046. */
  105047. export class GUID {
  105048. /**
  105049. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  105050. * Be aware Math.random() could cause collisions, but:
  105051. * "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"
  105052. * @returns a pseudo random id
  105053. */
  105054. static RandomId(): string;
  105055. }
  105056. }
  105057. declare module BABYLON {
  105058. /**
  105059. * Options to be used when creating a shadow depth material
  105060. */
  105061. export interface IIOptionShadowDepthMaterial {
  105062. /** Variables in the vertex shader code that need to have their names remapped.
  105063. * The format is: ["var_name", "var_remapped_name", "var_name", "var_remapped_name", ...]
  105064. * "var_name" should be either: worldPos or vNormalW
  105065. * So, if the variable holding the world position in your vertex shader is not named worldPos, you must tell the system
  105066. * the name to use instead by using: ["worldPos", "myWorldPosVar"] assuming the variable is named myWorldPosVar in your code.
  105067. * If the normal must also be remapped: ["worldPos", "myWorldPosVar", "vNormalW", "myWorldNormal"]
  105068. */
  105069. remappedVariables?: string[];
  105070. /** Set standalone to true if the base material wrapped by ShadowDepthMaterial is not used for a regular object but for depth shadow generation only */
  105071. standalone?: boolean;
  105072. }
  105073. /**
  105074. * Class that can be used to wrap a base material to generate accurate shadows when using custom vertex/fragment code in the base material
  105075. */
  105076. export class ShadowDepthWrapper {
  105077. private _scene;
  105078. private _options?;
  105079. private _baseMaterial;
  105080. private _onEffectCreatedObserver;
  105081. private _subMeshToEffect;
  105082. private _subMeshToDepthEffect;
  105083. private _meshes;
  105084. /** @hidden */
  105085. _matriceNames: any;
  105086. /** Gets the standalone status of the wrapper */
  105087. get standalone(): boolean;
  105088. /** Gets the base material the wrapper is built upon */
  105089. get baseMaterial(): Material;
  105090. /**
  105091. * Instantiate a new shadow depth wrapper.
  105092. * It works by injecting some specific code in the vertex/fragment shaders of the base material and is used by a shadow generator to
  105093. * generate the shadow depth map. For more information, please refer to the documentation:
  105094. * https://doc.babylonjs.com/babylon101/shadows
  105095. * @param baseMaterial Material to wrap
  105096. * @param scene Define the scene the material belongs to
  105097. * @param options Options used to create the wrapper
  105098. */
  105099. constructor(baseMaterial: Material, scene: Scene, options?: IIOptionShadowDepthMaterial);
  105100. /**
  105101. * Gets the effect to use to generate the depth map
  105102. * @param subMesh subMesh to get the effect for
  105103. * @param shadowGenerator shadow generator to get the effect for
  105104. * @returns the effect to use to generate the depth map for the subMesh + shadow generator specified
  105105. */
  105106. getEffect(subMesh: Nullable<SubMesh>, shadowGenerator: ShadowGenerator): Nullable<Effect>;
  105107. /**
  105108. * Specifies that the submesh is ready to be used for depth rendering
  105109. * @param subMesh submesh to check
  105110. * @param defines the list of defines to take into account when checking the effect
  105111. * @param shadowGenerator combined with subMesh, it defines the effect to check
  105112. * @param useInstances specifies that instances should be used
  105113. * @returns a boolean indicating that the submesh is ready or not
  105114. */
  105115. isReadyForSubMesh(subMesh: SubMesh, defines: string[], shadowGenerator: ShadowGenerator, useInstances: boolean): boolean;
  105116. /**
  105117. * Disposes the resources
  105118. */
  105119. dispose(): void;
  105120. private _makeEffect;
  105121. }
  105122. }
  105123. declare module BABYLON {
  105124. /**
  105125. * Options for compiling materials.
  105126. */
  105127. export interface IMaterialCompilationOptions {
  105128. /**
  105129. * Defines whether clip planes are enabled.
  105130. */
  105131. clipPlane: boolean;
  105132. /**
  105133. * Defines whether instances are enabled.
  105134. */
  105135. useInstances: boolean;
  105136. }
  105137. /**
  105138. * Options passed when calling customShaderNameResolve
  105139. */
  105140. export interface ICustomShaderNameResolveOptions {
  105141. /**
  105142. * 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
  105143. */
  105144. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  105145. }
  105146. /**
  105147. * Base class for the main features of a material in Babylon.js
  105148. */
  105149. export class Material implements IAnimatable {
  105150. /**
  105151. * Returns the triangle fill mode
  105152. */
  105153. static readonly TriangleFillMode: number;
  105154. /**
  105155. * Returns the wireframe mode
  105156. */
  105157. static readonly WireFrameFillMode: number;
  105158. /**
  105159. * Returns the point fill mode
  105160. */
  105161. static readonly PointFillMode: number;
  105162. /**
  105163. * Returns the point list draw mode
  105164. */
  105165. static readonly PointListDrawMode: number;
  105166. /**
  105167. * Returns the line list draw mode
  105168. */
  105169. static readonly LineListDrawMode: number;
  105170. /**
  105171. * Returns the line loop draw mode
  105172. */
  105173. static readonly LineLoopDrawMode: number;
  105174. /**
  105175. * Returns the line strip draw mode
  105176. */
  105177. static readonly LineStripDrawMode: number;
  105178. /**
  105179. * Returns the triangle strip draw mode
  105180. */
  105181. static readonly TriangleStripDrawMode: number;
  105182. /**
  105183. * Returns the triangle fan draw mode
  105184. */
  105185. static readonly TriangleFanDrawMode: number;
  105186. /**
  105187. * Stores the clock-wise side orientation
  105188. */
  105189. static readonly ClockWiseSideOrientation: number;
  105190. /**
  105191. * Stores the counter clock-wise side orientation
  105192. */
  105193. static readonly CounterClockWiseSideOrientation: number;
  105194. /**
  105195. * The dirty texture flag value
  105196. */
  105197. static readonly TextureDirtyFlag: number;
  105198. /**
  105199. * The dirty light flag value
  105200. */
  105201. static readonly LightDirtyFlag: number;
  105202. /**
  105203. * The dirty fresnel flag value
  105204. */
  105205. static readonly FresnelDirtyFlag: number;
  105206. /**
  105207. * The dirty attribute flag value
  105208. */
  105209. static readonly AttributesDirtyFlag: number;
  105210. /**
  105211. * The dirty misc flag value
  105212. */
  105213. static readonly MiscDirtyFlag: number;
  105214. /**
  105215. * The dirty prepass flag value
  105216. */
  105217. static readonly PrePassDirtyFlag: number;
  105218. /**
  105219. * The all dirty flag value
  105220. */
  105221. static readonly AllDirtyFlag: number;
  105222. /**
  105223. * MaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  105224. */
  105225. static readonly MATERIAL_OPAQUE: number;
  105226. /**
  105227. * MaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  105228. */
  105229. static readonly MATERIAL_ALPHATEST: number;
  105230. /**
  105231. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105232. */
  105233. static readonly MATERIAL_ALPHABLEND: number;
  105234. /**
  105235. * MaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  105236. * They are also discarded below the alpha cutoff threshold to improve performances.
  105237. */
  105238. static readonly MATERIAL_ALPHATESTANDBLEND: number;
  105239. /**
  105240. * The Whiteout method is used to blend normals.
  105241. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105242. */
  105243. static readonly MATERIAL_NORMALBLENDMETHOD_WHITEOUT: number;
  105244. /**
  105245. * The Reoriented Normal Mapping method is used to blend normals.
  105246. * Details of the algorithm can be found here: https://blog.selfshadow.com/publications/blending-in-detail/
  105247. */
  105248. static readonly MATERIAL_NORMALBLENDMETHOD_RNM: number;
  105249. /**
  105250. * Custom callback helping to override the default shader used in the material.
  105251. */
  105252. customShaderNameResolve: (shaderName: string, uniforms: string[], uniformBuffers: string[], samplers: string[], defines: MaterialDefines | string[], attributes?: string[], options?: ICustomShaderNameResolveOptions) => string;
  105253. /**
  105254. * Custom shadow depth material to use for shadow rendering instead of the in-built one
  105255. */
  105256. shadowDepthWrapper: Nullable<ShadowDepthWrapper>;
  105257. /**
  105258. * Gets or sets a boolean indicating that the material is allowed (if supported) to do shader hot swapping.
  105259. * This means that the material can keep using a previous shader while a new one is being compiled.
  105260. * This is mostly used when shader parallel compilation is supported (true by default)
  105261. */
  105262. allowShaderHotSwapping: boolean;
  105263. /**
  105264. * The ID of the material
  105265. */
  105266. id: string;
  105267. /**
  105268. * Gets or sets the unique id of the material
  105269. */
  105270. uniqueId: number;
  105271. /**
  105272. * The name of the material
  105273. */
  105274. name: string;
  105275. /**
  105276. * Gets or sets user defined metadata
  105277. */
  105278. metadata: any;
  105279. /**
  105280. * For internal use only. Please do not use.
  105281. */
  105282. reservedDataStore: any;
  105283. /**
  105284. * Specifies if the ready state should be checked on each call
  105285. */
  105286. checkReadyOnEveryCall: boolean;
  105287. /**
  105288. * Specifies if the ready state should be checked once
  105289. */
  105290. checkReadyOnlyOnce: boolean;
  105291. /**
  105292. * The state of the material
  105293. */
  105294. state: string;
  105295. /**
  105296. * If the material can be rendered to several textures with MRT extension
  105297. */
  105298. get canRenderToMRT(): boolean;
  105299. /**
  105300. * The alpha value of the material
  105301. */
  105302. protected _alpha: number;
  105303. /**
  105304. * List of inspectable custom properties (used by the Inspector)
  105305. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  105306. */
  105307. inspectableCustomProperties: IInspectable[];
  105308. /**
  105309. * Sets the alpha value of the material
  105310. */
  105311. set alpha(value: number);
  105312. /**
  105313. * Gets the alpha value of the material
  105314. */
  105315. get alpha(): number;
  105316. /**
  105317. * Specifies if back face culling is enabled
  105318. */
  105319. protected _backFaceCulling: boolean;
  105320. /**
  105321. * Sets the back-face culling state
  105322. */
  105323. set backFaceCulling(value: boolean);
  105324. /**
  105325. * Gets the back-face culling state
  105326. */
  105327. get backFaceCulling(): boolean;
  105328. /**
  105329. * Stores the value for side orientation
  105330. */
  105331. sideOrientation: number;
  105332. /**
  105333. * Callback triggered when the material is compiled
  105334. */
  105335. onCompiled: Nullable<(effect: Effect) => void>;
  105336. /**
  105337. * Callback triggered when an error occurs
  105338. */
  105339. onError: Nullable<(effect: Effect, errors: string) => void>;
  105340. /**
  105341. * Callback triggered to get the render target textures
  105342. */
  105343. getRenderTargetTextures: Nullable<() => SmartArray<RenderTargetTexture>>;
  105344. /**
  105345. * Gets a boolean indicating that current material needs to register RTT
  105346. */
  105347. get hasRenderTargetTextures(): boolean;
  105348. /**
  105349. * Specifies if the material should be serialized
  105350. */
  105351. doNotSerialize: boolean;
  105352. /**
  105353. * @hidden
  105354. */
  105355. _storeEffectOnSubMeshes: boolean;
  105356. /**
  105357. * Stores the animations for the material
  105358. */
  105359. animations: Nullable<Array<Animation>>;
  105360. /**
  105361. * An event triggered when the material is disposed
  105362. */
  105363. onDisposeObservable: Observable<Material>;
  105364. /**
  105365. * An observer which watches for dispose events
  105366. */
  105367. private _onDisposeObserver;
  105368. private _onUnBindObservable;
  105369. /**
  105370. * Called during a dispose event
  105371. */
  105372. set onDispose(callback: () => void);
  105373. private _onBindObservable;
  105374. /**
  105375. * An event triggered when the material is bound
  105376. */
  105377. get onBindObservable(): Observable<AbstractMesh>;
  105378. /**
  105379. * An observer which watches for bind events
  105380. */
  105381. private _onBindObserver;
  105382. /**
  105383. * Called during a bind event
  105384. */
  105385. set onBind(callback: (Mesh: AbstractMesh) => void);
  105386. /**
  105387. * An event triggered when the material is unbound
  105388. */
  105389. get onUnBindObservable(): Observable<Material>;
  105390. protected _onEffectCreatedObservable: Nullable<Observable<{
  105391. effect: Effect;
  105392. subMesh: Nullable<SubMesh>;
  105393. }>>;
  105394. /**
  105395. * An event triggered when the effect is (re)created
  105396. */
  105397. get onEffectCreatedObservable(): Observable<{
  105398. effect: Effect;
  105399. subMesh: Nullable<SubMesh>;
  105400. }>;
  105401. /**
  105402. * Stores the value of the alpha mode
  105403. */
  105404. private _alphaMode;
  105405. /**
  105406. * Sets the value of the alpha mode.
  105407. *
  105408. * | Value | Type | Description |
  105409. * | --- | --- | --- |
  105410. * | 0 | ALPHA_DISABLE | |
  105411. * | 1 | ALPHA_ADD | |
  105412. * | 2 | ALPHA_COMBINE | |
  105413. * | 3 | ALPHA_SUBTRACT | |
  105414. * | 4 | ALPHA_MULTIPLY | |
  105415. * | 5 | ALPHA_MAXIMIZED | |
  105416. * | 6 | ALPHA_ONEONE | |
  105417. * | 7 | ALPHA_PREMULTIPLIED | |
  105418. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  105419. * | 9 | ALPHA_INTERPOLATE | |
  105420. * | 10 | ALPHA_SCREENMODE | |
  105421. *
  105422. */
  105423. set alphaMode(value: number);
  105424. /**
  105425. * Gets the value of the alpha mode
  105426. */
  105427. get alphaMode(): number;
  105428. /**
  105429. * Stores the state of the need depth pre-pass value
  105430. */
  105431. private _needDepthPrePass;
  105432. /**
  105433. * Sets the need depth pre-pass value
  105434. */
  105435. set needDepthPrePass(value: boolean);
  105436. /**
  105437. * Gets the depth pre-pass value
  105438. */
  105439. get needDepthPrePass(): boolean;
  105440. /**
  105441. * Specifies if depth writing should be disabled
  105442. */
  105443. disableDepthWrite: boolean;
  105444. /**
  105445. * Specifies if color writing should be disabled
  105446. */
  105447. disableColorWrite: boolean;
  105448. /**
  105449. * Specifies if depth writing should be forced
  105450. */
  105451. forceDepthWrite: boolean;
  105452. /**
  105453. * Specifies the depth function that should be used. 0 means the default engine function
  105454. */
  105455. depthFunction: number;
  105456. /**
  105457. * Specifies if there should be a separate pass for culling
  105458. */
  105459. separateCullingPass: boolean;
  105460. /**
  105461. * Stores the state specifing if fog should be enabled
  105462. */
  105463. private _fogEnabled;
  105464. /**
  105465. * Sets the state for enabling fog
  105466. */
  105467. set fogEnabled(value: boolean);
  105468. /**
  105469. * Gets the value of the fog enabled state
  105470. */
  105471. get fogEnabled(): boolean;
  105472. /**
  105473. * Stores the size of points
  105474. */
  105475. pointSize: number;
  105476. /**
  105477. * Stores the z offset value
  105478. */
  105479. zOffset: number;
  105480. get wireframe(): boolean;
  105481. /**
  105482. * Sets the state of wireframe mode
  105483. */
  105484. set wireframe(value: boolean);
  105485. /**
  105486. * Gets the value specifying if point clouds are enabled
  105487. */
  105488. get pointsCloud(): boolean;
  105489. /**
  105490. * Sets the state of point cloud mode
  105491. */
  105492. set pointsCloud(value: boolean);
  105493. /**
  105494. * Gets the material fill mode
  105495. */
  105496. get fillMode(): number;
  105497. /**
  105498. * Sets the material fill mode
  105499. */
  105500. set fillMode(value: number);
  105501. /**
  105502. * @hidden
  105503. * Stores the effects for the material
  105504. */
  105505. _effect: Nullable<Effect>;
  105506. /**
  105507. * Specifies if uniform buffers should be used
  105508. */
  105509. private _useUBO;
  105510. /**
  105511. * Stores a reference to the scene
  105512. */
  105513. private _scene;
  105514. /**
  105515. * Stores the fill mode state
  105516. */
  105517. private _fillMode;
  105518. /**
  105519. * Specifies if the depth write state should be cached
  105520. */
  105521. private _cachedDepthWriteState;
  105522. /**
  105523. * Specifies if the color write state should be cached
  105524. */
  105525. private _cachedColorWriteState;
  105526. /**
  105527. * Specifies if the depth function state should be cached
  105528. */
  105529. private _cachedDepthFunctionState;
  105530. /**
  105531. * Stores the uniform buffer
  105532. */
  105533. protected _uniformBuffer: UniformBuffer;
  105534. /** @hidden */
  105535. _indexInSceneMaterialArray: number;
  105536. /** @hidden */
  105537. meshMap: Nullable<{
  105538. [id: string]: AbstractMesh | undefined;
  105539. }>;
  105540. /**
  105541. * Creates a material instance
  105542. * @param name defines the name of the material
  105543. * @param scene defines the scene to reference
  105544. * @param doNotAdd specifies if the material should be added to the scene
  105545. */
  105546. constructor(name: string, scene: Scene, doNotAdd?: boolean);
  105547. /**
  105548. * Returns a string representation of the current material
  105549. * @param fullDetails defines a boolean indicating which levels of logging is desired
  105550. * @returns a string with material information
  105551. */
  105552. toString(fullDetails?: boolean): string;
  105553. /**
  105554. * Gets the class name of the material
  105555. * @returns a string with the class name of the material
  105556. */
  105557. getClassName(): string;
  105558. /**
  105559. * Specifies if updates for the material been locked
  105560. */
  105561. get isFrozen(): boolean;
  105562. /**
  105563. * Locks updates for the material
  105564. */
  105565. freeze(): void;
  105566. /**
  105567. * Unlocks updates for the material
  105568. */
  105569. unfreeze(): void;
  105570. /**
  105571. * Specifies if the material is ready to be used
  105572. * @param mesh defines the mesh to check
  105573. * @param useInstances specifies if instances should be used
  105574. * @returns a boolean indicating if the material is ready to be used
  105575. */
  105576. isReady(mesh?: AbstractMesh, useInstances?: boolean): boolean;
  105577. /**
  105578. * Specifies that the submesh is ready to be used
  105579. * @param mesh defines the mesh to check
  105580. * @param subMesh defines which submesh to check
  105581. * @param useInstances specifies that instances should be used
  105582. * @returns a boolean indicating that the submesh is ready or not
  105583. */
  105584. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105585. /**
  105586. * Returns the material effect
  105587. * @returns the effect associated with the material
  105588. */
  105589. getEffect(): Nullable<Effect>;
  105590. /**
  105591. * Returns the current scene
  105592. * @returns a Scene
  105593. */
  105594. getScene(): Scene;
  105595. /**
  105596. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  105597. */
  105598. protected _forceAlphaTest: boolean;
  105599. /**
  105600. * The transparency mode of the material.
  105601. */
  105602. protected _transparencyMode: Nullable<number>;
  105603. /**
  105604. * Gets the current transparency mode.
  105605. */
  105606. get transparencyMode(): Nullable<number>;
  105607. /**
  105608. * Sets the transparency mode of the material.
  105609. *
  105610. * | Value | Type | Description |
  105611. * | ----- | ----------------------------------- | ----------- |
  105612. * | 0 | OPAQUE | |
  105613. * | 1 | ALPHATEST | |
  105614. * | 2 | ALPHABLEND | |
  105615. * | 3 | ALPHATESTANDBLEND | |
  105616. *
  105617. */
  105618. set transparencyMode(value: Nullable<number>);
  105619. /**
  105620. * Returns true if alpha blending should be disabled.
  105621. */
  105622. protected get _disableAlphaBlending(): boolean;
  105623. /**
  105624. * Specifies whether or not this material should be rendered in alpha blend mode.
  105625. * @returns a boolean specifying if alpha blending is needed
  105626. */
  105627. needAlphaBlending(): boolean;
  105628. /**
  105629. * Specifies if the mesh will require alpha blending
  105630. * @param mesh defines the mesh to check
  105631. * @returns a boolean specifying if alpha blending is needed for the mesh
  105632. */
  105633. needAlphaBlendingForMesh(mesh: AbstractMesh): boolean;
  105634. /**
  105635. * Specifies whether or not this material should be rendered in alpha test mode.
  105636. * @returns a boolean specifying if an alpha test is needed.
  105637. */
  105638. needAlphaTesting(): boolean;
  105639. /**
  105640. * Specifies if material alpha testing should be turned on for the mesh
  105641. * @param mesh defines the mesh to check
  105642. */
  105643. protected _shouldTurnAlphaTestOn(mesh: AbstractMesh): boolean;
  105644. /**
  105645. * Gets the texture used for the alpha test
  105646. * @returns the texture to use for alpha testing
  105647. */
  105648. getAlphaTestTexture(): Nullable<BaseTexture>;
  105649. /**
  105650. * Marks the material to indicate that it needs to be re-calculated
  105651. */
  105652. markDirty(): void;
  105653. /** @hidden */
  105654. _preBind(effect?: Effect, overrideOrientation?: Nullable<number>): boolean;
  105655. /**
  105656. * Binds the material to the mesh
  105657. * @param world defines the world transformation matrix
  105658. * @param mesh defines the mesh to bind the material to
  105659. */
  105660. bind(world: Matrix, mesh?: Mesh): void;
  105661. /**
  105662. * Binds the submesh to the material
  105663. * @param world defines the world transformation matrix
  105664. * @param mesh defines the mesh containing the submesh
  105665. * @param subMesh defines the submesh to bind the material to
  105666. */
  105667. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  105668. /**
  105669. * Binds the world matrix to the material
  105670. * @param world defines the world transformation matrix
  105671. */
  105672. bindOnlyWorldMatrix(world: Matrix): void;
  105673. /**
  105674. * Binds the scene's uniform buffer to the effect.
  105675. * @param effect defines the effect to bind to the scene uniform buffer
  105676. * @param sceneUbo defines the uniform buffer storing scene data
  105677. */
  105678. bindSceneUniformBuffer(effect: Effect, sceneUbo: UniformBuffer): void;
  105679. /**
  105680. * Binds the view matrix to the effect
  105681. * @param effect defines the effect to bind the view matrix to
  105682. */
  105683. bindView(effect: Effect): void;
  105684. /**
  105685. * Binds the view projection matrix to the effect
  105686. * @param effect defines the effect to bind the view projection matrix to
  105687. */
  105688. bindViewProjection(effect: Effect): void;
  105689. /**
  105690. * Processes to execute after binding the material to a mesh
  105691. * @param mesh defines the rendered mesh
  105692. */
  105693. protected _afterBind(mesh?: Mesh): void;
  105694. /**
  105695. * Unbinds the material from the mesh
  105696. */
  105697. unbind(): void;
  105698. /**
  105699. * Gets the active textures from the material
  105700. * @returns an array of textures
  105701. */
  105702. getActiveTextures(): BaseTexture[];
  105703. /**
  105704. * Specifies if the material uses a texture
  105705. * @param texture defines the texture to check against the material
  105706. * @returns a boolean specifying if the material uses the texture
  105707. */
  105708. hasTexture(texture: BaseTexture): boolean;
  105709. /**
  105710. * Makes a duplicate of the material, and gives it a new name
  105711. * @param name defines the new name for the duplicated material
  105712. * @returns the cloned material
  105713. */
  105714. clone(name: string): Nullable<Material>;
  105715. /**
  105716. * Gets the meshes bound to the material
  105717. * @returns an array of meshes bound to the material
  105718. */
  105719. getBindedMeshes(): AbstractMesh[];
  105720. /**
  105721. * Force shader compilation
  105722. * @param mesh defines the mesh associated with this material
  105723. * @param onCompiled defines a function to execute once the material is compiled
  105724. * @param options defines the options to configure the compilation
  105725. * @param onError defines a function to execute if the material fails compiling
  105726. */
  105727. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>, onError?: (reason: string) => void): void;
  105728. /**
  105729. * Force shader compilation
  105730. * @param mesh defines the mesh that will use this material
  105731. * @param options defines additional options for compiling the shaders
  105732. * @returns a promise that resolves when the compilation completes
  105733. */
  105734. forceCompilationAsync(mesh: AbstractMesh, options?: Partial<IMaterialCompilationOptions>): Promise<void>;
  105735. private static readonly _AllDirtyCallBack;
  105736. private static readonly _ImageProcessingDirtyCallBack;
  105737. private static readonly _TextureDirtyCallBack;
  105738. private static readonly _FresnelDirtyCallBack;
  105739. private static readonly _MiscDirtyCallBack;
  105740. private static readonly _PrePassDirtyCallBack;
  105741. private static readonly _LightsDirtyCallBack;
  105742. private static readonly _AttributeDirtyCallBack;
  105743. private static _FresnelAndMiscDirtyCallBack;
  105744. private static _TextureAndMiscDirtyCallBack;
  105745. private static readonly _DirtyCallbackArray;
  105746. private static readonly _RunDirtyCallBacks;
  105747. /**
  105748. * Marks a define in the material to indicate that it needs to be re-computed
  105749. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  105750. */
  105751. markAsDirty(flag: number): void;
  105752. /**
  105753. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  105754. * @param func defines a function which checks material defines against the submeshes
  105755. */
  105756. protected _markAllSubMeshesAsDirty(func: (defines: MaterialDefines) => void): void;
  105757. /**
  105758. * Indicates that the scene should check if the rendering now needs a prepass
  105759. */
  105760. protected _markScenePrePassDirty(): void;
  105761. /**
  105762. * Indicates that we need to re-calculated for all submeshes
  105763. */
  105764. protected _markAllSubMeshesAsAllDirty(): void;
  105765. /**
  105766. * Indicates that image processing needs to be re-calculated for all submeshes
  105767. */
  105768. protected _markAllSubMeshesAsImageProcessingDirty(): void;
  105769. /**
  105770. * Indicates that textures need to be re-calculated for all submeshes
  105771. */
  105772. protected _markAllSubMeshesAsTexturesDirty(): void;
  105773. /**
  105774. * Indicates that fresnel needs to be re-calculated for all submeshes
  105775. */
  105776. protected _markAllSubMeshesAsFresnelDirty(): void;
  105777. /**
  105778. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  105779. */
  105780. protected _markAllSubMeshesAsFresnelAndMiscDirty(): void;
  105781. /**
  105782. * Indicates that lights need to be re-calculated for all submeshes
  105783. */
  105784. protected _markAllSubMeshesAsLightsDirty(): void;
  105785. /**
  105786. * Indicates that attributes need to be re-calculated for all submeshes
  105787. */
  105788. protected _markAllSubMeshesAsAttributesDirty(): void;
  105789. /**
  105790. * Indicates that misc needs to be re-calculated for all submeshes
  105791. */
  105792. protected _markAllSubMeshesAsMiscDirty(): void;
  105793. /**
  105794. * Indicates that prepass needs to be re-calculated for all submeshes
  105795. */
  105796. protected _markAllSubMeshesAsPrePassDirty(): void;
  105797. /**
  105798. * Indicates that textures and misc need to be re-calculated for all submeshes
  105799. */
  105800. protected _markAllSubMeshesAsTexturesAndMiscDirty(): void;
  105801. /**
  105802. * Sets the required values to the prepass renderer.
  105803. * @param prePassRenderer defines the prepass renderer to setup.
  105804. * @returns true if the pre pass is needed.
  105805. */
  105806. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  105807. /**
  105808. * Disposes the material
  105809. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  105810. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  105811. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  105812. */
  105813. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, notBoundToMesh?: boolean): void;
  105814. /** @hidden */
  105815. private releaseVertexArrayObject;
  105816. /**
  105817. * Serializes this material
  105818. * @returns the serialized material object
  105819. */
  105820. serialize(): any;
  105821. /**
  105822. * Creates a material from parsed material data
  105823. * @param parsedMaterial defines parsed material data
  105824. * @param scene defines the hosting scene
  105825. * @param rootUrl defines the root URL to use to load textures
  105826. * @returns a new material
  105827. */
  105828. static Parse(parsedMaterial: any, scene: Scene, rootUrl: string): Nullable<Material>;
  105829. }
  105830. }
  105831. declare module BABYLON {
  105832. /**
  105833. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105834. * separate meshes. This can be use to improve performances.
  105835. * @see https://doc.babylonjs.com/how_to/multi_materials
  105836. */
  105837. export class MultiMaterial extends Material {
  105838. private _subMaterials;
  105839. /**
  105840. * Gets or Sets the list of Materials used within the multi material.
  105841. * They need to be ordered according to the submeshes order in the associated mesh
  105842. */
  105843. get subMaterials(): Nullable<Material>[];
  105844. set subMaterials(value: Nullable<Material>[]);
  105845. /**
  105846. * Function used to align with Node.getChildren()
  105847. * @returns the list of Materials used within the multi material
  105848. */
  105849. getChildren(): Nullable<Material>[];
  105850. /**
  105851. * Instantiates a new Multi Material
  105852. * A multi-material is used to apply different materials to different parts of the same object without the need of
  105853. * separate meshes. This can be use to improve performances.
  105854. * @see https://doc.babylonjs.com/how_to/multi_materials
  105855. * @param name Define the name in the scene
  105856. * @param scene Define the scene the material belongs to
  105857. */
  105858. constructor(name: string, scene: Scene);
  105859. private _hookArray;
  105860. /**
  105861. * Get one of the submaterial by its index in the submaterials array
  105862. * @param index The index to look the sub material at
  105863. * @returns The Material if the index has been defined
  105864. */
  105865. getSubMaterial(index: number): Nullable<Material>;
  105866. /**
  105867. * Get the list of active textures for the whole sub materials list.
  105868. * @returns All the textures that will be used during the rendering
  105869. */
  105870. getActiveTextures(): BaseTexture[];
  105871. /**
  105872. * Gets the current class name of the material e.g. "MultiMaterial"
  105873. * Mainly use in serialization.
  105874. * @returns the class name
  105875. */
  105876. getClassName(): string;
  105877. /**
  105878. * Checks if the material is ready to render the requested sub mesh
  105879. * @param mesh Define the mesh the submesh belongs to
  105880. * @param subMesh Define the sub mesh to look readyness for
  105881. * @param useInstances Define whether or not the material is used with instances
  105882. * @returns true if ready, otherwise false
  105883. */
  105884. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  105885. /**
  105886. * Clones the current material and its related sub materials
  105887. * @param name Define the name of the newly cloned material
  105888. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  105889. * @returns the cloned material
  105890. */
  105891. clone(name: string, cloneChildren?: boolean): MultiMaterial;
  105892. /**
  105893. * Serializes the materials into a JSON representation.
  105894. * @returns the JSON representation
  105895. */
  105896. serialize(): any;
  105897. /**
  105898. * Dispose the material and release its associated resources
  105899. * @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)
  105900. * @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)
  105901. * @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)
  105902. */
  105903. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean, forceDisposeChildren?: boolean): void;
  105904. /**
  105905. * Creates a MultiMaterial from parsed MultiMaterial data.
  105906. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  105907. * @param scene defines the hosting scene
  105908. * @returns a new MultiMaterial
  105909. */
  105910. static ParseMultiMaterial(parsedMultiMaterial: any, scene: Scene): MultiMaterial;
  105911. }
  105912. }
  105913. declare module BABYLON {
  105914. /**
  105915. * Defines a subdivision inside a mesh
  105916. */
  105917. export class SubMesh implements ICullable {
  105918. /** the material index to use */
  105919. materialIndex: number;
  105920. /** vertex index start */
  105921. verticesStart: number;
  105922. /** vertices count */
  105923. verticesCount: number;
  105924. /** index start */
  105925. indexStart: number;
  105926. /** indices count */
  105927. indexCount: number;
  105928. /** @hidden */
  105929. _materialDefines: Nullable<MaterialDefines>;
  105930. /** @hidden */
  105931. _materialEffect: Nullable<Effect>;
  105932. /** @hidden */
  105933. _effectOverride: Nullable<Effect>;
  105934. /**
  105935. * Gets material defines used by the effect associated to the sub mesh
  105936. */
  105937. get materialDefines(): Nullable<MaterialDefines>;
  105938. /**
  105939. * Sets material defines used by the effect associated to the sub mesh
  105940. */
  105941. set materialDefines(defines: Nullable<MaterialDefines>);
  105942. /**
  105943. * Gets associated effect
  105944. */
  105945. get effect(): Nullable<Effect>;
  105946. /**
  105947. * Sets associated effect (effect used to render this submesh)
  105948. * @param effect defines the effect to associate with
  105949. * @param defines defines the set of defines used to compile this effect
  105950. */
  105951. setEffect(effect: Nullable<Effect>, defines?: Nullable<MaterialDefines>): void;
  105952. /** @hidden */
  105953. _linesIndexCount: number;
  105954. private _mesh;
  105955. private _renderingMesh;
  105956. private _boundingInfo;
  105957. private _linesIndexBuffer;
  105958. /** @hidden */
  105959. _lastColliderWorldVertices: Nullable<Vector3[]>;
  105960. /** @hidden */
  105961. _trianglePlanes: Plane[];
  105962. /** @hidden */
  105963. _lastColliderTransformMatrix: Nullable<Matrix>;
  105964. /** @hidden */
  105965. _renderId: number;
  105966. /** @hidden */
  105967. _alphaIndex: number;
  105968. /** @hidden */
  105969. _distanceToCamera: number;
  105970. /** @hidden */
  105971. _id: number;
  105972. private _currentMaterial;
  105973. /**
  105974. * Add a new submesh to a mesh
  105975. * @param materialIndex defines the material index to use
  105976. * @param verticesStart defines vertex index start
  105977. * @param verticesCount defines vertices count
  105978. * @param indexStart defines index start
  105979. * @param indexCount defines indices count
  105980. * @param mesh defines the parent mesh
  105981. * @param renderingMesh defines an optional rendering mesh
  105982. * @param createBoundingBox defines if bounding box should be created for this submesh
  105983. * @returns the new submesh
  105984. */
  105985. static AddToMesh(materialIndex: number, verticesStart: number, verticesCount: number, indexStart: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean): SubMesh;
  105986. /**
  105987. * Creates a new submesh
  105988. * @param materialIndex defines the material index to use
  105989. * @param verticesStart defines vertex index start
  105990. * @param verticesCount defines vertices count
  105991. * @param indexStart defines index start
  105992. * @param indexCount defines indices count
  105993. * @param mesh defines the parent mesh
  105994. * @param renderingMesh defines an optional rendering mesh
  105995. * @param createBoundingBox defines if bounding box should be created for this submesh
  105996. * @param addToMesh defines a boolean indicating that the submesh must be added to the mesh.subMeshes array (true by default)
  105997. */
  105998. constructor(
  105999. /** the material index to use */
  106000. materialIndex: number,
  106001. /** vertex index start */
  106002. verticesStart: number,
  106003. /** vertices count */
  106004. verticesCount: number,
  106005. /** index start */
  106006. indexStart: number,
  106007. /** indices count */
  106008. indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh, createBoundingBox?: boolean, addToMesh?: boolean);
  106009. /**
  106010. * Returns true if this submesh covers the entire parent mesh
  106011. * @ignorenaming
  106012. */
  106013. get IsGlobal(): boolean;
  106014. /**
  106015. * Returns the submesh BoudingInfo object
  106016. * @returns current bounding info (or mesh's one if the submesh is global)
  106017. */
  106018. getBoundingInfo(): BoundingInfo;
  106019. /**
  106020. * Sets the submesh BoundingInfo
  106021. * @param boundingInfo defines the new bounding info to use
  106022. * @returns the SubMesh
  106023. */
  106024. setBoundingInfo(boundingInfo: BoundingInfo): SubMesh;
  106025. /**
  106026. * Returns the mesh of the current submesh
  106027. * @return the parent mesh
  106028. */
  106029. getMesh(): AbstractMesh;
  106030. /**
  106031. * Returns the rendering mesh of the submesh
  106032. * @returns the rendering mesh (could be different from parent mesh)
  106033. */
  106034. getRenderingMesh(): Mesh;
  106035. /**
  106036. * Returns the replacement mesh of the submesh
  106037. * @returns the replacement mesh (could be different from parent mesh)
  106038. */
  106039. getReplacementMesh(): Nullable<AbstractMesh>;
  106040. /**
  106041. * Returns the effective mesh of the submesh
  106042. * @returns the effective mesh (could be different from parent mesh)
  106043. */
  106044. getEffectiveMesh(): AbstractMesh;
  106045. /**
  106046. * Returns the submesh material
  106047. * @returns null or the current material
  106048. */
  106049. getMaterial(): Nullable<Material>;
  106050. private _IsMultiMaterial;
  106051. /**
  106052. * Sets a new updated BoundingInfo object to the submesh
  106053. * @param data defines an optional position array to use to determine the bounding info
  106054. * @returns the SubMesh
  106055. */
  106056. refreshBoundingInfo(data?: Nullable<FloatArray>): SubMesh;
  106057. /** @hidden */
  106058. _checkCollision(collider: Collider): boolean;
  106059. /**
  106060. * Updates the submesh BoundingInfo
  106061. * @param world defines the world matrix to use to update the bounding info
  106062. * @returns the submesh
  106063. */
  106064. updateBoundingInfo(world: DeepImmutable<Matrix>): SubMesh;
  106065. /**
  106066. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  106067. * @param frustumPlanes defines the frustum planes
  106068. * @returns true if the submesh is intersecting with the frustum
  106069. */
  106070. isInFrustum(frustumPlanes: Plane[]): boolean;
  106071. /**
  106072. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  106073. * @param frustumPlanes defines the frustum planes
  106074. * @returns true if the submesh is inside the frustum
  106075. */
  106076. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  106077. /**
  106078. * Renders the submesh
  106079. * @param enableAlphaMode defines if alpha needs to be used
  106080. * @returns the submesh
  106081. */
  106082. render(enableAlphaMode: boolean): SubMesh;
  106083. /**
  106084. * @hidden
  106085. */
  106086. _getLinesIndexBuffer(indices: IndicesArray, engine: Engine): DataBuffer;
  106087. /**
  106088. * Checks if the submesh intersects with a ray
  106089. * @param ray defines the ray to test
  106090. * @returns true is the passed ray intersects the submesh bounding box
  106091. */
  106092. canIntersects(ray: Ray): boolean;
  106093. /**
  106094. * Intersects current submesh with a ray
  106095. * @param ray defines the ray to test
  106096. * @param positions defines mesh's positions array
  106097. * @param indices defines mesh's indices array
  106098. * @param fastCheck defines if the first intersection will be used (and not the closest)
  106099. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  106100. * @returns intersection info or null if no intersection
  106101. */
  106102. intersects(ray: Ray, positions: Vector3[], indices: IndicesArray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<IntersectionInfo>;
  106103. /** @hidden */
  106104. private _intersectLines;
  106105. /** @hidden */
  106106. private _intersectUnIndexedLines;
  106107. /** @hidden */
  106108. private _intersectTriangles;
  106109. /** @hidden */
  106110. private _intersectUnIndexedTriangles;
  106111. /** @hidden */
  106112. _rebuild(): void;
  106113. /**
  106114. * Creates a new submesh from the passed mesh
  106115. * @param newMesh defines the new hosting mesh
  106116. * @param newRenderingMesh defines an optional rendering mesh
  106117. * @returns the new submesh
  106118. */
  106119. clone(newMesh: AbstractMesh, newRenderingMesh?: Mesh): SubMesh;
  106120. /**
  106121. * Release associated resources
  106122. */
  106123. dispose(): void;
  106124. /**
  106125. * Gets the class name
  106126. * @returns the string "SubMesh".
  106127. */
  106128. getClassName(): string;
  106129. /**
  106130. * Creates a new submesh from indices data
  106131. * @param materialIndex the index of the main mesh material
  106132. * @param startIndex the index where to start the copy in the mesh indices array
  106133. * @param indexCount the number of indices to copy then from the startIndex
  106134. * @param mesh the main mesh to create the submesh from
  106135. * @param renderingMesh the optional rendering mesh
  106136. * @returns a new submesh
  106137. */
  106138. static CreateFromIndices(materialIndex: number, startIndex: number, indexCount: number, mesh: AbstractMesh, renderingMesh?: Mesh): SubMesh;
  106139. }
  106140. }
  106141. declare module BABYLON {
  106142. /**
  106143. * Class used to represent data loading progression
  106144. */
  106145. export class SceneLoaderFlags {
  106146. private static _ForceFullSceneLoadingForIncremental;
  106147. private static _ShowLoadingScreen;
  106148. private static _CleanBoneMatrixWeights;
  106149. private static _loggingLevel;
  106150. /**
  106151. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  106152. */
  106153. static get ForceFullSceneLoadingForIncremental(): boolean;
  106154. static set ForceFullSceneLoadingForIncremental(value: boolean);
  106155. /**
  106156. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  106157. */
  106158. static get ShowLoadingScreen(): boolean;
  106159. static set ShowLoadingScreen(value: boolean);
  106160. /**
  106161. * Defines the current logging level (while loading the scene)
  106162. * @ignorenaming
  106163. */
  106164. static get loggingLevel(): number;
  106165. static set loggingLevel(value: number);
  106166. /**
  106167. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  106168. */
  106169. static get CleanBoneMatrixWeights(): boolean;
  106170. static set CleanBoneMatrixWeights(value: boolean);
  106171. }
  106172. }
  106173. declare module BABYLON {
  106174. /**
  106175. * Class used to store geometry data (vertex buffers + index buffer)
  106176. */
  106177. export class Geometry implements IGetSetVerticesData {
  106178. /**
  106179. * Gets or sets the ID of the geometry
  106180. */
  106181. id: string;
  106182. /**
  106183. * Gets or sets the unique ID of the geometry
  106184. */
  106185. uniqueId: number;
  106186. /**
  106187. * Gets the delay loading state of the geometry (none by default which means not delayed)
  106188. */
  106189. delayLoadState: number;
  106190. /**
  106191. * Gets the file containing the data to load when running in delay load state
  106192. */
  106193. delayLoadingFile: Nullable<string>;
  106194. /**
  106195. * Callback called when the geometry is updated
  106196. */
  106197. onGeometryUpdated: (geometry: Geometry, kind?: string) => void;
  106198. private _scene;
  106199. private _engine;
  106200. private _meshes;
  106201. private _totalVertices;
  106202. /** @hidden */
  106203. _indices: IndicesArray;
  106204. /** @hidden */
  106205. _vertexBuffers: {
  106206. [key: string]: VertexBuffer;
  106207. };
  106208. private _isDisposed;
  106209. private _extend;
  106210. private _boundingBias;
  106211. /** @hidden */
  106212. _delayInfo: Array<string>;
  106213. private _indexBuffer;
  106214. private _indexBufferIsUpdatable;
  106215. /** @hidden */
  106216. _boundingInfo: Nullable<BoundingInfo>;
  106217. /** @hidden */
  106218. _delayLoadingFunction: Nullable<(any: any, geometry: Geometry) => void>;
  106219. /** @hidden */
  106220. _softwareSkinningFrameId: number;
  106221. private _vertexArrayObjects;
  106222. private _updatable;
  106223. /** @hidden */
  106224. _positions: Nullable<Vector3[]>;
  106225. /**
  106226. * 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
  106227. */
  106228. get boundingBias(): Vector2;
  106229. /**
  106230. * 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
  106231. */
  106232. set boundingBias(value: Vector2);
  106233. /**
  106234. * Static function used to attach a new empty geometry to a mesh
  106235. * @param mesh defines the mesh to attach the geometry to
  106236. * @returns the new Geometry
  106237. */
  106238. static CreateGeometryForMesh(mesh: Mesh): Geometry;
  106239. /** Get the list of meshes using this geometry */
  106240. get meshes(): Mesh[];
  106241. /**
  106242. * 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
  106243. * and won't be computed based on the vertex positions (which is what we get when useBoundingInfoFromGeometry = false)
  106244. */
  106245. useBoundingInfoFromGeometry: boolean;
  106246. /**
  106247. * Creates a new geometry
  106248. * @param id defines the unique ID
  106249. * @param scene defines the hosting scene
  106250. * @param vertexData defines the VertexData used to get geometry data
  106251. * @param updatable defines if geometry must be updatable (false by default)
  106252. * @param mesh defines the mesh that will be associated with the geometry
  106253. */
  106254. constructor(id: string, scene: Scene, vertexData?: VertexData, updatable?: boolean, mesh?: Nullable<Mesh>);
  106255. /**
  106256. * Gets the current extend of the geometry
  106257. */
  106258. get extend(): {
  106259. minimum: Vector3;
  106260. maximum: Vector3;
  106261. };
  106262. /**
  106263. * Gets the hosting scene
  106264. * @returns the hosting Scene
  106265. */
  106266. getScene(): Scene;
  106267. /**
  106268. * Gets the hosting engine
  106269. * @returns the hosting Engine
  106270. */
  106271. getEngine(): Engine;
  106272. /**
  106273. * Defines if the geometry is ready to use
  106274. * @returns true if the geometry is ready to be used
  106275. */
  106276. isReady(): boolean;
  106277. /**
  106278. * Gets a value indicating that the geometry should not be serialized
  106279. */
  106280. get doNotSerialize(): boolean;
  106281. /** @hidden */
  106282. _rebuild(): void;
  106283. /**
  106284. * Affects all geometry data in one call
  106285. * @param vertexData defines the geometry data
  106286. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  106287. */
  106288. setAllVerticesData(vertexData: VertexData, updatable?: boolean): void;
  106289. /**
  106290. * Set specific vertex data
  106291. * @param kind defines the data kind (Position, normal, etc...)
  106292. * @param data defines the vertex data to use
  106293. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106294. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106295. */
  106296. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): void;
  106297. /**
  106298. * Removes a specific vertex data
  106299. * @param kind defines the data kind (Position, normal, etc...)
  106300. */
  106301. removeVerticesData(kind: string): void;
  106302. /**
  106303. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  106304. * @param buffer defines the vertex buffer to use
  106305. * @param totalVertices defines the total number of vertices for position kind (could be null)
  106306. */
  106307. setVerticesBuffer(buffer: VertexBuffer, totalVertices?: Nullable<number>): void;
  106308. /**
  106309. * Update a specific vertex buffer
  106310. * This function will directly update the underlying DataBuffer according to the passed numeric array or Float32Array
  106311. * It will do nothing if the buffer is not updatable
  106312. * @param kind defines the data kind (Position, normal, etc...)
  106313. * @param data defines the data to use
  106314. * @param offset defines the offset in the target buffer where to store the data
  106315. * @param useBytes set to true if the offset is in bytes
  106316. */
  106317. updateVerticesDataDirectly(kind: string, data: DataArray, offset: number, useBytes?: boolean): void;
  106318. /**
  106319. * Update a specific vertex buffer
  106320. * This function will create a new buffer if the current one is not updatable
  106321. * @param kind defines the data kind (Position, normal, etc...)
  106322. * @param data defines the data to use
  106323. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  106324. */
  106325. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean): void;
  106326. private _updateBoundingInfo;
  106327. /** @hidden */
  106328. _bind(effect: Nullable<Effect>, indexToBind?: Nullable<DataBuffer>): void;
  106329. /**
  106330. * Gets total number of vertices
  106331. * @returns the total number of vertices
  106332. */
  106333. getTotalVertices(): number;
  106334. /**
  106335. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106336. * @param kind defines the data kind (Position, normal, etc...)
  106337. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106338. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106339. * @returns a float array containing vertex data
  106340. */
  106341. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106342. /**
  106343. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  106344. * @param kind defines the data kind (Position, normal, etc...)
  106345. * @returns true if the vertex buffer with the specified kind is updatable
  106346. */
  106347. isVertexBufferUpdatable(kind: string): boolean;
  106348. /**
  106349. * Gets a specific vertex buffer
  106350. * @param kind defines the data kind (Position, normal, etc...)
  106351. * @returns a VertexBuffer
  106352. */
  106353. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  106354. /**
  106355. * Returns all vertex buffers
  106356. * @return an object holding all vertex buffers indexed by kind
  106357. */
  106358. getVertexBuffers(): Nullable<{
  106359. [key: string]: VertexBuffer;
  106360. }>;
  106361. /**
  106362. * Gets a boolean indicating if specific vertex buffer is present
  106363. * @param kind defines the data kind (Position, normal, etc...)
  106364. * @returns true if data is present
  106365. */
  106366. isVerticesDataPresent(kind: string): boolean;
  106367. /**
  106368. * Gets a list of all attached data kinds (Position, normal, etc...)
  106369. * @returns a list of string containing all kinds
  106370. */
  106371. getVerticesDataKinds(): string[];
  106372. /**
  106373. * Update index buffer
  106374. * @param indices defines the indices to store in the index buffer
  106375. * @param offset defines the offset in the target buffer where to store the data
  106376. * @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)
  106377. */
  106378. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): void;
  106379. /**
  106380. * Creates a new index buffer
  106381. * @param indices defines the indices to store in the index buffer
  106382. * @param totalVertices defines the total number of vertices (could be null)
  106383. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106384. */
  106385. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): void;
  106386. /**
  106387. * Return the total number of indices
  106388. * @returns the total number of indices
  106389. */
  106390. getTotalIndices(): number;
  106391. /**
  106392. * Gets the index buffer array
  106393. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106394. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106395. * @returns the index buffer array
  106396. */
  106397. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106398. /**
  106399. * Gets the index buffer
  106400. * @return the index buffer
  106401. */
  106402. getIndexBuffer(): Nullable<DataBuffer>;
  106403. /** @hidden */
  106404. _releaseVertexArrayObject(effect?: Nullable<Effect>): void;
  106405. /**
  106406. * Release the associated resources for a specific mesh
  106407. * @param mesh defines the source mesh
  106408. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  106409. */
  106410. releaseForMesh(mesh: Mesh, shouldDispose?: boolean): void;
  106411. /**
  106412. * Apply current geometry to a given mesh
  106413. * @param mesh defines the mesh to apply geometry to
  106414. */
  106415. applyToMesh(mesh: Mesh): void;
  106416. private _updateExtend;
  106417. private _applyToMesh;
  106418. private notifyUpdate;
  106419. /**
  106420. * Load the geometry if it was flagged as delay loaded
  106421. * @param scene defines the hosting scene
  106422. * @param onLoaded defines a callback called when the geometry is loaded
  106423. */
  106424. load(scene: Scene, onLoaded?: () => void): void;
  106425. private _queueLoad;
  106426. /**
  106427. * Invert the geometry to move from a right handed system to a left handed one.
  106428. */
  106429. toLeftHanded(): void;
  106430. /** @hidden */
  106431. _resetPointsArrayCache(): void;
  106432. /** @hidden */
  106433. _generatePointsArray(): boolean;
  106434. /**
  106435. * Gets a value indicating if the geometry is disposed
  106436. * @returns true if the geometry was disposed
  106437. */
  106438. isDisposed(): boolean;
  106439. private _disposeVertexArrayObjects;
  106440. /**
  106441. * Free all associated resources
  106442. */
  106443. dispose(): void;
  106444. /**
  106445. * Clone the current geometry into a new geometry
  106446. * @param id defines the unique ID of the new geometry
  106447. * @returns a new geometry object
  106448. */
  106449. copy(id: string): Geometry;
  106450. /**
  106451. * Serialize the current geometry info (and not the vertices data) into a JSON object
  106452. * @return a JSON representation of the current geometry data (without the vertices data)
  106453. */
  106454. serialize(): any;
  106455. private toNumberArray;
  106456. /**
  106457. * Serialize all vertices data into a JSON oject
  106458. * @returns a JSON representation of the current geometry data
  106459. */
  106460. serializeVerticeData(): any;
  106461. /**
  106462. * Extracts a clone of a mesh geometry
  106463. * @param mesh defines the source mesh
  106464. * @param id defines the unique ID of the new geometry object
  106465. * @returns the new geometry object
  106466. */
  106467. static ExtractFromMesh(mesh: Mesh, id: string): Nullable<Geometry>;
  106468. /**
  106469. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  106470. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  106471. * Be aware Math.random() could cause collisions, but:
  106472. * "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"
  106473. * @returns a string containing a new GUID
  106474. */
  106475. static RandomId(): string;
  106476. /** @hidden */
  106477. static _ImportGeometry(parsedGeometry: any, mesh: Mesh): void;
  106478. private static _CleanMatricesWeights;
  106479. /**
  106480. * Create a new geometry from persisted data (Using .babylon file format)
  106481. * @param parsedVertexData defines the persisted data
  106482. * @param scene defines the hosting scene
  106483. * @param rootUrl defines the root url to use to load assets (like delayed data)
  106484. * @returns the new geometry object
  106485. */
  106486. static Parse(parsedVertexData: any, scene: Scene, rootUrl: string): Nullable<Geometry>;
  106487. }
  106488. }
  106489. declare module BABYLON {
  106490. /**
  106491. * Define an interface for all classes that will get and set the data on vertices
  106492. */
  106493. export interface IGetSetVerticesData {
  106494. /**
  106495. * Gets a boolean indicating if specific vertex data is present
  106496. * @param kind defines the vertex data kind to use
  106497. * @returns true is data kind is present
  106498. */
  106499. isVerticesDataPresent(kind: string): boolean;
  106500. /**
  106501. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  106502. * @param kind defines the data kind (Position, normal, etc...)
  106503. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  106504. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106505. * @returns a float array containing vertex data
  106506. */
  106507. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  106508. /**
  106509. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  106510. * @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.
  106511. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  106512. * @returns the indices array or an empty array if the mesh has no geometry
  106513. */
  106514. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  106515. /**
  106516. * Set specific vertex data
  106517. * @param kind defines the data kind (Position, normal, etc...)
  106518. * @param data defines the vertex data to use
  106519. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  106520. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  106521. */
  106522. setVerticesData(kind: string, data: FloatArray, updatable: boolean): void;
  106523. /**
  106524. * Update a specific associated vertex buffer
  106525. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  106526. * - VertexBuffer.PositionKind
  106527. * - VertexBuffer.UVKind
  106528. * - VertexBuffer.UV2Kind
  106529. * - VertexBuffer.UV3Kind
  106530. * - VertexBuffer.UV4Kind
  106531. * - VertexBuffer.UV5Kind
  106532. * - VertexBuffer.UV6Kind
  106533. * - VertexBuffer.ColorKind
  106534. * - VertexBuffer.MatricesIndicesKind
  106535. * - VertexBuffer.MatricesIndicesExtraKind
  106536. * - VertexBuffer.MatricesWeightsKind
  106537. * - VertexBuffer.MatricesWeightsExtraKind
  106538. * @param data defines the data source
  106539. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  106540. * @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)
  106541. */
  106542. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): void;
  106543. /**
  106544. * Creates a new index buffer
  106545. * @param indices defines the indices to store in the index buffer
  106546. * @param totalVertices defines the total number of vertices (could be null)
  106547. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  106548. */
  106549. setIndices(indices: IndicesArray, totalVertices: Nullable<number>, updatable?: boolean): void;
  106550. }
  106551. /**
  106552. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  106553. */
  106554. export class VertexData {
  106555. /**
  106556. * Mesh side orientation : usually the external or front surface
  106557. */
  106558. static readonly FRONTSIDE: number;
  106559. /**
  106560. * Mesh side orientation : usually the internal or back surface
  106561. */
  106562. static readonly BACKSIDE: number;
  106563. /**
  106564. * Mesh side orientation : both internal and external or front and back surfaces
  106565. */
  106566. static readonly DOUBLESIDE: number;
  106567. /**
  106568. * Mesh side orientation : by default, `FRONTSIDE`
  106569. */
  106570. static readonly DEFAULTSIDE: number;
  106571. /**
  106572. * An array of the x, y, z position of each vertex [...., x, y, z, .....]
  106573. */
  106574. positions: Nullable<FloatArray>;
  106575. /**
  106576. * An array of the x, y, z normal vector of each vertex [...., x, y, z, .....]
  106577. */
  106578. normals: Nullable<FloatArray>;
  106579. /**
  106580. * An array of the x, y, z tangent vector of each vertex [...., x, y, z, .....]
  106581. */
  106582. tangents: Nullable<FloatArray>;
  106583. /**
  106584. * An array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106585. */
  106586. uvs: Nullable<FloatArray>;
  106587. /**
  106588. * A second array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106589. */
  106590. uvs2: Nullable<FloatArray>;
  106591. /**
  106592. * A third array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106593. */
  106594. uvs3: Nullable<FloatArray>;
  106595. /**
  106596. * A fourth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106597. */
  106598. uvs4: Nullable<FloatArray>;
  106599. /**
  106600. * A fifth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106601. */
  106602. uvs5: Nullable<FloatArray>;
  106603. /**
  106604. * A sixth array of u,v which maps a texture image onto each vertex [...., u, v, .....]
  106605. */
  106606. uvs6: Nullable<FloatArray>;
  106607. /**
  106608. * An array of the r, g, b, a, color of each vertex [...., r, g, b, a, .....]
  106609. */
  106610. colors: Nullable<FloatArray>;
  106611. /**
  106612. * 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).
  106613. */
  106614. matricesIndices: Nullable<FloatArray>;
  106615. /**
  106616. * An array containing the list of weights defining the weight of each indexed matrix in the final computation
  106617. */
  106618. matricesWeights: Nullable<FloatArray>;
  106619. /**
  106620. * An array extending the number of possible indices
  106621. */
  106622. matricesIndicesExtra: Nullable<FloatArray>;
  106623. /**
  106624. * An array extending the number of possible weights when the number of indices is extended
  106625. */
  106626. matricesWeightsExtra: Nullable<FloatArray>;
  106627. /**
  106628. * An array of i, j, k the three vertex indices required for each triangular facet [...., i, j, k .....]
  106629. */
  106630. indices: Nullable<IndicesArray>;
  106631. /**
  106632. * Uses the passed data array to set the set the values for the specified kind of data
  106633. * @param data a linear array of floating numbers
  106634. * @param kind the type of data that is being set, eg positions, colors etc
  106635. */
  106636. set(data: FloatArray, kind: string): void;
  106637. /**
  106638. * Associates the vertexData to the passed Mesh.
  106639. * Sets it as updatable or not (default `false`)
  106640. * @param mesh the mesh the vertexData is applied to
  106641. * @param updatable when used and having the value true allows new data to update the vertexData
  106642. * @returns the VertexData
  106643. */
  106644. applyToMesh(mesh: Mesh, updatable?: boolean): VertexData;
  106645. /**
  106646. * Associates the vertexData to the passed Geometry.
  106647. * Sets it as updatable or not (default `false`)
  106648. * @param geometry the geometry the vertexData is applied to
  106649. * @param updatable when used and having the value true allows new data to update the vertexData
  106650. * @returns VertexData
  106651. */
  106652. applyToGeometry(geometry: Geometry, updatable?: boolean): VertexData;
  106653. /**
  106654. * Updates the associated mesh
  106655. * @param mesh the mesh to be updated
  106656. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106657. * @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
  106658. * @returns VertexData
  106659. */
  106660. updateMesh(mesh: Mesh): VertexData;
  106661. /**
  106662. * Updates the associated geometry
  106663. * @param geometry the geometry to be updated
  106664. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  106665. * @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
  106666. * @returns VertexData.
  106667. */
  106668. updateGeometry(geometry: Geometry): VertexData;
  106669. private _applyTo;
  106670. private _update;
  106671. /**
  106672. * Transforms each position and each normal of the vertexData according to the passed Matrix
  106673. * @param matrix the transforming matrix
  106674. * @returns the VertexData
  106675. */
  106676. transform(matrix: Matrix): VertexData;
  106677. /**
  106678. * Merges the passed VertexData into the current one
  106679. * @param other the VertexData to be merged into the current one
  106680. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  106681. * @returns the modified VertexData
  106682. */
  106683. merge(other: VertexData, use32BitsIndices?: boolean): VertexData;
  106684. private _mergeElement;
  106685. private _validate;
  106686. /**
  106687. * Serializes the VertexData
  106688. * @returns a serialized object
  106689. */
  106690. serialize(): any;
  106691. /**
  106692. * Extracts the vertexData from a mesh
  106693. * @param mesh the mesh from which to extract the VertexData
  106694. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  106695. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106696. * @returns the object VertexData associated to the passed mesh
  106697. */
  106698. static ExtractFromMesh(mesh: Mesh, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106699. /**
  106700. * Extracts the vertexData from the geometry
  106701. * @param geometry the geometry from which to extract the VertexData
  106702. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  106703. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  106704. * @returns the object VertexData associated to the passed mesh
  106705. */
  106706. static ExtractFromGeometry(geometry: Geometry, copyWhenShared?: boolean, forceCopy?: boolean): VertexData;
  106707. private static _ExtractFrom;
  106708. /**
  106709. * Creates the VertexData for a Ribbon
  106710. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  106711. * * pathArray array of paths, each of which an array of successive Vector3
  106712. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  106713. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  106714. * * 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
  106715. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106716. * * 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)
  106717. * * 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)
  106718. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  106719. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  106720. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  106721. * @returns the VertexData of the ribbon
  106722. */
  106723. static CreateRibbon(options: {
  106724. pathArray: Vector3[][];
  106725. closeArray?: boolean;
  106726. closePath?: boolean;
  106727. offset?: number;
  106728. sideOrientation?: number;
  106729. frontUVs?: Vector4;
  106730. backUVs?: Vector4;
  106731. invertUV?: boolean;
  106732. uvs?: Vector2[];
  106733. colors?: Color4[];
  106734. }): VertexData;
  106735. /**
  106736. * Creates the VertexData for a box
  106737. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106738. * * size sets the width, height and depth of the box to the value of size, optional default 1
  106739. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  106740. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  106741. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  106742. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106743. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106744. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106745. * * 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)
  106746. * * 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)
  106747. * @returns the VertexData of the box
  106748. */
  106749. static CreateBox(options: {
  106750. size?: number;
  106751. width?: number;
  106752. height?: number;
  106753. depth?: number;
  106754. faceUV?: Vector4[];
  106755. faceColors?: Color4[];
  106756. sideOrientation?: number;
  106757. frontUVs?: Vector4;
  106758. backUVs?: Vector4;
  106759. }): VertexData;
  106760. /**
  106761. * Creates the VertexData for a tiled box
  106762. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106763. * * faceTiles sets the pattern, tile size and number of tiles for a face
  106764. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  106765. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  106766. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106767. * @returns the VertexData of the box
  106768. */
  106769. static CreateTiledBox(options: {
  106770. pattern?: number;
  106771. width?: number;
  106772. height?: number;
  106773. depth?: number;
  106774. tileSize?: number;
  106775. tileWidth?: number;
  106776. tileHeight?: number;
  106777. alignHorizontal?: number;
  106778. alignVertical?: number;
  106779. faceUV?: Vector4[];
  106780. faceColors?: Color4[];
  106781. sideOrientation?: number;
  106782. }): VertexData;
  106783. /**
  106784. * Creates the VertexData for a tiled plane
  106785. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106786. * * pattern a limited pattern arrangement depending on the number
  106787. * * tileSize sets the width, height and depth of the tile to the value of size, optional default 1
  106788. * * tileWidth sets the width (x direction) of the tile, overwrites the width set by size, optional, default size
  106789. * * tileHeight sets the height (y direction) of the tile, overwrites the height set by size, optional, default size
  106790. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106791. * * 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)
  106792. * * 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)
  106793. * @returns the VertexData of the tiled plane
  106794. */
  106795. static CreateTiledPlane(options: {
  106796. pattern?: number;
  106797. tileSize?: number;
  106798. tileWidth?: number;
  106799. tileHeight?: number;
  106800. size?: number;
  106801. width?: number;
  106802. height?: number;
  106803. alignHorizontal?: number;
  106804. alignVertical?: number;
  106805. sideOrientation?: number;
  106806. frontUVs?: Vector4;
  106807. backUVs?: Vector4;
  106808. }): VertexData;
  106809. /**
  106810. * Creates the VertexData for an ellipsoid, defaults to a sphere
  106811. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106812. * * segments sets the number of horizontal strips optional, default 32
  106813. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  106814. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  106815. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  106816. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  106817. * * 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
  106818. * * 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
  106819. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106820. * * 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)
  106821. * * 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)
  106822. * @returns the VertexData of the ellipsoid
  106823. */
  106824. static CreateSphere(options: {
  106825. segments?: number;
  106826. diameter?: number;
  106827. diameterX?: number;
  106828. diameterY?: number;
  106829. diameterZ?: number;
  106830. arc?: number;
  106831. slice?: number;
  106832. sideOrientation?: number;
  106833. frontUVs?: Vector4;
  106834. backUVs?: Vector4;
  106835. }): VertexData;
  106836. /**
  106837. * Creates the VertexData for a cylinder, cone or prism
  106838. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106839. * * height sets the height (y direction) of the cylinder, optional, default 2
  106840. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  106841. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  106842. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  106843. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106844. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  106845. * * 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
  106846. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  106847. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  106848. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  106849. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  106850. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106851. * * 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)
  106852. * * 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)
  106853. * @returns the VertexData of the cylinder, cone or prism
  106854. */
  106855. static CreateCylinder(options: {
  106856. height?: number;
  106857. diameterTop?: number;
  106858. diameterBottom?: number;
  106859. diameter?: number;
  106860. tessellation?: number;
  106861. subdivisions?: number;
  106862. arc?: number;
  106863. faceColors?: Color4[];
  106864. faceUV?: Vector4[];
  106865. hasRings?: boolean;
  106866. enclose?: boolean;
  106867. sideOrientation?: number;
  106868. frontUVs?: Vector4;
  106869. backUVs?: Vector4;
  106870. }): VertexData;
  106871. /**
  106872. * Creates the VertexData for a torus
  106873. * @param options an object used to set the following optional parameters for the box, required but can be empty
  106874. * * diameter the diameter of the torus, optional default 1
  106875. * * thickness the diameter of the tube forming the torus, optional default 0.5
  106876. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  106877. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106878. * * 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)
  106879. * * 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)
  106880. * @returns the VertexData of the torus
  106881. */
  106882. static CreateTorus(options: {
  106883. diameter?: number;
  106884. thickness?: number;
  106885. tessellation?: number;
  106886. sideOrientation?: number;
  106887. frontUVs?: Vector4;
  106888. backUVs?: Vector4;
  106889. }): VertexData;
  106890. /**
  106891. * Creates the VertexData of the LineSystem
  106892. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  106893. * - lines an array of lines, each line being an array of successive Vector3
  106894. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  106895. * @returns the VertexData of the LineSystem
  106896. */
  106897. static CreateLineSystem(options: {
  106898. lines: Vector3[][];
  106899. colors?: Nullable<Color4[][]>;
  106900. }): VertexData;
  106901. /**
  106902. * Create the VertexData for a DashedLines
  106903. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  106904. * - points an array successive Vector3
  106905. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  106906. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  106907. * - dashNb the intended total number of dashes, optional, default 200
  106908. * @returns the VertexData for the DashedLines
  106909. */
  106910. static CreateDashedLines(options: {
  106911. points: Vector3[];
  106912. dashSize?: number;
  106913. gapSize?: number;
  106914. dashNb?: number;
  106915. }): VertexData;
  106916. /**
  106917. * Creates the VertexData for a Ground
  106918. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106919. * - width the width (x direction) of the ground, optional, default 1
  106920. * - height the height (z direction) of the ground, optional, default 1
  106921. * - subdivisions the number of subdivisions per side, optional, default 1
  106922. * @returns the VertexData of the Ground
  106923. */
  106924. static CreateGround(options: {
  106925. width?: number;
  106926. height?: number;
  106927. subdivisions?: number;
  106928. subdivisionsX?: number;
  106929. subdivisionsY?: number;
  106930. }): VertexData;
  106931. /**
  106932. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  106933. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  106934. * * xmin the ground minimum X coordinate, optional, default -1
  106935. * * zmin the ground minimum Z coordinate, optional, default -1
  106936. * * xmax the ground maximum X coordinate, optional, default 1
  106937. * * zmax the ground maximum Z coordinate, optional, default 1
  106938. * * 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}
  106939. * * 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}
  106940. * @returns the VertexData of the TiledGround
  106941. */
  106942. static CreateTiledGround(options: {
  106943. xmin: number;
  106944. zmin: number;
  106945. xmax: number;
  106946. zmax: number;
  106947. subdivisions?: {
  106948. w: number;
  106949. h: number;
  106950. };
  106951. precision?: {
  106952. w: number;
  106953. h: number;
  106954. };
  106955. }): VertexData;
  106956. /**
  106957. * Creates the VertexData of the Ground designed from a heightmap
  106958. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  106959. * * width the width (x direction) of the ground
  106960. * * height the height (z direction) of the ground
  106961. * * subdivisions the number of subdivisions per side
  106962. * * minHeight the minimum altitude on the ground, optional, default 0
  106963. * * maxHeight the maximum altitude on the ground, optional default 1
  106964. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  106965. * * buffer the array holding the image color data
  106966. * * bufferWidth the width of image
  106967. * * bufferHeight the height of image
  106968. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  106969. * @returns the VertexData of the Ground designed from a heightmap
  106970. */
  106971. static CreateGroundFromHeightMap(options: {
  106972. width: number;
  106973. height: number;
  106974. subdivisions: number;
  106975. minHeight: number;
  106976. maxHeight: number;
  106977. colorFilter: Color3;
  106978. buffer: Uint8Array;
  106979. bufferWidth: number;
  106980. bufferHeight: number;
  106981. alphaFilter: number;
  106982. }): VertexData;
  106983. /**
  106984. * Creates the VertexData for a Plane
  106985. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  106986. * * size sets the width and height of the plane to the value of size, optional default 1
  106987. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  106988. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  106989. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  106990. * * 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)
  106991. * * 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)
  106992. * @returns the VertexData of the box
  106993. */
  106994. static CreatePlane(options: {
  106995. size?: number;
  106996. width?: number;
  106997. height?: number;
  106998. sideOrientation?: number;
  106999. frontUVs?: Vector4;
  107000. backUVs?: Vector4;
  107001. }): VertexData;
  107002. /**
  107003. * Creates the VertexData of the Disc or regular Polygon
  107004. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  107005. * * radius the radius of the disc, optional default 0.5
  107006. * * tessellation the number of polygon sides, optional, default 64
  107007. * * 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
  107008. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107009. * * 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)
  107010. * * 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)
  107011. * @returns the VertexData of the box
  107012. */
  107013. static CreateDisc(options: {
  107014. radius?: number;
  107015. tessellation?: number;
  107016. arc?: number;
  107017. sideOrientation?: number;
  107018. frontUVs?: Vector4;
  107019. backUVs?: Vector4;
  107020. }): VertexData;
  107021. /**
  107022. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  107023. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  107024. * @param polygon a mesh built from polygonTriangulation.build()
  107025. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107026. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  107027. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  107028. * @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)
  107029. * @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)
  107030. * @param wrap a boolean, default false, when true and fUVs used texture is wrapped around all sides, when false texture is applied side
  107031. * @returns the VertexData of the Polygon
  107032. */
  107033. static CreatePolygon(polygon: Mesh, sideOrientation: number, fUV?: Vector4[], fColors?: Color4[], frontUVs?: Vector4, backUVs?: Vector4, wrap?: boolean): VertexData;
  107034. /**
  107035. * Creates the VertexData of the IcoSphere
  107036. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  107037. * * radius the radius of the IcoSphere, optional default 1
  107038. * * radiusX allows stretching in the x direction, optional, default radius
  107039. * * radiusY allows stretching in the y direction, optional, default radius
  107040. * * radiusZ allows stretching in the z direction, optional, default radius
  107041. * * flat when true creates a flat shaded mesh, optional, default true
  107042. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  107043. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107044. * * 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)
  107045. * * 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)
  107046. * @returns the VertexData of the IcoSphere
  107047. */
  107048. static CreateIcoSphere(options: {
  107049. radius?: number;
  107050. radiusX?: number;
  107051. radiusY?: number;
  107052. radiusZ?: number;
  107053. flat?: boolean;
  107054. subdivisions?: number;
  107055. sideOrientation?: number;
  107056. frontUVs?: Vector4;
  107057. backUVs?: Vector4;
  107058. }): VertexData;
  107059. /**
  107060. * Creates the VertexData for a Polyhedron
  107061. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  107062. * * type provided types are:
  107063. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  107064. * * 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)
  107065. * * size the size of the IcoSphere, optional default 1
  107066. * * sizeX allows stretching in the x direction, optional, default size
  107067. * * sizeY allows stretching in the y direction, optional, default size
  107068. * * sizeZ allows stretching in the z direction, optional, default size
  107069. * * 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
  107070. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  107071. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  107072. * * flat when true creates a flat shaded mesh, optional, default true
  107073. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  107074. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107075. * * 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)
  107076. * * 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)
  107077. * @returns the VertexData of the Polyhedron
  107078. */
  107079. static CreatePolyhedron(options: {
  107080. type?: number;
  107081. size?: number;
  107082. sizeX?: number;
  107083. sizeY?: number;
  107084. sizeZ?: number;
  107085. custom?: any;
  107086. faceUV?: Vector4[];
  107087. faceColors?: Color4[];
  107088. flat?: boolean;
  107089. sideOrientation?: number;
  107090. frontUVs?: Vector4;
  107091. backUVs?: Vector4;
  107092. }): VertexData;
  107093. /**
  107094. * Creates the VertexData for a Capsule, inspired from https://github.com/maximeq/three-js-capsule-geometry/blob/master/src/CapsuleBufferGeometry.js
  107095. * @param options an object used to set the following optional parameters for the capsule, required but can be empty
  107096. * @returns the VertexData of the Capsule
  107097. */
  107098. static CreateCapsule(options?: ICreateCapsuleOptions): VertexData;
  107099. /**
  107100. * Creates the VertexData for a TorusKnot
  107101. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  107102. * * radius the radius of the torus knot, optional, default 2
  107103. * * tube the thickness of the tube, optional, default 0.5
  107104. * * radialSegments the number of sides on each tube segments, optional, default 32
  107105. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  107106. * * p the number of windings around the z axis, optional, default 2
  107107. * * q the number of windings around the x axis, optional, default 3
  107108. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  107109. * * 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)
  107110. * * 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)
  107111. * @returns the VertexData of the Torus Knot
  107112. */
  107113. static CreateTorusKnot(options: {
  107114. radius?: number;
  107115. tube?: number;
  107116. radialSegments?: number;
  107117. tubularSegments?: number;
  107118. p?: number;
  107119. q?: number;
  107120. sideOrientation?: number;
  107121. frontUVs?: Vector4;
  107122. backUVs?: Vector4;
  107123. }): VertexData;
  107124. /**
  107125. * Compute normals for given positions and indices
  107126. * @param positions an array of vertex positions, [...., x, y, z, ......]
  107127. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  107128. * @param normals an array of vertex normals, [...., x, y, z, ......]
  107129. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  107130. * * facetNormals : optional array of facet normals (vector3)
  107131. * * facetPositions : optional array of facet positions (vector3)
  107132. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  107133. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  107134. * * bInfo : optional bounding info, required for facetPartitioning computation
  107135. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  107136. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  107137. * * useRightHandedSystem: optional boolean to for right handed system computation
  107138. * * depthSort : optional boolean to enable the facet depth sort computation
  107139. * * distanceTo : optional Vector3 to compute the facet depth from this location
  107140. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  107141. */
  107142. static ComputeNormals(positions: any, indices: any, normals: any, options?: {
  107143. facetNormals?: any;
  107144. facetPositions?: any;
  107145. facetPartitioning?: any;
  107146. ratio?: number;
  107147. bInfo?: any;
  107148. bbSize?: Vector3;
  107149. subDiv?: any;
  107150. useRightHandedSystem?: boolean;
  107151. depthSort?: boolean;
  107152. distanceTo?: Vector3;
  107153. depthSortedFacets?: any;
  107154. }): void;
  107155. /** @hidden */
  107156. static _ComputeSides(sideOrientation: number, positions: FloatArray, indices: FloatArray, normals: FloatArray, uvs: FloatArray, frontUVs?: Vector4, backUVs?: Vector4): void;
  107157. /**
  107158. * Applies VertexData created from the imported parameters to the geometry
  107159. * @param parsedVertexData the parsed data from an imported file
  107160. * @param geometry the geometry to apply the VertexData to
  107161. */
  107162. static ImportVertexData(parsedVertexData: any, geometry: Geometry): void;
  107163. }
  107164. }
  107165. declare module BABYLON {
  107166. /**
  107167. * Defines a target to use with MorphTargetManager
  107168. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107169. */
  107170. export class MorphTarget implements IAnimatable {
  107171. /** defines the name of the target */
  107172. name: string;
  107173. /**
  107174. * Gets or sets the list of animations
  107175. */
  107176. animations: Animation[];
  107177. private _scene;
  107178. private _positions;
  107179. private _normals;
  107180. private _tangents;
  107181. private _uvs;
  107182. private _influence;
  107183. private _uniqueId;
  107184. /**
  107185. * Observable raised when the influence changes
  107186. */
  107187. onInfluenceChanged: Observable<boolean>;
  107188. /** @hidden */
  107189. _onDataLayoutChanged: Observable<void>;
  107190. /**
  107191. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  107192. */
  107193. get influence(): number;
  107194. set influence(influence: number);
  107195. /**
  107196. * Gets or sets the id of the morph Target
  107197. */
  107198. id: string;
  107199. private _animationPropertiesOverride;
  107200. /**
  107201. * Gets or sets the animation properties override
  107202. */
  107203. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  107204. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  107205. /**
  107206. * Creates a new MorphTarget
  107207. * @param name defines the name of the target
  107208. * @param influence defines the influence to use
  107209. * @param scene defines the scene the morphtarget belongs to
  107210. */
  107211. constructor(
  107212. /** defines the name of the target */
  107213. name: string, influence?: number, scene?: Nullable<Scene>);
  107214. /**
  107215. * Gets the unique ID of this manager
  107216. */
  107217. get uniqueId(): number;
  107218. /**
  107219. * Gets a boolean defining if the target contains position data
  107220. */
  107221. get hasPositions(): boolean;
  107222. /**
  107223. * Gets a boolean defining if the target contains normal data
  107224. */
  107225. get hasNormals(): boolean;
  107226. /**
  107227. * Gets a boolean defining if the target contains tangent data
  107228. */
  107229. get hasTangents(): boolean;
  107230. /**
  107231. * Gets a boolean defining if the target contains texture coordinates data
  107232. */
  107233. get hasUVs(): boolean;
  107234. /**
  107235. * Affects position data to this target
  107236. * @param data defines the position data to use
  107237. */
  107238. setPositions(data: Nullable<FloatArray>): void;
  107239. /**
  107240. * Gets the position data stored in this target
  107241. * @returns a FloatArray containing the position data (or null if not present)
  107242. */
  107243. getPositions(): Nullable<FloatArray>;
  107244. /**
  107245. * Affects normal data to this target
  107246. * @param data defines the normal data to use
  107247. */
  107248. setNormals(data: Nullable<FloatArray>): void;
  107249. /**
  107250. * Gets the normal data stored in this target
  107251. * @returns a FloatArray containing the normal data (or null if not present)
  107252. */
  107253. getNormals(): Nullable<FloatArray>;
  107254. /**
  107255. * Affects tangent data to this target
  107256. * @param data defines the tangent data to use
  107257. */
  107258. setTangents(data: Nullable<FloatArray>): void;
  107259. /**
  107260. * Gets the tangent data stored in this target
  107261. * @returns a FloatArray containing the tangent data (or null if not present)
  107262. */
  107263. getTangents(): Nullable<FloatArray>;
  107264. /**
  107265. * Affects texture coordinates data to this target
  107266. * @param data defines the texture coordinates data to use
  107267. */
  107268. setUVs(data: Nullable<FloatArray>): void;
  107269. /**
  107270. * Gets the texture coordinates data stored in this target
  107271. * @returns a FloatArray containing the texture coordinates data (or null if not present)
  107272. */
  107273. getUVs(): Nullable<FloatArray>;
  107274. /**
  107275. * Clone the current target
  107276. * @returns a new MorphTarget
  107277. */
  107278. clone(): MorphTarget;
  107279. /**
  107280. * Serializes the current target into a Serialization object
  107281. * @returns the serialized object
  107282. */
  107283. serialize(): any;
  107284. /**
  107285. * Returns the string "MorphTarget"
  107286. * @returns "MorphTarget"
  107287. */
  107288. getClassName(): string;
  107289. /**
  107290. * Creates a new target from serialized data
  107291. * @param serializationObject defines the serialized data to use
  107292. * @returns a new MorphTarget
  107293. */
  107294. static Parse(serializationObject: any): MorphTarget;
  107295. /**
  107296. * Creates a MorphTarget from mesh data
  107297. * @param mesh defines the source mesh
  107298. * @param name defines the name to use for the new target
  107299. * @param influence defines the influence to attach to the target
  107300. * @returns a new MorphTarget
  107301. */
  107302. static FromMesh(mesh: AbstractMesh, name?: string, influence?: number): MorphTarget;
  107303. }
  107304. }
  107305. declare module BABYLON {
  107306. /**
  107307. * This class is used to deform meshes using morphing between different targets
  107308. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  107309. */
  107310. export class MorphTargetManager {
  107311. private _targets;
  107312. private _targetInfluenceChangedObservers;
  107313. private _targetDataLayoutChangedObservers;
  107314. private _activeTargets;
  107315. private _scene;
  107316. private _influences;
  107317. private _supportsNormals;
  107318. private _supportsTangents;
  107319. private _supportsUVs;
  107320. private _vertexCount;
  107321. private _uniqueId;
  107322. private _tempInfluences;
  107323. /**
  107324. * Gets or sets a boolean indicating if normals must be morphed
  107325. */
  107326. enableNormalMorphing: boolean;
  107327. /**
  107328. * Gets or sets a boolean indicating if tangents must be morphed
  107329. */
  107330. enableTangentMorphing: boolean;
  107331. /**
  107332. * Gets or sets a boolean indicating if UV must be morphed
  107333. */
  107334. enableUVMorphing: boolean;
  107335. /**
  107336. * Creates a new MorphTargetManager
  107337. * @param scene defines the current scene
  107338. */
  107339. constructor(scene?: Nullable<Scene>);
  107340. /**
  107341. * Gets the unique ID of this manager
  107342. */
  107343. get uniqueId(): number;
  107344. /**
  107345. * Gets the number of vertices handled by this manager
  107346. */
  107347. get vertexCount(): number;
  107348. /**
  107349. * Gets a boolean indicating if this manager supports morphing of normals
  107350. */
  107351. get supportsNormals(): boolean;
  107352. /**
  107353. * Gets a boolean indicating if this manager supports morphing of tangents
  107354. */
  107355. get supportsTangents(): boolean;
  107356. /**
  107357. * Gets a boolean indicating if this manager supports morphing of texture coordinates
  107358. */
  107359. get supportsUVs(): boolean;
  107360. /**
  107361. * Gets the number of targets stored in this manager
  107362. */
  107363. get numTargets(): number;
  107364. /**
  107365. * Gets the number of influencers (ie. the number of targets with influences > 0)
  107366. */
  107367. get numInfluencers(): number;
  107368. /**
  107369. * Gets the list of influences (one per target)
  107370. */
  107371. get influences(): Float32Array;
  107372. /**
  107373. * Gets the active target at specified index. An active target is a target with an influence > 0
  107374. * @param index defines the index to check
  107375. * @returns the requested target
  107376. */
  107377. getActiveTarget(index: number): MorphTarget;
  107378. /**
  107379. * Gets the target at specified index
  107380. * @param index defines the index to check
  107381. * @returns the requested target
  107382. */
  107383. getTarget(index: number): MorphTarget;
  107384. /**
  107385. * Add a new target to this manager
  107386. * @param target defines the target to add
  107387. */
  107388. addTarget(target: MorphTarget): void;
  107389. /**
  107390. * Removes a target from the manager
  107391. * @param target defines the target to remove
  107392. */
  107393. removeTarget(target: MorphTarget): void;
  107394. /**
  107395. * Clone the current manager
  107396. * @returns a new MorphTargetManager
  107397. */
  107398. clone(): MorphTargetManager;
  107399. /**
  107400. * Serializes the current manager into a Serialization object
  107401. * @returns the serialized object
  107402. */
  107403. serialize(): any;
  107404. private _syncActiveTargets;
  107405. /**
  107406. * Syncrhonize the targets with all the meshes using this morph target manager
  107407. */
  107408. synchronize(): void;
  107409. /**
  107410. * Creates a new MorphTargetManager from serialized data
  107411. * @param serializationObject defines the serialized data
  107412. * @param scene defines the hosting scene
  107413. * @returns the new MorphTargetManager
  107414. */
  107415. static Parse(serializationObject: any, scene: Scene): MorphTargetManager;
  107416. }
  107417. }
  107418. declare module BABYLON {
  107419. /**
  107420. * Class used to represent a specific level of detail of a mesh
  107421. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  107422. */
  107423. export class MeshLODLevel {
  107424. /** Defines the distance where this level should start being displayed */
  107425. distance: number;
  107426. /** Defines the mesh to use to render this level */
  107427. mesh: Nullable<Mesh>;
  107428. /**
  107429. * Creates a new LOD level
  107430. * @param distance defines the distance where this level should star being displayed
  107431. * @param mesh defines the mesh to use to render this level
  107432. */
  107433. constructor(
  107434. /** Defines the distance where this level should start being displayed */
  107435. distance: number,
  107436. /** Defines the mesh to use to render this level */
  107437. mesh: Nullable<Mesh>);
  107438. }
  107439. }
  107440. declare module BABYLON {
  107441. /**
  107442. * Helper class used to generate a canvas to manipulate images
  107443. */
  107444. export class CanvasGenerator {
  107445. /**
  107446. * Create a new canvas (or offscreen canvas depending on the context)
  107447. * @param width defines the expected width
  107448. * @param height defines the expected height
  107449. * @return a new canvas or offscreen canvas
  107450. */
  107451. static CreateCanvas(width: number, height: number): HTMLCanvasElement | OffscreenCanvas;
  107452. }
  107453. }
  107454. declare module BABYLON {
  107455. /**
  107456. * Mesh representing the gorund
  107457. */
  107458. export class GroundMesh extends Mesh {
  107459. /** If octree should be generated */
  107460. generateOctree: boolean;
  107461. private _heightQuads;
  107462. /** @hidden */
  107463. _subdivisionsX: number;
  107464. /** @hidden */
  107465. _subdivisionsY: number;
  107466. /** @hidden */
  107467. _width: number;
  107468. /** @hidden */
  107469. _height: number;
  107470. /** @hidden */
  107471. _minX: number;
  107472. /** @hidden */
  107473. _maxX: number;
  107474. /** @hidden */
  107475. _minZ: number;
  107476. /** @hidden */
  107477. _maxZ: number;
  107478. constructor(name: string, scene: Scene);
  107479. /**
  107480. * "GroundMesh"
  107481. * @returns "GroundMesh"
  107482. */
  107483. getClassName(): string;
  107484. /**
  107485. * The minimum of x and y subdivisions
  107486. */
  107487. get subdivisions(): number;
  107488. /**
  107489. * X subdivisions
  107490. */
  107491. get subdivisionsX(): number;
  107492. /**
  107493. * Y subdivisions
  107494. */
  107495. get subdivisionsY(): number;
  107496. /**
  107497. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  107498. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  107499. * @param chunksCount the number of subdivisions for x and y
  107500. * @param octreeBlocksSize (Default: 32)
  107501. */
  107502. optimize(chunksCount: number, octreeBlocksSize?: number): void;
  107503. /**
  107504. * Returns a height (y) value in the Worl system :
  107505. * the ground altitude at the coordinates (x, z) expressed in the World system.
  107506. * @param x x coordinate
  107507. * @param z z coordinate
  107508. * @returns the ground y position if (x, z) are outside the ground surface.
  107509. */
  107510. getHeightAtCoordinates(x: number, z: number): number;
  107511. /**
  107512. * Returns a normalized vector (Vector3) orthogonal to the ground
  107513. * at the ground coordinates (x, z) expressed in the World system.
  107514. * @param x x coordinate
  107515. * @param z z coordinate
  107516. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  107517. */
  107518. getNormalAtCoordinates(x: number, z: number): Vector3;
  107519. /**
  107520. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  107521. * at the ground coordinates (x, z) expressed in the World system.
  107522. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  107523. * @param x x coordinate
  107524. * @param z z coordinate
  107525. * @param ref vector to store the result
  107526. * @returns the GroundMesh.
  107527. */
  107528. getNormalAtCoordinatesToRef(x: number, z: number, ref: Vector3): GroundMesh;
  107529. /**
  107530. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  107531. * if the ground has been updated.
  107532. * This can be used in the render loop.
  107533. * @returns the GroundMesh.
  107534. */
  107535. updateCoordinateHeights(): GroundMesh;
  107536. private _getFacetAt;
  107537. private _initHeightQuads;
  107538. private _computeHeightQuads;
  107539. /**
  107540. * Serializes this ground mesh
  107541. * @param serializationObject object to write serialization to
  107542. */
  107543. serialize(serializationObject: any): void;
  107544. /**
  107545. * Parses a serialized ground mesh
  107546. * @param parsedMesh the serialized mesh
  107547. * @param scene the scene to create the ground mesh in
  107548. * @returns the created ground mesh
  107549. */
  107550. static Parse(parsedMesh: any, scene: Scene): GroundMesh;
  107551. }
  107552. }
  107553. declare module BABYLON {
  107554. /**
  107555. * Interface for Physics-Joint data
  107556. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107557. */
  107558. export interface PhysicsJointData {
  107559. /**
  107560. * The main pivot of the joint
  107561. */
  107562. mainPivot?: Vector3;
  107563. /**
  107564. * The connected pivot of the joint
  107565. */
  107566. connectedPivot?: Vector3;
  107567. /**
  107568. * The main axis of the joint
  107569. */
  107570. mainAxis?: Vector3;
  107571. /**
  107572. * The connected axis of the joint
  107573. */
  107574. connectedAxis?: Vector3;
  107575. /**
  107576. * The collision of the joint
  107577. */
  107578. collision?: boolean;
  107579. /**
  107580. * Native Oimo/Cannon/Energy data
  107581. */
  107582. nativeParams?: any;
  107583. }
  107584. /**
  107585. * This is a holder class for the physics joint created by the physics plugin
  107586. * It holds a set of functions to control the underlying joint
  107587. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107588. */
  107589. export class PhysicsJoint {
  107590. /**
  107591. * The type of the physics joint
  107592. */
  107593. type: number;
  107594. /**
  107595. * The data for the physics joint
  107596. */
  107597. jointData: PhysicsJointData;
  107598. private _physicsJoint;
  107599. protected _physicsPlugin: IPhysicsEnginePlugin;
  107600. /**
  107601. * Initializes the physics joint
  107602. * @param type The type of the physics joint
  107603. * @param jointData The data for the physics joint
  107604. */
  107605. constructor(
  107606. /**
  107607. * The type of the physics joint
  107608. */
  107609. type: number,
  107610. /**
  107611. * The data for the physics joint
  107612. */
  107613. jointData: PhysicsJointData);
  107614. /**
  107615. * Gets the physics joint
  107616. */
  107617. get physicsJoint(): any;
  107618. /**
  107619. * Sets the physics joint
  107620. */
  107621. set physicsJoint(newJoint: any);
  107622. /**
  107623. * Sets the physics plugin
  107624. */
  107625. set physicsPlugin(physicsPlugin: IPhysicsEnginePlugin);
  107626. /**
  107627. * Execute a function that is physics-plugin specific.
  107628. * @param {Function} func the function that will be executed.
  107629. * It accepts two parameters: the physics world and the physics joint
  107630. */
  107631. executeNativeFunction(func: (world: any, physicsJoint: any) => void): void;
  107632. /**
  107633. * Distance-Joint type
  107634. */
  107635. static DistanceJoint: number;
  107636. /**
  107637. * Hinge-Joint type
  107638. */
  107639. static HingeJoint: number;
  107640. /**
  107641. * Ball-and-Socket joint type
  107642. */
  107643. static BallAndSocketJoint: number;
  107644. /**
  107645. * Wheel-Joint type
  107646. */
  107647. static WheelJoint: number;
  107648. /**
  107649. * Slider-Joint type
  107650. */
  107651. static SliderJoint: number;
  107652. /**
  107653. * Prismatic-Joint type
  107654. */
  107655. static PrismaticJoint: number;
  107656. /**
  107657. * Universal-Joint type
  107658. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  107659. */
  107660. static UniversalJoint: number;
  107661. /**
  107662. * Hinge-Joint 2 type
  107663. */
  107664. static Hinge2Joint: number;
  107665. /**
  107666. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  107667. */
  107668. static PointToPointJoint: number;
  107669. /**
  107670. * Spring-Joint type
  107671. */
  107672. static SpringJoint: number;
  107673. /**
  107674. * Lock-Joint type
  107675. */
  107676. static LockJoint: number;
  107677. }
  107678. /**
  107679. * A class representing a physics distance joint
  107680. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107681. */
  107682. export class DistanceJoint extends PhysicsJoint {
  107683. /**
  107684. *
  107685. * @param jointData The data for the Distance-Joint
  107686. */
  107687. constructor(jointData: DistanceJointData);
  107688. /**
  107689. * Update the predefined distance.
  107690. * @param maxDistance The maximum preferred distance
  107691. * @param minDistance The minimum preferred distance
  107692. */
  107693. updateDistance(maxDistance: number, minDistance?: number): void;
  107694. }
  107695. /**
  107696. * Represents a Motor-Enabled Joint
  107697. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107698. */
  107699. export class MotorEnabledJoint extends PhysicsJoint implements IMotorEnabledJoint {
  107700. /**
  107701. * Initializes the Motor-Enabled Joint
  107702. * @param type The type of the joint
  107703. * @param jointData The physica joint data for the joint
  107704. */
  107705. constructor(type: number, jointData: PhysicsJointData);
  107706. /**
  107707. * Set the motor values.
  107708. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107709. * @param force the force to apply
  107710. * @param maxForce max force for this motor.
  107711. */
  107712. setMotor(force?: number, maxForce?: number): void;
  107713. /**
  107714. * Set the motor's limits.
  107715. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107716. * @param upperLimit The upper limit of the motor
  107717. * @param lowerLimit The lower limit of the motor
  107718. */
  107719. setLimit(upperLimit: number, lowerLimit?: number): void;
  107720. }
  107721. /**
  107722. * This class represents a single physics Hinge-Joint
  107723. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107724. */
  107725. export class HingeJoint extends MotorEnabledJoint {
  107726. /**
  107727. * Initializes the Hinge-Joint
  107728. * @param jointData The joint data for the Hinge-Joint
  107729. */
  107730. constructor(jointData: PhysicsJointData);
  107731. /**
  107732. * Set the motor values.
  107733. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107734. * @param {number} force the force to apply
  107735. * @param {number} maxForce max force for this motor.
  107736. */
  107737. setMotor(force?: number, maxForce?: number): void;
  107738. /**
  107739. * Set the motor's limits.
  107740. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107741. * @param upperLimit The upper limit of the motor
  107742. * @param lowerLimit The lower limit of the motor
  107743. */
  107744. setLimit(upperLimit: number, lowerLimit?: number): void;
  107745. }
  107746. /**
  107747. * This class represents a dual hinge physics joint (same as wheel joint)
  107748. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107749. */
  107750. export class Hinge2Joint extends MotorEnabledJoint {
  107751. /**
  107752. * Initializes the Hinge2-Joint
  107753. * @param jointData The joint data for the Hinge2-Joint
  107754. */
  107755. constructor(jointData: PhysicsJointData);
  107756. /**
  107757. * Set the motor values.
  107758. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107759. * @param {number} targetSpeed the speed the motor is to reach
  107760. * @param {number} maxForce max force for this motor.
  107761. * @param {motorIndex} the motor's index, 0 or 1.
  107762. */
  107763. setMotor(targetSpeed?: number, maxForce?: number, motorIndex?: number): void;
  107764. /**
  107765. * Set the motor limits.
  107766. * Attention, this function is plugin specific. Engines won't react 100% the same.
  107767. * @param {number} upperLimit the upper limit
  107768. * @param {number} lowerLimit lower limit
  107769. * @param {motorIndex} the motor's index, 0 or 1.
  107770. */
  107771. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107772. }
  107773. /**
  107774. * Interface for a motor enabled joint
  107775. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107776. */
  107777. export interface IMotorEnabledJoint {
  107778. /**
  107779. * Physics joint
  107780. */
  107781. physicsJoint: any;
  107782. /**
  107783. * Sets the motor of the motor-enabled joint
  107784. * @param force The force of the motor
  107785. * @param maxForce The maximum force of the motor
  107786. * @param motorIndex The index of the motor
  107787. */
  107788. setMotor(force?: number, maxForce?: number, motorIndex?: number): void;
  107789. /**
  107790. * Sets the limit of the motor
  107791. * @param upperLimit The upper limit of the motor
  107792. * @param lowerLimit The lower limit of the motor
  107793. * @param motorIndex The index of the motor
  107794. */
  107795. setLimit(upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107796. }
  107797. /**
  107798. * Joint data for a Distance-Joint
  107799. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107800. */
  107801. export interface DistanceJointData extends PhysicsJointData {
  107802. /**
  107803. * Max distance the 2 joint objects can be apart
  107804. */
  107805. maxDistance: number;
  107806. }
  107807. /**
  107808. * Joint data from a spring joint
  107809. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107810. */
  107811. export interface SpringJointData extends PhysicsJointData {
  107812. /**
  107813. * Length of the spring
  107814. */
  107815. length: number;
  107816. /**
  107817. * Stiffness of the spring
  107818. */
  107819. stiffness: number;
  107820. /**
  107821. * Damping of the spring
  107822. */
  107823. damping: number;
  107824. /** this callback will be called when applying the force to the impostors. */
  107825. forceApplicationCallback: () => void;
  107826. }
  107827. }
  107828. declare module BABYLON {
  107829. /**
  107830. * Holds the data for the raycast result
  107831. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107832. */
  107833. export class PhysicsRaycastResult {
  107834. private _hasHit;
  107835. private _hitDistance;
  107836. private _hitNormalWorld;
  107837. private _hitPointWorld;
  107838. private _rayFromWorld;
  107839. private _rayToWorld;
  107840. /**
  107841. * Gets if there was a hit
  107842. */
  107843. get hasHit(): boolean;
  107844. /**
  107845. * Gets the distance from the hit
  107846. */
  107847. get hitDistance(): number;
  107848. /**
  107849. * Gets the hit normal/direction in the world
  107850. */
  107851. get hitNormalWorld(): Vector3;
  107852. /**
  107853. * Gets the hit point in the world
  107854. */
  107855. get hitPointWorld(): Vector3;
  107856. /**
  107857. * Gets the ray "start point" of the ray in the world
  107858. */
  107859. get rayFromWorld(): Vector3;
  107860. /**
  107861. * Gets the ray "end point" of the ray in the world
  107862. */
  107863. get rayToWorld(): Vector3;
  107864. /**
  107865. * Sets the hit data (normal & point in world space)
  107866. * @param hitNormalWorld defines the normal in world space
  107867. * @param hitPointWorld defines the point in world space
  107868. */
  107869. setHitData(hitNormalWorld: IXYZ, hitPointWorld: IXYZ): void;
  107870. /**
  107871. * Sets the distance from the start point to the hit point
  107872. * @param distance
  107873. */
  107874. setHitDistance(distance: number): void;
  107875. /**
  107876. * Calculates the distance manually
  107877. */
  107878. calculateHitDistance(): void;
  107879. /**
  107880. * Resets all the values to default
  107881. * @param from The from point on world space
  107882. * @param to The to point on world space
  107883. */
  107884. reset(from?: Vector3, to?: Vector3): void;
  107885. }
  107886. /**
  107887. * Interface for the size containing width and height
  107888. */
  107889. interface IXYZ {
  107890. /**
  107891. * X
  107892. */
  107893. x: number;
  107894. /**
  107895. * Y
  107896. */
  107897. y: number;
  107898. /**
  107899. * Z
  107900. */
  107901. z: number;
  107902. }
  107903. }
  107904. declare module BABYLON {
  107905. /**
  107906. * Interface used to describe a physics joint
  107907. */
  107908. export interface PhysicsImpostorJoint {
  107909. /** Defines the main impostor to which the joint is linked */
  107910. mainImpostor: PhysicsImpostor;
  107911. /** Defines the impostor that is connected to the main impostor using this joint */
  107912. connectedImpostor: PhysicsImpostor;
  107913. /** Defines the joint itself */
  107914. joint: PhysicsJoint;
  107915. }
  107916. /** @hidden */
  107917. export interface IPhysicsEnginePlugin {
  107918. world: any;
  107919. name: string;
  107920. setGravity(gravity: Vector3): void;
  107921. setTimeStep(timeStep: number): void;
  107922. getTimeStep(): number;
  107923. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  107924. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107925. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  107926. generatePhysicsBody(impostor: PhysicsImpostor): void;
  107927. removePhysicsBody(impostor: PhysicsImpostor): void;
  107928. generateJoint(joint: PhysicsImpostorJoint): void;
  107929. removeJoint(joint: PhysicsImpostorJoint): void;
  107930. isSupported(): boolean;
  107931. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  107932. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  107933. setLinearVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107934. setAngularVelocity(impostor: PhysicsImpostor, velocity: Nullable<Vector3>): void;
  107935. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107936. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  107937. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  107938. getBodyMass(impostor: PhysicsImpostor): number;
  107939. getBodyFriction(impostor: PhysicsImpostor): number;
  107940. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  107941. getBodyRestitution(impostor: PhysicsImpostor): number;
  107942. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  107943. getBodyPressure?(impostor: PhysicsImpostor): number;
  107944. setBodyPressure?(impostor: PhysicsImpostor, pressure: number): void;
  107945. getBodyStiffness?(impostor: PhysicsImpostor): number;
  107946. setBodyStiffness?(impostor: PhysicsImpostor, stiffness: number): void;
  107947. getBodyVelocityIterations?(impostor: PhysicsImpostor): number;
  107948. setBodyVelocityIterations?(impostor: PhysicsImpostor, velocityIterations: number): void;
  107949. getBodyPositionIterations?(impostor: PhysicsImpostor): number;
  107950. setBodyPositionIterations?(impostor: PhysicsImpostor, positionIterations: number): void;
  107951. appendAnchor?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107952. appendHook?(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): void;
  107953. sleepBody(impostor: PhysicsImpostor): void;
  107954. wakeUpBody(impostor: PhysicsImpostor): void;
  107955. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  107956. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  107957. setMotor(joint: IMotorEnabledJoint, speed: number, maxForce?: number, motorIndex?: number): void;
  107958. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  107959. getRadius(impostor: PhysicsImpostor): number;
  107960. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  107961. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  107962. dispose(): void;
  107963. }
  107964. /**
  107965. * Interface used to define a physics engine
  107966. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  107967. */
  107968. export interface IPhysicsEngine {
  107969. /**
  107970. * Gets the gravity vector used by the simulation
  107971. */
  107972. gravity: Vector3;
  107973. /**
  107974. * Sets the gravity vector used by the simulation
  107975. * @param gravity defines the gravity vector to use
  107976. */
  107977. setGravity(gravity: Vector3): void;
  107978. /**
  107979. * Set the time step of the physics engine.
  107980. * Default is 1/60.
  107981. * To slow it down, enter 1/600 for example.
  107982. * To speed it up, 1/30
  107983. * @param newTimeStep the new timestep to apply to this world.
  107984. */
  107985. setTimeStep(newTimeStep: number): void;
  107986. /**
  107987. * Get the time step of the physics engine.
  107988. * @returns the current time step
  107989. */
  107990. getTimeStep(): number;
  107991. /**
  107992. * Set the sub time step of the physics engine.
  107993. * Default is 0 meaning there is no sub steps
  107994. * To increase physics resolution precision, set a small value (like 1 ms)
  107995. * @param subTimeStep defines the new sub timestep used for physics resolution.
  107996. */
  107997. setSubTimeStep(subTimeStep: number): void;
  107998. /**
  107999. * Get the sub time step of the physics engine.
  108000. * @returns the current sub time step
  108001. */
  108002. getSubTimeStep(): number;
  108003. /**
  108004. * Release all resources
  108005. */
  108006. dispose(): void;
  108007. /**
  108008. * Gets the name of the current physics plugin
  108009. * @returns the name of the plugin
  108010. */
  108011. getPhysicsPluginName(): string;
  108012. /**
  108013. * Adding a new impostor for the impostor tracking.
  108014. * This will be done by the impostor itself.
  108015. * @param impostor the impostor to add
  108016. */
  108017. addImpostor(impostor: PhysicsImpostor): void;
  108018. /**
  108019. * Remove an impostor from the engine.
  108020. * This impostor and its mesh will not longer be updated by the physics engine.
  108021. * @param impostor the impostor to remove
  108022. */
  108023. removeImpostor(impostor: PhysicsImpostor): void;
  108024. /**
  108025. * Add a joint to the physics engine
  108026. * @param mainImpostor defines the main impostor to which the joint is added.
  108027. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  108028. * @param joint defines the joint that will connect both impostors.
  108029. */
  108030. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108031. /**
  108032. * Removes a joint from the simulation
  108033. * @param mainImpostor defines the impostor used with the joint
  108034. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  108035. * @param joint defines the joint to remove
  108036. */
  108037. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  108038. /**
  108039. * Gets the current plugin used to run the simulation
  108040. * @returns current plugin
  108041. */
  108042. getPhysicsPlugin(): IPhysicsEnginePlugin;
  108043. /**
  108044. * Gets the list of physic impostors
  108045. * @returns an array of PhysicsImpostor
  108046. */
  108047. getImpostors(): Array<PhysicsImpostor>;
  108048. /**
  108049. * Gets the impostor for a physics enabled object
  108050. * @param object defines the object impersonated by the impostor
  108051. * @returns the PhysicsImpostor or null if not found
  108052. */
  108053. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108054. /**
  108055. * Gets the impostor for a physics body object
  108056. * @param body defines physics body used by the impostor
  108057. * @returns the PhysicsImpostor or null if not found
  108058. */
  108059. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  108060. /**
  108061. * Does a raycast in the physics world
  108062. * @param from when should the ray start?
  108063. * @param to when should the ray end?
  108064. * @returns PhysicsRaycastResult
  108065. */
  108066. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  108067. /**
  108068. * Called by the scene. No need to call it.
  108069. * @param delta defines the timespam between frames
  108070. */
  108071. _step(delta: number): void;
  108072. }
  108073. }
  108074. declare module BABYLON {
  108075. /**
  108076. * The interface for the physics imposter parameters
  108077. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108078. */
  108079. export interface PhysicsImpostorParameters {
  108080. /**
  108081. * The mass of the physics imposter
  108082. */
  108083. mass: number;
  108084. /**
  108085. * The friction of the physics imposter
  108086. */
  108087. friction?: number;
  108088. /**
  108089. * The coefficient of restitution of the physics imposter
  108090. */
  108091. restitution?: number;
  108092. /**
  108093. * The native options of the physics imposter
  108094. */
  108095. nativeOptions?: any;
  108096. /**
  108097. * Specifies if the parent should be ignored
  108098. */
  108099. ignoreParent?: boolean;
  108100. /**
  108101. * Specifies if bi-directional transformations should be disabled
  108102. */
  108103. disableBidirectionalTransformation?: boolean;
  108104. /**
  108105. * The pressure inside the physics imposter, soft object only
  108106. */
  108107. pressure?: number;
  108108. /**
  108109. * The stiffness the physics imposter, soft object only
  108110. */
  108111. stiffness?: number;
  108112. /**
  108113. * The number of iterations used in maintaining consistent vertex velocities, soft object only
  108114. */
  108115. velocityIterations?: number;
  108116. /**
  108117. * The number of iterations used in maintaining consistent vertex positions, soft object only
  108118. */
  108119. positionIterations?: number;
  108120. /**
  108121. * The number used to fix points on a cloth (0, 1, 2, 4, 8) or rope (0, 1, 2) only
  108122. * 0 None, 1, back left or top, 2, back right or bottom, 4, front left, 8, front right
  108123. * Add to fix multiple points
  108124. */
  108125. fixedPoints?: number;
  108126. /**
  108127. * The collision margin around a soft object
  108128. */
  108129. margin?: number;
  108130. /**
  108131. * The collision margin around a soft object
  108132. */
  108133. damping?: number;
  108134. /**
  108135. * The path for a rope based on an extrusion
  108136. */
  108137. path?: any;
  108138. /**
  108139. * The shape of an extrusion used for a rope based on an extrusion
  108140. */
  108141. shape?: any;
  108142. }
  108143. /**
  108144. * Interface for a physics-enabled object
  108145. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108146. */
  108147. export interface IPhysicsEnabledObject {
  108148. /**
  108149. * The position of the physics-enabled object
  108150. */
  108151. position: Vector3;
  108152. /**
  108153. * The rotation of the physics-enabled object
  108154. */
  108155. rotationQuaternion: Nullable<Quaternion>;
  108156. /**
  108157. * The scale of the physics-enabled object
  108158. */
  108159. scaling: Vector3;
  108160. /**
  108161. * The rotation of the physics-enabled object
  108162. */
  108163. rotation?: Vector3;
  108164. /**
  108165. * The parent of the physics-enabled object
  108166. */
  108167. parent?: any;
  108168. /**
  108169. * The bounding info of the physics-enabled object
  108170. * @returns The bounding info of the physics-enabled object
  108171. */
  108172. getBoundingInfo(): BoundingInfo;
  108173. /**
  108174. * Computes the world matrix
  108175. * @param force Specifies if the world matrix should be computed by force
  108176. * @returns A world matrix
  108177. */
  108178. computeWorldMatrix(force: boolean): Matrix;
  108179. /**
  108180. * Gets the world matrix
  108181. * @returns A world matrix
  108182. */
  108183. getWorldMatrix?(): Matrix;
  108184. /**
  108185. * Gets the child meshes
  108186. * @param directDescendantsOnly Specifies if only direct-descendants should be obtained
  108187. * @returns An array of abstract meshes
  108188. */
  108189. getChildMeshes?(directDescendantsOnly?: boolean): Array<AbstractMesh>;
  108190. /**
  108191. * Gets the vertex data
  108192. * @param kind The type of vertex data
  108193. * @returns A nullable array of numbers, or a float32 array
  108194. */
  108195. getVerticesData(kind: string): Nullable<Array<number> | Float32Array>;
  108196. /**
  108197. * Gets the indices from the mesh
  108198. * @returns A nullable array of index arrays
  108199. */
  108200. getIndices?(): Nullable<IndicesArray>;
  108201. /**
  108202. * Gets the scene from the mesh
  108203. * @returns the indices array or null
  108204. */
  108205. getScene?(): Scene;
  108206. /**
  108207. * Gets the absolute position from the mesh
  108208. * @returns the absolute position
  108209. */
  108210. getAbsolutePosition(): Vector3;
  108211. /**
  108212. * Gets the absolute pivot point from the mesh
  108213. * @returns the absolute pivot point
  108214. */
  108215. getAbsolutePivotPoint(): Vector3;
  108216. /**
  108217. * Rotates the mesh
  108218. * @param axis The axis of rotation
  108219. * @param amount The amount of rotation
  108220. * @param space The space of the rotation
  108221. * @returns The rotation transform node
  108222. */
  108223. rotate(axis: Vector3, amount: number, space?: Space): TransformNode;
  108224. /**
  108225. * Translates the mesh
  108226. * @param axis The axis of translation
  108227. * @param distance The distance of translation
  108228. * @param space The space of the translation
  108229. * @returns The transform node
  108230. */
  108231. translate(axis: Vector3, distance: number, space?: Space): TransformNode;
  108232. /**
  108233. * Sets the absolute position of the mesh
  108234. * @param absolutePosition The absolute position of the mesh
  108235. * @returns The transform node
  108236. */
  108237. setAbsolutePosition(absolutePosition: Vector3): TransformNode;
  108238. /**
  108239. * Gets the class name of the mesh
  108240. * @returns The class name
  108241. */
  108242. getClassName(): string;
  108243. }
  108244. /**
  108245. * Represents a physics imposter
  108246. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  108247. */
  108248. export class PhysicsImpostor {
  108249. /**
  108250. * The physics-enabled object used as the physics imposter
  108251. */
  108252. object: IPhysicsEnabledObject;
  108253. /**
  108254. * The type of the physics imposter
  108255. */
  108256. type: number;
  108257. private _options;
  108258. private _scene?;
  108259. /**
  108260. * The default object size of the imposter
  108261. */
  108262. static DEFAULT_OBJECT_SIZE: Vector3;
  108263. /**
  108264. * The identity quaternion of the imposter
  108265. */
  108266. static IDENTITY_QUATERNION: Quaternion;
  108267. /** @hidden */
  108268. _pluginData: any;
  108269. private _physicsEngine;
  108270. private _physicsBody;
  108271. private _bodyUpdateRequired;
  108272. private _onBeforePhysicsStepCallbacks;
  108273. private _onAfterPhysicsStepCallbacks;
  108274. /** @hidden */
  108275. _onPhysicsCollideCallbacks: Array<{
  108276. callback: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void;
  108277. otherImpostors: Array<PhysicsImpostor>;
  108278. }>;
  108279. private _deltaPosition;
  108280. private _deltaRotation;
  108281. private _deltaRotationConjugated;
  108282. /** @hidden */
  108283. _isFromLine: boolean;
  108284. private _parent;
  108285. private _isDisposed;
  108286. private static _tmpVecs;
  108287. private static _tmpQuat;
  108288. /**
  108289. * Specifies if the physics imposter is disposed
  108290. */
  108291. get isDisposed(): boolean;
  108292. /**
  108293. * Gets the mass of the physics imposter
  108294. */
  108295. get mass(): number;
  108296. set mass(value: number);
  108297. /**
  108298. * Gets the coefficient of friction
  108299. */
  108300. get friction(): number;
  108301. /**
  108302. * Sets the coefficient of friction
  108303. */
  108304. set friction(value: number);
  108305. /**
  108306. * Gets the coefficient of restitution
  108307. */
  108308. get restitution(): number;
  108309. /**
  108310. * Sets the coefficient of restitution
  108311. */
  108312. set restitution(value: number);
  108313. /**
  108314. * Gets the pressure of a soft body; only supported by the AmmoJSPlugin
  108315. */
  108316. get pressure(): number;
  108317. /**
  108318. * Sets the pressure of a soft body; only supported by the AmmoJSPlugin
  108319. */
  108320. set pressure(value: number);
  108321. /**
  108322. * Gets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108323. */
  108324. get stiffness(): number;
  108325. /**
  108326. * Sets the stiffness of a soft body; only supported by the AmmoJSPlugin
  108327. */
  108328. set stiffness(value: number);
  108329. /**
  108330. * Gets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108331. */
  108332. get velocityIterations(): number;
  108333. /**
  108334. * Sets the velocityIterations of a soft body; only supported by the AmmoJSPlugin
  108335. */
  108336. set velocityIterations(value: number);
  108337. /**
  108338. * Gets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108339. */
  108340. get positionIterations(): number;
  108341. /**
  108342. * Sets the positionIterations of a soft body; only supported by the AmmoJSPlugin
  108343. */
  108344. set positionIterations(value: number);
  108345. /**
  108346. * The unique id of the physics imposter
  108347. * set by the physics engine when adding this impostor to the array
  108348. */
  108349. uniqueId: number;
  108350. /**
  108351. * @hidden
  108352. */
  108353. soft: boolean;
  108354. /**
  108355. * @hidden
  108356. */
  108357. segments: number;
  108358. private _joints;
  108359. /**
  108360. * Initializes the physics imposter
  108361. * @param object The physics-enabled object used as the physics imposter
  108362. * @param type The type of the physics imposter
  108363. * @param _options The options for the physics imposter
  108364. * @param _scene The Babylon scene
  108365. */
  108366. constructor(
  108367. /**
  108368. * The physics-enabled object used as the physics imposter
  108369. */
  108370. object: IPhysicsEnabledObject,
  108371. /**
  108372. * The type of the physics imposter
  108373. */
  108374. type: number, _options?: PhysicsImpostorParameters, _scene?: Scene | undefined);
  108375. /**
  108376. * This function will completly initialize this impostor.
  108377. * It will create a new body - but only if this mesh has no parent.
  108378. * If it has, this impostor will not be used other than to define the impostor
  108379. * of the child mesh.
  108380. * @hidden
  108381. */
  108382. _init(): void;
  108383. private _getPhysicsParent;
  108384. /**
  108385. * Should a new body be generated.
  108386. * @returns boolean specifying if body initialization is required
  108387. */
  108388. isBodyInitRequired(): boolean;
  108389. /**
  108390. * Sets the updated scaling
  108391. * @param updated Specifies if the scaling is updated
  108392. */
  108393. setScalingUpdated(): void;
  108394. /**
  108395. * Force a regeneration of this or the parent's impostor's body.
  108396. * Use under cautious - This will remove all joints already implemented.
  108397. */
  108398. forceUpdate(): void;
  108399. /**
  108400. * Gets the body that holds this impostor. Either its own, or its parent.
  108401. */
  108402. get physicsBody(): any;
  108403. /**
  108404. * Get the parent of the physics imposter
  108405. * @returns Physics imposter or null
  108406. */
  108407. get parent(): Nullable<PhysicsImpostor>;
  108408. /**
  108409. * Sets the parent of the physics imposter
  108410. */
  108411. set parent(value: Nullable<PhysicsImpostor>);
  108412. /**
  108413. * Set the physics body. Used mainly by the physics engine/plugin
  108414. */
  108415. set physicsBody(physicsBody: any);
  108416. /**
  108417. * Resets the update flags
  108418. */
  108419. resetUpdateFlags(): void;
  108420. /**
  108421. * Gets the object extend size
  108422. * @returns the object extend size
  108423. */
  108424. getObjectExtendSize(): Vector3;
  108425. /**
  108426. * Gets the object center
  108427. * @returns The object center
  108428. */
  108429. getObjectCenter(): Vector3;
  108430. /**
  108431. * Get a specific parameter from the options parameters
  108432. * @param paramName The object parameter name
  108433. * @returns The object parameter
  108434. */
  108435. getParam(paramName: string): any;
  108436. /**
  108437. * Sets a specific parameter in the options given to the physics plugin
  108438. * @param paramName The parameter name
  108439. * @param value The value of the parameter
  108440. */
  108441. setParam(paramName: string, value: number): void;
  108442. /**
  108443. * Specifically change the body's mass option. Won't recreate the physics body object
  108444. * @param mass The mass of the physics imposter
  108445. */
  108446. setMass(mass: number): void;
  108447. /**
  108448. * Gets the linear velocity
  108449. * @returns linear velocity or null
  108450. */
  108451. getLinearVelocity(): Nullable<Vector3>;
  108452. /**
  108453. * Sets the linear velocity
  108454. * @param velocity linear velocity or null
  108455. */
  108456. setLinearVelocity(velocity: Nullable<Vector3>): void;
  108457. /**
  108458. * Gets the angular velocity
  108459. * @returns angular velocity or null
  108460. */
  108461. getAngularVelocity(): Nullable<Vector3>;
  108462. /**
  108463. * Sets the angular velocity
  108464. * @param velocity The velocity or null
  108465. */
  108466. setAngularVelocity(velocity: Nullable<Vector3>): void;
  108467. /**
  108468. * Execute a function with the physics plugin native code
  108469. * Provide a function the will have two variables - the world object and the physics body object
  108470. * @param func The function to execute with the physics plugin native code
  108471. */
  108472. executeNativeFunction(func: (world: any, physicsBody: any) => void): void;
  108473. /**
  108474. * Register a function that will be executed before the physics world is stepping forward
  108475. * @param func The function to execute before the physics world is stepped forward
  108476. */
  108477. registerBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108478. /**
  108479. * Unregister a function that will be executed before the physics world is stepping forward
  108480. * @param func The function to execute before the physics world is stepped forward
  108481. */
  108482. unregisterBeforePhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108483. /**
  108484. * Register a function that will be executed after the physics step
  108485. * @param func The function to execute after physics step
  108486. */
  108487. registerAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108488. /**
  108489. * Unregisters a function that will be executed after the physics step
  108490. * @param func The function to execute after physics step
  108491. */
  108492. unregisterAfterPhysicsStep(func: (impostor: PhysicsImpostor) => void): void;
  108493. /**
  108494. * register a function that will be executed when this impostor collides against a different body
  108495. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  108496. * @param func Callback that is executed on collision
  108497. */
  108498. registerOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor) => void): void;
  108499. /**
  108500. * Unregisters the physics imposter on contact
  108501. * @param collideAgainst The physics object to collide against
  108502. * @param func Callback to execute on collision
  108503. */
  108504. unregisterOnPhysicsCollide(collideAgainst: PhysicsImpostor | Array<PhysicsImpostor>, func: (collider: PhysicsImpostor, collidedAgainst: PhysicsImpostor | Array<PhysicsImpostor>) => void): void;
  108505. private _tmpQuat;
  108506. private _tmpQuat2;
  108507. /**
  108508. * Get the parent rotation
  108509. * @returns The parent rotation
  108510. */
  108511. getParentsRotation(): Quaternion;
  108512. /**
  108513. * this function is executed by the physics engine.
  108514. */
  108515. beforeStep: () => void;
  108516. /**
  108517. * this function is executed by the physics engine
  108518. */
  108519. afterStep: () => void;
  108520. /**
  108521. * Legacy collision detection event support
  108522. */
  108523. onCollideEvent: Nullable<(collider: PhysicsImpostor, collidedWith: PhysicsImpostor) => void>;
  108524. /**
  108525. * event and body object due to cannon's event-based architecture.
  108526. */
  108527. onCollide: (e: {
  108528. body: any;
  108529. }) => void;
  108530. /**
  108531. * Apply a force
  108532. * @param force The force to apply
  108533. * @param contactPoint The contact point for the force
  108534. * @returns The physics imposter
  108535. */
  108536. applyForce(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108537. /**
  108538. * Apply an impulse
  108539. * @param force The impulse force
  108540. * @param contactPoint The contact point for the impulse force
  108541. * @returns The physics imposter
  108542. */
  108543. applyImpulse(force: Vector3, contactPoint: Vector3): PhysicsImpostor;
  108544. /**
  108545. * A help function to create a joint
  108546. * @param otherImpostor A physics imposter used to create a joint
  108547. * @param jointType The type of joint
  108548. * @param jointData The data for the joint
  108549. * @returns The physics imposter
  108550. */
  108551. createJoint(otherImpostor: PhysicsImpostor, jointType: number, jointData: PhysicsJointData): PhysicsImpostor;
  108552. /**
  108553. * Add a joint to this impostor with a different impostor
  108554. * @param otherImpostor A physics imposter used to add a joint
  108555. * @param joint The joint to add
  108556. * @returns The physics imposter
  108557. */
  108558. addJoint(otherImpostor: PhysicsImpostor, joint: PhysicsJoint): PhysicsImpostor;
  108559. /**
  108560. * Add an anchor to a cloth impostor
  108561. * @param otherImpostor rigid impostor to anchor to
  108562. * @param width ratio across width from 0 to 1
  108563. * @param height ratio up height from 0 to 1
  108564. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  108565. * @param noCollisionBetweenLinkedBodies when true collisions between cloth impostor and anchor are ignored; default false
  108566. * @returns impostor the soft imposter
  108567. */
  108568. addAnchor(otherImpostor: PhysicsImpostor, width: number, height: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108569. /**
  108570. * Add a hook to a rope impostor
  108571. * @param otherImpostor rigid impostor to anchor to
  108572. * @param length ratio across rope from 0 to 1
  108573. * @param influence the elasticity between rope impostor and anchor from 0, very stretchy to 1, little strech
  108574. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  108575. * @returns impostor the rope imposter
  108576. */
  108577. addHook(otherImpostor: PhysicsImpostor, length: number, influence: number, noCollisionBetweenLinkedBodies: boolean): PhysicsImpostor;
  108578. /**
  108579. * Will keep this body still, in a sleep mode.
  108580. * @returns the physics imposter
  108581. */
  108582. sleep(): PhysicsImpostor;
  108583. /**
  108584. * Wake the body up.
  108585. * @returns The physics imposter
  108586. */
  108587. wakeUp(): PhysicsImpostor;
  108588. /**
  108589. * Clones the physics imposter
  108590. * @param newObject The physics imposter clones to this physics-enabled object
  108591. * @returns A nullable physics imposter
  108592. */
  108593. clone(newObject: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  108594. /**
  108595. * Disposes the physics imposter
  108596. */
  108597. dispose(): void;
  108598. /**
  108599. * Sets the delta position
  108600. * @param position The delta position amount
  108601. */
  108602. setDeltaPosition(position: Vector3): void;
  108603. /**
  108604. * Sets the delta rotation
  108605. * @param rotation The delta rotation amount
  108606. */
  108607. setDeltaRotation(rotation: Quaternion): void;
  108608. /**
  108609. * Gets the box size of the physics imposter and stores the result in the input parameter
  108610. * @param result Stores the box size
  108611. * @returns The physics imposter
  108612. */
  108613. getBoxSizeToRef(result: Vector3): PhysicsImpostor;
  108614. /**
  108615. * Gets the radius of the physics imposter
  108616. * @returns Radius of the physics imposter
  108617. */
  108618. getRadius(): number;
  108619. /**
  108620. * Sync a bone with this impostor
  108621. * @param bone The bone to sync to the impostor.
  108622. * @param boneMesh The mesh that the bone is influencing.
  108623. * @param jointPivot The pivot of the joint / bone in local space.
  108624. * @param distToJoint Optional distance from the impostor to the joint.
  108625. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108626. */
  108627. syncBoneWithImpostor(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion): void;
  108628. /**
  108629. * Sync impostor to a bone
  108630. * @param bone The bone that the impostor will be synced to.
  108631. * @param boneMesh The mesh that the bone is influencing.
  108632. * @param jointPivot The pivot of the joint / bone in local space.
  108633. * @param distToJoint Optional distance from the impostor to the joint.
  108634. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  108635. * @param boneAxis Optional vector3 axis the bone is aligned with
  108636. */
  108637. syncImpostorWithBone(bone: Bone, boneMesh: AbstractMesh, jointPivot: Vector3, distToJoint?: number, adjustRotation?: Quaternion, boneAxis?: Vector3): void;
  108638. /**
  108639. * No-Imposter type
  108640. */
  108641. static NoImpostor: number;
  108642. /**
  108643. * Sphere-Imposter type
  108644. */
  108645. static SphereImpostor: number;
  108646. /**
  108647. * Box-Imposter type
  108648. */
  108649. static BoxImpostor: number;
  108650. /**
  108651. * Plane-Imposter type
  108652. */
  108653. static PlaneImpostor: number;
  108654. /**
  108655. * Mesh-imposter type
  108656. */
  108657. static MeshImpostor: number;
  108658. /**
  108659. * Capsule-Impostor type (Ammo.js plugin only)
  108660. */
  108661. static CapsuleImpostor: number;
  108662. /**
  108663. * Cylinder-Imposter type
  108664. */
  108665. static CylinderImpostor: number;
  108666. /**
  108667. * Particle-Imposter type
  108668. */
  108669. static ParticleImpostor: number;
  108670. /**
  108671. * Heightmap-Imposter type
  108672. */
  108673. static HeightmapImpostor: number;
  108674. /**
  108675. * ConvexHull-Impostor type (Ammo.js plugin only)
  108676. */
  108677. static ConvexHullImpostor: number;
  108678. /**
  108679. * Custom-Imposter type (Ammo.js plugin only)
  108680. */
  108681. static CustomImpostor: number;
  108682. /**
  108683. * Rope-Imposter type
  108684. */
  108685. static RopeImpostor: number;
  108686. /**
  108687. * Cloth-Imposter type
  108688. */
  108689. static ClothImpostor: number;
  108690. /**
  108691. * Softbody-Imposter type
  108692. */
  108693. static SoftbodyImpostor: number;
  108694. }
  108695. }
  108696. declare module BABYLON {
  108697. /**
  108698. * @hidden
  108699. **/
  108700. export class _CreationDataStorage {
  108701. closePath?: boolean;
  108702. closeArray?: boolean;
  108703. idx: number[];
  108704. dashSize: number;
  108705. gapSize: number;
  108706. path3D: Path3D;
  108707. pathArray: Vector3[][];
  108708. arc: number;
  108709. radius: number;
  108710. cap: number;
  108711. tessellation: number;
  108712. }
  108713. /**
  108714. * @hidden
  108715. **/
  108716. class _InstanceDataStorage {
  108717. visibleInstances: any;
  108718. batchCache: _InstancesBatch;
  108719. instancesBufferSize: number;
  108720. instancesBuffer: Nullable<Buffer>;
  108721. instancesData: Float32Array;
  108722. overridenInstanceCount: number;
  108723. isFrozen: boolean;
  108724. previousBatch: Nullable<_InstancesBatch>;
  108725. hardwareInstancedRendering: boolean;
  108726. sideOrientation: number;
  108727. manualUpdate: boolean;
  108728. previousRenderId: number;
  108729. }
  108730. /**
  108731. * @hidden
  108732. **/
  108733. export class _InstancesBatch {
  108734. mustReturn: boolean;
  108735. visibleInstances: Nullable<InstancedMesh[]>[];
  108736. renderSelf: boolean[];
  108737. hardwareInstancedRendering: boolean[];
  108738. }
  108739. /**
  108740. * @hidden
  108741. **/
  108742. class _ThinInstanceDataStorage {
  108743. instancesCount: number;
  108744. matrixBuffer: Nullable<Buffer>;
  108745. matrixBufferSize: number;
  108746. matrixData: Nullable<Float32Array>;
  108747. boundingVectors: Array<Vector3>;
  108748. worldMatrices: Nullable<Matrix[]>;
  108749. }
  108750. /**
  108751. * Class used to represent renderable models
  108752. */
  108753. export class Mesh extends AbstractMesh implements IGetSetVerticesData {
  108754. /**
  108755. * Mesh side orientation : usually the external or front surface
  108756. */
  108757. static readonly FRONTSIDE: number;
  108758. /**
  108759. * Mesh side orientation : usually the internal or back surface
  108760. */
  108761. static readonly BACKSIDE: number;
  108762. /**
  108763. * Mesh side orientation : both internal and external or front and back surfaces
  108764. */
  108765. static readonly DOUBLESIDE: number;
  108766. /**
  108767. * Mesh side orientation : by default, `FRONTSIDE`
  108768. */
  108769. static readonly DEFAULTSIDE: number;
  108770. /**
  108771. * Mesh cap setting : no cap
  108772. */
  108773. static readonly NO_CAP: number;
  108774. /**
  108775. * Mesh cap setting : one cap at the beginning of the mesh
  108776. */
  108777. static readonly CAP_START: number;
  108778. /**
  108779. * Mesh cap setting : one cap at the end of the mesh
  108780. */
  108781. static readonly CAP_END: number;
  108782. /**
  108783. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  108784. */
  108785. static readonly CAP_ALL: number;
  108786. /**
  108787. * Mesh pattern setting : no flip or rotate
  108788. */
  108789. static readonly NO_FLIP: number;
  108790. /**
  108791. * Mesh pattern setting : flip (reflect in y axis) alternate tiles on each row or column
  108792. */
  108793. static readonly FLIP_TILE: number;
  108794. /**
  108795. * Mesh pattern setting : rotate (180degs) alternate tiles on each row or column
  108796. */
  108797. static readonly ROTATE_TILE: number;
  108798. /**
  108799. * Mesh pattern setting : flip (reflect in y axis) all tiles on alternate rows
  108800. */
  108801. static readonly FLIP_ROW: number;
  108802. /**
  108803. * Mesh pattern setting : rotate (180degs) all tiles on alternate rows
  108804. */
  108805. static readonly ROTATE_ROW: number;
  108806. /**
  108807. * Mesh pattern setting : flip and rotate alternate tiles on each row or column
  108808. */
  108809. static readonly FLIP_N_ROTATE_TILE: number;
  108810. /**
  108811. * Mesh pattern setting : rotate pattern and rotate
  108812. */
  108813. static readonly FLIP_N_ROTATE_ROW: number;
  108814. /**
  108815. * Mesh tile positioning : part tiles same on left/right or top/bottom
  108816. */
  108817. static readonly CENTER: number;
  108818. /**
  108819. * Mesh tile positioning : part tiles on left
  108820. */
  108821. static readonly LEFT: number;
  108822. /**
  108823. * Mesh tile positioning : part tiles on right
  108824. */
  108825. static readonly RIGHT: number;
  108826. /**
  108827. * Mesh tile positioning : part tiles on top
  108828. */
  108829. static readonly TOP: number;
  108830. /**
  108831. * Mesh tile positioning : part tiles on bottom
  108832. */
  108833. static readonly BOTTOM: number;
  108834. /**
  108835. * Gets the default side orientation.
  108836. * @param orientation the orientation to value to attempt to get
  108837. * @returns the default orientation
  108838. * @hidden
  108839. */
  108840. static _GetDefaultSideOrientation(orientation?: number): number;
  108841. private _internalMeshDataInfo;
  108842. get computeBonesUsingShaders(): boolean;
  108843. set computeBonesUsingShaders(value: boolean);
  108844. /**
  108845. * An event triggered before rendering the mesh
  108846. */
  108847. get onBeforeRenderObservable(): Observable<Mesh>;
  108848. /**
  108849. * An event triggered before binding the mesh
  108850. */
  108851. get onBeforeBindObservable(): Observable<Mesh>;
  108852. /**
  108853. * An event triggered after rendering the mesh
  108854. */
  108855. get onAfterRenderObservable(): Observable<Mesh>;
  108856. /**
  108857. * An event triggered before drawing the mesh
  108858. */
  108859. get onBeforeDrawObservable(): Observable<Mesh>;
  108860. private _onBeforeDrawObserver;
  108861. /**
  108862. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  108863. */
  108864. set onBeforeDraw(callback: () => void);
  108865. get hasInstances(): boolean;
  108866. get hasThinInstances(): boolean;
  108867. /**
  108868. * Gets the delay loading state of the mesh (when delay loading is turned on)
  108869. * @see https://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  108870. */
  108871. delayLoadState: number;
  108872. /**
  108873. * Gets the list of instances created from this mesh
  108874. * it is not supposed to be modified manually.
  108875. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  108876. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  108877. */
  108878. instances: InstancedMesh[];
  108879. /**
  108880. * Gets the file containing delay loading data for this mesh
  108881. */
  108882. delayLoadingFile: string;
  108883. /** @hidden */
  108884. _binaryInfo: any;
  108885. /**
  108886. * User defined function used to change how LOD level selection is done
  108887. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108888. */
  108889. onLODLevelSelection: (distance: number, mesh: Mesh, selectedLevel: Nullable<Mesh>) => void;
  108890. /**
  108891. * Gets or sets the morph target manager
  108892. * @see https://doc.babylonjs.com/how_to/how_to_use_morphtargets
  108893. */
  108894. get morphTargetManager(): Nullable<MorphTargetManager>;
  108895. set morphTargetManager(value: Nullable<MorphTargetManager>);
  108896. /** @hidden */
  108897. _creationDataStorage: Nullable<_CreationDataStorage>;
  108898. /** @hidden */
  108899. _geometry: Nullable<Geometry>;
  108900. /** @hidden */
  108901. _delayInfo: Array<string>;
  108902. /** @hidden */
  108903. _delayLoadingFunction: (any: any, mesh: Mesh) => void;
  108904. /** @hidden */
  108905. _instanceDataStorage: _InstanceDataStorage;
  108906. /** @hidden */
  108907. _thinInstanceDataStorage: _ThinInstanceDataStorage;
  108908. private _effectiveMaterial;
  108909. /** @hidden */
  108910. _shouldGenerateFlatShading: boolean;
  108911. /** @hidden */
  108912. _originalBuilderSideOrientation: number;
  108913. /**
  108914. * Use this property to change the original side orientation defined at construction time
  108915. */
  108916. overrideMaterialSideOrientation: Nullable<number>;
  108917. /**
  108918. * Gets the source mesh (the one used to clone this one from)
  108919. */
  108920. get source(): Nullable<Mesh>;
  108921. /**
  108922. * Gets the list of clones of this mesh
  108923. * The scene must have been constructed with useClonedMeshMap=true for this to work!
  108924. * Note that useClonedMeshMap=true is the default setting
  108925. */
  108926. get cloneMeshMap(): Nullable<{
  108927. [id: string]: Mesh | undefined;
  108928. }>;
  108929. /**
  108930. * Gets or sets a boolean indicating that this mesh does not use index buffer
  108931. */
  108932. get isUnIndexed(): boolean;
  108933. set isUnIndexed(value: boolean);
  108934. /** Gets the array buffer used to store the instanced buffer used for instances' world matrices */
  108935. get worldMatrixInstancedBuffer(): Float32Array;
  108936. /** Gets or sets a boolean indicating that the update of the instance buffer of the world matrices is manual */
  108937. get manualUpdateOfWorldMatrixInstancedBuffer(): boolean;
  108938. set manualUpdateOfWorldMatrixInstancedBuffer(value: boolean);
  108939. /**
  108940. * @constructor
  108941. * @param name The value used by scene.getMeshByName() to do a lookup.
  108942. * @param scene The scene to add this mesh to.
  108943. * @param parent The parent of this mesh, if it has one
  108944. * @param source An optional Mesh from which geometry is shared, cloned.
  108945. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  108946. * When false, achieved by calling a clone(), also passing False.
  108947. * This will make creation of children, recursive.
  108948. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  108949. */
  108950. constructor(name: string, scene?: Nullable<Scene>, parent?: Nullable<Node>, source?: Nullable<Mesh>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean);
  108951. instantiateHierarchy(newParent?: Nullable<TransformNode>, options?: {
  108952. doNotInstantiate: boolean;
  108953. }, onNewNodeCreated?: (source: TransformNode, clone: TransformNode) => void): Nullable<TransformNode>;
  108954. /**
  108955. * Gets the class name
  108956. * @returns the string "Mesh".
  108957. */
  108958. getClassName(): string;
  108959. /** @hidden */
  108960. get _isMesh(): boolean;
  108961. /**
  108962. * Returns a description of this mesh
  108963. * @param fullDetails define if full details about this mesh must be used
  108964. * @returns a descriptive string representing this mesh
  108965. */
  108966. toString(fullDetails?: boolean): string;
  108967. /** @hidden */
  108968. _unBindEffect(): void;
  108969. /**
  108970. * Gets a boolean indicating if this mesh has LOD
  108971. */
  108972. get hasLODLevels(): boolean;
  108973. /**
  108974. * Gets the list of MeshLODLevel associated with the current mesh
  108975. * @returns an array of MeshLODLevel
  108976. */
  108977. getLODLevels(): MeshLODLevel[];
  108978. private _sortLODLevels;
  108979. /**
  108980. * Add a mesh as LOD level triggered at the given distance.
  108981. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108982. * @param distance The distance from the center of the object to show this level
  108983. * @param mesh The mesh to be added as LOD level (can be null)
  108984. * @return This mesh (for chaining)
  108985. */
  108986. addLODLevel(distance: number, mesh: Nullable<Mesh>): Mesh;
  108987. /**
  108988. * Returns the LOD level mesh at the passed distance or null if not found.
  108989. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108990. * @param distance The distance from the center of the object to show this level
  108991. * @returns a Mesh or `null`
  108992. */
  108993. getLODLevelAtDistance(distance: number): Nullable<Mesh>;
  108994. /**
  108995. * Remove a mesh from the LOD array
  108996. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  108997. * @param mesh defines the mesh to be removed
  108998. * @return This mesh (for chaining)
  108999. */
  109000. removeLODLevel(mesh: Mesh): Mesh;
  109001. /**
  109002. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  109003. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  109004. * @param camera defines the camera to use to compute distance
  109005. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  109006. * @return This mesh (for chaining)
  109007. */
  109008. getLOD(camera: Camera, boundingSphere?: BoundingSphere): Nullable<AbstractMesh>;
  109009. /**
  109010. * Gets the mesh internal Geometry object
  109011. */
  109012. get geometry(): Nullable<Geometry>;
  109013. /**
  109014. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  109015. * @returns the total number of vertices
  109016. */
  109017. getTotalVertices(): number;
  109018. /**
  109019. * Returns the content of an associated vertex buffer
  109020. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109021. * - VertexBuffer.PositionKind
  109022. * - VertexBuffer.UVKind
  109023. * - VertexBuffer.UV2Kind
  109024. * - VertexBuffer.UV3Kind
  109025. * - VertexBuffer.UV4Kind
  109026. * - VertexBuffer.UV5Kind
  109027. * - VertexBuffer.UV6Kind
  109028. * - VertexBuffer.ColorKind
  109029. * - VertexBuffer.MatricesIndicesKind
  109030. * - VertexBuffer.MatricesIndicesExtraKind
  109031. * - VertexBuffer.MatricesWeightsKind
  109032. * - VertexBuffer.MatricesWeightsExtraKind
  109033. * @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
  109034. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  109035. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  109036. */
  109037. getVerticesData(kind: string, copyWhenShared?: boolean, forceCopy?: boolean): Nullable<FloatArray>;
  109038. /**
  109039. * Returns the mesh VertexBuffer object from the requested `kind`
  109040. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109041. * - VertexBuffer.PositionKind
  109042. * - VertexBuffer.NormalKind
  109043. * - VertexBuffer.UVKind
  109044. * - VertexBuffer.UV2Kind
  109045. * - VertexBuffer.UV3Kind
  109046. * - VertexBuffer.UV4Kind
  109047. * - VertexBuffer.UV5Kind
  109048. * - VertexBuffer.UV6Kind
  109049. * - VertexBuffer.ColorKind
  109050. * - VertexBuffer.MatricesIndicesKind
  109051. * - VertexBuffer.MatricesIndicesExtraKind
  109052. * - VertexBuffer.MatricesWeightsKind
  109053. * - VertexBuffer.MatricesWeightsExtraKind
  109054. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  109055. */
  109056. getVertexBuffer(kind: string): Nullable<VertexBuffer>;
  109057. /**
  109058. * Tests if a specific vertex buffer is associated with this mesh
  109059. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  109060. * - VertexBuffer.PositionKind
  109061. * - VertexBuffer.NormalKind
  109062. * - VertexBuffer.UVKind
  109063. * - VertexBuffer.UV2Kind
  109064. * - VertexBuffer.UV3Kind
  109065. * - VertexBuffer.UV4Kind
  109066. * - VertexBuffer.UV5Kind
  109067. * - VertexBuffer.UV6Kind
  109068. * - VertexBuffer.ColorKind
  109069. * - VertexBuffer.MatricesIndicesKind
  109070. * - VertexBuffer.MatricesIndicesExtraKind
  109071. * - VertexBuffer.MatricesWeightsKind
  109072. * - VertexBuffer.MatricesWeightsExtraKind
  109073. * @returns a boolean
  109074. */
  109075. isVerticesDataPresent(kind: string): boolean;
  109076. /**
  109077. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  109078. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  109079. * - VertexBuffer.PositionKind
  109080. * - VertexBuffer.UVKind
  109081. * - VertexBuffer.UV2Kind
  109082. * - VertexBuffer.UV3Kind
  109083. * - VertexBuffer.UV4Kind
  109084. * - VertexBuffer.UV5Kind
  109085. * - VertexBuffer.UV6Kind
  109086. * - VertexBuffer.ColorKind
  109087. * - VertexBuffer.MatricesIndicesKind
  109088. * - VertexBuffer.MatricesIndicesExtraKind
  109089. * - VertexBuffer.MatricesWeightsKind
  109090. * - VertexBuffer.MatricesWeightsExtraKind
  109091. * @returns a boolean
  109092. */
  109093. isVertexBufferUpdatable(kind: string): boolean;
  109094. /**
  109095. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  109096. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  109097. * - VertexBuffer.PositionKind
  109098. * - VertexBuffer.NormalKind
  109099. * - VertexBuffer.UVKind
  109100. * - VertexBuffer.UV2Kind
  109101. * - VertexBuffer.UV3Kind
  109102. * - VertexBuffer.UV4Kind
  109103. * - VertexBuffer.UV5Kind
  109104. * - VertexBuffer.UV6Kind
  109105. * - VertexBuffer.ColorKind
  109106. * - VertexBuffer.MatricesIndicesKind
  109107. * - VertexBuffer.MatricesIndicesExtraKind
  109108. * - VertexBuffer.MatricesWeightsKind
  109109. * - VertexBuffer.MatricesWeightsExtraKind
  109110. * @returns an array of strings
  109111. */
  109112. getVerticesDataKinds(): string[];
  109113. /**
  109114. * Returns a positive integer : the total number of indices in this mesh geometry.
  109115. * @returns the numner of indices or zero if the mesh has no geometry.
  109116. */
  109117. getTotalIndices(): number;
  109118. /**
  109119. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  109120. * @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.
  109121. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  109122. * @returns the indices array or an empty array if the mesh has no geometry
  109123. */
  109124. getIndices(copyWhenShared?: boolean, forceCopy?: boolean): Nullable<IndicesArray>;
  109125. get isBlocked(): boolean;
  109126. /**
  109127. * Determine if the current mesh is ready to be rendered
  109128. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  109129. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  109130. * @returns true if all associated assets are ready (material, textures, shaders)
  109131. */
  109132. isReady(completeCheck?: boolean, forceInstanceSupport?: boolean): boolean;
  109133. /**
  109134. * 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.
  109135. */
  109136. get areNormalsFrozen(): boolean;
  109137. /**
  109138. * 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.
  109139. * @returns the current mesh
  109140. */
  109141. freezeNormals(): Mesh;
  109142. /**
  109143. * 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
  109144. * @returns the current mesh
  109145. */
  109146. unfreezeNormals(): Mesh;
  109147. /**
  109148. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  109149. */
  109150. set overridenInstanceCount(count: number);
  109151. /** @hidden */
  109152. _preActivate(): Mesh;
  109153. /** @hidden */
  109154. _preActivateForIntermediateRendering(renderId: number): Mesh;
  109155. /** @hidden */
  109156. _registerInstanceForRenderId(instance: InstancedMesh, renderId: number): Mesh;
  109157. protected _afterComputeWorldMatrix(): void;
  109158. /** @hidden */
  109159. _postActivate(): void;
  109160. /**
  109161. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  109162. * This means the mesh underlying bounding box and sphere are recomputed.
  109163. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  109164. * @returns the current mesh
  109165. */
  109166. refreshBoundingInfo(applySkeleton?: boolean): Mesh;
  109167. /** @hidden */
  109168. _createGlobalSubMesh(force: boolean): Nullable<SubMesh>;
  109169. /**
  109170. * This function will subdivide the mesh into multiple submeshes
  109171. * @param count defines the expected number of submeshes
  109172. */
  109173. subdivide(count: number): void;
  109174. /**
  109175. * Copy a FloatArray into a specific associated vertex buffer
  109176. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109177. * - VertexBuffer.PositionKind
  109178. * - VertexBuffer.UVKind
  109179. * - VertexBuffer.UV2Kind
  109180. * - VertexBuffer.UV3Kind
  109181. * - VertexBuffer.UV4Kind
  109182. * - VertexBuffer.UV5Kind
  109183. * - VertexBuffer.UV6Kind
  109184. * - VertexBuffer.ColorKind
  109185. * - VertexBuffer.MatricesIndicesKind
  109186. * - VertexBuffer.MatricesIndicesExtraKind
  109187. * - VertexBuffer.MatricesWeightsKind
  109188. * - VertexBuffer.MatricesWeightsExtraKind
  109189. * @param data defines the data source
  109190. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  109191. * @param stride defines the data stride size (can be null)
  109192. * @returns the current mesh
  109193. */
  109194. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  109195. /**
  109196. * Delete a vertex buffer associated with this mesh
  109197. * @param kind defines which buffer to delete (positions, indices, normals, etc). Possible `kind` values :
  109198. * - VertexBuffer.PositionKind
  109199. * - VertexBuffer.UVKind
  109200. * - VertexBuffer.UV2Kind
  109201. * - VertexBuffer.UV3Kind
  109202. * - VertexBuffer.UV4Kind
  109203. * - VertexBuffer.UV5Kind
  109204. * - VertexBuffer.UV6Kind
  109205. * - VertexBuffer.ColorKind
  109206. * - VertexBuffer.MatricesIndicesKind
  109207. * - VertexBuffer.MatricesIndicesExtraKind
  109208. * - VertexBuffer.MatricesWeightsKind
  109209. * - VertexBuffer.MatricesWeightsExtraKind
  109210. */
  109211. removeVerticesData(kind: string): void;
  109212. /**
  109213. * Flags an associated vertex buffer as updatable
  109214. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  109215. * - VertexBuffer.PositionKind
  109216. * - VertexBuffer.UVKind
  109217. * - VertexBuffer.UV2Kind
  109218. * - VertexBuffer.UV3Kind
  109219. * - VertexBuffer.UV4Kind
  109220. * - VertexBuffer.UV5Kind
  109221. * - VertexBuffer.UV6Kind
  109222. * - VertexBuffer.ColorKind
  109223. * - VertexBuffer.MatricesIndicesKind
  109224. * - VertexBuffer.MatricesIndicesExtraKind
  109225. * - VertexBuffer.MatricesWeightsKind
  109226. * - VertexBuffer.MatricesWeightsExtraKind
  109227. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  109228. */
  109229. markVerticesDataAsUpdatable(kind: string, updatable?: boolean): void;
  109230. /**
  109231. * Sets the mesh global Vertex Buffer
  109232. * @param buffer defines the buffer to use
  109233. * @returns the current mesh
  109234. */
  109235. setVerticesBuffer(buffer: VertexBuffer): Mesh;
  109236. /**
  109237. * Update a specific associated vertex buffer
  109238. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  109239. * - VertexBuffer.PositionKind
  109240. * - VertexBuffer.UVKind
  109241. * - VertexBuffer.UV2Kind
  109242. * - VertexBuffer.UV3Kind
  109243. * - VertexBuffer.UV4Kind
  109244. * - VertexBuffer.UV5Kind
  109245. * - VertexBuffer.UV6Kind
  109246. * - VertexBuffer.ColorKind
  109247. * - VertexBuffer.MatricesIndicesKind
  109248. * - VertexBuffer.MatricesIndicesExtraKind
  109249. * - VertexBuffer.MatricesWeightsKind
  109250. * - VertexBuffer.MatricesWeightsExtraKind
  109251. * @param data defines the data source
  109252. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  109253. * @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)
  109254. * @returns the current mesh
  109255. */
  109256. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  109257. /**
  109258. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  109259. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  109260. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  109261. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  109262. * @returns the current mesh
  109263. */
  109264. updateMeshPositions(positionFunction: (data: FloatArray) => void, computeNormals?: boolean): Mesh;
  109265. /**
  109266. * Creates a un-shared specific occurence of the geometry for the mesh.
  109267. * @returns the current mesh
  109268. */
  109269. makeGeometryUnique(): Mesh;
  109270. /**
  109271. * Set the index buffer of this mesh
  109272. * @param indices defines the source data
  109273. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  109274. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  109275. * @returns the current mesh
  109276. */
  109277. setIndices(indices: IndicesArray, totalVertices?: Nullable<number>, updatable?: boolean): AbstractMesh;
  109278. /**
  109279. * Update the current index buffer
  109280. * @param indices defines the source data
  109281. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  109282. * @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)
  109283. * @returns the current mesh
  109284. */
  109285. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  109286. /**
  109287. * Invert the geometry to move from a right handed system to a left handed one.
  109288. * @returns the current mesh
  109289. */
  109290. toLeftHanded(): Mesh;
  109291. /** @hidden */
  109292. _bind(subMesh: SubMesh, effect: Effect, fillMode: number): Mesh;
  109293. /** @hidden */
  109294. _draw(subMesh: SubMesh, fillMode: number, instancesCount?: number): Mesh;
  109295. /**
  109296. * Registers for this mesh a javascript function called just before the rendering process
  109297. * @param func defines the function to call before rendering this mesh
  109298. * @returns the current mesh
  109299. */
  109300. registerBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109301. /**
  109302. * Disposes a previously registered javascript function called before the rendering
  109303. * @param func defines the function to remove
  109304. * @returns the current mesh
  109305. */
  109306. unregisterBeforeRender(func: (mesh: AbstractMesh) => void): Mesh;
  109307. /**
  109308. * Registers for this mesh a javascript function called just after the rendering is complete
  109309. * @param func defines the function to call after rendering this mesh
  109310. * @returns the current mesh
  109311. */
  109312. registerAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109313. /**
  109314. * Disposes a previously registered javascript function called after the rendering.
  109315. * @param func defines the function to remove
  109316. * @returns the current mesh
  109317. */
  109318. unregisterAfterRender(func: (mesh: AbstractMesh) => void): Mesh;
  109319. /** @hidden */
  109320. _getInstancesRenderList(subMeshId: number, isReplacementMode?: boolean): _InstancesBatch;
  109321. /** @hidden */
  109322. _renderWithInstances(subMesh: SubMesh, fillMode: number, batch: _InstancesBatch, effect: Effect, engine: Engine): Mesh;
  109323. /** @hidden */
  109324. _renderWithThinInstances(subMesh: SubMesh, fillMode: number, effect: Effect, engine: Engine): void;
  109325. /** @hidden */
  109326. _processInstancedBuffers(visibleInstances: InstancedMesh[], renderSelf: boolean): void;
  109327. /** @hidden */
  109328. _processRendering(renderingMesh: AbstractMesh, subMesh: SubMesh, effect: Effect, fillMode: number, batch: _InstancesBatch, hardwareInstancedRendering: boolean, onBeforeDraw: (isInstance: boolean, world: Matrix, effectiveMaterial?: Material) => void, effectiveMaterial?: Material): Mesh;
  109329. /** @hidden */
  109330. _rebuild(): void;
  109331. /** @hidden */
  109332. _freeze(): void;
  109333. /** @hidden */
  109334. _unFreeze(): void;
  109335. /**
  109336. * 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
  109337. * @param subMesh defines the subMesh to render
  109338. * @param enableAlphaMode defines if alpha mode can be changed
  109339. * @param effectiveMeshReplacement defines an optional mesh used to provide info for the rendering
  109340. * @returns the current mesh
  109341. */
  109342. render(subMesh: SubMesh, enableAlphaMode: boolean, effectiveMeshReplacement?: AbstractMesh): Mesh;
  109343. private _onBeforeDraw;
  109344. /**
  109345. * Renormalize the mesh and patch it up if there are no weights
  109346. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  109347. * However in the case of zero weights then we set just a single influence to 1.
  109348. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  109349. */
  109350. cleanMatrixWeights(): void;
  109351. private normalizeSkinFourWeights;
  109352. private normalizeSkinWeightsAndExtra;
  109353. /**
  109354. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  109355. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  109356. * the user know there was an issue with importing the mesh
  109357. * @returns a validation object with skinned, valid and report string
  109358. */
  109359. validateSkinning(): {
  109360. skinned: boolean;
  109361. valid: boolean;
  109362. report: string;
  109363. };
  109364. /** @hidden */
  109365. _checkDelayState(): Mesh;
  109366. private _queueLoad;
  109367. /**
  109368. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  109369. * A mesh is in the frustum if its bounding box intersects the frustum
  109370. * @param frustumPlanes defines the frustum to test
  109371. * @returns true if the mesh is in the frustum planes
  109372. */
  109373. isInFrustum(frustumPlanes: Plane[]): boolean;
  109374. /**
  109375. * Sets the mesh material by the material or multiMaterial `id` property
  109376. * @param id is a string identifying the material or the multiMaterial
  109377. * @returns the current mesh
  109378. */
  109379. setMaterialByID(id: string): Mesh;
  109380. /**
  109381. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  109382. * @returns an array of IAnimatable
  109383. */
  109384. getAnimatables(): IAnimatable[];
  109385. /**
  109386. * Modifies the mesh geometry according to the passed transformation matrix.
  109387. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  109388. * The mesh normals are modified using the same transformation.
  109389. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109390. * @param transform defines the transform matrix to use
  109391. * @see https://doc.babylonjs.com/resources/baking_transformations
  109392. * @returns the current mesh
  109393. */
  109394. bakeTransformIntoVertices(transform: Matrix): Mesh;
  109395. /**
  109396. * Modifies the mesh geometry according to its own current World Matrix.
  109397. * The mesh World Matrix is then reset.
  109398. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  109399. * Note that, under the hood, this method sets a new VertexBuffer each call.
  109400. * @see https://doc.babylonjs.com/resources/baking_transformations
  109401. * @param bakeIndependenlyOfChildren indicates whether to preserve all child nodes' World Matrix during baking
  109402. * @returns the current mesh
  109403. */
  109404. bakeCurrentTransformIntoVertices(bakeIndependenlyOfChildren?: boolean): Mesh;
  109405. /** @hidden */
  109406. get _positions(): Nullable<Vector3[]>;
  109407. /** @hidden */
  109408. _resetPointsArrayCache(): Mesh;
  109409. /** @hidden */
  109410. _generatePointsArray(): boolean;
  109411. /**
  109412. * Returns a new Mesh object generated from the current mesh properties.
  109413. * This method must not get confused with createInstance()
  109414. * @param name is a string, the name given to the new mesh
  109415. * @param newParent can be any Node object (default `null`)
  109416. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  109417. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  109418. * @returns a new mesh
  109419. */
  109420. clone(name?: string, newParent?: Nullable<Node>, doNotCloneChildren?: boolean, clonePhysicsImpostor?: boolean): Mesh;
  109421. /**
  109422. * Releases resources associated with this mesh.
  109423. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  109424. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  109425. */
  109426. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  109427. /** @hidden */
  109428. _disposeInstanceSpecificData(): void;
  109429. /** @hidden */
  109430. _disposeThinInstanceSpecificData(): void;
  109431. /**
  109432. * Modifies the mesh geometry according to a displacement map.
  109433. * 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.
  109434. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109435. * @param url is a string, the URL from the image file is to be downloaded.
  109436. * @param minHeight is the lower limit of the displacement.
  109437. * @param maxHeight is the upper limit of the displacement.
  109438. * @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.
  109439. * @param uvOffset is an optional vector2 used to offset UV.
  109440. * @param uvScale is an optional vector2 used to scale UV.
  109441. * @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.
  109442. * @returns the Mesh.
  109443. */
  109444. applyDisplacementMap(url: string, minHeight: number, maxHeight: number, onSuccess?: (mesh: Mesh) => void, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109445. /**
  109446. * Modifies the mesh geometry according to a displacementMap buffer.
  109447. * 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.
  109448. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  109449. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  109450. * @param heightMapWidth is the width of the buffer image.
  109451. * @param heightMapHeight is the height of the buffer image.
  109452. * @param minHeight is the lower limit of the displacement.
  109453. * @param maxHeight is the upper limit of the displacement.
  109454. * @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.
  109455. * @param uvOffset is an optional vector2 used to offset UV.
  109456. * @param uvScale is an optional vector2 used to scale UV.
  109457. * @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.
  109458. * @returns the Mesh.
  109459. */
  109460. applyDisplacementMapFromBuffer(buffer: Uint8Array, heightMapWidth: number, heightMapHeight: number, minHeight: number, maxHeight: number, uvOffset?: Vector2, uvScale?: Vector2, forceUpdate?: boolean): Mesh;
  109461. /**
  109462. * Modify the mesh to get a flat shading rendering.
  109463. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  109464. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  109465. * @returns current mesh
  109466. */
  109467. convertToFlatShadedMesh(): Mesh;
  109468. /**
  109469. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  109470. * In other words, more vertices, no more indices and a single bigger VBO.
  109471. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  109472. * @returns current mesh
  109473. */
  109474. convertToUnIndexedMesh(): Mesh;
  109475. /**
  109476. * Inverses facet orientations.
  109477. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109478. * @param flipNormals will also inverts the normals
  109479. * @returns current mesh
  109480. */
  109481. flipFaces(flipNormals?: boolean): Mesh;
  109482. /**
  109483. * Increase the number of facets and hence vertices in a mesh
  109484. * Vertex normals are interpolated from existing vertex normals
  109485. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109486. * @param numberPerEdge the number of new vertices to add to each edge of a facet, optional default 1
  109487. */
  109488. increaseVertices(numberPerEdge: number): void;
  109489. /**
  109490. * Force adjacent facets to share vertices and remove any facets that have all vertices in a line
  109491. * This will undo any application of covertToFlatShadedMesh
  109492. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  109493. */
  109494. forceSharedVertices(): void;
  109495. /** @hidden */
  109496. static _instancedMeshFactory(name: string, mesh: Mesh): InstancedMesh;
  109497. /** @hidden */
  109498. static _PhysicsImpostorParser(scene: Scene, physicObject: IPhysicsEnabledObject, jsonObject: any): PhysicsImpostor;
  109499. /**
  109500. * Creates a new InstancedMesh object from the mesh model.
  109501. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  109502. * @param name defines the name of the new instance
  109503. * @returns a new InstancedMesh
  109504. */
  109505. createInstance(name: string): InstancedMesh;
  109506. /**
  109507. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  109508. * After this call, all the mesh instances have the same submeshes than the current mesh.
  109509. * @returns the current mesh
  109510. */
  109511. synchronizeInstances(): Mesh;
  109512. /**
  109513. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  109514. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  109515. * This should be used together with the simplification to avoid disappearing triangles.
  109516. * @param successCallback an optional success callback to be called after the optimization finished.
  109517. * @returns the current mesh
  109518. */
  109519. optimizeIndices(successCallback?: (mesh?: Mesh) => void): Mesh;
  109520. /**
  109521. * Serialize current mesh
  109522. * @param serializationObject defines the object which will receive the serialization data
  109523. */
  109524. serialize(serializationObject: any): void;
  109525. /** @hidden */
  109526. _syncGeometryWithMorphTargetManager(): void;
  109527. /** @hidden */
  109528. static _GroundMeshParser: (parsedMesh: any, scene: Scene) => Mesh;
  109529. /**
  109530. * Returns a new Mesh object parsed from the source provided.
  109531. * @param parsedMesh is the source
  109532. * @param scene defines the hosting scene
  109533. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  109534. * @returns a new Mesh
  109535. */
  109536. static Parse(parsedMesh: any, scene: Scene, rootUrl: string): Mesh;
  109537. /**
  109538. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  109539. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109540. * @param name defines the name of the mesh to create
  109541. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  109542. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  109543. * @param closePath creates a seam between the first and the last points of each path of the path array
  109544. * @param offset is taken in account only if the `pathArray` is containing a single path
  109545. * @param scene defines the hosting scene
  109546. * @param updatable defines if the mesh must be flagged as updatable
  109547. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109548. * @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)
  109549. * @returns a new Mesh
  109550. */
  109551. static CreateRibbon(name: string, pathArray: Vector3[][], closeArray: boolean, closePath: boolean, offset: number, scene?: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109552. /**
  109553. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  109554. * @param name defines the name of the mesh to create
  109555. * @param radius sets the radius size (float) of the polygon (default 0.5)
  109556. * @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
  109557. * @param scene defines the hosting scene
  109558. * @param updatable defines if the mesh must be flagged as updatable
  109559. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109560. * @returns a new Mesh
  109561. */
  109562. static CreateDisc(name: string, radius: number, tessellation: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109563. /**
  109564. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  109565. * @param name defines the name of the mesh to create
  109566. * @param size sets the size (float) of each box side (default 1)
  109567. * @param scene defines the hosting scene
  109568. * @param updatable defines if the mesh must be flagged as updatable
  109569. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109570. * @returns a new Mesh
  109571. */
  109572. static CreateBox(name: string, size: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number): Mesh;
  109573. /**
  109574. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  109575. * @param name defines the name of the mesh to create
  109576. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109577. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109578. * @param scene defines the hosting scene
  109579. * @param updatable defines if the mesh must be flagged as updatable
  109580. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109581. * @returns a new Mesh
  109582. */
  109583. static CreateSphere(name: string, segments: number, diameter: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109584. /**
  109585. * Creates a hemisphere mesh. Please consider using the same method from the MeshBuilder class instead
  109586. * @param name defines the name of the mesh to create
  109587. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  109588. * @param diameter sets the diameter size (float) of the sphere (default 1)
  109589. * @param scene defines the hosting scene
  109590. * @returns a new Mesh
  109591. */
  109592. static CreateHemisphere(name: string, segments: number, diameter: number, scene?: Scene): Mesh;
  109593. /**
  109594. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  109595. * @param name defines the name of the mesh to create
  109596. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  109597. * @param diameterTop set the top cap diameter (floats, default 1)
  109598. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  109599. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  109600. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  109601. * @param scene defines the hosting scene
  109602. * @param updatable defines if the mesh must be flagged as updatable
  109603. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109604. * @returns a new Mesh
  109605. */
  109606. static CreateCylinder(name: string, height: number, diameterTop: number, diameterBottom: number, tessellation: number, subdivisions: any, scene?: Scene, updatable?: any, sideOrientation?: number): Mesh;
  109607. /**
  109608. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  109609. * @param name defines the name of the mesh to create
  109610. * @param diameter sets the diameter size (float) of the torus (default 1)
  109611. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  109612. * @param tessellation sets the number of torus sides (postive integer, default 16)
  109613. * @param scene defines the hosting scene
  109614. * @param updatable defines if the mesh must be flagged as updatable
  109615. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109616. * @returns a new Mesh
  109617. */
  109618. static CreateTorus(name: string, diameter: number, thickness: number, tessellation: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109619. /**
  109620. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  109621. * @param name defines the name of the mesh to create
  109622. * @param radius sets the global radius size (float) of the torus knot (default 2)
  109623. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  109624. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  109625. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  109626. * @param p the number of windings on X axis (positive integers, default 2)
  109627. * @param q the number of windings on Y axis (positive integers, default 3)
  109628. * @param scene defines the hosting scene
  109629. * @param updatable defines if the mesh must be flagged as updatable
  109630. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109631. * @returns a new Mesh
  109632. */
  109633. static CreateTorusKnot(name: string, radius: number, tube: number, radialSegments: number, tubularSegments: number, p: number, q: number, scene?: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109634. /**
  109635. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  109636. * @param name defines the name of the mesh to create
  109637. * @param points is an array successive Vector3
  109638. * @param scene defines the hosting scene
  109639. * @param updatable defines if the mesh must be flagged as updatable
  109640. * @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).
  109641. * @returns a new Mesh
  109642. */
  109643. static CreateLines(name: string, points: Vector3[], scene?: Nullable<Scene>, updatable?: boolean, instance?: Nullable<LinesMesh>): LinesMesh;
  109644. /**
  109645. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  109646. * @param name defines the name of the mesh to create
  109647. * @param points is an array successive Vector3
  109648. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  109649. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  109650. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  109651. * @param scene defines the hosting scene
  109652. * @param updatable defines if the mesh must be flagged as updatable
  109653. * @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)
  109654. * @returns a new Mesh
  109655. */
  109656. static CreateDashedLines(name: string, points: Vector3[], dashSize: number, gapSize: number, dashNb: number, scene?: Nullable<Scene>, updatable?: boolean, instance?: LinesMesh): LinesMesh;
  109657. /**
  109658. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  109659. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  109660. * 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.
  109661. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109662. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  109663. * Remember you can only change the shape positions, not their number when updating a polygon.
  109664. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  109665. * @param name defines the name of the mesh to create
  109666. * @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
  109667. * @param scene defines the hosting scene
  109668. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109669. * @param updatable defines if the mesh must be flagged as updatable
  109670. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109671. * @param earcutInjection can be used to inject your own earcut reference
  109672. * @returns a new Mesh
  109673. */
  109674. static CreatePolygon(name: string, shape: Vector3[], scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109675. /**
  109676. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  109677. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  109678. * @param name defines the name of the mesh to create
  109679. * @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
  109680. * @param depth defines the height of extrusion
  109681. * @param scene defines the hosting scene
  109682. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  109683. * @param updatable defines if the mesh must be flagged as updatable
  109684. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109685. * @param earcutInjection can be used to inject your own earcut reference
  109686. * @returns a new Mesh
  109687. */
  109688. static ExtrudePolygon(name: string, shape: Vector3[], depth: number, scene: Scene, holes?: Vector3[][], updatable?: boolean, sideOrientation?: number, earcutInjection?: any): Mesh;
  109689. /**
  109690. * Creates an extruded shape mesh.
  109691. * 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
  109692. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109693. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109694. * @param name defines the name of the mesh to create
  109695. * @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
  109696. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109697. * @param scale is the value to scale the shape
  109698. * @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
  109699. * @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
  109700. * @param scene defines the hosting scene
  109701. * @param updatable defines if the mesh must be flagged as updatable
  109702. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109703. * @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)
  109704. * @returns a new Mesh
  109705. */
  109706. static ExtrudeShape(name: string, shape: Vector3[], path: Vector3[], scale: number, rotation: number, cap: number, scene?: Nullable<Scene>, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109707. /**
  109708. * Creates an custom extruded shape mesh.
  109709. * The custom extrusion is a parametric shape.
  109710. * It has no predefined shape. Its final shape will depend on the input parameters.
  109711. * Please consider using the same method from the MeshBuilder class instead
  109712. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  109713. * @param name defines the name of the mesh to create
  109714. * @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
  109715. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  109716. * @param scaleFunction is a custom Javascript function called on each path point
  109717. * @param rotationFunction is a custom Javascript function called on each path point
  109718. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  109719. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  109720. * @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
  109721. * @param scene defines the hosting scene
  109722. * @param updatable defines if the mesh must be flagged as updatable
  109723. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109724. * @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)
  109725. * @returns a new Mesh
  109726. */
  109727. 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;
  109728. /**
  109729. * Creates lathe mesh.
  109730. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  109731. * Please consider using the same method from the MeshBuilder class instead
  109732. * @param name defines the name of the mesh to create
  109733. * @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
  109734. * @param radius is the radius value of the lathe
  109735. * @param tessellation is the side number of the lathe.
  109736. * @param scene defines the hosting scene
  109737. * @param updatable defines if the mesh must be flagged as updatable
  109738. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109739. * @returns a new Mesh
  109740. */
  109741. static CreateLathe(name: string, shape: Vector3[], radius: number, tessellation: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109742. /**
  109743. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  109744. * @param name defines the name of the mesh to create
  109745. * @param size sets the size (float) of both sides of the plane at once (default 1)
  109746. * @param scene defines the hosting scene
  109747. * @param updatable defines if the mesh must be flagged as updatable
  109748. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109749. * @returns a new Mesh
  109750. */
  109751. static CreatePlane(name: string, size: number, scene: Scene, updatable?: boolean, sideOrientation?: number): Mesh;
  109752. /**
  109753. * Creates a ground mesh.
  109754. * Please consider using the same method from the MeshBuilder class instead
  109755. * @param name defines the name of the mesh to create
  109756. * @param width set the width of the ground
  109757. * @param height set the height of the ground
  109758. * @param subdivisions sets the number of subdivisions per side
  109759. * @param scene defines the hosting scene
  109760. * @param updatable defines if the mesh must be flagged as updatable
  109761. * @returns a new Mesh
  109762. */
  109763. static CreateGround(name: string, width: number, height: number, subdivisions: number, scene?: Scene, updatable?: boolean): Mesh;
  109764. /**
  109765. * Creates a tiled ground mesh.
  109766. * Please consider using the same method from the MeshBuilder class instead
  109767. * @param name defines the name of the mesh to create
  109768. * @param xmin set the ground minimum X coordinate
  109769. * @param zmin set the ground minimum Y coordinate
  109770. * @param xmax set the ground maximum X coordinate
  109771. * @param zmax set the ground maximum Z coordinate
  109772. * @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
  109773. * @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
  109774. * @param scene defines the hosting scene
  109775. * @param updatable defines if the mesh must be flagged as updatable
  109776. * @returns a new Mesh
  109777. */
  109778. static CreateTiledGround(name: string, xmin: number, zmin: number, xmax: number, zmax: number, subdivisions: {
  109779. w: number;
  109780. h: number;
  109781. }, precision: {
  109782. w: number;
  109783. h: number;
  109784. }, scene: Scene, updatable?: boolean): Mesh;
  109785. /**
  109786. * Creates a ground mesh from a height map.
  109787. * Please consider using the same method from the MeshBuilder class instead
  109788. * @see https://doc.babylonjs.com/babylon101/height_map
  109789. * @param name defines the name of the mesh to create
  109790. * @param url sets the URL of the height map image resource
  109791. * @param width set the ground width size
  109792. * @param height set the ground height size
  109793. * @param subdivisions sets the number of subdivision per side
  109794. * @param minHeight is the minimum altitude on the ground
  109795. * @param maxHeight is the maximum altitude on the ground
  109796. * @param scene defines the hosting scene
  109797. * @param updatable defines if the mesh must be flagged as updatable
  109798. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  109799. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  109800. * @returns a new Mesh
  109801. */
  109802. 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;
  109803. /**
  109804. * Creates a tube mesh.
  109805. * The tube is a parametric shape.
  109806. * It has no predefined shape. Its final shape will depend on the input parameters.
  109807. * Please consider using the same method from the MeshBuilder class instead
  109808. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  109809. * @param name defines the name of the mesh to create
  109810. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  109811. * @param radius sets the tube radius size
  109812. * @param tessellation is the number of sides on the tubular surface
  109813. * @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
  109814. * @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
  109815. * @param scene defines the hosting scene
  109816. * @param updatable defines if the mesh must be flagged as updatable
  109817. * @param sideOrientation defines the mesh side orientation (https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  109818. * @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)
  109819. * @returns a new Mesh
  109820. */
  109821. static CreateTube(name: string, path: Vector3[], radius: number, tessellation: number, radiusFunction: {
  109822. (i: number, distance: number): number;
  109823. }, cap: number, scene: Scene, updatable?: boolean, sideOrientation?: number, instance?: Mesh): Mesh;
  109824. /**
  109825. * Creates a polyhedron mesh.
  109826. * Please consider using the same method from the MeshBuilder class instead.
  109827. * * 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
  109828. * * The parameter `size` (positive float, default 1) sets the polygon size
  109829. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  109830. * * 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`
  109831. * * 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
  109832. * * 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)`)
  109833. * * 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
  109834. * * 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
  109835. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109836. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109838. * @param name defines the name of the mesh to create
  109839. * @param options defines the options used to create the mesh
  109840. * @param scene defines the hosting scene
  109841. * @returns a new Mesh
  109842. */
  109843. static CreatePolyhedron(name: string, options: {
  109844. type?: number;
  109845. size?: number;
  109846. sizeX?: number;
  109847. sizeY?: number;
  109848. sizeZ?: number;
  109849. custom?: any;
  109850. faceUV?: Vector4[];
  109851. faceColors?: Color4[];
  109852. updatable?: boolean;
  109853. sideOrientation?: number;
  109854. }, scene: Scene): Mesh;
  109855. /**
  109856. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  109857. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  109858. * * 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`)
  109859. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  109860. * * 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
  109861. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  109862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  109863. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  109864. * @param name defines the name of the mesh
  109865. * @param options defines the options used to create the mesh
  109866. * @param scene defines the hosting scene
  109867. * @returns a new Mesh
  109868. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  109869. */
  109870. static CreateIcoSphere(name: string, options: {
  109871. radius?: number;
  109872. flat?: boolean;
  109873. subdivisions?: number;
  109874. sideOrientation?: number;
  109875. updatable?: boolean;
  109876. }, scene: Scene): Mesh;
  109877. /**
  109878. * Creates a decal mesh.
  109879. * Please consider using the same method from the MeshBuilder class instead.
  109880. * A decal is a mesh usually applied as a model onto the surface of another mesh
  109881. * @param name defines the name of the mesh
  109882. * @param sourceMesh defines the mesh receiving the decal
  109883. * @param position sets the position of the decal in world coordinates
  109884. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  109885. * @param size sets the decal scaling
  109886. * @param angle sets the angle to rotate the decal
  109887. * @returns a new Mesh
  109888. */
  109889. static CreateDecal(name: string, sourceMesh: AbstractMesh, position: Vector3, normal: Vector3, size: Vector3, angle: number): Mesh;
  109890. /** Creates a Capsule Mesh
  109891. * @param name defines the name of the mesh.
  109892. * @param options the constructors options used to shape the mesh.
  109893. * @param scene defines the scene the mesh is scoped to.
  109894. * @returns the capsule mesh
  109895. * @see https://doc.babylonjs.com/how_to/capsule_shape
  109896. */
  109897. static CreateCapsule(name: string, options: ICreateCapsuleOptions, scene: Scene): Mesh;
  109898. /**
  109899. * Prepare internal position array for software CPU skinning
  109900. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  109901. */
  109902. setPositionsForCPUSkinning(): Float32Array;
  109903. /**
  109904. * Prepare internal normal array for software CPU skinning
  109905. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  109906. */
  109907. setNormalsForCPUSkinning(): Float32Array;
  109908. /**
  109909. * Updates the vertex buffer by applying transformation from the bones
  109910. * @param skeleton defines the skeleton to apply to current mesh
  109911. * @returns the current mesh
  109912. */
  109913. applySkeleton(skeleton: Skeleton): Mesh;
  109914. /**
  109915. * 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
  109916. * @param meshes defines the list of meshes to scan
  109917. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  109918. */
  109919. static MinMax(meshes: AbstractMesh[]): {
  109920. min: Vector3;
  109921. max: Vector3;
  109922. };
  109923. /**
  109924. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  109925. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  109926. * @returns a vector3
  109927. */
  109928. static Center(meshesOrMinMaxVector: {
  109929. min: Vector3;
  109930. max: Vector3;
  109931. } | AbstractMesh[]): Vector3;
  109932. /**
  109933. * Merge the array of meshes into a single mesh for performance reasons.
  109934. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  109935. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  109936. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  109937. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  109938. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  109939. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  109940. * @returns a new mesh
  109941. */
  109942. static MergeMeshes(meshes: Array<Mesh>, disposeSource?: boolean, allow32BitsIndices?: boolean, meshSubclass?: Mesh, subdivideWithSubMeshes?: boolean, multiMultiMaterials?: boolean): Nullable<Mesh>;
  109943. /** @hidden */
  109944. addInstance(instance: InstancedMesh): void;
  109945. /** @hidden */
  109946. removeInstance(instance: InstancedMesh): void;
  109947. }
  109948. }
  109949. declare module BABYLON {
  109950. /**
  109951. * This is the base class of all the camera used in the application.
  109952. * @see https://doc.babylonjs.com/features/cameras
  109953. */
  109954. export class Camera extends Node {
  109955. /** @hidden */
  109956. static _createDefaultParsedCamera: (name: string, scene: Scene) => Camera;
  109957. /**
  109958. * This is the default projection mode used by the cameras.
  109959. * It helps recreating a feeling of perspective and better appreciate depth.
  109960. * This is the best way to simulate real life cameras.
  109961. */
  109962. static readonly PERSPECTIVE_CAMERA: number;
  109963. /**
  109964. * This helps creating camera with an orthographic mode.
  109965. * 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.
  109966. */
  109967. static readonly ORTHOGRAPHIC_CAMERA: number;
  109968. /**
  109969. * This is the default FOV mode for perspective cameras.
  109970. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  109971. */
  109972. static readonly FOVMODE_VERTICAL_FIXED: number;
  109973. /**
  109974. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  109975. */
  109976. static readonly FOVMODE_HORIZONTAL_FIXED: number;
  109977. /**
  109978. * This specifies ther is no need for a camera rig.
  109979. * Basically only one eye is rendered corresponding to the camera.
  109980. */
  109981. static readonly RIG_MODE_NONE: number;
  109982. /**
  109983. * Simulates a camera Rig with one blue eye and one red eye.
  109984. * This can be use with 3d blue and red glasses.
  109985. */
  109986. static readonly RIG_MODE_STEREOSCOPIC_ANAGLYPH: number;
  109987. /**
  109988. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  109989. */
  109990. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL: number;
  109991. /**
  109992. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  109993. */
  109994. static readonly RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED: number;
  109995. /**
  109996. * Defines that both eyes of the camera will be rendered over under each other.
  109997. */
  109998. static readonly RIG_MODE_STEREOSCOPIC_OVERUNDER: number;
  109999. /**
  110000. * Defines that both eyes of the camera will be rendered on successive lines interlaced for passive 3d monitors.
  110001. */
  110002. static readonly RIG_MODE_STEREOSCOPIC_INTERLACED: number;
  110003. /**
  110004. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  110005. */
  110006. static readonly RIG_MODE_VR: number;
  110007. /**
  110008. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  110009. */
  110010. static readonly RIG_MODE_WEBVR: number;
  110011. /**
  110012. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  110013. */
  110014. static readonly RIG_MODE_CUSTOM: number;
  110015. /**
  110016. * Defines if by default attaching controls should prevent the default javascript event to continue.
  110017. */
  110018. static ForceAttachControlToAlwaysPreventDefault: boolean;
  110019. /**
  110020. * Define the input manager associated with the camera.
  110021. */
  110022. inputs: CameraInputsManager<Camera>;
  110023. /** @hidden */
  110024. _position: Vector3;
  110025. /**
  110026. * Define the current local position of the camera in the scene
  110027. */
  110028. get position(): Vector3;
  110029. set position(newPosition: Vector3);
  110030. protected _upVector: Vector3;
  110031. /**
  110032. * The vector the camera should consider as up.
  110033. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  110034. */
  110035. set upVector(vec: Vector3);
  110036. get upVector(): Vector3;
  110037. /**
  110038. * Define the current limit on the left side for an orthographic camera
  110039. * In scene unit
  110040. */
  110041. orthoLeft: Nullable<number>;
  110042. /**
  110043. * Define the current limit on the right side for an orthographic camera
  110044. * In scene unit
  110045. */
  110046. orthoRight: Nullable<number>;
  110047. /**
  110048. * Define the current limit on the bottom side for an orthographic camera
  110049. * In scene unit
  110050. */
  110051. orthoBottom: Nullable<number>;
  110052. /**
  110053. * Define the current limit on the top side for an orthographic camera
  110054. * In scene unit
  110055. */
  110056. orthoTop: Nullable<number>;
  110057. /**
  110058. * Field Of View is set in Radians. (default is 0.8)
  110059. */
  110060. fov: number;
  110061. /**
  110062. * Define the minimum distance the camera can see from.
  110063. * This is important to note that the depth buffer are not infinite and the closer it starts
  110064. * the more your scene might encounter depth fighting issue.
  110065. */
  110066. minZ: number;
  110067. /**
  110068. * Define the maximum distance the camera can see to.
  110069. * This is important to note that the depth buffer are not infinite and the further it end
  110070. * the more your scene might encounter depth fighting issue.
  110071. */
  110072. maxZ: number;
  110073. /**
  110074. * Define the default inertia of the camera.
  110075. * This helps giving a smooth feeling to the camera movement.
  110076. */
  110077. inertia: number;
  110078. /**
  110079. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.ORTHOGRAPHIC_CAMERA)
  110080. */
  110081. mode: number;
  110082. /**
  110083. * Define whether the camera is intermediate.
  110084. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  110085. */
  110086. isIntermediate: boolean;
  110087. /**
  110088. * Define the viewport of the camera.
  110089. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  110090. */
  110091. viewport: Viewport;
  110092. /**
  110093. * Restricts the camera to viewing objects with the same layerMask.
  110094. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  110095. */
  110096. layerMask: number;
  110097. /**
  110098. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  110099. */
  110100. fovMode: number;
  110101. /**
  110102. * Rig mode of the camera.
  110103. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  110104. * This is normally controlled byt the camera themselves as internal use.
  110105. */
  110106. cameraRigMode: number;
  110107. /**
  110108. * Defines the distance between both "eyes" in case of a RIG
  110109. */
  110110. interaxialDistance: number;
  110111. /**
  110112. * Defines if stereoscopic rendering is done side by side or over under.
  110113. */
  110114. isStereoscopicSideBySide: boolean;
  110115. /**
  110116. * 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
  110117. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  110118. * else in the scene. (Eg. security camera)
  110119. *
  110120. * 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)
  110121. */
  110122. customRenderTargets: RenderTargetTexture[];
  110123. /**
  110124. * When set, the camera will render to this render target instead of the default canvas
  110125. *
  110126. * If the desire is to use the output of a camera as a texture in the scene consider using camera.customRenderTargets instead
  110127. */
  110128. outputRenderTarget: Nullable<RenderTargetTexture>;
  110129. /**
  110130. * Observable triggered when the camera view matrix has changed.
  110131. */
  110132. onViewMatrixChangedObservable: Observable<Camera>;
  110133. /**
  110134. * Observable triggered when the camera Projection matrix has changed.
  110135. */
  110136. onProjectionMatrixChangedObservable: Observable<Camera>;
  110137. /**
  110138. * Observable triggered when the inputs have been processed.
  110139. */
  110140. onAfterCheckInputsObservable: Observable<Camera>;
  110141. /**
  110142. * Observable triggered when reset has been called and applied to the camera.
  110143. */
  110144. onRestoreStateObservable: Observable<Camera>;
  110145. /**
  110146. * Is this camera a part of a rig system?
  110147. */
  110148. isRigCamera: boolean;
  110149. /**
  110150. * If isRigCamera set to true this will be set with the parent camera.
  110151. * The parent camera is not (!) necessarily the .parent of this camera (like in the case of XR)
  110152. */
  110153. rigParent?: Camera;
  110154. /** @hidden */
  110155. _cameraRigParams: any;
  110156. /** @hidden */
  110157. _rigCameras: Camera[];
  110158. /** @hidden */
  110159. _rigPostProcess: Nullable<PostProcess>;
  110160. protected _webvrViewMatrix: Matrix;
  110161. /** @hidden */
  110162. _skipRendering: boolean;
  110163. /** @hidden */
  110164. _projectionMatrix: Matrix;
  110165. /** @hidden */
  110166. _postProcesses: Nullable<PostProcess>[];
  110167. /** @hidden */
  110168. _activeMeshes: SmartArray<AbstractMesh>;
  110169. protected _globalPosition: Vector3;
  110170. /** @hidden */
  110171. _computedViewMatrix: Matrix;
  110172. private _doNotComputeProjectionMatrix;
  110173. private _transformMatrix;
  110174. private _frustumPlanes;
  110175. private _refreshFrustumPlanes;
  110176. private _storedFov;
  110177. private _stateStored;
  110178. /**
  110179. * Instantiates a new camera object.
  110180. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  110181. * @see https://doc.babylonjs.com/features/cameras
  110182. * @param name Defines the name of the camera in the scene
  110183. * @param position Defines the position of the camera
  110184. * @param scene Defines the scene the camera belongs too
  110185. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  110186. */
  110187. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  110188. /**
  110189. * Store current camera state (fov, position, etc..)
  110190. * @returns the camera
  110191. */
  110192. storeState(): Camera;
  110193. /**
  110194. * Restores the camera state values if it has been stored. You must call storeState() first
  110195. */
  110196. protected _restoreStateValues(): boolean;
  110197. /**
  110198. * Restored camera state. You must call storeState() first.
  110199. * @returns true if restored and false otherwise
  110200. */
  110201. restoreState(): boolean;
  110202. /**
  110203. * Gets the class name of the camera.
  110204. * @returns the class name
  110205. */
  110206. getClassName(): string;
  110207. /** @hidden */
  110208. readonly _isCamera: boolean;
  110209. /**
  110210. * Gets a string representation of the camera useful for debug purpose.
  110211. * @param fullDetails Defines that a more verboe level of logging is required
  110212. * @returns the string representation
  110213. */
  110214. toString(fullDetails?: boolean): string;
  110215. /**
  110216. * Gets the current world space position of the camera.
  110217. */
  110218. get globalPosition(): Vector3;
  110219. /**
  110220. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  110221. * @returns the active meshe list
  110222. */
  110223. getActiveMeshes(): SmartArray<AbstractMesh>;
  110224. /**
  110225. * Check whether a mesh is part of the current active mesh list of the camera
  110226. * @param mesh Defines the mesh to check
  110227. * @returns true if active, false otherwise
  110228. */
  110229. isActiveMesh(mesh: Mesh): boolean;
  110230. /**
  110231. * Is this camera ready to be used/rendered
  110232. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  110233. * @return true if the camera is ready
  110234. */
  110235. isReady(completeCheck?: boolean): boolean;
  110236. /** @hidden */
  110237. _initCache(): void;
  110238. /** @hidden */
  110239. _updateCache(ignoreParentClass?: boolean): void;
  110240. /** @hidden */
  110241. _isSynchronized(): boolean;
  110242. /** @hidden */
  110243. _isSynchronizedViewMatrix(): boolean;
  110244. /** @hidden */
  110245. _isSynchronizedProjectionMatrix(): boolean;
  110246. /**
  110247. * Attach the input controls to a specific dom element to get the input from.
  110248. * @param element Defines the element the controls should be listened from
  110249. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  110250. */
  110251. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  110252. /**
  110253. * Detach the current controls from the specified dom element.
  110254. * @param element Defines the element to stop listening the inputs from
  110255. */
  110256. detachControl(element: HTMLElement): void;
  110257. /**
  110258. * Update the camera state according to the different inputs gathered during the frame.
  110259. */
  110260. update(): void;
  110261. /** @hidden */
  110262. _checkInputs(): void;
  110263. /** @hidden */
  110264. get rigCameras(): Camera[];
  110265. /**
  110266. * Gets the post process used by the rig cameras
  110267. */
  110268. get rigPostProcess(): Nullable<PostProcess>;
  110269. /**
  110270. * Internal, gets the first post proces.
  110271. * @returns the first post process to be run on this camera.
  110272. */
  110273. _getFirstPostProcess(): Nullable<PostProcess>;
  110274. private _cascadePostProcessesToRigCams;
  110275. /**
  110276. * Attach a post process to the camera.
  110277. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110278. * @param postProcess The post process to attach to the camera
  110279. * @param insertAt The position of the post process in case several of them are in use in the scene
  110280. * @returns the position the post process has been inserted at
  110281. */
  110282. attachPostProcess(postProcess: PostProcess, insertAt?: Nullable<number>): number;
  110283. /**
  110284. * Detach a post process to the camera.
  110285. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  110286. * @param postProcess The post process to detach from the camera
  110287. */
  110288. detachPostProcess(postProcess: PostProcess): void;
  110289. /**
  110290. * Gets the current world matrix of the camera
  110291. */
  110292. getWorldMatrix(): Matrix;
  110293. /** @hidden */
  110294. _getViewMatrix(): Matrix;
  110295. /**
  110296. * Gets the current view matrix of the camera.
  110297. * @param force forces the camera to recompute the matrix without looking at the cached state
  110298. * @returns the view matrix
  110299. */
  110300. getViewMatrix(force?: boolean): Matrix;
  110301. /**
  110302. * Freeze the projection matrix.
  110303. * It will prevent the cache check of the camera projection compute and can speed up perf
  110304. * if no parameter of the camera are meant to change
  110305. * @param projection Defines manually a projection if necessary
  110306. */
  110307. freezeProjectionMatrix(projection?: Matrix): void;
  110308. /**
  110309. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  110310. */
  110311. unfreezeProjectionMatrix(): void;
  110312. /**
  110313. * Gets the current projection matrix of the camera.
  110314. * @param force forces the camera to recompute the matrix without looking at the cached state
  110315. * @returns the projection matrix
  110316. */
  110317. getProjectionMatrix(force?: boolean): Matrix;
  110318. /**
  110319. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  110320. * @returns a Matrix
  110321. */
  110322. getTransformationMatrix(): Matrix;
  110323. private _updateFrustumPlanes;
  110324. /**
  110325. * Checks if a cullable object (mesh...) is in the camera frustum
  110326. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  110327. * @param target The object to check
  110328. * @param checkRigCameras If the rig cameras should be checked (eg. with webVR camera both eyes should be checked) (Default: false)
  110329. * @returns true if the object is in frustum otherwise false
  110330. */
  110331. isInFrustum(target: ICullable, checkRigCameras?: boolean): boolean;
  110332. /**
  110333. * Checks if a cullable object (mesh...) is in the camera frustum
  110334. * Unlike isInFrustum this cheks the full bounding box
  110335. * @param target The object to check
  110336. * @returns true if the object is in frustum otherwise false
  110337. */
  110338. isCompletelyInFrustum(target: ICullable): boolean;
  110339. /**
  110340. * Gets a ray in the forward direction from the camera.
  110341. * @param length Defines the length of the ray to create
  110342. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110343. * @param origin Defines the start point of the ray which defaults to the camera position
  110344. * @returns the forward ray
  110345. */
  110346. getForwardRay(length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110347. /**
  110348. * Gets a ray in the forward direction from the camera.
  110349. * @param refRay the ray to (re)use when setting the values
  110350. * @param length Defines the length of the ray to create
  110351. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  110352. * @param origin Defines the start point of the ray which defaults to the camera position
  110353. * @returns the forward ray
  110354. */
  110355. getForwardRayToRef(refRay: Ray, length?: number, transform?: Matrix, origin?: Vector3): Ray;
  110356. /**
  110357. * Releases resources associated with this node.
  110358. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  110359. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  110360. */
  110361. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  110362. /** @hidden */
  110363. _isLeftCamera: boolean;
  110364. /**
  110365. * Gets the left camera of a rig setup in case of Rigged Camera
  110366. */
  110367. get isLeftCamera(): boolean;
  110368. /** @hidden */
  110369. _isRightCamera: boolean;
  110370. /**
  110371. * Gets the right camera of a rig setup in case of Rigged Camera
  110372. */
  110373. get isRightCamera(): boolean;
  110374. /**
  110375. * Gets the left camera of a rig setup in case of Rigged Camera
  110376. */
  110377. get leftCamera(): Nullable<FreeCamera>;
  110378. /**
  110379. * Gets the right camera of a rig setup in case of Rigged Camera
  110380. */
  110381. get rightCamera(): Nullable<FreeCamera>;
  110382. /**
  110383. * Gets the left camera target of a rig setup in case of Rigged Camera
  110384. * @returns the target position
  110385. */
  110386. getLeftTarget(): Nullable<Vector3>;
  110387. /**
  110388. * Gets the right camera target of a rig setup in case of Rigged Camera
  110389. * @returns the target position
  110390. */
  110391. getRightTarget(): Nullable<Vector3>;
  110392. /**
  110393. * @hidden
  110394. */
  110395. setCameraRigMode(mode: number, rigParams: any): void;
  110396. /** @hidden */
  110397. static _setStereoscopicRigMode(camera: Camera): void;
  110398. /** @hidden */
  110399. static _setStereoscopicAnaglyphRigMode(camera: Camera): void;
  110400. /** @hidden */
  110401. static _setVRRigMode(camera: Camera, rigParams: any): void;
  110402. /** @hidden */
  110403. static _setWebVRRigMode(camera: Camera, rigParams: any): void;
  110404. /** @hidden */
  110405. _getVRProjectionMatrix(): Matrix;
  110406. protected _updateCameraRotationMatrix(): void;
  110407. protected _updateWebVRCameraRotationMatrix(): void;
  110408. /**
  110409. * This function MUST be overwritten by the different WebVR cameras available.
  110410. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110411. * @hidden
  110412. */
  110413. _getWebVRProjectionMatrix(): Matrix;
  110414. /**
  110415. * This function MUST be overwritten by the different WebVR cameras available.
  110416. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  110417. * @hidden
  110418. */
  110419. _getWebVRViewMatrix(): Matrix;
  110420. /** @hidden */
  110421. setCameraRigParameter(name: string, value: any): void;
  110422. /**
  110423. * needs to be overridden by children so sub has required properties to be copied
  110424. * @hidden
  110425. */
  110426. createRigCamera(name: string, cameraIndex: number): Nullable<Camera>;
  110427. /**
  110428. * May need to be overridden by children
  110429. * @hidden
  110430. */
  110431. _updateRigCameras(): void;
  110432. /** @hidden */
  110433. _setupInputs(): void;
  110434. /**
  110435. * Serialiaze the camera setup to a json represention
  110436. * @returns the JSON representation
  110437. */
  110438. serialize(): any;
  110439. /**
  110440. * Clones the current camera.
  110441. * @param name The cloned camera name
  110442. * @returns the cloned camera
  110443. */
  110444. clone(name: string): Camera;
  110445. /**
  110446. * Gets the direction of the camera relative to a given local axis.
  110447. * @param localAxis Defines the reference axis to provide a relative direction.
  110448. * @return the direction
  110449. */
  110450. getDirection(localAxis: Vector3): Vector3;
  110451. /**
  110452. * Returns the current camera absolute rotation
  110453. */
  110454. get absoluteRotation(): Quaternion;
  110455. /**
  110456. * Gets the direction of the camera relative to a given local axis into a passed vector.
  110457. * @param localAxis Defines the reference axis to provide a relative direction.
  110458. * @param result Defines the vector to store the result in
  110459. */
  110460. getDirectionToRef(localAxis: Vector3, result: Vector3): void;
  110461. /**
  110462. * Gets a camera constructor for a given camera type
  110463. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  110464. * @param name The name of the camera the result will be able to instantiate
  110465. * @param scene The scene the result will construct the camera in
  110466. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  110467. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  110468. * @returns a factory method to construc the camera
  110469. */
  110470. static GetConstructorFromName(type: string, name: string, scene: Scene, interaxial_distance?: number, isStereoscopicSideBySide?: boolean): () => Camera;
  110471. /**
  110472. * Compute the world matrix of the camera.
  110473. * @returns the camera world matrix
  110474. */
  110475. computeWorldMatrix(): Matrix;
  110476. /**
  110477. * Parse a JSON and creates the camera from the parsed information
  110478. * @param parsedCamera The JSON to parse
  110479. * @param scene The scene to instantiate the camera in
  110480. * @returns the newly constructed camera
  110481. */
  110482. static Parse(parsedCamera: any, scene: Scene): Camera;
  110483. }
  110484. }
  110485. declare module BABYLON {
  110486. /**
  110487. * Class containing static functions to help procedurally build meshes
  110488. */
  110489. export class DiscBuilder {
  110490. /**
  110491. * Creates a plane polygonal mesh. By default, this is a disc
  110492. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  110493. * * 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
  110494. * * 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
  110495. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  110496. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  110497. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  110498. * @param name defines the name of the mesh
  110499. * @param options defines the options used to create the mesh
  110500. * @param scene defines the hosting scene
  110501. * @returns the plane polygonal mesh
  110502. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  110503. */
  110504. static CreateDisc(name: string, options: {
  110505. radius?: number;
  110506. tessellation?: number;
  110507. arc?: number;
  110508. updatable?: boolean;
  110509. sideOrientation?: number;
  110510. frontUVs?: Vector4;
  110511. backUVs?: Vector4;
  110512. }, scene?: Nullable<Scene>): Mesh;
  110513. }
  110514. }
  110515. declare module BABYLON {
  110516. /**
  110517. * Options to be used when creating a FresnelParameters.
  110518. */
  110519. export type IFresnelParametersCreationOptions = {
  110520. /**
  110521. * Define the color used on edges (grazing angle)
  110522. */
  110523. leftColor?: Color3;
  110524. /**
  110525. * Define the color used on center
  110526. */
  110527. rightColor?: Color3;
  110528. /**
  110529. * Define bias applied to computed fresnel term
  110530. */
  110531. bias?: number;
  110532. /**
  110533. * Defined the power exponent applied to fresnel term
  110534. */
  110535. power?: number;
  110536. /**
  110537. * Define if the fresnel effect is enable or not.
  110538. */
  110539. isEnabled?: boolean;
  110540. };
  110541. /**
  110542. * Serialized format for FresnelParameters.
  110543. */
  110544. export type IFresnelParametersSerialized = {
  110545. /**
  110546. * Define the color used on edges (grazing angle) [as an array]
  110547. */
  110548. leftColor: number[];
  110549. /**
  110550. * Define the color used on center [as an array]
  110551. */
  110552. rightColor: number[];
  110553. /**
  110554. * Define bias applied to computed fresnel term
  110555. */
  110556. bias: number;
  110557. /**
  110558. * Defined the power exponent applied to fresnel term
  110559. */
  110560. power?: number;
  110561. /**
  110562. * Define if the fresnel effect is enable or not.
  110563. */
  110564. isEnabled: boolean;
  110565. };
  110566. /**
  110567. * This represents all the required information to add a fresnel effect on a material:
  110568. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  110569. */
  110570. export class FresnelParameters {
  110571. private _isEnabled;
  110572. /**
  110573. * Define if the fresnel effect is enable or not.
  110574. */
  110575. get isEnabled(): boolean;
  110576. set isEnabled(value: boolean);
  110577. /**
  110578. * Define the color used on edges (grazing angle)
  110579. */
  110580. leftColor: Color3;
  110581. /**
  110582. * Define the color used on center
  110583. */
  110584. rightColor: Color3;
  110585. /**
  110586. * Define bias applied to computed fresnel term
  110587. */
  110588. bias: number;
  110589. /**
  110590. * Defined the power exponent applied to fresnel term
  110591. */
  110592. power: number;
  110593. /**
  110594. * Creates a new FresnelParameters object.
  110595. *
  110596. * @param options provide your own settings to optionally to override defaults
  110597. */
  110598. constructor(options?: IFresnelParametersCreationOptions);
  110599. /**
  110600. * Clones the current fresnel and its valuues
  110601. * @returns a clone fresnel configuration
  110602. */
  110603. clone(): FresnelParameters;
  110604. /**
  110605. * Determines equality between FresnelParameters objects
  110606. * @param otherFresnelParameters defines the second operand
  110607. * @returns true if the power, bias, leftColor, rightColor and isEnabled values are equal to the given ones
  110608. */
  110609. equals(otherFresnelParameters: DeepImmutable<FresnelParameters>): boolean;
  110610. /**
  110611. * Serializes the current fresnel parameters to a JSON representation.
  110612. * @return the JSON serialization
  110613. */
  110614. serialize(): IFresnelParametersSerialized;
  110615. /**
  110616. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  110617. * @param parsedFresnelParameters Define the JSON representation
  110618. * @returns the parsed parameters
  110619. */
  110620. static Parse(parsedFresnelParameters: IFresnelParametersSerialized): FresnelParameters;
  110621. }
  110622. }
  110623. declare module BABYLON {
  110624. /**
  110625. * This groups all the flags used to control the materials channel.
  110626. */
  110627. export class MaterialFlags {
  110628. private static _DiffuseTextureEnabled;
  110629. /**
  110630. * Are diffuse textures enabled in the application.
  110631. */
  110632. static get DiffuseTextureEnabled(): boolean;
  110633. static set DiffuseTextureEnabled(value: boolean);
  110634. private static _DetailTextureEnabled;
  110635. /**
  110636. * Are detail textures enabled in the application.
  110637. */
  110638. static get DetailTextureEnabled(): boolean;
  110639. static set DetailTextureEnabled(value: boolean);
  110640. private static _AmbientTextureEnabled;
  110641. /**
  110642. * Are ambient textures enabled in the application.
  110643. */
  110644. static get AmbientTextureEnabled(): boolean;
  110645. static set AmbientTextureEnabled(value: boolean);
  110646. private static _OpacityTextureEnabled;
  110647. /**
  110648. * Are opacity textures enabled in the application.
  110649. */
  110650. static get OpacityTextureEnabled(): boolean;
  110651. static set OpacityTextureEnabled(value: boolean);
  110652. private static _ReflectionTextureEnabled;
  110653. /**
  110654. * Are reflection textures enabled in the application.
  110655. */
  110656. static get ReflectionTextureEnabled(): boolean;
  110657. static set ReflectionTextureEnabled(value: boolean);
  110658. private static _EmissiveTextureEnabled;
  110659. /**
  110660. * Are emissive textures enabled in the application.
  110661. */
  110662. static get EmissiveTextureEnabled(): boolean;
  110663. static set EmissiveTextureEnabled(value: boolean);
  110664. private static _SpecularTextureEnabled;
  110665. /**
  110666. * Are specular textures enabled in the application.
  110667. */
  110668. static get SpecularTextureEnabled(): boolean;
  110669. static set SpecularTextureEnabled(value: boolean);
  110670. private static _BumpTextureEnabled;
  110671. /**
  110672. * Are bump textures enabled in the application.
  110673. */
  110674. static get BumpTextureEnabled(): boolean;
  110675. static set BumpTextureEnabled(value: boolean);
  110676. private static _LightmapTextureEnabled;
  110677. /**
  110678. * Are lightmap textures enabled in the application.
  110679. */
  110680. static get LightmapTextureEnabled(): boolean;
  110681. static set LightmapTextureEnabled(value: boolean);
  110682. private static _RefractionTextureEnabled;
  110683. /**
  110684. * Are refraction textures enabled in the application.
  110685. */
  110686. static get RefractionTextureEnabled(): boolean;
  110687. static set RefractionTextureEnabled(value: boolean);
  110688. private static _ColorGradingTextureEnabled;
  110689. /**
  110690. * Are color grading textures enabled in the application.
  110691. */
  110692. static get ColorGradingTextureEnabled(): boolean;
  110693. static set ColorGradingTextureEnabled(value: boolean);
  110694. private static _FresnelEnabled;
  110695. /**
  110696. * Are fresnels enabled in the application.
  110697. */
  110698. static get FresnelEnabled(): boolean;
  110699. static set FresnelEnabled(value: boolean);
  110700. private static _ClearCoatTextureEnabled;
  110701. /**
  110702. * Are clear coat textures enabled in the application.
  110703. */
  110704. static get ClearCoatTextureEnabled(): boolean;
  110705. static set ClearCoatTextureEnabled(value: boolean);
  110706. private static _ClearCoatBumpTextureEnabled;
  110707. /**
  110708. * Are clear coat bump textures enabled in the application.
  110709. */
  110710. static get ClearCoatBumpTextureEnabled(): boolean;
  110711. static set ClearCoatBumpTextureEnabled(value: boolean);
  110712. private static _ClearCoatTintTextureEnabled;
  110713. /**
  110714. * Are clear coat tint textures enabled in the application.
  110715. */
  110716. static get ClearCoatTintTextureEnabled(): boolean;
  110717. static set ClearCoatTintTextureEnabled(value: boolean);
  110718. private static _SheenTextureEnabled;
  110719. /**
  110720. * Are sheen textures enabled in the application.
  110721. */
  110722. static get SheenTextureEnabled(): boolean;
  110723. static set SheenTextureEnabled(value: boolean);
  110724. private static _AnisotropicTextureEnabled;
  110725. /**
  110726. * Are anisotropic textures enabled in the application.
  110727. */
  110728. static get AnisotropicTextureEnabled(): boolean;
  110729. static set AnisotropicTextureEnabled(value: boolean);
  110730. private static _ThicknessTextureEnabled;
  110731. /**
  110732. * Are thickness textures enabled in the application.
  110733. */
  110734. static get ThicknessTextureEnabled(): boolean;
  110735. static set ThicknessTextureEnabled(value: boolean);
  110736. }
  110737. }
  110738. declare module BABYLON {
  110739. /** @hidden */
  110740. export var defaultFragmentDeclaration: {
  110741. name: string;
  110742. shader: string;
  110743. };
  110744. }
  110745. declare module BABYLON {
  110746. /** @hidden */
  110747. export var defaultUboDeclaration: {
  110748. name: string;
  110749. shader: string;
  110750. };
  110751. }
  110752. declare module BABYLON {
  110753. /** @hidden */
  110754. export var prePassDeclaration: {
  110755. name: string;
  110756. shader: string;
  110757. };
  110758. }
  110759. declare module BABYLON {
  110760. /** @hidden */
  110761. export var lightFragmentDeclaration: {
  110762. name: string;
  110763. shader: string;
  110764. };
  110765. }
  110766. declare module BABYLON {
  110767. /** @hidden */
  110768. export var lightUboDeclaration: {
  110769. name: string;
  110770. shader: string;
  110771. };
  110772. }
  110773. declare module BABYLON {
  110774. /** @hidden */
  110775. export var lightsFragmentFunctions: {
  110776. name: string;
  110777. shader: string;
  110778. };
  110779. }
  110780. declare module BABYLON {
  110781. /** @hidden */
  110782. export var shadowsFragmentFunctions: {
  110783. name: string;
  110784. shader: string;
  110785. };
  110786. }
  110787. declare module BABYLON {
  110788. /** @hidden */
  110789. export var fresnelFunction: {
  110790. name: string;
  110791. shader: string;
  110792. };
  110793. }
  110794. declare module BABYLON {
  110795. /** @hidden */
  110796. export var bumpFragmentMainFunctions: {
  110797. name: string;
  110798. shader: string;
  110799. };
  110800. }
  110801. declare module BABYLON {
  110802. /** @hidden */
  110803. export var bumpFragmentFunctions: {
  110804. name: string;
  110805. shader: string;
  110806. };
  110807. }
  110808. declare module BABYLON {
  110809. /** @hidden */
  110810. export var logDepthDeclaration: {
  110811. name: string;
  110812. shader: string;
  110813. };
  110814. }
  110815. declare module BABYLON {
  110816. /** @hidden */
  110817. export var bumpFragment: {
  110818. name: string;
  110819. shader: string;
  110820. };
  110821. }
  110822. declare module BABYLON {
  110823. /** @hidden */
  110824. export var depthPrePass: {
  110825. name: string;
  110826. shader: string;
  110827. };
  110828. }
  110829. declare module BABYLON {
  110830. /** @hidden */
  110831. export var lightFragment: {
  110832. name: string;
  110833. shader: string;
  110834. };
  110835. }
  110836. declare module BABYLON {
  110837. /** @hidden */
  110838. export var logDepthFragment: {
  110839. name: string;
  110840. shader: string;
  110841. };
  110842. }
  110843. declare module BABYLON {
  110844. /** @hidden */
  110845. export var defaultPixelShader: {
  110846. name: string;
  110847. shader: string;
  110848. };
  110849. }
  110850. declare module BABYLON {
  110851. /** @hidden */
  110852. export var defaultVertexDeclaration: {
  110853. name: string;
  110854. shader: string;
  110855. };
  110856. }
  110857. declare module BABYLON {
  110858. /** @hidden */
  110859. export var prePassVertexDeclaration: {
  110860. name: string;
  110861. shader: string;
  110862. };
  110863. }
  110864. declare module BABYLON {
  110865. /** @hidden */
  110866. export var bumpVertexDeclaration: {
  110867. name: string;
  110868. shader: string;
  110869. };
  110870. }
  110871. declare module BABYLON {
  110872. /** @hidden */
  110873. export var prePassVertex: {
  110874. name: string;
  110875. shader: string;
  110876. };
  110877. }
  110878. declare module BABYLON {
  110879. /** @hidden */
  110880. export var bumpVertex: {
  110881. name: string;
  110882. shader: string;
  110883. };
  110884. }
  110885. declare module BABYLON {
  110886. /** @hidden */
  110887. export var fogVertex: {
  110888. name: string;
  110889. shader: string;
  110890. };
  110891. }
  110892. declare module BABYLON {
  110893. /** @hidden */
  110894. export var shadowsVertex: {
  110895. name: string;
  110896. shader: string;
  110897. };
  110898. }
  110899. declare module BABYLON {
  110900. /** @hidden */
  110901. export var pointCloudVertex: {
  110902. name: string;
  110903. shader: string;
  110904. };
  110905. }
  110906. declare module BABYLON {
  110907. /** @hidden */
  110908. export var logDepthVertex: {
  110909. name: string;
  110910. shader: string;
  110911. };
  110912. }
  110913. declare module BABYLON {
  110914. /** @hidden */
  110915. export var defaultVertexShader: {
  110916. name: string;
  110917. shader: string;
  110918. };
  110919. }
  110920. declare module BABYLON {
  110921. /**
  110922. * @hidden
  110923. */
  110924. export interface IMaterialDetailMapDefines {
  110925. DETAIL: boolean;
  110926. DETAILDIRECTUV: number;
  110927. DETAIL_NORMALBLENDMETHOD: number;
  110928. /** @hidden */
  110929. _areTexturesDirty: boolean;
  110930. }
  110931. /**
  110932. * Define the code related to the detail map parameters of a material
  110933. *
  110934. * Inspired from:
  110935. * 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
  110936. * Unreal: https://docs.unrealengine.com/en-US/Engine/Rendering/Materials/HowTo/DetailTexturing/index.html
  110937. * Cryengine: https://docs.cryengine.com/display/SDKDOC2/Detail+Maps
  110938. */
  110939. export class DetailMapConfiguration {
  110940. private _texture;
  110941. /**
  110942. * The detail texture of the material.
  110943. */
  110944. texture: Nullable<BaseTexture>;
  110945. /**
  110946. * Defines how strongly the detail diffuse/albedo channel is blended with the regular diffuse/albedo texture
  110947. * Bigger values mean stronger blending
  110948. */
  110949. diffuseBlendLevel: number;
  110950. /**
  110951. * Defines how strongly the detail roughness channel is blended with the regular roughness value
  110952. * Bigger values mean stronger blending. Only used with PBR materials
  110953. */
  110954. roughnessBlendLevel: number;
  110955. /**
  110956. * Defines how strong the bump effect from the detail map is
  110957. * Bigger values mean stronger effect
  110958. */
  110959. bumpLevel: number;
  110960. private _normalBlendMethod;
  110961. /**
  110962. * The method used to blend the bump and detail normals together
  110963. */
  110964. normalBlendMethod: number;
  110965. private _isEnabled;
  110966. /**
  110967. * Enable or disable the detail map on this material
  110968. */
  110969. isEnabled: boolean;
  110970. /** @hidden */
  110971. private _internalMarkAllSubMeshesAsTexturesDirty;
  110972. /** @hidden */
  110973. _markAllSubMeshesAsTexturesDirty(): void;
  110974. /**
  110975. * Instantiate a new detail map
  110976. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  110977. */
  110978. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  110979. /**
  110980. * Gets whether the submesh is ready to be used or not.
  110981. * @param defines the list of "defines" to update.
  110982. * @param scene defines the scene the material belongs to.
  110983. * @returns - boolean indicating that the submesh is ready or not.
  110984. */
  110985. isReadyForSubMesh(defines: IMaterialDetailMapDefines, scene: Scene): boolean;
  110986. /**
  110987. * Update the defines for detail map usage
  110988. * @param defines the list of "defines" to update.
  110989. * @param scene defines the scene the material belongs to.
  110990. */
  110991. prepareDefines(defines: IMaterialDetailMapDefines, scene: Scene): void;
  110992. /**
  110993. * Binds the material data.
  110994. * @param uniformBuffer defines the Uniform buffer to fill in.
  110995. * @param scene defines the scene the material belongs to.
  110996. * @param isFrozen defines whether the material is frozen or not.
  110997. */
  110998. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  110999. /**
  111000. * Checks to see if a texture is used in the material.
  111001. * @param texture - Base texture to use.
  111002. * @returns - Boolean specifying if a texture is used in the material.
  111003. */
  111004. hasTexture(texture: BaseTexture): boolean;
  111005. /**
  111006. * Returns an array of the actively used textures.
  111007. * @param activeTextures Array of BaseTextures
  111008. */
  111009. getActiveTextures(activeTextures: BaseTexture[]): void;
  111010. /**
  111011. * Returns the animatable textures.
  111012. * @param animatables Array of animatable textures.
  111013. */
  111014. getAnimatables(animatables: IAnimatable[]): void;
  111015. /**
  111016. * Disposes the resources of the material.
  111017. * @param forceDisposeTextures - Forces the disposal of all textures.
  111018. */
  111019. dispose(forceDisposeTextures?: boolean): void;
  111020. /**
  111021. * Get the current class name useful for serialization or dynamic coding.
  111022. * @returns "DetailMap"
  111023. */
  111024. getClassName(): string;
  111025. /**
  111026. * Add the required uniforms to the current list.
  111027. * @param uniforms defines the current uniform list.
  111028. */
  111029. static AddUniforms(uniforms: string[]): void;
  111030. /**
  111031. * Add the required samplers to the current list.
  111032. * @param samplers defines the current sampler list.
  111033. */
  111034. static AddSamplers(samplers: string[]): void;
  111035. /**
  111036. * Add the required uniforms to the current buffer.
  111037. * @param uniformBuffer defines the current uniform buffer.
  111038. */
  111039. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  111040. /**
  111041. * Makes a duplicate of the current instance into another one.
  111042. * @param detailMap define the instance where to copy the info
  111043. */
  111044. copyTo(detailMap: DetailMapConfiguration): void;
  111045. /**
  111046. * Serializes this detail map instance
  111047. * @returns - An object with the serialized instance.
  111048. */
  111049. serialize(): any;
  111050. /**
  111051. * Parses a detail map setting from a serialized object.
  111052. * @param source - Serialized object.
  111053. * @param scene Defines the scene we are parsing for
  111054. * @param rootUrl Defines the rootUrl to load from
  111055. */
  111056. parse(source: any, scene: Scene, rootUrl: string): void;
  111057. }
  111058. }
  111059. declare module BABYLON {
  111060. /** @hidden */
  111061. export class StandardMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialDetailMapDefines {
  111062. MAINUV1: boolean;
  111063. MAINUV2: boolean;
  111064. DIFFUSE: boolean;
  111065. DIFFUSEDIRECTUV: number;
  111066. DETAIL: boolean;
  111067. DETAILDIRECTUV: number;
  111068. DETAIL_NORMALBLENDMETHOD: number;
  111069. AMBIENT: boolean;
  111070. AMBIENTDIRECTUV: number;
  111071. OPACITY: boolean;
  111072. OPACITYDIRECTUV: number;
  111073. OPACITYRGB: boolean;
  111074. REFLECTION: boolean;
  111075. EMISSIVE: boolean;
  111076. EMISSIVEDIRECTUV: number;
  111077. SPECULAR: boolean;
  111078. SPECULARDIRECTUV: number;
  111079. BUMP: boolean;
  111080. BUMPDIRECTUV: number;
  111081. PARALLAX: boolean;
  111082. PARALLAXOCCLUSION: boolean;
  111083. SPECULAROVERALPHA: boolean;
  111084. CLIPPLANE: boolean;
  111085. CLIPPLANE2: boolean;
  111086. CLIPPLANE3: boolean;
  111087. CLIPPLANE4: boolean;
  111088. CLIPPLANE5: boolean;
  111089. CLIPPLANE6: boolean;
  111090. ALPHATEST: boolean;
  111091. DEPTHPREPASS: boolean;
  111092. ALPHAFROMDIFFUSE: boolean;
  111093. POINTSIZE: boolean;
  111094. FOG: boolean;
  111095. SPECULARTERM: boolean;
  111096. DIFFUSEFRESNEL: boolean;
  111097. OPACITYFRESNEL: boolean;
  111098. REFLECTIONFRESNEL: boolean;
  111099. REFRACTIONFRESNEL: boolean;
  111100. EMISSIVEFRESNEL: boolean;
  111101. FRESNEL: boolean;
  111102. NORMAL: boolean;
  111103. UV1: boolean;
  111104. UV2: boolean;
  111105. VERTEXCOLOR: boolean;
  111106. VERTEXALPHA: boolean;
  111107. NUM_BONE_INFLUENCERS: number;
  111108. BonesPerMesh: number;
  111109. BONETEXTURE: boolean;
  111110. BONES_VELOCITY_ENABLED: boolean;
  111111. INSTANCES: boolean;
  111112. THIN_INSTANCES: boolean;
  111113. GLOSSINESS: boolean;
  111114. ROUGHNESS: boolean;
  111115. EMISSIVEASILLUMINATION: boolean;
  111116. LINKEMISSIVEWITHDIFFUSE: boolean;
  111117. REFLECTIONFRESNELFROMSPECULAR: boolean;
  111118. LIGHTMAP: boolean;
  111119. LIGHTMAPDIRECTUV: number;
  111120. OBJECTSPACE_NORMALMAP: boolean;
  111121. USELIGHTMAPASSHADOWMAP: boolean;
  111122. REFLECTIONMAP_3D: boolean;
  111123. REFLECTIONMAP_SPHERICAL: boolean;
  111124. REFLECTIONMAP_PLANAR: boolean;
  111125. REFLECTIONMAP_CUBIC: boolean;
  111126. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  111127. REFLECTIONMAP_PROJECTION: boolean;
  111128. REFLECTIONMAP_SKYBOX: boolean;
  111129. REFLECTIONMAP_EXPLICIT: boolean;
  111130. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  111131. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  111132. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  111133. INVERTCUBICMAP: boolean;
  111134. LOGARITHMICDEPTH: boolean;
  111135. REFRACTION: boolean;
  111136. REFRACTIONMAP_3D: boolean;
  111137. REFLECTIONOVERALPHA: boolean;
  111138. TWOSIDEDLIGHTING: boolean;
  111139. SHADOWFLOAT: boolean;
  111140. MORPHTARGETS: boolean;
  111141. MORPHTARGETS_NORMAL: boolean;
  111142. MORPHTARGETS_TANGENT: boolean;
  111143. MORPHTARGETS_UV: boolean;
  111144. NUM_MORPH_INFLUENCERS: number;
  111145. NONUNIFORMSCALING: boolean;
  111146. PREMULTIPLYALPHA: boolean;
  111147. ALPHATEST_AFTERALLALPHACOMPUTATIONS: boolean;
  111148. ALPHABLEND: boolean;
  111149. PREPASS: boolean;
  111150. PREPASS_IRRADIANCE: boolean;
  111151. PREPASS_IRRADIANCE_INDEX: number;
  111152. PREPASS_ALBEDO: boolean;
  111153. PREPASS_ALBEDO_INDEX: number;
  111154. PREPASS_DEPTHNORMAL: boolean;
  111155. PREPASS_DEPTHNORMAL_INDEX: number;
  111156. PREPASS_POSITION: boolean;
  111157. PREPASS_POSITION_INDEX: number;
  111158. PREPASS_VELOCITY: boolean;
  111159. PREPASS_VELOCITY_INDEX: number;
  111160. PREPASS_REFLECTIVITY: boolean;
  111161. PREPASS_REFLECTIVITY_INDEX: number;
  111162. SCENE_MRT_COUNT: number;
  111163. RGBDLIGHTMAP: boolean;
  111164. RGBDREFLECTION: boolean;
  111165. RGBDREFRACTION: boolean;
  111166. IMAGEPROCESSING: boolean;
  111167. VIGNETTE: boolean;
  111168. VIGNETTEBLENDMODEMULTIPLY: boolean;
  111169. VIGNETTEBLENDMODEOPAQUE: boolean;
  111170. TONEMAPPING: boolean;
  111171. TONEMAPPING_ACES: boolean;
  111172. CONTRAST: boolean;
  111173. COLORCURVES: boolean;
  111174. COLORGRADING: boolean;
  111175. COLORGRADING3D: boolean;
  111176. SAMPLER3DGREENDEPTH: boolean;
  111177. SAMPLER3DBGRMAP: boolean;
  111178. IMAGEPROCESSINGPOSTPROCESS: boolean;
  111179. MULTIVIEW: boolean;
  111180. /**
  111181. * If the reflection texture on this material is in linear color space
  111182. * @hidden
  111183. */
  111184. IS_REFLECTION_LINEAR: boolean;
  111185. /**
  111186. * If the refraction texture on this material is in linear color space
  111187. * @hidden
  111188. */
  111189. IS_REFRACTION_LINEAR: boolean;
  111190. EXPOSURE: boolean;
  111191. constructor();
  111192. setReflectionMode(modeToEnable: string): void;
  111193. }
  111194. /**
  111195. * This is the default material used in Babylon. It is the best trade off between quality
  111196. * and performances.
  111197. * @see https://doc.babylonjs.com/babylon101/materials
  111198. */
  111199. export class StandardMaterial extends PushMaterial {
  111200. private _diffuseTexture;
  111201. /**
  111202. * The basic texture of the material as viewed under a light.
  111203. */
  111204. diffuseTexture: Nullable<BaseTexture>;
  111205. private _ambientTexture;
  111206. /**
  111207. * AKA Occlusion Texture in other nomenclature, it helps adding baked shadows into your material.
  111208. */
  111209. ambientTexture: Nullable<BaseTexture>;
  111210. private _opacityTexture;
  111211. /**
  111212. * Define the transparency of the material from a texture.
  111213. * The final alpha value can be read either from the red channel (if texture.getAlphaFromRGB is false)
  111214. * or from the luminance or the current texel (if texture.getAlphaFromRGB is true)
  111215. */
  111216. opacityTexture: Nullable<BaseTexture>;
  111217. private _reflectionTexture;
  111218. /**
  111219. * Define the texture used to display the reflection.
  111220. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111221. */
  111222. reflectionTexture: Nullable<BaseTexture>;
  111223. private _emissiveTexture;
  111224. /**
  111225. * Define texture of the material as if self lit.
  111226. * This will be mixed in the final result even in the absence of light.
  111227. */
  111228. emissiveTexture: Nullable<BaseTexture>;
  111229. private _specularTexture;
  111230. /**
  111231. * Define how the color and intensity of the highlight given by the light in the material.
  111232. */
  111233. specularTexture: Nullable<BaseTexture>;
  111234. private _bumpTexture;
  111235. /**
  111236. * Bump mapping is a technique to simulate bump and dents on a rendered surface.
  111237. * 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.
  111238. * @see https://doc.babylonjs.com/how_to/more_materials#bump-map
  111239. */
  111240. bumpTexture: Nullable<BaseTexture>;
  111241. private _lightmapTexture;
  111242. /**
  111243. * Complex lighting can be computationally expensive to compute at runtime.
  111244. * To save on computation, lightmaps may be used to store calculated lighting in a texture which will be applied to a given mesh.
  111245. * @see https://doc.babylonjs.com/babylon101/lights#lightmaps
  111246. */
  111247. lightmapTexture: Nullable<BaseTexture>;
  111248. private _refractionTexture;
  111249. /**
  111250. * Define the texture used to display the refraction.
  111251. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111252. */
  111253. refractionTexture: Nullable<BaseTexture>;
  111254. /**
  111255. * The color of the material lit by the environmental background lighting.
  111256. * @see https://doc.babylonjs.com/babylon101/materials#ambient-color-example
  111257. */
  111258. ambientColor: Color3;
  111259. /**
  111260. * The basic color of the material as viewed under a light.
  111261. */
  111262. diffuseColor: Color3;
  111263. /**
  111264. * Define how the color and intensity of the highlight given by the light in the material.
  111265. */
  111266. specularColor: Color3;
  111267. /**
  111268. * Define the color of the material as if self lit.
  111269. * This will be mixed in the final result even in the absence of light.
  111270. */
  111271. emissiveColor: Color3;
  111272. /**
  111273. * Defines how sharp are the highlights in the material.
  111274. * The bigger the value the sharper giving a more glossy feeling to the result.
  111275. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  111276. */
  111277. specularPower: number;
  111278. private _useAlphaFromDiffuseTexture;
  111279. /**
  111280. * Does the transparency come from the diffuse texture alpha channel.
  111281. */
  111282. useAlphaFromDiffuseTexture: boolean;
  111283. private _useEmissiveAsIllumination;
  111284. /**
  111285. * If true, the emissive value is added into the end result, otherwise it is multiplied in.
  111286. */
  111287. useEmissiveAsIllumination: boolean;
  111288. private _linkEmissiveWithDiffuse;
  111289. /**
  111290. * If true, some kind of energy conservation will prevent the end result to be more than 1 by reducing
  111291. * the emissive level when the final color is close to one.
  111292. */
  111293. linkEmissiveWithDiffuse: boolean;
  111294. private _useSpecularOverAlpha;
  111295. /**
  111296. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  111297. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  111298. */
  111299. useSpecularOverAlpha: boolean;
  111300. private _useReflectionOverAlpha;
  111301. /**
  111302. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  111303. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  111304. */
  111305. useReflectionOverAlpha: boolean;
  111306. private _disableLighting;
  111307. /**
  111308. * Does lights from the scene impacts this material.
  111309. * It can be a nice trick for performance to disable lighting on a fully emissive material.
  111310. */
  111311. disableLighting: boolean;
  111312. private _useObjectSpaceNormalMap;
  111313. /**
  111314. * Allows using an object space normal map (instead of tangent space).
  111315. */
  111316. useObjectSpaceNormalMap: boolean;
  111317. private _useParallax;
  111318. /**
  111319. * Is parallax enabled or not.
  111320. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111321. */
  111322. useParallax: boolean;
  111323. private _useParallaxOcclusion;
  111324. /**
  111325. * Is parallax occlusion enabled or not.
  111326. * If true, the outcome is way more realistic than traditional Parallax but you can expect a performance hit that worthes consideration.
  111327. * @see https://doc.babylonjs.com/how_to/using_parallax_mapping
  111328. */
  111329. useParallaxOcclusion: boolean;
  111330. /**
  111331. * 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.
  111332. */
  111333. parallaxScaleBias: number;
  111334. private _roughness;
  111335. /**
  111336. * Helps to define how blurry the reflections should appears in the material.
  111337. */
  111338. roughness: number;
  111339. /**
  111340. * In case of refraction, define the value of the index of refraction.
  111341. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111342. */
  111343. indexOfRefraction: number;
  111344. /**
  111345. * Invert the refraction texture alongside the y axis.
  111346. * It can be useful with procedural textures or probe for instance.
  111347. * @see https://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  111348. */
  111349. invertRefractionY: boolean;
  111350. /**
  111351. * Defines the alpha limits in alpha test mode.
  111352. */
  111353. alphaCutOff: number;
  111354. private _useLightmapAsShadowmap;
  111355. /**
  111356. * In case of light mapping, define whether the map contains light or shadow informations.
  111357. */
  111358. useLightmapAsShadowmap: boolean;
  111359. private _diffuseFresnelParameters;
  111360. /**
  111361. * Define the diffuse fresnel parameters of the material.
  111362. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111363. */
  111364. diffuseFresnelParameters: FresnelParameters;
  111365. private _opacityFresnelParameters;
  111366. /**
  111367. * Define the opacity fresnel parameters of the material.
  111368. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111369. */
  111370. opacityFresnelParameters: FresnelParameters;
  111371. private _reflectionFresnelParameters;
  111372. /**
  111373. * Define the reflection fresnel parameters of the material.
  111374. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111375. */
  111376. reflectionFresnelParameters: FresnelParameters;
  111377. private _refractionFresnelParameters;
  111378. /**
  111379. * Define the refraction fresnel parameters of the material.
  111380. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111381. */
  111382. refractionFresnelParameters: FresnelParameters;
  111383. private _emissiveFresnelParameters;
  111384. /**
  111385. * Define the emissive fresnel parameters of the material.
  111386. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111387. */
  111388. emissiveFresnelParameters: FresnelParameters;
  111389. private _useReflectionFresnelFromSpecular;
  111390. /**
  111391. * If true automatically deducts the fresnels values from the material specularity.
  111392. * @see https://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  111393. */
  111394. useReflectionFresnelFromSpecular: boolean;
  111395. private _useGlossinessFromSpecularMapAlpha;
  111396. /**
  111397. * Defines if the glossiness/roughness of the material should be read from the specular map alpha channel
  111398. */
  111399. useGlossinessFromSpecularMapAlpha: boolean;
  111400. private _maxSimultaneousLights;
  111401. /**
  111402. * Defines the maximum number of lights that can be used in the material
  111403. */
  111404. maxSimultaneousLights: number;
  111405. private _invertNormalMapX;
  111406. /**
  111407. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  111408. */
  111409. invertNormalMapX: boolean;
  111410. private _invertNormalMapY;
  111411. /**
  111412. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  111413. */
  111414. invertNormalMapY: boolean;
  111415. private _twoSidedLighting;
  111416. /**
  111417. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  111418. */
  111419. twoSidedLighting: boolean;
  111420. /**
  111421. * Default configuration related to image processing available in the standard Material.
  111422. */
  111423. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  111424. /**
  111425. * Gets the image processing configuration used either in this material.
  111426. */
  111427. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  111428. /**
  111429. * Sets the Default image processing configuration used either in the this material.
  111430. *
  111431. * If sets to null, the scene one is in use.
  111432. */
  111433. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  111434. /**
  111435. * Keep track of the image processing observer to allow dispose and replace.
  111436. */
  111437. private _imageProcessingObserver;
  111438. /**
  111439. * Attaches a new image processing configuration to the Standard Material.
  111440. * @param configuration
  111441. */
  111442. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  111443. /**
  111444. * Defines additionnal PrePass parameters for the material.
  111445. */
  111446. readonly prePassConfiguration: PrePassConfiguration;
  111447. /**
  111448. * Gets wether the color curves effect is enabled.
  111449. */
  111450. get cameraColorCurvesEnabled(): boolean;
  111451. /**
  111452. * Sets wether the color curves effect is enabled.
  111453. */
  111454. set cameraColorCurvesEnabled(value: boolean);
  111455. /**
  111456. * Gets wether the color grading effect is enabled.
  111457. */
  111458. get cameraColorGradingEnabled(): boolean;
  111459. /**
  111460. * Gets wether the color grading effect is enabled.
  111461. */
  111462. set cameraColorGradingEnabled(value: boolean);
  111463. /**
  111464. * Gets wether tonemapping is enabled or not.
  111465. */
  111466. get cameraToneMappingEnabled(): boolean;
  111467. /**
  111468. * Sets wether tonemapping is enabled or not
  111469. */
  111470. set cameraToneMappingEnabled(value: boolean);
  111471. /**
  111472. * The camera exposure used on this material.
  111473. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111474. * This corresponds to a photographic exposure.
  111475. */
  111476. get cameraExposure(): number;
  111477. /**
  111478. * The camera exposure used on this material.
  111479. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  111480. * This corresponds to a photographic exposure.
  111481. */
  111482. set cameraExposure(value: number);
  111483. /**
  111484. * Gets The camera contrast used on this material.
  111485. */
  111486. get cameraContrast(): number;
  111487. /**
  111488. * Sets The camera contrast used on this material.
  111489. */
  111490. set cameraContrast(value: number);
  111491. /**
  111492. * Gets the Color Grading 2D Lookup Texture.
  111493. */
  111494. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  111495. /**
  111496. * Sets the Color Grading 2D Lookup Texture.
  111497. */
  111498. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  111499. /**
  111500. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111501. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111502. * 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;
  111503. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111504. */
  111505. get cameraColorCurves(): Nullable<ColorCurves>;
  111506. /**
  111507. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  111508. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  111509. * 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;
  111510. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  111511. */
  111512. set cameraColorCurves(value: Nullable<ColorCurves>);
  111513. /**
  111514. * Can this material render to several textures at once
  111515. */
  111516. get canRenderToMRT(): boolean;
  111517. /**
  111518. * Defines the detail map parameters for the material.
  111519. */
  111520. readonly detailMap: DetailMapConfiguration;
  111521. protected _renderTargets: SmartArray<RenderTargetTexture>;
  111522. protected _worldViewProjectionMatrix: Matrix;
  111523. protected _globalAmbientColor: Color3;
  111524. protected _useLogarithmicDepth: boolean;
  111525. protected _rebuildInParallel: boolean;
  111526. /**
  111527. * Instantiates a new standard material.
  111528. * This is the default material used in Babylon. It is the best trade off between quality
  111529. * and performances.
  111530. * @see https://doc.babylonjs.com/babylon101/materials
  111531. * @param name Define the name of the material in the scene
  111532. * @param scene Define the scene the material belong to
  111533. */
  111534. constructor(name: string, scene: Scene);
  111535. /**
  111536. * Gets a boolean indicating that current material needs to register RTT
  111537. */
  111538. get hasRenderTargetTextures(): boolean;
  111539. /**
  111540. * Gets the current class name of the material e.g. "StandardMaterial"
  111541. * Mainly use in serialization.
  111542. * @returns the class name
  111543. */
  111544. getClassName(): string;
  111545. /**
  111546. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  111547. * You can try switching to logarithmic depth.
  111548. * @see https://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  111549. */
  111550. get useLogarithmicDepth(): boolean;
  111551. set useLogarithmicDepth(value: boolean);
  111552. /**
  111553. * Specifies if the material will require alpha blending
  111554. * @returns a boolean specifying if alpha blending is needed
  111555. */
  111556. needAlphaBlending(): boolean;
  111557. /**
  111558. * Specifies if this material should be rendered in alpha test mode
  111559. * @returns a boolean specifying if an alpha test is needed.
  111560. */
  111561. needAlphaTesting(): boolean;
  111562. protected _shouldUseAlphaFromDiffuseTexture(): boolean;
  111563. /**
  111564. * Get the texture used for alpha test purpose.
  111565. * @returns the diffuse texture in case of the standard material.
  111566. */
  111567. getAlphaTestTexture(): Nullable<BaseTexture>;
  111568. /**
  111569. * Get if the submesh is ready to be used and all its information available.
  111570. * Child classes can use it to update shaders
  111571. * @param mesh defines the mesh to check
  111572. * @param subMesh defines which submesh to check
  111573. * @param useInstances specifies that instances should be used
  111574. * @returns a boolean indicating that the submesh is ready or not
  111575. */
  111576. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  111577. /**
  111578. * Builds the material UBO layouts.
  111579. * Used internally during the effect preparation.
  111580. */
  111581. buildUniformLayout(): void;
  111582. /**
  111583. * Unbinds the material from the mesh
  111584. */
  111585. unbind(): void;
  111586. /**
  111587. * Binds the submesh to this material by preparing the effect and shader to draw
  111588. * @param world defines the world transformation matrix
  111589. * @param mesh defines the mesh containing the submesh
  111590. * @param subMesh defines the submesh to bind the material to
  111591. */
  111592. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  111593. /**
  111594. * Get the list of animatables in the material.
  111595. * @returns the list of animatables object used in the material
  111596. */
  111597. getAnimatables(): IAnimatable[];
  111598. /**
  111599. * Gets the active textures from the material
  111600. * @returns an array of textures
  111601. */
  111602. getActiveTextures(): BaseTexture[];
  111603. /**
  111604. * Specifies if the material uses a texture
  111605. * @param texture defines the texture to check against the material
  111606. * @returns a boolean specifying if the material uses the texture
  111607. */
  111608. hasTexture(texture: BaseTexture): boolean;
  111609. /**
  111610. * Disposes the material
  111611. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  111612. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  111613. */
  111614. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  111615. /**
  111616. * Makes a duplicate of the material, and gives it a new name
  111617. * @param name defines the new name for the duplicated material
  111618. * @returns the cloned material
  111619. */
  111620. clone(name: string): StandardMaterial;
  111621. /**
  111622. * Serializes this material in a JSON representation
  111623. * @returns the serialized material object
  111624. */
  111625. serialize(): any;
  111626. /**
  111627. * Creates a standard material from parsed material data
  111628. * @param source defines the JSON representation of the material
  111629. * @param scene defines the hosting scene
  111630. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  111631. * @returns a new standard material
  111632. */
  111633. static Parse(source: any, scene: Scene, rootUrl: string): StandardMaterial;
  111634. /**
  111635. * Are diffuse textures enabled in the application.
  111636. */
  111637. static get DiffuseTextureEnabled(): boolean;
  111638. static set DiffuseTextureEnabled(value: boolean);
  111639. /**
  111640. * Are detail textures enabled in the application.
  111641. */
  111642. static get DetailTextureEnabled(): boolean;
  111643. static set DetailTextureEnabled(value: boolean);
  111644. /**
  111645. * Are ambient textures enabled in the application.
  111646. */
  111647. static get AmbientTextureEnabled(): boolean;
  111648. static set AmbientTextureEnabled(value: boolean);
  111649. /**
  111650. * Are opacity textures enabled in the application.
  111651. */
  111652. static get OpacityTextureEnabled(): boolean;
  111653. static set OpacityTextureEnabled(value: boolean);
  111654. /**
  111655. * Are reflection textures enabled in the application.
  111656. */
  111657. static get ReflectionTextureEnabled(): boolean;
  111658. static set ReflectionTextureEnabled(value: boolean);
  111659. /**
  111660. * Are emissive textures enabled in the application.
  111661. */
  111662. static get EmissiveTextureEnabled(): boolean;
  111663. static set EmissiveTextureEnabled(value: boolean);
  111664. /**
  111665. * Are specular textures enabled in the application.
  111666. */
  111667. static get SpecularTextureEnabled(): boolean;
  111668. static set SpecularTextureEnabled(value: boolean);
  111669. /**
  111670. * Are bump textures enabled in the application.
  111671. */
  111672. static get BumpTextureEnabled(): boolean;
  111673. static set BumpTextureEnabled(value: boolean);
  111674. /**
  111675. * Are lightmap textures enabled in the application.
  111676. */
  111677. static get LightmapTextureEnabled(): boolean;
  111678. static set LightmapTextureEnabled(value: boolean);
  111679. /**
  111680. * Are refraction textures enabled in the application.
  111681. */
  111682. static get RefractionTextureEnabled(): boolean;
  111683. static set RefractionTextureEnabled(value: boolean);
  111684. /**
  111685. * Are color grading textures enabled in the application.
  111686. */
  111687. static get ColorGradingTextureEnabled(): boolean;
  111688. static set ColorGradingTextureEnabled(value: boolean);
  111689. /**
  111690. * Are fresnels enabled in the application.
  111691. */
  111692. static get FresnelEnabled(): boolean;
  111693. static set FresnelEnabled(value: boolean);
  111694. }
  111695. }
  111696. declare module BABYLON {
  111697. /**
  111698. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  111699. *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.
  111700. * The SPS is also a particle system. It provides some methods to manage the particles.
  111701. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  111702. *
  111703. * Full documentation here : https://doc.babylonjs.com/how_to/Solid_Particle_System
  111704. */
  111705. export class SolidParticleSystem implements IDisposable {
  111706. /**
  111707. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  111708. * Example : var p = SPS.particles[i];
  111709. */
  111710. particles: SolidParticle[];
  111711. /**
  111712. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  111713. */
  111714. nbParticles: number;
  111715. /**
  111716. * If the particles must ever face the camera (default false). Useful for planar particles.
  111717. */
  111718. billboard: boolean;
  111719. /**
  111720. * Recompute normals when adding a shape
  111721. */
  111722. recomputeNormals: boolean;
  111723. /**
  111724. * This a counter ofr your own usage. It's not set by any SPS functions.
  111725. */
  111726. counter: number;
  111727. /**
  111728. * The SPS name. This name is also given to the underlying mesh.
  111729. */
  111730. name: string;
  111731. /**
  111732. * The SPS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  111733. */
  111734. mesh: Mesh;
  111735. /**
  111736. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  111737. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#garbage-collector-concerns
  111738. */
  111739. vars: any;
  111740. /**
  111741. * This array is populated when the SPS is set as 'pickable'.
  111742. * Each key of this array is a `faceId` value that you can get from a pickResult object.
  111743. * Each element of this array is an object `{idx: int, faceId: int}`.
  111744. * `idx` is the picked particle index in the `SPS.particles` array
  111745. * `faceId` is the picked face index counted within this particle.
  111746. * This array is the first element of the pickedBySubMesh array : sps.pickBySubMesh[0].
  111747. * It's not pertinent to use it when using a SPS with the support for MultiMaterial enabled.
  111748. * Use the method SPS.pickedParticle(pickingInfo) instead.
  111749. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111750. */
  111751. pickedParticles: {
  111752. idx: number;
  111753. faceId: number;
  111754. }[];
  111755. /**
  111756. * This array is populated when the SPS is set as 'pickable'
  111757. * Each key of this array is a submesh index.
  111758. * Each element of this array is a second array defined like this :
  111759. * Each key of this second array is a `faceId` value that you can get from a pickResult object.
  111760. * Each element of this second array is an object `{idx: int, faceId: int}`.
  111761. * `idx` is the picked particle index in the `SPS.particles` array
  111762. * `faceId` is the picked face index counted within this particle.
  111763. * It's better to use the method SPS.pickedParticle(pickingInfo) rather than using directly this array.
  111764. * Please read : https://doc.babylonjs.com/how_to/Solid_Particle_System#pickable-particles
  111765. */
  111766. pickedBySubMesh: {
  111767. idx: number;
  111768. faceId: number;
  111769. }[][];
  111770. /**
  111771. * This array is populated when `enableDepthSort` is set to true.
  111772. * Each element of this array is an instance of the class DepthSortedParticle.
  111773. */
  111774. depthSortedParticles: DepthSortedParticle[];
  111775. /**
  111776. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  111777. * @hidden
  111778. */
  111779. _bSphereOnly: boolean;
  111780. /**
  111781. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  111782. * @hidden
  111783. */
  111784. _bSphereRadiusFactor: number;
  111785. private _scene;
  111786. private _positions;
  111787. private _indices;
  111788. private _normals;
  111789. private _colors;
  111790. private _uvs;
  111791. private _indices32;
  111792. private _positions32;
  111793. private _normals32;
  111794. private _fixedNormal32;
  111795. private _colors32;
  111796. private _uvs32;
  111797. private _index;
  111798. private _updatable;
  111799. private _pickable;
  111800. private _isVisibilityBoxLocked;
  111801. private _alwaysVisible;
  111802. private _depthSort;
  111803. private _expandable;
  111804. private _shapeCounter;
  111805. private _copy;
  111806. private _color;
  111807. private _computeParticleColor;
  111808. private _computeParticleTexture;
  111809. private _computeParticleRotation;
  111810. private _computeParticleVertex;
  111811. private _computeBoundingBox;
  111812. private _depthSortParticles;
  111813. private _camera;
  111814. private _mustUnrotateFixedNormals;
  111815. private _particlesIntersect;
  111816. private _needs32Bits;
  111817. private _isNotBuilt;
  111818. private _lastParticleId;
  111819. private _idxOfId;
  111820. private _multimaterialEnabled;
  111821. private _useModelMaterial;
  111822. private _indicesByMaterial;
  111823. private _materialIndexes;
  111824. private _depthSortFunction;
  111825. private _materialSortFunction;
  111826. private _materials;
  111827. private _multimaterial;
  111828. private _materialIndexesById;
  111829. private _defaultMaterial;
  111830. private _autoUpdateSubMeshes;
  111831. private _tmpVertex;
  111832. /**
  111833. * Creates a SPS (Solid Particle System) object.
  111834. * @param name (String) is the SPS name, this will be the underlying mesh name.
  111835. * @param scene (Scene) is the scene in which the SPS is added.
  111836. * @param options defines the options of the sps e.g.
  111837. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  111838. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  111839. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  111840. * * 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.
  111841. * * enableMultiMaterial (optional boolean, default false) : if the solid particles can be given different materials.
  111842. * * expandable (optional boolean, default false) : if particles can still be added after the initial SPS mesh creation.
  111843. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  111844. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  111845. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  111846. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  111847. */
  111848. constructor(name: string, scene: Scene, options?: {
  111849. updatable?: boolean;
  111850. isPickable?: boolean;
  111851. enableDepthSort?: boolean;
  111852. particleIntersection?: boolean;
  111853. boundingSphereOnly?: boolean;
  111854. bSphereRadiusFactor?: number;
  111855. expandable?: boolean;
  111856. useModelMaterial?: boolean;
  111857. enableMultiMaterial?: boolean;
  111858. });
  111859. /**
  111860. * Builds the SPS underlying mesh. Returns a standard Mesh.
  111861. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  111862. * @returns the created mesh
  111863. */
  111864. buildMesh(): Mesh;
  111865. /**
  111866. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  111867. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  111868. * Thus the particles generated from `digest()` have their property `position` set yet.
  111869. * @param mesh ( Mesh ) is the mesh to be digested
  111870. * @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
  111871. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  111872. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  111873. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111874. * @returns the current SPS
  111875. */
  111876. digest(mesh: Mesh, options?: {
  111877. facetNb?: number;
  111878. number?: number;
  111879. delta?: number;
  111880. storage?: [];
  111881. }): SolidParticleSystem;
  111882. /**
  111883. * Unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  111884. * @hidden
  111885. */
  111886. private _unrotateFixedNormals;
  111887. /**
  111888. * Resets the temporary working copy particle
  111889. * @hidden
  111890. */
  111891. private _resetCopy;
  111892. /**
  111893. * Inserts the shape model geometry in the global SPS mesh by updating the positions, indices, normals, colors, uvs arrays
  111894. * @param p the current index in the positions array to be updated
  111895. * @param ind the current index in the indices array
  111896. * @param shape a Vector3 array, the shape geometry
  111897. * @param positions the positions array to be updated
  111898. * @param meshInd the shape indices array
  111899. * @param indices the indices array to be updated
  111900. * @param meshUV the shape uv array
  111901. * @param uvs the uv array to be updated
  111902. * @param meshCol the shape color array
  111903. * @param colors the color array to be updated
  111904. * @param meshNor the shape normals array
  111905. * @param normals the normals array to be updated
  111906. * @param idx the particle index
  111907. * @param idxInShape the particle index in its shape
  111908. * @param options the addShape() method passed options
  111909. * @model the particle model
  111910. * @hidden
  111911. */
  111912. private _meshBuilder;
  111913. /**
  111914. * Returns a shape Vector3 array from positions float array
  111915. * @param positions float array
  111916. * @returns a vector3 array
  111917. * @hidden
  111918. */
  111919. private _posToShape;
  111920. /**
  111921. * Returns a shapeUV array from a float uvs (array deep copy)
  111922. * @param uvs as a float array
  111923. * @returns a shapeUV array
  111924. * @hidden
  111925. */
  111926. private _uvsToShapeUV;
  111927. /**
  111928. * Adds a new particle object in the particles array
  111929. * @param idx particle index in particles array
  111930. * @param id particle id
  111931. * @param idxpos positionIndex : the starting index of the particle vertices in the SPS "positions" array
  111932. * @param idxind indiceIndex : he starting index of the particle indices in the SPS "indices" array
  111933. * @param model particle ModelShape object
  111934. * @param shapeId model shape identifier
  111935. * @param idxInShape index of the particle in the current model
  111936. * @param bInfo model bounding info object
  111937. * @param storage target storage array, if any
  111938. * @hidden
  111939. */
  111940. private _addParticle;
  111941. /**
  111942. * Adds some particles to the SPS from the model shape. Returns the shape id.
  111943. * Please read the doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#create-an-immutable-sps
  111944. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  111945. * @param nb (positive integer) the number of particles to be created from this model
  111946. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  111947. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  111948. * {storage} (optional existing array) is an array where the particles will be stored for a further use instead of being inserted in the SPS.
  111949. * @returns the number of shapes in the system
  111950. */
  111951. addShape(mesh: Mesh, nb: number, options?: {
  111952. positionFunction?: any;
  111953. vertexFunction?: any;
  111954. storage?: [];
  111955. }): number;
  111956. /**
  111957. * Rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  111958. * @hidden
  111959. */
  111960. private _rebuildParticle;
  111961. /**
  111962. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  111963. * @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.
  111964. * @returns the SPS.
  111965. */
  111966. rebuildMesh(reset?: boolean): SolidParticleSystem;
  111967. /** Removes the particles from the start-th to the end-th included from an expandable SPS (required).
  111968. * Returns an array with the removed particles.
  111969. * 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.
  111970. * The SPS can't be empty so at least one particle needs to remain in place.
  111971. * Under the hood, the VertexData array, so the VBO buffer, is recreated each call.
  111972. * @param start index of the first particle to remove
  111973. * @param end index of the last particle to remove (included)
  111974. * @returns an array populated with the removed particles
  111975. */
  111976. removeParticles(start: number, end: number): SolidParticle[];
  111977. /**
  111978. * Inserts some pre-created particles in the solid particle system so that they can be managed by setParticles().
  111979. * @param solidParticleArray an array populated with Solid Particles objects
  111980. * @returns the SPS
  111981. */
  111982. insertParticlesFromArray(solidParticleArray: SolidParticle[]): SolidParticleSystem;
  111983. /**
  111984. * Creates a new particle and modifies the SPS mesh geometry :
  111985. * - calls _meshBuilder() to increase the SPS mesh geometry step by step
  111986. * - calls _addParticle() to populate the particle array
  111987. * factorized code from addShape() and insertParticlesFromArray()
  111988. * @param idx particle index in the particles array
  111989. * @param i particle index in its shape
  111990. * @param modelShape particle ModelShape object
  111991. * @param shape shape vertex array
  111992. * @param meshInd shape indices array
  111993. * @param meshUV shape uv array
  111994. * @param meshCol shape color array
  111995. * @param meshNor shape normals array
  111996. * @param bbInfo shape bounding info
  111997. * @param storage target particle storage
  111998. * @options addShape() passed options
  111999. * @hidden
  112000. */
  112001. private _insertNewParticle;
  112002. /**
  112003. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  112004. * This method calls `updateParticle()` for each particle of the SPS.
  112005. * For an animated SPS, it is usually called within the render loop.
  112006. * 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.
  112007. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  112008. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  112009. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  112010. * @returns the SPS.
  112011. */
  112012. setParticles(start?: number, end?: number, update?: boolean): SolidParticleSystem;
  112013. /**
  112014. * Disposes the SPS.
  112015. */
  112016. dispose(): void;
  112017. /** Returns an object {idx: numbern faceId: number} for the picked particle from the passed pickingInfo object.
  112018. * idx is the particle index in the SPS
  112019. * faceId is the picked face index counted within this particle.
  112020. * Returns null if the pickInfo can't identify a picked particle.
  112021. * @param pickingInfo (PickingInfo object)
  112022. * @returns {idx: number, faceId: number} or null
  112023. */
  112024. pickedParticle(pickingInfo: PickingInfo): Nullable<{
  112025. idx: number;
  112026. faceId: number;
  112027. }>;
  112028. /**
  112029. * Returns a SolidParticle object from its identifier : particle.id
  112030. * @param id (integer) the particle Id
  112031. * @returns the searched particle or null if not found in the SPS.
  112032. */
  112033. getParticleById(id: number): Nullable<SolidParticle>;
  112034. /**
  112035. * Returns a new array populated with the particles having the passed shapeId.
  112036. * @param shapeId (integer) the shape identifier
  112037. * @returns a new solid particle array
  112038. */
  112039. getParticlesByShapeId(shapeId: number): SolidParticle[];
  112040. /**
  112041. * Populates the passed array "ref" with the particles having the passed shapeId.
  112042. * @param shapeId the shape identifier
  112043. * @returns the SPS
  112044. * @param ref
  112045. */
  112046. getParticlesByShapeIdToRef(shapeId: number, ref: SolidParticle[]): SolidParticleSystem;
  112047. /**
  112048. * Computes the required SubMeshes according the materials assigned to the particles.
  112049. * @returns the solid particle system.
  112050. * Does nothing if called before the SPS mesh is built.
  112051. */
  112052. computeSubMeshes(): SolidParticleSystem;
  112053. /**
  112054. * Sorts the solid particles by material when MultiMaterial is enabled.
  112055. * Updates the indices32 array.
  112056. * Updates the indicesByMaterial array.
  112057. * Updates the mesh indices array.
  112058. * @returns the SPS
  112059. * @hidden
  112060. */
  112061. private _sortParticlesByMaterial;
  112062. /**
  112063. * Sets the material indexes by id materialIndexesById[id] = materialIndex
  112064. * @hidden
  112065. */
  112066. private _setMaterialIndexesById;
  112067. /**
  112068. * Returns an array with unique values of Materials from the passed array
  112069. * @param array the material array to be checked and filtered
  112070. * @hidden
  112071. */
  112072. private _filterUniqueMaterialId;
  112073. /**
  112074. * Sets a new Standard Material as _defaultMaterial if not already set.
  112075. * @hidden
  112076. */
  112077. private _setDefaultMaterial;
  112078. /**
  112079. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  112080. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112081. * @returns the SPS.
  112082. */
  112083. refreshVisibleSize(): SolidParticleSystem;
  112084. /**
  112085. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  112086. * @param size the size (float) of the visibility box
  112087. * note : this doesn't lock the SPS mesh bounding box.
  112088. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112089. */
  112090. setVisibilityBox(size: number): void;
  112091. /**
  112092. * Gets whether the SPS as always visible or not
  112093. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112094. */
  112095. get isAlwaysVisible(): boolean;
  112096. /**
  112097. * Sets the SPS as always visible or not
  112098. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112099. */
  112100. set isAlwaysVisible(val: boolean);
  112101. /**
  112102. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112103. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112104. */
  112105. set isVisibilityBoxLocked(val: boolean);
  112106. /**
  112107. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  112108. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#sps-visibility
  112109. */
  112110. get isVisibilityBoxLocked(): boolean;
  112111. /**
  112112. * Tells to `setParticles()` to compute the particle rotations or not.
  112113. * Default value : true. The SPS is faster when it's set to false.
  112114. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112115. */
  112116. set computeParticleRotation(val: boolean);
  112117. /**
  112118. * Tells to `setParticles()` to compute the particle colors or not.
  112119. * Default value : true. The SPS is faster when it's set to false.
  112120. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112121. */
  112122. set computeParticleColor(val: boolean);
  112123. set computeParticleTexture(val: boolean);
  112124. /**
  112125. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  112126. * Default value : false. The SPS is faster when it's set to false.
  112127. * Note : the particle custom vertex positions aren't stored values.
  112128. */
  112129. set computeParticleVertex(val: boolean);
  112130. /**
  112131. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  112132. */
  112133. set computeBoundingBox(val: boolean);
  112134. /**
  112135. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  112136. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112137. * Default : `true`
  112138. */
  112139. set depthSortParticles(val: boolean);
  112140. /**
  112141. * Gets if `setParticles()` computes the particle rotations or not.
  112142. * Default value : true. The SPS is faster when it's set to false.
  112143. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  112144. */
  112145. get computeParticleRotation(): boolean;
  112146. /**
  112147. * Gets if `setParticles()` computes the particle colors or not.
  112148. * Default value : true. The SPS is faster when it's set to false.
  112149. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  112150. */
  112151. get computeParticleColor(): boolean;
  112152. /**
  112153. * Gets if `setParticles()` computes the particle textures or not.
  112154. * Default value : true. The SPS is faster when it's set to false.
  112155. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  112156. */
  112157. get computeParticleTexture(): boolean;
  112158. /**
  112159. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  112160. * Default value : false. The SPS is faster when it's set to false.
  112161. * Note : the particle custom vertex positions aren't stored values.
  112162. */
  112163. get computeParticleVertex(): boolean;
  112164. /**
  112165. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  112166. */
  112167. get computeBoundingBox(): boolean;
  112168. /**
  112169. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  112170. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  112171. * Default : `true`
  112172. */
  112173. get depthSortParticles(): boolean;
  112174. /**
  112175. * Gets if the SPS is created as expandable at construction time.
  112176. * Default : `false`
  112177. */
  112178. get expandable(): boolean;
  112179. /**
  112180. * Gets if the SPS supports the Multi Materials
  112181. */
  112182. get multimaterialEnabled(): boolean;
  112183. /**
  112184. * Gets if the SPS uses the model materials for its own multimaterial.
  112185. */
  112186. get useModelMaterial(): boolean;
  112187. /**
  112188. * The SPS used material array.
  112189. */
  112190. get materials(): Material[];
  112191. /**
  112192. * Sets the SPS MultiMaterial from the passed materials.
  112193. * Note : the passed array is internally copied and not used then by reference.
  112194. * @param materials an array of material objects. This array indexes are the materialIndex values of the particles.
  112195. */
  112196. setMultiMaterial(materials: Material[]): void;
  112197. /**
  112198. * The SPS computed multimaterial object
  112199. */
  112200. get multimaterial(): MultiMaterial;
  112201. set multimaterial(mm: MultiMaterial);
  112202. /**
  112203. * If the subMeshes must be updated on the next call to setParticles()
  112204. */
  112205. get autoUpdateSubMeshes(): boolean;
  112206. set autoUpdateSubMeshes(val: boolean);
  112207. /**
  112208. * This function does nothing. It may be overwritten to set all the particle first values.
  112209. * The SPS doesn't call this function, you may have to call it by your own.
  112210. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112211. */
  112212. initParticles(): void;
  112213. /**
  112214. * This function does nothing. It may be overwritten to recycle a particle.
  112215. * The SPS doesn't call this function, you may have to call it by your own.
  112216. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112217. * @param particle The particle to recycle
  112218. * @returns the recycled particle
  112219. */
  112220. recycleParticle(particle: SolidParticle): SolidParticle;
  112221. /**
  112222. * Updates a particle : this function should be overwritten by the user.
  112223. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  112224. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#particle-management
  112225. * @example : just set a particle position or velocity and recycle conditions
  112226. * @param particle The particle to update
  112227. * @returns the updated particle
  112228. */
  112229. updateParticle(particle: SolidParticle): SolidParticle;
  112230. /**
  112231. * Updates a vertex of a particle : it can be overwritten by the user.
  112232. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  112233. * @param particle the current particle
  112234. * @param vertex the current vertex of the current particle : a SolidParticleVertex object
  112235. * @param pt the index of the current vertex in the particle shape
  112236. * doc : https://doc.babylonjs.com/how_to/Solid_Particle_System#update-each-particle-shape
  112237. * @example : just set a vertex particle position or color
  112238. * @returns the sps
  112239. */
  112240. updateParticleVertex(particle: SolidParticle, vertex: SolidParticleVertex, pt: number): SolidParticleSystem;
  112241. /**
  112242. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  112243. * This does nothing and may be overwritten by the user.
  112244. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112245. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112246. * @param update the boolean update value actually passed to setParticles()
  112247. */
  112248. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112249. /**
  112250. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  112251. * This will be passed three parameters.
  112252. * This does nothing and may be overwritten by the user.
  112253. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112254. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  112255. * @param update the boolean update value actually passed to setParticles()
  112256. */
  112257. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  112258. }
  112259. }
  112260. declare module BABYLON {
  112261. /**
  112262. * Represents one particle of a solid particle system.
  112263. */
  112264. export class SolidParticle {
  112265. /**
  112266. * particle global index
  112267. */
  112268. idx: number;
  112269. /**
  112270. * particle identifier
  112271. */
  112272. id: number;
  112273. /**
  112274. * The color of the particle
  112275. */
  112276. color: Nullable<Color4>;
  112277. /**
  112278. * The world space position of the particle.
  112279. */
  112280. position: Vector3;
  112281. /**
  112282. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  112283. */
  112284. rotation: Vector3;
  112285. /**
  112286. * The world space rotation quaternion of the particle.
  112287. */
  112288. rotationQuaternion: Nullable<Quaternion>;
  112289. /**
  112290. * The scaling of the particle.
  112291. */
  112292. scaling: Vector3;
  112293. /**
  112294. * The uvs of the particle.
  112295. */
  112296. uvs: Vector4;
  112297. /**
  112298. * The current speed of the particle.
  112299. */
  112300. velocity: Vector3;
  112301. /**
  112302. * The pivot point in the particle local space.
  112303. */
  112304. pivot: Vector3;
  112305. /**
  112306. * Must the particle be translated from its pivot point in its local space ?
  112307. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  112308. * Default : false
  112309. */
  112310. translateFromPivot: boolean;
  112311. /**
  112312. * Is the particle active or not ?
  112313. */
  112314. alive: boolean;
  112315. /**
  112316. * Is the particle visible or not ?
  112317. */
  112318. isVisible: boolean;
  112319. /**
  112320. * Index of this particle in the global "positions" array (Internal use)
  112321. * @hidden
  112322. */
  112323. _pos: number;
  112324. /**
  112325. * @hidden Index of this particle in the global "indices" array (Internal use)
  112326. */
  112327. _ind: number;
  112328. /**
  112329. * @hidden ModelShape of this particle (Internal use)
  112330. */
  112331. _model: ModelShape;
  112332. /**
  112333. * ModelShape id of this particle
  112334. */
  112335. shapeId: number;
  112336. /**
  112337. * Index of the particle in its shape id
  112338. */
  112339. idxInShape: number;
  112340. /**
  112341. * @hidden Reference to the shape model BoundingInfo object (Internal use)
  112342. */
  112343. _modelBoundingInfo: BoundingInfo;
  112344. /**
  112345. * @hidden Particle BoundingInfo object (Internal use)
  112346. */
  112347. _boundingInfo: BoundingInfo;
  112348. /**
  112349. * @hidden Reference to the SPS what the particle belongs to (Internal use)
  112350. */
  112351. _sps: SolidParticleSystem;
  112352. /**
  112353. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  112354. */
  112355. _stillInvisible: boolean;
  112356. /**
  112357. * @hidden Last computed particle rotation matrix
  112358. */
  112359. _rotationMatrix: number[];
  112360. /**
  112361. * Parent particle Id, if any.
  112362. * Default null.
  112363. */
  112364. parentId: Nullable<number>;
  112365. /**
  112366. * The particle material identifier (integer) when MultiMaterials are enabled in the SPS.
  112367. */
  112368. materialIndex: Nullable<number>;
  112369. /**
  112370. * Custom object or properties.
  112371. */
  112372. props: Nullable<any>;
  112373. /**
  112374. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  112375. * The possible values are :
  112376. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112377. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112379. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112380. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112381. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  112382. * */
  112383. cullingStrategy: number;
  112384. /**
  112385. * @hidden Internal global position in the SPS.
  112386. */
  112387. _globalPosition: Vector3;
  112388. /**
  112389. * Creates a Solid Particle object.
  112390. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  112391. * @param particleIndex (integer) is the particle index in the Solid Particle System pool.
  112392. * @param particleId (integer) is the particle identifier. Unless some particles are removed from the SPS, it's the same value than the particle idx.
  112393. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  112394. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  112395. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  112396. * @param shapeId (integer) is the model shape identifier in the SPS.
  112397. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  112398. * @param sps defines the sps it is associated to
  112399. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  112400. * @param materialIndex is the particle material identifier (integer) when the MultiMaterials are enabled in the SPS.
  112401. */
  112402. constructor(particleIndex: number, particleId: number, positionIndex: number, indiceIndex: number, model: Nullable<ModelShape>, shapeId: number, idxInShape: number, sps: SolidParticleSystem, modelBoundingInfo?: Nullable<BoundingInfo>, materialIndex?: Nullable<number>);
  112403. /**
  112404. * Copies the particle property values into the existing target : position, rotation, scaling, uvs, colors, pivot, parent, visibility, alive
  112405. * @param target the particle target
  112406. * @returns the current particle
  112407. */
  112408. copyToRef(target: SolidParticle): SolidParticle;
  112409. /**
  112410. * Legacy support, changed scale to scaling
  112411. */
  112412. get scale(): Vector3;
  112413. /**
  112414. * Legacy support, changed scale to scaling
  112415. */
  112416. set scale(scale: Vector3);
  112417. /**
  112418. * Legacy support, changed quaternion to rotationQuaternion
  112419. */
  112420. get quaternion(): Nullable<Quaternion>;
  112421. /**
  112422. * Legacy support, changed quaternion to rotationQuaternion
  112423. */
  112424. set quaternion(q: Nullable<Quaternion>);
  112425. /**
  112426. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  112427. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  112428. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  112429. * @returns true if it intersects
  112430. */
  112431. intersectsMesh(target: Mesh | SolidParticle): boolean;
  112432. /**
  112433. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  112434. * A particle is in the frustum if its bounding box intersects the frustum
  112435. * @param frustumPlanes defines the frustum to test
  112436. * @returns true if the particle is in the frustum planes
  112437. */
  112438. isInFrustum(frustumPlanes: Plane[]): boolean;
  112439. /**
  112440. * get the rotation matrix of the particle
  112441. * @hidden
  112442. */
  112443. getRotationMatrix(m: Matrix): void;
  112444. }
  112445. /**
  112446. * Represents the shape of the model used by one particle of a solid particle system.
  112447. * SPS internal tool, don't use it manually.
  112448. */
  112449. export class ModelShape {
  112450. /**
  112451. * The shape id
  112452. * @hidden
  112453. */
  112454. shapeID: number;
  112455. /**
  112456. * flat array of model positions (internal use)
  112457. * @hidden
  112458. */
  112459. _shape: Vector3[];
  112460. /**
  112461. * flat array of model UVs (internal use)
  112462. * @hidden
  112463. */
  112464. _shapeUV: number[];
  112465. /**
  112466. * color array of the model
  112467. * @hidden
  112468. */
  112469. _shapeColors: number[];
  112470. /**
  112471. * indices array of the model
  112472. * @hidden
  112473. */
  112474. _indices: number[];
  112475. /**
  112476. * normals array of the model
  112477. * @hidden
  112478. */
  112479. _normals: number[];
  112480. /**
  112481. * length of the shape in the model indices array (internal use)
  112482. * @hidden
  112483. */
  112484. _indicesLength: number;
  112485. /**
  112486. * Custom position function (internal use)
  112487. * @hidden
  112488. */
  112489. _positionFunction: Nullable<(particle: SolidParticle, i: number, s: number) => void>;
  112490. /**
  112491. * Custom vertex function (internal use)
  112492. * @hidden
  112493. */
  112494. _vertexFunction: Nullable<(particle: SolidParticle, vertex: Vector3, i: number) => void>;
  112495. /**
  112496. * Model material (internal use)
  112497. * @hidden
  112498. */
  112499. _material: Nullable<Material>;
  112500. /**
  112501. * 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.
  112502. * SPS internal tool, don't use it manually.
  112503. * @hidden
  112504. */
  112505. 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>);
  112506. }
  112507. /**
  112508. * Represents a Depth Sorted Particle in the solid particle system.
  112509. * @hidden
  112510. */
  112511. export class DepthSortedParticle {
  112512. /**
  112513. * Particle index
  112514. */
  112515. idx: number;
  112516. /**
  112517. * Index of the particle in the "indices" array
  112518. */
  112519. ind: number;
  112520. /**
  112521. * Length of the particle shape in the "indices" array
  112522. */
  112523. indicesLength: number;
  112524. /**
  112525. * Squared distance from the particle to the camera
  112526. */
  112527. sqDistance: number;
  112528. /**
  112529. * Material index when used with MultiMaterials
  112530. */
  112531. materialIndex: number;
  112532. /**
  112533. * Creates a new sorted particle
  112534. * @param materialIndex
  112535. */
  112536. constructor(idx: number, ind: number, indLength: number, materialIndex: number);
  112537. }
  112538. /**
  112539. * Represents a solid particle vertex
  112540. */
  112541. export class SolidParticleVertex {
  112542. /**
  112543. * Vertex position
  112544. */
  112545. position: Vector3;
  112546. /**
  112547. * Vertex color
  112548. */
  112549. color: Color4;
  112550. /**
  112551. * Vertex UV
  112552. */
  112553. uv: Vector2;
  112554. /**
  112555. * Creates a new solid particle vertex
  112556. */
  112557. constructor();
  112558. /** Vertex x coordinate */
  112559. get x(): number;
  112560. set x(val: number);
  112561. /** Vertex y coordinate */
  112562. get y(): number;
  112563. set y(val: number);
  112564. /** Vertex z coordinate */
  112565. get z(): number;
  112566. set z(val: number);
  112567. }
  112568. }
  112569. declare module BABYLON {
  112570. /**
  112571. * @hidden
  112572. */
  112573. export class _MeshCollisionData {
  112574. _checkCollisions: boolean;
  112575. _collisionMask: number;
  112576. _collisionGroup: number;
  112577. _surroundingMeshes: Nullable<AbstractMesh[]>;
  112578. _collider: Nullable<Collider>;
  112579. _oldPositionForCollisions: Vector3;
  112580. _diffPositionForCollisions: Vector3;
  112581. _onCollideObserver: Nullable<Observer<AbstractMesh>>;
  112582. _onCollisionPositionChangeObserver: Nullable<Observer<Vector3>>;
  112583. _collisionResponse: boolean;
  112584. }
  112585. }
  112586. declare module BABYLON {
  112587. /** @hidden */
  112588. class _FacetDataStorage {
  112589. facetPositions: Vector3[];
  112590. facetNormals: Vector3[];
  112591. facetPartitioning: number[][];
  112592. facetNb: number;
  112593. partitioningSubdivisions: number;
  112594. partitioningBBoxRatio: number;
  112595. facetDataEnabled: boolean;
  112596. facetParameters: any;
  112597. bbSize: Vector3;
  112598. subDiv: {
  112599. max: number;
  112600. X: number;
  112601. Y: number;
  112602. Z: number;
  112603. };
  112604. facetDepthSort: boolean;
  112605. facetDepthSortEnabled: boolean;
  112606. depthSortedIndices: IndicesArray;
  112607. depthSortedFacets: {
  112608. ind: number;
  112609. sqDistance: number;
  112610. }[];
  112611. facetDepthSortFunction: (f1: {
  112612. ind: number;
  112613. sqDistance: number;
  112614. }, f2: {
  112615. ind: number;
  112616. sqDistance: number;
  112617. }) => number;
  112618. facetDepthSortFrom: Vector3;
  112619. facetDepthSortOrigin: Vector3;
  112620. invertedMatrix: Matrix;
  112621. }
  112622. /**
  112623. * @hidden
  112624. **/
  112625. class _InternalAbstractMeshDataInfo {
  112626. _hasVertexAlpha: boolean;
  112627. _useVertexColors: boolean;
  112628. _numBoneInfluencers: number;
  112629. _applyFog: boolean;
  112630. _receiveShadows: boolean;
  112631. _facetData: _FacetDataStorage;
  112632. _visibility: number;
  112633. _skeleton: Nullable<Skeleton>;
  112634. _layerMask: number;
  112635. _computeBonesUsingShaders: boolean;
  112636. _isActive: boolean;
  112637. _onlyForInstances: boolean;
  112638. _isActiveIntermediate: boolean;
  112639. _onlyForInstancesIntermediate: boolean;
  112640. _actAsRegularMesh: boolean;
  112641. }
  112642. /**
  112643. * Class used to store all common mesh properties
  112644. */
  112645. export class AbstractMesh extends TransformNode implements IDisposable, ICullable, IGetSetVerticesData {
  112646. /** No occlusion */
  112647. static OCCLUSION_TYPE_NONE: number;
  112648. /** Occlusion set to optimisitic */
  112649. static OCCLUSION_TYPE_OPTIMISTIC: number;
  112650. /** Occlusion set to strict */
  112651. static OCCLUSION_TYPE_STRICT: number;
  112652. /** Use an accurante occlusion algorithm */
  112653. static OCCLUSION_ALGORITHM_TYPE_ACCURATE: number;
  112654. /** Use a conservative occlusion algorithm */
  112655. static OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE: number;
  112656. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  112657. * Test order :
  112658. * Is the bounding sphere outside the frustum ?
  112659. * If not, are the bounding box vertices outside the frustum ?
  112660. * It not, then the cullable object is in the frustum.
  112661. */
  112662. static readonly CULLINGSTRATEGY_STANDARD: number;
  112663. /** Culling strategy : Bounding Sphere Only.
  112664. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  112665. * It's also less accurate than the standard because some not visible objects can still be selected.
  112666. * Test : is the bounding sphere outside the frustum ?
  112667. * If not, then the cullable object is in the frustum.
  112668. */
  112669. static readonly CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY: number;
  112670. /** Culling strategy : Optimistic Inclusion.
  112671. * This in an inclusion test first, then the standard exclusion test.
  112672. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  112673. * 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.
  112674. * Anyway, it's as accurate as the standard strategy.
  112675. * Test :
  112676. * Is the cullable object bounding sphere center in the frustum ?
  112677. * If not, apply the default culling strategy.
  112678. */
  112679. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION: number;
  112680. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  112681. * This in an inclusion test first, then the bounding sphere only exclusion test.
  112682. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  112683. * 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.
  112684. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  112685. * Test :
  112686. * Is the cullable object bounding sphere center in the frustum ?
  112687. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  112688. */
  112689. static readonly CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY: number;
  112690. /**
  112691. * No billboard
  112692. */
  112693. static get BILLBOARDMODE_NONE(): number;
  112694. /** Billboard on X axis */
  112695. static get BILLBOARDMODE_X(): number;
  112696. /** Billboard on Y axis */
  112697. static get BILLBOARDMODE_Y(): number;
  112698. /** Billboard on Z axis */
  112699. static get BILLBOARDMODE_Z(): number;
  112700. /** Billboard on all axes */
  112701. static get BILLBOARDMODE_ALL(): number;
  112702. /** Billboard on using position instead of orientation */
  112703. static get BILLBOARDMODE_USE_POSITION(): number;
  112704. /** @hidden */
  112705. _internalAbstractMeshDataInfo: _InternalAbstractMeshDataInfo;
  112706. /**
  112707. * The culling strategy to use to check whether the mesh must be rendered or not.
  112708. * This value can be changed at any time and will be used on the next render mesh selection.
  112709. * The possible values are :
  112710. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  112711. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  112712. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  112713. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  112714. * Please read each static variable documentation to get details about the culling process.
  112715. * */
  112716. cullingStrategy: number;
  112717. /**
  112718. * Gets the number of facets in the mesh
  112719. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112720. */
  112721. get facetNb(): number;
  112722. /**
  112723. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  112724. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112725. */
  112726. get partitioningSubdivisions(): number;
  112727. set partitioningSubdivisions(nb: number);
  112728. /**
  112729. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  112730. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  112731. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  112732. */
  112733. get partitioningBBoxRatio(): number;
  112734. set partitioningBBoxRatio(ratio: number);
  112735. /**
  112736. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  112737. * Works only for updatable meshes.
  112738. * Doesn't work with multi-materials
  112739. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112740. */
  112741. get mustDepthSortFacets(): boolean;
  112742. set mustDepthSortFacets(sort: boolean);
  112743. /**
  112744. * The location (Vector3) where the facet depth sort must be computed from.
  112745. * By default, the active camera position.
  112746. * Used only when facet depth sort is enabled
  112747. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  112748. */
  112749. get facetDepthSortFrom(): Vector3;
  112750. set facetDepthSortFrom(location: Vector3);
  112751. /**
  112752. * gets a boolean indicating if facetData is enabled
  112753. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  112754. */
  112755. get isFacetDataEnabled(): boolean;
  112756. /** @hidden */
  112757. _updateNonUniformScalingState(value: boolean): boolean;
  112758. /**
  112759. * An event triggered when this mesh collides with another one
  112760. */
  112761. onCollideObservable: Observable<AbstractMesh>;
  112762. /** Set a function to call when this mesh collides with another one */
  112763. set onCollide(callback: () => void);
  112764. /**
  112765. * An event triggered when the collision's position changes
  112766. */
  112767. onCollisionPositionChangeObservable: Observable<Vector3>;
  112768. /** Set a function to call when the collision's position changes */
  112769. set onCollisionPositionChange(callback: () => void);
  112770. /**
  112771. * An event triggered when material is changed
  112772. */
  112773. onMaterialChangedObservable: Observable<AbstractMesh>;
  112774. /**
  112775. * Gets or sets the orientation for POV movement & rotation
  112776. */
  112777. definedFacingForward: boolean;
  112778. /** @hidden */
  112779. _occlusionQuery: Nullable<WebGLQuery>;
  112780. /** @hidden */
  112781. _renderingGroup: Nullable<RenderingGroup>;
  112782. /**
  112783. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112784. */
  112785. get visibility(): number;
  112786. /**
  112787. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  112788. */
  112789. set visibility(value: number);
  112790. /** Gets or sets the alpha index used to sort transparent meshes
  112791. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  112792. */
  112793. alphaIndex: number;
  112794. /**
  112795. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  112796. */
  112797. isVisible: boolean;
  112798. /**
  112799. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  112800. */
  112801. isPickable: boolean;
  112802. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  112803. showSubMeshesBoundingBox: boolean;
  112804. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  112805. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  112806. */
  112807. isBlocker: boolean;
  112808. /**
  112809. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  112810. */
  112811. enablePointerMoveEvents: boolean;
  112812. private _renderingGroupId;
  112813. /**
  112814. * Specifies the rendering group id for this mesh (0 by default)
  112815. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  112816. */
  112817. get renderingGroupId(): number;
  112818. set renderingGroupId(value: number);
  112819. private _material;
  112820. /** Gets or sets current material */
  112821. get material(): Nullable<Material>;
  112822. set material(value: Nullable<Material>);
  112823. /**
  112824. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  112825. * @see https://doc.babylonjs.com/babylon101/shadows
  112826. */
  112827. get receiveShadows(): boolean;
  112828. set receiveShadows(value: boolean);
  112829. /** Defines color to use when rendering outline */
  112830. outlineColor: Color3;
  112831. /** Define width to use when rendering outline */
  112832. outlineWidth: number;
  112833. /** Defines color to use when rendering overlay */
  112834. overlayColor: Color3;
  112835. /** Defines alpha to use when rendering overlay */
  112836. overlayAlpha: number;
  112837. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  112838. get hasVertexAlpha(): boolean;
  112839. set hasVertexAlpha(value: boolean);
  112840. /** 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) */
  112841. get useVertexColors(): boolean;
  112842. set useVertexColors(value: boolean);
  112843. /**
  112844. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  112845. */
  112846. get computeBonesUsingShaders(): boolean;
  112847. set computeBonesUsingShaders(value: boolean);
  112848. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  112849. get numBoneInfluencers(): number;
  112850. set numBoneInfluencers(value: number);
  112851. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  112852. get applyFog(): boolean;
  112853. set applyFog(value: boolean);
  112854. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  112855. useOctreeForRenderingSelection: boolean;
  112856. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  112857. useOctreeForPicking: boolean;
  112858. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  112859. useOctreeForCollisions: boolean;
  112860. /**
  112861. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  112862. * @see https://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  112863. */
  112864. get layerMask(): number;
  112865. set layerMask(value: number);
  112866. /**
  112867. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  112868. */
  112869. alwaysSelectAsActiveMesh: boolean;
  112870. /**
  112871. * Gets or sets a boolean indicating that the bounding info does not need to be kept in sync (for performance reason)
  112872. */
  112873. doNotSyncBoundingInfo: boolean;
  112874. /**
  112875. * Gets or sets the current action manager
  112876. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  112877. */
  112878. actionManager: Nullable<AbstractActionManager>;
  112879. private _meshCollisionData;
  112880. /**
  112881. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  112882. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112883. */
  112884. ellipsoid: Vector3;
  112885. /**
  112886. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  112887. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  112888. */
  112889. ellipsoidOffset: Vector3;
  112890. /**
  112891. * Gets or sets a collision mask used to mask collisions (default is -1).
  112892. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112893. */
  112894. get collisionMask(): number;
  112895. set collisionMask(mask: number);
  112896. /**
  112897. * Gets or sets a collision response flag (default is true).
  112898. * when collisionResponse is false, events are still triggered but colliding entity has no response
  112899. * This helps creating trigger volume when user wants collision feedback events but not position/velocity
  112900. * to respond to the collision.
  112901. */
  112902. get collisionResponse(): boolean;
  112903. set collisionResponse(response: boolean);
  112904. /**
  112905. * Gets or sets the current collision group mask (-1 by default).
  112906. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  112907. */
  112908. get collisionGroup(): number;
  112909. set collisionGroup(mask: number);
  112910. /**
  112911. * Gets or sets current surrounding meshes (null by default).
  112912. *
  112913. * By default collision detection is tested against every mesh in the scene.
  112914. * It is possible to set surroundingMeshes to a defined list of meshes and then only these specified
  112915. * meshes will be tested for the collision.
  112916. *
  112917. * Note: if set to an empty array no collision will happen when this mesh is moved.
  112918. */
  112919. get surroundingMeshes(): Nullable<AbstractMesh[]>;
  112920. set surroundingMeshes(meshes: Nullable<AbstractMesh[]>);
  112921. /**
  112922. * Defines edge width used when edgesRenderer is enabled
  112923. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112924. */
  112925. edgesWidth: number;
  112926. /**
  112927. * Defines edge color used when edgesRenderer is enabled
  112928. * @see https://www.babylonjs-playground.com/#10OJSG#13
  112929. */
  112930. edgesColor: Color4;
  112931. /** @hidden */
  112932. _edgesRenderer: Nullable<IEdgesRenderer>;
  112933. /** @hidden */
  112934. _masterMesh: Nullable<AbstractMesh>;
  112935. /** @hidden */
  112936. _boundingInfo: Nullable<BoundingInfo>;
  112937. /** @hidden */
  112938. _renderId: number;
  112939. /**
  112940. * Gets or sets the list of subMeshes
  112941. * @see https://doc.babylonjs.com/how_to/multi_materials
  112942. */
  112943. subMeshes: SubMesh[];
  112944. /** @hidden */
  112945. _intersectionsInProgress: AbstractMesh[];
  112946. /** @hidden */
  112947. _unIndexed: boolean;
  112948. /** @hidden */
  112949. _lightSources: Light[];
  112950. /** Gets the list of lights affecting that mesh */
  112951. get lightSources(): Light[];
  112952. /** @hidden */
  112953. get _positions(): Nullable<Vector3[]>;
  112954. /** @hidden */
  112955. _waitingData: {
  112956. lods: Nullable<any>;
  112957. actions: Nullable<any>;
  112958. freezeWorldMatrix: Nullable<boolean>;
  112959. };
  112960. /** @hidden */
  112961. _bonesTransformMatrices: Nullable<Float32Array>;
  112962. /** @hidden */
  112963. _transformMatrixTexture: Nullable<RawTexture>;
  112964. /**
  112965. * Gets or sets a skeleton to apply skining transformations
  112966. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  112967. */
  112968. set skeleton(value: Nullable<Skeleton>);
  112969. get skeleton(): Nullable<Skeleton>;
  112970. /**
  112971. * An event triggered when the mesh is rebuilt.
  112972. */
  112973. onRebuildObservable: Observable<AbstractMesh>;
  112974. /**
  112975. * Creates a new AbstractMesh
  112976. * @param name defines the name of the mesh
  112977. * @param scene defines the hosting scene
  112978. */
  112979. constructor(name: string, scene?: Nullable<Scene>);
  112980. /**
  112981. * Returns the string "AbstractMesh"
  112982. * @returns "AbstractMesh"
  112983. */
  112984. getClassName(): string;
  112985. /**
  112986. * Gets a string representation of the current mesh
  112987. * @param fullDetails defines a boolean indicating if full details must be included
  112988. * @returns a string representation of the current mesh
  112989. */
  112990. toString(fullDetails?: boolean): string;
  112991. /**
  112992. * @hidden
  112993. */
  112994. protected _getEffectiveParent(): Nullable<Node>;
  112995. /** @hidden */
  112996. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  112997. /** @hidden */
  112998. _rebuild(): void;
  112999. /** @hidden */
  113000. _resyncLightSources(): void;
  113001. /** @hidden */
  113002. _resyncLightSource(light: Light): void;
  113003. /** @hidden */
  113004. _unBindEffect(): void;
  113005. /** @hidden */
  113006. _removeLightSource(light: Light, dispose: boolean): void;
  113007. private _markSubMeshesAsDirty;
  113008. /** @hidden */
  113009. _markSubMeshesAsLightDirty(dispose?: boolean): void;
  113010. /** @hidden */
  113011. _markSubMeshesAsAttributesDirty(): void;
  113012. /** @hidden */
  113013. _markSubMeshesAsMiscDirty(): void;
  113014. /**
  113015. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  113016. */
  113017. get scaling(): Vector3;
  113018. set scaling(newScaling: Vector3);
  113019. /**
  113020. * Returns true if the mesh is blocked. Implemented by child classes
  113021. */
  113022. get isBlocked(): boolean;
  113023. /**
  113024. * Returns the mesh itself by default. Implemented by child classes
  113025. * @param camera defines the camera to use to pick the right LOD level
  113026. * @returns the currentAbstractMesh
  113027. */
  113028. getLOD(camera: Camera): Nullable<AbstractMesh>;
  113029. /**
  113030. * Returns 0 by default. Implemented by child classes
  113031. * @returns an integer
  113032. */
  113033. getTotalVertices(): number;
  113034. /**
  113035. * Returns a positive integer : the total number of indices in this mesh geometry.
  113036. * @returns the numner of indices or zero if the mesh has no geometry.
  113037. */
  113038. getTotalIndices(): number;
  113039. /**
  113040. * Returns null by default. Implemented by child classes
  113041. * @returns null
  113042. */
  113043. getIndices(): Nullable<IndicesArray>;
  113044. /**
  113045. * Returns the array of the requested vertex data kind. Implemented by child classes
  113046. * @param kind defines the vertex data kind to use
  113047. * @returns null
  113048. */
  113049. getVerticesData(kind: string): Nullable<FloatArray>;
  113050. /**
  113051. * Sets the vertex data of the mesh geometry for the requested `kind`.
  113052. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  113053. * Note that a new underlying VertexBuffer object is created each call.
  113054. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  113055. * @param kind defines vertex data kind:
  113056. * * VertexBuffer.PositionKind
  113057. * * VertexBuffer.UVKind
  113058. * * VertexBuffer.UV2Kind
  113059. * * VertexBuffer.UV3Kind
  113060. * * VertexBuffer.UV4Kind
  113061. * * VertexBuffer.UV5Kind
  113062. * * VertexBuffer.UV6Kind
  113063. * * VertexBuffer.ColorKind
  113064. * * VertexBuffer.MatricesIndicesKind
  113065. * * VertexBuffer.MatricesIndicesExtraKind
  113066. * * VertexBuffer.MatricesWeightsKind
  113067. * * VertexBuffer.MatricesWeightsExtraKind
  113068. * @param data defines the data source
  113069. * @param updatable defines if the data must be flagged as updatable (or static)
  113070. * @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
  113071. * @returns the current mesh
  113072. */
  113073. setVerticesData(kind: string, data: FloatArray, updatable?: boolean, stride?: number): AbstractMesh;
  113074. /**
  113075. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  113076. * If the mesh has no geometry, it is simply returned as it is.
  113077. * @param kind defines vertex data kind:
  113078. * * VertexBuffer.PositionKind
  113079. * * VertexBuffer.UVKind
  113080. * * VertexBuffer.UV2Kind
  113081. * * VertexBuffer.UV3Kind
  113082. * * VertexBuffer.UV4Kind
  113083. * * VertexBuffer.UV5Kind
  113084. * * VertexBuffer.UV6Kind
  113085. * * VertexBuffer.ColorKind
  113086. * * VertexBuffer.MatricesIndicesKind
  113087. * * VertexBuffer.MatricesIndicesExtraKind
  113088. * * VertexBuffer.MatricesWeightsKind
  113089. * * VertexBuffer.MatricesWeightsExtraKind
  113090. * @param data defines the data source
  113091. * @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
  113092. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  113093. * @returns the current mesh
  113094. */
  113095. updateVerticesData(kind: string, data: FloatArray, updateExtends?: boolean, makeItUnique?: boolean): AbstractMesh;
  113096. /**
  113097. * Sets the mesh indices,
  113098. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  113099. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  113100. * @param totalVertices Defines the total number of vertices
  113101. * @returns the current mesh
  113102. */
  113103. setIndices(indices: IndicesArray, totalVertices: Nullable<number>): AbstractMesh;
  113104. /**
  113105. * Gets a boolean indicating if specific vertex data is present
  113106. * @param kind defines the vertex data kind to use
  113107. * @returns true is data kind is present
  113108. */
  113109. isVerticesDataPresent(kind: string): boolean;
  113110. /**
  113111. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined.
  113112. * Note that it returns a shallow bounding of the mesh (i.e. it does not include children).
  113113. * To get the full bounding of all children, call `getHierarchyBoundingVectors` instead.
  113114. * @returns a BoundingInfo
  113115. */
  113116. getBoundingInfo(): BoundingInfo;
  113117. /**
  113118. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  113119. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box. Default is false
  113120. * @param ignoreRotation ignore rotation when computing the scale (ie. object will be axis aligned). Default is false
  113121. * @param predicate predicate that is passed in to getHierarchyBoundingVectors when selecting which object should be included when scaling
  113122. * @returns the current mesh
  113123. */
  113124. normalizeToUnitCube(includeDescendants?: boolean, ignoreRotation?: boolean, predicate?: Nullable<(node: AbstractMesh) => boolean>): AbstractMesh;
  113125. /**
  113126. * Overwrite the current bounding info
  113127. * @param boundingInfo defines the new bounding info
  113128. * @returns the current mesh
  113129. */
  113130. setBoundingInfo(boundingInfo: BoundingInfo): AbstractMesh;
  113131. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  113132. get useBones(): boolean;
  113133. /** @hidden */
  113134. _preActivate(): void;
  113135. /** @hidden */
  113136. _preActivateForIntermediateRendering(renderId: number): void;
  113137. /** @hidden */
  113138. _activate(renderId: number, intermediateRendering: boolean): boolean;
  113139. /** @hidden */
  113140. _postActivate(): void;
  113141. /** @hidden */
  113142. _freeze(): void;
  113143. /** @hidden */
  113144. _unFreeze(): void;
  113145. /**
  113146. * Gets the current world matrix
  113147. * @returns a Matrix
  113148. */
  113149. getWorldMatrix(): Matrix;
  113150. /** @hidden */
  113151. _getWorldMatrixDeterminant(): number;
  113152. /**
  113153. * Gets a boolean indicating if this mesh is an instance or a regular mesh
  113154. */
  113155. get isAnInstance(): boolean;
  113156. /**
  113157. * Gets a boolean indicating if this mesh has instances
  113158. */
  113159. get hasInstances(): boolean;
  113160. /**
  113161. * Gets a boolean indicating if this mesh has thin instances
  113162. */
  113163. get hasThinInstances(): boolean;
  113164. /**
  113165. * Perform relative position change from the point of view of behind the front of the mesh.
  113166. * This is performed taking into account the meshes current rotation, so you do not have to care.
  113167. * Supports definition of mesh facing forward or backward
  113168. * @param amountRight defines the distance on the right axis
  113169. * @param amountUp defines the distance on the up axis
  113170. * @param amountForward defines the distance on the forward axis
  113171. * @returns the current mesh
  113172. */
  113173. movePOV(amountRight: number, amountUp: number, amountForward: number): AbstractMesh;
  113174. /**
  113175. * Calculate relative position change from the point of view of behind the front of the mesh.
  113176. * This is performed taking into account the meshes current rotation, so you do not have to care.
  113177. * Supports definition of mesh facing forward or backward
  113178. * @param amountRight defines the distance on the right axis
  113179. * @param amountUp defines the distance on the up axis
  113180. * @param amountForward defines the distance on the forward axis
  113181. * @returns the new displacement vector
  113182. */
  113183. calcMovePOV(amountRight: number, amountUp: number, amountForward: number): Vector3;
  113184. /**
  113185. * Perform relative rotation change from the point of view of behind the front of the mesh.
  113186. * Supports definition of mesh facing forward or backward
  113187. * @param flipBack defines the flip
  113188. * @param twirlClockwise defines the twirl
  113189. * @param tiltRight defines the tilt
  113190. * @returns the current mesh
  113191. */
  113192. rotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): AbstractMesh;
  113193. /**
  113194. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  113195. * Supports definition of mesh facing forward or backward.
  113196. * @param flipBack defines the flip
  113197. * @param twirlClockwise defines the twirl
  113198. * @param tiltRight defines the tilt
  113199. * @returns the new rotation vector
  113200. */
  113201. calcRotatePOV(flipBack: number, twirlClockwise: number, tiltRight: number): Vector3;
  113202. /**
  113203. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  113204. * This means the mesh underlying bounding box and sphere are recomputed.
  113205. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  113206. * @returns the current mesh
  113207. */
  113208. refreshBoundingInfo(applySkeleton?: boolean): AbstractMesh;
  113209. /** @hidden */
  113210. _refreshBoundingInfo(data: Nullable<FloatArray>, bias: Nullable<Vector2>): void;
  113211. /** @hidden */
  113212. _getPositionData(applySkeleton: boolean): Nullable<FloatArray>;
  113213. /** @hidden */
  113214. _updateBoundingInfo(): AbstractMesh;
  113215. /** @hidden */
  113216. _updateSubMeshesBoundingInfo(matrix: DeepImmutable<Matrix>): AbstractMesh;
  113217. /** @hidden */
  113218. protected _afterComputeWorldMatrix(): void;
  113219. /** @hidden */
  113220. get _effectiveMesh(): AbstractMesh;
  113221. /**
  113222. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  113223. * A mesh is in the frustum if its bounding box intersects the frustum
  113224. * @param frustumPlanes defines the frustum to test
  113225. * @returns true if the mesh is in the frustum planes
  113226. */
  113227. isInFrustum(frustumPlanes: Plane[]): boolean;
  113228. /**
  113229. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  113230. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  113231. * @param frustumPlanes defines the frustum to test
  113232. * @returns true if the mesh is completely in the frustum planes
  113233. */
  113234. isCompletelyInFrustum(frustumPlanes: Plane[]): boolean;
  113235. /**
  113236. * True if the mesh intersects another mesh or a SolidParticle object
  113237. * @param mesh defines a target mesh or SolidParticle to test
  113238. * @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)
  113239. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  113240. * @returns true if there is an intersection
  113241. */
  113242. intersectsMesh(mesh: AbstractMesh | SolidParticle, precise?: boolean, includeDescendants?: boolean): boolean;
  113243. /**
  113244. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  113245. * @param point defines the point to test
  113246. * @returns true if there is an intersection
  113247. */
  113248. intersectsPoint(point: Vector3): boolean;
  113249. /**
  113250. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  113251. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113252. */
  113253. get checkCollisions(): boolean;
  113254. set checkCollisions(collisionEnabled: boolean);
  113255. /**
  113256. * Gets Collider object used to compute collisions (not physics)
  113257. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113258. */
  113259. get collider(): Nullable<Collider>;
  113260. /**
  113261. * Move the mesh using collision engine
  113262. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  113263. * @param displacement defines the requested displacement vector
  113264. * @returns the current mesh
  113265. */
  113266. moveWithCollisions(displacement: Vector3): AbstractMesh;
  113267. private _onCollisionPositionChange;
  113268. /** @hidden */
  113269. _collideForSubMesh(subMesh: SubMesh, transformMatrix: Matrix, collider: Collider): AbstractMesh;
  113270. /** @hidden */
  113271. _processCollisionsForSubMeshes(collider: Collider, transformMatrix: Matrix): AbstractMesh;
  113272. /** @hidden */
  113273. _checkCollision(collider: Collider): AbstractMesh;
  113274. /** @hidden */
  113275. _generatePointsArray(): boolean;
  113276. /**
  113277. * Checks if the passed Ray intersects with the mesh
  113278. * @param ray defines the ray to use
  113279. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  113280. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  113281. * @param onlyBoundingInfo defines a boolean indicating if picking should only happen using bounding info (false by default)
  113282. * @param worldToUse defines the world matrix to use to get the world coordinate of the intersection point
  113283. * @returns the picking info
  113284. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  113285. */
  113286. intersects(ray: Ray, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate, onlyBoundingInfo?: boolean, worldToUse?: Matrix): PickingInfo;
  113287. /**
  113288. * Clones the current mesh
  113289. * @param name defines the mesh name
  113290. * @param newParent defines the new mesh parent
  113291. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  113292. * @returns the new mesh
  113293. */
  113294. clone(name: string, newParent: Nullable<Node>, doNotCloneChildren?: boolean): Nullable<AbstractMesh>;
  113295. /**
  113296. * Disposes all the submeshes of the current meshnp
  113297. * @returns the current mesh
  113298. */
  113299. releaseSubMeshes(): AbstractMesh;
  113300. /**
  113301. * Releases resources associated with this abstract mesh.
  113302. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113303. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113304. */
  113305. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113306. /**
  113307. * Adds the passed mesh as a child to the current mesh
  113308. * @param mesh defines the child mesh
  113309. * @returns the current mesh
  113310. */
  113311. addChild(mesh: AbstractMesh): AbstractMesh;
  113312. /**
  113313. * Removes the passed mesh from the current mesh children list
  113314. * @param mesh defines the child mesh
  113315. * @returns the current mesh
  113316. */
  113317. removeChild(mesh: AbstractMesh): AbstractMesh;
  113318. /** @hidden */
  113319. private _initFacetData;
  113320. /**
  113321. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  113322. * This method can be called within the render loop.
  113323. * 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
  113324. * @returns the current mesh
  113325. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113326. */
  113327. updateFacetData(): AbstractMesh;
  113328. /**
  113329. * Returns the facetLocalNormals array.
  113330. * The normals are expressed in the mesh local spac
  113331. * @returns an array of Vector3
  113332. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113333. */
  113334. getFacetLocalNormals(): Vector3[];
  113335. /**
  113336. * Returns the facetLocalPositions array.
  113337. * The facet positions are expressed in the mesh local space
  113338. * @returns an array of Vector3
  113339. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113340. */
  113341. getFacetLocalPositions(): Vector3[];
  113342. /**
  113343. * Returns the facetLocalPartioning array
  113344. * @returns an array of array of numbers
  113345. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113346. */
  113347. getFacetLocalPartitioning(): number[][];
  113348. /**
  113349. * Returns the i-th facet position in the world system.
  113350. * This method allocates a new Vector3 per call
  113351. * @param i defines the facet index
  113352. * @returns a new Vector3
  113353. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113354. */
  113355. getFacetPosition(i: number): Vector3;
  113356. /**
  113357. * Sets the reference Vector3 with the i-th facet position in the world system
  113358. * @param i defines the facet index
  113359. * @param ref defines the target vector
  113360. * @returns the current mesh
  113361. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113362. */
  113363. getFacetPositionToRef(i: number, ref: Vector3): AbstractMesh;
  113364. /**
  113365. * Returns the i-th facet normal in the world system.
  113366. * This method allocates a new Vector3 per call
  113367. * @param i defines the facet index
  113368. * @returns a new Vector3
  113369. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113370. */
  113371. getFacetNormal(i: number): Vector3;
  113372. /**
  113373. * Sets the reference Vector3 with the i-th facet normal in the world system
  113374. * @param i defines the facet index
  113375. * @param ref defines the target vector
  113376. * @returns the current mesh
  113377. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113378. */
  113379. getFacetNormalToRef(i: number, ref: Vector3): this;
  113380. /**
  113381. * 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)
  113382. * @param x defines x coordinate
  113383. * @param y defines y coordinate
  113384. * @param z defines z coordinate
  113385. * @returns the array of facet indexes
  113386. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113387. */
  113388. getFacetsAtLocalCoordinates(x: number, y: number, z: number): Nullable<number[]>;
  113389. /**
  113390. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  113391. * @param projected sets as the (x,y,z) world projection on the facet
  113392. * @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
  113393. * @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
  113394. * @param x defines x coordinate
  113395. * @param y defines y coordinate
  113396. * @param z defines z coordinate
  113397. * @returns the face index if found (or null instead)
  113398. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113399. */
  113400. getClosestFacetAtCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113401. /**
  113402. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  113403. * @param projected sets as the (x,y,z) local projection on the facet
  113404. * @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
  113405. * @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
  113406. * @param x defines x coordinate
  113407. * @param y defines y coordinate
  113408. * @param z defines z coordinate
  113409. * @returns the face index if found (or null instead)
  113410. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113411. */
  113412. getClosestFacetAtLocalCoordinates(x: number, y: number, z: number, projected?: Vector3, checkFace?: boolean, facing?: boolean): Nullable<number>;
  113413. /**
  113414. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  113415. * @returns the parameters
  113416. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113417. */
  113418. getFacetDataParameters(): any;
  113419. /**
  113420. * Disables the feature FacetData and frees the related memory
  113421. * @returns the current mesh
  113422. * @see https://doc.babylonjs.com/how_to/how_to_use_facetdata
  113423. */
  113424. disableFacetData(): AbstractMesh;
  113425. /**
  113426. * Updates the AbstractMesh indices array
  113427. * @param indices defines the data source
  113428. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  113429. * @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)
  113430. * @returns the current mesh
  113431. */
  113432. updateIndices(indices: IndicesArray, offset?: number, gpuMemoryOnly?: boolean): AbstractMesh;
  113433. /**
  113434. * Creates new normals data for the mesh
  113435. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  113436. * @returns the current mesh
  113437. */
  113438. createNormals(updatable: boolean): AbstractMesh;
  113439. /**
  113440. * Align the mesh with a normal
  113441. * @param normal defines the normal to use
  113442. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  113443. * @returns the current mesh
  113444. */
  113445. alignWithNormal(normal: Vector3, upDirection?: Vector3): AbstractMesh;
  113446. /** @hidden */
  113447. _checkOcclusionQuery(): boolean;
  113448. /**
  113449. * Disables the mesh edge rendering mode
  113450. * @returns the currentAbstractMesh
  113451. */
  113452. disableEdgesRendering(): AbstractMesh;
  113453. /**
  113454. * Enables the edge rendering mode on the mesh.
  113455. * This mode makes the mesh edges visible
  113456. * @param epsilon defines the maximal distance between two angles to detect a face
  113457. * @param checkVerticesInsteadOfIndices indicates that we should check vertex list directly instead of faces
  113458. * @returns the currentAbstractMesh
  113459. * @see https://www.babylonjs-playground.com/#19O9TU#0
  113460. */
  113461. enableEdgesRendering(epsilon?: number, checkVerticesInsteadOfIndices?: boolean): AbstractMesh;
  113462. /**
  113463. * This function returns all of the particle systems in the scene that use the mesh as an emitter.
  113464. * @returns an array of particle systems in the scene that use the mesh as an emitter
  113465. */
  113466. getConnectedParticleSystems(): IParticleSystem[];
  113467. }
  113468. }
  113469. declare module BABYLON {
  113470. /**
  113471. * Interface used to define ActionEvent
  113472. */
  113473. export interface IActionEvent {
  113474. /** The mesh or sprite that triggered the action */
  113475. source: any;
  113476. /** The X mouse cursor position at the time of the event */
  113477. pointerX: number;
  113478. /** The Y mouse cursor position at the time of the event */
  113479. pointerY: number;
  113480. /** The mesh that is currently pointed at (can be null) */
  113481. meshUnderPointer: Nullable<AbstractMesh>;
  113482. /** the original (browser) event that triggered the ActionEvent */
  113483. sourceEvent?: any;
  113484. /** additional data for the event */
  113485. additionalData?: any;
  113486. }
  113487. /**
  113488. * ActionEvent is the event being sent when an action is triggered.
  113489. */
  113490. export class ActionEvent implements IActionEvent {
  113491. /** The mesh or sprite that triggered the action */
  113492. source: any;
  113493. /** The X mouse cursor position at the time of the event */
  113494. pointerX: number;
  113495. /** The Y mouse cursor position at the time of the event */
  113496. pointerY: number;
  113497. /** The mesh that is currently pointed at (can be null) */
  113498. meshUnderPointer: Nullable<AbstractMesh>;
  113499. /** the original (browser) event that triggered the ActionEvent */
  113500. sourceEvent?: any;
  113501. /** additional data for the event */
  113502. additionalData?: any;
  113503. /**
  113504. * Creates a new ActionEvent
  113505. * @param source The mesh or sprite that triggered the action
  113506. * @param pointerX The X mouse cursor position at the time of the event
  113507. * @param pointerY The Y mouse cursor position at the time of the event
  113508. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  113509. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  113510. * @param additionalData additional data for the event
  113511. */
  113512. constructor(
  113513. /** The mesh or sprite that triggered the action */
  113514. source: any,
  113515. /** The X mouse cursor position at the time of the event */
  113516. pointerX: number,
  113517. /** The Y mouse cursor position at the time of the event */
  113518. pointerY: number,
  113519. /** The mesh that is currently pointed at (can be null) */
  113520. meshUnderPointer: Nullable<AbstractMesh>,
  113521. /** the original (browser) event that triggered the ActionEvent */
  113522. sourceEvent?: any,
  113523. /** additional data for the event */
  113524. additionalData?: any);
  113525. /**
  113526. * Helper function to auto-create an ActionEvent from a source mesh.
  113527. * @param source The source mesh that triggered the event
  113528. * @param evt The original (browser) event
  113529. * @param additionalData additional data for the event
  113530. * @returns the new ActionEvent
  113531. */
  113532. static CreateNew(source: AbstractMesh, evt?: Event, additionalData?: any): ActionEvent;
  113533. /**
  113534. * Helper function to auto-create an ActionEvent from a source sprite
  113535. * @param source The source sprite that triggered the event
  113536. * @param scene Scene associated with the sprite
  113537. * @param evt The original (browser) event
  113538. * @param additionalData additional data for the event
  113539. * @returns the new ActionEvent
  113540. */
  113541. static CreateNewFromSprite(source: Sprite, scene: Scene, evt?: Event, additionalData?: any): ActionEvent;
  113542. /**
  113543. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  113544. * @param scene the scene where the event occurred
  113545. * @param evt The original (browser) event
  113546. * @returns the new ActionEvent
  113547. */
  113548. static CreateNewFromScene(scene: Scene, evt: Event): ActionEvent;
  113549. /**
  113550. * Helper function to auto-create an ActionEvent from a primitive
  113551. * @param prim defines the target primitive
  113552. * @param pointerPos defines the pointer position
  113553. * @param evt The original (browser) event
  113554. * @param additionalData additional data for the event
  113555. * @returns the new ActionEvent
  113556. */
  113557. static CreateNewFromPrimitive(prim: any, pointerPos: Vector2, evt?: Event, additionalData?: any): ActionEvent;
  113558. }
  113559. }
  113560. declare module BABYLON {
  113561. /**
  113562. * Abstract class used to decouple action Manager from scene and meshes.
  113563. * Do not instantiate.
  113564. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  113565. */
  113566. export abstract class AbstractActionManager implements IDisposable {
  113567. /** Gets the list of active triggers */
  113568. static Triggers: {
  113569. [key: string]: number;
  113570. };
  113571. /** Gets the cursor to use when hovering items */
  113572. hoverCursor: string;
  113573. /** Gets the list of actions */
  113574. actions: IAction[];
  113575. /**
  113576. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  113577. */
  113578. isRecursive: boolean;
  113579. /**
  113580. * Releases all associated resources
  113581. */
  113582. abstract dispose(): void;
  113583. /**
  113584. * Does this action manager has pointer triggers
  113585. */
  113586. abstract get hasPointerTriggers(): boolean;
  113587. /**
  113588. * Does this action manager has pick triggers
  113589. */
  113590. abstract get hasPickTriggers(): boolean;
  113591. /**
  113592. * Process a specific trigger
  113593. * @param trigger defines the trigger to process
  113594. * @param evt defines the event details to be processed
  113595. */
  113596. abstract processTrigger(trigger: number, evt?: IActionEvent): void;
  113597. /**
  113598. * Does this action manager handles actions of any of the given triggers
  113599. * @param triggers defines the triggers to be tested
  113600. * @return a boolean indicating whether one (or more) of the triggers is handled
  113601. */
  113602. abstract hasSpecificTriggers(triggers: number[]): boolean;
  113603. /**
  113604. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  113605. * speed.
  113606. * @param triggerA defines the trigger to be tested
  113607. * @param triggerB defines the trigger to be tested
  113608. * @return a boolean indicating whether one (or more) of the triggers is handled
  113609. */
  113610. abstract hasSpecificTriggers2(triggerA: number, triggerB: number): boolean;
  113611. /**
  113612. * Does this action manager handles actions of a given trigger
  113613. * @param trigger defines the trigger to be tested
  113614. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  113615. * @return whether the trigger is handled
  113616. */
  113617. abstract hasSpecificTrigger(trigger: number, parameterPredicate?: (parameter: any) => boolean): boolean;
  113618. /**
  113619. * Serialize this manager to a JSON object
  113620. * @param name defines the property name to store this manager
  113621. * @returns a JSON representation of this manager
  113622. */
  113623. abstract serialize(name: string): any;
  113624. /**
  113625. * Registers an action to this action manager
  113626. * @param action defines the action to be registered
  113627. * @return the action amended (prepared) after registration
  113628. */
  113629. abstract registerAction(action: IAction): Nullable<IAction>;
  113630. /**
  113631. * Unregisters an action to this action manager
  113632. * @param action defines the action to be unregistered
  113633. * @return a boolean indicating whether the action has been unregistered
  113634. */
  113635. abstract unregisterAction(action: IAction): Boolean;
  113636. /**
  113637. * Does exist one action manager with at least one trigger
  113638. **/
  113639. static get HasTriggers(): boolean;
  113640. /**
  113641. * Does exist one action manager with at least one pick trigger
  113642. **/
  113643. static get HasPickTriggers(): boolean;
  113644. /**
  113645. * Does exist one action manager that handles actions of a given trigger
  113646. * @param trigger defines the trigger to be tested
  113647. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  113648. **/
  113649. static HasSpecificTrigger(trigger: number): boolean;
  113650. }
  113651. }
  113652. declare module BABYLON {
  113653. /**
  113654. * Defines how a node can be built from a string name.
  113655. */
  113656. export type NodeConstructor = (name: string, scene: Scene, options?: any) => () => Node;
  113657. /**
  113658. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  113659. */
  113660. export class Node implements IBehaviorAware<Node> {
  113661. /** @hidden */
  113662. static _AnimationRangeFactory: (name: string, from: number, to: number) => AnimationRange;
  113663. private static _NodeConstructors;
  113664. /**
  113665. * Add a new node constructor
  113666. * @param type defines the type name of the node to construct
  113667. * @param constructorFunc defines the constructor function
  113668. */
  113669. static AddNodeConstructor(type: string, constructorFunc: NodeConstructor): void;
  113670. /**
  113671. * Returns a node constructor based on type name
  113672. * @param type defines the type name
  113673. * @param name defines the new node name
  113674. * @param scene defines the hosting scene
  113675. * @param options defines optional options to transmit to constructors
  113676. * @returns the new constructor or null
  113677. */
  113678. static Construct(type: string, name: string, scene: Scene, options?: any): Nullable<() => Node>;
  113679. /**
  113680. * Gets or sets the name of the node
  113681. */
  113682. name: string;
  113683. /**
  113684. * Gets or sets the id of the node
  113685. */
  113686. id: string;
  113687. /**
  113688. * Gets or sets the unique id of the node
  113689. */
  113690. uniqueId: number;
  113691. /**
  113692. * Gets or sets a string used to store user defined state for the node
  113693. */
  113694. state: string;
  113695. /**
  113696. * Gets or sets an object used to store user defined information for the node
  113697. */
  113698. metadata: any;
  113699. /**
  113700. * For internal use only. Please do not use.
  113701. */
  113702. reservedDataStore: any;
  113703. /**
  113704. * List of inspectable custom properties (used by the Inspector)
  113705. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  113706. */
  113707. inspectableCustomProperties: IInspectable[];
  113708. private _doNotSerialize;
  113709. /**
  113710. * Gets or sets a boolean used to define if the node must be serialized
  113711. */
  113712. get doNotSerialize(): boolean;
  113713. set doNotSerialize(value: boolean);
  113714. /** @hidden */
  113715. _isDisposed: boolean;
  113716. /**
  113717. * Gets a list of Animations associated with the node
  113718. */
  113719. animations: Animation[];
  113720. protected _ranges: {
  113721. [name: string]: Nullable<AnimationRange>;
  113722. };
  113723. /**
  113724. * Callback raised when the node is ready to be used
  113725. */
  113726. onReady: Nullable<(node: Node) => void>;
  113727. private _isEnabled;
  113728. private _isParentEnabled;
  113729. private _isReady;
  113730. /** @hidden */
  113731. _currentRenderId: number;
  113732. private _parentUpdateId;
  113733. /** @hidden */
  113734. _childUpdateId: number;
  113735. /** @hidden */
  113736. _waitingParentId: Nullable<string>;
  113737. /** @hidden */
  113738. _scene: Scene;
  113739. /** @hidden */
  113740. _cache: any;
  113741. private _parentNode;
  113742. private _children;
  113743. /** @hidden */
  113744. _worldMatrix: Matrix;
  113745. /** @hidden */
  113746. _worldMatrixDeterminant: number;
  113747. /** @hidden */
  113748. _worldMatrixDeterminantIsDirty: boolean;
  113749. /** @hidden */
  113750. private _sceneRootNodesIndex;
  113751. /**
  113752. * Gets a boolean indicating if the node has been disposed
  113753. * @returns true if the node was disposed
  113754. */
  113755. isDisposed(): boolean;
  113756. /**
  113757. * Gets or sets the parent of the node (without keeping the current position in the scene)
  113758. * @see https://doc.babylonjs.com/how_to/parenting
  113759. */
  113760. set parent(parent: Nullable<Node>);
  113761. get parent(): Nullable<Node>;
  113762. /** @hidden */
  113763. _addToSceneRootNodes(): void;
  113764. /** @hidden */
  113765. _removeFromSceneRootNodes(): void;
  113766. private _animationPropertiesOverride;
  113767. /**
  113768. * Gets or sets the animation properties override
  113769. */
  113770. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  113771. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  113772. /**
  113773. * Gets a string identifying the name of the class
  113774. * @returns "Node" string
  113775. */
  113776. getClassName(): string;
  113777. /** @hidden */
  113778. readonly _isNode: boolean;
  113779. /**
  113780. * An event triggered when the mesh is disposed
  113781. */
  113782. onDisposeObservable: Observable<Node>;
  113783. private _onDisposeObserver;
  113784. /**
  113785. * Sets a callback that will be raised when the node will be disposed
  113786. */
  113787. set onDispose(callback: () => void);
  113788. /**
  113789. * Creates a new Node
  113790. * @param name the name and id to be given to this node
  113791. * @param scene the scene this node will be added to
  113792. */
  113793. constructor(name: string, scene?: Nullable<Scene>);
  113794. /**
  113795. * Gets the scene of the node
  113796. * @returns a scene
  113797. */
  113798. getScene(): Scene;
  113799. /**
  113800. * Gets the engine of the node
  113801. * @returns a Engine
  113802. */
  113803. getEngine(): Engine;
  113804. private _behaviors;
  113805. /**
  113806. * Attach a behavior to the node
  113807. * @see https://doc.babylonjs.com/features/behaviour
  113808. * @param behavior defines the behavior to attach
  113809. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  113810. * @returns the current Node
  113811. */
  113812. addBehavior(behavior: Behavior<Node>, attachImmediately?: boolean): Node;
  113813. /**
  113814. * Remove an attached behavior
  113815. * @see https://doc.babylonjs.com/features/behaviour
  113816. * @param behavior defines the behavior to attach
  113817. * @returns the current Node
  113818. */
  113819. removeBehavior(behavior: Behavior<Node>): Node;
  113820. /**
  113821. * Gets the list of attached behaviors
  113822. * @see https://doc.babylonjs.com/features/behaviour
  113823. */
  113824. get behaviors(): Behavior<Node>[];
  113825. /**
  113826. * Gets an attached behavior by name
  113827. * @param name defines the name of the behavior to look for
  113828. * @see https://doc.babylonjs.com/features/behaviour
  113829. * @returns null if behavior was not found else the requested behavior
  113830. */
  113831. getBehaviorByName(name: string): Nullable<Behavior<Node>>;
  113832. /**
  113833. * Returns the latest update of the World matrix
  113834. * @returns a Matrix
  113835. */
  113836. getWorldMatrix(): Matrix;
  113837. /** @hidden */
  113838. _getWorldMatrixDeterminant(): number;
  113839. /**
  113840. * Returns directly the latest state of the mesh World matrix.
  113841. * A Matrix is returned.
  113842. */
  113843. get worldMatrixFromCache(): Matrix;
  113844. /** @hidden */
  113845. _initCache(): void;
  113846. /** @hidden */
  113847. updateCache(force?: boolean): void;
  113848. /** @hidden */
  113849. _getActionManagerForTrigger(trigger?: number, initialCall?: boolean): Nullable<AbstractActionManager>;
  113850. /** @hidden */
  113851. _updateCache(ignoreParentClass?: boolean): void;
  113852. /** @hidden */
  113853. _isSynchronized(): boolean;
  113854. /** @hidden */
  113855. _markSyncedWithParent(): void;
  113856. /** @hidden */
  113857. isSynchronizedWithParent(): boolean;
  113858. /** @hidden */
  113859. isSynchronized(): boolean;
  113860. /**
  113861. * Is this node ready to be used/rendered
  113862. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  113863. * @return true if the node is ready
  113864. */
  113865. isReady(completeCheck?: boolean): boolean;
  113866. /**
  113867. * Is this node enabled?
  113868. * 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
  113869. * @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
  113870. * @return whether this node (and its parent) is enabled
  113871. */
  113872. isEnabled(checkAncestors?: boolean): boolean;
  113873. /** @hidden */
  113874. protected _syncParentEnabledState(): void;
  113875. /**
  113876. * Set the enabled state of this node
  113877. * @param value defines the new enabled state
  113878. */
  113879. setEnabled(value: boolean): void;
  113880. /**
  113881. * Is this node a descendant of the given node?
  113882. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  113883. * @param ancestor defines the parent node to inspect
  113884. * @returns a boolean indicating if this node is a descendant of the given node
  113885. */
  113886. isDescendantOf(ancestor: Node): boolean;
  113887. /** @hidden */
  113888. _getDescendants(results: Node[], directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): void;
  113889. /**
  113890. * Will return all nodes that have this node as ascendant
  113891. * @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
  113892. * @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
  113893. * @return all children nodes of all types
  113894. */
  113895. getDescendants(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): Node[];
  113896. /**
  113897. * Get all child-meshes of this node
  113898. * @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)
  113899. * @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
  113900. * @returns an array of AbstractMesh
  113901. */
  113902. getChildMeshes(directDescendantsOnly?: boolean, predicate?: (node: Node) => boolean): AbstractMesh[];
  113903. /**
  113904. * Get all direct children of this node
  113905. * @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
  113906. * @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)
  113907. * @returns an array of Node
  113908. */
  113909. getChildren(predicate?: (node: Node) => boolean, directDescendantsOnly?: boolean): Node[];
  113910. /** @hidden */
  113911. _setReady(state: boolean): void;
  113912. /**
  113913. * Get an animation by name
  113914. * @param name defines the name of the animation to look for
  113915. * @returns null if not found else the requested animation
  113916. */
  113917. getAnimationByName(name: string): Nullable<Animation>;
  113918. /**
  113919. * Creates an animation range for this node
  113920. * @param name defines the name of the range
  113921. * @param from defines the starting key
  113922. * @param to defines the end key
  113923. */
  113924. createAnimationRange(name: string, from: number, to: number): void;
  113925. /**
  113926. * Delete a specific animation range
  113927. * @param name defines the name of the range to delete
  113928. * @param deleteFrames defines if animation frames from the range must be deleted as well
  113929. */
  113930. deleteAnimationRange(name: string, deleteFrames?: boolean): void;
  113931. /**
  113932. * Get an animation range by name
  113933. * @param name defines the name of the animation range to look for
  113934. * @returns null if not found else the requested animation range
  113935. */
  113936. getAnimationRange(name: string): Nullable<AnimationRange>;
  113937. /**
  113938. * Gets the list of all animation ranges defined on this node
  113939. * @returns an array
  113940. */
  113941. getAnimationRanges(): Nullable<AnimationRange>[];
  113942. /**
  113943. * Will start the animation sequence
  113944. * @param name defines the range frames for animation sequence
  113945. * @param loop defines if the animation should loop (false by default)
  113946. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  113947. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  113948. * @returns the object created for this animation. If range does not exist, it will return null
  113949. */
  113950. beginAnimation(name: string, loop?: boolean, speedRatio?: number, onAnimationEnd?: () => void): Nullable<Animatable>;
  113951. /**
  113952. * Serialize animation ranges into a JSON compatible object
  113953. * @returns serialization object
  113954. */
  113955. serializeAnimationRanges(): any;
  113956. /**
  113957. * Computes the world matrix of the node
  113958. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  113959. * @returns the world matrix
  113960. */
  113961. computeWorldMatrix(force?: boolean): Matrix;
  113962. /**
  113963. * Releases resources associated with this node.
  113964. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  113965. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  113966. */
  113967. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  113968. /**
  113969. * Parse animation range data from a serialization object and store them into a given node
  113970. * @param node defines where to store the animation ranges
  113971. * @param parsedNode defines the serialization object to read data from
  113972. * @param scene defines the hosting scene
  113973. */
  113974. static ParseAnimationRanges(node: Node, parsedNode: any, scene: Scene): void;
  113975. /**
  113976. * Return the minimum and maximum world vectors of the entire hierarchy under current node
  113977. * @param includeDescendants Include bounding info from descendants as well (true by default)
  113978. * @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
  113979. * @returns the new bounding vectors
  113980. */
  113981. getHierarchyBoundingVectors(includeDescendants?: boolean, predicate?: Nullable<(abstractMesh: AbstractMesh) => boolean>): {
  113982. min: Vector3;
  113983. max: Vector3;
  113984. };
  113985. }
  113986. }
  113987. declare module BABYLON {
  113988. /**
  113989. * @hidden
  113990. */
  113991. export class _IAnimationState {
  113992. key: number;
  113993. repeatCount: number;
  113994. workValue?: any;
  113995. loopMode?: number;
  113996. offsetValue?: any;
  113997. highLimitValue?: any;
  113998. }
  113999. /**
  114000. * Class used to store any kind of animation
  114001. */
  114002. export class Animation {
  114003. /**Name of the animation */
  114004. name: string;
  114005. /**Property to animate */
  114006. targetProperty: string;
  114007. /**The frames per second of the animation */
  114008. framePerSecond: number;
  114009. /**The data type of the animation */
  114010. dataType: number;
  114011. /**The loop mode of the animation */
  114012. loopMode?: number | undefined;
  114013. /**Specifies if blending should be enabled */
  114014. enableBlending?: boolean | undefined;
  114015. /**
  114016. * Use matrix interpolation instead of using direct key value when animating matrices
  114017. */
  114018. static AllowMatricesInterpolation: boolean;
  114019. /**
  114020. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  114021. */
  114022. static AllowMatrixDecomposeForInterpolation: boolean;
  114023. /** Define the Url to load snippets */
  114024. static SnippetUrl: string;
  114025. /** Snippet ID if the animation was created from the snippet server */
  114026. snippetId: string;
  114027. /**
  114028. * Stores the key frames of the animation
  114029. */
  114030. private _keys;
  114031. /**
  114032. * Stores the easing function of the animation
  114033. */
  114034. private _easingFunction;
  114035. /**
  114036. * @hidden Internal use only
  114037. */
  114038. _runtimeAnimations: RuntimeAnimation[];
  114039. /**
  114040. * The set of event that will be linked to this animation
  114041. */
  114042. private _events;
  114043. /**
  114044. * Stores an array of target property paths
  114045. */
  114046. targetPropertyPath: string[];
  114047. /**
  114048. * Stores the blending speed of the animation
  114049. */
  114050. blendingSpeed: number;
  114051. /**
  114052. * Stores the animation ranges for the animation
  114053. */
  114054. private _ranges;
  114055. /**
  114056. * @hidden Internal use
  114057. */
  114058. static _PrepareAnimation(name: string, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction): Nullable<Animation>;
  114059. /**
  114060. * Sets up an animation
  114061. * @param property The property to animate
  114062. * @param animationType The animation type to apply
  114063. * @param framePerSecond The frames per second of the animation
  114064. * @param easingFunction The easing function used in the animation
  114065. * @returns The created animation
  114066. */
  114067. static CreateAnimation(property: string, animationType: number, framePerSecond: number, easingFunction: EasingFunction): Animation;
  114068. /**
  114069. * Create and start an animation on a node
  114070. * @param name defines the name of the global animation that will be run on all nodes
  114071. * @param node defines the root node where the animation will take place
  114072. * @param targetProperty defines property to animate
  114073. * @param framePerSecond defines the number of frame per second yo use
  114074. * @param totalFrame defines the number of frames in total
  114075. * @param from defines the initial value
  114076. * @param to defines the final value
  114077. * @param loopMode defines which loop mode you want to use (off by default)
  114078. * @param easingFunction defines the easing function to use (linear by default)
  114079. * @param onAnimationEnd defines the callback to call when animation end
  114080. * @returns the animatable created for this animation
  114081. */
  114082. static CreateAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  114083. /**
  114084. * Create and start an animation on a node and its descendants
  114085. * @param name defines the name of the global animation that will be run on all nodes
  114086. * @param node defines the root node where the animation will take place
  114087. * @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
  114088. * @param targetProperty defines property to animate
  114089. * @param framePerSecond defines the number of frame per second to use
  114090. * @param totalFrame defines the number of frames in total
  114091. * @param from defines the initial value
  114092. * @param to defines the final value
  114093. * @param loopMode defines which loop mode you want to use (off by default)
  114094. * @param easingFunction defines the easing function to use (linear by default)
  114095. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  114096. * @returns the list of animatables created for all nodes
  114097. * @example https://www.babylonjs-playground.com/#MH0VLI
  114098. */
  114099. 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[]>;
  114100. /**
  114101. * Creates a new animation, merges it with the existing animations and starts it
  114102. * @param name Name of the animation
  114103. * @param node Node which contains the scene that begins the animations
  114104. * @param targetProperty Specifies which property to animate
  114105. * @param framePerSecond The frames per second of the animation
  114106. * @param totalFrame The total number of frames
  114107. * @param from The frame at the beginning of the animation
  114108. * @param to The frame at the end of the animation
  114109. * @param loopMode Specifies the loop mode of the animation
  114110. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  114111. * @param onAnimationEnd Callback to run once the animation is complete
  114112. * @returns Nullable animation
  114113. */
  114114. static CreateMergeAndStartAnimation(name: string, node: Node, targetProperty: string, framePerSecond: number, totalFrame: number, from: any, to: any, loopMode?: number, easingFunction?: EasingFunction, onAnimationEnd?: () => void): Nullable<Animatable>;
  114115. /**
  114116. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  114117. * @param sourceAnimation defines the Animation containing keyframes to convert
  114118. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  114119. * @param range defines the name of the AnimationRange belonging to the Animation to convert
  114120. * @param cloneOriginal defines whether or not to clone the animation and convert the clone or convert the original animation (default is false)
  114121. * @param clonedName defines the name of the resulting cloned Animation if cloneOriginal is true
  114122. * @returns a new Animation if cloneOriginal is true or the original Animation if cloneOriginal is false
  114123. */
  114124. static MakeAnimationAdditive(sourceAnimation: Animation, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): Animation;
  114125. /**
  114126. * Transition property of an host to the target Value
  114127. * @param property The property to transition
  114128. * @param targetValue The target Value of the property
  114129. * @param host The object where the property to animate belongs
  114130. * @param scene Scene used to run the animation
  114131. * @param frameRate Framerate (in frame/s) to use
  114132. * @param transition The transition type we want to use
  114133. * @param duration The duration of the animation, in milliseconds
  114134. * @param onAnimationEnd Callback trigger at the end of the animation
  114135. * @returns Nullable animation
  114136. */
  114137. static TransitionTo(property: string, targetValue: any, host: any, scene: Scene, frameRate: number, transition: Animation, duration: number, onAnimationEnd?: Nullable<() => void>): Nullable<Animatable>;
  114138. /**
  114139. * Return the array of runtime animations currently using this animation
  114140. */
  114141. get runtimeAnimations(): RuntimeAnimation[];
  114142. /**
  114143. * Specifies if any of the runtime animations are currently running
  114144. */
  114145. get hasRunningRuntimeAnimations(): boolean;
  114146. /**
  114147. * Initializes the animation
  114148. * @param name Name of the animation
  114149. * @param targetProperty Property to animate
  114150. * @param framePerSecond The frames per second of the animation
  114151. * @param dataType The data type of the animation
  114152. * @param loopMode The loop mode of the animation
  114153. * @param enableBlending Specifies if blending should be enabled
  114154. */
  114155. constructor(
  114156. /**Name of the animation */
  114157. name: string,
  114158. /**Property to animate */
  114159. targetProperty: string,
  114160. /**The frames per second of the animation */
  114161. framePerSecond: number,
  114162. /**The data type of the animation */
  114163. dataType: number,
  114164. /**The loop mode of the animation */
  114165. loopMode?: number | undefined,
  114166. /**Specifies if blending should be enabled */
  114167. enableBlending?: boolean | undefined);
  114168. /**
  114169. * Converts the animation to a string
  114170. * @param fullDetails support for multiple levels of logging within scene loading
  114171. * @returns String form of the animation
  114172. */
  114173. toString(fullDetails?: boolean): string;
  114174. /**
  114175. * Add an event to this animation
  114176. * @param event Event to add
  114177. */
  114178. addEvent(event: AnimationEvent): void;
  114179. /**
  114180. * Remove all events found at the given frame
  114181. * @param frame The frame to remove events from
  114182. */
  114183. removeEvents(frame: number): void;
  114184. /**
  114185. * Retrieves all the events from the animation
  114186. * @returns Events from the animation
  114187. */
  114188. getEvents(): AnimationEvent[];
  114189. /**
  114190. * Creates an animation range
  114191. * @param name Name of the animation range
  114192. * @param from Starting frame of the animation range
  114193. * @param to Ending frame of the animation
  114194. */
  114195. createRange(name: string, from: number, to: number): void;
  114196. /**
  114197. * Deletes an animation range by name
  114198. * @param name Name of the animation range to delete
  114199. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  114200. */
  114201. deleteRange(name: string, deleteFrames?: boolean): void;
  114202. /**
  114203. * Gets the animation range by name, or null if not defined
  114204. * @param name Name of the animation range
  114205. * @returns Nullable animation range
  114206. */
  114207. getRange(name: string): Nullable<AnimationRange>;
  114208. /**
  114209. * Gets the key frames from the animation
  114210. * @returns The key frames of the animation
  114211. */
  114212. getKeys(): Array<IAnimationKey>;
  114213. /**
  114214. * Gets the highest frame rate of the animation
  114215. * @returns Highest frame rate of the animation
  114216. */
  114217. getHighestFrame(): number;
  114218. /**
  114219. * Gets the easing function of the animation
  114220. * @returns Easing function of the animation
  114221. */
  114222. getEasingFunction(): IEasingFunction;
  114223. /**
  114224. * Sets the easing function of the animation
  114225. * @param easingFunction A custom mathematical formula for animation
  114226. */
  114227. setEasingFunction(easingFunction: EasingFunction): void;
  114228. /**
  114229. * Interpolates a scalar linearly
  114230. * @param startValue Start value of the animation curve
  114231. * @param endValue End value of the animation curve
  114232. * @param gradient Scalar amount to interpolate
  114233. * @returns Interpolated scalar value
  114234. */
  114235. floatInterpolateFunction(startValue: number, endValue: number, gradient: number): number;
  114236. /**
  114237. * Interpolates a scalar cubically
  114238. * @param startValue Start value of the animation curve
  114239. * @param outTangent End tangent of the animation
  114240. * @param endValue End value of the animation curve
  114241. * @param inTangent Start tangent of the animation curve
  114242. * @param gradient Scalar amount to interpolate
  114243. * @returns Interpolated scalar value
  114244. */
  114245. floatInterpolateFunctionWithTangents(startValue: number, outTangent: number, endValue: number, inTangent: number, gradient: number): number;
  114246. /**
  114247. * Interpolates a quaternion using a spherical linear interpolation
  114248. * @param startValue Start value of the animation curve
  114249. * @param endValue End value of the animation curve
  114250. * @param gradient Scalar amount to interpolate
  114251. * @returns Interpolated quaternion value
  114252. */
  114253. quaternionInterpolateFunction(startValue: Quaternion, endValue: Quaternion, gradient: number): Quaternion;
  114254. /**
  114255. * Interpolates a quaternion cubically
  114256. * @param startValue Start value of the animation curve
  114257. * @param outTangent End tangent of the animation curve
  114258. * @param endValue End value of the animation curve
  114259. * @param inTangent Start tangent of the animation curve
  114260. * @param gradient Scalar amount to interpolate
  114261. * @returns Interpolated quaternion value
  114262. */
  114263. quaternionInterpolateFunctionWithTangents(startValue: Quaternion, outTangent: Quaternion, endValue: Quaternion, inTangent: Quaternion, gradient: number): Quaternion;
  114264. /**
  114265. * Interpolates a Vector3 linearl
  114266. * @param startValue Start value of the animation curve
  114267. * @param endValue End value of the animation curve
  114268. * @param gradient Scalar amount to interpolate
  114269. * @returns Interpolated scalar value
  114270. */
  114271. vector3InterpolateFunction(startValue: Vector3, endValue: Vector3, gradient: number): Vector3;
  114272. /**
  114273. * Interpolates a Vector3 cubically
  114274. * @param startValue Start value of the animation curve
  114275. * @param outTangent End tangent of the animation
  114276. * @param endValue End value of the animation curve
  114277. * @param inTangent Start tangent of the animation curve
  114278. * @param gradient Scalar amount to interpolate
  114279. * @returns InterpolatedVector3 value
  114280. */
  114281. vector3InterpolateFunctionWithTangents(startValue: Vector3, outTangent: Vector3, endValue: Vector3, inTangent: Vector3, gradient: number): Vector3;
  114282. /**
  114283. * Interpolates a Vector2 linearly
  114284. * @param startValue Start value of the animation curve
  114285. * @param endValue End value of the animation curve
  114286. * @param gradient Scalar amount to interpolate
  114287. * @returns Interpolated Vector2 value
  114288. */
  114289. vector2InterpolateFunction(startValue: Vector2, endValue: Vector2, gradient: number): Vector2;
  114290. /**
  114291. * Interpolates a Vector2 cubically
  114292. * @param startValue Start value of the animation curve
  114293. * @param outTangent End tangent of the animation
  114294. * @param endValue End value of the animation curve
  114295. * @param inTangent Start tangent of the animation curve
  114296. * @param gradient Scalar amount to interpolate
  114297. * @returns Interpolated Vector2 value
  114298. */
  114299. vector2InterpolateFunctionWithTangents(startValue: Vector2, outTangent: Vector2, endValue: Vector2, inTangent: Vector2, gradient: number): Vector2;
  114300. /**
  114301. * Interpolates a size linearly
  114302. * @param startValue Start value of the animation curve
  114303. * @param endValue End value of the animation curve
  114304. * @param gradient Scalar amount to interpolate
  114305. * @returns Interpolated Size value
  114306. */
  114307. sizeInterpolateFunction(startValue: Size, endValue: Size, gradient: number): Size;
  114308. /**
  114309. * Interpolates a Color3 linearly
  114310. * @param startValue Start value of the animation curve
  114311. * @param endValue End value of the animation curve
  114312. * @param gradient Scalar amount to interpolate
  114313. * @returns Interpolated Color3 value
  114314. */
  114315. color3InterpolateFunction(startValue: Color3, endValue: Color3, gradient: number): Color3;
  114316. /**
  114317. * Interpolates a Color4 linearly
  114318. * @param startValue Start value of the animation curve
  114319. * @param endValue End value of the animation curve
  114320. * @param gradient Scalar amount to interpolate
  114321. * @returns Interpolated Color3 value
  114322. */
  114323. color4InterpolateFunction(startValue: Color4, endValue: Color4, gradient: number): Color4;
  114324. /**
  114325. * @hidden Internal use only
  114326. */
  114327. _getKeyValue(value: any): any;
  114328. /**
  114329. * @hidden Internal use only
  114330. */
  114331. _interpolate(currentFrame: number, state: _IAnimationState): any;
  114332. /**
  114333. * Defines the function to use to interpolate matrices
  114334. * @param startValue defines the start matrix
  114335. * @param endValue defines the end matrix
  114336. * @param gradient defines the gradient between both matrices
  114337. * @param result defines an optional target matrix where to store the interpolation
  114338. * @returns the interpolated matrix
  114339. */
  114340. matrixInterpolateFunction(startValue: Matrix, endValue: Matrix, gradient: number, result?: Matrix): Matrix;
  114341. /**
  114342. * Makes a copy of the animation
  114343. * @returns Cloned animation
  114344. */
  114345. clone(): Animation;
  114346. /**
  114347. * Sets the key frames of the animation
  114348. * @param values The animation key frames to set
  114349. */
  114350. setKeys(values: Array<IAnimationKey>): void;
  114351. /**
  114352. * Serializes the animation to an object
  114353. * @returns Serialized object
  114354. */
  114355. serialize(): any;
  114356. /**
  114357. * Float animation type
  114358. */
  114359. static readonly ANIMATIONTYPE_FLOAT: number;
  114360. /**
  114361. * Vector3 animation type
  114362. */
  114363. static readonly ANIMATIONTYPE_VECTOR3: number;
  114364. /**
  114365. * Quaternion animation type
  114366. */
  114367. static readonly ANIMATIONTYPE_QUATERNION: number;
  114368. /**
  114369. * Matrix animation type
  114370. */
  114371. static readonly ANIMATIONTYPE_MATRIX: number;
  114372. /**
  114373. * Color3 animation type
  114374. */
  114375. static readonly ANIMATIONTYPE_COLOR3: number;
  114376. /**
  114377. * Color3 animation type
  114378. */
  114379. static readonly ANIMATIONTYPE_COLOR4: number;
  114380. /**
  114381. * Vector2 animation type
  114382. */
  114383. static readonly ANIMATIONTYPE_VECTOR2: number;
  114384. /**
  114385. * Size animation type
  114386. */
  114387. static readonly ANIMATIONTYPE_SIZE: number;
  114388. /**
  114389. * Relative Loop Mode
  114390. */
  114391. static readonly ANIMATIONLOOPMODE_RELATIVE: number;
  114392. /**
  114393. * Cycle Loop Mode
  114394. */
  114395. static readonly ANIMATIONLOOPMODE_CYCLE: number;
  114396. /**
  114397. * Constant Loop Mode
  114398. */
  114399. static readonly ANIMATIONLOOPMODE_CONSTANT: number;
  114400. /** @hidden */
  114401. static _UniversalLerp(left: any, right: any, amount: number): any;
  114402. /**
  114403. * Parses an animation object and creates an animation
  114404. * @param parsedAnimation Parsed animation object
  114405. * @returns Animation object
  114406. */
  114407. static Parse(parsedAnimation: any): Animation;
  114408. /**
  114409. * Appends the serialized animations from the source animations
  114410. * @param source Source containing the animations
  114411. * @param destination Target to store the animations
  114412. */
  114413. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114414. /**
  114415. * Creates a new animation or an array of animations from a snippet saved in a remote file
  114416. * @param name defines the name of the animation to create (can be null or empty to use the one from the json data)
  114417. * @param url defines the url to load from
  114418. * @returns a promise that will resolve to the new animation or an array of animations
  114419. */
  114420. static ParseFromFileAsync(name: Nullable<string>, url: string): Promise<Animation | Array<Animation>>;
  114421. /**
  114422. * Creates an animation or an array of animations from a snippet saved by the Inspector
  114423. * @param snippetId defines the snippet to load
  114424. * @returns a promise that will resolve to the new animation or a new array of animations
  114425. */
  114426. static CreateFromSnippetAsync(snippetId: string): Promise<Animation | Array<Animation>>;
  114427. }
  114428. }
  114429. declare module BABYLON {
  114430. /**
  114431. * Interface containing an array of animations
  114432. */
  114433. export interface IAnimatable {
  114434. /**
  114435. * Array of animations
  114436. */
  114437. animations: Nullable<Array<Animation>>;
  114438. }
  114439. }
  114440. declare module BABYLON {
  114441. export function expandToProperty(callback: string, targetKey?: Nullable<string>): (target: any, propertyKey: string) => void;
  114442. export function serialize(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114443. export function serializeAsTexture(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114444. export function serializeAsColor3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114445. export function serializeAsFresnelParameters(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114446. export function serializeAsVector2(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114447. export function serializeAsVector3(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114448. export function serializeAsMeshReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114449. export function serializeAsColorCurves(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114450. export function serializeAsColor4(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114451. export function serializeAsImageProcessingConfiguration(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114452. export function serializeAsQuaternion(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114453. export function serializeAsMatrix(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114454. /**
  114455. * Decorator used to define property that can be serialized as reference to a camera
  114456. * @param sourceName defines the name of the property to decorate
  114457. */
  114458. export function serializeAsCameraReference(sourceName?: string): (target: any, propertyKey: string | symbol) => void;
  114459. /**
  114460. * Class used to help serialization objects
  114461. */
  114462. export class SerializationHelper {
  114463. /** @hidden */
  114464. static _ImageProcessingConfigurationParser: (sourceProperty: any) => ImageProcessingConfiguration;
  114465. /** @hidden */
  114466. static _FresnelParametersParser: (sourceProperty: any) => FresnelParameters;
  114467. /** @hidden */
  114468. static _ColorCurvesParser: (sourceProperty: any) => ColorCurves;
  114469. /** @hidden */
  114470. static _TextureParser: (sourceProperty: any, scene: Scene, rootUrl: string) => Nullable<BaseTexture>;
  114471. /**
  114472. * Appends the serialized animations from the source animations
  114473. * @param source Source containing the animations
  114474. * @param destination Target to store the animations
  114475. */
  114476. static AppendSerializedAnimations(source: IAnimatable, destination: any): void;
  114477. /**
  114478. * Static function used to serialized a specific entity
  114479. * @param entity defines the entity to serialize
  114480. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  114481. * @returns a JSON compatible object representing the serialization of the entity
  114482. */
  114483. static Serialize<T>(entity: T, serializationObject?: any): any;
  114484. /**
  114485. * Creates a new entity from a serialization data object
  114486. * @param creationFunction defines a function used to instanciated the new entity
  114487. * @param source defines the source serialization data
  114488. * @param scene defines the hosting scene
  114489. * @param rootUrl defines the root url for resources
  114490. * @returns a new entity
  114491. */
  114492. static Parse<T>(creationFunction: () => T, source: any, scene: Nullable<Scene>, rootUrl?: Nullable<string>): T;
  114493. /**
  114494. * Clones an object
  114495. * @param creationFunction defines the function used to instanciate the new object
  114496. * @param source defines the source object
  114497. * @returns the cloned object
  114498. */
  114499. static Clone<T>(creationFunction: () => T, source: T): T;
  114500. /**
  114501. * Instanciates a new object based on a source one (some data will be shared between both object)
  114502. * @param creationFunction defines the function used to instanciate the new object
  114503. * @param source defines the source object
  114504. * @returns the new object
  114505. */
  114506. static Instanciate<T>(creationFunction: () => T, source: T): T;
  114507. }
  114508. }
  114509. declare module BABYLON {
  114510. /**
  114511. * Base class of all the textures in babylon.
  114512. * It groups all the common properties the materials, post process, lights... might need
  114513. * in order to make a correct use of the texture.
  114514. */
  114515. export class BaseTexture implements IAnimatable {
  114516. /**
  114517. * Default anisotropic filtering level for the application.
  114518. * It is set to 4 as a good tradeoff between perf and quality.
  114519. */
  114520. static DEFAULT_ANISOTROPIC_FILTERING_LEVEL: number;
  114521. /**
  114522. * Gets or sets the unique id of the texture
  114523. */
  114524. uniqueId: number;
  114525. /**
  114526. * Define the name of the texture.
  114527. */
  114528. name: string;
  114529. /**
  114530. * Gets or sets an object used to store user defined information.
  114531. */
  114532. metadata: any;
  114533. /**
  114534. * For internal use only. Please do not use.
  114535. */
  114536. reservedDataStore: any;
  114537. private _hasAlpha;
  114538. /**
  114539. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  114540. */
  114541. set hasAlpha(value: boolean);
  114542. get hasAlpha(): boolean;
  114543. /**
  114544. * Defines if the alpha value should be determined via the rgb values.
  114545. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  114546. */
  114547. getAlphaFromRGB: boolean;
  114548. /**
  114549. * Intensity or strength of the texture.
  114550. * It is commonly used by materials to fine tune the intensity of the texture
  114551. */
  114552. level: number;
  114553. /**
  114554. * Define the UV chanel to use starting from 0 and defaulting to 0.
  114555. * This is part of the texture as textures usually maps to one uv set.
  114556. */
  114557. coordinatesIndex: number;
  114558. protected _coordinatesMode: number;
  114559. /**
  114560. * How a texture is mapped.
  114561. *
  114562. * | Value | Type | Description |
  114563. * | ----- | ----------------------------------- | ----------- |
  114564. * | 0 | EXPLICIT_MODE | |
  114565. * | 1 | SPHERICAL_MODE | |
  114566. * | 2 | PLANAR_MODE | |
  114567. * | 3 | CUBIC_MODE | |
  114568. * | 4 | PROJECTION_MODE | |
  114569. * | 5 | SKYBOX_MODE | |
  114570. * | 6 | INVCUBIC_MODE | |
  114571. * | 7 | EQUIRECTANGULAR_MODE | |
  114572. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  114573. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  114574. */
  114575. set coordinatesMode(value: number);
  114576. get coordinatesMode(): number;
  114577. private _wrapU;
  114578. /**
  114579. * | Value | Type | Description |
  114580. * | ----- | ------------------ | ----------- |
  114581. * | 0 | CLAMP_ADDRESSMODE | |
  114582. * | 1 | WRAP_ADDRESSMODE | |
  114583. * | 2 | MIRROR_ADDRESSMODE | |
  114584. */
  114585. get wrapU(): number;
  114586. set wrapU(value: number);
  114587. private _wrapV;
  114588. /**
  114589. * | Value | Type | Description |
  114590. * | ----- | ------------------ | ----------- |
  114591. * | 0 | CLAMP_ADDRESSMODE | |
  114592. * | 1 | WRAP_ADDRESSMODE | |
  114593. * | 2 | MIRROR_ADDRESSMODE | |
  114594. */
  114595. get wrapV(): number;
  114596. set wrapV(value: number);
  114597. /**
  114598. * | Value | Type | Description |
  114599. * | ----- | ------------------ | ----------- |
  114600. * | 0 | CLAMP_ADDRESSMODE | |
  114601. * | 1 | WRAP_ADDRESSMODE | |
  114602. * | 2 | MIRROR_ADDRESSMODE | |
  114603. */
  114604. wrapR: number;
  114605. /**
  114606. * With compliant hardware and browser (supporting anisotropic filtering)
  114607. * this defines the level of anisotropic filtering in the texture.
  114608. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  114609. */
  114610. anisotropicFilteringLevel: number;
  114611. /**
  114612. * Define if the texture is a cube texture or if false a 2d texture.
  114613. */
  114614. get isCube(): boolean;
  114615. set isCube(value: boolean);
  114616. /**
  114617. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  114618. */
  114619. get is3D(): boolean;
  114620. set is3D(value: boolean);
  114621. /**
  114622. * Define if the texture is a 2d array texture (webgl 2) or if false a 2d texture.
  114623. */
  114624. get is2DArray(): boolean;
  114625. set is2DArray(value: boolean);
  114626. private _gammaSpace;
  114627. /**
  114628. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  114629. * HDR texture are usually stored in linear space.
  114630. * This only impacts the PBR and Background materials
  114631. */
  114632. get gammaSpace(): boolean;
  114633. set gammaSpace(gamma: boolean);
  114634. /**
  114635. * Gets or sets whether or not the texture contains RGBD data.
  114636. */
  114637. get isRGBD(): boolean;
  114638. set isRGBD(value: boolean);
  114639. /**
  114640. * Is Z inverted in the texture (useful in a cube texture).
  114641. */
  114642. invertZ: boolean;
  114643. /**
  114644. * Are mip maps generated for this texture or not.
  114645. */
  114646. get noMipmap(): boolean;
  114647. /**
  114648. * @hidden
  114649. */
  114650. lodLevelInAlpha: boolean;
  114651. /**
  114652. * With prefiltered texture, defined the offset used during the prefiltering steps.
  114653. */
  114654. get lodGenerationOffset(): number;
  114655. set lodGenerationOffset(value: number);
  114656. /**
  114657. * With prefiltered texture, defined the scale used during the prefiltering steps.
  114658. */
  114659. get lodGenerationScale(): number;
  114660. set lodGenerationScale(value: number);
  114661. /**
  114662. * With prefiltered texture, defined if the specular generation is based on a linear ramp.
  114663. * By default we are using a log2 of the linear roughness helping to keep a better resolution for
  114664. * average roughness values.
  114665. */
  114666. get linearSpecularLOD(): boolean;
  114667. set linearSpecularLOD(value: boolean);
  114668. /**
  114669. * In case a better definition than spherical harmonics is required for the diffuse part of the environment.
  114670. * You can set the irradiance texture to rely on a texture instead of the spherical approach.
  114671. * This texture need to have the same characteristics than its parent (Cube vs 2d, coordinates mode, Gamma/Linear, RGBD).
  114672. */
  114673. get irradianceTexture(): Nullable<BaseTexture>;
  114674. set irradianceTexture(value: Nullable<BaseTexture>);
  114675. /**
  114676. * Define if the texture is a render target.
  114677. */
  114678. isRenderTarget: boolean;
  114679. /**
  114680. * Define the unique id of the texture in the scene.
  114681. */
  114682. get uid(): string;
  114683. /** @hidden */
  114684. _prefiltered: boolean;
  114685. /**
  114686. * Return a string representation of the texture.
  114687. * @returns the texture as a string
  114688. */
  114689. toString(): string;
  114690. /**
  114691. * Get the class name of the texture.
  114692. * @returns "BaseTexture"
  114693. */
  114694. getClassName(): string;
  114695. /**
  114696. * Define the list of animation attached to the texture.
  114697. */
  114698. animations: Animation[];
  114699. /**
  114700. * An event triggered when the texture is disposed.
  114701. */
  114702. onDisposeObservable: Observable<BaseTexture>;
  114703. private _onDisposeObserver;
  114704. /**
  114705. * Callback triggered when the texture has been disposed.
  114706. * Kept for back compatibility, you can use the onDisposeObservable instead.
  114707. */
  114708. set onDispose(callback: () => void);
  114709. /**
  114710. * Define the current state of the loading sequence when in delayed load mode.
  114711. */
  114712. delayLoadState: number;
  114713. protected _scene: Nullable<Scene>;
  114714. protected _engine: Nullable<ThinEngine>;
  114715. /** @hidden */
  114716. _texture: Nullable<InternalTexture>;
  114717. private _uid;
  114718. /**
  114719. * Define if the texture is preventinga material to render or not.
  114720. * If not and the texture is not ready, the engine will use a default black texture instead.
  114721. */
  114722. get isBlocking(): boolean;
  114723. /**
  114724. * Instantiates a new BaseTexture.
  114725. * Base class of all the textures in babylon.
  114726. * It groups all the common properties the materials, post process, lights... might need
  114727. * in order to make a correct use of the texture.
  114728. * @param sceneOrEngine Define the scene or engine the texture blongs to
  114729. */
  114730. constructor(sceneOrEngine: Nullable<Scene | ThinEngine>);
  114731. /**
  114732. * Get the scene the texture belongs to.
  114733. * @returns the scene or null if undefined
  114734. */
  114735. getScene(): Nullable<Scene>;
  114736. /** @hidden */
  114737. protected _getEngine(): Nullable<ThinEngine>;
  114738. /**
  114739. * Get the texture transform matrix used to offset tile the texture for istance.
  114740. * @returns the transformation matrix
  114741. */
  114742. getTextureMatrix(): Matrix;
  114743. /**
  114744. * Get the texture reflection matrix used to rotate/transform the reflection.
  114745. * @returns the reflection matrix
  114746. */
  114747. getReflectionTextureMatrix(): Matrix;
  114748. /**
  114749. * Get the underlying lower level texture from Babylon.
  114750. * @returns the insternal texture
  114751. */
  114752. getInternalTexture(): Nullable<InternalTexture>;
  114753. /**
  114754. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  114755. * @returns true if ready or not blocking
  114756. */
  114757. isReadyOrNotBlocking(): boolean;
  114758. /**
  114759. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  114760. * @returns true if fully ready
  114761. */
  114762. isReady(): boolean;
  114763. private _cachedSize;
  114764. /**
  114765. * Get the size of the texture.
  114766. * @returns the texture size.
  114767. */
  114768. getSize(): ISize;
  114769. /**
  114770. * Get the base size of the texture.
  114771. * It can be different from the size if the texture has been resized for POT for instance
  114772. * @returns the base size
  114773. */
  114774. getBaseSize(): ISize;
  114775. /**
  114776. * Update the sampling mode of the texture.
  114777. * Default is Trilinear mode.
  114778. *
  114779. * | Value | Type | Description |
  114780. * | ----- | ------------------ | ----------- |
  114781. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  114782. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  114783. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  114784. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  114785. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  114786. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  114787. * | 7 | NEAREST_LINEAR | |
  114788. * | 8 | NEAREST_NEAREST | |
  114789. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  114790. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  114791. * | 11 | LINEAR_LINEAR | |
  114792. * | 12 | LINEAR_NEAREST | |
  114793. *
  114794. * > _mag_: magnification filter (close to the viewer)
  114795. * > _min_: minification filter (far from the viewer)
  114796. * > _mip_: filter used between mip map levels
  114797. *@param samplingMode Define the new sampling mode of the texture
  114798. */
  114799. updateSamplingMode(samplingMode: number): void;
  114800. /**
  114801. * Scales the texture if is `canRescale()`
  114802. * @param ratio the resize factor we want to use to rescale
  114803. */
  114804. scale(ratio: number): void;
  114805. /**
  114806. * Get if the texture can rescale.
  114807. */
  114808. get canRescale(): boolean;
  114809. /** @hidden */
  114810. _getFromCache(url: Nullable<string>, noMipmap: boolean, sampling?: number, invertY?: boolean): Nullable<InternalTexture>;
  114811. /** @hidden */
  114812. _rebuild(): void;
  114813. /**
  114814. * Triggers the load sequence in delayed load mode.
  114815. */
  114816. delayLoad(): void;
  114817. /**
  114818. * Clones the texture.
  114819. * @returns the cloned texture
  114820. */
  114821. clone(): Nullable<BaseTexture>;
  114822. /**
  114823. * Get the texture underlying type (INT, FLOAT...)
  114824. */
  114825. get textureType(): number;
  114826. /**
  114827. * Get the texture underlying format (RGB, RGBA...)
  114828. */
  114829. get textureFormat(): number;
  114830. /**
  114831. * Indicates that textures need to be re-calculated for all materials
  114832. */
  114833. protected _markAllSubMeshesAsTexturesDirty(): void;
  114834. /**
  114835. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  114836. * This will returns an RGBA array buffer containing either in values (0-255) or
  114837. * float values (0-1) depending of the underlying buffer type.
  114838. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  114839. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  114840. * @param buffer defines a user defined buffer to fill with data (can be null)
  114841. * @returns The Array buffer containing the pixels data.
  114842. */
  114843. readPixels(faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): Nullable<ArrayBufferView>;
  114844. /**
  114845. * Release and destroy the underlying lower level texture aka internalTexture.
  114846. */
  114847. releaseInternalTexture(): void;
  114848. /** @hidden */
  114849. get _lodTextureHigh(): Nullable<BaseTexture>;
  114850. /** @hidden */
  114851. get _lodTextureMid(): Nullable<BaseTexture>;
  114852. /** @hidden */
  114853. get _lodTextureLow(): Nullable<BaseTexture>;
  114854. /**
  114855. * Dispose the texture and release its associated resources.
  114856. */
  114857. dispose(): void;
  114858. /**
  114859. * Serialize the texture into a JSON representation that can be parsed later on.
  114860. * @returns the JSON representation of the texture
  114861. */
  114862. serialize(): any;
  114863. /**
  114864. * Helper function to be called back once a list of texture contains only ready textures.
  114865. * @param textures Define the list of textures to wait for
  114866. * @param callback Define the callback triggered once the entire list will be ready
  114867. */
  114868. static WhenAllReady(textures: BaseTexture[], callback: () => void): void;
  114869. private static _isScene;
  114870. }
  114871. }
  114872. declare module BABYLON {
  114873. /**
  114874. * Options to be used when creating an effect.
  114875. */
  114876. export interface IEffectCreationOptions {
  114877. /**
  114878. * Atrributes that will be used in the shader.
  114879. */
  114880. attributes: string[];
  114881. /**
  114882. * Uniform varible names that will be set in the shader.
  114883. */
  114884. uniformsNames: string[];
  114885. /**
  114886. * Uniform buffer variable names that will be set in the shader.
  114887. */
  114888. uniformBuffersNames: string[];
  114889. /**
  114890. * Sampler texture variable names that will be set in the shader.
  114891. */
  114892. samplers: string[];
  114893. /**
  114894. * Define statements that will be set in the shader.
  114895. */
  114896. defines: any;
  114897. /**
  114898. * Possible fallbacks for this effect to improve performance when needed.
  114899. */
  114900. fallbacks: Nullable<IEffectFallbacks>;
  114901. /**
  114902. * Callback that will be called when the shader is compiled.
  114903. */
  114904. onCompiled: Nullable<(effect: Effect) => void>;
  114905. /**
  114906. * Callback that will be called if an error occurs during shader compilation.
  114907. */
  114908. onError: Nullable<(effect: Effect, errors: string) => void>;
  114909. /**
  114910. * Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  114911. */
  114912. indexParameters?: any;
  114913. /**
  114914. * Max number of lights that can be used in the shader.
  114915. */
  114916. maxSimultaneousLights?: number;
  114917. /**
  114918. * See https://developer.mozilla.org/en-US/docs/Web/API/WebGL2RenderingContext/transformFeedbackVaryings
  114919. */
  114920. transformFeedbackVaryings?: Nullable<string[]>;
  114921. /**
  114922. * 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
  114923. */
  114924. processFinalCode?: Nullable<(shaderType: string, code: string) => string>;
  114925. /**
  114926. * Is this effect rendering to several color attachments ?
  114927. */
  114928. multiTarget?: boolean;
  114929. }
  114930. /**
  114931. * Effect containing vertex and fragment shader that can be executed on an object.
  114932. */
  114933. export class Effect implements IDisposable {
  114934. /**
  114935. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  114936. */
  114937. static ShadersRepository: string;
  114938. /**
  114939. * Enable logging of the shader code when a compilation error occurs
  114940. */
  114941. static LogShaderCodeOnCompilationError: boolean;
  114942. /**
  114943. * Name of the effect.
  114944. */
  114945. name: any;
  114946. /**
  114947. * String container all the define statements that should be set on the shader.
  114948. */
  114949. defines: string;
  114950. /**
  114951. * Callback that will be called when the shader is compiled.
  114952. */
  114953. onCompiled: Nullable<(effect: Effect) => void>;
  114954. /**
  114955. * Callback that will be called if an error occurs during shader compilation.
  114956. */
  114957. onError: Nullable<(effect: Effect, errors: string) => void>;
  114958. /**
  114959. * Callback that will be called when effect is bound.
  114960. */
  114961. onBind: Nullable<(effect: Effect) => void>;
  114962. /**
  114963. * Unique ID of the effect.
  114964. */
  114965. uniqueId: number;
  114966. /**
  114967. * Observable that will be called when the shader is compiled.
  114968. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  114969. */
  114970. onCompileObservable: Observable<Effect>;
  114971. /**
  114972. * Observable that will be called if an error occurs during shader compilation.
  114973. */
  114974. onErrorObservable: Observable<Effect>;
  114975. /** @hidden */
  114976. _onBindObservable: Nullable<Observable<Effect>>;
  114977. /**
  114978. * @hidden
  114979. * Specifies if the effect was previously ready
  114980. */
  114981. _wasPreviouslyReady: boolean;
  114982. /**
  114983. * Observable that will be called when effect is bound.
  114984. */
  114985. get onBindObservable(): Observable<Effect>;
  114986. /** @hidden */
  114987. _bonesComputationForcedToCPU: boolean;
  114988. /** @hidden */
  114989. _multiTarget: boolean;
  114990. private static _uniqueIdSeed;
  114991. private _engine;
  114992. private _uniformBuffersNames;
  114993. private _uniformBuffersNamesList;
  114994. private _uniformsNames;
  114995. private _samplerList;
  114996. private _samplers;
  114997. private _isReady;
  114998. private _compilationError;
  114999. private _allFallbacksProcessed;
  115000. private _attributesNames;
  115001. private _attributes;
  115002. private _attributeLocationByName;
  115003. private _uniforms;
  115004. /**
  115005. * Key for the effect.
  115006. * @hidden
  115007. */
  115008. _key: string;
  115009. private _indexParameters;
  115010. private _fallbacks;
  115011. private _vertexSourceCode;
  115012. private _fragmentSourceCode;
  115013. private _vertexSourceCodeOverride;
  115014. private _fragmentSourceCodeOverride;
  115015. private _transformFeedbackVaryings;
  115016. /**
  115017. * Compiled shader to webGL program.
  115018. * @hidden
  115019. */
  115020. _pipelineContext: Nullable<IPipelineContext>;
  115021. private _valueCache;
  115022. private static _baseCache;
  115023. /**
  115024. * Instantiates an effect.
  115025. * An effect can be used to create/manage/execute vertex and fragment shaders.
  115026. * @param baseName Name of the effect.
  115027. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  115028. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  115029. * @param samplers List of sampler variables that will be passed to the shader.
  115030. * @param engine Engine to be used to render the effect
  115031. * @param defines Define statements to be added to the shader.
  115032. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  115033. * @param onCompiled Callback that will be called when the shader is compiled.
  115034. * @param onError Callback that will be called if an error occurs during shader compilation.
  115035. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  115036. */
  115037. 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);
  115038. private _useFinalCode;
  115039. /**
  115040. * Unique key for this effect
  115041. */
  115042. get key(): string;
  115043. /**
  115044. * If the effect has been compiled and prepared.
  115045. * @returns if the effect is compiled and prepared.
  115046. */
  115047. isReady(): boolean;
  115048. private _isReadyInternal;
  115049. /**
  115050. * The engine the effect was initialized with.
  115051. * @returns the engine.
  115052. */
  115053. getEngine(): Engine;
  115054. /**
  115055. * The pipeline context for this effect
  115056. * @returns the associated pipeline context
  115057. */
  115058. getPipelineContext(): Nullable<IPipelineContext>;
  115059. /**
  115060. * The set of names of attribute variables for the shader.
  115061. * @returns An array of attribute names.
  115062. */
  115063. getAttributesNames(): string[];
  115064. /**
  115065. * Returns the attribute at the given index.
  115066. * @param index The index of the attribute.
  115067. * @returns The location of the attribute.
  115068. */
  115069. getAttributeLocation(index: number): number;
  115070. /**
  115071. * Returns the attribute based on the name of the variable.
  115072. * @param name of the attribute to look up.
  115073. * @returns the attribute location.
  115074. */
  115075. getAttributeLocationByName(name: string): number;
  115076. /**
  115077. * The number of attributes.
  115078. * @returns the numnber of attributes.
  115079. */
  115080. getAttributesCount(): number;
  115081. /**
  115082. * Gets the index of a uniform variable.
  115083. * @param uniformName of the uniform to look up.
  115084. * @returns the index.
  115085. */
  115086. getUniformIndex(uniformName: string): number;
  115087. /**
  115088. * Returns the attribute based on the name of the variable.
  115089. * @param uniformName of the uniform to look up.
  115090. * @returns the location of the uniform.
  115091. */
  115092. getUniform(uniformName: string): Nullable<WebGLUniformLocation>;
  115093. /**
  115094. * Returns an array of sampler variable names
  115095. * @returns The array of sampler variable names.
  115096. */
  115097. getSamplers(): string[];
  115098. /**
  115099. * Returns an array of uniform variable names
  115100. * @returns The array of uniform variable names.
  115101. */
  115102. getUniformNames(): string[];
  115103. /**
  115104. * Returns an array of uniform buffer variable names
  115105. * @returns The array of uniform buffer variable names.
  115106. */
  115107. getUniformBuffersNames(): string[];
  115108. /**
  115109. * Returns the index parameters used to create the effect
  115110. * @returns The index parameters object
  115111. */
  115112. getIndexParameters(): any;
  115113. /**
  115114. * The error from the last compilation.
  115115. * @returns the error string.
  115116. */
  115117. getCompilationError(): string;
  115118. /**
  115119. * Gets a boolean indicating that all fallbacks were used during compilation
  115120. * @returns true if all fallbacks were used
  115121. */
  115122. allFallbacksProcessed(): boolean;
  115123. /**
  115124. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  115125. * @param func The callback to be used.
  115126. */
  115127. executeWhenCompiled(func: (effect: Effect) => void): void;
  115128. private _checkIsReady;
  115129. private _loadShader;
  115130. /**
  115131. * Gets the vertex shader source code of this effect
  115132. */
  115133. get vertexSourceCode(): string;
  115134. /**
  115135. * Gets the fragment shader source code of this effect
  115136. */
  115137. get fragmentSourceCode(): string;
  115138. /**
  115139. * Recompiles the webGL program
  115140. * @param vertexSourceCode The source code for the vertex shader.
  115141. * @param fragmentSourceCode The source code for the fragment shader.
  115142. * @param onCompiled Callback called when completed.
  115143. * @param onError Callback called on error.
  115144. * @hidden
  115145. */
  115146. _rebuildProgram(vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (pipelineContext: IPipelineContext) => void, onError: (message: string) => void): void;
  115147. /**
  115148. * Prepares the effect
  115149. * @hidden
  115150. */
  115151. _prepareEffect(): void;
  115152. private _getShaderCodeAndErrorLine;
  115153. private _processCompilationErrors;
  115154. /**
  115155. * Checks if the effect is supported. (Must be called after compilation)
  115156. */
  115157. get isSupported(): boolean;
  115158. /**
  115159. * Binds a texture to the engine to be used as output of the shader.
  115160. * @param channel Name of the output variable.
  115161. * @param texture Texture to bind.
  115162. * @hidden
  115163. */
  115164. _bindTexture(channel: string, texture: Nullable<InternalTexture>): void;
  115165. /**
  115166. * Sets a texture on the engine to be used in the shader.
  115167. * @param channel Name of the sampler variable.
  115168. * @param texture Texture to set.
  115169. */
  115170. setTexture(channel: string, texture: Nullable<BaseTexture>): void;
  115171. /**
  115172. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  115173. * @param channel Name of the sampler variable.
  115174. * @param texture Texture to set.
  115175. */
  115176. setDepthStencilTexture(channel: string, texture: Nullable<RenderTargetTexture>): void;
  115177. /**
  115178. * Sets an array of textures on the engine to be used in the shader.
  115179. * @param channel Name of the variable.
  115180. * @param textures Textures to set.
  115181. */
  115182. setTextureArray(channel: string, textures: BaseTexture[]): void;
  115183. /**
  115184. * 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)
  115185. * @param channel Name of the sampler variable.
  115186. * @param postProcess Post process to get the input texture from.
  115187. */
  115188. setTextureFromPostProcess(channel: string, postProcess: Nullable<PostProcess>): void;
  115189. /**
  115190. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  115191. * 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)
  115192. * @param channel Name of the sampler variable.
  115193. * @param postProcess Post process to get the output texture from.
  115194. */
  115195. setTextureFromPostProcessOutput(channel: string, postProcess: Nullable<PostProcess>): void;
  115196. /** @hidden */
  115197. _cacheMatrix(uniformName: string, matrix: IMatrixLike): boolean;
  115198. /** @hidden */
  115199. _cacheFloat2(uniformName: string, x: number, y: number): boolean;
  115200. /** @hidden */
  115201. _cacheFloat3(uniformName: string, x: number, y: number, z: number): boolean;
  115202. /** @hidden */
  115203. _cacheFloat4(uniformName: string, x: number, y: number, z: number, w: number): boolean;
  115204. /**
  115205. * Binds a buffer to a uniform.
  115206. * @param buffer Buffer to bind.
  115207. * @param name Name of the uniform variable to bind to.
  115208. */
  115209. bindUniformBuffer(buffer: DataBuffer, name: string): void;
  115210. /**
  115211. * Binds block to a uniform.
  115212. * @param blockName Name of the block to bind.
  115213. * @param index Index to bind.
  115214. */
  115215. bindUniformBlock(blockName: string, index: number): void;
  115216. /**
  115217. * Sets an interger value on a uniform variable.
  115218. * @param uniformName Name of the variable.
  115219. * @param value Value to be set.
  115220. * @returns this effect.
  115221. */
  115222. setInt(uniformName: string, value: number): Effect;
  115223. /**
  115224. * Sets an int array on a uniform variable.
  115225. * @param uniformName Name of the variable.
  115226. * @param array array to be set.
  115227. * @returns this effect.
  115228. */
  115229. setIntArray(uniformName: string, array: Int32Array): Effect;
  115230. /**
  115231. * 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)
  115232. * @param uniformName Name of the variable.
  115233. * @param array array to be set.
  115234. * @returns this effect.
  115235. */
  115236. setIntArray2(uniformName: string, array: Int32Array): Effect;
  115237. /**
  115238. * 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)
  115239. * @param uniformName Name of the variable.
  115240. * @param array array to be set.
  115241. * @returns this effect.
  115242. */
  115243. setIntArray3(uniformName: string, array: Int32Array): Effect;
  115244. /**
  115245. * 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)
  115246. * @param uniformName Name of the variable.
  115247. * @param array array to be set.
  115248. * @returns this effect.
  115249. */
  115250. setIntArray4(uniformName: string, array: Int32Array): Effect;
  115251. /**
  115252. * Sets an float array on a uniform variable.
  115253. * @param uniformName Name of the variable.
  115254. * @param array array to be set.
  115255. * @returns this effect.
  115256. */
  115257. setFloatArray(uniformName: string, array: Float32Array): Effect;
  115258. /**
  115259. * 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)
  115260. * @param uniformName Name of the variable.
  115261. * @param array array to be set.
  115262. * @returns this effect.
  115263. */
  115264. setFloatArray2(uniformName: string, array: Float32Array): Effect;
  115265. /**
  115266. * 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)
  115267. * @param uniformName Name of the variable.
  115268. * @param array array to be set.
  115269. * @returns this effect.
  115270. */
  115271. setFloatArray3(uniformName: string, array: Float32Array): Effect;
  115272. /**
  115273. * 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)
  115274. * @param uniformName Name of the variable.
  115275. * @param array array to be set.
  115276. * @returns this effect.
  115277. */
  115278. setFloatArray4(uniformName: string, array: Float32Array): Effect;
  115279. /**
  115280. * Sets an array on a uniform variable.
  115281. * @param uniformName Name of the variable.
  115282. * @param array array to be set.
  115283. * @returns this effect.
  115284. */
  115285. setArray(uniformName: string, array: number[]): Effect;
  115286. /**
  115287. * 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)
  115288. * @param uniformName Name of the variable.
  115289. * @param array array to be set.
  115290. * @returns this effect.
  115291. */
  115292. setArray2(uniformName: string, array: number[]): Effect;
  115293. /**
  115294. * 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)
  115295. * @param uniformName Name of the variable.
  115296. * @param array array to be set.
  115297. * @returns this effect.
  115298. */
  115299. setArray3(uniformName: string, array: number[]): Effect;
  115300. /**
  115301. * 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)
  115302. * @param uniformName Name of the variable.
  115303. * @param array array to be set.
  115304. * @returns this effect.
  115305. */
  115306. setArray4(uniformName: string, array: number[]): Effect;
  115307. /**
  115308. * Sets matrices on a uniform variable.
  115309. * @param uniformName Name of the variable.
  115310. * @param matrices matrices to be set.
  115311. * @returns this effect.
  115312. */
  115313. setMatrices(uniformName: string, matrices: Float32Array | Array<number>): Effect;
  115314. /**
  115315. * Sets matrix on a uniform variable.
  115316. * @param uniformName Name of the variable.
  115317. * @param matrix matrix to be set.
  115318. * @returns this effect.
  115319. */
  115320. setMatrix(uniformName: string, matrix: IMatrixLike): Effect;
  115321. /**
  115322. * 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)
  115323. * @param uniformName Name of the variable.
  115324. * @param matrix matrix to be set.
  115325. * @returns this effect.
  115326. */
  115327. setMatrix3x3(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115328. /**
  115329. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  115330. * @param uniformName Name of the variable.
  115331. * @param matrix matrix to be set.
  115332. * @returns this effect.
  115333. */
  115334. setMatrix2x2(uniformName: string, matrix: Float32Array | Array<number>): Effect;
  115335. /**
  115336. * Sets a float on a uniform variable.
  115337. * @param uniformName Name of the variable.
  115338. * @param value value to be set.
  115339. * @returns this effect.
  115340. */
  115341. setFloat(uniformName: string, value: number): Effect;
  115342. /**
  115343. * Sets a boolean on a uniform variable.
  115344. * @param uniformName Name of the variable.
  115345. * @param bool value to be set.
  115346. * @returns this effect.
  115347. */
  115348. setBool(uniformName: string, bool: boolean): Effect;
  115349. /**
  115350. * Sets a Vector2 on a uniform variable.
  115351. * @param uniformName Name of the variable.
  115352. * @param vector2 vector2 to be set.
  115353. * @returns this effect.
  115354. */
  115355. setVector2(uniformName: string, vector2: IVector2Like): Effect;
  115356. /**
  115357. * Sets a float2 on a uniform variable.
  115358. * @param uniformName Name of the variable.
  115359. * @param x First float in float2.
  115360. * @param y Second float in float2.
  115361. * @returns this effect.
  115362. */
  115363. setFloat2(uniformName: string, x: number, y: number): Effect;
  115364. /**
  115365. * Sets a Vector3 on a uniform variable.
  115366. * @param uniformName Name of the variable.
  115367. * @param vector3 Value to be set.
  115368. * @returns this effect.
  115369. */
  115370. setVector3(uniformName: string, vector3: IVector3Like): Effect;
  115371. /**
  115372. * Sets a float3 on a uniform variable.
  115373. * @param uniformName Name of the variable.
  115374. * @param x First float in float3.
  115375. * @param y Second float in float3.
  115376. * @param z Third float in float3.
  115377. * @returns this effect.
  115378. */
  115379. setFloat3(uniformName: string, x: number, y: number, z: number): Effect;
  115380. /**
  115381. * Sets a Vector4 on a uniform variable.
  115382. * @param uniformName Name of the variable.
  115383. * @param vector4 Value to be set.
  115384. * @returns this effect.
  115385. */
  115386. setVector4(uniformName: string, vector4: IVector4Like): Effect;
  115387. /**
  115388. * Sets a float4 on a uniform variable.
  115389. * @param uniformName Name of the variable.
  115390. * @param x First float in float4.
  115391. * @param y Second float in float4.
  115392. * @param z Third float in float4.
  115393. * @param w Fourth float in float4.
  115394. * @returns this effect.
  115395. */
  115396. setFloat4(uniformName: string, x: number, y: number, z: number, w: number): Effect;
  115397. /**
  115398. * Sets a Color3 on a uniform variable.
  115399. * @param uniformName Name of the variable.
  115400. * @param color3 Value to be set.
  115401. * @returns this effect.
  115402. */
  115403. setColor3(uniformName: string, color3: IColor3Like): Effect;
  115404. /**
  115405. * Sets a Color4 on a uniform variable.
  115406. * @param uniformName Name of the variable.
  115407. * @param color3 Value to be set.
  115408. * @param alpha Alpha value to be set.
  115409. * @returns this effect.
  115410. */
  115411. setColor4(uniformName: string, color3: IColor3Like, alpha: number): Effect;
  115412. /**
  115413. * Sets a Color4 on a uniform variable
  115414. * @param uniformName defines the name of the variable
  115415. * @param color4 defines the value to be set
  115416. * @returns this effect.
  115417. */
  115418. setDirectColor4(uniformName: string, color4: IColor4Like): Effect;
  115419. /** Release all associated resources */
  115420. dispose(): void;
  115421. /**
  115422. * This function will add a new shader to the shader store
  115423. * @param name the name of the shader
  115424. * @param pixelShader optional pixel shader content
  115425. * @param vertexShader optional vertex shader content
  115426. */
  115427. static RegisterShader(name: string, pixelShader?: string, vertexShader?: string): void;
  115428. /**
  115429. * Store of each shader (The can be looked up using effect.key)
  115430. */
  115431. static ShadersStore: {
  115432. [key: string]: string;
  115433. };
  115434. /**
  115435. * Store of each included file for a shader (The can be looked up using effect.key)
  115436. */
  115437. static IncludesShadersStore: {
  115438. [key: string]: string;
  115439. };
  115440. /**
  115441. * Resets the cache of effects.
  115442. */
  115443. static ResetCache(): void;
  115444. }
  115445. }
  115446. declare module BABYLON {
  115447. /**
  115448. * Interface used to describe the capabilities of the engine relatively to the current browser
  115449. */
  115450. export interface EngineCapabilities {
  115451. /** Maximum textures units per fragment shader */
  115452. maxTexturesImageUnits: number;
  115453. /** Maximum texture units per vertex shader */
  115454. maxVertexTextureImageUnits: number;
  115455. /** Maximum textures units in the entire pipeline */
  115456. maxCombinedTexturesImageUnits: number;
  115457. /** Maximum texture size */
  115458. maxTextureSize: number;
  115459. /** Maximum texture samples */
  115460. maxSamples?: number;
  115461. /** Maximum cube texture size */
  115462. maxCubemapTextureSize: number;
  115463. /** Maximum render texture size */
  115464. maxRenderTextureSize: number;
  115465. /** Maximum number of vertex attributes */
  115466. maxVertexAttribs: number;
  115467. /** Maximum number of varyings */
  115468. maxVaryingVectors: number;
  115469. /** Maximum number of uniforms per vertex shader */
  115470. maxVertexUniformVectors: number;
  115471. /** Maximum number of uniforms per fragment shader */
  115472. maxFragmentUniformVectors: number;
  115473. /** Defines if standard derivates (dx/dy) are supported */
  115474. standardDerivatives: boolean;
  115475. /** Defines if s3tc texture compression is supported */
  115476. s3tc?: WEBGL_compressed_texture_s3tc;
  115477. /** Defines if pvrtc texture compression is supported */
  115478. pvrtc: any;
  115479. /** Defines if etc1 texture compression is supported */
  115480. etc1: any;
  115481. /** Defines if etc2 texture compression is supported */
  115482. etc2: any;
  115483. /** Defines if astc texture compression is supported */
  115484. astc: any;
  115485. /** Defines if bptc texture compression is supported */
  115486. bptc: any;
  115487. /** Defines if float textures are supported */
  115488. textureFloat: boolean;
  115489. /** Defines if vertex array objects are supported */
  115490. vertexArrayObject: boolean;
  115491. /** Gets the webgl extension for anisotropic filtering (null if not supported) */
  115492. textureAnisotropicFilterExtension?: EXT_texture_filter_anisotropic;
  115493. /** Gets the maximum level of anisotropy supported */
  115494. maxAnisotropy: number;
  115495. /** Defines if instancing is supported */
  115496. instancedArrays: boolean;
  115497. /** Defines if 32 bits indices are supported */
  115498. uintIndices: boolean;
  115499. /** Defines if high precision shaders are supported */
  115500. highPrecisionShaderSupported: boolean;
  115501. /** Defines if depth reading in the fragment shader is supported */
  115502. fragmentDepthSupported: boolean;
  115503. /** Defines if float texture linear filtering is supported*/
  115504. textureFloatLinearFiltering: boolean;
  115505. /** Defines if rendering to float textures is supported */
  115506. textureFloatRender: boolean;
  115507. /** Defines if half float textures are supported*/
  115508. textureHalfFloat: boolean;
  115509. /** Defines if half float texture linear filtering is supported*/
  115510. textureHalfFloatLinearFiltering: boolean;
  115511. /** Defines if rendering to half float textures is supported */
  115512. textureHalfFloatRender: boolean;
  115513. /** Defines if textureLOD shader command is supported */
  115514. textureLOD: boolean;
  115515. /** Defines if draw buffers extension is supported */
  115516. drawBuffersExtension: boolean;
  115517. /** Defines if depth textures are supported */
  115518. depthTextureExtension: boolean;
  115519. /** Defines if float color buffer are supported */
  115520. colorBufferFloat: boolean;
  115521. /** Gets disjoint timer query extension (null if not supported) */
  115522. timerQuery?: EXT_disjoint_timer_query;
  115523. /** Defines if timestamp can be used with timer query */
  115524. canUseTimestampForTimerQuery: boolean;
  115525. /** Defines if multiview is supported (https://www.khronos.org/registry/webgl/extensions/WEBGL_multiview/) */
  115526. multiview?: any;
  115527. /** Defines if oculus multiview is supported (https://developer.oculus.com/documentation/oculus-browser/latest/concepts/browser-multiview/) */
  115528. oculusMultiview?: any;
  115529. /** Function used to let the system compiles shaders in background */
  115530. parallelShaderCompile?: {
  115531. COMPLETION_STATUS_KHR: number;
  115532. };
  115533. /** Max number of texture samples for MSAA */
  115534. maxMSAASamples: number;
  115535. /** Defines if the blend min max extension is supported */
  115536. blendMinMax: boolean;
  115537. }
  115538. }
  115539. declare module BABYLON {
  115540. /**
  115541. * @hidden
  115542. **/
  115543. export class DepthCullingState {
  115544. private _isDepthTestDirty;
  115545. private _isDepthMaskDirty;
  115546. private _isDepthFuncDirty;
  115547. private _isCullFaceDirty;
  115548. private _isCullDirty;
  115549. private _isZOffsetDirty;
  115550. private _isFrontFaceDirty;
  115551. private _depthTest;
  115552. private _depthMask;
  115553. private _depthFunc;
  115554. private _cull;
  115555. private _cullFace;
  115556. private _zOffset;
  115557. private _frontFace;
  115558. /**
  115559. * Initializes the state.
  115560. */
  115561. constructor();
  115562. get isDirty(): boolean;
  115563. get zOffset(): number;
  115564. set zOffset(value: number);
  115565. get cullFace(): Nullable<number>;
  115566. set cullFace(value: Nullable<number>);
  115567. get cull(): Nullable<boolean>;
  115568. set cull(value: Nullable<boolean>);
  115569. get depthFunc(): Nullable<number>;
  115570. set depthFunc(value: Nullable<number>);
  115571. get depthMask(): boolean;
  115572. set depthMask(value: boolean);
  115573. get depthTest(): boolean;
  115574. set depthTest(value: boolean);
  115575. get frontFace(): Nullable<number>;
  115576. set frontFace(value: Nullable<number>);
  115577. reset(): void;
  115578. apply(gl: WebGLRenderingContext): void;
  115579. }
  115580. }
  115581. declare module BABYLON {
  115582. /**
  115583. * @hidden
  115584. **/
  115585. export class StencilState {
  115586. /** 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 */
  115587. static readonly ALWAYS: number;
  115588. /** Passed to stencilOperation to specify that stencil value must be kept */
  115589. static readonly KEEP: number;
  115590. /** Passed to stencilOperation to specify that stencil value must be replaced */
  115591. static readonly REPLACE: number;
  115592. private _isStencilTestDirty;
  115593. private _isStencilMaskDirty;
  115594. private _isStencilFuncDirty;
  115595. private _isStencilOpDirty;
  115596. private _stencilTest;
  115597. private _stencilMask;
  115598. private _stencilFunc;
  115599. private _stencilFuncRef;
  115600. private _stencilFuncMask;
  115601. private _stencilOpStencilFail;
  115602. private _stencilOpDepthFail;
  115603. private _stencilOpStencilDepthPass;
  115604. get isDirty(): boolean;
  115605. get stencilFunc(): number;
  115606. set stencilFunc(value: number);
  115607. get stencilFuncRef(): number;
  115608. set stencilFuncRef(value: number);
  115609. get stencilFuncMask(): number;
  115610. set stencilFuncMask(value: number);
  115611. get stencilOpStencilFail(): number;
  115612. set stencilOpStencilFail(value: number);
  115613. get stencilOpDepthFail(): number;
  115614. set stencilOpDepthFail(value: number);
  115615. get stencilOpStencilDepthPass(): number;
  115616. set stencilOpStencilDepthPass(value: number);
  115617. get stencilMask(): number;
  115618. set stencilMask(value: number);
  115619. get stencilTest(): boolean;
  115620. set stencilTest(value: boolean);
  115621. constructor();
  115622. reset(): void;
  115623. apply(gl: WebGLRenderingContext): void;
  115624. }
  115625. }
  115626. declare module BABYLON {
  115627. /**
  115628. * @hidden
  115629. **/
  115630. export class AlphaState {
  115631. private _isAlphaBlendDirty;
  115632. private _isBlendFunctionParametersDirty;
  115633. private _isBlendEquationParametersDirty;
  115634. private _isBlendConstantsDirty;
  115635. private _alphaBlend;
  115636. private _blendFunctionParameters;
  115637. private _blendEquationParameters;
  115638. private _blendConstants;
  115639. /**
  115640. * Initializes the state.
  115641. */
  115642. constructor();
  115643. get isDirty(): boolean;
  115644. get alphaBlend(): boolean;
  115645. set alphaBlend(value: boolean);
  115646. setAlphaBlendConstants(r: number, g: number, b: number, a: number): void;
  115647. setAlphaBlendFunctionParameters(value0: number, value1: number, value2: number, value3: number): void;
  115648. setAlphaEquationParameters(rgb: number, alpha: number): void;
  115649. reset(): void;
  115650. apply(gl: WebGLRenderingContext): void;
  115651. }
  115652. }
  115653. declare module BABYLON {
  115654. /** @hidden */
  115655. export class WebGL2ShaderProcessor implements IShaderProcessor {
  115656. attributeProcessor(attribute: string): string;
  115657. varyingProcessor(varying: string, isFragment: boolean): string;
  115658. postProcessor(code: string, defines: string[], isFragment: boolean): string;
  115659. }
  115660. }
  115661. declare module BABYLON {
  115662. /**
  115663. * Interface for attribute information associated with buffer instanciation
  115664. */
  115665. export interface InstancingAttributeInfo {
  115666. /**
  115667. * Name of the GLSL attribute
  115668. * if attribute index is not specified, this is used to retrieve the index from the effect
  115669. */
  115670. attributeName: string;
  115671. /**
  115672. * Index/offset of the attribute in the vertex shader
  115673. * if not specified, this will be computes from the name.
  115674. */
  115675. index?: number;
  115676. /**
  115677. * size of the attribute, 1, 2, 3 or 4
  115678. */
  115679. attributeSize: number;
  115680. /**
  115681. * Offset of the data in the Vertex Buffer acting as the instancing buffer
  115682. */
  115683. offset: number;
  115684. /**
  115685. * Modifies the rate at which generic vertex attributes advance when rendering multiple instances
  115686. * default to 1
  115687. */
  115688. divisor?: number;
  115689. /**
  115690. * type of the attribute, gl.BYTE, gl.UNSIGNED_BYTE, gl.SHORT, gl.UNSIGNED_SHORT, gl.FIXED, gl.FLOAT.
  115691. * default is FLOAT
  115692. */
  115693. attributeType?: number;
  115694. /**
  115695. * normalization of fixed-point data. behavior unclear, use FALSE, default is FALSE
  115696. */
  115697. normalized?: boolean;
  115698. }
  115699. }
  115700. declare module BABYLON {
  115701. interface ThinEngine {
  115702. /**
  115703. * Update a video texture
  115704. * @param texture defines the texture to update
  115705. * @param video defines the video element to use
  115706. * @param invertY defines if data must be stored with Y axis inverted
  115707. */
  115708. updateVideoTexture(texture: Nullable<InternalTexture>, video: HTMLVideoElement, invertY: boolean): void;
  115709. }
  115710. }
  115711. declare module BABYLON {
  115712. interface ThinEngine {
  115713. /**
  115714. * Creates a dynamic texture
  115715. * @param width defines the width of the texture
  115716. * @param height defines the height of the texture
  115717. * @param generateMipMaps defines if the engine should generate the mip levels
  115718. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  115719. * @returns the dynamic texture inside an InternalTexture
  115720. */
  115721. createDynamicTexture(width: number, height: number, generateMipMaps: boolean, samplingMode: number): InternalTexture;
  115722. /**
  115723. * Update the content of a dynamic texture
  115724. * @param texture defines the texture to update
  115725. * @param canvas defines the canvas containing the source
  115726. * @param invertY defines if data must be stored with Y axis inverted
  115727. * @param premulAlpha defines if alpha is stored as premultiplied
  115728. * @param format defines the format of the data
  115729. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  115730. */
  115731. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement | OffscreenCanvas, invertY: boolean, premulAlpha?: boolean, format?: number, forceBindTexture?: boolean): void;
  115732. }
  115733. }
  115734. declare module BABYLON {
  115735. /**
  115736. * Settings for finer control over video usage
  115737. */
  115738. export interface VideoTextureSettings {
  115739. /**
  115740. * Applies `autoplay` to video, if specified
  115741. */
  115742. autoPlay?: boolean;
  115743. /**
  115744. * Applies `loop` to video, if specified
  115745. */
  115746. loop?: boolean;
  115747. /**
  115748. * Automatically updates internal texture from video at every frame in the render loop
  115749. */
  115750. autoUpdateTexture: boolean;
  115751. /**
  115752. * Image src displayed during the video loading or until the user interacts with the video.
  115753. */
  115754. poster?: string;
  115755. }
  115756. /**
  115757. * If you want to display a video in your scene, this is the special texture for that.
  115758. * This special texture works similar to other textures, with the exception of a few parameters.
  115759. * @see https://doc.babylonjs.com/how_to/video_texture
  115760. */
  115761. export class VideoTexture extends Texture {
  115762. /**
  115763. * Tells whether textures will be updated automatically or user is required to call `updateTexture` manually
  115764. */
  115765. readonly autoUpdateTexture: boolean;
  115766. /**
  115767. * The video instance used by the texture internally
  115768. */
  115769. readonly video: HTMLVideoElement;
  115770. private _onUserActionRequestedObservable;
  115771. /**
  115772. * Event triggerd when a dom action is required by the user to play the video.
  115773. * This happens due to recent changes in browser policies preventing video to auto start.
  115774. */
  115775. get onUserActionRequestedObservable(): Observable<Texture>;
  115776. private _generateMipMaps;
  115777. private _stillImageCaptured;
  115778. private _displayingPosterTexture;
  115779. private _settings;
  115780. private _createInternalTextureOnEvent;
  115781. private _frameId;
  115782. private _currentSrc;
  115783. /**
  115784. * Creates a video texture.
  115785. * If you want to display a video in your scene, this is the special texture for that.
  115786. * This special texture works similar to other textures, with the exception of a few parameters.
  115787. * @see https://doc.babylonjs.com/how_to/video_texture
  115788. * @param name optional name, will detect from video source, if not defined
  115789. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  115790. * @param scene is obviously the current scene.
  115791. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  115792. * @param invertY is false by default but can be used to invert video on Y axis
  115793. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  115794. * @param settings allows finer control over video usage
  115795. */
  115796. constructor(name: Nullable<string>, src: string | string[] | HTMLVideoElement, scene: Nullable<Scene>, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, settings?: VideoTextureSettings);
  115797. private _getName;
  115798. private _getVideo;
  115799. private _createInternalTexture;
  115800. private reset;
  115801. /**
  115802. * @hidden Internal method to initiate `update`.
  115803. */
  115804. _rebuild(): void;
  115805. /**
  115806. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  115807. */
  115808. update(): void;
  115809. /**
  115810. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  115811. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  115812. */
  115813. updateTexture(isVisible: boolean): void;
  115814. protected _updateInternalTexture: () => void;
  115815. /**
  115816. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  115817. * @param url New url.
  115818. */
  115819. updateURL(url: string): void;
  115820. /**
  115821. * Clones the texture.
  115822. * @returns the cloned texture
  115823. */
  115824. clone(): VideoTexture;
  115825. /**
  115826. * Dispose the texture and release its associated resources.
  115827. */
  115828. dispose(): void;
  115829. /**
  115830. * Creates a video texture straight from a stream.
  115831. * @param scene Define the scene the texture should be created in
  115832. * @param stream Define the stream the texture should be created from
  115833. * @returns The created video texture as a promise
  115834. */
  115835. static CreateFromStreamAsync(scene: Scene, stream: MediaStream): Promise<VideoTexture>;
  115836. /**
  115837. * Creates a video texture straight from your WebCam video feed.
  115838. * @param scene Define the scene the texture should be created in
  115839. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115840. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115841. * @returns The created video texture as a promise
  115842. */
  115843. static CreateFromWebCamAsync(scene: Scene, constraints: {
  115844. minWidth: number;
  115845. maxWidth: number;
  115846. minHeight: number;
  115847. maxHeight: number;
  115848. deviceId: string;
  115849. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): Promise<VideoTexture>;
  115850. /**
  115851. * Creates a video texture straight from your WebCam video feed.
  115852. * @param scene Define the scene the texture should be created in
  115853. * @param onReady Define a callback to triggered once the texture will be ready
  115854. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  115855. * @param audioConstaints Define the audio constraints to use to create the web cam feed from WebRTC
  115856. */
  115857. static CreateFromWebCam(scene: Scene, onReady: (videoTexture: VideoTexture) => void, constraints: {
  115858. minWidth: number;
  115859. maxWidth: number;
  115860. minHeight: number;
  115861. maxHeight: number;
  115862. deviceId: string;
  115863. } & MediaTrackConstraints, audioConstaints?: boolean | MediaTrackConstraints): void;
  115864. }
  115865. }
  115866. declare module BABYLON {
  115867. /**
  115868. * Defines the interface used by objects working like Scene
  115869. * @hidden
  115870. */
  115871. export interface ISceneLike {
  115872. _addPendingData(data: any): void;
  115873. _removePendingData(data: any): void;
  115874. offlineProvider: IOfflineProvider;
  115875. }
  115876. /**
  115877. * Information about the current host
  115878. */
  115879. export interface HostInformation {
  115880. /**
  115881. * Defines if the current host is a mobile
  115882. */
  115883. isMobile: boolean;
  115884. }
  115885. /** Interface defining initialization parameters for Engine class */
  115886. export interface EngineOptions extends WebGLContextAttributes {
  115887. /**
  115888. * Defines if the engine should no exceed a specified device ratio
  115889. * @see https://developer.mozilla.org/en-US/docs/Web/API/Window/devicePixelRatio
  115890. */
  115891. limitDeviceRatio?: number;
  115892. /**
  115893. * Defines if webvr should be enabled automatically
  115894. * @see https://doc.babylonjs.com/how_to/webvr_camera
  115895. */
  115896. autoEnableWebVR?: boolean;
  115897. /**
  115898. * Defines if webgl2 should be turned off even if supported
  115899. * @see https://doc.babylonjs.com/features/webgl2
  115900. */
  115901. disableWebGL2Support?: boolean;
  115902. /**
  115903. * Defines if webaudio should be initialized as well
  115904. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  115905. */
  115906. audioEngine?: boolean;
  115907. /**
  115908. * Defines if animations should run using a deterministic lock step
  115909. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  115910. */
  115911. deterministicLockstep?: boolean;
  115912. /** Defines the maximum steps to use with deterministic lock step mode */
  115913. lockstepMaxSteps?: number;
  115914. /** Defines the seconds between each deterministic lock step */
  115915. timeStep?: number;
  115916. /**
  115917. * Defines that engine should ignore context lost events
  115918. * If this event happens when this parameter is true, you will have to reload the page to restore rendering
  115919. */
  115920. doNotHandleContextLost?: boolean;
  115921. /**
  115922. * Defines that engine should ignore modifying touch action attribute and style
  115923. * If not handle, you might need to set it up on your side for expected touch devices behavior.
  115924. */
  115925. doNotHandleTouchAction?: boolean;
  115926. /**
  115927. * Defines that engine should compile shaders with high precision floats (if supported). True by default
  115928. */
  115929. useHighPrecisionFloats?: boolean;
  115930. /**
  115931. * Make the canvas XR Compatible for XR sessions
  115932. */
  115933. xrCompatible?: boolean;
  115934. /**
  115935. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  115936. */
  115937. useHighPrecisionMatrix?: boolean;
  115938. /**
  115939. * Will prevent the system from falling back to software implementation if a hardware device cannot be created
  115940. */
  115941. failIfMajorPerformanceCaveat?: boolean;
  115942. }
  115943. /**
  115944. * The base engine class (root of all engines)
  115945. */
  115946. export class ThinEngine {
  115947. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  115948. static ExceptionList: ({
  115949. key: string;
  115950. capture: string;
  115951. captureConstraint: number;
  115952. targets: string[];
  115953. } | {
  115954. key: string;
  115955. capture: null;
  115956. captureConstraint: null;
  115957. targets: string[];
  115958. })[];
  115959. /** @hidden */
  115960. static _TextureLoaders: IInternalTextureLoader[];
  115961. /**
  115962. * Returns the current npm package of the sdk
  115963. */
  115964. static get NpmPackage(): string;
  115965. /**
  115966. * Returns the current version of the framework
  115967. */
  115968. static get Version(): string;
  115969. /**
  115970. * Returns a string describing the current engine
  115971. */
  115972. get description(): string;
  115973. /**
  115974. * Gets or sets the epsilon value used by collision engine
  115975. */
  115976. static CollisionsEpsilon: number;
  115977. /**
  115978. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  115979. */
  115980. static get ShadersRepository(): string;
  115981. static set ShadersRepository(value: string);
  115982. /** @hidden */
  115983. _shaderProcessor: IShaderProcessor;
  115984. /**
  115985. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  115986. */
  115987. forcePOTTextures: boolean;
  115988. /**
  115989. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  115990. */
  115991. isFullscreen: boolean;
  115992. /**
  115993. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  115994. */
  115995. cullBackFaces: boolean;
  115996. /**
  115997. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  115998. */
  115999. renderEvenInBackground: boolean;
  116000. /**
  116001. * Gets or sets a boolean indicating that cache can be kept between frames
  116002. */
  116003. preventCacheWipeBetweenFrames: boolean;
  116004. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  116005. validateShaderPrograms: boolean;
  116006. /**
  116007. * Gets or sets a boolean indicating if depth buffer should be reverse, going from far to near.
  116008. * This can provide greater z depth for distant objects.
  116009. */
  116010. useReverseDepthBuffer: boolean;
  116011. /**
  116012. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  116013. */
  116014. disableUniformBuffers: boolean;
  116015. /** @hidden */
  116016. _uniformBuffers: UniformBuffer[];
  116017. /**
  116018. * Gets a boolean indicating that the engine supports uniform buffers
  116019. * @see https://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  116020. */
  116021. get supportsUniformBuffers(): boolean;
  116022. /** @hidden */
  116023. _gl: WebGLRenderingContext;
  116024. /** @hidden */
  116025. _webGLVersion: number;
  116026. protected _renderingCanvas: Nullable<HTMLCanvasElement>;
  116027. protected _windowIsBackground: boolean;
  116028. protected _creationOptions: EngineOptions;
  116029. protected _highPrecisionShadersAllowed: boolean;
  116030. /** @hidden */
  116031. get _shouldUseHighPrecisionShader(): boolean;
  116032. /**
  116033. * Gets a boolean indicating that only power of 2 textures are supported
  116034. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  116035. */
  116036. get needPOTTextures(): boolean;
  116037. /** @hidden */
  116038. _badOS: boolean;
  116039. /** @hidden */
  116040. _badDesktopOS: boolean;
  116041. private _hardwareScalingLevel;
  116042. /** @hidden */
  116043. _caps: EngineCapabilities;
  116044. private _isStencilEnable;
  116045. private _glVersion;
  116046. private _glRenderer;
  116047. private _glVendor;
  116048. /** @hidden */
  116049. _videoTextureSupported: boolean;
  116050. protected _renderingQueueLaunched: boolean;
  116051. protected _activeRenderLoops: (() => void)[];
  116052. /**
  116053. * Observable signaled when a context lost event is raised
  116054. */
  116055. onContextLostObservable: Observable<ThinEngine>;
  116056. /**
  116057. * Observable signaled when a context restored event is raised
  116058. */
  116059. onContextRestoredObservable: Observable<ThinEngine>;
  116060. private _onContextLost;
  116061. private _onContextRestored;
  116062. protected _contextWasLost: boolean;
  116063. /** @hidden */
  116064. _doNotHandleContextLost: boolean;
  116065. /**
  116066. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  116067. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  116068. */
  116069. get doNotHandleContextLost(): boolean;
  116070. set doNotHandleContextLost(value: boolean);
  116071. /**
  116072. * Gets or sets a boolean indicating that vertex array object must be disabled even if they are supported
  116073. */
  116074. disableVertexArrayObjects: boolean;
  116075. /** @hidden */
  116076. protected _colorWrite: boolean;
  116077. /** @hidden */
  116078. protected _colorWriteChanged: boolean;
  116079. /** @hidden */
  116080. protected _depthCullingState: DepthCullingState;
  116081. /** @hidden */
  116082. protected _stencilState: StencilState;
  116083. /** @hidden */
  116084. _alphaState: AlphaState;
  116085. /** @hidden */
  116086. _alphaMode: number;
  116087. /** @hidden */
  116088. _alphaEquation: number;
  116089. /** @hidden */
  116090. _internalTexturesCache: InternalTexture[];
  116091. /** @hidden */
  116092. protected _activeChannel: number;
  116093. private _currentTextureChannel;
  116094. /** @hidden */
  116095. protected _boundTexturesCache: {
  116096. [key: string]: Nullable<InternalTexture>;
  116097. };
  116098. /** @hidden */
  116099. protected _currentEffect: Nullable<Effect>;
  116100. /** @hidden */
  116101. protected _currentProgram: Nullable<WebGLProgram>;
  116102. private _compiledEffects;
  116103. private _vertexAttribArraysEnabled;
  116104. /** @hidden */
  116105. protected _cachedViewport: Nullable<IViewportLike>;
  116106. private _cachedVertexArrayObject;
  116107. /** @hidden */
  116108. protected _cachedVertexBuffers: any;
  116109. /** @hidden */
  116110. protected _cachedIndexBuffer: Nullable<DataBuffer>;
  116111. /** @hidden */
  116112. protected _cachedEffectForVertexBuffers: Nullable<Effect>;
  116113. /** @hidden */
  116114. _currentRenderTarget: Nullable<InternalTexture>;
  116115. private _uintIndicesCurrentlySet;
  116116. protected _currentBoundBuffer: Nullable<WebGLBuffer>[];
  116117. /** @hidden */
  116118. _currentFramebuffer: Nullable<WebGLFramebuffer>;
  116119. /** @hidden */
  116120. _dummyFramebuffer: Nullable<WebGLFramebuffer>;
  116121. private _currentBufferPointers;
  116122. private _currentInstanceLocations;
  116123. private _currentInstanceBuffers;
  116124. private _textureUnits;
  116125. /** @hidden */
  116126. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  116127. /** @hidden */
  116128. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  116129. /** @hidden */
  116130. _boundRenderFunction: any;
  116131. private _vaoRecordInProgress;
  116132. private _mustWipeVertexAttributes;
  116133. private _emptyTexture;
  116134. private _emptyCubeTexture;
  116135. private _emptyTexture3D;
  116136. private _emptyTexture2DArray;
  116137. /** @hidden */
  116138. _frameHandler: number;
  116139. private _nextFreeTextureSlots;
  116140. private _maxSimultaneousTextures;
  116141. private _activeRequests;
  116142. /** @hidden */
  116143. _transformTextureUrl: Nullable<(url: string) => string>;
  116144. /**
  116145. * Gets information about the current host
  116146. */
  116147. hostInformation: HostInformation;
  116148. protected get _supportsHardwareTextureRescaling(): boolean;
  116149. private _framebufferDimensionsObject;
  116150. /**
  116151. * sets the object from which width and height will be taken from when getting render width and height
  116152. * Will fallback to the gl object
  116153. * @param dimensions the framebuffer width and height that will be used.
  116154. */
  116155. set framebufferDimensionsObject(dimensions: Nullable<{
  116156. framebufferWidth: number;
  116157. framebufferHeight: number;
  116158. }>);
  116159. /**
  116160. * Gets the current viewport
  116161. */
  116162. get currentViewport(): Nullable<IViewportLike>;
  116163. /**
  116164. * Gets the default empty texture
  116165. */
  116166. get emptyTexture(): InternalTexture;
  116167. /**
  116168. * Gets the default empty 3D texture
  116169. */
  116170. get emptyTexture3D(): InternalTexture;
  116171. /**
  116172. * Gets the default empty 2D array texture
  116173. */
  116174. get emptyTexture2DArray(): InternalTexture;
  116175. /**
  116176. * Gets the default empty cube texture
  116177. */
  116178. get emptyCubeTexture(): InternalTexture;
  116179. /**
  116180. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  116181. */
  116182. readonly premultipliedAlpha: boolean;
  116183. /**
  116184. * Observable event triggered before each texture is initialized
  116185. */
  116186. onBeforeTextureInitObservable: Observable<Texture>;
  116187. /**
  116188. * Creates a new engine
  116189. * @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
  116190. * @param antialias defines enable antialiasing (default: false)
  116191. * @param options defines further options to be sent to the getContext() function
  116192. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  116193. */
  116194. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext | WebGL2RenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  116195. private _rebuildInternalTextures;
  116196. private _rebuildEffects;
  116197. /**
  116198. * Gets a boolean indicating if all created effects are ready
  116199. * @returns true if all effects are ready
  116200. */
  116201. areAllEffectsReady(): boolean;
  116202. protected _rebuildBuffers(): void;
  116203. protected _initGLContext(): void;
  116204. /**
  116205. * Gets version of the current webGL context
  116206. */
  116207. get webGLVersion(): number;
  116208. /**
  116209. * Gets a string identifying the name of the class
  116210. * @returns "Engine" string
  116211. */
  116212. getClassName(): string;
  116213. /**
  116214. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  116215. */
  116216. get isStencilEnable(): boolean;
  116217. /** @hidden */
  116218. _prepareWorkingCanvas(): void;
  116219. /**
  116220. * Reset the texture cache to empty state
  116221. */
  116222. resetTextureCache(): void;
  116223. /**
  116224. * Gets an object containing information about the current webGL context
  116225. * @returns an object containing the vender, the renderer and the version of the current webGL context
  116226. */
  116227. getGlInfo(): {
  116228. vendor: string;
  116229. renderer: string;
  116230. version: string;
  116231. };
  116232. /**
  116233. * Defines the hardware scaling level.
  116234. * By default the hardware scaling level is computed from the window device ratio.
  116235. * 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.
  116236. * @param level defines the level to use
  116237. */
  116238. setHardwareScalingLevel(level: number): void;
  116239. /**
  116240. * Gets the current hardware scaling level.
  116241. * By default the hardware scaling level is computed from the window device ratio.
  116242. * 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.
  116243. * @returns a number indicating the current hardware scaling level
  116244. */
  116245. getHardwareScalingLevel(): number;
  116246. /**
  116247. * Gets the list of loaded textures
  116248. * @returns an array containing all loaded textures
  116249. */
  116250. getLoadedTexturesCache(): InternalTexture[];
  116251. /**
  116252. * Gets the object containing all engine capabilities
  116253. * @returns the EngineCapabilities object
  116254. */
  116255. getCaps(): EngineCapabilities;
  116256. /**
  116257. * stop executing a render loop function and remove it from the execution array
  116258. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  116259. */
  116260. stopRenderLoop(renderFunction?: () => void): void;
  116261. /** @hidden */
  116262. _renderLoop(): void;
  116263. /**
  116264. * Gets the HTML canvas attached with the current webGL context
  116265. * @returns a HTML canvas
  116266. */
  116267. getRenderingCanvas(): Nullable<HTMLCanvasElement>;
  116268. /**
  116269. * Gets host window
  116270. * @returns the host window object
  116271. */
  116272. getHostWindow(): Nullable<Window>;
  116273. /**
  116274. * Gets the current render width
  116275. * @param useScreen defines if screen size must be used (or the current render target if any)
  116276. * @returns a number defining the current render width
  116277. */
  116278. getRenderWidth(useScreen?: boolean): number;
  116279. /**
  116280. * Gets the current render height
  116281. * @param useScreen defines if screen size must be used (or the current render target if any)
  116282. * @returns a number defining the current render height
  116283. */
  116284. getRenderHeight(useScreen?: boolean): number;
  116285. /**
  116286. * Can be used to override the current requestAnimationFrame requester.
  116287. * @hidden
  116288. */
  116289. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  116290. /**
  116291. * Register and execute a render loop. The engine can have more than one render function
  116292. * @param renderFunction defines the function to continuously execute
  116293. */
  116294. runRenderLoop(renderFunction: () => void): void;
  116295. /**
  116296. * Clear the current render buffer or the current render target (if any is set up)
  116297. * @param color defines the color to use
  116298. * @param backBuffer defines if the back buffer must be cleared
  116299. * @param depth defines if the depth buffer must be cleared
  116300. * @param stencil defines if the stencil buffer must be cleared
  116301. */
  116302. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  116303. private _viewportCached;
  116304. /** @hidden */
  116305. _viewport(x: number, y: number, width: number, height: number): void;
  116306. /**
  116307. * Set the WebGL's viewport
  116308. * @param viewport defines the viewport element to be used
  116309. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  116310. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  116311. */
  116312. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  116313. /**
  116314. * Begin a new frame
  116315. */
  116316. beginFrame(): void;
  116317. /**
  116318. * Enf the current frame
  116319. */
  116320. endFrame(): void;
  116321. /**
  116322. * Resize the view according to the canvas' size
  116323. */
  116324. resize(): void;
  116325. /**
  116326. * Force a specific size of the canvas
  116327. * @param width defines the new canvas' width
  116328. * @param height defines the new canvas' height
  116329. * @returns true if the size was changed
  116330. */
  116331. setSize(width: number, height: number): boolean;
  116332. /**
  116333. * Binds the frame buffer to the specified texture.
  116334. * @param texture The texture to render to or null for the default canvas
  116335. * @param faceIndex The face of the texture to render to in case of cube texture
  116336. * @param requiredWidth The width of the target to render to
  116337. * @param requiredHeight The height of the target to render to
  116338. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  116339. * @param lodLevel defines the lod level to bind to the frame buffer
  116340. * @param layer defines the 2d array index to bind to frame buffer to
  116341. */
  116342. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean, lodLevel?: number, layer?: number): void;
  116343. /** @hidden */
  116344. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  116345. /**
  116346. * Unbind the current render target texture from the webGL context
  116347. * @param texture defines the render target texture to unbind
  116348. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  116349. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  116350. */
  116351. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  116352. /**
  116353. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  116354. */
  116355. flushFramebuffer(): void;
  116356. /**
  116357. * Unbind the current render target and bind the default framebuffer
  116358. */
  116359. restoreDefaultFramebuffer(): void;
  116360. /** @hidden */
  116361. protected _resetVertexBufferBinding(): void;
  116362. /**
  116363. * Creates a vertex buffer
  116364. * @param data the data for the vertex buffer
  116365. * @returns the new WebGL static buffer
  116366. */
  116367. createVertexBuffer(data: DataArray): DataBuffer;
  116368. private _createVertexBuffer;
  116369. /**
  116370. * Creates a dynamic vertex buffer
  116371. * @param data the data for the dynamic vertex buffer
  116372. * @returns the new WebGL dynamic buffer
  116373. */
  116374. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  116375. protected _resetIndexBufferBinding(): void;
  116376. /**
  116377. * Creates a new index buffer
  116378. * @param indices defines the content of the index buffer
  116379. * @param updatable defines if the index buffer must be updatable
  116380. * @returns a new webGL buffer
  116381. */
  116382. createIndexBuffer(indices: IndicesArray, updatable?: boolean): DataBuffer;
  116383. protected _normalizeIndexData(indices: IndicesArray): Uint16Array | Uint32Array;
  116384. /**
  116385. * Bind a webGL buffer to the webGL context
  116386. * @param buffer defines the buffer to bind
  116387. */
  116388. bindArrayBuffer(buffer: Nullable<DataBuffer>): void;
  116389. protected bindIndexBuffer(buffer: Nullable<DataBuffer>): void;
  116390. private bindBuffer;
  116391. /**
  116392. * update the bound buffer with the given data
  116393. * @param data defines the data to update
  116394. */
  116395. updateArrayBuffer(data: Float32Array): void;
  116396. private _vertexAttribPointer;
  116397. /** @hidden */
  116398. _bindIndexBufferWithCache(indexBuffer: Nullable<DataBuffer>): void;
  116399. private _bindVertexBuffersAttributes;
  116400. /**
  116401. * Records a vertex array object
  116402. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116403. * @param vertexBuffers defines the list of vertex buffers to store
  116404. * @param indexBuffer defines the index buffer to store
  116405. * @param effect defines the effect to store
  116406. * @returns the new vertex array object
  116407. */
  116408. recordVertexArrayObject(vertexBuffers: {
  116409. [key: string]: VertexBuffer;
  116410. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): WebGLVertexArrayObject;
  116411. /**
  116412. * Bind a specific vertex array object
  116413. * @see https://doc.babylonjs.com/features/webgl2#vertex-array-objects
  116414. * @param vertexArrayObject defines the vertex array object to bind
  116415. * @param indexBuffer defines the index buffer to bind
  116416. */
  116417. bindVertexArrayObject(vertexArrayObject: WebGLVertexArrayObject, indexBuffer: Nullable<DataBuffer>): void;
  116418. /**
  116419. * Bind webGl buffers directly to the webGL context
  116420. * @param vertexBuffer defines the vertex buffer to bind
  116421. * @param indexBuffer defines the index buffer to bind
  116422. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  116423. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  116424. * @param effect defines the effect associated with the vertex buffer
  116425. */
  116426. bindBuffersDirectly(vertexBuffer: DataBuffer, indexBuffer: DataBuffer, vertexDeclaration: number[], vertexStrideSize: number, effect: Effect): void;
  116427. private _unbindVertexArrayObject;
  116428. /**
  116429. * Bind a list of vertex buffers to the webGL context
  116430. * @param vertexBuffers defines the list of vertex buffers to bind
  116431. * @param indexBuffer defines the index buffer to bind
  116432. * @param effect defines the effect associated with the vertex buffers
  116433. */
  116434. bindBuffers(vertexBuffers: {
  116435. [key: string]: Nullable<VertexBuffer>;
  116436. }, indexBuffer: Nullable<DataBuffer>, effect: Effect): void;
  116437. /**
  116438. * Unbind all instance attributes
  116439. */
  116440. unbindInstanceAttributes(): void;
  116441. /**
  116442. * Release and free the memory of a vertex array object
  116443. * @param vao defines the vertex array object to delete
  116444. */
  116445. releaseVertexArrayObject(vao: WebGLVertexArrayObject): void;
  116446. /** @hidden */
  116447. _releaseBuffer(buffer: DataBuffer): boolean;
  116448. protected _deleteBuffer(buffer: DataBuffer): void;
  116449. /**
  116450. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  116451. * @param instancesBuffer defines the webGL buffer to update and bind
  116452. * @param data defines the data to store in the buffer
  116453. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  116454. */
  116455. updateAndBindInstancesBuffer(instancesBuffer: DataBuffer, data: Float32Array, offsetLocations: number[] | InstancingAttributeInfo[]): void;
  116456. /**
  116457. * Bind the content of a webGL buffer used with instantiation
  116458. * @param instancesBuffer defines the webGL buffer to bind
  116459. * @param attributesInfo defines the offsets or attributes information used to determine where data must be stored in the buffer
  116460. * @param computeStride defines Whether to compute the strides from the info or use the default 0
  116461. */
  116462. bindInstancesBuffer(instancesBuffer: DataBuffer, attributesInfo: InstancingAttributeInfo[], computeStride?: boolean): void;
  116463. /**
  116464. * Disable the instance attribute corresponding to the name in parameter
  116465. * @param name defines the name of the attribute to disable
  116466. */
  116467. disableInstanceAttributeByName(name: string): void;
  116468. /**
  116469. * Disable the instance attribute corresponding to the location in parameter
  116470. * @param attributeLocation defines the attribute location of the attribute to disable
  116471. */
  116472. disableInstanceAttribute(attributeLocation: number): void;
  116473. /**
  116474. * Disable the attribute corresponding to the location in parameter
  116475. * @param attributeLocation defines the attribute location of the attribute to disable
  116476. */
  116477. disableAttributeByIndex(attributeLocation: number): void;
  116478. /**
  116479. * Send a draw order
  116480. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116481. * @param indexStart defines the starting index
  116482. * @param indexCount defines the number of index to draw
  116483. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116484. */
  116485. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  116486. /**
  116487. * Draw a list of points
  116488. * @param verticesStart defines the index of first vertex to draw
  116489. * @param verticesCount defines the count of vertices to draw
  116490. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116491. */
  116492. drawPointClouds(verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116493. /**
  116494. * Draw a list of unindexed primitives
  116495. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  116496. * @param verticesStart defines the index of first vertex to draw
  116497. * @param verticesCount defines the count of vertices to draw
  116498. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116499. */
  116500. drawUnIndexed(useTriangles: boolean, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116501. /**
  116502. * Draw a list of indexed primitives
  116503. * @param fillMode defines the primitive to use
  116504. * @param indexStart defines the starting index
  116505. * @param indexCount defines the number of index to draw
  116506. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116507. */
  116508. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  116509. /**
  116510. * Draw a list of unindexed primitives
  116511. * @param fillMode defines the primitive to use
  116512. * @param verticesStart defines the index of first vertex to draw
  116513. * @param verticesCount defines the count of vertices to draw
  116514. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  116515. */
  116516. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  116517. private _drawMode;
  116518. /** @hidden */
  116519. protected _reportDrawCall(): void;
  116520. /** @hidden */
  116521. _releaseEffect(effect: Effect): void;
  116522. /** @hidden */
  116523. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  116524. /**
  116525. * Create a new effect (used to store vertex/fragment shaders)
  116526. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  116527. * @param attributesNamesOrOptions defines either a list of attribute names or an IEffectCreationOptions object
  116528. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  116529. * @param samplers defines an array of string used to represent textures
  116530. * @param defines defines the string containing the defines to use to compile the shaders
  116531. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  116532. * @param onCompiled defines a function to call when the effect creation is successful
  116533. * @param onError defines a function to call when the effect creation has failed
  116534. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  116535. * @returns the new Effect
  116536. */
  116537. 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;
  116538. protected static _ConcatenateShader(source: string, defines: Nullable<string>, shaderVersion?: string): string;
  116539. private _compileShader;
  116540. private _compileRawShader;
  116541. /** @hidden */
  116542. _getShaderSource(shader: WebGLShader): Nullable<string>;
  116543. /**
  116544. * Directly creates a webGL program
  116545. * @param pipelineContext defines the pipeline context to attach to
  116546. * @param vertexCode defines the vertex shader code to use
  116547. * @param fragmentCode defines the fragment shader code to use
  116548. * @param context defines the webGL context to use (if not set, the current one will be used)
  116549. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116550. * @returns the new webGL program
  116551. */
  116552. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116553. /**
  116554. * Creates a webGL program
  116555. * @param pipelineContext defines the pipeline context to attach to
  116556. * @param vertexCode defines the vertex shader code to use
  116557. * @param fragmentCode defines the fragment shader code to use
  116558. * @param defines defines the string containing the defines to use to compile the shaders
  116559. * @param context defines the webGL context to use (if not set, the current one will be used)
  116560. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  116561. * @returns the new webGL program
  116562. */
  116563. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116564. /**
  116565. * Creates a new pipeline context
  116566. * @returns the new pipeline
  116567. */
  116568. createPipelineContext(): IPipelineContext;
  116569. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  116570. protected _finalizePipelineContext(pipelineContext: WebGLPipelineContext): void;
  116571. /** @hidden */
  116572. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  116573. /** @hidden */
  116574. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  116575. /** @hidden */
  116576. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  116577. /**
  116578. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  116579. * @param pipelineContext defines the pipeline context to use
  116580. * @param uniformsNames defines the list of uniform names
  116581. * @returns an array of webGL uniform locations
  116582. */
  116583. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  116584. /**
  116585. * Gets the lsit of active attributes for a given webGL program
  116586. * @param pipelineContext defines the pipeline context to use
  116587. * @param attributesNames defines the list of attribute names to get
  116588. * @returns an array of indices indicating the offset of each attribute
  116589. */
  116590. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  116591. /**
  116592. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  116593. * @param effect defines the effect to activate
  116594. */
  116595. enableEffect(effect: Nullable<Effect>): void;
  116596. /**
  116597. * Set the value of an uniform to a number (int)
  116598. * @param uniform defines the webGL uniform location where to store the value
  116599. * @param value defines the int number to store
  116600. * @returns true if the value was set
  116601. */
  116602. setInt(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116603. /**
  116604. * Set the value of an uniform to an array of int32
  116605. * @param uniform defines the webGL uniform location where to store the value
  116606. * @param array defines the array of int32 to store
  116607. * @returns true if the value was set
  116608. */
  116609. setIntArray(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116610. /**
  116611. * Set the value of an uniform to an array of int32 (stored as vec2)
  116612. * @param uniform defines the webGL uniform location where to store the value
  116613. * @param array defines the array of int32 to store
  116614. * @returns true if the value was set
  116615. */
  116616. setIntArray2(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116617. /**
  116618. * Set the value of an uniform to an array of int32 (stored as vec3)
  116619. * @param uniform defines the webGL uniform location where to store the value
  116620. * @param array defines the array of int32 to store
  116621. * @returns true if the value was set
  116622. */
  116623. setIntArray3(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116624. /**
  116625. * Set the value of an uniform to an array of int32 (stored as vec4)
  116626. * @param uniform defines the webGL uniform location where to store the value
  116627. * @param array defines the array of int32 to store
  116628. * @returns true if the value was set
  116629. */
  116630. setIntArray4(uniform: Nullable<WebGLUniformLocation>, array: Int32Array): boolean;
  116631. /**
  116632. * Set the value of an uniform to an array of number
  116633. * @param uniform defines the webGL uniform location where to store the value
  116634. * @param array defines the array of number to store
  116635. * @returns true if the value was set
  116636. */
  116637. setArray(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116638. /**
  116639. * Set the value of an uniform to an array of number (stored as vec2)
  116640. * @param uniform defines the webGL uniform location where to store the value
  116641. * @param array defines the array of number to store
  116642. * @returns true if the value was set
  116643. */
  116644. setArray2(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116645. /**
  116646. * Set the value of an uniform to an array of number (stored as vec3)
  116647. * @param uniform defines the webGL uniform location where to store the value
  116648. * @param array defines the array of number to store
  116649. * @returns true if the value was set
  116650. */
  116651. setArray3(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116652. /**
  116653. * Set the value of an uniform to an array of number (stored as vec4)
  116654. * @param uniform defines the webGL uniform location where to store the value
  116655. * @param array defines the array of number to store
  116656. * @returns true if the value was set
  116657. */
  116658. setArray4(uniform: Nullable<WebGLUniformLocation>, array: number[] | Float32Array): boolean;
  116659. /**
  116660. * Set the value of an uniform to an array of float32 (stored as matrices)
  116661. * @param uniform defines the webGL uniform location where to store the value
  116662. * @param matrices defines the array of float32 to store
  116663. * @returns true if the value was set
  116664. */
  116665. setMatrices(uniform: Nullable<WebGLUniformLocation>, matrices: Float32Array): boolean;
  116666. /**
  116667. * Set the value of an uniform to a matrix (3x3)
  116668. * @param uniform defines the webGL uniform location where to store the value
  116669. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  116670. * @returns true if the value was set
  116671. */
  116672. setMatrix3x3(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116673. /**
  116674. * Set the value of an uniform to a matrix (2x2)
  116675. * @param uniform defines the webGL uniform location where to store the value
  116676. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  116677. * @returns true if the value was set
  116678. */
  116679. setMatrix2x2(uniform: Nullable<WebGLUniformLocation>, matrix: Float32Array): boolean;
  116680. /**
  116681. * Set the value of an uniform to a number (float)
  116682. * @param uniform defines the webGL uniform location where to store the value
  116683. * @param value defines the float number to store
  116684. * @returns true if the value was transfered
  116685. */
  116686. setFloat(uniform: Nullable<WebGLUniformLocation>, value: number): boolean;
  116687. /**
  116688. * Set the value of an uniform to a vec2
  116689. * @param uniform defines the webGL uniform location where to store the value
  116690. * @param x defines the 1st component of the value
  116691. * @param y defines the 2nd component of the value
  116692. * @returns true if the value was set
  116693. */
  116694. setFloat2(uniform: Nullable<WebGLUniformLocation>, x: number, y: number): boolean;
  116695. /**
  116696. * Set the value of an uniform to a vec3
  116697. * @param uniform defines the webGL uniform location where to store the value
  116698. * @param x defines the 1st component of the value
  116699. * @param y defines the 2nd component of the value
  116700. * @param z defines the 3rd component of the value
  116701. * @returns true if the value was set
  116702. */
  116703. setFloat3(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number): boolean;
  116704. /**
  116705. * Set the value of an uniform to a vec4
  116706. * @param uniform defines the webGL uniform location where to store the value
  116707. * @param x defines the 1st component of the value
  116708. * @param y defines the 2nd component of the value
  116709. * @param z defines the 3rd component of the value
  116710. * @param w defines the 4th component of the value
  116711. * @returns true if the value was set
  116712. */
  116713. setFloat4(uniform: Nullable<WebGLUniformLocation>, x: number, y: number, z: number, w: number): boolean;
  116714. /**
  116715. * Apply all cached states (depth, culling, stencil and alpha)
  116716. */
  116717. applyStates(): void;
  116718. /**
  116719. * Enable or disable color writing
  116720. * @param enable defines the state to set
  116721. */
  116722. setColorWrite(enable: boolean): void;
  116723. /**
  116724. * Gets a boolean indicating if color writing is enabled
  116725. * @returns the current color writing state
  116726. */
  116727. getColorWrite(): boolean;
  116728. /**
  116729. * Gets the depth culling state manager
  116730. */
  116731. get depthCullingState(): DepthCullingState;
  116732. /**
  116733. * Gets the alpha state manager
  116734. */
  116735. get alphaState(): AlphaState;
  116736. /**
  116737. * Gets the stencil state manager
  116738. */
  116739. get stencilState(): StencilState;
  116740. /**
  116741. * Clears the list of texture accessible through engine.
  116742. * This can help preventing texture load conflict due to name collision.
  116743. */
  116744. clearInternalTexturesCache(): void;
  116745. /**
  116746. * Force the entire cache to be cleared
  116747. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  116748. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  116749. */
  116750. wipeCaches(bruteForce?: boolean): void;
  116751. /** @hidden */
  116752. _getSamplingParameters(samplingMode: number, generateMipMaps: boolean): {
  116753. min: number;
  116754. mag: number;
  116755. };
  116756. /** @hidden */
  116757. _createTexture(): WebGLTexture;
  116758. /**
  116759. * Usually called from Texture.ts.
  116760. * Passed information to create a WebGLTexture
  116761. * @param url defines a value which contains one of the following:
  116762. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  116763. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  116764. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  116765. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  116766. * @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)
  116767. * @param scene needed for loading to the correct scene
  116768. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  116769. * @param onLoad optional callback to be called upon successful completion
  116770. * @param onError optional callback to be called upon failure
  116771. * @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
  116772. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  116773. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  116774. * @param forcedExtension defines the extension to use to pick the right loader
  116775. * @param mimeType defines an optional mime type
  116776. * @returns a InternalTexture for assignment back into BABYLON.Texture
  116777. */
  116778. 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;
  116779. /**
  116780. * Loads an image as an HTMLImageElement.
  116781. * @param input url string, ArrayBuffer, or Blob to load
  116782. * @param onLoad callback called when the image successfully loads
  116783. * @param onError callback called when the image fails to load
  116784. * @param offlineProvider offline provider for caching
  116785. * @param mimeType optional mime type
  116786. * @returns the HTMLImageElement of the loaded image
  116787. * @hidden
  116788. */
  116789. 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>;
  116790. /**
  116791. * @hidden
  116792. */
  116793. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  116794. private _unpackFlipYCached;
  116795. /**
  116796. * In case you are sharing the context with other applications, it might
  116797. * be interested to not cache the unpack flip y state to ensure a consistent
  116798. * value would be set.
  116799. */
  116800. enableUnpackFlipYCached: boolean;
  116801. /** @hidden */
  116802. _unpackFlipY(value: boolean): void;
  116803. /** @hidden */
  116804. _getUnpackAlignement(): number;
  116805. private _getTextureTarget;
  116806. /**
  116807. * Update the sampling mode of a given texture
  116808. * @param samplingMode defines the required sampling mode
  116809. * @param texture defines the texture to update
  116810. * @param generateMipMaps defines whether to generate mipmaps for the texture
  116811. */
  116812. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture, generateMipMaps?: boolean): void;
  116813. /**
  116814. * Update the sampling mode of a given texture
  116815. * @param texture defines the texture to update
  116816. * @param wrapU defines the texture wrap mode of the u coordinates
  116817. * @param wrapV defines the texture wrap mode of the v coordinates
  116818. * @param wrapR defines the texture wrap mode of the r coordinates
  116819. */
  116820. updateTextureWrappingMode(texture: InternalTexture, wrapU: Nullable<number>, wrapV?: Nullable<number>, wrapR?: Nullable<number>): void;
  116821. /** @hidden */
  116822. _setupDepthStencilTexture(internalTexture: InternalTexture, size: number | {
  116823. width: number;
  116824. height: number;
  116825. layers?: number;
  116826. }, generateStencil: boolean, bilinearFiltering: boolean, comparisonFunction: number): void;
  116827. /** @hidden */
  116828. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116829. /** @hidden */
  116830. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number, babylonInternalFormat?: number, useTextureWidthAndHeight?: boolean): void;
  116831. /**
  116832. * Update a portion of an internal texture
  116833. * @param texture defines the texture to update
  116834. * @param imageData defines the data to store into the texture
  116835. * @param xOffset defines the x coordinates of the update rectangle
  116836. * @param yOffset defines the y coordinates of the update rectangle
  116837. * @param width defines the width of the update rectangle
  116838. * @param height defines the height of the update rectangle
  116839. * @param faceIndex defines the face index if texture is a cube (0 by default)
  116840. * @param lod defines the lod level to update (0 by default)
  116841. */
  116842. updateTextureData(texture: InternalTexture, imageData: ArrayBufferView, xOffset: number, yOffset: number, width: number, height: number, faceIndex?: number, lod?: number): void;
  116843. /** @hidden */
  116844. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  116845. protected _prepareWebGLTextureContinuation(texture: InternalTexture, scene: Nullable<ISceneLike>, noMipmap: boolean, isCompressed: boolean, samplingMode: number): void;
  116846. private _prepareWebGLTexture;
  116847. /** @hidden */
  116848. _setupFramebufferDepthAttachments(generateStencilBuffer: boolean, generateDepthBuffer: boolean, width: number, height: number, samples?: number): Nullable<WebGLRenderbuffer>;
  116849. private _getDepthStencilBuffer;
  116850. /** @hidden */
  116851. _releaseFramebufferObjects(texture: InternalTexture): void;
  116852. /** @hidden */
  116853. _releaseTexture(texture: InternalTexture): void;
  116854. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  116855. protected _setProgram(program: WebGLProgram): void;
  116856. protected _boundUniforms: {
  116857. [key: number]: WebGLUniformLocation;
  116858. };
  116859. /**
  116860. * Binds an effect to the webGL context
  116861. * @param effect defines the effect to bind
  116862. */
  116863. bindSamplers(effect: Effect): void;
  116864. private _activateCurrentTexture;
  116865. /** @hidden */
  116866. _bindTextureDirectly(target: number, texture: Nullable<InternalTexture>, forTextureDataUpdate?: boolean, force?: boolean): boolean;
  116867. /** @hidden */
  116868. _bindTexture(channel: number, texture: Nullable<InternalTexture>): void;
  116869. /**
  116870. * Unbind all textures from the webGL context
  116871. */
  116872. unbindAllTextures(): void;
  116873. /**
  116874. * Sets a texture to the according uniform.
  116875. * @param channel The texture channel
  116876. * @param uniform The uniform to set
  116877. * @param texture The texture to apply
  116878. */
  116879. setTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<BaseTexture>): void;
  116880. private _bindSamplerUniformToChannel;
  116881. private _getTextureWrapMode;
  116882. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  116883. /**
  116884. * Sets an array of texture to the webGL context
  116885. * @param channel defines the channel where the texture array must be set
  116886. * @param uniform defines the associated uniform location
  116887. * @param textures defines the array of textures to bind
  116888. */
  116889. setTextureArray(channel: number, uniform: Nullable<WebGLUniformLocation>, textures: BaseTexture[]): void;
  116890. /** @hidden */
  116891. _setAnisotropicLevel(target: number, internalTexture: InternalTexture, anisotropicFilteringLevel: number): void;
  116892. private _setTextureParameterFloat;
  116893. private _setTextureParameterInteger;
  116894. /**
  116895. * Unbind all vertex attributes from the webGL context
  116896. */
  116897. unbindAllAttributes(): void;
  116898. /**
  116899. * 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
  116900. */
  116901. releaseEffects(): void;
  116902. /**
  116903. * Dispose and release all associated resources
  116904. */
  116905. dispose(): void;
  116906. /**
  116907. * Attach a new callback raised when context lost event is fired
  116908. * @param callback defines the callback to call
  116909. */
  116910. attachContextLostEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116911. /**
  116912. * Attach a new callback raised when context restored event is fired
  116913. * @param callback defines the callback to call
  116914. */
  116915. attachContextRestoredEvent(callback: ((event: WebGLContextEvent) => void)): void;
  116916. /**
  116917. * Get the current error code of the webGL context
  116918. * @returns the error code
  116919. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  116920. */
  116921. getError(): number;
  116922. private _canRenderToFloatFramebuffer;
  116923. private _canRenderToHalfFloatFramebuffer;
  116924. private _canRenderToFramebuffer;
  116925. /** @hidden */
  116926. _getWebGLTextureType(type: number): number;
  116927. /** @hidden */
  116928. _getInternalFormat(format: number): number;
  116929. /** @hidden */
  116930. _getRGBABufferInternalSizedFormat(type: number, format?: number): number;
  116931. /** @hidden */
  116932. _getRGBAMultiSampleBufferFormat(type: number): number;
  116933. /** @hidden */
  116934. _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;
  116935. /**
  116936. * Loads a file from a url
  116937. * @param url url to load
  116938. * @param onSuccess callback called when the file successfully loads
  116939. * @param onProgress callback called while file is loading (if the server supports this mode)
  116940. * @param offlineProvider defines the offline provider for caching
  116941. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  116942. * @param onError callback called when the file fails to load
  116943. * @returns a file request object
  116944. * @hidden
  116945. */
  116946. 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;
  116947. /**
  116948. * Reads pixels from the current frame buffer. Please note that this function can be slow
  116949. * @param x defines the x coordinate of the rectangle where pixels must be read
  116950. * @param y defines the y coordinate of the rectangle where pixels must be read
  116951. * @param width defines the width of the rectangle where pixels must be read
  116952. * @param height defines the height of the rectangle where pixels must be read
  116953. * @param hasAlpha defines whether the output should have alpha or not (defaults to true)
  116954. * @returns a Uint8Array containing RGBA colors
  116955. */
  116956. readPixels(x: number, y: number, width: number, height: number, hasAlpha?: boolean): Uint8Array;
  116957. private static _IsSupported;
  116958. private static _HasMajorPerformanceCaveat;
  116959. /**
  116960. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116961. */
  116962. static get IsSupported(): boolean;
  116963. /**
  116964. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  116965. * @returns true if the engine can be created
  116966. * @ignorenaming
  116967. */
  116968. static isSupported(): boolean;
  116969. /**
  116970. * Gets a boolean indicating if the engine can be instanciated on a performant device (ie. if a webGL context can be found and it does not use a slow implementation)
  116971. */
  116972. static get HasMajorPerformanceCaveat(): boolean;
  116973. /**
  116974. * Find the next highest power of two.
  116975. * @param x Number to start search from.
  116976. * @return Next highest power of two.
  116977. */
  116978. static CeilingPOT(x: number): number;
  116979. /**
  116980. * Find the next lowest power of two.
  116981. * @param x Number to start search from.
  116982. * @return Next lowest power of two.
  116983. */
  116984. static FloorPOT(x: number): number;
  116985. /**
  116986. * Find the nearest power of two.
  116987. * @param x Number to start search from.
  116988. * @return Next nearest power of two.
  116989. */
  116990. static NearestPOT(x: number): number;
  116991. /**
  116992. * Get the closest exponent of two
  116993. * @param value defines the value to approximate
  116994. * @param max defines the maximum value to return
  116995. * @param mode defines how to define the closest value
  116996. * @returns closest exponent of two of the given value
  116997. */
  116998. static GetExponentOfTwo(value: number, max: number, mode?: number): number;
  116999. /**
  117000. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  117001. * @param func - the function to be called
  117002. * @param requester - the object that will request the next frame. Falls back to window.
  117003. * @returns frame number
  117004. */
  117005. static QueueNewFrame(func: () => void, requester?: any): number;
  117006. /**
  117007. * Gets host document
  117008. * @returns the host document object
  117009. */
  117010. getHostDocument(): Nullable<Document>;
  117011. }
  117012. }
  117013. declare module BABYLON {
  117014. /**
  117015. * Class representing spherical harmonics coefficients to the 3rd degree
  117016. */
  117017. export class SphericalHarmonics {
  117018. /**
  117019. * Defines whether or not the harmonics have been prescaled for rendering.
  117020. */
  117021. preScaled: boolean;
  117022. /**
  117023. * The l0,0 coefficients of the spherical harmonics
  117024. */
  117025. l00: Vector3;
  117026. /**
  117027. * The l1,-1 coefficients of the spherical harmonics
  117028. */
  117029. l1_1: Vector3;
  117030. /**
  117031. * The l1,0 coefficients of the spherical harmonics
  117032. */
  117033. l10: Vector3;
  117034. /**
  117035. * The l1,1 coefficients of the spherical harmonics
  117036. */
  117037. l11: Vector3;
  117038. /**
  117039. * The l2,-2 coefficients of the spherical harmonics
  117040. */
  117041. l2_2: Vector3;
  117042. /**
  117043. * The l2,-1 coefficients of the spherical harmonics
  117044. */
  117045. l2_1: Vector3;
  117046. /**
  117047. * The l2,0 coefficients of the spherical harmonics
  117048. */
  117049. l20: Vector3;
  117050. /**
  117051. * The l2,1 coefficients of the spherical harmonics
  117052. */
  117053. l21: Vector3;
  117054. /**
  117055. * The l2,2 coefficients of the spherical harmonics
  117056. */
  117057. l22: Vector3;
  117058. /**
  117059. * Adds a light to the spherical harmonics
  117060. * @param direction the direction of the light
  117061. * @param color the color of the light
  117062. * @param deltaSolidAngle the delta solid angle of the light
  117063. */
  117064. addLight(direction: Vector3, color: Color3, deltaSolidAngle: number): void;
  117065. /**
  117066. * Scales the spherical harmonics by the given amount
  117067. * @param scale the amount to scale
  117068. */
  117069. scaleInPlace(scale: number): void;
  117070. /**
  117071. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  117072. *
  117073. * ```
  117074. * E_lm = A_l * L_lm
  117075. * ```
  117076. *
  117077. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  117078. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  117079. * the scaling factors are given in equation 9.
  117080. */
  117081. convertIncidentRadianceToIrradiance(): void;
  117082. /**
  117083. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  117084. *
  117085. * ```
  117086. * L = (1/pi) * E * rho
  117087. * ```
  117088. *
  117089. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  117090. */
  117091. convertIrradianceToLambertianRadiance(): void;
  117092. /**
  117093. * Integrates the reconstruction coefficients directly in to the SH preventing further
  117094. * required operations at run time.
  117095. *
  117096. * This is simply done by scaling back the SH with Ylm constants parameter.
  117097. * The trigonometric part being applied by the shader at run time.
  117098. */
  117099. preScaleForRendering(): void;
  117100. /**
  117101. * Constructs a spherical harmonics from an array.
  117102. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  117103. * @returns the spherical harmonics
  117104. */
  117105. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalHarmonics;
  117106. /**
  117107. * Gets the spherical harmonics from polynomial
  117108. * @param polynomial the spherical polynomial
  117109. * @returns the spherical harmonics
  117110. */
  117111. static FromPolynomial(polynomial: SphericalPolynomial): SphericalHarmonics;
  117112. }
  117113. /**
  117114. * Class representing spherical polynomial coefficients to the 3rd degree
  117115. */
  117116. export class SphericalPolynomial {
  117117. private _harmonics;
  117118. /**
  117119. * The spherical harmonics used to create the polynomials.
  117120. */
  117121. get preScaledHarmonics(): SphericalHarmonics;
  117122. /**
  117123. * The x coefficients of the spherical polynomial
  117124. */
  117125. x: Vector3;
  117126. /**
  117127. * The y coefficients of the spherical polynomial
  117128. */
  117129. y: Vector3;
  117130. /**
  117131. * The z coefficients of the spherical polynomial
  117132. */
  117133. z: Vector3;
  117134. /**
  117135. * The xx coefficients of the spherical polynomial
  117136. */
  117137. xx: Vector3;
  117138. /**
  117139. * The yy coefficients of the spherical polynomial
  117140. */
  117141. yy: Vector3;
  117142. /**
  117143. * The zz coefficients of the spherical polynomial
  117144. */
  117145. zz: Vector3;
  117146. /**
  117147. * The xy coefficients of the spherical polynomial
  117148. */
  117149. xy: Vector3;
  117150. /**
  117151. * The yz coefficients of the spherical polynomial
  117152. */
  117153. yz: Vector3;
  117154. /**
  117155. * The zx coefficients of the spherical polynomial
  117156. */
  117157. zx: Vector3;
  117158. /**
  117159. * Adds an ambient color to the spherical polynomial
  117160. * @param color the color to add
  117161. */
  117162. addAmbient(color: Color3): void;
  117163. /**
  117164. * Scales the spherical polynomial by the given amount
  117165. * @param scale the amount to scale
  117166. */
  117167. scaleInPlace(scale: number): void;
  117168. /**
  117169. * Gets the spherical polynomial from harmonics
  117170. * @param harmonics the spherical harmonics
  117171. * @returns the spherical polynomial
  117172. */
  117173. static FromHarmonics(harmonics: SphericalHarmonics): SphericalPolynomial;
  117174. /**
  117175. * Constructs a spherical polynomial from an array.
  117176. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  117177. * @returns the spherical polynomial
  117178. */
  117179. static FromArray(data: ArrayLike<ArrayLike<number>>): SphericalPolynomial;
  117180. }
  117181. }
  117182. declare module BABYLON {
  117183. /**
  117184. * Defines the source of the internal texture
  117185. */
  117186. export enum InternalTextureSource {
  117187. /**
  117188. * The source of the texture data is unknown
  117189. */
  117190. Unknown = 0,
  117191. /**
  117192. * Texture data comes from an URL
  117193. */
  117194. Url = 1,
  117195. /**
  117196. * Texture data is only used for temporary storage
  117197. */
  117198. Temp = 2,
  117199. /**
  117200. * Texture data comes from raw data (ArrayBuffer)
  117201. */
  117202. Raw = 3,
  117203. /**
  117204. * Texture content is dynamic (video or dynamic texture)
  117205. */
  117206. Dynamic = 4,
  117207. /**
  117208. * Texture content is generated by rendering to it
  117209. */
  117210. RenderTarget = 5,
  117211. /**
  117212. * Texture content is part of a multi render target process
  117213. */
  117214. MultiRenderTarget = 6,
  117215. /**
  117216. * Texture data comes from a cube data file
  117217. */
  117218. Cube = 7,
  117219. /**
  117220. * Texture data comes from a raw cube data
  117221. */
  117222. CubeRaw = 8,
  117223. /**
  117224. * Texture data come from a prefiltered cube data file
  117225. */
  117226. CubePrefiltered = 9,
  117227. /**
  117228. * Texture content is raw 3D data
  117229. */
  117230. Raw3D = 10,
  117231. /**
  117232. * Texture content is raw 2D array data
  117233. */
  117234. Raw2DArray = 11,
  117235. /**
  117236. * Texture content is a depth texture
  117237. */
  117238. Depth = 12,
  117239. /**
  117240. * Texture data comes from a raw cube data encoded with RGBD
  117241. */
  117242. CubeRawRGBD = 13
  117243. }
  117244. /**
  117245. * Class used to store data associated with WebGL texture data for the engine
  117246. * This class should not be used directly
  117247. */
  117248. export class InternalTexture {
  117249. /** @hidden */
  117250. static _UpdateRGBDAsync: (internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number) => Promise<void>;
  117251. /**
  117252. * Defines if the texture is ready
  117253. */
  117254. isReady: boolean;
  117255. /**
  117256. * Defines if the texture is a cube texture
  117257. */
  117258. isCube: boolean;
  117259. /**
  117260. * Defines if the texture contains 3D data
  117261. */
  117262. is3D: boolean;
  117263. /**
  117264. * Defines if the texture contains 2D array data
  117265. */
  117266. is2DArray: boolean;
  117267. /**
  117268. * Defines if the texture contains multiview data
  117269. */
  117270. isMultiview: boolean;
  117271. /**
  117272. * Gets the URL used to load this texture
  117273. */
  117274. url: string;
  117275. /**
  117276. * Gets the sampling mode of the texture
  117277. */
  117278. samplingMode: number;
  117279. /**
  117280. * Gets a boolean indicating if the texture needs mipmaps generation
  117281. */
  117282. generateMipMaps: boolean;
  117283. /**
  117284. * Gets the number of samples used by the texture (WebGL2+ only)
  117285. */
  117286. samples: number;
  117287. /**
  117288. * Gets the type of the texture (int, float...)
  117289. */
  117290. type: number;
  117291. /**
  117292. * Gets the format of the texture (RGB, RGBA...)
  117293. */
  117294. format: number;
  117295. /**
  117296. * Observable called when the texture is loaded
  117297. */
  117298. onLoadedObservable: Observable<InternalTexture>;
  117299. /**
  117300. * Gets the width of the texture
  117301. */
  117302. width: number;
  117303. /**
  117304. * Gets the height of the texture
  117305. */
  117306. height: number;
  117307. /**
  117308. * Gets the depth of the texture
  117309. */
  117310. depth: number;
  117311. /**
  117312. * Gets the initial width of the texture (It could be rescaled if the current system does not support non power of two textures)
  117313. */
  117314. baseWidth: number;
  117315. /**
  117316. * Gets the initial height of the texture (It could be rescaled if the current system does not support non power of two textures)
  117317. */
  117318. baseHeight: number;
  117319. /**
  117320. * Gets the initial depth of the texture (It could be rescaled if the current system does not support non power of two textures)
  117321. */
  117322. baseDepth: number;
  117323. /**
  117324. * Gets a boolean indicating if the texture is inverted on Y axis
  117325. */
  117326. invertY: boolean;
  117327. /** @hidden */
  117328. _invertVScale: boolean;
  117329. /** @hidden */
  117330. _associatedChannel: number;
  117331. /** @hidden */
  117332. _source: InternalTextureSource;
  117333. /** @hidden */
  117334. _buffer: Nullable<string | ArrayBuffer | ArrayBufferView | HTMLImageElement | Blob | ImageBitmap>;
  117335. /** @hidden */
  117336. _bufferView: Nullable<ArrayBufferView>;
  117337. /** @hidden */
  117338. _bufferViewArray: Nullable<ArrayBufferView[]>;
  117339. /** @hidden */
  117340. _bufferViewArrayArray: Nullable<ArrayBufferView[][]>;
  117341. /** @hidden */
  117342. _size: number;
  117343. /** @hidden */
  117344. _extension: string;
  117345. /** @hidden */
  117346. _files: Nullable<string[]>;
  117347. /** @hidden */
  117348. _workingCanvas: Nullable<HTMLCanvasElement | OffscreenCanvas>;
  117349. /** @hidden */
  117350. _workingContext: Nullable<CanvasRenderingContext2D | OffscreenCanvasRenderingContext2D>;
  117351. /** @hidden */
  117352. _framebuffer: Nullable<WebGLFramebuffer>;
  117353. /** @hidden */
  117354. _depthStencilBuffer: Nullable<WebGLRenderbuffer>;
  117355. /** @hidden */
  117356. _MSAAFramebuffer: Nullable<WebGLFramebuffer>;
  117357. /** @hidden */
  117358. _MSAARenderBuffer: Nullable<WebGLRenderbuffer>;
  117359. /** @hidden */
  117360. _attachments: Nullable<number[]>;
  117361. /** @hidden */
  117362. _textureArray: Nullable<InternalTexture[]>;
  117363. /** @hidden */
  117364. _cachedCoordinatesMode: Nullable<number>;
  117365. /** @hidden */
  117366. _cachedWrapU: Nullable<number>;
  117367. /** @hidden */
  117368. _cachedWrapV: Nullable<number>;
  117369. /** @hidden */
  117370. _cachedWrapR: Nullable<number>;
  117371. /** @hidden */
  117372. _cachedAnisotropicFilteringLevel: Nullable<number>;
  117373. /** @hidden */
  117374. _isDisabled: boolean;
  117375. /** @hidden */
  117376. _compression: Nullable<string>;
  117377. /** @hidden */
  117378. _generateStencilBuffer: boolean;
  117379. /** @hidden */
  117380. _generateDepthBuffer: boolean;
  117381. /** @hidden */
  117382. _comparisonFunction: number;
  117383. /** @hidden */
  117384. _sphericalPolynomial: Nullable<SphericalPolynomial>;
  117385. /** @hidden */
  117386. _lodGenerationScale: number;
  117387. /** @hidden */
  117388. _lodGenerationOffset: number;
  117389. /** @hidden */
  117390. _depthStencilTexture: Nullable<InternalTexture>;
  117391. /** @hidden */
  117392. _colorTextureArray: Nullable<WebGLTexture>;
  117393. /** @hidden */
  117394. _depthStencilTextureArray: Nullable<WebGLTexture>;
  117395. /** @hidden */
  117396. _lodTextureHigh: Nullable<BaseTexture>;
  117397. /** @hidden */
  117398. _lodTextureMid: Nullable<BaseTexture>;
  117399. /** @hidden */
  117400. _lodTextureLow: Nullable<BaseTexture>;
  117401. /** @hidden */
  117402. _isRGBD: boolean;
  117403. /** @hidden */
  117404. _linearSpecularLOD: boolean;
  117405. /** @hidden */
  117406. _irradianceTexture: Nullable<BaseTexture>;
  117407. /** @hidden */
  117408. _webGLTexture: Nullable<WebGLTexture>;
  117409. /** @hidden */
  117410. _references: number;
  117411. /** @hidden */
  117412. _gammaSpace: Nullable<boolean>;
  117413. private _engine;
  117414. /**
  117415. * Gets the Engine the texture belongs to.
  117416. * @returns The babylon engine
  117417. */
  117418. getEngine(): ThinEngine;
  117419. /**
  117420. * Gets the data source type of the texture
  117421. */
  117422. get source(): InternalTextureSource;
  117423. /**
  117424. * Creates a new InternalTexture
  117425. * @param engine defines the engine to use
  117426. * @param source defines the type of data that will be used
  117427. * @param delayAllocation if the texture allocation should be delayed (default: false)
  117428. */
  117429. constructor(engine: ThinEngine, source: InternalTextureSource, delayAllocation?: boolean);
  117430. /**
  117431. * Increments the number of references (ie. the number of Texture that point to it)
  117432. */
  117433. incrementReferences(): void;
  117434. /**
  117435. * Change the size of the texture (not the size of the content)
  117436. * @param width defines the new width
  117437. * @param height defines the new height
  117438. * @param depth defines the new depth (1 by default)
  117439. */
  117440. updateSize(width: int, height: int, depth?: int): void;
  117441. /** @hidden */
  117442. _rebuild(): void;
  117443. /** @hidden */
  117444. _swapAndDie(target: InternalTexture): void;
  117445. /**
  117446. * Dispose the current allocated resources
  117447. */
  117448. dispose(): void;
  117449. }
  117450. }
  117451. declare module BABYLON {
  117452. /**
  117453. * Class used to work with sound analyzer using fast fourier transform (FFT)
  117454. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117455. */
  117456. export class Analyser {
  117457. /**
  117458. * Gets or sets the smoothing
  117459. * @ignorenaming
  117460. */
  117461. SMOOTHING: number;
  117462. /**
  117463. * Gets or sets the FFT table size
  117464. * @ignorenaming
  117465. */
  117466. FFT_SIZE: number;
  117467. /**
  117468. * Gets or sets the bar graph amplitude
  117469. * @ignorenaming
  117470. */
  117471. BARGRAPHAMPLITUDE: number;
  117472. /**
  117473. * Gets or sets the position of the debug canvas
  117474. * @ignorenaming
  117475. */
  117476. DEBUGCANVASPOS: {
  117477. x: number;
  117478. y: number;
  117479. };
  117480. /**
  117481. * Gets or sets the debug canvas size
  117482. * @ignorenaming
  117483. */
  117484. DEBUGCANVASSIZE: {
  117485. width: number;
  117486. height: number;
  117487. };
  117488. private _byteFreqs;
  117489. private _byteTime;
  117490. private _floatFreqs;
  117491. private _webAudioAnalyser;
  117492. private _debugCanvas;
  117493. private _debugCanvasContext;
  117494. private _scene;
  117495. private _registerFunc;
  117496. private _audioEngine;
  117497. /**
  117498. * Creates a new analyser
  117499. * @param scene defines hosting scene
  117500. */
  117501. constructor(scene: Scene);
  117502. /**
  117503. * Get the number of data values you will have to play with for the visualization
  117504. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  117505. * @returns a number
  117506. */
  117507. getFrequencyBinCount(): number;
  117508. /**
  117509. * Gets the current frequency data as a byte array
  117510. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117511. * @returns a Uint8Array
  117512. */
  117513. getByteFrequencyData(): Uint8Array;
  117514. /**
  117515. * Gets the current waveform as a byte array
  117516. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  117517. * @returns a Uint8Array
  117518. */
  117519. getByteTimeDomainData(): Uint8Array;
  117520. /**
  117521. * Gets the current frequency data as a float array
  117522. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  117523. * @returns a Float32Array
  117524. */
  117525. getFloatFrequencyData(): Float32Array;
  117526. /**
  117527. * Renders the debug canvas
  117528. */
  117529. drawDebugCanvas(): void;
  117530. /**
  117531. * Stops rendering the debug canvas and removes it
  117532. */
  117533. stopDebugCanvas(): void;
  117534. /**
  117535. * Connects two audio nodes
  117536. * @param inputAudioNode defines first node to connect
  117537. * @param outputAudioNode defines second node to connect
  117538. */
  117539. connectAudioNodes(inputAudioNode: AudioNode, outputAudioNode: AudioNode): void;
  117540. /**
  117541. * Releases all associated resources
  117542. */
  117543. dispose(): void;
  117544. }
  117545. }
  117546. declare module BABYLON {
  117547. /**
  117548. * This represents an audio engine and it is responsible
  117549. * to play, synchronize and analyse sounds throughout the application.
  117550. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117551. */
  117552. export interface IAudioEngine extends IDisposable {
  117553. /**
  117554. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117555. */
  117556. readonly canUseWebAudio: boolean;
  117557. /**
  117558. * Gets the current AudioContext if available.
  117559. */
  117560. readonly audioContext: Nullable<AudioContext>;
  117561. /**
  117562. * The master gain node defines the global audio volume of your audio engine.
  117563. */
  117564. readonly masterGain: GainNode;
  117565. /**
  117566. * Gets whether or not mp3 are supported by your browser.
  117567. */
  117568. readonly isMP3supported: boolean;
  117569. /**
  117570. * Gets whether or not ogg are supported by your browser.
  117571. */
  117572. readonly isOGGsupported: boolean;
  117573. /**
  117574. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117575. * @ignoreNaming
  117576. */
  117577. WarnedWebAudioUnsupported: boolean;
  117578. /**
  117579. * Defines if the audio engine relies on a custom unlocked button.
  117580. * In this case, the embedded button will not be displayed.
  117581. */
  117582. useCustomUnlockedButton: boolean;
  117583. /**
  117584. * Gets whether or not the audio engine is unlocked (require first a user gesture on some browser).
  117585. */
  117586. readonly unlocked: boolean;
  117587. /**
  117588. * Event raised when audio has been unlocked on the browser.
  117589. */
  117590. onAudioUnlockedObservable: Observable<AudioEngine>;
  117591. /**
  117592. * Event raised when audio has been locked on the browser.
  117593. */
  117594. onAudioLockedObservable: Observable<AudioEngine>;
  117595. /**
  117596. * Flags the audio engine in Locked state.
  117597. * This happens due to new browser policies preventing audio to autoplay.
  117598. */
  117599. lock(): void;
  117600. /**
  117601. * Unlocks the audio engine once a user action has been done on the dom.
  117602. * This is helpful to resume play once browser policies have been satisfied.
  117603. */
  117604. unlock(): void;
  117605. /**
  117606. * Gets the global volume sets on the master gain.
  117607. * @returns the global volume if set or -1 otherwise
  117608. */
  117609. getGlobalVolume(): number;
  117610. /**
  117611. * Sets the global volume of your experience (sets on the master gain).
  117612. * @param newVolume Defines the new global volume of the application
  117613. */
  117614. setGlobalVolume(newVolume: number): void;
  117615. /**
  117616. * Connect the audio engine to an audio analyser allowing some amazing
  117617. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117618. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117619. * @param analyser The analyser to connect to the engine
  117620. */
  117621. connectToAnalyser(analyser: Analyser): void;
  117622. }
  117623. /**
  117624. * This represents the default audio engine used in babylon.
  117625. * It is responsible to play, synchronize and analyse sounds throughout the application.
  117626. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  117627. */
  117628. export class AudioEngine implements IAudioEngine {
  117629. private _audioContext;
  117630. private _audioContextInitialized;
  117631. private _muteButton;
  117632. private _hostElement;
  117633. /**
  117634. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  117635. */
  117636. canUseWebAudio: boolean;
  117637. /**
  117638. * The master gain node defines the global audio volume of your audio engine.
  117639. */
  117640. masterGain: GainNode;
  117641. /**
  117642. * Defines if Babylon should emit a warning if WebAudio is not supported.
  117643. * @ignoreNaming
  117644. */
  117645. WarnedWebAudioUnsupported: boolean;
  117646. /**
  117647. * Gets whether or not mp3 are supported by your browser.
  117648. */
  117649. isMP3supported: boolean;
  117650. /**
  117651. * Gets whether or not ogg are supported by your browser.
  117652. */
  117653. isOGGsupported: boolean;
  117654. /**
  117655. * Gets whether audio has been unlocked on the device.
  117656. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  117657. * a user interaction has happened.
  117658. */
  117659. unlocked: boolean;
  117660. /**
  117661. * Defines if the audio engine relies on a custom unlocked button.
  117662. * In this case, the embedded button will not be displayed.
  117663. */
  117664. useCustomUnlockedButton: boolean;
  117665. /**
  117666. * Event raised when audio has been unlocked on the browser.
  117667. */
  117668. onAudioUnlockedObservable: Observable<AudioEngine>;
  117669. /**
  117670. * Event raised when audio has been locked on the browser.
  117671. */
  117672. onAudioLockedObservable: Observable<AudioEngine>;
  117673. /**
  117674. * Gets the current AudioContext if available.
  117675. */
  117676. get audioContext(): Nullable<AudioContext>;
  117677. private _connectedAnalyser;
  117678. /**
  117679. * Instantiates a new audio engine.
  117680. *
  117681. * There should be only one per page as some browsers restrict the number
  117682. * of audio contexts you can create.
  117683. * @param hostElement defines the host element where to display the mute icon if necessary
  117684. */
  117685. constructor(hostElement?: Nullable<HTMLElement>);
  117686. /**
  117687. * Flags the audio engine in Locked state.
  117688. * This happens due to new browser policies preventing audio to autoplay.
  117689. */
  117690. lock(): void;
  117691. /**
  117692. * Unlocks the audio engine once a user action has been done on the dom.
  117693. * This is helpful to resume play once browser policies have been satisfied.
  117694. */
  117695. unlock(): void;
  117696. private _resumeAudioContext;
  117697. private _initializeAudioContext;
  117698. private _tryToRun;
  117699. private _triggerRunningState;
  117700. private _triggerSuspendedState;
  117701. private _displayMuteButton;
  117702. private _moveButtonToTopLeft;
  117703. private _onResize;
  117704. private _hideMuteButton;
  117705. /**
  117706. * Destroy and release the resources associated with the audio ccontext.
  117707. */
  117708. dispose(): void;
  117709. /**
  117710. * Gets the global volume sets on the master gain.
  117711. * @returns the global volume if set or -1 otherwise
  117712. */
  117713. getGlobalVolume(): number;
  117714. /**
  117715. * Sets the global volume of your experience (sets on the master gain).
  117716. * @param newVolume Defines the new global volume of the application
  117717. */
  117718. setGlobalVolume(newVolume: number): void;
  117719. /**
  117720. * Connect the audio engine to an audio analyser allowing some amazing
  117721. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  117722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  117723. * @param analyser The analyser to connect to the engine
  117724. */
  117725. connectToAnalyser(analyser: Analyser): void;
  117726. }
  117727. }
  117728. declare module BABYLON {
  117729. /**
  117730. * Interface used to present a loading screen while loading a scene
  117731. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117732. */
  117733. export interface ILoadingScreen {
  117734. /**
  117735. * Function called to display the loading screen
  117736. */
  117737. displayLoadingUI: () => void;
  117738. /**
  117739. * Function called to hide the loading screen
  117740. */
  117741. hideLoadingUI: () => void;
  117742. /**
  117743. * Gets or sets the color to use for the background
  117744. */
  117745. loadingUIBackgroundColor: string;
  117746. /**
  117747. * Gets or sets the text to display while loading
  117748. */
  117749. loadingUIText: string;
  117750. }
  117751. /**
  117752. * Class used for the default loading screen
  117753. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  117754. */
  117755. export class DefaultLoadingScreen implements ILoadingScreen {
  117756. private _renderingCanvas;
  117757. private _loadingText;
  117758. private _loadingDivBackgroundColor;
  117759. private _loadingDiv;
  117760. private _loadingTextDiv;
  117761. /** Gets or sets the logo url to use for the default loading screen */
  117762. static DefaultLogoUrl: string;
  117763. /** Gets or sets the spinner url to use for the default loading screen */
  117764. static DefaultSpinnerUrl: string;
  117765. /**
  117766. * Creates a new default loading screen
  117767. * @param _renderingCanvas defines the canvas used to render the scene
  117768. * @param _loadingText defines the default text to display
  117769. * @param _loadingDivBackgroundColor defines the default background color
  117770. */
  117771. constructor(_renderingCanvas: HTMLCanvasElement, _loadingText?: string, _loadingDivBackgroundColor?: string);
  117772. /**
  117773. * Function called to display the loading screen
  117774. */
  117775. displayLoadingUI(): void;
  117776. /**
  117777. * Function called to hide the loading screen
  117778. */
  117779. hideLoadingUI(): void;
  117780. /**
  117781. * Gets or sets the text to display while loading
  117782. */
  117783. set loadingUIText(text: string);
  117784. get loadingUIText(): string;
  117785. /**
  117786. * Gets or sets the color to use for the background
  117787. */
  117788. get loadingUIBackgroundColor(): string;
  117789. set loadingUIBackgroundColor(color: string);
  117790. private _resizeLoadingUI;
  117791. }
  117792. }
  117793. declare module BABYLON {
  117794. /**
  117795. * Interface for any object that can request an animation frame
  117796. */
  117797. export interface ICustomAnimationFrameRequester {
  117798. /**
  117799. * This function will be called when the render loop is ready. If this is not populated, the engine's renderloop function will be called
  117800. */
  117801. renderFunction?: Function;
  117802. /**
  117803. * Called to request the next frame to render to
  117804. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame
  117805. */
  117806. requestAnimationFrame: Function;
  117807. /**
  117808. * You can pass this value to cancelAnimationFrame() to cancel the refresh callback request
  117809. * @see https://developer.mozilla.org/en-US/docs/Web/API/window/requestAnimationFrame#Return_value
  117810. */
  117811. requestID?: number;
  117812. }
  117813. }
  117814. declare module BABYLON {
  117815. /**
  117816. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  117817. */
  117818. export class PerformanceMonitor {
  117819. private _enabled;
  117820. private _rollingFrameTime;
  117821. private _lastFrameTimeMs;
  117822. /**
  117823. * constructor
  117824. * @param frameSampleSize The number of samples required to saturate the sliding window
  117825. */
  117826. constructor(frameSampleSize?: number);
  117827. /**
  117828. * Samples current frame
  117829. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  117830. */
  117831. sampleFrame(timeMs?: number): void;
  117832. /**
  117833. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117834. */
  117835. get averageFrameTime(): number;
  117836. /**
  117837. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  117838. */
  117839. get averageFrameTimeVariance(): number;
  117840. /**
  117841. * Returns the frame time of the most recent frame
  117842. */
  117843. get instantaneousFrameTime(): number;
  117844. /**
  117845. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  117846. */
  117847. get averageFPS(): number;
  117848. /**
  117849. * Returns the average framerate in frames per second using the most recent frame time
  117850. */
  117851. get instantaneousFPS(): number;
  117852. /**
  117853. * Returns true if enough samples have been taken to completely fill the sliding window
  117854. */
  117855. get isSaturated(): boolean;
  117856. /**
  117857. * Enables contributions to the sliding window sample set
  117858. */
  117859. enable(): void;
  117860. /**
  117861. * Disables contributions to the sliding window sample set
  117862. * Samples will not be interpolated over the disabled period
  117863. */
  117864. disable(): void;
  117865. /**
  117866. * Returns true if sampling is enabled
  117867. */
  117868. get isEnabled(): boolean;
  117869. /**
  117870. * Resets performance monitor
  117871. */
  117872. reset(): void;
  117873. }
  117874. /**
  117875. * RollingAverage
  117876. *
  117877. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  117878. */
  117879. export class RollingAverage {
  117880. /**
  117881. * Current average
  117882. */
  117883. average: number;
  117884. /**
  117885. * Current variance
  117886. */
  117887. variance: number;
  117888. protected _samples: Array<number>;
  117889. protected _sampleCount: number;
  117890. protected _pos: number;
  117891. protected _m2: number;
  117892. /**
  117893. * constructor
  117894. * @param length The number of samples required to saturate the sliding window
  117895. */
  117896. constructor(length: number);
  117897. /**
  117898. * Adds a sample to the sample set
  117899. * @param v The sample value
  117900. */
  117901. add(v: number): void;
  117902. /**
  117903. * Returns previously added values or null if outside of history or outside the sliding window domain
  117904. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  117905. * @return Value previously recorded with add() or null if outside of range
  117906. */
  117907. history(i: number): number;
  117908. /**
  117909. * Returns true if enough samples have been taken to completely fill the sliding window
  117910. * @return true if sample-set saturated
  117911. */
  117912. isSaturated(): boolean;
  117913. /**
  117914. * Resets the rolling average (equivalent to 0 samples taken so far)
  117915. */
  117916. reset(): void;
  117917. /**
  117918. * Wraps a value around the sample range boundaries
  117919. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  117920. * @return Wrapped position in sample range
  117921. */
  117922. protected _wrapPosition(i: number): number;
  117923. }
  117924. }
  117925. declare module BABYLON {
  117926. /**
  117927. * This class is used to track a performance counter which is number based.
  117928. * The user has access to many properties which give statistics of different nature.
  117929. *
  117930. * The implementer can track two kinds of Performance Counter: time and count.
  117931. * 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.
  117932. * 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.
  117933. */
  117934. export class PerfCounter {
  117935. /**
  117936. * Gets or sets a global boolean to turn on and off all the counters
  117937. */
  117938. static Enabled: boolean;
  117939. /**
  117940. * Returns the smallest value ever
  117941. */
  117942. get min(): number;
  117943. /**
  117944. * Returns the biggest value ever
  117945. */
  117946. get max(): number;
  117947. /**
  117948. * Returns the average value since the performance counter is running
  117949. */
  117950. get average(): number;
  117951. /**
  117952. * Returns the average value of the last second the counter was monitored
  117953. */
  117954. get lastSecAverage(): number;
  117955. /**
  117956. * Returns the current value
  117957. */
  117958. get current(): number;
  117959. /**
  117960. * Gets the accumulated total
  117961. */
  117962. get total(): number;
  117963. /**
  117964. * Gets the total value count
  117965. */
  117966. get count(): number;
  117967. /**
  117968. * Creates a new counter
  117969. */
  117970. constructor();
  117971. /**
  117972. * Call this method to start monitoring a new frame.
  117973. * 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.
  117974. */
  117975. fetchNewFrame(): void;
  117976. /**
  117977. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  117978. * @param newCount the count value to add to the monitored count
  117979. * @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.
  117980. */
  117981. addCount(newCount: number, fetchResult: boolean): void;
  117982. /**
  117983. * Start monitoring this performance counter
  117984. */
  117985. beginMonitoring(): void;
  117986. /**
  117987. * Compute the time lapsed since the previous beginMonitoring() call.
  117988. * @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
  117989. */
  117990. endMonitoring(newFrame?: boolean): void;
  117991. private _fetchResult;
  117992. private _startMonitoringTime;
  117993. private _min;
  117994. private _max;
  117995. private _average;
  117996. private _current;
  117997. private _totalValueCount;
  117998. private _totalAccumulated;
  117999. private _lastSecAverage;
  118000. private _lastSecAccumulated;
  118001. private _lastSecTime;
  118002. private _lastSecValueCount;
  118003. }
  118004. }
  118005. declare module BABYLON {
  118006. interface ThinEngine {
  118007. /** @hidden */
  118008. _readTexturePixels(texture: InternalTexture, width: number, height: number, faceIndex?: number, level?: number, buffer?: Nullable<ArrayBufferView>): ArrayBufferView;
  118009. }
  118010. }
  118011. declare module BABYLON {
  118012. /**
  118013. * Defines the interface used by display changed events
  118014. */
  118015. export interface IDisplayChangedEventArgs {
  118016. /** Gets the vrDisplay object (if any) */
  118017. vrDisplay: Nullable<any>;
  118018. /** Gets a boolean indicating if webVR is supported */
  118019. vrSupported: boolean;
  118020. }
  118021. /**
  118022. * Defines the interface used by objects containing a viewport (like a camera)
  118023. */
  118024. interface IViewportOwnerLike {
  118025. /**
  118026. * Gets or sets the viewport
  118027. */
  118028. viewport: IViewportLike;
  118029. }
  118030. /**
  118031. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  118032. */
  118033. export class Engine extends ThinEngine {
  118034. /** Defines that alpha blending is disabled */
  118035. static readonly ALPHA_DISABLE: number;
  118036. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  118037. static readonly ALPHA_ADD: number;
  118038. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  118039. static readonly ALPHA_COMBINE: number;
  118040. /** Defines that alpha blending to DEST - SRC * DEST */
  118041. static readonly ALPHA_SUBTRACT: number;
  118042. /** Defines that alpha blending to SRC * DEST */
  118043. static readonly ALPHA_MULTIPLY: number;
  118044. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  118045. static readonly ALPHA_MAXIMIZED: number;
  118046. /** Defines that alpha blending to SRC + DEST */
  118047. static readonly ALPHA_ONEONE: number;
  118048. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  118049. static readonly ALPHA_PREMULTIPLIED: number;
  118050. /**
  118051. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  118052. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  118053. */
  118054. static readonly ALPHA_PREMULTIPLIED_PORTERDUFF: number;
  118055. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  118056. static readonly ALPHA_INTERPOLATE: number;
  118057. /**
  118058. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  118059. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  118060. */
  118061. static readonly ALPHA_SCREENMODE: number;
  118062. /** Defines that the ressource is not delayed*/
  118063. static readonly DELAYLOADSTATE_NONE: number;
  118064. /** Defines that the ressource was successfully delay loaded */
  118065. static readonly DELAYLOADSTATE_LOADED: number;
  118066. /** Defines that the ressource is currently delay loading */
  118067. static readonly DELAYLOADSTATE_LOADING: number;
  118068. /** Defines that the ressource is delayed and has not started loading */
  118069. static readonly DELAYLOADSTATE_NOTLOADED: number;
  118070. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  118071. static readonly NEVER: number;
  118072. /** 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 */
  118073. static readonly ALWAYS: number;
  118074. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  118075. static readonly LESS: number;
  118076. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  118077. static readonly EQUAL: number;
  118078. /** 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 */
  118079. static readonly LEQUAL: number;
  118080. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  118081. static readonly GREATER: number;
  118082. /** 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 */
  118083. static readonly GEQUAL: number;
  118084. /** 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 */
  118085. static readonly NOTEQUAL: number;
  118086. /** Passed to stencilOperation to specify that stencil value must be kept */
  118087. static readonly KEEP: number;
  118088. /** Passed to stencilOperation to specify that stencil value must be replaced */
  118089. static readonly REPLACE: number;
  118090. /** Passed to stencilOperation to specify that stencil value must be incremented */
  118091. static readonly INCR: number;
  118092. /** Passed to stencilOperation to specify that stencil value must be decremented */
  118093. static readonly DECR: number;
  118094. /** Passed to stencilOperation to specify that stencil value must be inverted */
  118095. static readonly INVERT: number;
  118096. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  118097. static readonly INCR_WRAP: number;
  118098. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  118099. static readonly DECR_WRAP: number;
  118100. /** Texture is not repeating outside of 0..1 UVs */
  118101. static readonly TEXTURE_CLAMP_ADDRESSMODE: number;
  118102. /** Texture is repeating outside of 0..1 UVs */
  118103. static readonly TEXTURE_WRAP_ADDRESSMODE: number;
  118104. /** Texture is repeating and mirrored */
  118105. static readonly TEXTURE_MIRROR_ADDRESSMODE: number;
  118106. /** ALPHA */
  118107. static readonly TEXTUREFORMAT_ALPHA: number;
  118108. /** LUMINANCE */
  118109. static readonly TEXTUREFORMAT_LUMINANCE: number;
  118110. /** LUMINANCE_ALPHA */
  118111. static readonly TEXTUREFORMAT_LUMINANCE_ALPHA: number;
  118112. /** RGB */
  118113. static readonly TEXTUREFORMAT_RGB: number;
  118114. /** RGBA */
  118115. static readonly TEXTUREFORMAT_RGBA: number;
  118116. /** RED */
  118117. static readonly TEXTUREFORMAT_RED: number;
  118118. /** RED (2nd reference) */
  118119. static readonly TEXTUREFORMAT_R: number;
  118120. /** RG */
  118121. static readonly TEXTUREFORMAT_RG: number;
  118122. /** RED_INTEGER */
  118123. static readonly TEXTUREFORMAT_RED_INTEGER: number;
  118124. /** RED_INTEGER (2nd reference) */
  118125. static readonly TEXTUREFORMAT_R_INTEGER: number;
  118126. /** RG_INTEGER */
  118127. static readonly TEXTUREFORMAT_RG_INTEGER: number;
  118128. /** RGB_INTEGER */
  118129. static readonly TEXTUREFORMAT_RGB_INTEGER: number;
  118130. /** RGBA_INTEGER */
  118131. static readonly TEXTUREFORMAT_RGBA_INTEGER: number;
  118132. /** UNSIGNED_BYTE */
  118133. static readonly TEXTURETYPE_UNSIGNED_BYTE: number;
  118134. /** UNSIGNED_BYTE (2nd reference) */
  118135. static readonly TEXTURETYPE_UNSIGNED_INT: number;
  118136. /** FLOAT */
  118137. static readonly TEXTURETYPE_FLOAT: number;
  118138. /** HALF_FLOAT */
  118139. static readonly TEXTURETYPE_HALF_FLOAT: number;
  118140. /** BYTE */
  118141. static readonly TEXTURETYPE_BYTE: number;
  118142. /** SHORT */
  118143. static readonly TEXTURETYPE_SHORT: number;
  118144. /** UNSIGNED_SHORT */
  118145. static readonly TEXTURETYPE_UNSIGNED_SHORT: number;
  118146. /** INT */
  118147. static readonly TEXTURETYPE_INT: number;
  118148. /** UNSIGNED_INT */
  118149. static readonly TEXTURETYPE_UNSIGNED_INTEGER: number;
  118150. /** UNSIGNED_SHORT_4_4_4_4 */
  118151. static readonly TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4: number;
  118152. /** UNSIGNED_SHORT_5_5_5_1 */
  118153. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1: number;
  118154. /** UNSIGNED_SHORT_5_6_5 */
  118155. static readonly TEXTURETYPE_UNSIGNED_SHORT_5_6_5: number;
  118156. /** UNSIGNED_INT_2_10_10_10_REV */
  118157. static readonly TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV: number;
  118158. /** UNSIGNED_INT_24_8 */
  118159. static readonly TEXTURETYPE_UNSIGNED_INT_24_8: number;
  118160. /** UNSIGNED_INT_10F_11F_11F_REV */
  118161. static readonly TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV: number;
  118162. /** UNSIGNED_INT_5_9_9_9_REV */
  118163. static readonly TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV: number;
  118164. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  118165. static readonly TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  118166. /** nearest is mag = nearest and min = nearest and mip = linear */
  118167. static readonly TEXTURE_NEAREST_SAMPLINGMODE: number;
  118168. /** Bilinear is mag = linear and min = linear and mip = nearest */
  118169. static readonly TEXTURE_BILINEAR_SAMPLINGMODE: number;
  118170. /** Trilinear is mag = linear and min = linear and mip = linear */
  118171. static readonly TEXTURE_TRILINEAR_SAMPLINGMODE: number;
  118172. /** nearest is mag = nearest and min = nearest and mip = linear */
  118173. static readonly TEXTURE_NEAREST_NEAREST_MIPLINEAR: number;
  118174. /** Bilinear is mag = linear and min = linear and mip = nearest */
  118175. static readonly TEXTURE_LINEAR_LINEAR_MIPNEAREST: number;
  118176. /** Trilinear is mag = linear and min = linear and mip = linear */
  118177. static readonly TEXTURE_LINEAR_LINEAR_MIPLINEAR: number;
  118178. /** mag = nearest and min = nearest and mip = nearest */
  118179. static readonly TEXTURE_NEAREST_NEAREST_MIPNEAREST: number;
  118180. /** mag = nearest and min = linear and mip = nearest */
  118181. static readonly TEXTURE_NEAREST_LINEAR_MIPNEAREST: number;
  118182. /** mag = nearest and min = linear and mip = linear */
  118183. static readonly TEXTURE_NEAREST_LINEAR_MIPLINEAR: number;
  118184. /** mag = nearest and min = linear and mip = none */
  118185. static readonly TEXTURE_NEAREST_LINEAR: number;
  118186. /** mag = nearest and min = nearest and mip = none */
  118187. static readonly TEXTURE_NEAREST_NEAREST: number;
  118188. /** mag = linear and min = nearest and mip = nearest */
  118189. static readonly TEXTURE_LINEAR_NEAREST_MIPNEAREST: number;
  118190. /** mag = linear and min = nearest and mip = linear */
  118191. static readonly TEXTURE_LINEAR_NEAREST_MIPLINEAR: number;
  118192. /** mag = linear and min = linear and mip = none */
  118193. static readonly TEXTURE_LINEAR_LINEAR: number;
  118194. /** mag = linear and min = nearest and mip = none */
  118195. static readonly TEXTURE_LINEAR_NEAREST: number;
  118196. /** Explicit coordinates mode */
  118197. static readonly TEXTURE_EXPLICIT_MODE: number;
  118198. /** Spherical coordinates mode */
  118199. static readonly TEXTURE_SPHERICAL_MODE: number;
  118200. /** Planar coordinates mode */
  118201. static readonly TEXTURE_PLANAR_MODE: number;
  118202. /** Cubic coordinates mode */
  118203. static readonly TEXTURE_CUBIC_MODE: number;
  118204. /** Projection coordinates mode */
  118205. static readonly TEXTURE_PROJECTION_MODE: number;
  118206. /** Skybox coordinates mode */
  118207. static readonly TEXTURE_SKYBOX_MODE: number;
  118208. /** Inverse Cubic coordinates mode */
  118209. static readonly TEXTURE_INVCUBIC_MODE: number;
  118210. /** Equirectangular coordinates mode */
  118211. static readonly TEXTURE_EQUIRECTANGULAR_MODE: number;
  118212. /** Equirectangular Fixed coordinates mode */
  118213. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MODE: number;
  118214. /** Equirectangular Fixed Mirrored coordinates mode */
  118215. static readonly TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE: number;
  118216. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  118217. static readonly SCALEMODE_FLOOR: number;
  118218. /** Defines that texture rescaling will look for the nearest power of 2 size */
  118219. static readonly SCALEMODE_NEAREST: number;
  118220. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  118221. static readonly SCALEMODE_CEILING: number;
  118222. /**
  118223. * Returns the current npm package of the sdk
  118224. */
  118225. static get NpmPackage(): string;
  118226. /**
  118227. * Returns the current version of the framework
  118228. */
  118229. static get Version(): string;
  118230. /** Gets the list of created engines */
  118231. static get Instances(): Engine[];
  118232. /**
  118233. * Gets the latest created engine
  118234. */
  118235. static get LastCreatedEngine(): Nullable<Engine>;
  118236. /**
  118237. * Gets the latest created scene
  118238. */
  118239. static get LastCreatedScene(): Nullable<Scene>;
  118240. /**
  118241. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  118242. * @param flag defines which part of the materials must be marked as dirty
  118243. * @param predicate defines a predicate used to filter which materials should be affected
  118244. */
  118245. static MarkAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  118246. /**
  118247. * Method called to create the default loading screen.
  118248. * This can be overriden in your own app.
  118249. * @param canvas The rendering canvas element
  118250. * @returns The loading screen
  118251. */
  118252. static DefaultLoadingScreenFactory(canvas: HTMLCanvasElement): ILoadingScreen;
  118253. /**
  118254. * Method called to create the default rescale post process on each engine.
  118255. */
  118256. static _RescalePostProcessFactory: Nullable<(engine: Engine) => PostProcess>;
  118257. /**
  118258. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  118259. **/
  118260. enableOfflineSupport: boolean;
  118261. /**
  118262. * 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)
  118263. **/
  118264. disableManifestCheck: boolean;
  118265. /**
  118266. * Gets the list of created scenes
  118267. */
  118268. scenes: Scene[];
  118269. /**
  118270. * Event raised when a new scene is created
  118271. */
  118272. onNewSceneAddedObservable: Observable<Scene>;
  118273. /**
  118274. * Gets the list of created postprocesses
  118275. */
  118276. postProcesses: PostProcess[];
  118277. /**
  118278. * Gets a boolean indicating if the pointer is currently locked
  118279. */
  118280. isPointerLock: boolean;
  118281. /**
  118282. * Observable event triggered each time the rendering canvas is resized
  118283. */
  118284. onResizeObservable: Observable<Engine>;
  118285. /**
  118286. * Observable event triggered each time the canvas loses focus
  118287. */
  118288. onCanvasBlurObservable: Observable<Engine>;
  118289. /**
  118290. * Observable event triggered each time the canvas gains focus
  118291. */
  118292. onCanvasFocusObservable: Observable<Engine>;
  118293. /**
  118294. * Observable event triggered each time the canvas receives pointerout event
  118295. */
  118296. onCanvasPointerOutObservable: Observable<PointerEvent>;
  118297. /**
  118298. * Observable raised when the engine begins a new frame
  118299. */
  118300. onBeginFrameObservable: Observable<Engine>;
  118301. /**
  118302. * If set, will be used to request the next animation frame for the render loop
  118303. */
  118304. customAnimationFrameRequester: Nullable<ICustomAnimationFrameRequester>;
  118305. /**
  118306. * Observable raised when the engine ends the current frame
  118307. */
  118308. onEndFrameObservable: Observable<Engine>;
  118309. /**
  118310. * Observable raised when the engine is about to compile a shader
  118311. */
  118312. onBeforeShaderCompilationObservable: Observable<Engine>;
  118313. /**
  118314. * Observable raised when the engine has jsut compiled a shader
  118315. */
  118316. onAfterShaderCompilationObservable: Observable<Engine>;
  118317. /**
  118318. * Gets the audio engine
  118319. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  118320. * @ignorenaming
  118321. */
  118322. static audioEngine: IAudioEngine;
  118323. /**
  118324. * Default AudioEngine factory responsible of creating the Audio Engine.
  118325. * By default, this will create a BabylonJS Audio Engine if the workload has been embedded.
  118326. */
  118327. static AudioEngineFactory: (hostElement: Nullable<HTMLElement>) => IAudioEngine;
  118328. /**
  118329. * Default offline support factory responsible of creating a tool used to store data locally.
  118330. * By default, this will create a Database object if the workload has been embedded.
  118331. */
  118332. static OfflineProviderFactory: (urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck: boolean) => IOfflineProvider;
  118333. private _loadingScreen;
  118334. private _pointerLockRequested;
  118335. private _rescalePostProcess;
  118336. private _deterministicLockstep;
  118337. private _lockstepMaxSteps;
  118338. private _timeStep;
  118339. protected get _supportsHardwareTextureRescaling(): boolean;
  118340. private _fps;
  118341. private _deltaTime;
  118342. /** @hidden */
  118343. _drawCalls: PerfCounter;
  118344. /** 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 */
  118345. canvasTabIndex: number;
  118346. /**
  118347. * Turn this value on if you want to pause FPS computation when in background
  118348. */
  118349. disablePerformanceMonitorInBackground: boolean;
  118350. private _performanceMonitor;
  118351. /**
  118352. * Gets the performance monitor attached to this engine
  118353. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  118354. */
  118355. get performanceMonitor(): PerformanceMonitor;
  118356. private _onFocus;
  118357. private _onBlur;
  118358. private _onCanvasPointerOut;
  118359. private _onCanvasBlur;
  118360. private _onCanvasFocus;
  118361. private _onFullscreenChange;
  118362. private _onPointerLockChange;
  118363. /**
  118364. * Gets the HTML element used to attach event listeners
  118365. * @returns a HTML element
  118366. */
  118367. getInputElement(): Nullable<HTMLElement>;
  118368. /**
  118369. * Creates a new engine
  118370. * @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
  118371. * @param antialias defines enable antialiasing (default: false)
  118372. * @param options defines further options to be sent to the getContext() function
  118373. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  118374. */
  118375. constructor(canvasOrContext: Nullable<HTMLCanvasElement | WebGLRenderingContext>, antialias?: boolean, options?: EngineOptions, adaptToDeviceRatio?: boolean);
  118376. /**
  118377. * Gets current aspect ratio
  118378. * @param viewportOwner defines the camera to use to get the aspect ratio
  118379. * @param useScreen defines if screen size must be used (or the current render target if any)
  118380. * @returns a number defining the aspect ratio
  118381. */
  118382. getAspectRatio(viewportOwner: IViewportOwnerLike, useScreen?: boolean): number;
  118383. /**
  118384. * Gets current screen aspect ratio
  118385. * @returns a number defining the aspect ratio
  118386. */
  118387. getScreenAspectRatio(): number;
  118388. /**
  118389. * Gets the client rect of the HTML canvas attached with the current webGL context
  118390. * @returns a client rectanglee
  118391. */
  118392. getRenderingCanvasClientRect(): Nullable<ClientRect>;
  118393. /**
  118394. * Gets the client rect of the HTML element used for events
  118395. * @returns a client rectanglee
  118396. */
  118397. getInputElementClientRect(): Nullable<ClientRect>;
  118398. /**
  118399. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  118400. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118401. * @returns true if engine is in deterministic lock step mode
  118402. */
  118403. isDeterministicLockStep(): boolean;
  118404. /**
  118405. * Gets the max steps when engine is running in deterministic lock step
  118406. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  118407. * @returns the max steps
  118408. */
  118409. getLockstepMaxSteps(): number;
  118410. /**
  118411. * Returns the time in ms between steps when using deterministic lock step.
  118412. * @returns time step in (ms)
  118413. */
  118414. getTimeStep(): number;
  118415. /**
  118416. * Force the mipmap generation for the given render target texture
  118417. * @param texture defines the render target texture to use
  118418. * @param unbind defines whether or not to unbind the texture after generation. Defaults to true.
  118419. */
  118420. generateMipMapsForCubemap(texture: InternalTexture, unbind?: boolean): void;
  118421. /** States */
  118422. /**
  118423. * Set various states to the webGL context
  118424. * @param culling defines backface culling state
  118425. * @param zOffset defines the value to apply to zOffset (0 by default)
  118426. * @param force defines if states must be applied even if cache is up to date
  118427. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  118428. */
  118429. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  118430. /**
  118431. * Set the z offset to apply to current rendering
  118432. * @param value defines the offset to apply
  118433. */
  118434. setZOffset(value: number): void;
  118435. /**
  118436. * Gets the current value of the zOffset
  118437. * @returns the current zOffset state
  118438. */
  118439. getZOffset(): number;
  118440. /**
  118441. * Enable or disable depth buffering
  118442. * @param enable defines the state to set
  118443. */
  118444. setDepthBuffer(enable: boolean): void;
  118445. /**
  118446. * Gets a boolean indicating if depth writing is enabled
  118447. * @returns the current depth writing state
  118448. */
  118449. getDepthWrite(): boolean;
  118450. /**
  118451. * Enable or disable depth writing
  118452. * @param enable defines the state to set
  118453. */
  118454. setDepthWrite(enable: boolean): void;
  118455. /**
  118456. * Gets a boolean indicating if stencil buffer is enabled
  118457. * @returns the current stencil buffer state
  118458. */
  118459. getStencilBuffer(): boolean;
  118460. /**
  118461. * Enable or disable the stencil buffer
  118462. * @param enable defines if the stencil buffer must be enabled or disabled
  118463. */
  118464. setStencilBuffer(enable: boolean): void;
  118465. /**
  118466. * Gets the current stencil mask
  118467. * @returns a number defining the new stencil mask to use
  118468. */
  118469. getStencilMask(): number;
  118470. /**
  118471. * Sets the current stencil mask
  118472. * @param mask defines the new stencil mask to use
  118473. */
  118474. setStencilMask(mask: number): void;
  118475. /**
  118476. * Gets the current stencil function
  118477. * @returns a number defining the stencil function to use
  118478. */
  118479. getStencilFunction(): number;
  118480. /**
  118481. * Gets the current stencil reference value
  118482. * @returns a number defining the stencil reference value to use
  118483. */
  118484. getStencilFunctionReference(): number;
  118485. /**
  118486. * Gets the current stencil mask
  118487. * @returns a number defining the stencil mask to use
  118488. */
  118489. getStencilFunctionMask(): number;
  118490. /**
  118491. * Sets the current stencil function
  118492. * @param stencilFunc defines the new stencil function to use
  118493. */
  118494. setStencilFunction(stencilFunc: number): void;
  118495. /**
  118496. * Sets the current stencil reference
  118497. * @param reference defines the new stencil reference to use
  118498. */
  118499. setStencilFunctionReference(reference: number): void;
  118500. /**
  118501. * Sets the current stencil mask
  118502. * @param mask defines the new stencil mask to use
  118503. */
  118504. setStencilFunctionMask(mask: number): void;
  118505. /**
  118506. * Gets the current stencil operation when stencil fails
  118507. * @returns a number defining stencil operation to use when stencil fails
  118508. */
  118509. getStencilOperationFail(): number;
  118510. /**
  118511. * Gets the current stencil operation when depth fails
  118512. * @returns a number defining stencil operation to use when depth fails
  118513. */
  118514. getStencilOperationDepthFail(): number;
  118515. /**
  118516. * Gets the current stencil operation when stencil passes
  118517. * @returns a number defining stencil operation to use when stencil passes
  118518. */
  118519. getStencilOperationPass(): number;
  118520. /**
  118521. * Sets the stencil operation to use when stencil fails
  118522. * @param operation defines the stencil operation to use when stencil fails
  118523. */
  118524. setStencilOperationFail(operation: number): void;
  118525. /**
  118526. * Sets the stencil operation to use when depth fails
  118527. * @param operation defines the stencil operation to use when depth fails
  118528. */
  118529. setStencilOperationDepthFail(operation: number): void;
  118530. /**
  118531. * Sets the stencil operation to use when stencil passes
  118532. * @param operation defines the stencil operation to use when stencil passes
  118533. */
  118534. setStencilOperationPass(operation: number): void;
  118535. /**
  118536. * Sets a boolean indicating if the dithering state is enabled or disabled
  118537. * @param value defines the dithering state
  118538. */
  118539. setDitheringState(value: boolean): void;
  118540. /**
  118541. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  118542. * @param value defines the rasterizer state
  118543. */
  118544. setRasterizerState(value: boolean): void;
  118545. /**
  118546. * Gets the current depth function
  118547. * @returns a number defining the depth function
  118548. */
  118549. getDepthFunction(): Nullable<number>;
  118550. /**
  118551. * Sets the current depth function
  118552. * @param depthFunc defines the function to use
  118553. */
  118554. setDepthFunction(depthFunc: number): void;
  118555. /**
  118556. * Sets the current depth function to GREATER
  118557. */
  118558. setDepthFunctionToGreater(): void;
  118559. /**
  118560. * Sets the current depth function to GEQUAL
  118561. */
  118562. setDepthFunctionToGreaterOrEqual(): void;
  118563. /**
  118564. * Sets the current depth function to LESS
  118565. */
  118566. setDepthFunctionToLess(): void;
  118567. /**
  118568. * Sets the current depth function to LEQUAL
  118569. */
  118570. setDepthFunctionToLessOrEqual(): void;
  118571. private _cachedStencilBuffer;
  118572. private _cachedStencilFunction;
  118573. private _cachedStencilMask;
  118574. private _cachedStencilOperationPass;
  118575. private _cachedStencilOperationFail;
  118576. private _cachedStencilOperationDepthFail;
  118577. private _cachedStencilReference;
  118578. /**
  118579. * Caches the the state of the stencil buffer
  118580. */
  118581. cacheStencilState(): void;
  118582. /**
  118583. * Restores the state of the stencil buffer
  118584. */
  118585. restoreStencilState(): void;
  118586. /**
  118587. * Directly set the WebGL Viewport
  118588. * @param x defines the x coordinate of the viewport (in screen space)
  118589. * @param y defines the y coordinate of the viewport (in screen space)
  118590. * @param width defines the width of the viewport (in screen space)
  118591. * @param height defines the height of the viewport (in screen space)
  118592. * @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
  118593. */
  118594. setDirectViewport(x: number, y: number, width: number, height: number): Nullable<IViewportLike>;
  118595. /**
  118596. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  118597. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118598. * @param y defines the y-coordinate of the corner of the clear rectangle
  118599. * @param width defines the width of the clear rectangle
  118600. * @param height defines the height of the clear rectangle
  118601. * @param clearColor defines the clear color
  118602. */
  118603. scissorClear(x: number, y: number, width: number, height: number, clearColor: IColor4Like): void;
  118604. /**
  118605. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  118606. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  118607. * @param y defines the y-coordinate of the corner of the clear rectangle
  118608. * @param width defines the width of the clear rectangle
  118609. * @param height defines the height of the clear rectangle
  118610. */
  118611. enableScissor(x: number, y: number, width: number, height: number): void;
  118612. /**
  118613. * Disable previously set scissor test rectangle
  118614. */
  118615. disableScissor(): void;
  118616. protected _reportDrawCall(): void;
  118617. /**
  118618. * Initializes a webVR display and starts listening to display change events
  118619. * The onVRDisplayChangedObservable will be notified upon these changes
  118620. * @returns The onVRDisplayChangedObservable
  118621. */
  118622. initWebVR(): Observable<IDisplayChangedEventArgs>;
  118623. /** @hidden */
  118624. _prepareVRComponent(): void;
  118625. /** @hidden */
  118626. _connectVREvents(canvas?: HTMLCanvasElement, document?: any): void;
  118627. /** @hidden */
  118628. _submitVRFrame(): void;
  118629. /**
  118630. * Call this function to leave webVR mode
  118631. * Will do nothing if webVR is not supported or if there is no webVR device
  118632. * @see https://doc.babylonjs.com/how_to/webvr_camera
  118633. */
  118634. disableVR(): void;
  118635. /**
  118636. * Gets a boolean indicating that the system is in VR mode and is presenting
  118637. * @returns true if VR mode is engaged
  118638. */
  118639. isVRPresenting(): boolean;
  118640. /** @hidden */
  118641. _requestVRFrame(): void;
  118642. /** @hidden */
  118643. _loadFileAsync(url: string, offlineProvider?: IOfflineProvider, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  118644. /**
  118645. * Gets the source code of the vertex shader associated with a specific webGL program
  118646. * @param program defines the program to use
  118647. * @returns a string containing the source code of the vertex shader associated with the program
  118648. */
  118649. getVertexShaderSource(program: WebGLProgram): Nullable<string>;
  118650. /**
  118651. * Gets the source code of the fragment shader associated with a specific webGL program
  118652. * @param program defines the program to use
  118653. * @returns a string containing the source code of the fragment shader associated with the program
  118654. */
  118655. getFragmentShaderSource(program: WebGLProgram): Nullable<string>;
  118656. /**
  118657. * Sets a depth stencil texture from a render target to the according uniform.
  118658. * @param channel The texture channel
  118659. * @param uniform The uniform to set
  118660. * @param texture The render target texture containing the depth stencil texture to apply
  118661. */
  118662. setDepthStencilTexture(channel: number, uniform: Nullable<WebGLUniformLocation>, texture: Nullable<RenderTargetTexture>): void;
  118663. /**
  118664. * Sets a texture to the webGL context from a postprocess
  118665. * @param channel defines the channel to use
  118666. * @param postProcess defines the source postprocess
  118667. */
  118668. setTextureFromPostProcess(channel: number, postProcess: Nullable<PostProcess>): void;
  118669. /**
  118670. * Binds the output of the passed in post process to the texture channel specified
  118671. * @param channel The channel the texture should be bound to
  118672. * @param postProcess The post process which's output should be bound
  118673. */
  118674. setTextureFromPostProcessOutput(channel: number, postProcess: Nullable<PostProcess>): void;
  118675. protected _rebuildBuffers(): void;
  118676. /** @hidden */
  118677. _renderFrame(): void;
  118678. _renderLoop(): void;
  118679. /** @hidden */
  118680. _renderViews(): boolean;
  118681. /**
  118682. * Toggle full screen mode
  118683. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118684. */
  118685. switchFullscreen(requestPointerLock: boolean): void;
  118686. /**
  118687. * Enters full screen mode
  118688. * @param requestPointerLock defines if a pointer lock should be requested from the user
  118689. */
  118690. enterFullscreen(requestPointerLock: boolean): void;
  118691. /**
  118692. * Exits full screen mode
  118693. */
  118694. exitFullscreen(): void;
  118695. /**
  118696. * Enters Pointerlock mode
  118697. */
  118698. enterPointerlock(): void;
  118699. /**
  118700. * Exits Pointerlock mode
  118701. */
  118702. exitPointerlock(): void;
  118703. /**
  118704. * Begin a new frame
  118705. */
  118706. beginFrame(): void;
  118707. /**
  118708. * Enf the current frame
  118709. */
  118710. endFrame(): void;
  118711. resize(): void;
  118712. /**
  118713. * Force a specific size of the canvas
  118714. * @param width defines the new canvas' width
  118715. * @param height defines the new canvas' height
  118716. * @returns true if the size was changed
  118717. */
  118718. setSize(width: number, height: number): boolean;
  118719. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  118720. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118721. protected _createShaderProgram(pipelineContext: WebGLPipelineContext, vertexShader: WebGLShader, fragmentShader: WebGLShader, context: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): WebGLProgram;
  118722. _releaseTexture(texture: InternalTexture): void;
  118723. /**
  118724. * @hidden
  118725. * Rescales a texture
  118726. * @param source input texutre
  118727. * @param destination destination texture
  118728. * @param scene scene to use to render the resize
  118729. * @param internalFormat format to use when resizing
  118730. * @param onComplete callback to be called when resize has completed
  118731. */
  118732. _rescaleTexture(source: InternalTexture, destination: InternalTexture, scene: Nullable<any>, internalFormat: number, onComplete: () => void): void;
  118733. /**
  118734. * Gets the current framerate
  118735. * @returns a number representing the framerate
  118736. */
  118737. getFps(): number;
  118738. /**
  118739. * Gets the time spent between current and previous frame
  118740. * @returns a number representing the delta time in ms
  118741. */
  118742. getDeltaTime(): number;
  118743. private _measureFps;
  118744. /** @hidden */
  118745. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement | ImageBitmap, faceIndex?: number, lod?: number): void;
  118746. /**
  118747. * Updates the sample count of a render target texture
  118748. * @see https://doc.babylonjs.com/features/webgl2#multisample-render-targets
  118749. * @param texture defines the texture to update
  118750. * @param samples defines the sample count to set
  118751. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  118752. */
  118753. updateRenderTargetTextureSampleCount(texture: Nullable<InternalTexture>, samples: number): number;
  118754. /**
  118755. * Updates a depth texture Comparison Mode and Function.
  118756. * If the comparison Function is equal to 0, the mode will be set to none.
  118757. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  118758. * @param texture The texture to set the comparison function for
  118759. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  118760. */
  118761. updateTextureComparisonFunction(texture: InternalTexture, comparisonFunction: number): void;
  118762. /**
  118763. * Creates a webGL buffer to use with instanciation
  118764. * @param capacity defines the size of the buffer
  118765. * @returns the webGL buffer
  118766. */
  118767. createInstancesBuffer(capacity: number): DataBuffer;
  118768. /**
  118769. * Delete a webGL buffer used with instanciation
  118770. * @param buffer defines the webGL buffer to delete
  118771. */
  118772. deleteInstancesBuffer(buffer: WebGLBuffer): void;
  118773. private _clientWaitAsync;
  118774. /** @hidden */
  118775. _readPixelsAsync(x: number, y: number, w: number, h: number, format: number, type: number, outputBuffer: ArrayBufferView): Promise<ArrayBufferView> | null;
  118776. dispose(): void;
  118777. private _disableTouchAction;
  118778. /**
  118779. * Display the loading screen
  118780. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118781. */
  118782. displayLoadingUI(): void;
  118783. /**
  118784. * Hide the loading screen
  118785. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118786. */
  118787. hideLoadingUI(): void;
  118788. /**
  118789. * Gets the current loading screen object
  118790. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118791. */
  118792. get loadingScreen(): ILoadingScreen;
  118793. /**
  118794. * Sets the current loading screen object
  118795. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118796. */
  118797. set loadingScreen(loadingScreen: ILoadingScreen);
  118798. /**
  118799. * Sets the current loading screen text
  118800. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118801. */
  118802. set loadingUIText(text: string);
  118803. /**
  118804. * Sets the current loading screen background color
  118805. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  118806. */
  118807. set loadingUIBackgroundColor(color: string);
  118808. /** Pointerlock and fullscreen */
  118809. /**
  118810. * Ask the browser to promote the current element to pointerlock mode
  118811. * @param element defines the DOM element to promote
  118812. */
  118813. static _RequestPointerlock(element: HTMLElement): void;
  118814. /**
  118815. * Asks the browser to exit pointerlock mode
  118816. */
  118817. static _ExitPointerlock(): void;
  118818. /**
  118819. * Ask the browser to promote the current element to fullscreen rendering mode
  118820. * @param element defines the DOM element to promote
  118821. */
  118822. static _RequestFullscreen(element: HTMLElement): void;
  118823. /**
  118824. * Asks the browser to exit fullscreen mode
  118825. */
  118826. static _ExitFullscreen(): void;
  118827. }
  118828. }
  118829. declare module BABYLON {
  118830. /**
  118831. * The engine store class is responsible to hold all the instances of Engine and Scene created
  118832. * during the life time of the application.
  118833. */
  118834. export class EngineStore {
  118835. /** Gets the list of created engines */
  118836. static Instances: Engine[];
  118837. /** @hidden */
  118838. static _LastCreatedScene: Nullable<Scene>;
  118839. /**
  118840. * Gets the latest created engine
  118841. */
  118842. static get LastCreatedEngine(): Nullable<Engine>;
  118843. /**
  118844. * Gets the latest created scene
  118845. */
  118846. static get LastCreatedScene(): Nullable<Scene>;
  118847. /**
  118848. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118849. * @ignorenaming
  118850. */
  118851. static UseFallbackTexture: boolean;
  118852. /**
  118853. * Texture content used if a texture cannot loaded
  118854. * @ignorenaming
  118855. */
  118856. static FallbackTexture: string;
  118857. }
  118858. }
  118859. declare module BABYLON {
  118860. /**
  118861. * Helper class that provides a small promise polyfill
  118862. */
  118863. export class PromisePolyfill {
  118864. /**
  118865. * Static function used to check if the polyfill is required
  118866. * If this is the case then the function will inject the polyfill to window.Promise
  118867. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  118868. */
  118869. static Apply(force?: boolean): void;
  118870. }
  118871. }
  118872. declare module BABYLON {
  118873. /**
  118874. * Interface for screenshot methods with describe argument called `size` as object with options
  118875. * @link https://doc.babylonjs.com/api/classes/babylon.screenshottools
  118876. */
  118877. export interface IScreenshotSize {
  118878. /**
  118879. * number in pixels for canvas height
  118880. */
  118881. height?: number;
  118882. /**
  118883. * multiplier allowing render at a higher or lower resolution
  118884. * If value is defined then height and width will be ignored and taken from camera
  118885. */
  118886. precision?: number;
  118887. /**
  118888. * number in pixels for canvas width
  118889. */
  118890. width?: number;
  118891. }
  118892. }
  118893. declare module BABYLON {
  118894. interface IColor4Like {
  118895. r: float;
  118896. g: float;
  118897. b: float;
  118898. a: float;
  118899. }
  118900. /**
  118901. * Class containing a set of static utilities functions
  118902. */
  118903. export class Tools {
  118904. /**
  118905. * Gets or sets the base URL to use to load assets
  118906. */
  118907. static get BaseUrl(): string;
  118908. static set BaseUrl(value: string);
  118909. /**
  118910. * Enable/Disable Custom HTTP Request Headers globally.
  118911. * default = false
  118912. * @see CustomRequestHeaders
  118913. */
  118914. static UseCustomRequestHeaders: boolean;
  118915. /**
  118916. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  118917. * i.e. when loading files, where the server/service expects an Authorization header
  118918. */
  118919. static CustomRequestHeaders: {
  118920. [key: string]: string;
  118921. };
  118922. /**
  118923. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  118924. */
  118925. static get DefaultRetryStrategy(): (url: string, request: WebRequest, retryIndex: number) => number;
  118926. static set DefaultRetryStrategy(strategy: (url: string, request: WebRequest, retryIndex: number) => number);
  118927. /**
  118928. * Default behaviour for cors in the application.
  118929. * It can be a string if the expected behavior is identical in the entire app.
  118930. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  118931. */
  118932. static get CorsBehavior(): string | ((url: string | string[]) => string);
  118933. static set CorsBehavior(value: string | ((url: string | string[]) => string));
  118934. /**
  118935. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  118936. * @ignorenaming
  118937. */
  118938. static get UseFallbackTexture(): boolean;
  118939. static set UseFallbackTexture(value: boolean);
  118940. /**
  118941. * Use this object to register external classes like custom textures or material
  118942. * to allow the laoders to instantiate them
  118943. */
  118944. static get RegisteredExternalClasses(): {
  118945. [key: string]: Object;
  118946. };
  118947. static set RegisteredExternalClasses(classes: {
  118948. [key: string]: Object;
  118949. });
  118950. /**
  118951. * Texture content used if a texture cannot loaded
  118952. * @ignorenaming
  118953. */
  118954. static get fallbackTexture(): string;
  118955. static set fallbackTexture(value: string);
  118956. /**
  118957. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  118958. * @param u defines the coordinate on X axis
  118959. * @param v defines the coordinate on Y axis
  118960. * @param width defines the width of the source data
  118961. * @param height defines the height of the source data
  118962. * @param pixels defines the source byte array
  118963. * @param color defines the output color
  118964. */
  118965. static FetchToRef(u: number, v: number, width: number, height: number, pixels: Uint8Array, color: IColor4Like): void;
  118966. /**
  118967. * Interpolates between a and b via alpha
  118968. * @param a The lower value (returned when alpha = 0)
  118969. * @param b The upper value (returned when alpha = 1)
  118970. * @param alpha The interpolation-factor
  118971. * @return The mixed value
  118972. */
  118973. static Mix(a: number, b: number, alpha: number): number;
  118974. /**
  118975. * Tries to instantiate a new object from a given class name
  118976. * @param className defines the class name to instantiate
  118977. * @returns the new object or null if the system was not able to do the instantiation
  118978. */
  118979. static Instantiate(className: string): any;
  118980. /**
  118981. * Provides a slice function that will work even on IE
  118982. * @param data defines the array to slice
  118983. * @param start defines the start of the data (optional)
  118984. * @param end defines the end of the data (optional)
  118985. * @returns the new sliced array
  118986. */
  118987. static Slice<T>(data: T, start?: number, end?: number): T;
  118988. /**
  118989. * Polyfill for setImmediate
  118990. * @param action defines the action to execute after the current execution block
  118991. */
  118992. static SetImmediate(action: () => void): void;
  118993. /**
  118994. * Function indicating if a number is an exponent of 2
  118995. * @param value defines the value to test
  118996. * @returns true if the value is an exponent of 2
  118997. */
  118998. static IsExponentOfTwo(value: number): boolean;
  118999. private static _tmpFloatArray;
  119000. /**
  119001. * Returns the nearest 32-bit single precision float representation of a Number
  119002. * @param value A Number. If the parameter is of a different type, it will get converted
  119003. * to a number or to NaN if it cannot be converted
  119004. * @returns number
  119005. */
  119006. static FloatRound(value: number): number;
  119007. /**
  119008. * Extracts the filename from a path
  119009. * @param path defines the path to use
  119010. * @returns the filename
  119011. */
  119012. static GetFilename(path: string): string;
  119013. /**
  119014. * Extracts the "folder" part of a path (everything before the filename).
  119015. * @param uri The URI to extract the info from
  119016. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  119017. * @returns The "folder" part of the path
  119018. */
  119019. static GetFolderPath(uri: string, returnUnchangedIfNoSlash?: boolean): string;
  119020. /**
  119021. * Extracts text content from a DOM element hierarchy
  119022. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  119023. */
  119024. static GetDOMTextContent: typeof DomManagement.GetDOMTextContent;
  119025. /**
  119026. * Convert an angle in radians to degrees
  119027. * @param angle defines the angle to convert
  119028. * @returns the angle in degrees
  119029. */
  119030. static ToDegrees(angle: number): number;
  119031. /**
  119032. * Convert an angle in degrees to radians
  119033. * @param angle defines the angle to convert
  119034. * @returns the angle in radians
  119035. */
  119036. static ToRadians(angle: number): number;
  119037. /**
  119038. * Returns an array if obj is not an array
  119039. * @param obj defines the object to evaluate as an array
  119040. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  119041. * @returns either obj directly if obj is an array or a new array containing obj
  119042. */
  119043. static MakeArray(obj: any, allowsNullUndefined?: boolean): Nullable<Array<any>>;
  119044. /**
  119045. * Gets the pointer prefix to use
  119046. * @param engine defines the engine we are finding the prefix for
  119047. * @returns "pointer" if touch is enabled. Else returns "mouse"
  119048. */
  119049. static GetPointerPrefix(engine: Engine): string;
  119050. /**
  119051. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  119052. * @param url define the url we are trying
  119053. * @param element define the dom element where to configure the cors policy
  119054. */
  119055. static SetCorsBehavior(url: string | string[], element: {
  119056. crossOrigin: string | null;
  119057. }): void;
  119058. /**
  119059. * Removes unwanted characters from an url
  119060. * @param url defines the url to clean
  119061. * @returns the cleaned url
  119062. */
  119063. static CleanUrl(url: string): string;
  119064. /**
  119065. * Gets or sets a function used to pre-process url before using them to load assets
  119066. */
  119067. static get PreprocessUrl(): (url: string) => string;
  119068. static set PreprocessUrl(processor: (url: string) => string);
  119069. /**
  119070. * Loads an image as an HTMLImageElement.
  119071. * @param input url string, ArrayBuffer, or Blob to load
  119072. * @param onLoad callback called when the image successfully loads
  119073. * @param onError callback called when the image fails to load
  119074. * @param offlineProvider offline provider for caching
  119075. * @param mimeType optional mime type
  119076. * @returns the HTMLImageElement of the loaded image
  119077. */
  119078. static LoadImage(input: string | ArrayBuffer | Blob, onLoad: (img: HTMLImageElement | ImageBitmap) => void, onError: (message?: string, exception?: any) => void, offlineProvider: Nullable<IOfflineProvider>, mimeType?: string): Nullable<HTMLImageElement>;
  119079. /**
  119080. * Loads a file from a url
  119081. * @param url url string, ArrayBuffer, or Blob to load
  119082. * @param onSuccess callback called when the file successfully loads
  119083. * @param onProgress callback called while file is loading (if the server supports this mode)
  119084. * @param offlineProvider defines the offline provider for caching
  119085. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119086. * @param onError callback called when the file fails to load
  119087. * @returns a file request object
  119088. */
  119089. 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;
  119090. /**
  119091. * Loads a file from a url
  119092. * @param url the file url to load
  119093. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  119094. * @returns a promise containing an ArrayBuffer corresponding to the loaded file
  119095. */
  119096. static LoadFileAsync(url: string, useArrayBuffer?: boolean): Promise<ArrayBuffer | string>;
  119097. /**
  119098. * Load a script (identified by an url). When the url returns, the
  119099. * content of this file is added into a new script element, attached to the DOM (body element)
  119100. * @param scriptUrl defines the url of the script to laod
  119101. * @param onSuccess defines the callback called when the script is loaded
  119102. * @param onError defines the callback to call if an error occurs
  119103. * @param scriptId defines the id of the script element
  119104. */
  119105. static LoadScript(scriptUrl: string, onSuccess: () => void, onError?: (message?: string, exception?: any) => void, scriptId?: string): void;
  119106. /**
  119107. * Load an asynchronous script (identified by an url). When the url returns, the
  119108. * content of this file is added into a new script element, attached to the DOM (body element)
  119109. * @param scriptUrl defines the url of the script to laod
  119110. * @param scriptId defines the id of the script element
  119111. * @returns a promise request object
  119112. */
  119113. static LoadScriptAsync(scriptUrl: string, scriptId?: string): Promise<void>;
  119114. /**
  119115. * Loads a file from a blob
  119116. * @param fileToLoad defines the blob to use
  119117. * @param callback defines the callback to call when data is loaded
  119118. * @param progressCallback defines the callback to call during loading process
  119119. * @returns a file request object
  119120. */
  119121. static ReadFileAsDataURL(fileToLoad: Blob, callback: (data: any) => void, progressCallback: (ev: ProgressEvent) => any): IFileRequest;
  119122. /**
  119123. * Reads a file from a File object
  119124. * @param file defines the file to load
  119125. * @param onSuccess defines the callback to call when data is loaded
  119126. * @param onProgress defines the callback to call during loading process
  119127. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  119128. * @param onError defines the callback to call when an error occurs
  119129. * @returns a file request object
  119130. */
  119131. static ReadFile(file: File, onSuccess: (data: any) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  119132. /**
  119133. * Creates a data url from a given string content
  119134. * @param content defines the content to convert
  119135. * @returns the new data url link
  119136. */
  119137. static FileAsURL(content: string): string;
  119138. /**
  119139. * Format the given number to a specific decimal format
  119140. * @param value defines the number to format
  119141. * @param decimals defines the number of decimals to use
  119142. * @returns the formatted string
  119143. */
  119144. static Format(value: number, decimals?: number): string;
  119145. /**
  119146. * Tries to copy an object by duplicating every property
  119147. * @param source defines the source object
  119148. * @param destination defines the target object
  119149. * @param doNotCopyList defines a list of properties to avoid
  119150. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  119151. */
  119152. static DeepCopy(source: any, destination: any, doNotCopyList?: string[], mustCopyList?: string[]): void;
  119153. /**
  119154. * Gets a boolean indicating if the given object has no own property
  119155. * @param obj defines the object to test
  119156. * @returns true if object has no own property
  119157. */
  119158. static IsEmpty(obj: any): boolean;
  119159. /**
  119160. * Function used to register events at window level
  119161. * @param windowElement defines the Window object to use
  119162. * @param events defines the events to register
  119163. */
  119164. static RegisterTopRootEvents(windowElement: Window, events: {
  119165. name: string;
  119166. handler: Nullable<(e: FocusEvent) => any>;
  119167. }[]): void;
  119168. /**
  119169. * Function used to unregister events from window level
  119170. * @param windowElement defines the Window object to use
  119171. * @param events defines the events to unregister
  119172. */
  119173. static UnregisterTopRootEvents(windowElement: Window, events: {
  119174. name: string;
  119175. handler: Nullable<(e: FocusEvent) => any>;
  119176. }[]): void;
  119177. /**
  119178. * @ignore
  119179. */
  119180. static _ScreenshotCanvas: HTMLCanvasElement;
  119181. /**
  119182. * Dumps the current bound framebuffer
  119183. * @param width defines the rendering width
  119184. * @param height defines the rendering height
  119185. * @param engine defines the hosting engine
  119186. * @param successCallback defines the callback triggered once the data are available
  119187. * @param mimeType defines the mime type of the result
  119188. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  119189. */
  119190. static DumpFramebuffer(width: number, height: number, engine: Engine, successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  119191. /**
  119192. * Converts the canvas data to blob.
  119193. * This acts as a polyfill for browsers not supporting the to blob function.
  119194. * @param canvas Defines the canvas to extract the data from
  119195. * @param successCallback Defines the callback triggered once the data are available
  119196. * @param mimeType Defines the mime type of the result
  119197. */
  119198. static ToBlob(canvas: HTMLCanvasElement, successCallback: (blob: Nullable<Blob>) => void, mimeType?: string): void;
  119199. /**
  119200. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  119201. * @param successCallback defines the callback triggered once the data are available
  119202. * @param mimeType defines the mime type of the result
  119203. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  119204. */
  119205. static EncodeScreenshotCanvasData(successCallback?: (data: string) => void, mimeType?: string, fileName?: string): void;
  119206. /**
  119207. * Downloads a blob in the browser
  119208. * @param blob defines the blob to download
  119209. * @param fileName defines the name of the downloaded file
  119210. */
  119211. static Download(blob: Blob, fileName: string): void;
  119212. /**
  119213. * Captures a screenshot of the current rendering
  119214. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119215. * @param engine defines the rendering engine
  119216. * @param camera defines the source camera
  119217. * @param size This parameter can be set to a single number or to an object with the
  119218. * following (optional) properties: precision, width, height. If a single number is passed,
  119219. * it will be used for both width and height. If an object is passed, the screenshot size
  119220. * will be derived from the parameters. The precision property is a multiplier allowing
  119221. * rendering at a higher or lower resolution
  119222. * @param successCallback defines the callback receives a single parameter which contains the
  119223. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119224. * src parameter of an <img> to display it
  119225. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  119226. * Check your browser for supported MIME types
  119227. */
  119228. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  119229. /**
  119230. * Captures a screenshot of the current rendering
  119231. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119232. * @param engine defines the rendering engine
  119233. * @param camera defines the source camera
  119234. * @param size This parameter can be set to a single number or to an object with the
  119235. * following (optional) properties: precision, width, height. If a single number is passed,
  119236. * it will be used for both width and height. If an object is passed, the screenshot size
  119237. * will be derived from the parameters. The precision property is a multiplier allowing
  119238. * rendering at a higher or lower resolution
  119239. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  119240. * Check your browser for supported MIME types
  119241. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119242. * to the src parameter of an <img> to display it
  119243. */
  119244. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string): Promise<string>;
  119245. /**
  119246. * Generates an image screenshot from the specified camera.
  119247. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119248. * @param engine The engine to use for rendering
  119249. * @param camera The camera to use for rendering
  119250. * @param size This parameter can be set to a single number or to an object with the
  119251. * following (optional) properties: precision, width, height. If a single number is passed,
  119252. * it will be used for both width and height. If an object is passed, the screenshot size
  119253. * will be derived from the parameters. The precision property is a multiplier allowing
  119254. * rendering at a higher or lower resolution
  119255. * @param successCallback The callback receives a single parameter which contains the
  119256. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  119257. * src parameter of an <img> to display it
  119258. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119259. * Check your browser for supported MIME types
  119260. * @param samples Texture samples (default: 1)
  119261. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119262. * @param fileName A name for for the downloaded file.
  119263. */
  119264. static CreateScreenshotUsingRenderTarget(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): void;
  119265. /**
  119266. * Generates an image screenshot from the specified camera.
  119267. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  119268. * @param engine The engine to use for rendering
  119269. * @param camera The camera to use for rendering
  119270. * @param size This parameter can be set to a single number or to an object with the
  119271. * following (optional) properties: precision, width, height. If a single number is passed,
  119272. * it will be used for both width and height. If an object is passed, the screenshot size
  119273. * will be derived from the parameters. The precision property is a multiplier allowing
  119274. * rendering at a higher or lower resolution
  119275. * @param mimeType The MIME type of the screenshot image (default: image/png).
  119276. * Check your browser for supported MIME types
  119277. * @param samples Texture samples (default: 1)
  119278. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  119279. * @param fileName A name for for the downloaded file.
  119280. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  119281. * to the src parameter of an <img> to display it
  119282. */
  119283. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: IScreenshotSize | number, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string): Promise<string>;
  119284. /**
  119285. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  119286. * Be aware Math.random() could cause collisions, but:
  119287. * "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"
  119288. * @returns a pseudo random id
  119289. */
  119290. static RandomId(): string;
  119291. /**
  119292. * Test if the given uri is a base64 string
  119293. * @param uri The uri to test
  119294. * @return True if the uri is a base64 string or false otherwise
  119295. */
  119296. static IsBase64(uri: string): boolean;
  119297. /**
  119298. * Decode the given base64 uri.
  119299. * @param uri The uri to decode
  119300. * @return The decoded base64 data.
  119301. */
  119302. static DecodeBase64(uri: string): ArrayBuffer;
  119303. /**
  119304. * Gets the absolute url.
  119305. * @param url the input url
  119306. * @return the absolute url
  119307. */
  119308. static GetAbsoluteUrl(url: string): string;
  119309. /**
  119310. * No log
  119311. */
  119312. static readonly NoneLogLevel: number;
  119313. /**
  119314. * Only message logs
  119315. */
  119316. static readonly MessageLogLevel: number;
  119317. /**
  119318. * Only warning logs
  119319. */
  119320. static readonly WarningLogLevel: number;
  119321. /**
  119322. * Only error logs
  119323. */
  119324. static readonly ErrorLogLevel: number;
  119325. /**
  119326. * All logs
  119327. */
  119328. static readonly AllLogLevel: number;
  119329. /**
  119330. * Gets a value indicating the number of loading errors
  119331. * @ignorenaming
  119332. */
  119333. static get errorsCount(): number;
  119334. /**
  119335. * Callback called when a new log is added
  119336. */
  119337. static OnNewCacheEntry: (entry: string) => void;
  119338. /**
  119339. * Log a message to the console
  119340. * @param message defines the message to log
  119341. */
  119342. static Log(message: string): void;
  119343. /**
  119344. * Write a warning message to the console
  119345. * @param message defines the message to log
  119346. */
  119347. static Warn(message: string): void;
  119348. /**
  119349. * Write an error message to the console
  119350. * @param message defines the message to log
  119351. */
  119352. static Error(message: string): void;
  119353. /**
  119354. * Gets current log cache (list of logs)
  119355. */
  119356. static get LogCache(): string;
  119357. /**
  119358. * Clears the log cache
  119359. */
  119360. static ClearLogCache(): void;
  119361. /**
  119362. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  119363. */
  119364. static set LogLevels(level: number);
  119365. /**
  119366. * Checks if the window object exists
  119367. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  119368. */
  119369. static IsWindowObjectExist: typeof DomManagement.IsWindowObjectExist;
  119370. /**
  119371. * No performance log
  119372. */
  119373. static readonly PerformanceNoneLogLevel: number;
  119374. /**
  119375. * Use user marks to log performance
  119376. */
  119377. static readonly PerformanceUserMarkLogLevel: number;
  119378. /**
  119379. * Log performance to the console
  119380. */
  119381. static readonly PerformanceConsoleLogLevel: number;
  119382. private static _performance;
  119383. /**
  119384. * Sets the current performance log level
  119385. */
  119386. static set PerformanceLogLevel(level: number);
  119387. private static _StartPerformanceCounterDisabled;
  119388. private static _EndPerformanceCounterDisabled;
  119389. private static _StartUserMark;
  119390. private static _EndUserMark;
  119391. private static _StartPerformanceConsole;
  119392. private static _EndPerformanceConsole;
  119393. /**
  119394. * Starts a performance counter
  119395. */
  119396. static StartPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119397. /**
  119398. * Ends a specific performance coutner
  119399. */
  119400. static EndPerformanceCounter: (counterName: string, condition?: boolean) => void;
  119401. /**
  119402. * Gets either window.performance.now() if supported or Date.now() else
  119403. */
  119404. static get Now(): number;
  119405. /**
  119406. * This method will return the name of the class used to create the instance of the given object.
  119407. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  119408. * @param object the object to get the class name from
  119409. * @param isType defines if the object is actually a type
  119410. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  119411. */
  119412. static GetClassName(object: any, isType?: boolean): string;
  119413. /**
  119414. * Gets the first element of an array satisfying a given predicate
  119415. * @param array defines the array to browse
  119416. * @param predicate defines the predicate to use
  119417. * @returns null if not found or the element
  119418. */
  119419. static First<T>(array: Array<T>, predicate: (item: T) => boolean): Nullable<T>;
  119420. /**
  119421. * This method will return the name of the full name of the class, including its owning module (if any).
  119422. * 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).
  119423. * @param object the object to get the class name from
  119424. * @param isType defines if the object is actually a type
  119425. * @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.
  119426. * @ignorenaming
  119427. */
  119428. static getFullClassName(object: any, isType?: boolean): Nullable<string>;
  119429. /**
  119430. * Returns a promise that resolves after the given amount of time.
  119431. * @param delay Number of milliseconds to delay
  119432. * @returns Promise that resolves after the given amount of time
  119433. */
  119434. static DelayAsync(delay: number): Promise<void>;
  119435. /**
  119436. * Utility function to detect if the current user agent is Safari
  119437. * @returns whether or not the current user agent is safari
  119438. */
  119439. static IsSafari(): boolean;
  119440. }
  119441. /**
  119442. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  119443. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  119444. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  119445. * @param name The name of the class, case should be preserved
  119446. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  119447. */
  119448. export function className(name: string, module?: string): (target: Object) => void;
  119449. /**
  119450. * An implementation of a loop for asynchronous functions.
  119451. */
  119452. export class AsyncLoop {
  119453. /**
  119454. * Defines the number of iterations for the loop
  119455. */
  119456. iterations: number;
  119457. /**
  119458. * Defines the current index of the loop.
  119459. */
  119460. index: number;
  119461. private _done;
  119462. private _fn;
  119463. private _successCallback;
  119464. /**
  119465. * Constructor.
  119466. * @param iterations the number of iterations.
  119467. * @param func the function to run each iteration
  119468. * @param successCallback the callback that will be called upon succesful execution
  119469. * @param offset starting offset.
  119470. */
  119471. constructor(
  119472. /**
  119473. * Defines the number of iterations for the loop
  119474. */
  119475. iterations: number, func: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number);
  119476. /**
  119477. * Execute the next iteration. Must be called after the last iteration was finished.
  119478. */
  119479. executeNext(): void;
  119480. /**
  119481. * Break the loop and run the success callback.
  119482. */
  119483. breakLoop(): void;
  119484. /**
  119485. * Create and run an async loop.
  119486. * @param iterations the number of iterations.
  119487. * @param fn the function to run each iteration
  119488. * @param successCallback the callback that will be called upon succesful execution
  119489. * @param offset starting offset.
  119490. * @returns the created async loop object
  119491. */
  119492. static Run(iterations: number, fn: (asyncLoop: AsyncLoop) => void, successCallback: () => void, offset?: number): AsyncLoop;
  119493. /**
  119494. * A for-loop that will run a given number of iterations synchronous and the rest async.
  119495. * @param iterations total number of iterations
  119496. * @param syncedIterations number of synchronous iterations in each async iteration.
  119497. * @param fn the function to call each iteration.
  119498. * @param callback a success call back that will be called when iterating stops.
  119499. * @param breakFunction a break condition (optional)
  119500. * @param timeout timeout settings for the setTimeout function. default - 0.
  119501. * @returns the created async loop object
  119502. */
  119503. static SyncAsyncForLoop(iterations: number, syncedIterations: number, fn: (iteration: number) => void, callback: () => void, breakFunction?: () => boolean, timeout?: number): AsyncLoop;
  119504. }
  119505. }
  119506. declare module BABYLON {
  119507. /**
  119508. * This class implement a typical dictionary using a string as key and the generic type T as value.
  119509. * The underlying implementation relies on an associative array to ensure the best performances.
  119510. * The value can be anything including 'null' but except 'undefined'
  119511. */
  119512. export class StringDictionary<T> {
  119513. /**
  119514. * This will clear this dictionary and copy the content from the 'source' one.
  119515. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  119516. * @param source the dictionary to take the content from and copy to this dictionary
  119517. */
  119518. copyFrom(source: StringDictionary<T>): void;
  119519. /**
  119520. * Get a value based from its key
  119521. * @param key the given key to get the matching value from
  119522. * @return the value if found, otherwise undefined is returned
  119523. */
  119524. get(key: string): T | undefined;
  119525. /**
  119526. * Get a value from its key or add it if it doesn't exist.
  119527. * This method will ensure you that a given key/data will be present in the dictionary.
  119528. * @param key the given key to get the matching value from
  119529. * @param factory the factory that will create the value if the key is not present in the dictionary.
  119530. * The factory will only be invoked if there's no data for the given key.
  119531. * @return the value corresponding to the key.
  119532. */
  119533. getOrAddWithFactory(key: string, factory: (key: string) => T): T;
  119534. /**
  119535. * Get a value from its key if present in the dictionary otherwise add it
  119536. * @param key the key to get the value from
  119537. * @param val if there's no such key/value pair in the dictionary add it with this value
  119538. * @return the value corresponding to the key
  119539. */
  119540. getOrAdd(key: string, val: T): T;
  119541. /**
  119542. * Check if there's a given key in the dictionary
  119543. * @param key the key to check for
  119544. * @return true if the key is present, false otherwise
  119545. */
  119546. contains(key: string): boolean;
  119547. /**
  119548. * Add a new key and its corresponding value
  119549. * @param key the key to add
  119550. * @param value the value corresponding to the key
  119551. * @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
  119552. */
  119553. add(key: string, value: T): boolean;
  119554. /**
  119555. * Update a specific value associated to a key
  119556. * @param key defines the key to use
  119557. * @param value defines the value to store
  119558. * @returns true if the value was updated (or false if the key was not found)
  119559. */
  119560. set(key: string, value: T): boolean;
  119561. /**
  119562. * Get the element of the given key and remove it from the dictionary
  119563. * @param key defines the key to search
  119564. * @returns the value associated with the key or null if not found
  119565. */
  119566. getAndRemove(key: string): Nullable<T>;
  119567. /**
  119568. * Remove a key/value from the dictionary.
  119569. * @param key the key to remove
  119570. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  119571. */
  119572. remove(key: string): boolean;
  119573. /**
  119574. * Clear the whole content of the dictionary
  119575. */
  119576. clear(): void;
  119577. /**
  119578. * Gets the current count
  119579. */
  119580. get count(): number;
  119581. /**
  119582. * Execute a callback on each key/val of the dictionary.
  119583. * Note that you can remove any element in this dictionary in the callback implementation
  119584. * @param callback the callback to execute on a given key/value pair
  119585. */
  119586. forEach(callback: (key: string, val: T) => void): void;
  119587. /**
  119588. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  119589. * If the callback returns null or undefined the method will iterate to the next key/value pair
  119590. * Note that you can remove any element in this dictionary in the callback implementation
  119591. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  119592. * @returns the first item
  119593. */
  119594. first<TRes>(callback: (key: string, val: T) => TRes): TRes | null;
  119595. private _count;
  119596. private _data;
  119597. }
  119598. }
  119599. declare module BABYLON {
  119600. /** @hidden */
  119601. export interface ICollisionCoordinator {
  119602. createCollider(): Collider;
  119603. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: Nullable<AbstractMesh>, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119604. init(scene: Scene): void;
  119605. }
  119606. /** @hidden */
  119607. export class DefaultCollisionCoordinator implements ICollisionCoordinator {
  119608. private _scene;
  119609. private _scaledPosition;
  119610. private _scaledVelocity;
  119611. private _finalPosition;
  119612. getNewPosition(position: Vector3, displacement: Vector3, collider: Collider, maximumRetry: number, excludedMesh: AbstractMesh, onNewPosition: (collisionIndex: number, newPosition: Vector3, collidedMesh: Nullable<AbstractMesh>) => void, collisionIndex: number): void;
  119613. createCollider(): Collider;
  119614. init(scene: Scene): void;
  119615. private _collideWithWorld;
  119616. }
  119617. }
  119618. declare module BABYLON {
  119619. /**
  119620. * Class used to manage all inputs for the scene.
  119621. */
  119622. export class InputManager {
  119623. /** The distance in pixel that you have to move to prevent some events */
  119624. static DragMovementThreshold: number;
  119625. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  119626. static LongPressDelay: number;
  119627. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  119628. static DoubleClickDelay: number;
  119629. /** If you need to check double click without raising a single click at first click, enable this flag */
  119630. static ExclusiveDoubleClickMode: boolean;
  119631. /** 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. */
  119632. private _alreadyAttached;
  119633. private _wheelEventName;
  119634. private _onPointerMove;
  119635. private _onPointerDown;
  119636. private _onPointerUp;
  119637. private _initClickEvent;
  119638. private _initActionManager;
  119639. private _delayedSimpleClick;
  119640. private _delayedSimpleClickTimeout;
  119641. private _previousDelayedSimpleClickTimeout;
  119642. private _meshPickProceed;
  119643. private _previousButtonPressed;
  119644. private _currentPickResult;
  119645. private _previousPickResult;
  119646. private _totalPointersPressed;
  119647. private _doubleClickOccured;
  119648. private _pointerOverMesh;
  119649. private _pickedDownMesh;
  119650. private _pickedUpMesh;
  119651. private _pointerX;
  119652. private _pointerY;
  119653. private _unTranslatedPointerX;
  119654. private _unTranslatedPointerY;
  119655. private _startingPointerPosition;
  119656. private _previousStartingPointerPosition;
  119657. private _startingPointerTime;
  119658. private _previousStartingPointerTime;
  119659. private _pointerCaptures;
  119660. private _meshUnderPointerId;
  119661. private _onKeyDown;
  119662. private _onKeyUp;
  119663. private _onCanvasFocusObserver;
  119664. private _onCanvasBlurObserver;
  119665. private _scene;
  119666. /**
  119667. * Creates a new InputManager
  119668. * @param scene defines the hosting scene
  119669. */
  119670. constructor(scene: Scene);
  119671. /**
  119672. * Gets the mesh that is currently under the pointer
  119673. */
  119674. get meshUnderPointer(): Nullable<AbstractMesh>;
  119675. /**
  119676. * When using more than one pointer (for example in XR) you can get the mesh under the specific pointer
  119677. * @param pointerId the pointer id to use
  119678. * @returns The mesh under this pointer id or null if not found
  119679. */
  119680. getMeshUnderPointerByPointerId(pointerId: number): Nullable<AbstractMesh>;
  119681. /**
  119682. * Gets the pointer coordinates in 2D without any translation (ie. straight out of the pointer event)
  119683. */
  119684. get unTranslatedPointer(): Vector2;
  119685. /**
  119686. * Gets or sets the current on-screen X position of the pointer
  119687. */
  119688. get pointerX(): number;
  119689. set pointerX(value: number);
  119690. /**
  119691. * Gets or sets the current on-screen Y position of the pointer
  119692. */
  119693. get pointerY(): number;
  119694. set pointerY(value: number);
  119695. private _updatePointerPosition;
  119696. private _processPointerMove;
  119697. private _setRayOnPointerInfo;
  119698. private _checkPrePointerObservable;
  119699. /**
  119700. * Use this method to simulate a pointer move on a mesh
  119701. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119702. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119703. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119704. */
  119705. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119706. /**
  119707. * Use this method to simulate a pointer down on a mesh
  119708. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119709. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119710. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119711. */
  119712. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): void;
  119713. private _processPointerDown;
  119714. /** @hidden */
  119715. _isPointerSwiping(): boolean;
  119716. /**
  119717. * Use this method to simulate a pointer up on a mesh
  119718. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  119719. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  119720. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  119721. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  119722. */
  119723. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): void;
  119724. private _processPointerUp;
  119725. /**
  119726. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  119727. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  119728. * @returns true if the pointer was captured
  119729. */
  119730. isPointerCaptured(pointerId?: number): boolean;
  119731. /**
  119732. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  119733. * @param attachUp defines if you want to attach events to pointerup
  119734. * @param attachDown defines if you want to attach events to pointerdown
  119735. * @param attachMove defines if you want to attach events to pointermove
  119736. * @param elementToAttachTo defines the target DOM element to attach to (will use the canvas by default)
  119737. */
  119738. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean, elementToAttachTo?: Nullable<HTMLElement>): void;
  119739. /**
  119740. * Detaches all event handlers
  119741. */
  119742. detachControl(): void;
  119743. /**
  119744. * Force the value of meshUnderPointer
  119745. * @param mesh defines the mesh to use
  119746. * @param pointerId optional pointer id when using more than one pointer. Defaults to 0
  119747. */
  119748. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  119749. /**
  119750. * Gets the mesh under the pointer
  119751. * @returns a Mesh or null if no mesh is under the pointer
  119752. */
  119753. getPointerOverMesh(): Nullable<AbstractMesh>;
  119754. }
  119755. }
  119756. declare module BABYLON {
  119757. /**
  119758. * This class defines the direct association between an animation and a target
  119759. */
  119760. export class TargetedAnimation {
  119761. /**
  119762. * Animation to perform
  119763. */
  119764. animation: Animation;
  119765. /**
  119766. * Target to animate
  119767. */
  119768. target: any;
  119769. /**
  119770. * Returns the string "TargetedAnimation"
  119771. * @returns "TargetedAnimation"
  119772. */
  119773. getClassName(): string;
  119774. /**
  119775. * Serialize the object
  119776. * @returns the JSON object representing the current entity
  119777. */
  119778. serialize(): any;
  119779. }
  119780. /**
  119781. * Use this class to create coordinated animations on multiple targets
  119782. */
  119783. export class AnimationGroup implements IDisposable {
  119784. /** The name of the animation group */
  119785. name: string;
  119786. private _scene;
  119787. private _targetedAnimations;
  119788. private _animatables;
  119789. private _from;
  119790. private _to;
  119791. private _isStarted;
  119792. private _isPaused;
  119793. private _speedRatio;
  119794. private _loopAnimation;
  119795. private _isAdditive;
  119796. /**
  119797. * Gets or sets the unique id of the node
  119798. */
  119799. uniqueId: number;
  119800. /**
  119801. * This observable will notify when one animation have ended
  119802. */
  119803. onAnimationEndObservable: Observable<TargetedAnimation>;
  119804. /**
  119805. * Observer raised when one animation loops
  119806. */
  119807. onAnimationLoopObservable: Observable<TargetedAnimation>;
  119808. /**
  119809. * Observer raised when all animations have looped
  119810. */
  119811. onAnimationGroupLoopObservable: Observable<AnimationGroup>;
  119812. /**
  119813. * This observable will notify when all animations have ended.
  119814. */
  119815. onAnimationGroupEndObservable: Observable<AnimationGroup>;
  119816. /**
  119817. * This observable will notify when all animations have paused.
  119818. */
  119819. onAnimationGroupPauseObservable: Observable<AnimationGroup>;
  119820. /**
  119821. * This observable will notify when all animations are playing.
  119822. */
  119823. onAnimationGroupPlayObservable: Observable<AnimationGroup>;
  119824. /**
  119825. * Gets the first frame
  119826. */
  119827. get from(): number;
  119828. /**
  119829. * Gets the last frame
  119830. */
  119831. get to(): number;
  119832. /**
  119833. * Define if the animations are started
  119834. */
  119835. get isStarted(): boolean;
  119836. /**
  119837. * Gets a value indicating that the current group is playing
  119838. */
  119839. get isPlaying(): boolean;
  119840. /**
  119841. * Gets or sets the speed ratio to use for all animations
  119842. */
  119843. get speedRatio(): number;
  119844. /**
  119845. * Gets or sets the speed ratio to use for all animations
  119846. */
  119847. set speedRatio(value: number);
  119848. /**
  119849. * Gets or sets if all animations should loop or not
  119850. */
  119851. get loopAnimation(): boolean;
  119852. set loopAnimation(value: boolean);
  119853. /**
  119854. * Gets or sets if all animations should be evaluated additively
  119855. */
  119856. get isAdditive(): boolean;
  119857. set isAdditive(value: boolean);
  119858. /**
  119859. * Gets the targeted animations for this animation group
  119860. */
  119861. get targetedAnimations(): Array<TargetedAnimation>;
  119862. /**
  119863. * returning the list of animatables controlled by this animation group.
  119864. */
  119865. get animatables(): Array<Animatable>;
  119866. /**
  119867. * Gets the list of target animations
  119868. */
  119869. get children(): TargetedAnimation[];
  119870. /**
  119871. * Instantiates a new Animation Group.
  119872. * This helps managing several animations at once.
  119873. * @see https://doc.babylonjs.com/how_to/group
  119874. * @param name Defines the name of the group
  119875. * @param scene Defines the scene the group belongs to
  119876. */
  119877. constructor(
  119878. /** The name of the animation group */
  119879. name: string, scene?: Nullable<Scene>);
  119880. /**
  119881. * Add an animation (with its target) in the group
  119882. * @param animation defines the animation we want to add
  119883. * @param target defines the target of the animation
  119884. * @returns the TargetedAnimation object
  119885. */
  119886. addTargetedAnimation(animation: Animation, target: any): TargetedAnimation;
  119887. /**
  119888. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  119889. * It can add constant keys at begin or end
  119890. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  119891. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  119892. * @returns the animation group
  119893. */
  119894. normalize(beginFrame?: Nullable<number>, endFrame?: Nullable<number>): AnimationGroup;
  119895. private _animationLoopCount;
  119896. private _animationLoopFlags;
  119897. private _processLoop;
  119898. /**
  119899. * Start all animations on given targets
  119900. * @param loop defines if animations must loop
  119901. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  119902. * @param from defines the from key (optional)
  119903. * @param to defines the to key (optional)
  119904. * @param isAdditive defines the additive state for the resulting animatables (optional)
  119905. * @returns the current animation group
  119906. */
  119907. start(loop?: boolean, speedRatio?: number, from?: number, to?: number, isAdditive?: boolean): AnimationGroup;
  119908. /**
  119909. * Pause all animations
  119910. * @returns the animation group
  119911. */
  119912. pause(): AnimationGroup;
  119913. /**
  119914. * Play all animations to initial state
  119915. * This function will start() the animations if they were not started or will restart() them if they were paused
  119916. * @param loop defines if animations must loop
  119917. * @returns the animation group
  119918. */
  119919. play(loop?: boolean): AnimationGroup;
  119920. /**
  119921. * Reset all animations to initial state
  119922. * @returns the animation group
  119923. */
  119924. reset(): AnimationGroup;
  119925. /**
  119926. * Restart animations from key 0
  119927. * @returns the animation group
  119928. */
  119929. restart(): AnimationGroup;
  119930. /**
  119931. * Stop all animations
  119932. * @returns the animation group
  119933. */
  119934. stop(): AnimationGroup;
  119935. /**
  119936. * Set animation weight for all animatables
  119937. * @param weight defines the weight to use
  119938. * @return the animationGroup
  119939. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119940. */
  119941. setWeightForAllAnimatables(weight: number): AnimationGroup;
  119942. /**
  119943. * Synchronize and normalize all animatables with a source animatable
  119944. * @param root defines the root animatable to synchronize with
  119945. * @return the animationGroup
  119946. * @see https://doc.babylonjs.com/babylon101/animations#animation-weights
  119947. */
  119948. syncAllAnimationsWith(root: Animatable): AnimationGroup;
  119949. /**
  119950. * Goes to a specific frame in this animation group
  119951. * @param frame the frame number to go to
  119952. * @return the animationGroup
  119953. */
  119954. goToFrame(frame: number): AnimationGroup;
  119955. /**
  119956. * Dispose all associated resources
  119957. */
  119958. dispose(): void;
  119959. private _checkAnimationGroupEnded;
  119960. /**
  119961. * Clone the current animation group and returns a copy
  119962. * @param newName defines the name of the new group
  119963. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  119964. * @returns the new aniamtion group
  119965. */
  119966. clone(newName: string, targetConverter?: (oldTarget: any) => any): AnimationGroup;
  119967. /**
  119968. * Serializes the animationGroup to an object
  119969. * @returns Serialized object
  119970. */
  119971. serialize(): any;
  119972. /**
  119973. * Returns a new AnimationGroup object parsed from the source provided.
  119974. * @param parsedAnimationGroup defines the source
  119975. * @param scene defines the scene that will receive the animationGroup
  119976. * @returns a new AnimationGroup
  119977. */
  119978. static Parse(parsedAnimationGroup: any, scene: Scene): AnimationGroup;
  119979. /**
  119980. * Convert the keyframes for all animations belonging to the group to be relative to a given reference frame.
  119981. * @param sourceAnimationGroup defines the AnimationGroup containing animations to convert
  119982. * @param referenceFrame defines the frame that keyframes in the range will be relative to
  119983. * @param range defines the name of the AnimationRange belonging to the animations in the group to convert
  119984. * @param cloneOriginal defines whether or not to clone the group and convert the clone or convert the original group (default is false)
  119985. * @param clonedName defines the name of the resulting cloned AnimationGroup if cloneOriginal is true
  119986. * @returns a new AnimationGroup if cloneOriginal is true or the original AnimationGroup if cloneOriginal is false
  119987. */
  119988. static MakeAnimationAdditive(sourceAnimationGroup: AnimationGroup, referenceFrame?: number, range?: string, cloneOriginal?: boolean, clonedName?: string): AnimationGroup;
  119989. /**
  119990. * Returns the string "AnimationGroup"
  119991. * @returns "AnimationGroup"
  119992. */
  119993. getClassName(): string;
  119994. /**
  119995. * Creates a detailled string about the object
  119996. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  119997. * @returns a string representing the object
  119998. */
  119999. toString(fullDetails?: boolean): string;
  120000. }
  120001. }
  120002. declare module BABYLON {
  120003. /**
  120004. * Define an interface for all classes that will hold resources
  120005. */
  120006. export interface IDisposable {
  120007. /**
  120008. * Releases all held resources
  120009. */
  120010. dispose(): void;
  120011. }
  120012. /** Interface defining initialization parameters for Scene class */
  120013. export interface SceneOptions {
  120014. /**
  120015. * Defines that scene should keep up-to-date a map of geometry to enable fast look-up by uniqueId
  120016. * It will improve performance when the number of geometries becomes important.
  120017. */
  120018. useGeometryUniqueIdsMap?: boolean;
  120019. /**
  120020. * Defines that each material of the scene should keep up-to-date a map of referencing meshes for fast diposing
  120021. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  120022. */
  120023. useMaterialMeshMap?: boolean;
  120024. /**
  120025. * Defines that each mesh of the scene should keep up-to-date a map of referencing cloned meshes for fast diposing
  120026. * It will improve performance when the number of mesh becomes important, but might consume a bit more memory
  120027. */
  120028. useClonedMeshMap?: boolean;
  120029. /** Defines if the creation of the scene should impact the engine (Eg. UtilityLayer's scene) */
  120030. virtual?: boolean;
  120031. }
  120032. /**
  120033. * Represents a scene to be rendered by the engine.
  120034. * @see https://doc.babylonjs.com/features/scene
  120035. */
  120036. export class Scene extends AbstractScene implements IAnimatable, IClipPlanesHolder {
  120037. /** The fog is deactivated */
  120038. static readonly FOGMODE_NONE: number;
  120039. /** The fog density is following an exponential function */
  120040. static readonly FOGMODE_EXP: number;
  120041. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  120042. static readonly FOGMODE_EXP2: number;
  120043. /** The fog density is following a linear function. */
  120044. static readonly FOGMODE_LINEAR: number;
  120045. /**
  120046. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  120047. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120048. */
  120049. static MinDeltaTime: number;
  120050. /**
  120051. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  120052. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120053. */
  120054. static MaxDeltaTime: number;
  120055. /**
  120056. * Factory used to create the default material.
  120057. * @param name The name of the material to create
  120058. * @param scene The scene to create the material for
  120059. * @returns The default material
  120060. */
  120061. static DefaultMaterialFactory(scene: Scene): Material;
  120062. /**
  120063. * Factory used to create the a collision coordinator.
  120064. * @returns The collision coordinator
  120065. */
  120066. static CollisionCoordinatorFactory(): ICollisionCoordinator;
  120067. /** @hidden */
  120068. _inputManager: InputManager;
  120069. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  120070. cameraToUseForPointers: Nullable<Camera>;
  120071. /** @hidden */
  120072. readonly _isScene: boolean;
  120073. /** @hidden */
  120074. _blockEntityCollection: boolean;
  120075. /**
  120076. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  120077. */
  120078. autoClear: boolean;
  120079. /**
  120080. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  120081. */
  120082. autoClearDepthAndStencil: boolean;
  120083. /**
  120084. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  120085. */
  120086. clearColor: Color4;
  120087. /**
  120088. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  120089. */
  120090. ambientColor: Color3;
  120091. /**
  120092. * This is use to store the default BRDF lookup for PBR materials in your scene.
  120093. * It should only be one of the following (if not the default embedded one):
  120094. * * For uncorrelated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = false) : https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  120095. * * For correlated BRDF (pbr.brdf.useEnergyConservation = false and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedBRDF.dds
  120096. * * For correlated multi scattering BRDF (pbr.brdf.useEnergyConservation = true and pbr.brdf.useSmithVisibilityHeightCorrelated = true) : https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  120097. * The material properties need to be setup according to the type of texture in use.
  120098. */
  120099. environmentBRDFTexture: BaseTexture;
  120100. /**
  120101. * Texture used in all pbr material as the reflection texture.
  120102. * As in the majority of the scene they are the same (exception for multi room and so on),
  120103. * this is easier to reference from here than from all the materials.
  120104. */
  120105. get environmentTexture(): Nullable<BaseTexture>;
  120106. /**
  120107. * Texture used in all pbr material as the reflection texture.
  120108. * As in the majority of the scene they are the same (exception for multi room and so on),
  120109. * this is easier to set here than in all the materials.
  120110. */
  120111. set environmentTexture(value: Nullable<BaseTexture>);
  120112. /** @hidden */
  120113. protected _environmentIntensity: number;
  120114. /**
  120115. * Intensity of the environment in all pbr material.
  120116. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  120117. * As in the majority of the scene they are the same (exception for multi room and so on),
  120118. * this is easier to reference from here than from all the materials.
  120119. */
  120120. get environmentIntensity(): number;
  120121. /**
  120122. * Intensity of the environment in all pbr material.
  120123. * This dims or reinforces the IBL lighting overall (reflection and diffuse).
  120124. * As in the majority of the scene they are the same (exception for multi room and so on),
  120125. * this is easier to set here than in all the materials.
  120126. */
  120127. set environmentIntensity(value: number);
  120128. /** @hidden */
  120129. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  120130. /**
  120131. * Default image processing configuration used either in the rendering
  120132. * Forward main pass or through the imageProcessingPostProcess if present.
  120133. * As in the majority of the scene they are the same (exception for multi camera),
  120134. * this is easier to reference from here than from all the materials and post process.
  120135. *
  120136. * No setter as we it is a shared configuration, you can set the values instead.
  120137. */
  120138. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  120139. private _forceWireframe;
  120140. /**
  120141. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  120142. */
  120143. set forceWireframe(value: boolean);
  120144. get forceWireframe(): boolean;
  120145. private _skipFrustumClipping;
  120146. /**
  120147. * Gets or sets a boolean indicating if we should skip the frustum clipping part of the active meshes selection
  120148. */
  120149. set skipFrustumClipping(value: boolean);
  120150. get skipFrustumClipping(): boolean;
  120151. private _forcePointsCloud;
  120152. /**
  120153. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  120154. */
  120155. set forcePointsCloud(value: boolean);
  120156. get forcePointsCloud(): boolean;
  120157. /**
  120158. * Gets or sets the active clipplane 1
  120159. */
  120160. clipPlane: Nullable<Plane>;
  120161. /**
  120162. * Gets or sets the active clipplane 2
  120163. */
  120164. clipPlane2: Nullable<Plane>;
  120165. /**
  120166. * Gets or sets the active clipplane 3
  120167. */
  120168. clipPlane3: Nullable<Plane>;
  120169. /**
  120170. * Gets or sets the active clipplane 4
  120171. */
  120172. clipPlane4: Nullable<Plane>;
  120173. /**
  120174. * Gets or sets the active clipplane 5
  120175. */
  120176. clipPlane5: Nullable<Plane>;
  120177. /**
  120178. * Gets or sets the active clipplane 6
  120179. */
  120180. clipPlane6: Nullable<Plane>;
  120181. /**
  120182. * Gets or sets a boolean indicating if animations are enabled
  120183. */
  120184. animationsEnabled: boolean;
  120185. private _animationPropertiesOverride;
  120186. /**
  120187. * Gets or sets the animation properties override
  120188. */
  120189. get animationPropertiesOverride(): Nullable<AnimationPropertiesOverride>;
  120190. set animationPropertiesOverride(value: Nullable<AnimationPropertiesOverride>);
  120191. /**
  120192. * Gets or sets a boolean indicating if a constant deltatime has to be used
  120193. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  120194. */
  120195. useConstantAnimationDeltaTime: boolean;
  120196. /**
  120197. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  120198. * Please note that it requires to run a ray cast through the scene on every frame
  120199. */
  120200. constantlyUpdateMeshUnderPointer: boolean;
  120201. /**
  120202. * Defines the HTML cursor to use when hovering over interactive elements
  120203. */
  120204. hoverCursor: string;
  120205. /**
  120206. * Defines the HTML default cursor to use (empty by default)
  120207. */
  120208. defaultCursor: string;
  120209. /**
  120210. * Defines whether cursors are handled by the scene.
  120211. */
  120212. doNotHandleCursors: boolean;
  120213. /**
  120214. * This is used to call preventDefault() on pointer down
  120215. * in order to block unwanted artifacts like system double clicks
  120216. */
  120217. preventDefaultOnPointerDown: boolean;
  120218. /**
  120219. * This is used to call preventDefault() on pointer up
  120220. * in order to block unwanted artifacts like system double clicks
  120221. */
  120222. preventDefaultOnPointerUp: boolean;
  120223. /**
  120224. * Gets or sets user defined metadata
  120225. */
  120226. metadata: any;
  120227. /**
  120228. * For internal use only. Please do not use.
  120229. */
  120230. reservedDataStore: any;
  120231. /**
  120232. * Gets the name of the plugin used to load this scene (null by default)
  120233. */
  120234. loadingPluginName: string;
  120235. /**
  120236. * Use this array to add regular expressions used to disable offline support for specific urls
  120237. */
  120238. disableOfflineSupportExceptionRules: RegExp[];
  120239. /**
  120240. * An event triggered when the scene is disposed.
  120241. */
  120242. onDisposeObservable: Observable<Scene>;
  120243. private _onDisposeObserver;
  120244. /** Sets a function to be executed when this scene is disposed. */
  120245. set onDispose(callback: () => void);
  120246. /**
  120247. * An event triggered before rendering the scene (right after animations and physics)
  120248. */
  120249. onBeforeRenderObservable: Observable<Scene>;
  120250. private _onBeforeRenderObserver;
  120251. /** Sets a function to be executed before rendering this scene */
  120252. set beforeRender(callback: Nullable<() => void>);
  120253. /**
  120254. * An event triggered after rendering the scene
  120255. */
  120256. onAfterRenderObservable: Observable<Scene>;
  120257. /**
  120258. * An event triggered after rendering the scene for an active camera (When scene.render is called this will be called after each camera)
  120259. */
  120260. onAfterRenderCameraObservable: Observable<Camera>;
  120261. private _onAfterRenderObserver;
  120262. /** Sets a function to be executed after rendering this scene */
  120263. set afterRender(callback: Nullable<() => void>);
  120264. /**
  120265. * An event triggered before animating the scene
  120266. */
  120267. onBeforeAnimationsObservable: Observable<Scene>;
  120268. /**
  120269. * An event triggered after animations processing
  120270. */
  120271. onAfterAnimationsObservable: Observable<Scene>;
  120272. /**
  120273. * An event triggered before draw calls are ready to be sent
  120274. */
  120275. onBeforeDrawPhaseObservable: Observable<Scene>;
  120276. /**
  120277. * An event triggered after draw calls have been sent
  120278. */
  120279. onAfterDrawPhaseObservable: Observable<Scene>;
  120280. /**
  120281. * An event triggered when the scene is ready
  120282. */
  120283. onReadyObservable: Observable<Scene>;
  120284. /**
  120285. * An event triggered before rendering a camera
  120286. */
  120287. onBeforeCameraRenderObservable: Observable<Camera>;
  120288. private _onBeforeCameraRenderObserver;
  120289. /** Sets a function to be executed before rendering a camera*/
  120290. set beforeCameraRender(callback: () => void);
  120291. /**
  120292. * An event triggered after rendering a camera
  120293. */
  120294. onAfterCameraRenderObservable: Observable<Camera>;
  120295. private _onAfterCameraRenderObserver;
  120296. /** Sets a function to be executed after rendering a camera*/
  120297. set afterCameraRender(callback: () => void);
  120298. /**
  120299. * An event triggered when active meshes evaluation is about to start
  120300. */
  120301. onBeforeActiveMeshesEvaluationObservable: Observable<Scene>;
  120302. /**
  120303. * An event triggered when active meshes evaluation is done
  120304. */
  120305. onAfterActiveMeshesEvaluationObservable: Observable<Scene>;
  120306. /**
  120307. * An event triggered when particles rendering is about to start
  120308. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120309. */
  120310. onBeforeParticlesRenderingObservable: Observable<Scene>;
  120311. /**
  120312. * An event triggered when particles rendering is done
  120313. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  120314. */
  120315. onAfterParticlesRenderingObservable: Observable<Scene>;
  120316. /**
  120317. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  120318. */
  120319. onDataLoadedObservable: Observable<Scene>;
  120320. /**
  120321. * An event triggered when a camera is created
  120322. */
  120323. onNewCameraAddedObservable: Observable<Camera>;
  120324. /**
  120325. * An event triggered when a camera is removed
  120326. */
  120327. onCameraRemovedObservable: Observable<Camera>;
  120328. /**
  120329. * An event triggered when a light is created
  120330. */
  120331. onNewLightAddedObservable: Observable<Light>;
  120332. /**
  120333. * An event triggered when a light is removed
  120334. */
  120335. onLightRemovedObservable: Observable<Light>;
  120336. /**
  120337. * An event triggered when a geometry is created
  120338. */
  120339. onNewGeometryAddedObservable: Observable<Geometry>;
  120340. /**
  120341. * An event triggered when a geometry is removed
  120342. */
  120343. onGeometryRemovedObservable: Observable<Geometry>;
  120344. /**
  120345. * An event triggered when a transform node is created
  120346. */
  120347. onNewTransformNodeAddedObservable: Observable<TransformNode>;
  120348. /**
  120349. * An event triggered when a transform node is removed
  120350. */
  120351. onTransformNodeRemovedObservable: Observable<TransformNode>;
  120352. /**
  120353. * An event triggered when a mesh is created
  120354. */
  120355. onNewMeshAddedObservable: Observable<AbstractMesh>;
  120356. /**
  120357. * An event triggered when a mesh is removed
  120358. */
  120359. onMeshRemovedObservable: Observable<AbstractMesh>;
  120360. /**
  120361. * An event triggered when a skeleton is created
  120362. */
  120363. onNewSkeletonAddedObservable: Observable<Skeleton>;
  120364. /**
  120365. * An event triggered when a skeleton is removed
  120366. */
  120367. onSkeletonRemovedObservable: Observable<Skeleton>;
  120368. /**
  120369. * An event triggered when a material is created
  120370. */
  120371. onNewMaterialAddedObservable: Observable<Material>;
  120372. /**
  120373. * An event triggered when a material is removed
  120374. */
  120375. onMaterialRemovedObservable: Observable<Material>;
  120376. /**
  120377. * An event triggered when a texture is created
  120378. */
  120379. onNewTextureAddedObservable: Observable<BaseTexture>;
  120380. /**
  120381. * An event triggered when a texture is removed
  120382. */
  120383. onTextureRemovedObservable: Observable<BaseTexture>;
  120384. /**
  120385. * An event triggered when render targets are about to be rendered
  120386. * Can happen multiple times per frame.
  120387. */
  120388. onBeforeRenderTargetsRenderObservable: Observable<Scene>;
  120389. /**
  120390. * An event triggered when render targets were rendered.
  120391. * Can happen multiple times per frame.
  120392. */
  120393. onAfterRenderTargetsRenderObservable: Observable<Scene>;
  120394. /**
  120395. * An event triggered before calculating deterministic simulation step
  120396. */
  120397. onBeforeStepObservable: Observable<Scene>;
  120398. /**
  120399. * An event triggered after calculating deterministic simulation step
  120400. */
  120401. onAfterStepObservable: Observable<Scene>;
  120402. /**
  120403. * An event triggered when the activeCamera property is updated
  120404. */
  120405. onActiveCameraChanged: Observable<Scene>;
  120406. /**
  120407. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  120408. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120409. * 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)
  120410. */
  120411. onBeforeRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120412. /**
  120413. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  120414. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  120415. * 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)
  120416. */
  120417. onAfterRenderingGroupObservable: Observable<RenderingGroupInfo>;
  120418. /**
  120419. * This Observable will when a mesh has been imported into the scene.
  120420. */
  120421. onMeshImportedObservable: Observable<AbstractMesh>;
  120422. /**
  120423. * This Observable will when an animation file has been imported into the scene.
  120424. */
  120425. onAnimationFileImportedObservable: Observable<Scene>;
  120426. /**
  120427. * Gets or sets a user defined funtion to select LOD from a mesh and a camera.
  120428. * By default this function is undefined and Babylon.js will select LOD based on distance to camera
  120429. */
  120430. customLODSelector: (mesh: AbstractMesh, camera: Camera) => Nullable<AbstractMesh>;
  120431. /** @hidden */
  120432. _registeredForLateAnimationBindings: SmartArrayNoDuplicate<any>;
  120433. /**
  120434. * Gets or sets a predicate used to select candidate meshes for a pointer down event
  120435. */
  120436. pointerDownPredicate: (Mesh: AbstractMesh) => boolean;
  120437. /**
  120438. * Gets or sets a predicate used to select candidate meshes for a pointer up event
  120439. */
  120440. pointerUpPredicate: (Mesh: AbstractMesh) => boolean;
  120441. /**
  120442. * Gets or sets a predicate used to select candidate meshes for a pointer move event
  120443. */
  120444. pointerMovePredicate: (Mesh: AbstractMesh) => boolean;
  120445. /** Callback called when a pointer move is detected */
  120446. onPointerMove: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120447. /** Callback called when a pointer down is detected */
  120448. onPointerDown: (evt: PointerEvent, pickInfo: PickingInfo, type: PointerEventTypes) => void;
  120449. /** Callback called when a pointer up is detected */
  120450. onPointerUp: (evt: PointerEvent, pickInfo: Nullable<PickingInfo>, type: PointerEventTypes) => void;
  120451. /** Callback called when a pointer pick is detected */
  120452. onPointerPick: (evt: PointerEvent, pickInfo: PickingInfo) => void;
  120453. /**
  120454. * 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).
  120455. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  120456. */
  120457. onPrePointerObservable: Observable<PointerInfoPre>;
  120458. /**
  120459. * Observable event triggered each time an input event is received from the rendering canvas
  120460. */
  120461. onPointerObservable: Observable<PointerInfo>;
  120462. /**
  120463. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  120464. */
  120465. get unTranslatedPointer(): Vector2;
  120466. /**
  120467. * Gets or sets the distance in pixel that you have to move to prevent some events. Default is 10 pixels
  120468. */
  120469. static get DragMovementThreshold(): number;
  120470. static set DragMovementThreshold(value: number);
  120471. /**
  120472. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 500 ms
  120473. */
  120474. static get LongPressDelay(): number;
  120475. static set LongPressDelay(value: number);
  120476. /**
  120477. * Time in milliseconds to wait to raise long press events if button is still pressed. Default is 300 ms
  120478. */
  120479. static get DoubleClickDelay(): number;
  120480. static set DoubleClickDelay(value: number);
  120481. /** If you need to check double click without raising a single click at first click, enable this flag */
  120482. static get ExclusiveDoubleClickMode(): boolean;
  120483. static set ExclusiveDoubleClickMode(value: boolean);
  120484. /** @hidden */
  120485. _mirroredCameraPosition: Nullable<Vector3>;
  120486. /**
  120487. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  120488. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  120489. */
  120490. onPreKeyboardObservable: Observable<KeyboardInfoPre>;
  120491. /**
  120492. * Observable event triggered each time an keyboard event is received from the hosting window
  120493. */
  120494. onKeyboardObservable: Observable<KeyboardInfo>;
  120495. private _useRightHandedSystem;
  120496. /**
  120497. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  120498. */
  120499. set useRightHandedSystem(value: boolean);
  120500. get useRightHandedSystem(): boolean;
  120501. private _timeAccumulator;
  120502. private _currentStepId;
  120503. private _currentInternalStep;
  120504. /**
  120505. * Sets the step Id used by deterministic lock step
  120506. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120507. * @param newStepId defines the step Id
  120508. */
  120509. setStepId(newStepId: number): void;
  120510. /**
  120511. * Gets the step Id used by deterministic lock step
  120512. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120513. * @returns the step Id
  120514. */
  120515. getStepId(): number;
  120516. /**
  120517. * Gets the internal step used by deterministic lock step
  120518. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  120519. * @returns the internal step
  120520. */
  120521. getInternalStep(): number;
  120522. private _fogEnabled;
  120523. /**
  120524. * Gets or sets a boolean indicating if fog is enabled on this scene
  120525. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120526. * (Default is true)
  120527. */
  120528. set fogEnabled(value: boolean);
  120529. get fogEnabled(): boolean;
  120530. private _fogMode;
  120531. /**
  120532. * Gets or sets the fog mode to use
  120533. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120534. * | mode | value |
  120535. * | --- | --- |
  120536. * | FOGMODE_NONE | 0 |
  120537. * | FOGMODE_EXP | 1 |
  120538. * | FOGMODE_EXP2 | 2 |
  120539. * | FOGMODE_LINEAR | 3 |
  120540. */
  120541. set fogMode(value: number);
  120542. get fogMode(): number;
  120543. /**
  120544. * Gets or sets the fog color to use
  120545. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120546. * (Default is Color3(0.2, 0.2, 0.3))
  120547. */
  120548. fogColor: Color3;
  120549. /**
  120550. * Gets or sets the fog density to use
  120551. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120552. * (Default is 0.1)
  120553. */
  120554. fogDensity: number;
  120555. /**
  120556. * Gets or sets the fog start distance to use
  120557. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120558. * (Default is 0)
  120559. */
  120560. fogStart: number;
  120561. /**
  120562. * Gets or sets the fog end distance to use
  120563. * @see https://doc.babylonjs.com/babylon101/environment#fog
  120564. * (Default is 1000)
  120565. */
  120566. fogEnd: number;
  120567. /**
  120568. * Flag indicating that the frame buffer binding is handled by another component
  120569. */
  120570. prePass: boolean;
  120571. private _shadowsEnabled;
  120572. /**
  120573. * Gets or sets a boolean indicating if shadows are enabled on this scene
  120574. */
  120575. set shadowsEnabled(value: boolean);
  120576. get shadowsEnabled(): boolean;
  120577. private _lightsEnabled;
  120578. /**
  120579. * Gets or sets a boolean indicating if lights are enabled on this scene
  120580. */
  120581. set lightsEnabled(value: boolean);
  120582. get lightsEnabled(): boolean;
  120583. /** All of the active cameras added to this scene. */
  120584. activeCameras: Camera[];
  120585. /** @hidden */
  120586. _activeCamera: Nullable<Camera>;
  120587. /** Gets or sets the current active camera */
  120588. get activeCamera(): Nullable<Camera>;
  120589. set activeCamera(value: Nullable<Camera>);
  120590. private _defaultMaterial;
  120591. /** The default material used on meshes when no material is affected */
  120592. get defaultMaterial(): Material;
  120593. /** The default material used on meshes when no material is affected */
  120594. set defaultMaterial(value: Material);
  120595. private _texturesEnabled;
  120596. /**
  120597. * Gets or sets a boolean indicating if textures are enabled on this scene
  120598. */
  120599. set texturesEnabled(value: boolean);
  120600. get texturesEnabled(): boolean;
  120601. /**
  120602. * Gets or sets a boolean indicating if physic engines are enabled on this scene
  120603. */
  120604. physicsEnabled: boolean;
  120605. /**
  120606. * Gets or sets a boolean indicating if particles are enabled on this scene
  120607. */
  120608. particlesEnabled: boolean;
  120609. /**
  120610. * Gets or sets a boolean indicating if sprites are enabled on this scene
  120611. */
  120612. spritesEnabled: boolean;
  120613. private _skeletonsEnabled;
  120614. /**
  120615. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  120616. */
  120617. set skeletonsEnabled(value: boolean);
  120618. get skeletonsEnabled(): boolean;
  120619. /**
  120620. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  120621. */
  120622. lensFlaresEnabled: boolean;
  120623. /**
  120624. * Gets or sets a boolean indicating if collisions are enabled on this scene
  120625. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120626. */
  120627. collisionsEnabled: boolean;
  120628. private _collisionCoordinator;
  120629. /** @hidden */
  120630. get collisionCoordinator(): ICollisionCoordinator;
  120631. /**
  120632. * Defines the gravity applied to this scene (used only for collisions)
  120633. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  120634. */
  120635. gravity: Vector3;
  120636. /**
  120637. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  120638. */
  120639. postProcessesEnabled: boolean;
  120640. /**
  120641. * Gets the current postprocess manager
  120642. */
  120643. postProcessManager: PostProcessManager;
  120644. /**
  120645. * Gets or sets a boolean indicating if render targets are enabled on this scene
  120646. */
  120647. renderTargetsEnabled: boolean;
  120648. /**
  120649. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  120650. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  120651. */
  120652. dumpNextRenderTargets: boolean;
  120653. /**
  120654. * The list of user defined render targets added to the scene
  120655. */
  120656. customRenderTargets: RenderTargetTexture[];
  120657. /**
  120658. * Defines if texture loading must be delayed
  120659. * If true, textures will only be loaded when they need to be rendered
  120660. */
  120661. useDelayedTextureLoading: boolean;
  120662. /**
  120663. * Gets the list of meshes imported to the scene through SceneLoader
  120664. */
  120665. importedMeshesFiles: String[];
  120666. /**
  120667. * Gets or sets a boolean indicating if probes are enabled on this scene
  120668. */
  120669. probesEnabled: boolean;
  120670. /**
  120671. * Gets or sets the current offline provider to use to store scene data
  120672. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  120673. */
  120674. offlineProvider: IOfflineProvider;
  120675. /**
  120676. * Gets or sets the action manager associated with the scene
  120677. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  120678. */
  120679. actionManager: AbstractActionManager;
  120680. private _meshesForIntersections;
  120681. /**
  120682. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  120683. */
  120684. proceduralTexturesEnabled: boolean;
  120685. private _engine;
  120686. private _totalVertices;
  120687. /** @hidden */
  120688. _activeIndices: PerfCounter;
  120689. /** @hidden */
  120690. _activeParticles: PerfCounter;
  120691. /** @hidden */
  120692. _activeBones: PerfCounter;
  120693. private _animationRatio;
  120694. /** @hidden */
  120695. _animationTimeLast: number;
  120696. /** @hidden */
  120697. _animationTime: number;
  120698. /**
  120699. * Gets or sets a general scale for animation speed
  120700. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  120701. */
  120702. animationTimeScale: number;
  120703. /** @hidden */
  120704. _cachedMaterial: Nullable<Material>;
  120705. /** @hidden */
  120706. _cachedEffect: Nullable<Effect>;
  120707. /** @hidden */
  120708. _cachedVisibility: Nullable<number>;
  120709. private _renderId;
  120710. private _frameId;
  120711. private _executeWhenReadyTimeoutId;
  120712. private _intermediateRendering;
  120713. private _viewUpdateFlag;
  120714. private _projectionUpdateFlag;
  120715. /** @hidden */
  120716. _toBeDisposed: Nullable<IDisposable>[];
  120717. private _activeRequests;
  120718. /** @hidden */
  120719. _pendingData: any[];
  120720. private _isDisposed;
  120721. /**
  120722. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  120723. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  120724. */
  120725. dispatchAllSubMeshesOfActiveMeshes: boolean;
  120726. private _activeMeshes;
  120727. private _processedMaterials;
  120728. private _renderTargets;
  120729. /** @hidden */
  120730. _activeParticleSystems: SmartArray<IParticleSystem>;
  120731. private _activeSkeletons;
  120732. private _softwareSkinnedMeshes;
  120733. private _renderingManager;
  120734. /** @hidden */
  120735. _activeAnimatables: Animatable[];
  120736. private _transformMatrix;
  120737. private _sceneUbo;
  120738. /** @hidden */
  120739. _viewMatrix: Matrix;
  120740. private _projectionMatrix;
  120741. /** @hidden */
  120742. _forcedViewPosition: Nullable<Vector3>;
  120743. /** @hidden */
  120744. _frustumPlanes: Plane[];
  120745. /**
  120746. * Gets the list of frustum planes (built from the active camera)
  120747. */
  120748. get frustumPlanes(): Plane[];
  120749. /**
  120750. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  120751. * This is useful if there are more lights that the maximum simulteanous authorized
  120752. */
  120753. requireLightSorting: boolean;
  120754. /** @hidden */
  120755. readonly useMaterialMeshMap: boolean;
  120756. /** @hidden */
  120757. readonly useClonedMeshMap: boolean;
  120758. private _externalData;
  120759. private _uid;
  120760. /**
  120761. * @hidden
  120762. * Backing store of defined scene components.
  120763. */
  120764. _components: ISceneComponent[];
  120765. /**
  120766. * @hidden
  120767. * Backing store of defined scene components.
  120768. */
  120769. _serializableComponents: ISceneSerializableComponent[];
  120770. /**
  120771. * List of components to register on the next registration step.
  120772. */
  120773. private _transientComponents;
  120774. /**
  120775. * Registers the transient components if needed.
  120776. */
  120777. private _registerTransientComponents;
  120778. /**
  120779. * @hidden
  120780. * Add a component to the scene.
  120781. * Note that the ccomponent could be registered on th next frame if this is called after
  120782. * the register component stage.
  120783. * @param component Defines the component to add to the scene
  120784. */
  120785. _addComponent(component: ISceneComponent): void;
  120786. /**
  120787. * @hidden
  120788. * Gets a component from the scene.
  120789. * @param name defines the name of the component to retrieve
  120790. * @returns the component or null if not present
  120791. */
  120792. _getComponent(name: string): Nullable<ISceneComponent>;
  120793. /**
  120794. * @hidden
  120795. * Defines the actions happening before camera updates.
  120796. */
  120797. _beforeCameraUpdateStage: Stage<SimpleStageAction>;
  120798. /**
  120799. * @hidden
  120800. * Defines the actions happening before clear the canvas.
  120801. */
  120802. _beforeClearStage: Stage<SimpleStageAction>;
  120803. /**
  120804. * @hidden
  120805. * Defines the actions when collecting render targets for the frame.
  120806. */
  120807. _gatherRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120808. /**
  120809. * @hidden
  120810. * Defines the actions happening for one camera in the frame.
  120811. */
  120812. _gatherActiveCameraRenderTargetsStage: Stage<RenderTargetsStageAction>;
  120813. /**
  120814. * @hidden
  120815. * Defines the actions happening during the per mesh ready checks.
  120816. */
  120817. _isReadyForMeshStage: Stage<MeshStageAction>;
  120818. /**
  120819. * @hidden
  120820. * Defines the actions happening before evaluate active mesh checks.
  120821. */
  120822. _beforeEvaluateActiveMeshStage: Stage<SimpleStageAction>;
  120823. /**
  120824. * @hidden
  120825. * Defines the actions happening during the evaluate sub mesh checks.
  120826. */
  120827. _evaluateSubMeshStage: Stage<EvaluateSubMeshStageAction>;
  120828. /**
  120829. * @hidden
  120830. * Defines the actions happening during the active mesh stage.
  120831. */
  120832. _activeMeshStage: Stage<ActiveMeshStageAction>;
  120833. /**
  120834. * @hidden
  120835. * Defines the actions happening during the per camera render target step.
  120836. */
  120837. _cameraDrawRenderTargetStage: Stage<CameraStageFrameBufferAction>;
  120838. /**
  120839. * @hidden
  120840. * Defines the actions happening just before the active camera is drawing.
  120841. */
  120842. _beforeCameraDrawStage: Stage<CameraStageAction>;
  120843. /**
  120844. * @hidden
  120845. * Defines the actions happening just before a render target is drawing.
  120846. */
  120847. _beforeRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120848. /**
  120849. * @hidden
  120850. * Defines the actions happening just before a rendering group is drawing.
  120851. */
  120852. _beforeRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120853. /**
  120854. * @hidden
  120855. * Defines the actions happening just before a mesh is drawing.
  120856. */
  120857. _beforeRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120858. /**
  120859. * @hidden
  120860. * Defines the actions happening just after a mesh has been drawn.
  120861. */
  120862. _afterRenderingMeshStage: Stage<RenderingMeshStageAction>;
  120863. /**
  120864. * @hidden
  120865. * Defines the actions happening just after a rendering group has been drawn.
  120866. */
  120867. _afterRenderingGroupDrawStage: Stage<RenderingGroupStageAction>;
  120868. /**
  120869. * @hidden
  120870. * Defines the actions happening just after the active camera has been drawn.
  120871. */
  120872. _afterCameraDrawStage: Stage<CameraStageAction>;
  120873. /**
  120874. * @hidden
  120875. * Defines the actions happening just after a render target has been drawn.
  120876. */
  120877. _afterRenderTargetDrawStage: Stage<RenderTargetStageAction>;
  120878. /**
  120879. * @hidden
  120880. * Defines the actions happening just after rendering all cameras and computing intersections.
  120881. */
  120882. _afterRenderStage: Stage<SimpleStageAction>;
  120883. /**
  120884. * @hidden
  120885. * Defines the actions happening when a pointer move event happens.
  120886. */
  120887. _pointerMoveStage: Stage<PointerMoveStageAction>;
  120888. /**
  120889. * @hidden
  120890. * Defines the actions happening when a pointer down event happens.
  120891. */
  120892. _pointerDownStage: Stage<PointerUpDownStageAction>;
  120893. /**
  120894. * @hidden
  120895. * Defines the actions happening when a pointer up event happens.
  120896. */
  120897. _pointerUpStage: Stage<PointerUpDownStageAction>;
  120898. /**
  120899. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  120900. */
  120901. private geometriesByUniqueId;
  120902. /**
  120903. * Creates a new Scene
  120904. * @param engine defines the engine to use to render this scene
  120905. * @param options defines the scene options
  120906. */
  120907. constructor(engine: Engine, options?: SceneOptions);
  120908. /**
  120909. * Gets a string identifying the name of the class
  120910. * @returns "Scene" string
  120911. */
  120912. getClassName(): string;
  120913. private _defaultMeshCandidates;
  120914. /**
  120915. * @hidden
  120916. */
  120917. _getDefaultMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  120918. private _defaultSubMeshCandidates;
  120919. /**
  120920. * @hidden
  120921. */
  120922. _getDefaultSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  120923. /**
  120924. * Sets the default candidate providers for the scene.
  120925. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  120926. * and getCollidingSubMeshCandidates to their default function
  120927. */
  120928. setDefaultCandidateProviders(): void;
  120929. /**
  120930. * Gets the mesh that is currently under the pointer
  120931. */
  120932. get meshUnderPointer(): Nullable<AbstractMesh>;
  120933. /**
  120934. * Gets or sets the current on-screen X position of the pointer
  120935. */
  120936. get pointerX(): number;
  120937. set pointerX(value: number);
  120938. /**
  120939. * Gets or sets the current on-screen Y position of the pointer
  120940. */
  120941. get pointerY(): number;
  120942. set pointerY(value: number);
  120943. /**
  120944. * Gets the cached material (ie. the latest rendered one)
  120945. * @returns the cached material
  120946. */
  120947. getCachedMaterial(): Nullable<Material>;
  120948. /**
  120949. * Gets the cached effect (ie. the latest rendered one)
  120950. * @returns the cached effect
  120951. */
  120952. getCachedEffect(): Nullable<Effect>;
  120953. /**
  120954. * Gets the cached visibility state (ie. the latest rendered one)
  120955. * @returns the cached visibility state
  120956. */
  120957. getCachedVisibility(): Nullable<number>;
  120958. /**
  120959. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  120960. * @param material defines the current material
  120961. * @param effect defines the current effect
  120962. * @param visibility defines the current visibility state
  120963. * @returns true if one parameter is not cached
  120964. */
  120965. isCachedMaterialInvalid(material: Material, effect: Effect, visibility?: number): boolean;
  120966. /**
  120967. * Gets the engine associated with the scene
  120968. * @returns an Engine
  120969. */
  120970. getEngine(): Engine;
  120971. /**
  120972. * Gets the total number of vertices rendered per frame
  120973. * @returns the total number of vertices rendered per frame
  120974. */
  120975. getTotalVertices(): number;
  120976. /**
  120977. * Gets the performance counter for total vertices
  120978. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120979. */
  120980. get totalVerticesPerfCounter(): PerfCounter;
  120981. /**
  120982. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  120983. * @returns the total number of active indices rendered per frame
  120984. */
  120985. getActiveIndices(): number;
  120986. /**
  120987. * Gets the performance counter for active indices
  120988. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120989. */
  120990. get totalActiveIndicesPerfCounter(): PerfCounter;
  120991. /**
  120992. * Gets the total number of active particles rendered per frame
  120993. * @returns the total number of active particles rendered per frame
  120994. */
  120995. getActiveParticles(): number;
  120996. /**
  120997. * Gets the performance counter for active particles
  120998. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  120999. */
  121000. get activeParticlesPerfCounter(): PerfCounter;
  121001. /**
  121002. * Gets the total number of active bones rendered per frame
  121003. * @returns the total number of active bones rendered per frame
  121004. */
  121005. getActiveBones(): number;
  121006. /**
  121007. * Gets the performance counter for active bones
  121008. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  121009. */
  121010. get activeBonesPerfCounter(): PerfCounter;
  121011. /**
  121012. * Gets the array of active meshes
  121013. * @returns an array of AbstractMesh
  121014. */
  121015. getActiveMeshes(): SmartArray<AbstractMesh>;
  121016. /**
  121017. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  121018. * @returns a number
  121019. */
  121020. getAnimationRatio(): number;
  121021. /**
  121022. * Gets an unique Id for the current render phase
  121023. * @returns a number
  121024. */
  121025. getRenderId(): number;
  121026. /**
  121027. * Gets an unique Id for the current frame
  121028. * @returns a number
  121029. */
  121030. getFrameId(): number;
  121031. /** Call this function if you want to manually increment the render Id*/
  121032. incrementRenderId(): void;
  121033. private _createUbo;
  121034. /**
  121035. * Use this method to simulate a pointer move on a mesh
  121036. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121037. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121038. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121039. * @returns the current scene
  121040. */
  121041. simulatePointerMove(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  121042. /**
  121043. * Use this method to simulate a pointer down on a mesh
  121044. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121045. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121046. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121047. * @returns the current scene
  121048. */
  121049. simulatePointerDown(pickResult: PickingInfo, pointerEventInit?: PointerEventInit): Scene;
  121050. /**
  121051. * Use this method to simulate a pointer up on a mesh
  121052. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  121053. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  121054. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  121055. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  121056. * @returns the current scene
  121057. */
  121058. simulatePointerUp(pickResult: PickingInfo, pointerEventInit?: PointerEventInit, doubleTap?: boolean): Scene;
  121059. /**
  121060. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  121061. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  121062. * @returns true if the pointer was captured
  121063. */
  121064. isPointerCaptured(pointerId?: number): boolean;
  121065. /**
  121066. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  121067. * @param attachUp defines if you want to attach events to pointerup
  121068. * @param attachDown defines if you want to attach events to pointerdown
  121069. * @param attachMove defines if you want to attach events to pointermove
  121070. */
  121071. attachControl(attachUp?: boolean, attachDown?: boolean, attachMove?: boolean): void;
  121072. /** Detaches all event handlers*/
  121073. detachControl(): void;
  121074. /**
  121075. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  121076. * Delay loaded resources are not taking in account
  121077. * @return true if all required resources are ready
  121078. */
  121079. isReady(): boolean;
  121080. /** Resets all cached information relative to material (including effect and visibility) */
  121081. resetCachedMaterial(): void;
  121082. /**
  121083. * Registers a function to be called before every frame render
  121084. * @param func defines the function to register
  121085. */
  121086. registerBeforeRender(func: () => void): void;
  121087. /**
  121088. * Unregisters a function called before every frame render
  121089. * @param func defines the function to unregister
  121090. */
  121091. unregisterBeforeRender(func: () => void): void;
  121092. /**
  121093. * Registers a function to be called after every frame render
  121094. * @param func defines the function to register
  121095. */
  121096. registerAfterRender(func: () => void): void;
  121097. /**
  121098. * Unregisters a function called after every frame render
  121099. * @param func defines the function to unregister
  121100. */
  121101. unregisterAfterRender(func: () => void): void;
  121102. private _executeOnceBeforeRender;
  121103. /**
  121104. * The provided function will run before render once and will be disposed afterwards.
  121105. * A timeout delay can be provided so that the function will be executed in N ms.
  121106. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  121107. * @param func The function to be executed.
  121108. * @param timeout optional delay in ms
  121109. */
  121110. executeOnceBeforeRender(func: () => void, timeout?: number): void;
  121111. /** @hidden */
  121112. _addPendingData(data: any): void;
  121113. /** @hidden */
  121114. _removePendingData(data: any): void;
  121115. /**
  121116. * Returns the number of items waiting to be loaded
  121117. * @returns the number of items waiting to be loaded
  121118. */
  121119. getWaitingItemsCount(): number;
  121120. /**
  121121. * Returns a boolean indicating if the scene is still loading data
  121122. */
  121123. get isLoading(): boolean;
  121124. /**
  121125. * Registers a function to be executed when the scene is ready
  121126. * @param {Function} func - the function to be executed
  121127. */
  121128. executeWhenReady(func: () => void): void;
  121129. /**
  121130. * Returns a promise that resolves when the scene is ready
  121131. * @returns A promise that resolves when the scene is ready
  121132. */
  121133. whenReadyAsync(): Promise<void>;
  121134. /** @hidden */
  121135. _checkIsReady(): void;
  121136. /**
  121137. * Gets all animatable attached to the scene
  121138. */
  121139. get animatables(): Animatable[];
  121140. /**
  121141. * Resets the last animation time frame.
  121142. * Useful to override when animations start running when loading a scene for the first time.
  121143. */
  121144. resetLastAnimationTimeFrame(): void;
  121145. /**
  121146. * Gets the current view matrix
  121147. * @returns a Matrix
  121148. */
  121149. getViewMatrix(): Matrix;
  121150. /**
  121151. * Gets the current projection matrix
  121152. * @returns a Matrix
  121153. */
  121154. getProjectionMatrix(): Matrix;
  121155. /**
  121156. * Gets the current transform matrix
  121157. * @returns a Matrix made of View * Projection
  121158. */
  121159. getTransformMatrix(): Matrix;
  121160. /**
  121161. * Sets the current transform matrix
  121162. * @param viewL defines the View matrix to use
  121163. * @param projectionL defines the Projection matrix to use
  121164. * @param viewR defines the right View matrix to use (if provided)
  121165. * @param projectionR defines the right Projection matrix to use (if provided)
  121166. */
  121167. setTransformMatrix(viewL: Matrix, projectionL: Matrix, viewR?: Matrix, projectionR?: Matrix): void;
  121168. /**
  121169. * Gets the uniform buffer used to store scene data
  121170. * @returns a UniformBuffer
  121171. */
  121172. getSceneUniformBuffer(): UniformBuffer;
  121173. /**
  121174. * Gets an unique (relatively to the current scene) Id
  121175. * @returns an unique number for the scene
  121176. */
  121177. getUniqueId(): number;
  121178. /**
  121179. * Add a mesh to the list of scene's meshes
  121180. * @param newMesh defines the mesh to add
  121181. * @param recursive if all child meshes should also be added to the scene
  121182. */
  121183. addMesh(newMesh: AbstractMesh, recursive?: boolean): void;
  121184. /**
  121185. * Remove a mesh for the list of scene's meshes
  121186. * @param toRemove defines the mesh to remove
  121187. * @param recursive if all child meshes should also be removed from the scene
  121188. * @returns the index where the mesh was in the mesh list
  121189. */
  121190. removeMesh(toRemove: AbstractMesh, recursive?: boolean): number;
  121191. /**
  121192. * Add a transform node to the list of scene's transform nodes
  121193. * @param newTransformNode defines the transform node to add
  121194. */
  121195. addTransformNode(newTransformNode: TransformNode): void;
  121196. /**
  121197. * Remove a transform node for the list of scene's transform nodes
  121198. * @param toRemove defines the transform node to remove
  121199. * @returns the index where the transform node was in the transform node list
  121200. */
  121201. removeTransformNode(toRemove: TransformNode): number;
  121202. /**
  121203. * Remove a skeleton for the list of scene's skeletons
  121204. * @param toRemove defines the skeleton to remove
  121205. * @returns the index where the skeleton was in the skeleton list
  121206. */
  121207. removeSkeleton(toRemove: Skeleton): number;
  121208. /**
  121209. * Remove a morph target for the list of scene's morph targets
  121210. * @param toRemove defines the morph target to remove
  121211. * @returns the index where the morph target was in the morph target list
  121212. */
  121213. removeMorphTargetManager(toRemove: MorphTargetManager): number;
  121214. /**
  121215. * Remove a light for the list of scene's lights
  121216. * @param toRemove defines the light to remove
  121217. * @returns the index where the light was in the light list
  121218. */
  121219. removeLight(toRemove: Light): number;
  121220. /**
  121221. * Remove a camera for the list of scene's cameras
  121222. * @param toRemove defines the camera to remove
  121223. * @returns the index where the camera was in the camera list
  121224. */
  121225. removeCamera(toRemove: Camera): number;
  121226. /**
  121227. * Remove a particle system for the list of scene's particle systems
  121228. * @param toRemove defines the particle system to remove
  121229. * @returns the index where the particle system was in the particle system list
  121230. */
  121231. removeParticleSystem(toRemove: IParticleSystem): number;
  121232. /**
  121233. * Remove a animation for the list of scene's animations
  121234. * @param toRemove defines the animation to remove
  121235. * @returns the index where the animation was in the animation list
  121236. */
  121237. removeAnimation(toRemove: Animation): number;
  121238. /**
  121239. * Will stop the animation of the given target
  121240. * @param target - the target
  121241. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  121242. * @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)
  121243. */
  121244. stopAnimation(target: any, animationName?: string, targetMask?: (target: any) => boolean): void;
  121245. /**
  121246. * Removes the given animation group from this scene.
  121247. * @param toRemove The animation group to remove
  121248. * @returns The index of the removed animation group
  121249. */
  121250. removeAnimationGroup(toRemove: AnimationGroup): number;
  121251. /**
  121252. * Removes the given multi-material from this scene.
  121253. * @param toRemove The multi-material to remove
  121254. * @returns The index of the removed multi-material
  121255. */
  121256. removeMultiMaterial(toRemove: MultiMaterial): number;
  121257. /**
  121258. * Removes the given material from this scene.
  121259. * @param toRemove The material to remove
  121260. * @returns The index of the removed material
  121261. */
  121262. removeMaterial(toRemove: Material): number;
  121263. /**
  121264. * Removes the given action manager from this scene.
  121265. * @param toRemove The action manager to remove
  121266. * @returns The index of the removed action manager
  121267. */
  121268. removeActionManager(toRemove: AbstractActionManager): number;
  121269. /**
  121270. * Removes the given texture from this scene.
  121271. * @param toRemove The texture to remove
  121272. * @returns The index of the removed texture
  121273. */
  121274. removeTexture(toRemove: BaseTexture): number;
  121275. /**
  121276. * Adds the given light to this scene
  121277. * @param newLight The light to add
  121278. */
  121279. addLight(newLight: Light): void;
  121280. /**
  121281. * Sorts the list list based on light priorities
  121282. */
  121283. sortLightsByPriority(): void;
  121284. /**
  121285. * Adds the given camera to this scene
  121286. * @param newCamera The camera to add
  121287. */
  121288. addCamera(newCamera: Camera): void;
  121289. /**
  121290. * Adds the given skeleton to this scene
  121291. * @param newSkeleton The skeleton to add
  121292. */
  121293. addSkeleton(newSkeleton: Skeleton): void;
  121294. /**
  121295. * Adds the given particle system to this scene
  121296. * @param newParticleSystem The particle system to add
  121297. */
  121298. addParticleSystem(newParticleSystem: IParticleSystem): void;
  121299. /**
  121300. * Adds the given animation to this scene
  121301. * @param newAnimation The animation to add
  121302. */
  121303. addAnimation(newAnimation: Animation): void;
  121304. /**
  121305. * Adds the given animation group to this scene.
  121306. * @param newAnimationGroup The animation group to add
  121307. */
  121308. addAnimationGroup(newAnimationGroup: AnimationGroup): void;
  121309. /**
  121310. * Adds the given multi-material to this scene
  121311. * @param newMultiMaterial The multi-material to add
  121312. */
  121313. addMultiMaterial(newMultiMaterial: MultiMaterial): void;
  121314. /**
  121315. * Adds the given material to this scene
  121316. * @param newMaterial The material to add
  121317. */
  121318. addMaterial(newMaterial: Material): void;
  121319. /**
  121320. * Adds the given morph target to this scene
  121321. * @param newMorphTargetManager The morph target to add
  121322. */
  121323. addMorphTargetManager(newMorphTargetManager: MorphTargetManager): void;
  121324. /**
  121325. * Adds the given geometry to this scene
  121326. * @param newGeometry The geometry to add
  121327. */
  121328. addGeometry(newGeometry: Geometry): void;
  121329. /**
  121330. * Adds the given action manager to this scene
  121331. * @param newActionManager The action manager to add
  121332. */
  121333. addActionManager(newActionManager: AbstractActionManager): void;
  121334. /**
  121335. * Adds the given texture to this scene.
  121336. * @param newTexture The texture to add
  121337. */
  121338. addTexture(newTexture: BaseTexture): void;
  121339. /**
  121340. * Switch active camera
  121341. * @param newCamera defines the new active camera
  121342. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  121343. */
  121344. switchActiveCamera(newCamera: Camera, attachControl?: boolean): void;
  121345. /**
  121346. * sets the active camera of the scene using its ID
  121347. * @param id defines the camera's ID
  121348. * @return the new active camera or null if none found.
  121349. */
  121350. setActiveCameraByID(id: string): Nullable<Camera>;
  121351. /**
  121352. * sets the active camera of the scene using its name
  121353. * @param name defines the camera's name
  121354. * @returns the new active camera or null if none found.
  121355. */
  121356. setActiveCameraByName(name: string): Nullable<Camera>;
  121357. /**
  121358. * get an animation group using its name
  121359. * @param name defines the material's name
  121360. * @return the animation group or null if none found.
  121361. */
  121362. getAnimationGroupByName(name: string): Nullable<AnimationGroup>;
  121363. /**
  121364. * Get a material using its unique id
  121365. * @param uniqueId defines the material's unique id
  121366. * @return the material or null if none found.
  121367. */
  121368. getMaterialByUniqueID(uniqueId: number): Nullable<Material>;
  121369. /**
  121370. * get a material using its id
  121371. * @param id defines the material's ID
  121372. * @return the material or null if none found.
  121373. */
  121374. getMaterialByID(id: string): Nullable<Material>;
  121375. /**
  121376. * Gets a the last added material using a given id
  121377. * @param id defines the material's ID
  121378. * @return the last material with the given id or null if none found.
  121379. */
  121380. getLastMaterialByID(id: string): Nullable<Material>;
  121381. /**
  121382. * Gets a material using its name
  121383. * @param name defines the material's name
  121384. * @return the material or null if none found.
  121385. */
  121386. getMaterialByName(name: string): Nullable<Material>;
  121387. /**
  121388. * Get a texture using its unique id
  121389. * @param uniqueId defines the texture's unique id
  121390. * @return the texture or null if none found.
  121391. */
  121392. getTextureByUniqueID(uniqueId: number): Nullable<BaseTexture>;
  121393. /**
  121394. * Gets a camera using its id
  121395. * @param id defines the id to look for
  121396. * @returns the camera or null if not found
  121397. */
  121398. getCameraByID(id: string): Nullable<Camera>;
  121399. /**
  121400. * Gets a camera using its unique id
  121401. * @param uniqueId defines the unique id to look for
  121402. * @returns the camera or null if not found
  121403. */
  121404. getCameraByUniqueID(uniqueId: number): Nullable<Camera>;
  121405. /**
  121406. * Gets a camera using its name
  121407. * @param name defines the camera's name
  121408. * @return the camera or null if none found.
  121409. */
  121410. getCameraByName(name: string): Nullable<Camera>;
  121411. /**
  121412. * Gets a bone using its id
  121413. * @param id defines the bone's id
  121414. * @return the bone or null if not found
  121415. */
  121416. getBoneByID(id: string): Nullable<Bone>;
  121417. /**
  121418. * Gets a bone using its id
  121419. * @param name defines the bone's name
  121420. * @return the bone or null if not found
  121421. */
  121422. getBoneByName(name: string): Nullable<Bone>;
  121423. /**
  121424. * Gets a light node using its name
  121425. * @param name defines the the light's name
  121426. * @return the light or null if none found.
  121427. */
  121428. getLightByName(name: string): Nullable<Light>;
  121429. /**
  121430. * Gets a light node using its id
  121431. * @param id defines the light's id
  121432. * @return the light or null if none found.
  121433. */
  121434. getLightByID(id: string): Nullable<Light>;
  121435. /**
  121436. * Gets a light node using its scene-generated unique ID
  121437. * @param uniqueId defines the light's unique id
  121438. * @return the light or null if none found.
  121439. */
  121440. getLightByUniqueID(uniqueId: number): Nullable<Light>;
  121441. /**
  121442. * Gets a particle system by id
  121443. * @param id defines the particle system id
  121444. * @return the corresponding system or null if none found
  121445. */
  121446. getParticleSystemByID(id: string): Nullable<IParticleSystem>;
  121447. /**
  121448. * Gets a geometry using its ID
  121449. * @param id defines the geometry's id
  121450. * @return the geometry or null if none found.
  121451. */
  121452. getGeometryByID(id: string): Nullable<Geometry>;
  121453. private _getGeometryByUniqueID;
  121454. /**
  121455. * Add a new geometry to this scene
  121456. * @param geometry defines the geometry to be added to the scene.
  121457. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  121458. * @return a boolean defining if the geometry was added or not
  121459. */
  121460. pushGeometry(geometry: Geometry, force?: boolean): boolean;
  121461. /**
  121462. * Removes an existing geometry
  121463. * @param geometry defines the geometry to be removed from the scene
  121464. * @return a boolean defining if the geometry was removed or not
  121465. */
  121466. removeGeometry(geometry: Geometry): boolean;
  121467. /**
  121468. * Gets the list of geometries attached to the scene
  121469. * @returns an array of Geometry
  121470. */
  121471. getGeometries(): Geometry[];
  121472. /**
  121473. * Gets the first added mesh found of a given ID
  121474. * @param id defines the id to search for
  121475. * @return the mesh found or null if not found at all
  121476. */
  121477. getMeshByID(id: string): Nullable<AbstractMesh>;
  121478. /**
  121479. * Gets a list of meshes using their id
  121480. * @param id defines the id to search for
  121481. * @returns a list of meshes
  121482. */
  121483. getMeshesByID(id: string): Array<AbstractMesh>;
  121484. /**
  121485. * Gets the first added transform node found of a given ID
  121486. * @param id defines the id to search for
  121487. * @return the found transform node or null if not found at all.
  121488. */
  121489. getTransformNodeByID(id: string): Nullable<TransformNode>;
  121490. /**
  121491. * Gets a transform node with its auto-generated unique id
  121492. * @param uniqueId efines the unique id to search for
  121493. * @return the found transform node or null if not found at all.
  121494. */
  121495. getTransformNodeByUniqueID(uniqueId: number): Nullable<TransformNode>;
  121496. /**
  121497. * Gets a list of transform nodes using their id
  121498. * @param id defines the id to search for
  121499. * @returns a list of transform nodes
  121500. */
  121501. getTransformNodesByID(id: string): Array<TransformNode>;
  121502. /**
  121503. * Gets a mesh with its auto-generated unique id
  121504. * @param uniqueId defines the unique id to search for
  121505. * @return the found mesh or null if not found at all.
  121506. */
  121507. getMeshByUniqueID(uniqueId: number): Nullable<AbstractMesh>;
  121508. /**
  121509. * Gets a the last added mesh using a given id
  121510. * @param id defines the id to search for
  121511. * @return the found mesh or null if not found at all.
  121512. */
  121513. getLastMeshByID(id: string): Nullable<AbstractMesh>;
  121514. /**
  121515. * Gets a the last added node (Mesh, Camera, Light) using a given id
  121516. * @param id defines the id to search for
  121517. * @return the found node or null if not found at all
  121518. */
  121519. getLastEntryByID(id: string): Nullable<Node>;
  121520. /**
  121521. * Gets a node (Mesh, Camera, Light) using a given id
  121522. * @param id defines the id to search for
  121523. * @return the found node or null if not found at all
  121524. */
  121525. getNodeByID(id: string): Nullable<Node>;
  121526. /**
  121527. * Gets a node (Mesh, Camera, Light) using a given name
  121528. * @param name defines the name to search for
  121529. * @return the found node or null if not found at all.
  121530. */
  121531. getNodeByName(name: string): Nullable<Node>;
  121532. /**
  121533. * Gets a mesh using a given name
  121534. * @param name defines the name to search for
  121535. * @return the found mesh or null if not found at all.
  121536. */
  121537. getMeshByName(name: string): Nullable<AbstractMesh>;
  121538. /**
  121539. * Gets a transform node using a given name
  121540. * @param name defines the name to search for
  121541. * @return the found transform node or null if not found at all.
  121542. */
  121543. getTransformNodeByName(name: string): Nullable<TransformNode>;
  121544. /**
  121545. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  121546. * @param id defines the id to search for
  121547. * @return the found skeleton or null if not found at all.
  121548. */
  121549. getLastSkeletonByID(id: string): Nullable<Skeleton>;
  121550. /**
  121551. * Gets a skeleton using a given auto generated unique id
  121552. * @param uniqueId defines the unique id to search for
  121553. * @return the found skeleton or null if not found at all.
  121554. */
  121555. getSkeletonByUniqueId(uniqueId: number): Nullable<Skeleton>;
  121556. /**
  121557. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  121558. * @param id defines the id to search for
  121559. * @return the found skeleton or null if not found at all.
  121560. */
  121561. getSkeletonById(id: string): Nullable<Skeleton>;
  121562. /**
  121563. * Gets a skeleton using a given name
  121564. * @param name defines the name to search for
  121565. * @return the found skeleton or null if not found at all.
  121566. */
  121567. getSkeletonByName(name: string): Nullable<Skeleton>;
  121568. /**
  121569. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  121570. * @param id defines the id to search for
  121571. * @return the found morph target manager or null if not found at all.
  121572. */
  121573. getMorphTargetManagerById(id: number): Nullable<MorphTargetManager>;
  121574. /**
  121575. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  121576. * @param id defines the id to search for
  121577. * @return the found morph target or null if not found at all.
  121578. */
  121579. getMorphTargetById(id: string): Nullable<MorphTarget>;
  121580. /**
  121581. * Gets a morph target using a given name (if many are found, this function will pick the first one)
  121582. * @param name defines the name to search for
  121583. * @return the found morph target or null if not found at all.
  121584. */
  121585. getMorphTargetByName(name: string): Nullable<MorphTarget>;
  121586. /**
  121587. * Gets a post process using a given name (if many are found, this function will pick the first one)
  121588. * @param name defines the name to search for
  121589. * @return the found post process or null if not found at all.
  121590. */
  121591. getPostProcessByName(name: string): Nullable<PostProcess>;
  121592. /**
  121593. * Gets a boolean indicating if the given mesh is active
  121594. * @param mesh defines the mesh to look for
  121595. * @returns true if the mesh is in the active list
  121596. */
  121597. isActiveMesh(mesh: AbstractMesh): boolean;
  121598. /**
  121599. * Return a unique id as a string which can serve as an identifier for the scene
  121600. */
  121601. get uid(): string;
  121602. /**
  121603. * Add an externaly attached data from its key.
  121604. * This method call will fail and return false, if such key already exists.
  121605. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  121606. * @param key the unique key that identifies the data
  121607. * @param data the data object to associate to the key for this Engine instance
  121608. * @return true if no such key were already present and the data was added successfully, false otherwise
  121609. */
  121610. addExternalData<T>(key: string, data: T): boolean;
  121611. /**
  121612. * Get an externaly attached data from its key
  121613. * @param key the unique key that identifies the data
  121614. * @return the associated data, if present (can be null), or undefined if not present
  121615. */
  121616. getExternalData<T>(key: string): Nullable<T>;
  121617. /**
  121618. * Get an externaly attached data from its key, create it using a factory if it's not already present
  121619. * @param key the unique key that identifies the data
  121620. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  121621. * @return the associated data, can be null if the factory returned null.
  121622. */
  121623. getOrAddExternalDataWithFactory<T>(key: string, factory: (k: string) => T): T;
  121624. /**
  121625. * Remove an externaly attached data from the Engine instance
  121626. * @param key the unique key that identifies the data
  121627. * @return true if the data was successfully removed, false if it doesn't exist
  121628. */
  121629. removeExternalData(key: string): boolean;
  121630. private _evaluateSubMesh;
  121631. /**
  121632. * Clear the processed materials smart array preventing retention point in material dispose.
  121633. */
  121634. freeProcessedMaterials(): void;
  121635. private _preventFreeActiveMeshesAndRenderingGroups;
  121636. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  121637. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  121638. * when disposing several meshes in a row or a hierarchy of meshes.
  121639. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  121640. */
  121641. get blockfreeActiveMeshesAndRenderingGroups(): boolean;
  121642. set blockfreeActiveMeshesAndRenderingGroups(value: boolean);
  121643. /**
  121644. * Clear the active meshes smart array preventing retention point in mesh dispose.
  121645. */
  121646. freeActiveMeshes(): void;
  121647. /**
  121648. * Clear the info related to rendering groups preventing retention points during dispose.
  121649. */
  121650. freeRenderingGroups(): void;
  121651. /** @hidden */
  121652. _isInIntermediateRendering(): boolean;
  121653. /**
  121654. * Lambda returning the list of potentially active meshes.
  121655. */
  121656. getActiveMeshCandidates: () => ISmartArrayLike<AbstractMesh>;
  121657. /**
  121658. * Lambda returning the list of potentially active sub meshes.
  121659. */
  121660. getActiveSubMeshCandidates: (mesh: AbstractMesh) => ISmartArrayLike<SubMesh>;
  121661. /**
  121662. * Lambda returning the list of potentially intersecting sub meshes.
  121663. */
  121664. getIntersectingSubMeshCandidates: (mesh: AbstractMesh, localRay: Ray) => ISmartArrayLike<SubMesh>;
  121665. /**
  121666. * Lambda returning the list of potentially colliding sub meshes.
  121667. */
  121668. getCollidingSubMeshCandidates: (mesh: AbstractMesh, collider: Collider) => ISmartArrayLike<SubMesh>;
  121669. private _activeMeshesFrozen;
  121670. private _skipEvaluateActiveMeshesCompletely;
  121671. /**
  121672. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  121673. * @param skipEvaluateActiveMeshes defines an optional boolean indicating that the evaluate active meshes step must be completely skipped
  121674. * @returns the current scene
  121675. */
  121676. freezeActiveMeshes(skipEvaluateActiveMeshes?: boolean): Scene;
  121677. /**
  121678. * Use this function to restart evaluating active meshes on every frame
  121679. * @returns the current scene
  121680. */
  121681. unfreezeActiveMeshes(): Scene;
  121682. private _evaluateActiveMeshes;
  121683. private _activeMesh;
  121684. /**
  121685. * Update the transform matrix to update from the current active camera
  121686. * @param force defines a boolean used to force the update even if cache is up to date
  121687. */
  121688. updateTransformMatrix(force?: boolean): void;
  121689. private _bindFrameBuffer;
  121690. /** @hidden */
  121691. _allowPostProcessClearColor: boolean;
  121692. /** @hidden */
  121693. _renderForCamera(camera: Camera, rigParent?: Camera): void;
  121694. private _processSubCameras;
  121695. private _checkIntersections;
  121696. /** @hidden */
  121697. _advancePhysicsEngineStep(step: number): void;
  121698. /**
  121699. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  121700. */
  121701. getDeterministicFrameTime: () => number;
  121702. /** @hidden */
  121703. _animate(): void;
  121704. /** Execute all animations (for a frame) */
  121705. animate(): void;
  121706. /**
  121707. * Render the scene
  121708. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  121709. * @param ignoreAnimations defines a boolean indicating if animations should not be executed (false by default)
  121710. */
  121711. render(updateCameras?: boolean, ignoreAnimations?: boolean): void;
  121712. /**
  121713. * Freeze all materials
  121714. * A frozen material will not be updatable but should be faster to render
  121715. */
  121716. freezeMaterials(): void;
  121717. /**
  121718. * Unfreeze all materials
  121719. * A frozen material will not be updatable but should be faster to render
  121720. */
  121721. unfreezeMaterials(): void;
  121722. /**
  121723. * Releases all held ressources
  121724. */
  121725. dispose(): void;
  121726. /**
  121727. * Gets if the scene is already disposed
  121728. */
  121729. get isDisposed(): boolean;
  121730. /**
  121731. * Call this function to reduce memory footprint of the scene.
  121732. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  121733. */
  121734. clearCachedVertexData(): void;
  121735. /**
  121736. * This function will remove the local cached buffer data from texture.
  121737. * It will save memory but will prevent the texture from being rebuilt
  121738. */
  121739. cleanCachedTextureBuffer(): void;
  121740. /**
  121741. * Get the world extend vectors with an optional filter
  121742. *
  121743. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  121744. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  121745. */
  121746. getWorldExtends(filterPredicate?: (mesh: AbstractMesh) => boolean): {
  121747. min: Vector3;
  121748. max: Vector3;
  121749. };
  121750. /**
  121751. * Creates a ray that can be used to pick in the scene
  121752. * @param x defines the x coordinate of the origin (on-screen)
  121753. * @param y defines the y coordinate of the origin (on-screen)
  121754. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121755. * @param camera defines the camera to use for the picking
  121756. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121757. * @returns a Ray
  121758. */
  121759. createPickingRay(x: number, y: number, world: Matrix, camera: Nullable<Camera>, cameraViewSpace?: boolean): Ray;
  121760. /**
  121761. * Creates a ray that can be used to pick in the scene
  121762. * @param x defines the x coordinate of the origin (on-screen)
  121763. * @param y defines the y coordinate of the origin (on-screen)
  121764. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  121765. * @param result defines the ray where to store the picking ray
  121766. * @param camera defines the camera to use for the picking
  121767. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  121768. * @returns the current scene
  121769. */
  121770. createPickingRayToRef(x: number, y: number, world: Matrix, result: Ray, camera: Nullable<Camera>, cameraViewSpace?: boolean): Scene;
  121771. /**
  121772. * Creates a ray that can be used to pick in the scene
  121773. * @param x defines the x coordinate of the origin (on-screen)
  121774. * @param y defines the y coordinate of the origin (on-screen)
  121775. * @param camera defines the camera to use for the picking
  121776. * @returns a Ray
  121777. */
  121778. createPickingRayInCameraSpace(x: number, y: number, camera?: Camera): Ray;
  121779. /**
  121780. * Creates a ray that can be used to pick in the scene
  121781. * @param x defines the x coordinate of the origin (on-screen)
  121782. * @param y defines the y coordinate of the origin (on-screen)
  121783. * @param result defines the ray where to store the picking ray
  121784. * @param camera defines the camera to use for the picking
  121785. * @returns the current scene
  121786. */
  121787. createPickingRayInCameraSpaceToRef(x: number, y: number, result: Ray, camera?: Camera): Scene;
  121788. /** Launch a ray to try to pick a mesh in the scene
  121789. * @param x position on screen
  121790. * @param y position on screen
  121791. * @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
  121792. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121793. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121794. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121795. * @returns a PickingInfo
  121796. */
  121797. pick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121798. /** Launch a ray to try to pick a mesh in the scene using only bounding information of the main mesh (not using submeshes)
  121799. * @param x position on screen
  121800. * @param y position on screen
  121801. * @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
  121802. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121803. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121804. * @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)
  121805. */
  121806. pickWithBoundingInfo(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, camera?: Nullable<Camera>): Nullable<PickingInfo>;
  121807. /** Use the given ray to pick a mesh in the scene
  121808. * @param ray The ray to use to pick meshes
  121809. * @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
  121810. * @param fastCheck defines if the first intersection will be used (and not the closest)
  121811. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121812. * @returns a PickingInfo
  121813. */
  121814. pickWithRay(ray: Ray, predicate?: (mesh: AbstractMesh) => boolean, fastCheck?: boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo>;
  121815. /**
  121816. * Launch a ray to try to pick a mesh in the scene
  121817. * @param x X position on screen
  121818. * @param y Y position on screen
  121819. * @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
  121820. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  121821. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121822. * @returns an array of PickingInfo
  121823. */
  121824. multiPick(x: number, y: number, predicate?: (mesh: AbstractMesh) => boolean, camera?: Camera, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121825. /**
  121826. * Launch a ray to try to pick a mesh in the scene
  121827. * @param ray Ray to use
  121828. * @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
  121829. * @param trianglePredicate defines an optional predicate used to select faces when a mesh intersection is detected
  121830. * @returns an array of PickingInfo
  121831. */
  121832. multiPickWithRay(ray: Ray, predicate: (mesh: AbstractMesh) => boolean, trianglePredicate?: TrianglePickingPredicate): Nullable<PickingInfo[]>;
  121833. /**
  121834. * Force the value of meshUnderPointer
  121835. * @param mesh defines the mesh to use
  121836. * @param pointerId optional pointer id when using more than one pointer
  121837. */
  121838. setPointerOverMesh(mesh: Nullable<AbstractMesh>, pointerId?: number): void;
  121839. /**
  121840. * Gets the mesh under the pointer
  121841. * @returns a Mesh or null if no mesh is under the pointer
  121842. */
  121843. getPointerOverMesh(): Nullable<AbstractMesh>;
  121844. /** @hidden */
  121845. _rebuildGeometries(): void;
  121846. /** @hidden */
  121847. _rebuildTextures(): void;
  121848. private _getByTags;
  121849. /**
  121850. * Get a list of meshes by tags
  121851. * @param tagsQuery defines the tags query to use
  121852. * @param forEach defines a predicate used to filter results
  121853. * @returns an array of Mesh
  121854. */
  121855. getMeshesByTags(tagsQuery: string, forEach?: (mesh: AbstractMesh) => void): Mesh[];
  121856. /**
  121857. * Get a list of cameras by tags
  121858. * @param tagsQuery defines the tags query to use
  121859. * @param forEach defines a predicate used to filter results
  121860. * @returns an array of Camera
  121861. */
  121862. getCamerasByTags(tagsQuery: string, forEach?: (camera: Camera) => void): Camera[];
  121863. /**
  121864. * Get a list of lights by tags
  121865. * @param tagsQuery defines the tags query to use
  121866. * @param forEach defines a predicate used to filter results
  121867. * @returns an array of Light
  121868. */
  121869. getLightsByTags(tagsQuery: string, forEach?: (light: Light) => void): Light[];
  121870. /**
  121871. * Get a list of materials by tags
  121872. * @param tagsQuery defines the tags query to use
  121873. * @param forEach defines a predicate used to filter results
  121874. * @returns an array of Material
  121875. */
  121876. getMaterialByTags(tagsQuery: string, forEach?: (material: Material) => void): Material[];
  121877. /**
  121878. * Get a list of transform nodes by tags
  121879. * @param tagsQuery defines the tags query to use
  121880. * @param forEach defines a predicate used to filter results
  121881. * @returns an array of TransformNode
  121882. */
  121883. getTransformNodesByTags(tagsQuery: string, forEach?: (transform: TransformNode) => void): TransformNode[];
  121884. /**
  121885. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  121886. * This allowed control for front to back rendering or reversly depending of the special needs.
  121887. *
  121888. * @param renderingGroupId The rendering group id corresponding to its index
  121889. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  121890. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  121891. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  121892. */
  121893. 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;
  121894. /**
  121895. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  121896. *
  121897. * @param renderingGroupId The rendering group id corresponding to its index
  121898. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  121899. * @param depth Automatically clears depth between groups if true and autoClear is true.
  121900. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  121901. */
  121902. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean, depth?: boolean, stencil?: boolean): void;
  121903. /**
  121904. * Gets the current auto clear configuration for one rendering group of the rendering
  121905. * manager.
  121906. * @param index the rendering group index to get the information for
  121907. * @returns The auto clear setup for the requested rendering group
  121908. */
  121909. getAutoClearDepthStencilSetup(index: number): IRenderingManagerAutoClearSetup;
  121910. private _blockMaterialDirtyMechanism;
  121911. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  121912. get blockMaterialDirtyMechanism(): boolean;
  121913. set blockMaterialDirtyMechanism(value: boolean);
  121914. /**
  121915. * Will flag all materials as dirty to trigger new shader compilation
  121916. * @param flag defines the flag used to specify which material part must be marked as dirty
  121917. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  121918. */
  121919. markAllMaterialsAsDirty(flag: number, predicate?: (mat: Material) => boolean): void;
  121920. /** @hidden */
  121921. _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;
  121922. /** @hidden */
  121923. _loadFileAsync(url: string, onProgress?: (data: any) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121924. /** @hidden */
  121925. _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;
  121926. /** @hidden */
  121927. _requestFileAsync(url: string, onProgress?: (ev: ProgressEvent) => void, useOfflineSupport?: boolean, useArrayBuffer?: boolean, onOpened?: (request: WebRequest) => void): Promise<string | ArrayBuffer>;
  121928. /** @hidden */
  121929. _readFile(file: File, onSuccess: (data: string | ArrayBuffer) => void, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: ReadFileError) => void): IFileRequest;
  121930. /** @hidden */
  121931. _readFileAsync(file: File, onProgress?: (ev: ProgressEvent) => any, useArrayBuffer?: boolean): Promise<string | ArrayBuffer>;
  121932. }
  121933. }
  121934. declare module BABYLON {
  121935. /**
  121936. * Set of assets to keep when moving a scene into an asset container.
  121937. */
  121938. export class KeepAssets extends AbstractScene {
  121939. }
  121940. /**
  121941. * Class used to store the output of the AssetContainer.instantiateAllMeshesToScene function
  121942. */
  121943. export class InstantiatedEntries {
  121944. /**
  121945. * List of new root nodes (eg. nodes with no parent)
  121946. */
  121947. rootNodes: TransformNode[];
  121948. /**
  121949. * List of new skeletons
  121950. */
  121951. skeletons: Skeleton[];
  121952. /**
  121953. * List of new animation groups
  121954. */
  121955. animationGroups: AnimationGroup[];
  121956. }
  121957. /**
  121958. * Container with a set of assets that can be added or removed from a scene.
  121959. */
  121960. export class AssetContainer extends AbstractScene {
  121961. private _wasAddedToScene;
  121962. /**
  121963. * The scene the AssetContainer belongs to.
  121964. */
  121965. scene: Scene;
  121966. /**
  121967. * Instantiates an AssetContainer.
  121968. * @param scene The scene the AssetContainer belongs to.
  121969. */
  121970. constructor(scene: Scene);
  121971. /**
  121972. * Instantiate or clone all meshes and add the new ones to the scene.
  121973. * Skeletons and animation groups will all be cloned
  121974. * @param nameFunction defines an optional function used to get new names for clones
  121975. * @param cloneMaterials defines an optional boolean that defines if materials must be cloned as well (false by default)
  121976. * @returns a list of rootNodes, skeletons and aniamtion groups that were duplicated
  121977. */
  121978. instantiateModelsToScene(nameFunction?: (sourceName: string) => string, cloneMaterials?: boolean): InstantiatedEntries;
  121979. /**
  121980. * Adds all the assets from the container to the scene.
  121981. */
  121982. addAllToScene(): void;
  121983. /**
  121984. * Removes all the assets in the container from the scene
  121985. */
  121986. removeAllFromScene(): void;
  121987. /**
  121988. * Disposes all the assets in the container
  121989. */
  121990. dispose(): void;
  121991. private _moveAssets;
  121992. /**
  121993. * Removes all the assets contained in the scene and adds them to the container.
  121994. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  121995. */
  121996. moveAllFromScene(keepAssets?: KeepAssets): void;
  121997. /**
  121998. * 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.
  121999. * @returns the root mesh
  122000. */
  122001. createRootMesh(): Mesh;
  122002. /**
  122003. * Merge animations (direct and animation groups) from this asset container into a scene
  122004. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  122005. * @param animatables set of animatables to retarget to a node from the scene
  122006. * @param targetConverter defines a function used to convert animation targets from the asset container to the scene (default: search node by name)
  122007. * @returns an array of the new AnimationGroup added to the scene (empty array if none)
  122008. */
  122009. mergeAnimationsTo(scene: Scene | null | undefined, animatables: Animatable[], targetConverter?: Nullable<(target: any) => Nullable<Node>>): AnimationGroup[];
  122010. }
  122011. }
  122012. declare module BABYLON {
  122013. /**
  122014. * Defines how the parser contract is defined.
  122015. * These parsers are used to parse a list of specific assets (like particle systems, etc..)
  122016. */
  122017. export type BabylonFileParser = (parsedData: any, scene: Scene, container: AssetContainer, rootUrl: string) => void;
  122018. /**
  122019. * Defines how the individual parser contract is defined.
  122020. * These parser can parse an individual asset
  122021. */
  122022. export type IndividualBabylonFileParser = (parsedData: any, scene: Scene, rootUrl: string) => any;
  122023. /**
  122024. * Base class of the scene acting as a container for the different elements composing a scene.
  122025. * This class is dynamically extended by the different components of the scene increasing
  122026. * flexibility and reducing coupling
  122027. */
  122028. export abstract class AbstractScene {
  122029. /**
  122030. * Stores the list of available parsers in the application.
  122031. */
  122032. private static _BabylonFileParsers;
  122033. /**
  122034. * Stores the list of available individual parsers in the application.
  122035. */
  122036. private static _IndividualBabylonFileParsers;
  122037. /**
  122038. * Adds a parser in the list of available ones
  122039. * @param name Defines the name of the parser
  122040. * @param parser Defines the parser to add
  122041. */
  122042. static AddParser(name: string, parser: BabylonFileParser): void;
  122043. /**
  122044. * Gets a general parser from the list of avaialble ones
  122045. * @param name Defines the name of the parser
  122046. * @returns the requested parser or null
  122047. */
  122048. static GetParser(name: string): Nullable<BabylonFileParser>;
  122049. /**
  122050. * Adds n individual parser in the list of available ones
  122051. * @param name Defines the name of the parser
  122052. * @param parser Defines the parser to add
  122053. */
  122054. static AddIndividualParser(name: string, parser: IndividualBabylonFileParser): void;
  122055. /**
  122056. * Gets an individual parser from the list of avaialble ones
  122057. * @param name Defines the name of the parser
  122058. * @returns the requested parser or null
  122059. */
  122060. static GetIndividualParser(name: string): Nullable<IndividualBabylonFileParser>;
  122061. /**
  122062. * Parser json data and populate both a scene and its associated container object
  122063. * @param jsonData Defines the data to parse
  122064. * @param scene Defines the scene to parse the data for
  122065. * @param container Defines the container attached to the parsing sequence
  122066. * @param rootUrl Defines the root url of the data
  122067. */
  122068. static Parse(jsonData: any, scene: Scene, container: AssetContainer, rootUrl: string): void;
  122069. /**
  122070. * Gets the list of root nodes (ie. nodes with no parent)
  122071. */
  122072. rootNodes: Node[];
  122073. /** All of the cameras added to this scene
  122074. * @see https://doc.babylonjs.com/babylon101/cameras
  122075. */
  122076. cameras: Camera[];
  122077. /**
  122078. * All of the lights added to this scene
  122079. * @see https://doc.babylonjs.com/babylon101/lights
  122080. */
  122081. lights: Light[];
  122082. /**
  122083. * All of the (abstract) meshes added to this scene
  122084. */
  122085. meshes: AbstractMesh[];
  122086. /**
  122087. * The list of skeletons added to the scene
  122088. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  122089. */
  122090. skeletons: Skeleton[];
  122091. /**
  122092. * All of the particle systems added to this scene
  122093. * @see https://doc.babylonjs.com/babylon101/particles
  122094. */
  122095. particleSystems: IParticleSystem[];
  122096. /**
  122097. * Gets a list of Animations associated with the scene
  122098. */
  122099. animations: Animation[];
  122100. /**
  122101. * All of the animation groups added to this scene
  122102. * @see https://doc.babylonjs.com/how_to/group
  122103. */
  122104. animationGroups: AnimationGroup[];
  122105. /**
  122106. * All of the multi-materials added to this scene
  122107. * @see https://doc.babylonjs.com/how_to/multi_materials
  122108. */
  122109. multiMaterials: MultiMaterial[];
  122110. /**
  122111. * All of the materials added to this scene
  122112. * In the context of a Scene, it is not supposed to be modified manually.
  122113. * Any addition or removal should be done using the addMaterial and removeMaterial Scene methods.
  122114. * Note also that the order of the Material within the array is not significant and might change.
  122115. * @see https://doc.babylonjs.com/babylon101/materials
  122116. */
  122117. materials: Material[];
  122118. /**
  122119. * The list of morph target managers added to the scene
  122120. * @see https://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  122121. */
  122122. morphTargetManagers: MorphTargetManager[];
  122123. /**
  122124. * The list of geometries used in the scene.
  122125. */
  122126. geometries: Geometry[];
  122127. /**
  122128. * All of the tranform nodes added to this scene
  122129. * In the context of a Scene, it is not supposed to be modified manually.
  122130. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  122131. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  122132. * @see https://doc.babylonjs.com/how_to/transformnode
  122133. */
  122134. transformNodes: TransformNode[];
  122135. /**
  122136. * ActionManagers available on the scene.
  122137. */
  122138. actionManagers: AbstractActionManager[];
  122139. /**
  122140. * Textures to keep.
  122141. */
  122142. textures: BaseTexture[];
  122143. /** @hidden */
  122144. protected _environmentTexture: Nullable<BaseTexture>;
  122145. /**
  122146. * Texture used in all pbr material as the reflection texture.
  122147. * As in the majority of the scene they are the same (exception for multi room and so on),
  122148. * this is easier to reference from here than from all the materials.
  122149. */
  122150. get environmentTexture(): Nullable<BaseTexture>;
  122151. set environmentTexture(value: Nullable<BaseTexture>);
  122152. /**
  122153. * The list of postprocesses added to the scene
  122154. */
  122155. postProcesses: PostProcess[];
  122156. /**
  122157. * @returns all meshes, lights, cameras, transformNodes and bones
  122158. */
  122159. getNodes(): Array<Node>;
  122160. }
  122161. }
  122162. declare module BABYLON {
  122163. /**
  122164. * Interface used to define options for Sound class
  122165. */
  122166. export interface ISoundOptions {
  122167. /**
  122168. * Does the sound autoplay once loaded.
  122169. */
  122170. autoplay?: boolean;
  122171. /**
  122172. * Does the sound loop after it finishes playing once.
  122173. */
  122174. loop?: boolean;
  122175. /**
  122176. * Sound's volume
  122177. */
  122178. volume?: number;
  122179. /**
  122180. * Is it a spatial sound?
  122181. */
  122182. spatialSound?: boolean;
  122183. /**
  122184. * Maximum distance to hear that sound
  122185. */
  122186. maxDistance?: number;
  122187. /**
  122188. * Uses user defined attenuation function
  122189. */
  122190. useCustomAttenuation?: boolean;
  122191. /**
  122192. * Define the roll off factor of spatial sounds.
  122193. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122194. */
  122195. rolloffFactor?: number;
  122196. /**
  122197. * Define the reference distance the sound should be heard perfectly.
  122198. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122199. */
  122200. refDistance?: number;
  122201. /**
  122202. * Define the distance attenuation model the sound will follow.
  122203. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122204. */
  122205. distanceModel?: string;
  122206. /**
  122207. * Defines the playback speed (1 by default)
  122208. */
  122209. playbackRate?: number;
  122210. /**
  122211. * Defines if the sound is from a streaming source
  122212. */
  122213. streaming?: boolean;
  122214. /**
  122215. * Defines an optional length (in seconds) inside the sound file
  122216. */
  122217. length?: number;
  122218. /**
  122219. * Defines an optional offset (in seconds) inside the sound file
  122220. */
  122221. offset?: number;
  122222. /**
  122223. * If true, URLs will not be required to state the audio file codec to use.
  122224. */
  122225. skipCodecCheck?: boolean;
  122226. }
  122227. /**
  122228. * Defines a sound that can be played in the application.
  122229. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  122230. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122231. */
  122232. export class Sound {
  122233. /**
  122234. * The name of the sound in the scene.
  122235. */
  122236. name: string;
  122237. /**
  122238. * Does the sound autoplay once loaded.
  122239. */
  122240. autoplay: boolean;
  122241. /**
  122242. * Does the sound loop after it finishes playing once.
  122243. */
  122244. loop: boolean;
  122245. /**
  122246. * Does the sound use a custom attenuation curve to simulate the falloff
  122247. * happening when the source gets further away from the camera.
  122248. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122249. */
  122250. useCustomAttenuation: boolean;
  122251. /**
  122252. * The sound track id this sound belongs to.
  122253. */
  122254. soundTrackId: number;
  122255. /**
  122256. * Is this sound currently played.
  122257. */
  122258. isPlaying: boolean;
  122259. /**
  122260. * Is this sound currently paused.
  122261. */
  122262. isPaused: boolean;
  122263. /**
  122264. * Does this sound enables spatial sound.
  122265. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122266. */
  122267. spatialSound: boolean;
  122268. /**
  122269. * Define the reference distance the sound should be heard perfectly.
  122270. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122271. */
  122272. refDistance: number;
  122273. /**
  122274. * Define the roll off factor of spatial sounds.
  122275. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122276. */
  122277. rolloffFactor: number;
  122278. /**
  122279. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  122280. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122281. */
  122282. maxDistance: number;
  122283. /**
  122284. * Define the distance attenuation model the sound will follow.
  122285. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122286. */
  122287. distanceModel: string;
  122288. /**
  122289. * @hidden
  122290. * Back Compat
  122291. **/
  122292. onended: () => any;
  122293. /**
  122294. * Gets or sets an object used to store user defined information for the sound.
  122295. */
  122296. metadata: any;
  122297. /**
  122298. * Observable event when the current playing sound finishes.
  122299. */
  122300. onEndedObservable: Observable<Sound>;
  122301. private _panningModel;
  122302. private _playbackRate;
  122303. private _streaming;
  122304. private _startTime;
  122305. private _startOffset;
  122306. private _position;
  122307. /** @hidden */
  122308. _positionInEmitterSpace: boolean;
  122309. private _localDirection;
  122310. private _volume;
  122311. private _isReadyToPlay;
  122312. private _isDirectional;
  122313. private _readyToPlayCallback;
  122314. private _audioBuffer;
  122315. private _soundSource;
  122316. private _streamingSource;
  122317. private _soundPanner;
  122318. private _soundGain;
  122319. private _inputAudioNode;
  122320. private _outputAudioNode;
  122321. private _coneInnerAngle;
  122322. private _coneOuterAngle;
  122323. private _coneOuterGain;
  122324. private _scene;
  122325. private _connectedTransformNode;
  122326. private _customAttenuationFunction;
  122327. private _registerFunc;
  122328. private _isOutputConnected;
  122329. private _htmlAudioElement;
  122330. private _urlType;
  122331. private _length?;
  122332. private _offset?;
  122333. /** @hidden */
  122334. static _SceneComponentInitialization: (scene: Scene) => void;
  122335. /**
  122336. * Create a sound and attach it to a scene
  122337. * @param name Name of your sound
  122338. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  122339. * @param scene defines the scene the sound belongs to
  122340. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  122341. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  122342. */
  122343. constructor(name: string, urlOrArrayBuffer: any, scene: Scene, readyToPlayCallback?: Nullable<() => void>, options?: ISoundOptions);
  122344. /**
  122345. * Release the sound and its associated resources
  122346. */
  122347. dispose(): void;
  122348. /**
  122349. * Gets if the sounds is ready to be played or not.
  122350. * @returns true if ready, otherwise false
  122351. */
  122352. isReady(): boolean;
  122353. private _soundLoaded;
  122354. /**
  122355. * Sets the data of the sound from an audiobuffer
  122356. * @param audioBuffer The audioBuffer containing the data
  122357. */
  122358. setAudioBuffer(audioBuffer: AudioBuffer): void;
  122359. /**
  122360. * Updates the current sounds options such as maxdistance, loop...
  122361. * @param options A JSON object containing values named as the object properties
  122362. */
  122363. updateOptions(options: ISoundOptions): void;
  122364. private _createSpatialParameters;
  122365. private _updateSpatialParameters;
  122366. /**
  122367. * Switch the panning model to HRTF:
  122368. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122369. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122370. */
  122371. switchPanningModelToHRTF(): void;
  122372. /**
  122373. * Switch the panning model to Equal Power:
  122374. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122375. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122376. */
  122377. switchPanningModelToEqualPower(): void;
  122378. private _switchPanningModel;
  122379. /**
  122380. * Connect this sound to a sound track audio node like gain...
  122381. * @param soundTrackAudioNode the sound track audio node to connect to
  122382. */
  122383. connectToSoundTrackAudioNode(soundTrackAudioNode: AudioNode): void;
  122384. /**
  122385. * Transform this sound into a directional source
  122386. * @param coneInnerAngle Size of the inner cone in degree
  122387. * @param coneOuterAngle Size of the outer cone in degree
  122388. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  122389. */
  122390. setDirectionalCone(coneInnerAngle: number, coneOuterAngle: number, coneOuterGain: number): void;
  122391. /**
  122392. * Gets or sets the inner angle for the directional cone.
  122393. */
  122394. get directionalConeInnerAngle(): number;
  122395. /**
  122396. * Gets or sets the inner angle for the directional cone.
  122397. */
  122398. set directionalConeInnerAngle(value: number);
  122399. /**
  122400. * Gets or sets the outer angle for the directional cone.
  122401. */
  122402. get directionalConeOuterAngle(): number;
  122403. /**
  122404. * Gets or sets the outer angle for the directional cone.
  122405. */
  122406. set directionalConeOuterAngle(value: number);
  122407. /**
  122408. * Sets the position of the emitter if spatial sound is enabled
  122409. * @param newPosition Defines the new posisiton
  122410. */
  122411. setPosition(newPosition: Vector3): void;
  122412. /**
  122413. * Sets the local direction of the emitter if spatial sound is enabled
  122414. * @param newLocalDirection Defines the new local direction
  122415. */
  122416. setLocalDirectionToMesh(newLocalDirection: Vector3): void;
  122417. private _updateDirection;
  122418. /** @hidden */
  122419. updateDistanceFromListener(): void;
  122420. /**
  122421. * Sets a new custom attenuation function for the sound.
  122422. * @param callback Defines the function used for the attenuation
  122423. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  122424. */
  122425. setAttenuationFunction(callback: (currentVolume: number, currentDistance: number, maxDistance: number, refDistance: number, rolloffFactor: number) => number): void;
  122426. /**
  122427. * Play the sound
  122428. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  122429. * @param offset (optional) Start the sound at a specific time in seconds
  122430. * @param length (optional) Sound duration (in seconds)
  122431. */
  122432. play(time?: number, offset?: number, length?: number): void;
  122433. private _onended;
  122434. /**
  122435. * Stop the sound
  122436. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  122437. */
  122438. stop(time?: number): void;
  122439. /**
  122440. * Put the sound in pause
  122441. */
  122442. pause(): void;
  122443. /**
  122444. * Sets a dedicated volume for this sounds
  122445. * @param newVolume Define the new volume of the sound
  122446. * @param time Define time for gradual change to new volume
  122447. */
  122448. setVolume(newVolume: number, time?: number): void;
  122449. /**
  122450. * Set the sound play back rate
  122451. * @param newPlaybackRate Define the playback rate the sound should be played at
  122452. */
  122453. setPlaybackRate(newPlaybackRate: number): void;
  122454. /**
  122455. * Gets the volume of the sound.
  122456. * @returns the volume of the sound
  122457. */
  122458. getVolume(): number;
  122459. /**
  122460. * Attach the sound to a dedicated mesh
  122461. * @param transformNode The transform node to connect the sound with
  122462. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122463. */
  122464. attachToMesh(transformNode: TransformNode): void;
  122465. /**
  122466. * Detach the sound from the previously attached mesh
  122467. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  122468. */
  122469. detachFromMesh(): void;
  122470. private _onRegisterAfterWorldMatrixUpdate;
  122471. /**
  122472. * Clone the current sound in the scene.
  122473. * @returns the new sound clone
  122474. */
  122475. clone(): Nullable<Sound>;
  122476. /**
  122477. * Gets the current underlying audio buffer containing the data
  122478. * @returns the audio buffer
  122479. */
  122480. getAudioBuffer(): Nullable<AudioBuffer>;
  122481. /**
  122482. * Gets the WebAudio AudioBufferSourceNode, lets you keep track of and stop instances of this Sound.
  122483. * @returns the source node
  122484. */
  122485. getSoundSource(): Nullable<AudioBufferSourceNode>;
  122486. /**
  122487. * Gets the WebAudio GainNode, gives you precise control over the gain of instances of this Sound.
  122488. * @returns the gain node
  122489. */
  122490. getSoundGain(): Nullable<GainNode>;
  122491. /**
  122492. * Serializes the Sound in a JSON representation
  122493. * @returns the JSON representation of the sound
  122494. */
  122495. serialize(): any;
  122496. /**
  122497. * Parse a JSON representation of a sound to innstantiate in a given scene
  122498. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  122499. * @param scene Define the scene the new parsed sound should be created in
  122500. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  122501. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  122502. * @returns the newly parsed sound
  122503. */
  122504. static Parse(parsedSound: any, scene: Scene, rootUrl: string, sourceSound?: Sound): Sound;
  122505. }
  122506. }
  122507. declare module BABYLON {
  122508. /**
  122509. * This defines an action helpful to play a defined sound on a triggered action.
  122510. */
  122511. export class PlaySoundAction extends Action {
  122512. private _sound;
  122513. /**
  122514. * Instantiate the action
  122515. * @param triggerOptions defines the trigger options
  122516. * @param sound defines the sound to play
  122517. * @param condition defines the trigger related conditions
  122518. */
  122519. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122520. /** @hidden */
  122521. _prepare(): void;
  122522. /**
  122523. * Execute the action and play the sound.
  122524. */
  122525. execute(): void;
  122526. /**
  122527. * Serializes the actions and its related information.
  122528. * @param parent defines the object to serialize in
  122529. * @returns the serialized object
  122530. */
  122531. serialize(parent: any): any;
  122532. }
  122533. /**
  122534. * This defines an action helpful to stop a defined sound on a triggered action.
  122535. */
  122536. export class StopSoundAction extends Action {
  122537. private _sound;
  122538. /**
  122539. * Instantiate the action
  122540. * @param triggerOptions defines the trigger options
  122541. * @param sound defines the sound to stop
  122542. * @param condition defines the trigger related conditions
  122543. */
  122544. constructor(triggerOptions: any, sound: Sound, condition?: Condition);
  122545. /** @hidden */
  122546. _prepare(): void;
  122547. /**
  122548. * Execute the action and stop the sound.
  122549. */
  122550. execute(): void;
  122551. /**
  122552. * Serializes the actions and its related information.
  122553. * @param parent defines the object to serialize in
  122554. * @returns the serialized object
  122555. */
  122556. serialize(parent: any): any;
  122557. }
  122558. }
  122559. declare module BABYLON {
  122560. /**
  122561. * This defines an action responsible to change the value of a property
  122562. * by interpolating between its current value and the newly set one once triggered.
  122563. * @see https://doc.babylonjs.com/how_to/how_to_use_actions
  122564. */
  122565. export class InterpolateValueAction extends Action {
  122566. /**
  122567. * Defines the path of the property where the value should be interpolated
  122568. */
  122569. propertyPath: string;
  122570. /**
  122571. * Defines the target value at the end of the interpolation.
  122572. */
  122573. value: any;
  122574. /**
  122575. * Defines the time it will take for the property to interpolate to the value.
  122576. */
  122577. duration: number;
  122578. /**
  122579. * Defines if the other scene animations should be stopped when the action has been triggered
  122580. */
  122581. stopOtherAnimations?: boolean;
  122582. /**
  122583. * Defines a callback raised once the interpolation animation has been done.
  122584. */
  122585. onInterpolationDone?: () => void;
  122586. /**
  122587. * Observable triggered once the interpolation animation has been done.
  122588. */
  122589. onInterpolationDoneObservable: Observable<InterpolateValueAction>;
  122590. private _target;
  122591. private _effectiveTarget;
  122592. private _property;
  122593. /**
  122594. * Instantiate the action
  122595. * @param triggerOptions defines the trigger options
  122596. * @param target defines the object containing the value to interpolate
  122597. * @param propertyPath defines the path to the property in the target object
  122598. * @param value defines the target value at the end of the interpolation
  122599. * @param duration deines the time it will take for the property to interpolate to the value.
  122600. * @param condition defines the trigger related conditions
  122601. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  122602. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  122603. */
  122604. constructor(triggerOptions: any, target: any, propertyPath: string, value: any, duration?: number, condition?: Condition, stopOtherAnimations?: boolean, onInterpolationDone?: () => void);
  122605. /** @hidden */
  122606. _prepare(): void;
  122607. /**
  122608. * Execute the action starts the value interpolation.
  122609. */
  122610. execute(): void;
  122611. /**
  122612. * Serializes the actions and its related information.
  122613. * @param parent defines the object to serialize in
  122614. * @returns the serialized object
  122615. */
  122616. serialize(parent: any): any;
  122617. }
  122618. }
  122619. declare module BABYLON {
  122620. /**
  122621. * Options allowed during the creation of a sound track.
  122622. */
  122623. export interface ISoundTrackOptions {
  122624. /**
  122625. * The volume the sound track should take during creation
  122626. */
  122627. volume?: number;
  122628. /**
  122629. * Define if the sound track is the main sound track of the scene
  122630. */
  122631. mainTrack?: boolean;
  122632. }
  122633. /**
  122634. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  122635. * It will be also used in a future release to apply effects on a specific track.
  122636. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122637. */
  122638. export class SoundTrack {
  122639. /**
  122640. * The unique identifier of the sound track in the scene.
  122641. */
  122642. id: number;
  122643. /**
  122644. * The list of sounds included in the sound track.
  122645. */
  122646. soundCollection: Array<Sound>;
  122647. private _outputAudioNode;
  122648. private _scene;
  122649. private _connectedAnalyser;
  122650. private _options;
  122651. private _isInitialized;
  122652. /**
  122653. * Creates a new sound track.
  122654. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  122655. * @param scene Define the scene the sound track belongs to
  122656. * @param options
  122657. */
  122658. constructor(scene: Scene, options?: ISoundTrackOptions);
  122659. private _initializeSoundTrackAudioGraph;
  122660. /**
  122661. * Release the sound track and its associated resources
  122662. */
  122663. dispose(): void;
  122664. /**
  122665. * Adds a sound to this sound track
  122666. * @param sound define the cound to add
  122667. * @ignoreNaming
  122668. */
  122669. AddSound(sound: Sound): void;
  122670. /**
  122671. * Removes a sound to this sound track
  122672. * @param sound define the cound to remove
  122673. * @ignoreNaming
  122674. */
  122675. RemoveSound(sound: Sound): void;
  122676. /**
  122677. * Set a global volume for the full sound track.
  122678. * @param newVolume Define the new volume of the sound track
  122679. */
  122680. setVolume(newVolume: number): void;
  122681. /**
  122682. * Switch the panning model to HRTF:
  122683. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  122684. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122685. */
  122686. switchPanningModelToHRTF(): void;
  122687. /**
  122688. * Switch the panning model to Equal Power:
  122689. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  122690. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  122691. */
  122692. switchPanningModelToEqualPower(): void;
  122693. /**
  122694. * Connect the sound track to an audio analyser allowing some amazing
  122695. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  122696. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  122697. * @param analyser The analyser to connect to the engine
  122698. */
  122699. connectToAnalyser(analyser: Analyser): void;
  122700. }
  122701. }
  122702. declare module BABYLON {
  122703. interface AbstractScene {
  122704. /**
  122705. * The list of sounds used in the scene.
  122706. */
  122707. sounds: Nullable<Array<Sound>>;
  122708. }
  122709. interface Scene {
  122710. /**
  122711. * @hidden
  122712. * Backing field
  122713. */
  122714. _mainSoundTrack: SoundTrack;
  122715. /**
  122716. * The main sound track played by the scene.
  122717. * It cotains your primary collection of sounds.
  122718. */
  122719. mainSoundTrack: SoundTrack;
  122720. /**
  122721. * The list of sound tracks added to the scene
  122722. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122723. */
  122724. soundTracks: Nullable<Array<SoundTrack>>;
  122725. /**
  122726. * Gets a sound using a given name
  122727. * @param name defines the name to search for
  122728. * @return the found sound or null if not found at all.
  122729. */
  122730. getSoundByName(name: string): Nullable<Sound>;
  122731. /**
  122732. * Gets or sets if audio support is enabled
  122733. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122734. */
  122735. audioEnabled: boolean;
  122736. /**
  122737. * Gets or sets if audio will be output to headphones
  122738. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122739. */
  122740. headphone: boolean;
  122741. /**
  122742. * Gets or sets custom audio listener position provider
  122743. * @see https://doc.babylonjs.com/how_to/playing_sounds_and_music
  122744. */
  122745. audioListenerPositionProvider: Nullable<() => Vector3>;
  122746. /**
  122747. * Gets or sets a refresh rate when using 3D audio positioning
  122748. */
  122749. audioPositioningRefreshRate: number;
  122750. }
  122751. /**
  122752. * Defines the sound scene component responsible to manage any sounds
  122753. * in a given scene.
  122754. */
  122755. export class AudioSceneComponent implements ISceneSerializableComponent {
  122756. private static _CameraDirectionLH;
  122757. private static _CameraDirectionRH;
  122758. /**
  122759. * The component name helpfull to identify the component in the list of scene components.
  122760. */
  122761. readonly name: string;
  122762. /**
  122763. * The scene the component belongs to.
  122764. */
  122765. scene: Scene;
  122766. private _audioEnabled;
  122767. /**
  122768. * Gets whether audio is enabled or not.
  122769. * Please use related enable/disable method to switch state.
  122770. */
  122771. get audioEnabled(): boolean;
  122772. private _headphone;
  122773. /**
  122774. * Gets whether audio is outputing to headphone or not.
  122775. * Please use the according Switch methods to change output.
  122776. */
  122777. get headphone(): boolean;
  122778. /**
  122779. * Gets or sets a refresh rate when using 3D audio positioning
  122780. */
  122781. audioPositioningRefreshRate: number;
  122782. private _audioListenerPositionProvider;
  122783. /**
  122784. * Gets the current audio listener position provider
  122785. */
  122786. get audioListenerPositionProvider(): Nullable<() => Vector3>;
  122787. /**
  122788. * Sets a custom listener position for all sounds in the scene
  122789. * By default, this is the position of the first active camera
  122790. */
  122791. set audioListenerPositionProvider(value: Nullable<() => Vector3>);
  122792. /**
  122793. * Creates a new instance of the component for the given scene
  122794. * @param scene Defines the scene to register the component in
  122795. */
  122796. constructor(scene: Scene);
  122797. /**
  122798. * Registers the component in a given scene
  122799. */
  122800. register(): void;
  122801. /**
  122802. * Rebuilds the elements related to this component in case of
  122803. * context lost for instance.
  122804. */
  122805. rebuild(): void;
  122806. /**
  122807. * Serializes the component data to the specified json object
  122808. * @param serializationObject The object to serialize to
  122809. */
  122810. serialize(serializationObject: any): void;
  122811. /**
  122812. * Adds all the elements from the container to the scene
  122813. * @param container the container holding the elements
  122814. */
  122815. addFromContainer(container: AbstractScene): void;
  122816. /**
  122817. * Removes all the elements in the container from the scene
  122818. * @param container contains the elements to remove
  122819. * @param dispose if the removed element should be disposed (default: false)
  122820. */
  122821. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  122822. /**
  122823. * Disposes the component and the associated ressources.
  122824. */
  122825. dispose(): void;
  122826. /**
  122827. * Disables audio in the associated scene.
  122828. */
  122829. disableAudio(): void;
  122830. /**
  122831. * Enables audio in the associated scene.
  122832. */
  122833. enableAudio(): void;
  122834. /**
  122835. * Switch audio to headphone output.
  122836. */
  122837. switchAudioModeForHeadphones(): void;
  122838. /**
  122839. * Switch audio to normal speakers.
  122840. */
  122841. switchAudioModeForNormalSpeakers(): void;
  122842. private _cachedCameraDirection;
  122843. private _cachedCameraPosition;
  122844. private _lastCheck;
  122845. private _afterRender;
  122846. }
  122847. }
  122848. declare module BABYLON {
  122849. /**
  122850. * Wraps one or more Sound objects and selects one with random weight for playback.
  122851. */
  122852. export class WeightedSound {
  122853. /** When true a Sound will be selected and played when the current playing Sound completes. */
  122854. loop: boolean;
  122855. private _coneInnerAngle;
  122856. private _coneOuterAngle;
  122857. private _volume;
  122858. /** A Sound is currently playing. */
  122859. isPlaying: boolean;
  122860. /** A Sound is currently paused. */
  122861. isPaused: boolean;
  122862. private _sounds;
  122863. private _weights;
  122864. private _currentIndex?;
  122865. /**
  122866. * Creates a new WeightedSound from the list of sounds given.
  122867. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  122868. * @param sounds Array of Sounds that will be selected from.
  122869. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  122870. */
  122871. constructor(loop: boolean, sounds: Sound[], weights: number[]);
  122872. /**
  122873. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  122874. */
  122875. get directionalConeInnerAngle(): number;
  122876. /**
  122877. * The size of cone in degress for a directional sound in which there will be no attenuation.
  122878. */
  122879. set directionalConeInnerAngle(value: number);
  122880. /**
  122881. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122882. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122883. */
  122884. get directionalConeOuterAngle(): number;
  122885. /**
  122886. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  122887. * Listener angles between innerAngle and outerAngle will falloff linearly.
  122888. */
  122889. set directionalConeOuterAngle(value: number);
  122890. /**
  122891. * Playback volume.
  122892. */
  122893. get volume(): number;
  122894. /**
  122895. * Playback volume.
  122896. */
  122897. set volume(value: number);
  122898. private _onended;
  122899. /**
  122900. * Suspend playback
  122901. */
  122902. pause(): void;
  122903. /**
  122904. * Stop playback
  122905. */
  122906. stop(): void;
  122907. /**
  122908. * Start playback.
  122909. * @param startOffset Position the clip head at a specific time in seconds.
  122910. */
  122911. play(startOffset?: number): void;
  122912. }
  122913. }
  122914. declare module BABYLON {
  122915. /**
  122916. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  122917. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  122918. */
  122919. export class BouncingBehavior implements Behavior<ArcRotateCamera> {
  122920. /**
  122921. * Gets the name of the behavior.
  122922. */
  122923. get name(): string;
  122924. /**
  122925. * The easing function used by animations
  122926. */
  122927. static EasingFunction: BackEase;
  122928. /**
  122929. * The easing mode used by animations
  122930. */
  122931. static EasingMode: number;
  122932. /**
  122933. * The duration of the animation, in milliseconds
  122934. */
  122935. transitionDuration: number;
  122936. /**
  122937. * Length of the distance animated by the transition when lower radius is reached
  122938. */
  122939. lowerRadiusTransitionRange: number;
  122940. /**
  122941. * Length of the distance animated by the transition when upper radius is reached
  122942. */
  122943. upperRadiusTransitionRange: number;
  122944. private _autoTransitionRange;
  122945. /**
  122946. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122947. */
  122948. get autoTransitionRange(): boolean;
  122949. /**
  122950. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  122951. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  122952. */
  122953. set autoTransitionRange(value: boolean);
  122954. private _attachedCamera;
  122955. private _onAfterCheckInputsObserver;
  122956. private _onMeshTargetChangedObserver;
  122957. /**
  122958. * Initializes the behavior.
  122959. */
  122960. init(): void;
  122961. /**
  122962. * Attaches the behavior to its arc rotate camera.
  122963. * @param camera Defines the camera to attach the behavior to
  122964. */
  122965. attach(camera: ArcRotateCamera): void;
  122966. /**
  122967. * Detaches the behavior from its current arc rotate camera.
  122968. */
  122969. detach(): void;
  122970. private _radiusIsAnimating;
  122971. private _radiusBounceTransition;
  122972. private _animatables;
  122973. private _cachedWheelPrecision;
  122974. /**
  122975. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  122976. * @param radiusLimit The limit to check against.
  122977. * @return Bool to indicate if at limit.
  122978. */
  122979. private _isRadiusAtLimit;
  122980. /**
  122981. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  122982. * @param radiusDelta The delta by which to animate to. Can be negative.
  122983. */
  122984. private _applyBoundRadiusAnimation;
  122985. /**
  122986. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  122987. */
  122988. protected _clearAnimationLocks(): void;
  122989. /**
  122990. * Stops and removes all animations that have been applied to the camera
  122991. */
  122992. stopAllAnimations(): void;
  122993. }
  122994. }
  122995. declare module BABYLON {
  122996. /**
  122997. * 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.
  122998. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  122999. */
  123000. export class FramingBehavior implements Behavior<ArcRotateCamera> {
  123001. /**
  123002. * Gets the name of the behavior.
  123003. */
  123004. get name(): string;
  123005. private _mode;
  123006. private _radiusScale;
  123007. private _positionScale;
  123008. private _defaultElevation;
  123009. private _elevationReturnTime;
  123010. private _elevationReturnWaitTime;
  123011. private _zoomStopsAnimation;
  123012. private _framingTime;
  123013. /**
  123014. * The easing function used by animations
  123015. */
  123016. static EasingFunction: ExponentialEase;
  123017. /**
  123018. * The easing mode used by animations
  123019. */
  123020. static EasingMode: number;
  123021. /**
  123022. * Sets the current mode used by the behavior
  123023. */
  123024. set mode(mode: number);
  123025. /**
  123026. * Gets current mode used by the behavior.
  123027. */
  123028. get mode(): number;
  123029. /**
  123030. * Sets the scale applied to the radius (1 by default)
  123031. */
  123032. set radiusScale(radius: number);
  123033. /**
  123034. * Gets the scale applied to the radius
  123035. */
  123036. get radiusScale(): number;
  123037. /**
  123038. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  123039. */
  123040. set positionScale(scale: number);
  123041. /**
  123042. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  123043. */
  123044. get positionScale(): number;
  123045. /**
  123046. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  123047. * behaviour is triggered, in radians.
  123048. */
  123049. set defaultElevation(elevation: number);
  123050. /**
  123051. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  123052. * behaviour is triggered, in radians.
  123053. */
  123054. get defaultElevation(): number;
  123055. /**
  123056. * Sets the time (in milliseconds) taken to return to the default beta position.
  123057. * Negative value indicates camera should not return to default.
  123058. */
  123059. set elevationReturnTime(speed: number);
  123060. /**
  123061. * Gets the time (in milliseconds) taken to return to the default beta position.
  123062. * Negative value indicates camera should not return to default.
  123063. */
  123064. get elevationReturnTime(): number;
  123065. /**
  123066. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  123067. */
  123068. set elevationReturnWaitTime(time: number);
  123069. /**
  123070. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  123071. */
  123072. get elevationReturnWaitTime(): number;
  123073. /**
  123074. * Sets the flag that indicates if user zooming should stop animation.
  123075. */
  123076. set zoomStopsAnimation(flag: boolean);
  123077. /**
  123078. * Gets the flag that indicates if user zooming should stop animation.
  123079. */
  123080. get zoomStopsAnimation(): boolean;
  123081. /**
  123082. * Sets the transition time when framing the mesh, in milliseconds
  123083. */
  123084. set framingTime(time: number);
  123085. /**
  123086. * Gets the transition time when framing the mesh, in milliseconds
  123087. */
  123088. get framingTime(): number;
  123089. /**
  123090. * Define if the behavior should automatically change the configured
  123091. * camera limits and sensibilities.
  123092. */
  123093. autoCorrectCameraLimitsAndSensibility: boolean;
  123094. private _onPrePointerObservableObserver;
  123095. private _onAfterCheckInputsObserver;
  123096. private _onMeshTargetChangedObserver;
  123097. private _attachedCamera;
  123098. private _isPointerDown;
  123099. private _lastInteractionTime;
  123100. /**
  123101. * Initializes the behavior.
  123102. */
  123103. init(): void;
  123104. /**
  123105. * Attaches the behavior to its arc rotate camera.
  123106. * @param camera Defines the camera to attach the behavior to
  123107. */
  123108. attach(camera: ArcRotateCamera): void;
  123109. /**
  123110. * Detaches the behavior from its current arc rotate camera.
  123111. */
  123112. detach(): void;
  123113. private _animatables;
  123114. private _betaIsAnimating;
  123115. private _betaTransition;
  123116. private _radiusTransition;
  123117. private _vectorTransition;
  123118. /**
  123119. * Targets the given mesh and updates zoom level accordingly.
  123120. * @param mesh The mesh to target.
  123121. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123122. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123123. */
  123124. zoomOnMesh(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123125. /**
  123126. * Targets the given mesh with its children and updates zoom level accordingly.
  123127. * @param mesh The mesh to target.
  123128. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123129. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123130. */
  123131. zoomOnMeshHierarchy(mesh: AbstractMesh, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123132. /**
  123133. * Targets the given meshes with their children and updates zoom level accordingly.
  123134. * @param meshes The mesh to target.
  123135. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123136. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123137. */
  123138. zoomOnMeshesHierarchy(meshes: AbstractMesh[], focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123139. /**
  123140. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  123141. * @param minimumWorld Determines the smaller position of the bounding box extend
  123142. * @param maximumWorld Determines the bigger position of the bounding box extend
  123143. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  123144. * @param onAnimationEnd Callback triggered at the end of the framing animation
  123145. */
  123146. zoomOnBoundingInfo(minimumWorld: Vector3, maximumWorld: Vector3, focusOnOriginXZ?: boolean, onAnimationEnd?: Nullable<() => void>): void;
  123147. /**
  123148. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  123149. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  123150. * frustum width.
  123151. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  123152. * to fully enclose the mesh in the viewing frustum.
  123153. */
  123154. protected _calculateLowerRadiusFromModelBoundingSphere(minimumWorld: Vector3, maximumWorld: Vector3): number;
  123155. /**
  123156. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  123157. * is automatically returned to its default position (expected to be above ground plane).
  123158. */
  123159. private _maintainCameraAboveGround;
  123160. /**
  123161. * Returns the frustum slope based on the canvas ratio and camera FOV
  123162. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  123163. */
  123164. private _getFrustumSlope;
  123165. /**
  123166. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  123167. */
  123168. private _clearAnimationLocks;
  123169. /**
  123170. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  123171. */
  123172. private _applyUserInteraction;
  123173. /**
  123174. * Stops and removes all animations that have been applied to the camera
  123175. */
  123176. stopAllAnimations(): void;
  123177. /**
  123178. * Gets a value indicating if the user is moving the camera
  123179. */
  123180. get isUserIsMoving(): boolean;
  123181. /**
  123182. * The camera can move all the way towards the mesh.
  123183. */
  123184. static IgnoreBoundsSizeMode: number;
  123185. /**
  123186. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  123187. */
  123188. static FitFrustumSidesMode: number;
  123189. }
  123190. }
  123191. declare module BABYLON {
  123192. /**
  123193. * Base class for Camera Pointer Inputs.
  123194. * See FollowCameraPointersInput in src/Cameras/Inputs/followCameraPointersInput.ts
  123195. * for example usage.
  123196. */
  123197. export abstract class BaseCameraPointersInput implements ICameraInput<Camera> {
  123198. /**
  123199. * Defines the camera the input is attached to.
  123200. */
  123201. abstract camera: Camera;
  123202. /**
  123203. * Whether keyboard modifier keys are pressed at time of last mouse event.
  123204. */
  123205. protected _altKey: boolean;
  123206. protected _ctrlKey: boolean;
  123207. protected _metaKey: boolean;
  123208. protected _shiftKey: boolean;
  123209. /**
  123210. * Which mouse buttons were pressed at time of last mouse event.
  123211. * https://developer.mozilla.org/en-US/docs/Web/API/MouseEvent/buttons
  123212. */
  123213. protected _buttonsPressed: number;
  123214. /**
  123215. * Defines the buttons associated with the input to handle camera move.
  123216. */
  123217. buttons: number[];
  123218. /**
  123219. * Attach the input controls to a specific dom element to get the input from.
  123220. * @param element Defines the element the controls should be listened from
  123221. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123222. */
  123223. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123224. /**
  123225. * Detach the current controls from the specified dom element.
  123226. * @param element Defines the element to stop listening the inputs from
  123227. */
  123228. detachControl(element: Nullable<HTMLElement>): void;
  123229. /**
  123230. * Gets the class name of the current input.
  123231. * @returns the class name
  123232. */
  123233. getClassName(): string;
  123234. /**
  123235. * Get the friendly name associated with the input class.
  123236. * @returns the input friendly name
  123237. */
  123238. getSimpleName(): string;
  123239. /**
  123240. * Called on pointer POINTERDOUBLETAP event.
  123241. * Override this method to provide functionality on POINTERDOUBLETAP event.
  123242. */
  123243. protected onDoubleTap(type: string): void;
  123244. /**
  123245. * Called on pointer POINTERMOVE event if only a single touch is active.
  123246. * Override this method to provide functionality.
  123247. */
  123248. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123249. /**
  123250. * Called on pointer POINTERMOVE event if multiple touches are active.
  123251. * Override this method to provide functionality.
  123252. */
  123253. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123254. /**
  123255. * Called on JS contextmenu event.
  123256. * Override this method to provide functionality.
  123257. */
  123258. protected onContextMenu(evt: PointerEvent): void;
  123259. /**
  123260. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123261. * press.
  123262. * Override this method to provide functionality.
  123263. */
  123264. protected onButtonDown(evt: PointerEvent): void;
  123265. /**
  123266. * Called each time a new POINTERUP event occurs. Ie, for each button
  123267. * release.
  123268. * Override this method to provide functionality.
  123269. */
  123270. protected onButtonUp(evt: PointerEvent): void;
  123271. /**
  123272. * Called when window becomes inactive.
  123273. * Override this method to provide functionality.
  123274. */
  123275. protected onLostFocus(): void;
  123276. private _pointerInput;
  123277. private _observer;
  123278. private _onLostFocus;
  123279. private pointA;
  123280. private pointB;
  123281. }
  123282. }
  123283. declare module BABYLON {
  123284. /**
  123285. * Manage the pointers inputs to control an arc rotate camera.
  123286. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123287. */
  123288. export class ArcRotateCameraPointersInput extends BaseCameraPointersInput {
  123289. /**
  123290. * Defines the camera the input is attached to.
  123291. */
  123292. camera: ArcRotateCamera;
  123293. /**
  123294. * Gets the class name of the current input.
  123295. * @returns the class name
  123296. */
  123297. getClassName(): string;
  123298. /**
  123299. * Defines the buttons associated with the input to handle camera move.
  123300. */
  123301. buttons: number[];
  123302. /**
  123303. * Defines the pointer angular sensibility along the X axis or how fast is
  123304. * the camera rotating.
  123305. */
  123306. angularSensibilityX: number;
  123307. /**
  123308. * Defines the pointer angular sensibility along the Y axis or how fast is
  123309. * the camera rotating.
  123310. */
  123311. angularSensibilityY: number;
  123312. /**
  123313. * Defines the pointer pinch precision or how fast is the camera zooming.
  123314. */
  123315. pinchPrecision: number;
  123316. /**
  123317. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  123318. * from 0.
  123319. * It defines the percentage of current camera.radius to use as delta when
  123320. * pinch zoom is used.
  123321. */
  123322. pinchDeltaPercentage: number;
  123323. /**
  123324. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123325. * that any object in the plane at the camera's target point will scale
  123326. * perfectly with finger motion.
  123327. * Overrides pinchDeltaPercentage and pinchPrecision.
  123328. */
  123329. useNaturalPinchZoom: boolean;
  123330. /**
  123331. * Defines the pointer panning sensibility or how fast is the camera moving.
  123332. */
  123333. panningSensibility: number;
  123334. /**
  123335. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  123336. */
  123337. multiTouchPanning: boolean;
  123338. /**
  123339. * Defines whether panning is enabled for both pan (2 fingers swipe) and
  123340. * zoom (pinch) through multitouch.
  123341. */
  123342. multiTouchPanAndZoom: boolean;
  123343. /**
  123344. * Revers pinch action direction.
  123345. */
  123346. pinchInwards: boolean;
  123347. private _isPanClick;
  123348. private _twoFingerActivityCount;
  123349. private _isPinching;
  123350. /**
  123351. * Called on pointer POINTERMOVE event if only a single touch is active.
  123352. */
  123353. protected onTouch(point: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  123354. /**
  123355. * Called on pointer POINTERDOUBLETAP event.
  123356. */
  123357. protected onDoubleTap(type: string): void;
  123358. /**
  123359. * Called on pointer POINTERMOVE event if multiple touches are active.
  123360. */
  123361. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  123362. /**
  123363. * Called each time a new POINTERDOWN event occurs. Ie, for each button
  123364. * press.
  123365. */
  123366. protected onButtonDown(evt: PointerEvent): void;
  123367. /**
  123368. * Called each time a new POINTERUP event occurs. Ie, for each button
  123369. * release.
  123370. */
  123371. protected onButtonUp(evt: PointerEvent): void;
  123372. /**
  123373. * Called when window becomes inactive.
  123374. */
  123375. protected onLostFocus(): void;
  123376. }
  123377. }
  123378. declare module BABYLON {
  123379. /**
  123380. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  123381. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123382. */
  123383. export class ArcRotateCameraKeyboardMoveInput implements ICameraInput<ArcRotateCamera> {
  123384. /**
  123385. * Defines the camera the input is attached to.
  123386. */
  123387. camera: ArcRotateCamera;
  123388. /**
  123389. * Defines the list of key codes associated with the up action (increase alpha)
  123390. */
  123391. keysUp: number[];
  123392. /**
  123393. * Defines the list of key codes associated with the down action (decrease alpha)
  123394. */
  123395. keysDown: number[];
  123396. /**
  123397. * Defines the list of key codes associated with the left action (increase beta)
  123398. */
  123399. keysLeft: number[];
  123400. /**
  123401. * Defines the list of key codes associated with the right action (decrease beta)
  123402. */
  123403. keysRight: number[];
  123404. /**
  123405. * Defines the list of key codes associated with the reset action.
  123406. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  123407. */
  123408. keysReset: number[];
  123409. /**
  123410. * Defines the panning sensibility of the inputs.
  123411. * (How fast is the camera panning)
  123412. */
  123413. panningSensibility: number;
  123414. /**
  123415. * Defines the zooming sensibility of the inputs.
  123416. * (How fast is the camera zooming)
  123417. */
  123418. zoomingSensibility: number;
  123419. /**
  123420. * Defines whether maintaining the alt key down switch the movement mode from
  123421. * orientation to zoom.
  123422. */
  123423. useAltToZoom: boolean;
  123424. /**
  123425. * Rotation speed of the camera
  123426. */
  123427. angularSpeed: number;
  123428. private _keys;
  123429. private _ctrlPressed;
  123430. private _altPressed;
  123431. private _onCanvasBlurObserver;
  123432. private _onKeyboardObserver;
  123433. private _engine;
  123434. private _scene;
  123435. /**
  123436. * Attach the input controls to a specific dom element to get the input from.
  123437. * @param element Defines the element the controls should be listened from
  123438. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123439. */
  123440. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123441. /**
  123442. * Detach the current controls from the specified dom element.
  123443. * @param element Defines the element to stop listening the inputs from
  123444. */
  123445. detachControl(element: Nullable<HTMLElement>): void;
  123446. /**
  123447. * Update the current camera state depending on the inputs that have been used this frame.
  123448. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  123449. */
  123450. checkInputs(): void;
  123451. /**
  123452. * Gets the class name of the current intput.
  123453. * @returns the class name
  123454. */
  123455. getClassName(): string;
  123456. /**
  123457. * Get the friendly name associated with the input class.
  123458. * @returns the input friendly name
  123459. */
  123460. getSimpleName(): string;
  123461. }
  123462. }
  123463. declare module BABYLON {
  123464. /**
  123465. * Manage the mouse wheel inputs to control an arc rotate camera.
  123466. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123467. */
  123468. export class ArcRotateCameraMouseWheelInput implements ICameraInput<ArcRotateCamera> {
  123469. /**
  123470. * Defines the camera the input is attached to.
  123471. */
  123472. camera: ArcRotateCamera;
  123473. /**
  123474. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123475. */
  123476. wheelPrecision: number;
  123477. /**
  123478. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  123479. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  123480. */
  123481. wheelDeltaPercentage: number;
  123482. private _wheel;
  123483. private _observer;
  123484. private computeDeltaFromMouseWheelLegacyEvent;
  123485. /**
  123486. * Attach the input controls to a specific dom element to get the input from.
  123487. * @param element Defines the element the controls should be listened from
  123488. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123489. */
  123490. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  123491. /**
  123492. * Detach the current controls from the specified dom element.
  123493. * @param element Defines the element to stop listening the inputs from
  123494. */
  123495. detachControl(element: Nullable<HTMLElement>): void;
  123496. /**
  123497. * Gets the class name of the current intput.
  123498. * @returns the class name
  123499. */
  123500. getClassName(): string;
  123501. /**
  123502. * Get the friendly name associated with the input class.
  123503. * @returns the input friendly name
  123504. */
  123505. getSimpleName(): string;
  123506. }
  123507. }
  123508. declare module BABYLON {
  123509. /**
  123510. * Default Inputs manager for the ArcRotateCamera.
  123511. * It groups all the default supported inputs for ease of use.
  123512. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  123513. */
  123514. export class ArcRotateCameraInputsManager extends CameraInputsManager<ArcRotateCamera> {
  123515. /**
  123516. * Instantiates a new ArcRotateCameraInputsManager.
  123517. * @param camera Defines the camera the inputs belong to
  123518. */
  123519. constructor(camera: ArcRotateCamera);
  123520. /**
  123521. * Add mouse wheel input support to the input manager.
  123522. * @returns the current input manager
  123523. */
  123524. addMouseWheel(): ArcRotateCameraInputsManager;
  123525. /**
  123526. * Add pointers input support to the input manager.
  123527. * @returns the current input manager
  123528. */
  123529. addPointers(): ArcRotateCameraInputsManager;
  123530. /**
  123531. * Add keyboard input support to the input manager.
  123532. * @returns the current input manager
  123533. */
  123534. addKeyboard(): ArcRotateCameraInputsManager;
  123535. }
  123536. }
  123537. declare module BABYLON {
  123538. /**
  123539. * This represents an orbital type of camera.
  123540. *
  123541. * 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.
  123542. * 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.
  123543. * @see https://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  123544. */
  123545. export class ArcRotateCamera extends TargetCamera {
  123546. /**
  123547. * Defines the rotation angle of the camera along the longitudinal axis.
  123548. */
  123549. alpha: number;
  123550. /**
  123551. * Defines the rotation angle of the camera along the latitudinal axis.
  123552. */
  123553. beta: number;
  123554. /**
  123555. * Defines the radius of the camera from it s target point.
  123556. */
  123557. radius: number;
  123558. protected _target: Vector3;
  123559. protected _targetHost: Nullable<AbstractMesh>;
  123560. /**
  123561. * Defines the target point of the camera.
  123562. * The camera looks towards it form the radius distance.
  123563. * Please note that you can set the target to a mesh and thus the target will be copied from mesh.position
  123564. */
  123565. get target(): Vector3;
  123566. set target(value: Vector3);
  123567. /**
  123568. * Define the current local position of the camera in the scene
  123569. */
  123570. get position(): Vector3;
  123571. set position(newPosition: Vector3);
  123572. protected _upToYMatrix: Matrix;
  123573. protected _YToUpMatrix: Matrix;
  123574. /**
  123575. * The vector the camera should consider as up. (default is Vector3(0, 1, 0) as returned by Vector3.Up())
  123576. * Setting this will copy the given vector to the camera's upVector, and set rotation matrices to and from Y up.
  123577. * DO NOT set the up vector using copyFrom or copyFromFloats, as this bypasses setting the above matrices.
  123578. */
  123579. set upVector(vec: Vector3);
  123580. get upVector(): Vector3;
  123581. /**
  123582. * Sets the Y-up to camera up-vector rotation matrix, and the up-vector to Y-up rotation matrix.
  123583. */
  123584. setMatUp(): void;
  123585. /**
  123586. * Current inertia value on the longitudinal axis.
  123587. * The bigger this number the longer it will take for the camera to stop.
  123588. */
  123589. inertialAlphaOffset: number;
  123590. /**
  123591. * Current inertia value on the latitudinal axis.
  123592. * The bigger this number the longer it will take for the camera to stop.
  123593. */
  123594. inertialBetaOffset: number;
  123595. /**
  123596. * Current inertia value on the radius axis.
  123597. * The bigger this number the longer it will take for the camera to stop.
  123598. */
  123599. inertialRadiusOffset: number;
  123600. /**
  123601. * Minimum allowed angle on the longitudinal axis.
  123602. * This can help limiting how the Camera is able to move in the scene.
  123603. */
  123604. lowerAlphaLimit: Nullable<number>;
  123605. /**
  123606. * Maximum allowed angle on the longitudinal axis.
  123607. * This can help limiting how the Camera is able to move in the scene.
  123608. */
  123609. upperAlphaLimit: Nullable<number>;
  123610. /**
  123611. * Minimum allowed angle on the latitudinal axis.
  123612. * This can help limiting how the Camera is able to move in the scene.
  123613. */
  123614. lowerBetaLimit: number;
  123615. /**
  123616. * Maximum allowed angle on the latitudinal axis.
  123617. * This can help limiting how the Camera is able to move in the scene.
  123618. */
  123619. upperBetaLimit: number;
  123620. /**
  123621. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  123622. * This can help limiting how the Camera is able to move in the scene.
  123623. */
  123624. lowerRadiusLimit: Nullable<number>;
  123625. /**
  123626. * Maximum allowed distance of the camera to the target (The camera can not get further).
  123627. * This can help limiting how the Camera is able to move in the scene.
  123628. */
  123629. upperRadiusLimit: Nullable<number>;
  123630. /**
  123631. * Defines the current inertia value used during panning of the camera along the X axis.
  123632. */
  123633. inertialPanningX: number;
  123634. /**
  123635. * Defines the current inertia value used during panning of the camera along the Y axis.
  123636. */
  123637. inertialPanningY: number;
  123638. /**
  123639. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  123640. * Basically if your fingers moves away from more than this distance you will be considered
  123641. * in pinch mode.
  123642. */
  123643. pinchToPanMaxDistance: number;
  123644. /**
  123645. * Defines the maximum distance the camera can pan.
  123646. * This could help keeping the cammera always in your scene.
  123647. */
  123648. panningDistanceLimit: Nullable<number>;
  123649. /**
  123650. * Defines the target of the camera before paning.
  123651. */
  123652. panningOriginTarget: Vector3;
  123653. /**
  123654. * Defines the value of the inertia used during panning.
  123655. * 0 would mean stop inertia and one would mean no decelleration at all.
  123656. */
  123657. panningInertia: number;
  123658. /**
  123659. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  123660. */
  123661. get angularSensibilityX(): number;
  123662. set angularSensibilityX(value: number);
  123663. /**
  123664. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  123665. */
  123666. get angularSensibilityY(): number;
  123667. set angularSensibilityY(value: number);
  123668. /**
  123669. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  123670. */
  123671. get pinchPrecision(): number;
  123672. set pinchPrecision(value: number);
  123673. /**
  123674. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  123675. * It will be used instead of pinchDeltaPrecision if different from 0.
  123676. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123677. */
  123678. get pinchDeltaPercentage(): number;
  123679. set pinchDeltaPercentage(value: number);
  123680. /**
  123681. * Gets or Set the pointer use natural pinch zoom to override the pinch precision
  123682. * and pinch delta percentage.
  123683. * When useNaturalPinchZoom is true, multi touch zoom will zoom in such
  123684. * that any object in the plane at the camera's target point will scale
  123685. * perfectly with finger motion.
  123686. */
  123687. get useNaturalPinchZoom(): boolean;
  123688. set useNaturalPinchZoom(value: boolean);
  123689. /**
  123690. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  123691. */
  123692. get panningSensibility(): number;
  123693. set panningSensibility(value: number);
  123694. /**
  123695. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  123696. */
  123697. get keysUp(): number[];
  123698. set keysUp(value: number[]);
  123699. /**
  123700. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  123701. */
  123702. get keysDown(): number[];
  123703. set keysDown(value: number[]);
  123704. /**
  123705. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  123706. */
  123707. get keysLeft(): number[];
  123708. set keysLeft(value: number[]);
  123709. /**
  123710. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  123711. */
  123712. get keysRight(): number[];
  123713. set keysRight(value: number[]);
  123714. /**
  123715. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  123716. */
  123717. get wheelPrecision(): number;
  123718. set wheelPrecision(value: number);
  123719. /**
  123720. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  123721. * It will be used instead of pinchDeltaPrecision if different from 0.
  123722. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  123723. */
  123724. get wheelDeltaPercentage(): number;
  123725. set wheelDeltaPercentage(value: number);
  123726. /**
  123727. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  123728. */
  123729. zoomOnFactor: number;
  123730. /**
  123731. * Defines a screen offset for the camera position.
  123732. */
  123733. targetScreenOffset: Vector2;
  123734. /**
  123735. * Allows the camera to be completely reversed.
  123736. * If false the camera can not arrive upside down.
  123737. */
  123738. allowUpsideDown: boolean;
  123739. /**
  123740. * Define if double tap/click is used to restore the previously saved state of the camera.
  123741. */
  123742. useInputToRestoreState: boolean;
  123743. /** @hidden */
  123744. _viewMatrix: Matrix;
  123745. /** @hidden */
  123746. _useCtrlForPanning: boolean;
  123747. /** @hidden */
  123748. _panningMouseButton: number;
  123749. /**
  123750. * Defines the input associated to the camera.
  123751. */
  123752. inputs: ArcRotateCameraInputsManager;
  123753. /** @hidden */
  123754. _reset: () => void;
  123755. /**
  123756. * Defines the allowed panning axis.
  123757. */
  123758. panningAxis: Vector3;
  123759. protected _localDirection: Vector3;
  123760. protected _transformedDirection: Vector3;
  123761. private _bouncingBehavior;
  123762. /**
  123763. * Gets the bouncing behavior of the camera if it has been enabled.
  123764. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123765. */
  123766. get bouncingBehavior(): Nullable<BouncingBehavior>;
  123767. /**
  123768. * Defines if the bouncing behavior of the camera is enabled on the camera.
  123769. * @see https://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  123770. */
  123771. get useBouncingBehavior(): boolean;
  123772. set useBouncingBehavior(value: boolean);
  123773. private _framingBehavior;
  123774. /**
  123775. * Gets the framing behavior of the camera if it has been enabled.
  123776. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123777. */
  123778. get framingBehavior(): Nullable<FramingBehavior>;
  123779. /**
  123780. * Defines if the framing behavior of the camera is enabled on the camera.
  123781. * @see https://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  123782. */
  123783. get useFramingBehavior(): boolean;
  123784. set useFramingBehavior(value: boolean);
  123785. private _autoRotationBehavior;
  123786. /**
  123787. * Gets the auto rotation behavior of the camera if it has been enabled.
  123788. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123789. */
  123790. get autoRotationBehavior(): Nullable<AutoRotationBehavior>;
  123791. /**
  123792. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  123793. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123794. */
  123795. get useAutoRotationBehavior(): boolean;
  123796. set useAutoRotationBehavior(value: boolean);
  123797. /**
  123798. * Observable triggered when the mesh target has been changed on the camera.
  123799. */
  123800. onMeshTargetChangedObservable: Observable<Nullable<AbstractMesh>>;
  123801. /**
  123802. * Event raised when the camera is colliding with a mesh.
  123803. */
  123804. onCollide: (collidedMesh: AbstractMesh) => void;
  123805. /**
  123806. * Defines whether the camera should check collision with the objects oh the scene.
  123807. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  123808. */
  123809. checkCollisions: boolean;
  123810. /**
  123811. * Defines the collision radius of the camera.
  123812. * This simulates a sphere around the camera.
  123813. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  123814. */
  123815. collisionRadius: Vector3;
  123816. protected _collider: Collider;
  123817. protected _previousPosition: Vector3;
  123818. protected _collisionVelocity: Vector3;
  123819. protected _newPosition: Vector3;
  123820. protected _previousAlpha: number;
  123821. protected _previousBeta: number;
  123822. protected _previousRadius: number;
  123823. protected _collisionTriggered: boolean;
  123824. protected _targetBoundingCenter: Nullable<Vector3>;
  123825. private _computationVector;
  123826. /**
  123827. * Instantiates a new ArcRotateCamera in a given scene
  123828. * @param name Defines the name of the camera
  123829. * @param alpha Defines the camera rotation along the logitudinal axis
  123830. * @param beta Defines the camera rotation along the latitudinal axis
  123831. * @param radius Defines the camera distance from its target
  123832. * @param target Defines the camera target
  123833. * @param scene Defines the scene the camera belongs to
  123834. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  123835. */
  123836. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  123837. /** @hidden */
  123838. _initCache(): void;
  123839. /** @hidden */
  123840. _updateCache(ignoreParentClass?: boolean): void;
  123841. protected _getTargetPosition(): Vector3;
  123842. private _storedAlpha;
  123843. private _storedBeta;
  123844. private _storedRadius;
  123845. private _storedTarget;
  123846. private _storedTargetScreenOffset;
  123847. /**
  123848. * Stores the current state of the camera (alpha, beta, radius and target)
  123849. * @returns the camera itself
  123850. */
  123851. storeState(): Camera;
  123852. /**
  123853. * @hidden
  123854. * Restored camera state. You must call storeState() first
  123855. */
  123856. _restoreStateValues(): boolean;
  123857. /** @hidden */
  123858. _isSynchronizedViewMatrix(): boolean;
  123859. /**
  123860. * Attached controls to the current camera.
  123861. * @param element Defines the element the controls should be listened from
  123862. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  123863. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  123864. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  123865. */
  123866. attachControl(element: HTMLElement, noPreventDefault?: boolean, useCtrlForPanning?: boolean, panningMouseButton?: number): void;
  123867. /**
  123868. * Detach the current controls from the camera.
  123869. * The camera will stop reacting to inputs.
  123870. * @param element Defines the element to stop listening the inputs from
  123871. */
  123872. detachControl(element: HTMLElement): void;
  123873. /** @hidden */
  123874. _checkInputs(): void;
  123875. protected _checkLimits(): void;
  123876. /**
  123877. * Rebuilds angles (alpha, beta) and radius from the give position and target
  123878. */
  123879. rebuildAnglesAndRadius(): void;
  123880. /**
  123881. * Use a position to define the current camera related information like alpha, beta and radius
  123882. * @param position Defines the position to set the camera at
  123883. */
  123884. setPosition(position: Vector3): void;
  123885. /**
  123886. * Defines the target the camera should look at.
  123887. * This will automatically adapt alpha beta and radius to fit within the new target.
  123888. * @param target Defines the new target as a Vector or a mesh
  123889. * @param toBoundingCenter In case of a mesh target, defines whether to target the mesh position or its bounding information center
  123890. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  123891. */
  123892. setTarget(target: AbstractMesh | Vector3, toBoundingCenter?: boolean, allowSamePosition?: boolean): void;
  123893. /** @hidden */
  123894. _getViewMatrix(): Matrix;
  123895. protected _onCollisionPositionChange: (collisionId: number, newPosition: Vector3, collidedMesh?: Nullable<AbstractMesh>) => void;
  123896. /**
  123897. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  123898. * @param meshes Defines the mesh to zoom on
  123899. * @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)
  123900. */
  123901. zoomOn(meshes?: AbstractMesh[], doNotUpdateMaxZ?: boolean): void;
  123902. /**
  123903. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  123904. * The target will be changed but the radius
  123905. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  123906. * @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)
  123907. */
  123908. focusOn(meshesOrMinMaxVectorAndDistance: AbstractMesh[] | {
  123909. min: Vector3;
  123910. max: Vector3;
  123911. distance: number;
  123912. }, doNotUpdateMaxZ?: boolean): void;
  123913. /**
  123914. * @override
  123915. * Override Camera.createRigCamera
  123916. */
  123917. createRigCamera(name: string, cameraIndex: number): Camera;
  123918. /**
  123919. * @hidden
  123920. * @override
  123921. * Override Camera._updateRigCameras
  123922. */
  123923. _updateRigCameras(): void;
  123924. /**
  123925. * Destroy the camera and release the current resources hold by it.
  123926. */
  123927. dispose(): void;
  123928. /**
  123929. * Gets the current object class name.
  123930. * @return the class name
  123931. */
  123932. getClassName(): string;
  123933. }
  123934. }
  123935. declare module BABYLON {
  123936. /**
  123937. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  123938. * @see https://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  123939. */
  123940. export class AutoRotationBehavior implements Behavior<ArcRotateCamera> {
  123941. /**
  123942. * Gets the name of the behavior.
  123943. */
  123944. get name(): string;
  123945. private _zoomStopsAnimation;
  123946. private _idleRotationSpeed;
  123947. private _idleRotationWaitTime;
  123948. private _idleRotationSpinupTime;
  123949. /**
  123950. * Sets the flag that indicates if user zooming should stop animation.
  123951. */
  123952. set zoomStopsAnimation(flag: boolean);
  123953. /**
  123954. * Gets the flag that indicates if user zooming should stop animation.
  123955. */
  123956. get zoomStopsAnimation(): boolean;
  123957. /**
  123958. * Sets the default speed at which the camera rotates around the model.
  123959. */
  123960. set idleRotationSpeed(speed: number);
  123961. /**
  123962. * Gets the default speed at which the camera rotates around the model.
  123963. */
  123964. get idleRotationSpeed(): number;
  123965. /**
  123966. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  123967. */
  123968. set idleRotationWaitTime(time: number);
  123969. /**
  123970. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  123971. */
  123972. get idleRotationWaitTime(): number;
  123973. /**
  123974. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123975. */
  123976. set idleRotationSpinupTime(time: number);
  123977. /**
  123978. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  123979. */
  123980. get idleRotationSpinupTime(): number;
  123981. /**
  123982. * Gets a value indicating if the camera is currently rotating because of this behavior
  123983. */
  123984. get rotationInProgress(): boolean;
  123985. private _onPrePointerObservableObserver;
  123986. private _onAfterCheckInputsObserver;
  123987. private _attachedCamera;
  123988. private _isPointerDown;
  123989. private _lastFrameTime;
  123990. private _lastInteractionTime;
  123991. private _cameraRotationSpeed;
  123992. /**
  123993. * Initializes the behavior.
  123994. */
  123995. init(): void;
  123996. /**
  123997. * Attaches the behavior to its arc rotate camera.
  123998. * @param camera Defines the camera to attach the behavior to
  123999. */
  124000. attach(camera: ArcRotateCamera): void;
  124001. /**
  124002. * Detaches the behavior from its current arc rotate camera.
  124003. */
  124004. detach(): void;
  124005. /**
  124006. * Returns true if user is scrolling.
  124007. * @return true if user is scrolling.
  124008. */
  124009. private _userIsZooming;
  124010. private _lastFrameRadius;
  124011. private _shouldAnimationStopForInteraction;
  124012. /**
  124013. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  124014. */
  124015. private _applyUserInteraction;
  124016. private _userIsMoving;
  124017. }
  124018. }
  124019. declare module BABYLON {
  124020. /**
  124021. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  124022. */
  124023. export class AttachToBoxBehavior implements Behavior<Mesh> {
  124024. private ui;
  124025. /**
  124026. * The name of the behavior
  124027. */
  124028. name: string;
  124029. /**
  124030. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  124031. */
  124032. distanceAwayFromFace: number;
  124033. /**
  124034. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  124035. */
  124036. distanceAwayFromBottomOfFace: number;
  124037. private _faceVectors;
  124038. private _target;
  124039. private _scene;
  124040. private _onRenderObserver;
  124041. private _tmpMatrix;
  124042. private _tmpVector;
  124043. /**
  124044. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  124045. * @param ui The transform node that should be attched to the mesh
  124046. */
  124047. constructor(ui: TransformNode);
  124048. /**
  124049. * Initializes the behavior
  124050. */
  124051. init(): void;
  124052. private _closestFace;
  124053. private _zeroVector;
  124054. private _lookAtTmpMatrix;
  124055. private _lookAtToRef;
  124056. /**
  124057. * Attaches the AttachToBoxBehavior to the passed in mesh
  124058. * @param target The mesh that the specified node will be attached to
  124059. */
  124060. attach(target: Mesh): void;
  124061. /**
  124062. * Detaches the behavior from the mesh
  124063. */
  124064. detach(): void;
  124065. }
  124066. }
  124067. declare module BABYLON {
  124068. /**
  124069. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  124070. */
  124071. export class FadeInOutBehavior implements Behavior<Mesh> {
  124072. /**
  124073. * Time in milliseconds to delay before fading in (Default: 0)
  124074. */
  124075. delay: number;
  124076. /**
  124077. * Time in milliseconds for the mesh to fade in (Default: 300)
  124078. */
  124079. fadeInTime: number;
  124080. private _millisecondsPerFrame;
  124081. private _hovered;
  124082. private _hoverValue;
  124083. private _ownerNode;
  124084. /**
  124085. * Instatiates the FadeInOutBehavior
  124086. */
  124087. constructor();
  124088. /**
  124089. * The name of the behavior
  124090. */
  124091. get name(): string;
  124092. /**
  124093. * Initializes the behavior
  124094. */
  124095. init(): void;
  124096. /**
  124097. * Attaches the fade behavior on the passed in mesh
  124098. * @param ownerNode The mesh that will be faded in/out once attached
  124099. */
  124100. attach(ownerNode: Mesh): void;
  124101. /**
  124102. * Detaches the behavior from the mesh
  124103. */
  124104. detach(): void;
  124105. /**
  124106. * Triggers the mesh to begin fading in or out
  124107. * @param value if the object should fade in or out (true to fade in)
  124108. */
  124109. fadeIn(value: boolean): void;
  124110. private _update;
  124111. private _setAllVisibility;
  124112. }
  124113. }
  124114. declare module BABYLON {
  124115. /**
  124116. * Class containing a set of static utilities functions for managing Pivots
  124117. * @hidden
  124118. */
  124119. export class PivotTools {
  124120. private static _PivotCached;
  124121. private static _OldPivotPoint;
  124122. private static _PivotTranslation;
  124123. private static _PivotTmpVector;
  124124. private static _PivotPostMultiplyPivotMatrix;
  124125. /** @hidden */
  124126. static _RemoveAndStorePivotPoint(mesh: AbstractMesh): void;
  124127. /** @hidden */
  124128. static _RestorePivotPoint(mesh: AbstractMesh): void;
  124129. }
  124130. }
  124131. declare module BABYLON {
  124132. /**
  124133. * Class containing static functions to help procedurally build meshes
  124134. */
  124135. export class PlaneBuilder {
  124136. /**
  124137. * Creates a plane mesh
  124138. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  124139. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  124140. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  124141. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  124142. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  124143. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  124144. * @param name defines the name of the mesh
  124145. * @param options defines the options used to create the mesh
  124146. * @param scene defines the hosting scene
  124147. * @returns the plane mesh
  124148. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  124149. */
  124150. static CreatePlane(name: string, options: {
  124151. size?: number;
  124152. width?: number;
  124153. height?: number;
  124154. sideOrientation?: number;
  124155. frontUVs?: Vector4;
  124156. backUVs?: Vector4;
  124157. updatable?: boolean;
  124158. sourcePlane?: Plane;
  124159. }, scene?: Nullable<Scene>): Mesh;
  124160. }
  124161. }
  124162. declare module BABYLON {
  124163. /**
  124164. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  124165. */
  124166. export class PointerDragBehavior implements Behavior<AbstractMesh> {
  124167. private static _AnyMouseID;
  124168. /**
  124169. * Abstract mesh the behavior is set on
  124170. */
  124171. attachedNode: AbstractMesh;
  124172. private _dragPlane;
  124173. private _scene;
  124174. private _pointerObserver;
  124175. private _beforeRenderObserver;
  124176. private static _planeScene;
  124177. private _useAlternatePickedPointAboveMaxDragAngleDragSpeed;
  124178. /**
  124179. * 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)
  124180. */
  124181. maxDragAngle: number;
  124182. /**
  124183. * @hidden
  124184. */
  124185. _useAlternatePickedPointAboveMaxDragAngle: boolean;
  124186. /**
  124187. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124188. */
  124189. currentDraggingPointerID: number;
  124190. /**
  124191. * The last position where the pointer hit the drag plane in world space
  124192. */
  124193. lastDragPosition: Vector3;
  124194. /**
  124195. * If the behavior is currently in a dragging state
  124196. */
  124197. dragging: boolean;
  124198. /**
  124199. * 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)
  124200. */
  124201. dragDeltaRatio: number;
  124202. /**
  124203. * If the drag plane orientation should be updated during the dragging (Default: true)
  124204. */
  124205. updateDragPlane: boolean;
  124206. private _debugMode;
  124207. private _moving;
  124208. /**
  124209. * Fires each time the attached mesh is dragged with the pointer
  124210. * * delta between last drag position and current drag position in world space
  124211. * * dragDistance along the drag axis
  124212. * * dragPlaneNormal normal of the current drag plane used during the drag
  124213. * * dragPlanePoint in world space where the drag intersects the drag plane
  124214. */
  124215. onDragObservable: Observable<{
  124216. delta: Vector3;
  124217. dragPlanePoint: Vector3;
  124218. dragPlaneNormal: Vector3;
  124219. dragDistance: number;
  124220. pointerId: number;
  124221. }>;
  124222. /**
  124223. * Fires each time a drag begins (eg. mouse down on mesh)
  124224. */
  124225. onDragStartObservable: Observable<{
  124226. dragPlanePoint: Vector3;
  124227. pointerId: number;
  124228. }>;
  124229. /**
  124230. * Fires each time a drag ends (eg. mouse release after drag)
  124231. */
  124232. onDragEndObservable: Observable<{
  124233. dragPlanePoint: Vector3;
  124234. pointerId: number;
  124235. }>;
  124236. /**
  124237. * If the attached mesh should be moved when dragged
  124238. */
  124239. moveAttached: boolean;
  124240. /**
  124241. * If the drag behavior will react to drag events (Default: true)
  124242. */
  124243. enabled: boolean;
  124244. /**
  124245. * If pointer events should start and release the drag (Default: true)
  124246. */
  124247. startAndReleaseDragOnPointerEvents: boolean;
  124248. /**
  124249. * If camera controls should be detached during the drag
  124250. */
  124251. detachCameraControls: boolean;
  124252. /**
  124253. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  124254. */
  124255. useObjectOrientationForDragging: boolean;
  124256. private _options;
  124257. /**
  124258. * Gets the options used by the behavior
  124259. */
  124260. get options(): {
  124261. dragAxis?: Vector3;
  124262. dragPlaneNormal?: Vector3;
  124263. };
  124264. /**
  124265. * Sets the options used by the behavior
  124266. */
  124267. set options(options: {
  124268. dragAxis?: Vector3;
  124269. dragPlaneNormal?: Vector3;
  124270. });
  124271. /**
  124272. * Creates a pointer drag behavior that can be attached to a mesh
  124273. * @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)
  124274. */
  124275. constructor(options?: {
  124276. dragAxis?: Vector3;
  124277. dragPlaneNormal?: Vector3;
  124278. });
  124279. /**
  124280. * Predicate to determine if it is valid to move the object to a new position when it is moved
  124281. */
  124282. validateDrag: (targetPosition: Vector3) => boolean;
  124283. /**
  124284. * The name of the behavior
  124285. */
  124286. get name(): string;
  124287. /**
  124288. * Initializes the behavior
  124289. */
  124290. init(): void;
  124291. private _tmpVector;
  124292. private _alternatePickedPoint;
  124293. private _worldDragAxis;
  124294. private _targetPosition;
  124295. private _attachedElement;
  124296. /**
  124297. * Attaches the drag behavior the passed in mesh
  124298. * @param ownerNode The mesh that will be dragged around once attached
  124299. * @param predicate Predicate to use for pick filtering
  124300. */
  124301. attach(ownerNode: AbstractMesh, predicate?: (m: AbstractMesh) => boolean): void;
  124302. /**
  124303. * Force relase the drag action by code.
  124304. */
  124305. releaseDrag(): void;
  124306. private _startDragRay;
  124307. private _lastPointerRay;
  124308. /**
  124309. * Simulates the start of a pointer drag event on the behavior
  124310. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  124311. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  124312. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  124313. */
  124314. startDrag(pointerId?: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124315. protected _startDrag(pointerId: number, fromRay?: Ray, startPickedPoint?: Vector3): void;
  124316. private _dragDelta;
  124317. protected _moveDrag(ray: Ray): void;
  124318. private _pickWithRayOnDragPlane;
  124319. private _pointA;
  124320. private _pointC;
  124321. private _localAxis;
  124322. private _lookAt;
  124323. private _updateDragPlanePosition;
  124324. /**
  124325. * Detaches the behavior from the mesh
  124326. */
  124327. detach(): void;
  124328. }
  124329. }
  124330. declare module BABYLON {
  124331. /**
  124332. * A behavior that when attached to a mesh will allow the mesh to be scaled
  124333. */
  124334. export class MultiPointerScaleBehavior implements Behavior<Mesh> {
  124335. private _dragBehaviorA;
  124336. private _dragBehaviorB;
  124337. private _startDistance;
  124338. private _initialScale;
  124339. private _targetScale;
  124340. private _ownerNode;
  124341. private _sceneRenderObserver;
  124342. /**
  124343. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  124344. */
  124345. constructor();
  124346. /**
  124347. * The name of the behavior
  124348. */
  124349. get name(): string;
  124350. /**
  124351. * Initializes the behavior
  124352. */
  124353. init(): void;
  124354. private _getCurrentDistance;
  124355. /**
  124356. * Attaches the scale behavior the passed in mesh
  124357. * @param ownerNode The mesh that will be scaled around once attached
  124358. */
  124359. attach(ownerNode: Mesh): void;
  124360. /**
  124361. * Detaches the behavior from the mesh
  124362. */
  124363. detach(): void;
  124364. }
  124365. }
  124366. declare module BABYLON {
  124367. /**
  124368. * 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
  124369. */
  124370. export class SixDofDragBehavior implements Behavior<Mesh> {
  124371. private static _virtualScene;
  124372. private _ownerNode;
  124373. private _sceneRenderObserver;
  124374. private _scene;
  124375. private _targetPosition;
  124376. private _virtualOriginMesh;
  124377. private _virtualDragMesh;
  124378. private _pointerObserver;
  124379. private _moving;
  124380. private _startingOrientation;
  124381. private _attachedElement;
  124382. /**
  124383. * 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)
  124384. */
  124385. private zDragFactor;
  124386. /**
  124387. * If the object should rotate to face the drag origin
  124388. */
  124389. rotateDraggedObject: boolean;
  124390. /**
  124391. * If the behavior is currently in a dragging state
  124392. */
  124393. dragging: boolean;
  124394. /**
  124395. * 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)
  124396. */
  124397. dragDeltaRatio: number;
  124398. /**
  124399. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  124400. */
  124401. currentDraggingPointerID: number;
  124402. /**
  124403. * If camera controls should be detached during the drag
  124404. */
  124405. detachCameraControls: boolean;
  124406. /**
  124407. * Fires each time a drag starts
  124408. */
  124409. onDragStartObservable: Observable<{}>;
  124410. /**
  124411. * Fires each time a drag ends (eg. mouse release after drag)
  124412. */
  124413. onDragEndObservable: Observable<{}>;
  124414. /**
  124415. * 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
  124416. */
  124417. constructor();
  124418. /**
  124419. * The name of the behavior
  124420. */
  124421. get name(): string;
  124422. /**
  124423. * Initializes the behavior
  124424. */
  124425. init(): void;
  124426. /**
  124427. * In the case of multiplea active cameras, the cameraToUseForPointers should be used if set instead of active camera
  124428. */
  124429. private get _pointerCamera();
  124430. /**
  124431. * Attaches the scale behavior the passed in mesh
  124432. * @param ownerNode The mesh that will be scaled around once attached
  124433. */
  124434. attach(ownerNode: Mesh): void;
  124435. /**
  124436. * Detaches the behavior from the mesh
  124437. */
  124438. detach(): void;
  124439. }
  124440. }
  124441. declare module BABYLON {
  124442. /**
  124443. * Class used to apply inverse kinematics to bones
  124444. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  124445. */
  124446. export class BoneIKController {
  124447. private static _tmpVecs;
  124448. private static _tmpQuat;
  124449. private static _tmpMats;
  124450. /**
  124451. * Gets or sets the target mesh
  124452. */
  124453. targetMesh: AbstractMesh;
  124454. /** Gets or sets the mesh used as pole */
  124455. poleTargetMesh: AbstractMesh;
  124456. /**
  124457. * Gets or sets the bone used as pole
  124458. */
  124459. poleTargetBone: Nullable<Bone>;
  124460. /**
  124461. * Gets or sets the target position
  124462. */
  124463. targetPosition: Vector3;
  124464. /**
  124465. * Gets or sets the pole target position
  124466. */
  124467. poleTargetPosition: Vector3;
  124468. /**
  124469. * Gets or sets the pole target local offset
  124470. */
  124471. poleTargetLocalOffset: Vector3;
  124472. /**
  124473. * Gets or sets the pole angle
  124474. */
  124475. poleAngle: number;
  124476. /**
  124477. * Gets or sets the mesh associated with the controller
  124478. */
  124479. mesh: AbstractMesh;
  124480. /**
  124481. * 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)
  124482. */
  124483. slerpAmount: number;
  124484. private _bone1Quat;
  124485. private _bone1Mat;
  124486. private _bone2Ang;
  124487. private _bone1;
  124488. private _bone2;
  124489. private _bone1Length;
  124490. private _bone2Length;
  124491. private _maxAngle;
  124492. private _maxReach;
  124493. private _rightHandedSystem;
  124494. private _bendAxis;
  124495. private _slerping;
  124496. private _adjustRoll;
  124497. /**
  124498. * Gets or sets maximum allowed angle
  124499. */
  124500. get maxAngle(): number;
  124501. set maxAngle(value: number);
  124502. /**
  124503. * Creates a new BoneIKController
  124504. * @param mesh defines the mesh to control
  124505. * @param bone defines the bone to control
  124506. * @param options defines options to set up the controller
  124507. */
  124508. constructor(mesh: AbstractMesh, bone: Bone, options?: {
  124509. targetMesh?: AbstractMesh;
  124510. poleTargetMesh?: AbstractMesh;
  124511. poleTargetBone?: Bone;
  124512. poleTargetLocalOffset?: Vector3;
  124513. poleAngle?: number;
  124514. bendAxis?: Vector3;
  124515. maxAngle?: number;
  124516. slerpAmount?: number;
  124517. });
  124518. private _setMaxAngle;
  124519. /**
  124520. * Force the controller to update the bones
  124521. */
  124522. update(): void;
  124523. }
  124524. }
  124525. declare module BABYLON {
  124526. /**
  124527. * Class used to make a bone look toward a point in space
  124528. * @see https://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  124529. */
  124530. export class BoneLookController {
  124531. private static _tmpVecs;
  124532. private static _tmpQuat;
  124533. private static _tmpMats;
  124534. /**
  124535. * The target Vector3 that the bone will look at
  124536. */
  124537. target: Vector3;
  124538. /**
  124539. * The mesh that the bone is attached to
  124540. */
  124541. mesh: AbstractMesh;
  124542. /**
  124543. * The bone that will be looking to the target
  124544. */
  124545. bone: Bone;
  124546. /**
  124547. * The up axis of the coordinate system that is used when the bone is rotated
  124548. */
  124549. upAxis: Vector3;
  124550. /**
  124551. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  124552. */
  124553. upAxisSpace: Space;
  124554. /**
  124555. * Used to make an adjustment to the yaw of the bone
  124556. */
  124557. adjustYaw: number;
  124558. /**
  124559. * Used to make an adjustment to the pitch of the bone
  124560. */
  124561. adjustPitch: number;
  124562. /**
  124563. * Used to make an adjustment to the roll of the bone
  124564. */
  124565. adjustRoll: number;
  124566. /**
  124567. * 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)
  124568. */
  124569. slerpAmount: number;
  124570. private _minYaw;
  124571. private _maxYaw;
  124572. private _minPitch;
  124573. private _maxPitch;
  124574. private _minYawSin;
  124575. private _minYawCos;
  124576. private _maxYawSin;
  124577. private _maxYawCos;
  124578. private _midYawConstraint;
  124579. private _minPitchTan;
  124580. private _maxPitchTan;
  124581. private _boneQuat;
  124582. private _slerping;
  124583. private _transformYawPitch;
  124584. private _transformYawPitchInv;
  124585. private _firstFrameSkipped;
  124586. private _yawRange;
  124587. private _fowardAxis;
  124588. /**
  124589. * Gets or sets the minimum yaw angle that the bone can look to
  124590. */
  124591. get minYaw(): number;
  124592. set minYaw(value: number);
  124593. /**
  124594. * Gets or sets the maximum yaw angle that the bone can look to
  124595. */
  124596. get maxYaw(): number;
  124597. set maxYaw(value: number);
  124598. /**
  124599. * Gets or sets the minimum pitch angle that the bone can look to
  124600. */
  124601. get minPitch(): number;
  124602. set minPitch(value: number);
  124603. /**
  124604. * Gets or sets the maximum pitch angle that the bone can look to
  124605. */
  124606. get maxPitch(): number;
  124607. set maxPitch(value: number);
  124608. /**
  124609. * Create a BoneLookController
  124610. * @param mesh the mesh that the bone belongs to
  124611. * @param bone the bone that will be looking to the target
  124612. * @param target the target Vector3 to look at
  124613. * @param options optional settings:
  124614. * * maxYaw: the maximum angle the bone will yaw to
  124615. * * minYaw: the minimum angle the bone will yaw to
  124616. * * maxPitch: the maximum angle the bone will pitch to
  124617. * * minPitch: the minimum angle the bone will yaw to
  124618. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  124619. * * upAxis: the up axis of the coordinate system
  124620. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  124621. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  124622. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  124623. * * adjustYaw: used to make an adjustment to the yaw of the bone
  124624. * * adjustPitch: used to make an adjustment to the pitch of the bone
  124625. * * adjustRoll: used to make an adjustment to the roll of the bone
  124626. **/
  124627. constructor(mesh: AbstractMesh, bone: Bone, target: Vector3, options?: {
  124628. maxYaw?: number;
  124629. minYaw?: number;
  124630. maxPitch?: number;
  124631. minPitch?: number;
  124632. slerpAmount?: number;
  124633. upAxis?: Vector3;
  124634. upAxisSpace?: Space;
  124635. yawAxis?: Vector3;
  124636. pitchAxis?: Vector3;
  124637. adjustYaw?: number;
  124638. adjustPitch?: number;
  124639. adjustRoll?: number;
  124640. });
  124641. /**
  124642. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  124643. */
  124644. update(): void;
  124645. private _getAngleDiff;
  124646. private _getAngleBetween;
  124647. private _isAngleBetween;
  124648. }
  124649. }
  124650. declare module BABYLON {
  124651. /**
  124652. * Manage the gamepad inputs to control an arc rotate camera.
  124653. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124654. */
  124655. export class ArcRotateCameraGamepadInput implements ICameraInput<ArcRotateCamera> {
  124656. /**
  124657. * Defines the camera the input is attached to.
  124658. */
  124659. camera: ArcRotateCamera;
  124660. /**
  124661. * Defines the gamepad the input is gathering event from.
  124662. */
  124663. gamepad: Nullable<Gamepad>;
  124664. /**
  124665. * Defines the gamepad rotation sensiblity.
  124666. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  124667. */
  124668. gamepadRotationSensibility: number;
  124669. /**
  124670. * Defines the gamepad move sensiblity.
  124671. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  124672. */
  124673. gamepadMoveSensibility: number;
  124674. private _yAxisScale;
  124675. /**
  124676. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  124677. */
  124678. get invertYAxis(): boolean;
  124679. set invertYAxis(value: boolean);
  124680. private _onGamepadConnectedObserver;
  124681. private _onGamepadDisconnectedObserver;
  124682. /**
  124683. * Attach the input controls to a specific dom element to get the input from.
  124684. * @param element Defines the element the controls should be listened from
  124685. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124686. */
  124687. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124688. /**
  124689. * Detach the current controls from the specified dom element.
  124690. * @param element Defines the element to stop listening the inputs from
  124691. */
  124692. detachControl(element: Nullable<HTMLElement>): void;
  124693. /**
  124694. * Update the current camera state depending on the inputs that have been used this frame.
  124695. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124696. */
  124697. checkInputs(): void;
  124698. /**
  124699. * Gets the class name of the current intput.
  124700. * @returns the class name
  124701. */
  124702. getClassName(): string;
  124703. /**
  124704. * Get the friendly name associated with the input class.
  124705. * @returns the input friendly name
  124706. */
  124707. getSimpleName(): string;
  124708. }
  124709. }
  124710. declare module BABYLON {
  124711. interface ArcRotateCameraInputsManager {
  124712. /**
  124713. * Add orientation input support to the input manager.
  124714. * @returns the current input manager
  124715. */
  124716. addVRDeviceOrientation(): ArcRotateCameraInputsManager;
  124717. }
  124718. /**
  124719. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  124720. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124721. */
  124722. export class ArcRotateCameraVRDeviceOrientationInput implements ICameraInput<ArcRotateCamera> {
  124723. /**
  124724. * Defines the camera the input is attached to.
  124725. */
  124726. camera: ArcRotateCamera;
  124727. /**
  124728. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  124729. */
  124730. alphaCorrection: number;
  124731. /**
  124732. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  124733. */
  124734. gammaCorrection: number;
  124735. private _alpha;
  124736. private _gamma;
  124737. private _dirty;
  124738. private _deviceOrientationHandler;
  124739. /**
  124740. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  124741. */
  124742. constructor();
  124743. /**
  124744. * Attach the input controls to a specific dom element to get the input from.
  124745. * @param element Defines the element the controls should be listened from
  124746. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  124747. */
  124748. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124749. /** @hidden */
  124750. _onOrientationEvent(evt: DeviceOrientationEvent): void;
  124751. /**
  124752. * Update the current camera state depending on the inputs that have been used this frame.
  124753. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  124754. */
  124755. checkInputs(): void;
  124756. /**
  124757. * Detach the current controls from the specified dom element.
  124758. * @param element Defines the element to stop listening the inputs from
  124759. */
  124760. detachControl(element: Nullable<HTMLElement>): void;
  124761. /**
  124762. * Gets the class name of the current intput.
  124763. * @returns the class name
  124764. */
  124765. getClassName(): string;
  124766. /**
  124767. * Get the friendly name associated with the input class.
  124768. * @returns the input friendly name
  124769. */
  124770. getSimpleName(): string;
  124771. }
  124772. }
  124773. declare module BABYLON {
  124774. /**
  124775. * Listen to mouse events to control the camera.
  124776. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124777. */
  124778. export class FlyCameraMouseInput implements ICameraInput<FlyCamera> {
  124779. /**
  124780. * Defines the camera the input is attached to.
  124781. */
  124782. camera: FlyCamera;
  124783. /**
  124784. * Defines if touch is enabled. (Default is true.)
  124785. */
  124786. touchEnabled: boolean;
  124787. /**
  124788. * Defines the buttons associated with the input to handle camera rotation.
  124789. */
  124790. buttons: number[];
  124791. /**
  124792. * Assign buttons for Yaw control.
  124793. */
  124794. buttonsYaw: number[];
  124795. /**
  124796. * Assign buttons for Pitch control.
  124797. */
  124798. buttonsPitch: number[];
  124799. /**
  124800. * Assign buttons for Roll control.
  124801. */
  124802. buttonsRoll: number[];
  124803. /**
  124804. * Detect if any button is being pressed while mouse is moved.
  124805. * -1 = Mouse locked.
  124806. * 0 = Left button.
  124807. * 1 = Middle Button.
  124808. * 2 = Right Button.
  124809. */
  124810. activeButton: number;
  124811. /**
  124812. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  124813. * Higher values reduce its sensitivity.
  124814. */
  124815. angularSensibility: number;
  124816. private _observer;
  124817. private _rollObserver;
  124818. private previousPosition;
  124819. private noPreventDefault;
  124820. private element;
  124821. /**
  124822. * Listen to mouse events to control the camera.
  124823. * @param touchEnabled Define if touch is enabled. (Default is true.)
  124824. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124825. */
  124826. constructor(touchEnabled?: boolean);
  124827. /**
  124828. * Attach the mouse control to the HTML DOM element.
  124829. * @param element Defines the element that listens to the input events.
  124830. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  124831. */
  124832. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  124833. /**
  124834. * Detach the current controls from the specified dom element.
  124835. * @param element Defines the element to stop listening the inputs from
  124836. */
  124837. detachControl(element: Nullable<HTMLElement>): void;
  124838. /**
  124839. * Gets the class name of the current input.
  124840. * @returns the class name.
  124841. */
  124842. getClassName(): string;
  124843. /**
  124844. * Get the friendly name associated with the input class.
  124845. * @returns the input's friendly name.
  124846. */
  124847. getSimpleName(): string;
  124848. private _pointerInput;
  124849. private _onMouseMove;
  124850. /**
  124851. * Rotate camera by mouse offset.
  124852. */
  124853. private rotateCamera;
  124854. }
  124855. }
  124856. declare module BABYLON {
  124857. /**
  124858. * Default Inputs manager for the FlyCamera.
  124859. * It groups all the default supported inputs for ease of use.
  124860. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  124861. */
  124862. export class FlyCameraInputsManager extends CameraInputsManager<FlyCamera> {
  124863. /**
  124864. * Instantiates a new FlyCameraInputsManager.
  124865. * @param camera Defines the camera the inputs belong to.
  124866. */
  124867. constructor(camera: FlyCamera);
  124868. /**
  124869. * Add keyboard input support to the input manager.
  124870. * @returns the new FlyCameraKeyboardMoveInput().
  124871. */
  124872. addKeyboard(): FlyCameraInputsManager;
  124873. /**
  124874. * Add mouse input support to the input manager.
  124875. * @param touchEnabled Enable touch screen support.
  124876. * @returns the new FlyCameraMouseInput().
  124877. */
  124878. addMouse(touchEnabled?: boolean): FlyCameraInputsManager;
  124879. }
  124880. }
  124881. declare module BABYLON {
  124882. /**
  124883. * This is a flying camera, designed for 3D movement and rotation in all directions,
  124884. * such as in a 3D Space Shooter or a Flight Simulator.
  124885. */
  124886. export class FlyCamera extends TargetCamera {
  124887. /**
  124888. * Define the collision ellipsoid of the camera.
  124889. * This is helpful for simulating a camera body, like a player's body.
  124890. * @see https://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  124891. */
  124892. ellipsoid: Vector3;
  124893. /**
  124894. * Define an offset for the position of the ellipsoid around the camera.
  124895. * This can be helpful if the camera is attached away from the player's body center,
  124896. * such as at its head.
  124897. */
  124898. ellipsoidOffset: Vector3;
  124899. /**
  124900. * Enable or disable collisions of the camera with the rest of the scene objects.
  124901. */
  124902. checkCollisions: boolean;
  124903. /**
  124904. * Enable or disable gravity on the camera.
  124905. */
  124906. applyGravity: boolean;
  124907. /**
  124908. * Define the current direction the camera is moving to.
  124909. */
  124910. cameraDirection: Vector3;
  124911. /**
  124912. * Define the current local rotation of the camera as a quaternion to prevent Gimbal lock.
  124913. * This overrides and empties cameraRotation.
  124914. */
  124915. rotationQuaternion: Quaternion;
  124916. /**
  124917. * Track Roll to maintain the wanted Rolling when looking around.
  124918. */
  124919. _trackRoll: number;
  124920. /**
  124921. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  124922. */
  124923. rollCorrect: number;
  124924. /**
  124925. * Mimic a banked turn, Rolling the camera when Yawing.
  124926. * It's recommended to use rollCorrect = 10 for faster banking correction.
  124927. */
  124928. bankedTurn: boolean;
  124929. /**
  124930. * Limit in radians for how much Roll banking will add. (Default: 90°)
  124931. */
  124932. bankedTurnLimit: number;
  124933. /**
  124934. * Value of 0 disables the banked Roll.
  124935. * Value of 1 is equal to the Yaw angle in radians.
  124936. */
  124937. bankedTurnMultiplier: number;
  124938. /**
  124939. * The inputs manager loads all the input sources, such as keyboard and mouse.
  124940. */
  124941. inputs: FlyCameraInputsManager;
  124942. /**
  124943. * Gets the input sensibility for mouse input.
  124944. * Higher values reduce sensitivity.
  124945. */
  124946. get angularSensibility(): number;
  124947. /**
  124948. * Sets the input sensibility for a mouse input.
  124949. * Higher values reduce sensitivity.
  124950. */
  124951. set angularSensibility(value: number);
  124952. /**
  124953. * Get the keys for camera movement forward.
  124954. */
  124955. get keysForward(): number[];
  124956. /**
  124957. * Set the keys for camera movement forward.
  124958. */
  124959. set keysForward(value: number[]);
  124960. /**
  124961. * Get the keys for camera movement backward.
  124962. */
  124963. get keysBackward(): number[];
  124964. set keysBackward(value: number[]);
  124965. /**
  124966. * Get the keys for camera movement up.
  124967. */
  124968. get keysUp(): number[];
  124969. /**
  124970. * Set the keys for camera movement up.
  124971. */
  124972. set keysUp(value: number[]);
  124973. /**
  124974. * Get the keys for camera movement down.
  124975. */
  124976. get keysDown(): number[];
  124977. /**
  124978. * Set the keys for camera movement down.
  124979. */
  124980. set keysDown(value: number[]);
  124981. /**
  124982. * Get the keys for camera movement left.
  124983. */
  124984. get keysLeft(): number[];
  124985. /**
  124986. * Set the keys for camera movement left.
  124987. */
  124988. set keysLeft(value: number[]);
  124989. /**
  124990. * Set the keys for camera movement right.
  124991. */
  124992. get keysRight(): number[];
  124993. /**
  124994. * Set the keys for camera movement right.
  124995. */
  124996. set keysRight(value: number[]);
  124997. /**
  124998. * Event raised when the camera collides with a mesh in the scene.
  124999. */
  125000. onCollide: (collidedMesh: AbstractMesh) => void;
  125001. private _collider;
  125002. private _needMoveForGravity;
  125003. private _oldPosition;
  125004. private _diffPosition;
  125005. private _newPosition;
  125006. /** @hidden */
  125007. _localDirection: Vector3;
  125008. /** @hidden */
  125009. _transformedDirection: Vector3;
  125010. /**
  125011. * Instantiates a FlyCamera.
  125012. * This is a flying camera, designed for 3D movement and rotation in all directions,
  125013. * such as in a 3D Space Shooter or a Flight Simulator.
  125014. * @param name Define the name of the camera in the scene.
  125015. * @param position Define the starting position of the camera in the scene.
  125016. * @param scene Define the scene the camera belongs to.
  125017. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  125018. */
  125019. constructor(name: string, position: Vector3, scene: Scene, setActiveOnSceneIfNoneActive?: boolean);
  125020. /**
  125021. * Attach a control to the HTML DOM element.
  125022. * @param element Defines the element that listens to the input events.
  125023. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  125024. */
  125025. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125026. /**
  125027. * Detach a control from the HTML DOM element.
  125028. * The camera will stop reacting to that input.
  125029. * @param element Defines the element that listens to the input events.
  125030. */
  125031. detachControl(element: HTMLElement): void;
  125032. private _collisionMask;
  125033. /**
  125034. * Get the mask that the camera ignores in collision events.
  125035. */
  125036. get collisionMask(): number;
  125037. /**
  125038. * Set the mask that the camera ignores in collision events.
  125039. */
  125040. set collisionMask(mask: number);
  125041. /** @hidden */
  125042. _collideWithWorld(displacement: Vector3): void;
  125043. /** @hidden */
  125044. private _onCollisionPositionChange;
  125045. /** @hidden */
  125046. _checkInputs(): void;
  125047. /** @hidden */
  125048. _decideIfNeedsToMove(): boolean;
  125049. /** @hidden */
  125050. _updatePosition(): void;
  125051. /**
  125052. * Restore the Roll to its target value at the rate specified.
  125053. * @param rate - Higher means slower restoring.
  125054. * @hidden
  125055. */
  125056. restoreRoll(rate: number): void;
  125057. /**
  125058. * Destroy the camera and release the current resources held by it.
  125059. */
  125060. dispose(): void;
  125061. /**
  125062. * Get the current object class name.
  125063. * @returns the class name.
  125064. */
  125065. getClassName(): string;
  125066. }
  125067. }
  125068. declare module BABYLON {
  125069. /**
  125070. * Listen to keyboard events to control the camera.
  125071. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125072. */
  125073. export class FlyCameraKeyboardInput implements ICameraInput<FlyCamera> {
  125074. /**
  125075. * Defines the camera the input is attached to.
  125076. */
  125077. camera: FlyCamera;
  125078. /**
  125079. * The list of keyboard keys used to control the forward move of the camera.
  125080. */
  125081. keysForward: number[];
  125082. /**
  125083. * The list of keyboard keys used to control the backward move of the camera.
  125084. */
  125085. keysBackward: number[];
  125086. /**
  125087. * The list of keyboard keys used to control the forward move of the camera.
  125088. */
  125089. keysUp: number[];
  125090. /**
  125091. * The list of keyboard keys used to control the backward move of the camera.
  125092. */
  125093. keysDown: number[];
  125094. /**
  125095. * The list of keyboard keys used to control the right strafe move of the camera.
  125096. */
  125097. keysRight: number[];
  125098. /**
  125099. * The list of keyboard keys used to control the left strafe move of the camera.
  125100. */
  125101. keysLeft: number[];
  125102. private _keys;
  125103. private _onCanvasBlurObserver;
  125104. private _onKeyboardObserver;
  125105. private _engine;
  125106. private _scene;
  125107. /**
  125108. * Attach the input controls to a specific dom element to get the input from.
  125109. * @param element Defines the element the controls should be listened from
  125110. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125111. */
  125112. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125113. /**
  125114. * Detach the current controls from the specified dom element.
  125115. * @param element Defines the element to stop listening the inputs from
  125116. */
  125117. detachControl(element: Nullable<HTMLElement>): void;
  125118. /**
  125119. * Gets the class name of the current intput.
  125120. * @returns the class name
  125121. */
  125122. getClassName(): string;
  125123. /** @hidden */
  125124. _onLostFocus(e: FocusEvent): void;
  125125. /**
  125126. * Get the friendly name associated with the input class.
  125127. * @returns the input friendly name
  125128. */
  125129. getSimpleName(): string;
  125130. /**
  125131. * Update the current camera state depending on the inputs that have been used this frame.
  125132. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125133. */
  125134. checkInputs(): void;
  125135. }
  125136. }
  125137. declare module BABYLON {
  125138. /**
  125139. * Manage the mouse wheel inputs to control a follow camera.
  125140. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125141. */
  125142. export class FollowCameraMouseWheelInput implements ICameraInput<FollowCamera> {
  125143. /**
  125144. * Defines the camera the input is attached to.
  125145. */
  125146. camera: FollowCamera;
  125147. /**
  125148. * Moue wheel controls zoom. (Mouse wheel modifies camera.radius value.)
  125149. */
  125150. axisControlRadius: boolean;
  125151. /**
  125152. * Moue wheel controls height. (Mouse wheel modifies camera.heightOffset value.)
  125153. */
  125154. axisControlHeight: boolean;
  125155. /**
  125156. * Moue wheel controls angle. (Mouse wheel modifies camera.rotationOffset value.)
  125157. */
  125158. axisControlRotation: boolean;
  125159. /**
  125160. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  125161. * relation to mouseWheel events.
  125162. */
  125163. wheelPrecision: number;
  125164. /**
  125165. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  125166. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  125167. */
  125168. wheelDeltaPercentage: number;
  125169. private _wheel;
  125170. private _observer;
  125171. /**
  125172. * Attach the input controls to a specific dom element to get the input from.
  125173. * @param element Defines the element the controls should be listened from
  125174. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125175. */
  125176. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125177. /**
  125178. * Detach the current controls from the specified dom element.
  125179. * @param element Defines the element to stop listening the inputs from
  125180. */
  125181. detachControl(element: Nullable<HTMLElement>): void;
  125182. /**
  125183. * Gets the class name of the current intput.
  125184. * @returns the class name
  125185. */
  125186. getClassName(): string;
  125187. /**
  125188. * Get the friendly name associated with the input class.
  125189. * @returns the input friendly name
  125190. */
  125191. getSimpleName(): string;
  125192. }
  125193. }
  125194. declare module BABYLON {
  125195. /**
  125196. * Manage the pointers inputs to control an follow camera.
  125197. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125198. */
  125199. export class FollowCameraPointersInput extends BaseCameraPointersInput {
  125200. /**
  125201. * Defines the camera the input is attached to.
  125202. */
  125203. camera: FollowCamera;
  125204. /**
  125205. * Gets the class name of the current input.
  125206. * @returns the class name
  125207. */
  125208. getClassName(): string;
  125209. /**
  125210. * Defines the pointer angular sensibility along the X axis or how fast is
  125211. * the camera rotating.
  125212. * A negative number will reverse the axis direction.
  125213. */
  125214. angularSensibilityX: number;
  125215. /**
  125216. * Defines the pointer angular sensibility along the Y axis or how fast is
  125217. * the camera rotating.
  125218. * A negative number will reverse the axis direction.
  125219. */
  125220. angularSensibilityY: number;
  125221. /**
  125222. * Defines the pointer pinch precision or how fast is the camera zooming.
  125223. * A negative number will reverse the axis direction.
  125224. */
  125225. pinchPrecision: number;
  125226. /**
  125227. * pinchDeltaPercentage will be used instead of pinchPrecision if different
  125228. * from 0.
  125229. * It defines the percentage of current camera.radius to use as delta when
  125230. * pinch zoom is used.
  125231. */
  125232. pinchDeltaPercentage: number;
  125233. /**
  125234. * Pointer X axis controls zoom. (X axis modifies camera.radius value.)
  125235. */
  125236. axisXControlRadius: boolean;
  125237. /**
  125238. * Pointer X axis controls height. (X axis modifies camera.heightOffset value.)
  125239. */
  125240. axisXControlHeight: boolean;
  125241. /**
  125242. * Pointer X axis controls angle. (X axis modifies camera.rotationOffset value.)
  125243. */
  125244. axisXControlRotation: boolean;
  125245. /**
  125246. * Pointer Y axis controls zoom. (Y axis modifies camera.radius value.)
  125247. */
  125248. axisYControlRadius: boolean;
  125249. /**
  125250. * Pointer Y axis controls height. (Y axis modifies camera.heightOffset value.)
  125251. */
  125252. axisYControlHeight: boolean;
  125253. /**
  125254. * Pointer Y axis controls angle. (Y axis modifies camera.rotationOffset value.)
  125255. */
  125256. axisYControlRotation: boolean;
  125257. /**
  125258. * Pinch controls zoom. (Pinch modifies camera.radius value.)
  125259. */
  125260. axisPinchControlRadius: boolean;
  125261. /**
  125262. * Pinch controls height. (Pinch modifies camera.heightOffset value.)
  125263. */
  125264. axisPinchControlHeight: boolean;
  125265. /**
  125266. * Pinch controls angle. (Pinch modifies camera.rotationOffset value.)
  125267. */
  125268. axisPinchControlRotation: boolean;
  125269. /**
  125270. * Log error messages if basic misconfiguration has occurred.
  125271. */
  125272. warningEnable: boolean;
  125273. protected onTouch(pointA: Nullable<PointerTouch>, offsetX: number, offsetY: number): void;
  125274. protected onMultiTouch(pointA: Nullable<PointerTouch>, pointB: Nullable<PointerTouch>, previousPinchSquaredDistance: number, pinchSquaredDistance: number, previousMultiTouchPanPosition: Nullable<PointerTouch>, multiTouchPanPosition: Nullable<PointerTouch>): void;
  125275. private _warningCounter;
  125276. private _warning;
  125277. }
  125278. }
  125279. declare module BABYLON {
  125280. /**
  125281. * Default Inputs manager for the FollowCamera.
  125282. * It groups all the default supported inputs for ease of use.
  125283. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125284. */
  125285. export class FollowCameraInputsManager extends CameraInputsManager<FollowCamera> {
  125286. /**
  125287. * Instantiates a new FollowCameraInputsManager.
  125288. * @param camera Defines the camera the inputs belong to
  125289. */
  125290. constructor(camera: FollowCamera);
  125291. /**
  125292. * Add keyboard input support to the input manager.
  125293. * @returns the current input manager
  125294. */
  125295. addKeyboard(): FollowCameraInputsManager;
  125296. /**
  125297. * Add mouse wheel input support to the input manager.
  125298. * @returns the current input manager
  125299. */
  125300. addMouseWheel(): FollowCameraInputsManager;
  125301. /**
  125302. * Add pointers input support to the input manager.
  125303. * @returns the current input manager
  125304. */
  125305. addPointers(): FollowCameraInputsManager;
  125306. /**
  125307. * Add orientation input support to the input manager.
  125308. * @returns the current input manager
  125309. */
  125310. addVRDeviceOrientation(): FollowCameraInputsManager;
  125311. }
  125312. }
  125313. declare module BABYLON {
  125314. /**
  125315. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  125316. * an arc rotate version arcFollowCamera are available.
  125317. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125318. */
  125319. export class FollowCamera extends TargetCamera {
  125320. /**
  125321. * Distance the follow camera should follow an object at
  125322. */
  125323. radius: number;
  125324. /**
  125325. * Minimum allowed distance of the camera to the axis of rotation
  125326. * (The camera can not get closer).
  125327. * This can help limiting how the Camera is able to move in the scene.
  125328. */
  125329. lowerRadiusLimit: Nullable<number>;
  125330. /**
  125331. * Maximum allowed distance of the camera to the axis of rotation
  125332. * (The camera can not get further).
  125333. * This can help limiting how the Camera is able to move in the scene.
  125334. */
  125335. upperRadiusLimit: Nullable<number>;
  125336. /**
  125337. * Define a rotation offset between the camera and the object it follows
  125338. */
  125339. rotationOffset: number;
  125340. /**
  125341. * Minimum allowed angle to camera position relative to target object.
  125342. * This can help limiting how the Camera is able to move in the scene.
  125343. */
  125344. lowerRotationOffsetLimit: Nullable<number>;
  125345. /**
  125346. * Maximum allowed angle to camera position relative to target object.
  125347. * This can help limiting how the Camera is able to move in the scene.
  125348. */
  125349. upperRotationOffsetLimit: Nullable<number>;
  125350. /**
  125351. * Define a height offset between the camera and the object it follows.
  125352. * It can help following an object from the top (like a car chaing a plane)
  125353. */
  125354. heightOffset: number;
  125355. /**
  125356. * Minimum allowed height of camera position relative to target object.
  125357. * This can help limiting how the Camera is able to move in the scene.
  125358. */
  125359. lowerHeightOffsetLimit: Nullable<number>;
  125360. /**
  125361. * Maximum allowed height of camera position relative to target object.
  125362. * This can help limiting how the Camera is able to move in the scene.
  125363. */
  125364. upperHeightOffsetLimit: Nullable<number>;
  125365. /**
  125366. * Define how fast the camera can accelerate to follow it s target.
  125367. */
  125368. cameraAcceleration: number;
  125369. /**
  125370. * Define the speed limit of the camera following an object.
  125371. */
  125372. maxCameraSpeed: number;
  125373. /**
  125374. * Define the target of the camera.
  125375. */
  125376. lockedTarget: Nullable<AbstractMesh>;
  125377. /**
  125378. * Defines the input associated with the camera.
  125379. */
  125380. inputs: FollowCameraInputsManager;
  125381. /**
  125382. * Instantiates the follow camera.
  125383. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125384. * @param name Define the name of the camera in the scene
  125385. * @param position Define the position of the camera
  125386. * @param scene Define the scene the camera belong to
  125387. * @param lockedTarget Define the target of the camera
  125388. */
  125389. constructor(name: string, position: Vector3, scene: Scene, lockedTarget?: Nullable<AbstractMesh>);
  125390. private _follow;
  125391. /**
  125392. * Attached controls to the current camera.
  125393. * @param element Defines the element the controls should be listened from
  125394. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125395. */
  125396. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125397. /**
  125398. * Detach the current controls from the camera.
  125399. * The camera will stop reacting to inputs.
  125400. * @param element Defines the element to stop listening the inputs from
  125401. */
  125402. detachControl(element: HTMLElement): void;
  125403. /** @hidden */
  125404. _checkInputs(): void;
  125405. private _checkLimits;
  125406. /**
  125407. * Gets the camera class name.
  125408. * @returns the class name
  125409. */
  125410. getClassName(): string;
  125411. }
  125412. /**
  125413. * Arc Rotate version of the follow camera.
  125414. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  125415. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125416. */
  125417. export class ArcFollowCamera extends TargetCamera {
  125418. /** The longitudinal angle of the camera */
  125419. alpha: number;
  125420. /** The latitudinal angle of the camera */
  125421. beta: number;
  125422. /** The radius of the camera from its target */
  125423. radius: number;
  125424. private _cartesianCoordinates;
  125425. /** Define the camera target (the mesh it should follow) */
  125426. private _meshTarget;
  125427. /**
  125428. * Instantiates a new ArcFollowCamera
  125429. * @see https://doc.babylonjs.com/features/cameras#follow-camera
  125430. * @param name Define the name of the camera
  125431. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  125432. * @param beta Define the rotation angle of the camera around the elevation axis
  125433. * @param radius Define the radius of the camera from its target point
  125434. * @param target Define the target of the camera
  125435. * @param scene Define the scene the camera belongs to
  125436. */
  125437. constructor(name: string,
  125438. /** The longitudinal angle of the camera */
  125439. alpha: number,
  125440. /** The latitudinal angle of the camera */
  125441. beta: number,
  125442. /** The radius of the camera from its target */
  125443. radius: number,
  125444. /** Define the camera target (the mesh it should follow) */
  125445. target: Nullable<AbstractMesh>, scene: Scene);
  125446. private _follow;
  125447. /** @hidden */
  125448. _checkInputs(): void;
  125449. /**
  125450. * Returns the class name of the object.
  125451. * It is mostly used internally for serialization purposes.
  125452. */
  125453. getClassName(): string;
  125454. }
  125455. }
  125456. declare module BABYLON {
  125457. /**
  125458. * Manage the keyboard inputs to control the movement of a follow camera.
  125459. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125460. */
  125461. export class FollowCameraKeyboardMoveInput implements ICameraInput<FollowCamera> {
  125462. /**
  125463. * Defines the camera the input is attached to.
  125464. */
  125465. camera: FollowCamera;
  125466. /**
  125467. * Defines the list of key codes associated with the up action (increase heightOffset)
  125468. */
  125469. keysHeightOffsetIncr: number[];
  125470. /**
  125471. * Defines the list of key codes associated with the down action (decrease heightOffset)
  125472. */
  125473. keysHeightOffsetDecr: number[];
  125474. /**
  125475. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  125476. */
  125477. keysHeightOffsetModifierAlt: boolean;
  125478. /**
  125479. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  125480. */
  125481. keysHeightOffsetModifierCtrl: boolean;
  125482. /**
  125483. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  125484. */
  125485. keysHeightOffsetModifierShift: boolean;
  125486. /**
  125487. * Defines the list of key codes associated with the left action (increase rotationOffset)
  125488. */
  125489. keysRotationOffsetIncr: number[];
  125490. /**
  125491. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  125492. */
  125493. keysRotationOffsetDecr: number[];
  125494. /**
  125495. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  125496. */
  125497. keysRotationOffsetModifierAlt: boolean;
  125498. /**
  125499. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  125500. */
  125501. keysRotationOffsetModifierCtrl: boolean;
  125502. /**
  125503. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  125504. */
  125505. keysRotationOffsetModifierShift: boolean;
  125506. /**
  125507. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  125508. */
  125509. keysRadiusIncr: number[];
  125510. /**
  125511. * Defines the list of key codes associated with the zoom-out action (increase radius)
  125512. */
  125513. keysRadiusDecr: number[];
  125514. /**
  125515. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  125516. */
  125517. keysRadiusModifierAlt: boolean;
  125518. /**
  125519. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  125520. */
  125521. keysRadiusModifierCtrl: boolean;
  125522. /**
  125523. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  125524. */
  125525. keysRadiusModifierShift: boolean;
  125526. /**
  125527. * Defines the rate of change of heightOffset.
  125528. */
  125529. heightSensibility: number;
  125530. /**
  125531. * Defines the rate of change of rotationOffset.
  125532. */
  125533. rotationSensibility: number;
  125534. /**
  125535. * Defines the rate of change of radius.
  125536. */
  125537. radiusSensibility: number;
  125538. private _keys;
  125539. private _ctrlPressed;
  125540. private _altPressed;
  125541. private _shiftPressed;
  125542. private _onCanvasBlurObserver;
  125543. private _onKeyboardObserver;
  125544. private _engine;
  125545. private _scene;
  125546. /**
  125547. * Attach the input controls to a specific dom element to get the input from.
  125548. * @param element Defines the element the controls should be listened from
  125549. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125550. */
  125551. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125552. /**
  125553. * Detach the current controls from the specified dom element.
  125554. * @param element Defines the element to stop listening the inputs from
  125555. */
  125556. detachControl(element: Nullable<HTMLElement>): void;
  125557. /**
  125558. * Update the current camera state depending on the inputs that have been used this frame.
  125559. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125560. */
  125561. checkInputs(): void;
  125562. /**
  125563. * Gets the class name of the current input.
  125564. * @returns the class name
  125565. */
  125566. getClassName(): string;
  125567. /**
  125568. * Get the friendly name associated with the input class.
  125569. * @returns the input friendly name
  125570. */
  125571. getSimpleName(): string;
  125572. /**
  125573. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125574. * allow modification of the heightOffset value.
  125575. */
  125576. private _modifierHeightOffset;
  125577. /**
  125578. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125579. * allow modification of the rotationOffset value.
  125580. */
  125581. private _modifierRotationOffset;
  125582. /**
  125583. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  125584. * allow modification of the radius value.
  125585. */
  125586. private _modifierRadius;
  125587. }
  125588. }
  125589. declare module BABYLON {
  125590. interface FreeCameraInputsManager {
  125591. /**
  125592. * @hidden
  125593. */
  125594. _deviceOrientationInput: Nullable<FreeCameraDeviceOrientationInput>;
  125595. /**
  125596. * Add orientation input support to the input manager.
  125597. * @returns the current input manager
  125598. */
  125599. addDeviceOrientation(): FreeCameraInputsManager;
  125600. }
  125601. /**
  125602. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  125603. * Screen rotation is taken into account.
  125604. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125605. */
  125606. export class FreeCameraDeviceOrientationInput implements ICameraInput<FreeCamera> {
  125607. private _camera;
  125608. private _screenOrientationAngle;
  125609. private _constantTranform;
  125610. private _screenQuaternion;
  125611. private _alpha;
  125612. private _beta;
  125613. private _gamma;
  125614. /**
  125615. * Can be used to detect if a device orientation sensor is available on a device
  125616. * @param timeout amount of time in milliseconds to wait for a response from the sensor (default: infinite)
  125617. * @returns a promise that will resolve on orientation change
  125618. */
  125619. static WaitForOrientationChangeAsync(timeout?: number): Promise<unknown>;
  125620. /**
  125621. * @hidden
  125622. */
  125623. _onDeviceOrientationChangedObservable: Observable<void>;
  125624. /**
  125625. * Instantiates a new input
  125626. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125627. */
  125628. constructor();
  125629. /**
  125630. * Define the camera controlled by the input.
  125631. */
  125632. get camera(): FreeCamera;
  125633. set camera(camera: FreeCamera);
  125634. /**
  125635. * Attach the input controls to a specific dom element to get the input from.
  125636. * @param element Defines the element the controls should be listened from
  125637. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125638. */
  125639. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125640. private _orientationChanged;
  125641. private _deviceOrientation;
  125642. /**
  125643. * Detach the current controls from the specified dom element.
  125644. * @param element Defines the element to stop listening the inputs from
  125645. */
  125646. detachControl(element: Nullable<HTMLElement>): void;
  125647. /**
  125648. * Update the current camera state depending on the inputs that have been used this frame.
  125649. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125650. */
  125651. checkInputs(): void;
  125652. /**
  125653. * Gets the class name of the current intput.
  125654. * @returns the class name
  125655. */
  125656. getClassName(): string;
  125657. /**
  125658. * Get the friendly name associated with the input class.
  125659. * @returns the input friendly name
  125660. */
  125661. getSimpleName(): string;
  125662. }
  125663. }
  125664. declare module BABYLON {
  125665. /**
  125666. * Manage the gamepad inputs to control a free camera.
  125667. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125668. */
  125669. export class FreeCameraGamepadInput implements ICameraInput<FreeCamera> {
  125670. /**
  125671. * Define the camera the input is attached to.
  125672. */
  125673. camera: FreeCamera;
  125674. /**
  125675. * Define the Gamepad controlling the input
  125676. */
  125677. gamepad: Nullable<Gamepad>;
  125678. /**
  125679. * Defines the gamepad rotation sensiblity.
  125680. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  125681. */
  125682. gamepadAngularSensibility: number;
  125683. /**
  125684. * Defines the gamepad move sensiblity.
  125685. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  125686. */
  125687. gamepadMoveSensibility: number;
  125688. private _yAxisScale;
  125689. /**
  125690. * Gets or sets a boolean indicating that Yaxis (for right stick) should be inverted
  125691. */
  125692. get invertYAxis(): boolean;
  125693. set invertYAxis(value: boolean);
  125694. private _onGamepadConnectedObserver;
  125695. private _onGamepadDisconnectedObserver;
  125696. private _cameraTransform;
  125697. private _deltaTransform;
  125698. private _vector3;
  125699. private _vector2;
  125700. /**
  125701. * Attach the input controls to a specific dom element to get the input from.
  125702. * @param element Defines the element the controls should be listened from
  125703. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125704. */
  125705. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125706. /**
  125707. * Detach the current controls from the specified dom element.
  125708. * @param element Defines the element to stop listening the inputs from
  125709. */
  125710. detachControl(element: Nullable<HTMLElement>): void;
  125711. /**
  125712. * Update the current camera state depending on the inputs that have been used this frame.
  125713. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125714. */
  125715. checkInputs(): void;
  125716. /**
  125717. * Gets the class name of the current intput.
  125718. * @returns the class name
  125719. */
  125720. getClassName(): string;
  125721. /**
  125722. * Get the friendly name associated with the input class.
  125723. * @returns the input friendly name
  125724. */
  125725. getSimpleName(): string;
  125726. }
  125727. }
  125728. declare module BABYLON {
  125729. /**
  125730. * Defines the potential axis of a Joystick
  125731. */
  125732. export enum JoystickAxis {
  125733. /** X axis */
  125734. X = 0,
  125735. /** Y axis */
  125736. Y = 1,
  125737. /** Z axis */
  125738. Z = 2
  125739. }
  125740. /**
  125741. * Represents the different customization options available
  125742. * for VirtualJoystick
  125743. */
  125744. interface VirtualJoystickCustomizations {
  125745. /**
  125746. * Size of the joystick's puck
  125747. */
  125748. puckSize: number;
  125749. /**
  125750. * Size of the joystick's container
  125751. */
  125752. containerSize: number;
  125753. /**
  125754. * Color of the joystick && puck
  125755. */
  125756. color: string;
  125757. /**
  125758. * Image URL for the joystick's puck
  125759. */
  125760. puckImage?: string;
  125761. /**
  125762. * Image URL for the joystick's container
  125763. */
  125764. containerImage?: string;
  125765. /**
  125766. * Defines the unmoving position of the joystick container
  125767. */
  125768. position?: {
  125769. x: number;
  125770. y: number;
  125771. };
  125772. /**
  125773. * Defines whether or not the joystick container is always visible
  125774. */
  125775. alwaysVisible: boolean;
  125776. /**
  125777. * Defines whether or not to limit the movement of the puck to the joystick's container
  125778. */
  125779. limitToContainer: boolean;
  125780. }
  125781. /**
  125782. * Class used to define virtual joystick (used in touch mode)
  125783. */
  125784. export class VirtualJoystick {
  125785. /**
  125786. * Gets or sets a boolean indicating that left and right values must be inverted
  125787. */
  125788. reverseLeftRight: boolean;
  125789. /**
  125790. * Gets or sets a boolean indicating that up and down values must be inverted
  125791. */
  125792. reverseUpDown: boolean;
  125793. /**
  125794. * Gets the offset value for the position (ie. the change of the position value)
  125795. */
  125796. deltaPosition: Vector3;
  125797. /**
  125798. * Gets a boolean indicating if the virtual joystick was pressed
  125799. */
  125800. pressed: boolean;
  125801. /**
  125802. * Canvas the virtual joystick will render onto, default z-index of this is 5
  125803. */
  125804. static Canvas: Nullable<HTMLCanvasElement>;
  125805. /**
  125806. * boolean indicating whether or not the joystick's puck's movement should be limited to the joystick's container area
  125807. */
  125808. limitToContainer: boolean;
  125809. private static _globalJoystickIndex;
  125810. private static _alwaysVisibleSticks;
  125811. private static vjCanvasContext;
  125812. private static vjCanvasWidth;
  125813. private static vjCanvasHeight;
  125814. private static halfWidth;
  125815. private static _GetDefaultOptions;
  125816. private _action;
  125817. private _axisTargetedByLeftAndRight;
  125818. private _axisTargetedByUpAndDown;
  125819. private _joystickSensibility;
  125820. private _inversedSensibility;
  125821. private _joystickPointerID;
  125822. private _joystickColor;
  125823. private _joystickPointerPos;
  125824. private _joystickPreviousPointerPos;
  125825. private _joystickPointerStartPos;
  125826. private _deltaJoystickVector;
  125827. private _leftJoystick;
  125828. private _touches;
  125829. private _joystickPosition;
  125830. private _alwaysVisible;
  125831. private _puckImage;
  125832. private _containerImage;
  125833. private _joystickPuckSize;
  125834. private _joystickContainerSize;
  125835. private _clearPuckSize;
  125836. private _clearContainerSize;
  125837. private _clearPuckSizeOffset;
  125838. private _clearContainerSizeOffset;
  125839. private _onPointerDownHandlerRef;
  125840. private _onPointerMoveHandlerRef;
  125841. private _onPointerUpHandlerRef;
  125842. private _onResize;
  125843. /**
  125844. * Creates a new virtual joystick
  125845. * @param leftJoystick defines that the joystick is for left hand (false by default)
  125846. * @param customizations Defines the options we want to customize the VirtualJoystick
  125847. */
  125848. constructor(leftJoystick?: boolean, customizations?: Partial<VirtualJoystickCustomizations>);
  125849. /**
  125850. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  125851. * @param newJoystickSensibility defines the new sensibility
  125852. */
  125853. setJoystickSensibility(newJoystickSensibility: number): void;
  125854. private _onPointerDown;
  125855. private _onPointerMove;
  125856. private _onPointerUp;
  125857. /**
  125858. * Change the color of the virtual joystick
  125859. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  125860. */
  125861. setJoystickColor(newColor: string): void;
  125862. /**
  125863. * Size of the joystick's container
  125864. */
  125865. set containerSize(newSize: number);
  125866. get containerSize(): number;
  125867. /**
  125868. * Size of the joystick's puck
  125869. */
  125870. set puckSize(newSize: number);
  125871. get puckSize(): number;
  125872. /**
  125873. * Clears the set position of the joystick
  125874. */
  125875. clearPosition(): void;
  125876. /**
  125877. * Defines whether or not the joystick container is always visible
  125878. */
  125879. set alwaysVisible(value: boolean);
  125880. get alwaysVisible(): boolean;
  125881. /**
  125882. * Sets the constant position of the Joystick container
  125883. * @param x X axis coordinate
  125884. * @param y Y axis coordinate
  125885. */
  125886. setPosition(x: number, y: number): void;
  125887. /**
  125888. * Defines a callback to call when the joystick is touched
  125889. * @param action defines the callback
  125890. */
  125891. setActionOnTouch(action: () => any): void;
  125892. /**
  125893. * Defines which axis you'd like to control for left & right
  125894. * @param axis defines the axis to use
  125895. */
  125896. setAxisForLeftRight(axis: JoystickAxis): void;
  125897. /**
  125898. * Defines which axis you'd like to control for up & down
  125899. * @param axis defines the axis to use
  125900. */
  125901. setAxisForUpDown(axis: JoystickAxis): void;
  125902. /**
  125903. * Clears the canvas from the previous puck / container draw
  125904. */
  125905. private _clearPreviousDraw;
  125906. /**
  125907. * Loads `urlPath` to be used for the container's image
  125908. * @param urlPath defines the urlPath of an image to use
  125909. */
  125910. setContainerImage(urlPath: string): void;
  125911. /**
  125912. * Loads `urlPath` to be used for the puck's image
  125913. * @param urlPath defines the urlPath of an image to use
  125914. */
  125915. setPuckImage(urlPath: string): void;
  125916. /**
  125917. * Draws the Virtual Joystick's container
  125918. */
  125919. private _drawContainer;
  125920. /**
  125921. * Draws the Virtual Joystick's puck
  125922. */
  125923. private _drawPuck;
  125924. private _drawVirtualJoystick;
  125925. /**
  125926. * Release internal HTML canvas
  125927. */
  125928. releaseCanvas(): void;
  125929. }
  125930. }
  125931. declare module BABYLON {
  125932. interface FreeCameraInputsManager {
  125933. /**
  125934. * Add virtual joystick input support to the input manager.
  125935. * @returns the current input manager
  125936. */
  125937. addVirtualJoystick(): FreeCameraInputsManager;
  125938. }
  125939. /**
  125940. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  125941. * @see https://doc.babylonjs.com/how_to/customizing_camera_inputs
  125942. */
  125943. export class FreeCameraVirtualJoystickInput implements ICameraInput<FreeCamera> {
  125944. /**
  125945. * Defines the camera the input is attached to.
  125946. */
  125947. camera: FreeCamera;
  125948. private _leftjoystick;
  125949. private _rightjoystick;
  125950. /**
  125951. * Gets the left stick of the virtual joystick.
  125952. * @returns The virtual Joystick
  125953. */
  125954. getLeftJoystick(): VirtualJoystick;
  125955. /**
  125956. * Gets the right stick of the virtual joystick.
  125957. * @returns The virtual Joystick
  125958. */
  125959. getRightJoystick(): VirtualJoystick;
  125960. /**
  125961. * Update the current camera state depending on the inputs that have been used this frame.
  125962. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  125963. */
  125964. checkInputs(): void;
  125965. /**
  125966. * Attach the input controls to a specific dom element to get the input from.
  125967. * @param element Defines the element the controls should be listened from
  125968. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  125969. */
  125970. attachControl(element: HTMLElement, noPreventDefault?: boolean): void;
  125971. /**
  125972. * Detach the current controls from the specified dom element.
  125973. * @param element Defines the element to stop listening the inputs from
  125974. */
  125975. detachControl(element: Nullable<HTMLElement>): void;
  125976. /**
  125977. * Gets the class name of the current intput.
  125978. * @returns the class name
  125979. */
  125980. getClassName(): string;
  125981. /**
  125982. * Get the friendly name associated with the input class.
  125983. * @returns the input friendly name
  125984. */
  125985. getSimpleName(): string;
  125986. }
  125987. }
  125988. declare module BABYLON {
  125989. /**
  125990. * This represents a FPS type of camera controlled by touch.
  125991. * This is like a universal camera minus the Gamepad controls.
  125992. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  125993. */
  125994. export class TouchCamera extends FreeCamera {
  125995. /**
  125996. * Defines the touch sensibility for rotation.
  125997. * The higher the faster.
  125998. */
  125999. get touchAngularSensibility(): number;
  126000. set touchAngularSensibility(value: number);
  126001. /**
  126002. * Defines the touch sensibility for move.
  126003. * The higher the faster.
  126004. */
  126005. get touchMoveSensibility(): number;
  126006. set touchMoveSensibility(value: number);
  126007. /**
  126008. * Instantiates a new touch camera.
  126009. * This represents a FPS type of camera controlled by touch.
  126010. * This is like a universal camera minus the Gamepad controls.
  126011. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126012. * @param name Define the name of the camera in the scene
  126013. * @param position Define the start position of the camera in the scene
  126014. * @param scene Define the scene the camera belongs to
  126015. */
  126016. constructor(name: string, position: Vector3, scene: Scene);
  126017. /**
  126018. * Gets the current object class name.
  126019. * @return the class name
  126020. */
  126021. getClassName(): string;
  126022. /** @hidden */
  126023. _setupInputs(): void;
  126024. }
  126025. }
  126026. declare module BABYLON {
  126027. /**
  126028. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  126029. * being tilted forward or back and left or right.
  126030. */
  126031. export class DeviceOrientationCamera extends FreeCamera {
  126032. private _initialQuaternion;
  126033. private _quaternionCache;
  126034. private _tmpDragQuaternion;
  126035. private _disablePointerInputWhenUsingDeviceOrientation;
  126036. /**
  126037. * Creates a new device orientation camera
  126038. * @param name The name of the camera
  126039. * @param position The start position camera
  126040. * @param scene The scene the camera belongs to
  126041. */
  126042. constructor(name: string, position: Vector3, scene: Scene);
  126043. /**
  126044. * Gets or sets a boolean indicating that pointer input must be disabled on first orientation sensor update (Default: true)
  126045. */
  126046. get disablePointerInputWhenUsingDeviceOrientation(): boolean;
  126047. set disablePointerInputWhenUsingDeviceOrientation(value: boolean);
  126048. private _dragFactor;
  126049. /**
  126050. * Enabled turning on the y axis when the orientation sensor is active
  126051. * @param dragFactor the factor that controls the turn speed (default: 1/300)
  126052. */
  126053. enableHorizontalDragging(dragFactor?: number): void;
  126054. /**
  126055. * Gets the current instance class name ("DeviceOrientationCamera").
  126056. * This helps avoiding instanceof at run time.
  126057. * @returns the class name
  126058. */
  126059. getClassName(): string;
  126060. /**
  126061. * @hidden
  126062. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  126063. */
  126064. _checkInputs(): void;
  126065. /**
  126066. * Reset the camera to its default orientation on the specified axis only.
  126067. * @param axis The axis to reset
  126068. */
  126069. resetToCurrentRotation(axis?: Axis): void;
  126070. }
  126071. }
  126072. declare module BABYLON {
  126073. /**
  126074. * Defines supported buttons for XBox360 compatible gamepads
  126075. */
  126076. export enum Xbox360Button {
  126077. /** A */
  126078. A = 0,
  126079. /** B */
  126080. B = 1,
  126081. /** X */
  126082. X = 2,
  126083. /** Y */
  126084. Y = 3,
  126085. /** Left button */
  126086. LB = 4,
  126087. /** Right button */
  126088. RB = 5,
  126089. /** Back */
  126090. Back = 8,
  126091. /** Start */
  126092. Start = 9,
  126093. /** Left stick */
  126094. LeftStick = 10,
  126095. /** Right stick */
  126096. RightStick = 11
  126097. }
  126098. /** Defines values for XBox360 DPad */
  126099. export enum Xbox360Dpad {
  126100. /** Up */
  126101. Up = 12,
  126102. /** Down */
  126103. Down = 13,
  126104. /** Left */
  126105. Left = 14,
  126106. /** Right */
  126107. Right = 15
  126108. }
  126109. /**
  126110. * Defines a XBox360 gamepad
  126111. */
  126112. export class Xbox360Pad extends Gamepad {
  126113. private _leftTrigger;
  126114. private _rightTrigger;
  126115. private _onlefttriggerchanged;
  126116. private _onrighttriggerchanged;
  126117. private _onbuttondown;
  126118. private _onbuttonup;
  126119. private _ondpaddown;
  126120. private _ondpadup;
  126121. /** Observable raised when a button is pressed */
  126122. onButtonDownObservable: Observable<Xbox360Button>;
  126123. /** Observable raised when a button is released */
  126124. onButtonUpObservable: Observable<Xbox360Button>;
  126125. /** Observable raised when a pad is pressed */
  126126. onPadDownObservable: Observable<Xbox360Dpad>;
  126127. /** Observable raised when a pad is released */
  126128. onPadUpObservable: Observable<Xbox360Dpad>;
  126129. private _buttonA;
  126130. private _buttonB;
  126131. private _buttonX;
  126132. private _buttonY;
  126133. private _buttonBack;
  126134. private _buttonStart;
  126135. private _buttonLB;
  126136. private _buttonRB;
  126137. private _buttonLeftStick;
  126138. private _buttonRightStick;
  126139. private _dPadUp;
  126140. private _dPadDown;
  126141. private _dPadLeft;
  126142. private _dPadRight;
  126143. private _isXboxOnePad;
  126144. /**
  126145. * Creates a new XBox360 gamepad object
  126146. * @param id defines the id of this gamepad
  126147. * @param index defines its index
  126148. * @param gamepad defines the internal HTML gamepad object
  126149. * @param xboxOne defines if it is a XBox One gamepad
  126150. */
  126151. constructor(id: string, index: number, gamepad: any, xboxOne?: boolean);
  126152. /**
  126153. * Defines the callback to call when left trigger is pressed
  126154. * @param callback defines the callback to use
  126155. */
  126156. onlefttriggerchanged(callback: (value: number) => void): void;
  126157. /**
  126158. * Defines the callback to call when right trigger is pressed
  126159. * @param callback defines the callback to use
  126160. */
  126161. onrighttriggerchanged(callback: (value: number) => void): void;
  126162. /**
  126163. * Gets the left trigger value
  126164. */
  126165. get leftTrigger(): number;
  126166. /**
  126167. * Sets the left trigger value
  126168. */
  126169. set leftTrigger(newValue: number);
  126170. /**
  126171. * Gets the right trigger value
  126172. */
  126173. get rightTrigger(): number;
  126174. /**
  126175. * Sets the right trigger value
  126176. */
  126177. set rightTrigger(newValue: number);
  126178. /**
  126179. * Defines the callback to call when a button is pressed
  126180. * @param callback defines the callback to use
  126181. */
  126182. onbuttondown(callback: (buttonPressed: Xbox360Button) => void): void;
  126183. /**
  126184. * Defines the callback to call when a button is released
  126185. * @param callback defines the callback to use
  126186. */
  126187. onbuttonup(callback: (buttonReleased: Xbox360Button) => void): void;
  126188. /**
  126189. * Defines the callback to call when a pad is pressed
  126190. * @param callback defines the callback to use
  126191. */
  126192. ondpaddown(callback: (dPadPressed: Xbox360Dpad) => void): void;
  126193. /**
  126194. * Defines the callback to call when a pad is released
  126195. * @param callback defines the callback to use
  126196. */
  126197. ondpadup(callback: (dPadReleased: Xbox360Dpad) => void): void;
  126198. private _setButtonValue;
  126199. private _setDPadValue;
  126200. /**
  126201. * Gets the value of the `A` button
  126202. */
  126203. get buttonA(): number;
  126204. /**
  126205. * Sets the value of the `A` button
  126206. */
  126207. set buttonA(value: number);
  126208. /**
  126209. * Gets the value of the `B` button
  126210. */
  126211. get buttonB(): number;
  126212. /**
  126213. * Sets the value of the `B` button
  126214. */
  126215. set buttonB(value: number);
  126216. /**
  126217. * Gets the value of the `X` button
  126218. */
  126219. get buttonX(): number;
  126220. /**
  126221. * Sets the value of the `X` button
  126222. */
  126223. set buttonX(value: number);
  126224. /**
  126225. * Gets the value of the `Y` button
  126226. */
  126227. get buttonY(): number;
  126228. /**
  126229. * Sets the value of the `Y` button
  126230. */
  126231. set buttonY(value: number);
  126232. /**
  126233. * Gets the value of the `Start` button
  126234. */
  126235. get buttonStart(): number;
  126236. /**
  126237. * Sets the value of the `Start` button
  126238. */
  126239. set buttonStart(value: number);
  126240. /**
  126241. * Gets the value of the `Back` button
  126242. */
  126243. get buttonBack(): number;
  126244. /**
  126245. * Sets the value of the `Back` button
  126246. */
  126247. set buttonBack(value: number);
  126248. /**
  126249. * Gets the value of the `Left` button
  126250. */
  126251. get buttonLB(): number;
  126252. /**
  126253. * Sets the value of the `Left` button
  126254. */
  126255. set buttonLB(value: number);
  126256. /**
  126257. * Gets the value of the `Right` button
  126258. */
  126259. get buttonRB(): number;
  126260. /**
  126261. * Sets the value of the `Right` button
  126262. */
  126263. set buttonRB(value: number);
  126264. /**
  126265. * Gets the value of the Left joystick
  126266. */
  126267. get buttonLeftStick(): number;
  126268. /**
  126269. * Sets the value of the Left joystick
  126270. */
  126271. set buttonLeftStick(value: number);
  126272. /**
  126273. * Gets the value of the Right joystick
  126274. */
  126275. get buttonRightStick(): number;
  126276. /**
  126277. * Sets the value of the Right joystick
  126278. */
  126279. set buttonRightStick(value: number);
  126280. /**
  126281. * Gets the value of D-pad up
  126282. */
  126283. get dPadUp(): number;
  126284. /**
  126285. * Sets the value of D-pad up
  126286. */
  126287. set dPadUp(value: number);
  126288. /**
  126289. * Gets the value of D-pad down
  126290. */
  126291. get dPadDown(): number;
  126292. /**
  126293. * Sets the value of D-pad down
  126294. */
  126295. set dPadDown(value: number);
  126296. /**
  126297. * Gets the value of D-pad left
  126298. */
  126299. get dPadLeft(): number;
  126300. /**
  126301. * Sets the value of D-pad left
  126302. */
  126303. set dPadLeft(value: number);
  126304. /**
  126305. * Gets the value of D-pad right
  126306. */
  126307. get dPadRight(): number;
  126308. /**
  126309. * Sets the value of D-pad right
  126310. */
  126311. set dPadRight(value: number);
  126312. /**
  126313. * Force the gamepad to synchronize with device values
  126314. */
  126315. update(): void;
  126316. /**
  126317. * Disposes the gamepad
  126318. */
  126319. dispose(): void;
  126320. }
  126321. }
  126322. declare module BABYLON {
  126323. /**
  126324. * Defines supported buttons for DualShock compatible gamepads
  126325. */
  126326. export enum DualShockButton {
  126327. /** Cross */
  126328. Cross = 0,
  126329. /** Circle */
  126330. Circle = 1,
  126331. /** Square */
  126332. Square = 2,
  126333. /** Triangle */
  126334. Triangle = 3,
  126335. /** L1 */
  126336. L1 = 4,
  126337. /** R1 */
  126338. R1 = 5,
  126339. /** Share */
  126340. Share = 8,
  126341. /** Options */
  126342. Options = 9,
  126343. /** Left stick */
  126344. LeftStick = 10,
  126345. /** Right stick */
  126346. RightStick = 11
  126347. }
  126348. /** Defines values for DualShock DPad */
  126349. export enum DualShockDpad {
  126350. /** Up */
  126351. Up = 12,
  126352. /** Down */
  126353. Down = 13,
  126354. /** Left */
  126355. Left = 14,
  126356. /** Right */
  126357. Right = 15
  126358. }
  126359. /**
  126360. * Defines a DualShock gamepad
  126361. */
  126362. export class DualShockPad extends Gamepad {
  126363. private _leftTrigger;
  126364. private _rightTrigger;
  126365. private _onlefttriggerchanged;
  126366. private _onrighttriggerchanged;
  126367. private _onbuttondown;
  126368. private _onbuttonup;
  126369. private _ondpaddown;
  126370. private _ondpadup;
  126371. /** Observable raised when a button is pressed */
  126372. onButtonDownObservable: Observable<DualShockButton>;
  126373. /** Observable raised when a button is released */
  126374. onButtonUpObservable: Observable<DualShockButton>;
  126375. /** Observable raised when a pad is pressed */
  126376. onPadDownObservable: Observable<DualShockDpad>;
  126377. /** Observable raised when a pad is released */
  126378. onPadUpObservable: Observable<DualShockDpad>;
  126379. private _buttonCross;
  126380. private _buttonCircle;
  126381. private _buttonSquare;
  126382. private _buttonTriangle;
  126383. private _buttonShare;
  126384. private _buttonOptions;
  126385. private _buttonL1;
  126386. private _buttonR1;
  126387. private _buttonLeftStick;
  126388. private _buttonRightStick;
  126389. private _dPadUp;
  126390. private _dPadDown;
  126391. private _dPadLeft;
  126392. private _dPadRight;
  126393. /**
  126394. * Creates a new DualShock gamepad object
  126395. * @param id defines the id of this gamepad
  126396. * @param index defines its index
  126397. * @param gamepad defines the internal HTML gamepad object
  126398. */
  126399. constructor(id: string, index: number, gamepad: any);
  126400. /**
  126401. * Defines the callback to call when left trigger is pressed
  126402. * @param callback defines the callback to use
  126403. */
  126404. onlefttriggerchanged(callback: (value: number) => void): void;
  126405. /**
  126406. * Defines the callback to call when right trigger is pressed
  126407. * @param callback defines the callback to use
  126408. */
  126409. onrighttriggerchanged(callback: (value: number) => void): void;
  126410. /**
  126411. * Gets the left trigger value
  126412. */
  126413. get leftTrigger(): number;
  126414. /**
  126415. * Sets the left trigger value
  126416. */
  126417. set leftTrigger(newValue: number);
  126418. /**
  126419. * Gets the right trigger value
  126420. */
  126421. get rightTrigger(): number;
  126422. /**
  126423. * Sets the right trigger value
  126424. */
  126425. set rightTrigger(newValue: number);
  126426. /**
  126427. * Defines the callback to call when a button is pressed
  126428. * @param callback defines the callback to use
  126429. */
  126430. onbuttondown(callback: (buttonPressed: DualShockButton) => void): void;
  126431. /**
  126432. * Defines the callback to call when a button is released
  126433. * @param callback defines the callback to use
  126434. */
  126435. onbuttonup(callback: (buttonReleased: DualShockButton) => void): void;
  126436. /**
  126437. * Defines the callback to call when a pad is pressed
  126438. * @param callback defines the callback to use
  126439. */
  126440. ondpaddown(callback: (dPadPressed: DualShockDpad) => void): void;
  126441. /**
  126442. * Defines the callback to call when a pad is released
  126443. * @param callback defines the callback to use
  126444. */
  126445. ondpadup(callback: (dPadReleased: DualShockDpad) => void): void;
  126446. private _setButtonValue;
  126447. private _setDPadValue;
  126448. /**
  126449. * Gets the value of the `Cross` button
  126450. */
  126451. get buttonCross(): number;
  126452. /**
  126453. * Sets the value of the `Cross` button
  126454. */
  126455. set buttonCross(value: number);
  126456. /**
  126457. * Gets the value of the `Circle` button
  126458. */
  126459. get buttonCircle(): number;
  126460. /**
  126461. * Sets the value of the `Circle` button
  126462. */
  126463. set buttonCircle(value: number);
  126464. /**
  126465. * Gets the value of the `Square` button
  126466. */
  126467. get buttonSquare(): number;
  126468. /**
  126469. * Sets the value of the `Square` button
  126470. */
  126471. set buttonSquare(value: number);
  126472. /**
  126473. * Gets the value of the `Triangle` button
  126474. */
  126475. get buttonTriangle(): number;
  126476. /**
  126477. * Sets the value of the `Triangle` button
  126478. */
  126479. set buttonTriangle(value: number);
  126480. /**
  126481. * Gets the value of the `Options` button
  126482. */
  126483. get buttonOptions(): number;
  126484. /**
  126485. * Sets the value of the `Options` button
  126486. */
  126487. set buttonOptions(value: number);
  126488. /**
  126489. * Gets the value of the `Share` button
  126490. */
  126491. get buttonShare(): number;
  126492. /**
  126493. * Sets the value of the `Share` button
  126494. */
  126495. set buttonShare(value: number);
  126496. /**
  126497. * Gets the value of the `L1` button
  126498. */
  126499. get buttonL1(): number;
  126500. /**
  126501. * Sets the value of the `L1` button
  126502. */
  126503. set buttonL1(value: number);
  126504. /**
  126505. * Gets the value of the `R1` button
  126506. */
  126507. get buttonR1(): number;
  126508. /**
  126509. * Sets the value of the `R1` button
  126510. */
  126511. set buttonR1(value: number);
  126512. /**
  126513. * Gets the value of the Left joystick
  126514. */
  126515. get buttonLeftStick(): number;
  126516. /**
  126517. * Sets the value of the Left joystick
  126518. */
  126519. set buttonLeftStick(value: number);
  126520. /**
  126521. * Gets the value of the Right joystick
  126522. */
  126523. get buttonRightStick(): number;
  126524. /**
  126525. * Sets the value of the Right joystick
  126526. */
  126527. set buttonRightStick(value: number);
  126528. /**
  126529. * Gets the value of D-pad up
  126530. */
  126531. get dPadUp(): number;
  126532. /**
  126533. * Sets the value of D-pad up
  126534. */
  126535. set dPadUp(value: number);
  126536. /**
  126537. * Gets the value of D-pad down
  126538. */
  126539. get dPadDown(): number;
  126540. /**
  126541. * Sets the value of D-pad down
  126542. */
  126543. set dPadDown(value: number);
  126544. /**
  126545. * Gets the value of D-pad left
  126546. */
  126547. get dPadLeft(): number;
  126548. /**
  126549. * Sets the value of D-pad left
  126550. */
  126551. set dPadLeft(value: number);
  126552. /**
  126553. * Gets the value of D-pad right
  126554. */
  126555. get dPadRight(): number;
  126556. /**
  126557. * Sets the value of D-pad right
  126558. */
  126559. set dPadRight(value: number);
  126560. /**
  126561. * Force the gamepad to synchronize with device values
  126562. */
  126563. update(): void;
  126564. /**
  126565. * Disposes the gamepad
  126566. */
  126567. dispose(): void;
  126568. }
  126569. }
  126570. declare module BABYLON {
  126571. /**
  126572. * Manager for handling gamepads
  126573. */
  126574. export class GamepadManager {
  126575. private _scene?;
  126576. private _babylonGamepads;
  126577. private _oneGamepadConnected;
  126578. /** @hidden */
  126579. _isMonitoring: boolean;
  126580. private _gamepadEventSupported;
  126581. private _gamepadSupport?;
  126582. /**
  126583. * observable to be triggered when the gamepad controller has been connected
  126584. */
  126585. onGamepadConnectedObservable: Observable<Gamepad>;
  126586. /**
  126587. * observable to be triggered when the gamepad controller has been disconnected
  126588. */
  126589. onGamepadDisconnectedObservable: Observable<Gamepad>;
  126590. private _onGamepadConnectedEvent;
  126591. private _onGamepadDisconnectedEvent;
  126592. /**
  126593. * Initializes the gamepad manager
  126594. * @param _scene BabylonJS scene
  126595. */
  126596. constructor(_scene?: Scene | undefined);
  126597. /**
  126598. * The gamepads in the game pad manager
  126599. */
  126600. get gamepads(): Gamepad[];
  126601. /**
  126602. * Get the gamepad controllers based on type
  126603. * @param type The type of gamepad controller
  126604. * @returns Nullable gamepad
  126605. */
  126606. getGamepadByType(type?: number): Nullable<Gamepad>;
  126607. /**
  126608. * Disposes the gamepad manager
  126609. */
  126610. dispose(): void;
  126611. private _addNewGamepad;
  126612. private _startMonitoringGamepads;
  126613. private _stopMonitoringGamepads;
  126614. /** @hidden */
  126615. _checkGamepadsStatus(): void;
  126616. private _updateGamepadObjects;
  126617. }
  126618. }
  126619. declare module BABYLON {
  126620. interface Scene {
  126621. /** @hidden */
  126622. _gamepadManager: Nullable<GamepadManager>;
  126623. /**
  126624. * Gets the gamepad manager associated with the scene
  126625. * @see https://doc.babylonjs.com/how_to/how_to_use_gamepads
  126626. */
  126627. gamepadManager: GamepadManager;
  126628. }
  126629. /**
  126630. * Interface representing a free camera inputs manager
  126631. */
  126632. interface FreeCameraInputsManager {
  126633. /**
  126634. * Adds gamepad input support to the FreeCameraInputsManager.
  126635. * @returns the FreeCameraInputsManager
  126636. */
  126637. addGamepad(): FreeCameraInputsManager;
  126638. }
  126639. /**
  126640. * Interface representing an arc rotate camera inputs manager
  126641. */
  126642. interface ArcRotateCameraInputsManager {
  126643. /**
  126644. * Adds gamepad input support to the ArcRotateCamera InputManager.
  126645. * @returns the camera inputs manager
  126646. */
  126647. addGamepad(): ArcRotateCameraInputsManager;
  126648. }
  126649. /**
  126650. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  126651. */
  126652. export class GamepadSystemSceneComponent implements ISceneComponent {
  126653. /**
  126654. * The component name helpfull to identify the component in the list of scene components.
  126655. */
  126656. readonly name: string;
  126657. /**
  126658. * The scene the component belongs to.
  126659. */
  126660. scene: Scene;
  126661. /**
  126662. * Creates a new instance of the component for the given scene
  126663. * @param scene Defines the scene to register the component in
  126664. */
  126665. constructor(scene: Scene);
  126666. /**
  126667. * Registers the component in a given scene
  126668. */
  126669. register(): void;
  126670. /**
  126671. * Rebuilds the elements related to this component in case of
  126672. * context lost for instance.
  126673. */
  126674. rebuild(): void;
  126675. /**
  126676. * Disposes the component and the associated ressources
  126677. */
  126678. dispose(): void;
  126679. private _beforeCameraUpdate;
  126680. }
  126681. }
  126682. declare module BABYLON {
  126683. /**
  126684. * 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,
  126685. * which still works and will still be found in many Playgrounds.
  126686. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126687. */
  126688. export class UniversalCamera extends TouchCamera {
  126689. /**
  126690. * Defines the gamepad rotation sensiblity.
  126691. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  126692. */
  126693. get gamepadAngularSensibility(): number;
  126694. set gamepadAngularSensibility(value: number);
  126695. /**
  126696. * Defines the gamepad move sensiblity.
  126697. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  126698. */
  126699. get gamepadMoveSensibility(): number;
  126700. set gamepadMoveSensibility(value: number);
  126701. /**
  126702. * 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,
  126703. * which still works and will still be found in many Playgrounds.
  126704. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126705. * @param name Define the name of the camera in the scene
  126706. * @param position Define the start position of the camera in the scene
  126707. * @param scene Define the scene the camera belongs to
  126708. */
  126709. constructor(name: string, position: Vector3, scene: Scene);
  126710. /**
  126711. * Gets the current object class name.
  126712. * @return the class name
  126713. */
  126714. getClassName(): string;
  126715. }
  126716. }
  126717. declare module BABYLON {
  126718. /**
  126719. * This represents a FPS type of camera. This is only here for back compat purpose.
  126720. * Please use the UniversalCamera instead as both are identical.
  126721. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126722. */
  126723. export class GamepadCamera extends UniversalCamera {
  126724. /**
  126725. * Instantiates a new Gamepad Camera
  126726. * This represents a FPS type of camera. This is only here for back compat purpose.
  126727. * Please use the UniversalCamera instead as both are identical.
  126728. * @see https://doc.babylonjs.com/features/cameras#universal-camera
  126729. * @param name Define the name of the camera in the scene
  126730. * @param position Define the start position of the camera in the scene
  126731. * @param scene Define the scene the camera belongs to
  126732. */
  126733. constructor(name: string, position: Vector3, scene: Scene);
  126734. /**
  126735. * Gets the current object class name.
  126736. * @return the class name
  126737. */
  126738. getClassName(): string;
  126739. }
  126740. }
  126741. declare module BABYLON {
  126742. /** @hidden */
  126743. export var passPixelShader: {
  126744. name: string;
  126745. shader: string;
  126746. };
  126747. }
  126748. declare module BABYLON {
  126749. /** @hidden */
  126750. export var passCubePixelShader: {
  126751. name: string;
  126752. shader: string;
  126753. };
  126754. }
  126755. declare module BABYLON {
  126756. /**
  126757. * PassPostProcess which produces an output the same as it's input
  126758. */
  126759. export class PassPostProcess extends PostProcess {
  126760. /**
  126761. * Gets a string identifying the name of the class
  126762. * @returns "PassPostProcess" string
  126763. */
  126764. getClassName(): string;
  126765. /**
  126766. * Creates the PassPostProcess
  126767. * @param name The name of the effect.
  126768. * @param options The required width/height ratio to downsize to before computing the render pass.
  126769. * @param camera The camera to apply the render pass to.
  126770. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126771. * @param engine The engine which the post process will be applied. (default: current engine)
  126772. * @param reusable If the post process can be reused on the same frame. (default: false)
  126773. * @param textureType The type of texture to be used when performing the post processing.
  126774. * @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)
  126775. */
  126776. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126777. /** @hidden */
  126778. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassPostProcess;
  126779. }
  126780. /**
  126781. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  126782. */
  126783. export class PassCubePostProcess extends PostProcess {
  126784. private _face;
  126785. /**
  126786. * Gets or sets the cube face to display.
  126787. * * 0 is +X
  126788. * * 1 is -X
  126789. * * 2 is +Y
  126790. * * 3 is -Y
  126791. * * 4 is +Z
  126792. * * 5 is -Z
  126793. */
  126794. get face(): number;
  126795. set face(value: number);
  126796. /**
  126797. * Gets a string identifying the name of the class
  126798. * @returns "PassCubePostProcess" string
  126799. */
  126800. getClassName(): string;
  126801. /**
  126802. * Creates the PassCubePostProcess
  126803. * @param name The name of the effect.
  126804. * @param options The required width/height ratio to downsize to before computing the render pass.
  126805. * @param camera The camera to apply the render pass to.
  126806. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  126807. * @param engine The engine which the post process will be applied. (default: current engine)
  126808. * @param reusable If the post process can be reused on the same frame. (default: false)
  126809. * @param textureType The type of texture to be used when performing the post processing.
  126810. * @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)
  126811. */
  126812. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  126813. /** @hidden */
  126814. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): PassCubePostProcess;
  126815. }
  126816. }
  126817. declare module BABYLON {
  126818. /** @hidden */
  126819. export var anaglyphPixelShader: {
  126820. name: string;
  126821. shader: string;
  126822. };
  126823. }
  126824. declare module BABYLON {
  126825. /**
  126826. * Postprocess used to generate anaglyphic rendering
  126827. */
  126828. export class AnaglyphPostProcess extends PostProcess {
  126829. private _passedProcess;
  126830. /**
  126831. * Gets a string identifying the name of the class
  126832. * @returns "AnaglyphPostProcess" string
  126833. */
  126834. getClassName(): string;
  126835. /**
  126836. * Creates a new AnaglyphPostProcess
  126837. * @param name defines postprocess name
  126838. * @param options defines creation options or target ratio scale
  126839. * @param rigCameras defines cameras using this postprocess
  126840. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  126841. * @param engine defines hosting engine
  126842. * @param reusable defines if the postprocess will be reused multiple times per frame
  126843. */
  126844. constructor(name: string, options: number | PostProcessOptions, rigCameras: Camera[], samplingMode?: number, engine?: Engine, reusable?: boolean);
  126845. }
  126846. }
  126847. declare module BABYLON {
  126848. /**
  126849. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  126850. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126851. */
  126852. export class AnaglyphArcRotateCamera extends ArcRotateCamera {
  126853. /**
  126854. * Creates a new AnaglyphArcRotateCamera
  126855. * @param name defines camera name
  126856. * @param alpha defines alpha angle (in radians)
  126857. * @param beta defines beta angle (in radians)
  126858. * @param radius defines radius
  126859. * @param target defines camera target
  126860. * @param interaxialDistance defines distance between each color axis
  126861. * @param scene defines the hosting scene
  126862. */
  126863. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, scene: Scene);
  126864. /**
  126865. * Gets camera class name
  126866. * @returns AnaglyphArcRotateCamera
  126867. */
  126868. getClassName(): string;
  126869. }
  126870. }
  126871. declare module BABYLON {
  126872. /**
  126873. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  126874. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126875. */
  126876. export class AnaglyphFreeCamera extends FreeCamera {
  126877. /**
  126878. * Creates a new AnaglyphFreeCamera
  126879. * @param name defines camera name
  126880. * @param position defines initial position
  126881. * @param interaxialDistance defines distance between each color axis
  126882. * @param scene defines the hosting scene
  126883. */
  126884. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126885. /**
  126886. * Gets camera class name
  126887. * @returns AnaglyphFreeCamera
  126888. */
  126889. getClassName(): string;
  126890. }
  126891. }
  126892. declare module BABYLON {
  126893. /**
  126894. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  126895. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126896. */
  126897. export class AnaglyphGamepadCamera extends GamepadCamera {
  126898. /**
  126899. * Creates a new AnaglyphGamepadCamera
  126900. * @param name defines camera name
  126901. * @param position defines initial position
  126902. * @param interaxialDistance defines distance between each color axis
  126903. * @param scene defines the hosting scene
  126904. */
  126905. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126906. /**
  126907. * Gets camera class name
  126908. * @returns AnaglyphGamepadCamera
  126909. */
  126910. getClassName(): string;
  126911. }
  126912. }
  126913. declare module BABYLON {
  126914. /**
  126915. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  126916. * @see https://doc.babylonjs.com/features/cameras#anaglyph-cameras
  126917. */
  126918. export class AnaglyphUniversalCamera extends UniversalCamera {
  126919. /**
  126920. * Creates a new AnaglyphUniversalCamera
  126921. * @param name defines camera name
  126922. * @param position defines initial position
  126923. * @param interaxialDistance defines distance between each color axis
  126924. * @param scene defines the hosting scene
  126925. */
  126926. constructor(name: string, position: Vector3, interaxialDistance: number, scene: Scene);
  126927. /**
  126928. * Gets camera class name
  126929. * @returns AnaglyphUniversalCamera
  126930. */
  126931. getClassName(): string;
  126932. }
  126933. }
  126934. declare module BABYLON {
  126935. /**
  126936. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  126937. * @see https://doc.babylonjs.com/features/cameras
  126938. */
  126939. export class StereoscopicArcRotateCamera extends ArcRotateCamera {
  126940. /**
  126941. * Creates a new StereoscopicArcRotateCamera
  126942. * @param name defines camera name
  126943. * @param alpha defines alpha angle (in radians)
  126944. * @param beta defines beta angle (in radians)
  126945. * @param radius defines radius
  126946. * @param target defines camera target
  126947. * @param interaxialDistance defines distance between each color axis
  126948. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126949. * @param scene defines the hosting scene
  126950. */
  126951. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126952. /**
  126953. * Gets camera class name
  126954. * @returns StereoscopicArcRotateCamera
  126955. */
  126956. getClassName(): string;
  126957. }
  126958. }
  126959. declare module BABYLON {
  126960. /**
  126961. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  126962. * @see https://doc.babylonjs.com/features/cameras
  126963. */
  126964. export class StereoscopicFreeCamera extends FreeCamera {
  126965. /**
  126966. * Creates a new StereoscopicFreeCamera
  126967. * @param name defines camera name
  126968. * @param position defines initial position
  126969. * @param interaxialDistance defines distance between each color axis
  126970. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126971. * @param scene defines the hosting scene
  126972. */
  126973. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126974. /**
  126975. * Gets camera class name
  126976. * @returns StereoscopicFreeCamera
  126977. */
  126978. getClassName(): string;
  126979. }
  126980. }
  126981. declare module BABYLON {
  126982. /**
  126983. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  126984. * @see https://doc.babylonjs.com/features/cameras
  126985. */
  126986. export class StereoscopicGamepadCamera extends GamepadCamera {
  126987. /**
  126988. * Creates a new StereoscopicGamepadCamera
  126989. * @param name defines camera name
  126990. * @param position defines initial position
  126991. * @param interaxialDistance defines distance between each color axis
  126992. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  126993. * @param scene defines the hosting scene
  126994. */
  126995. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  126996. /**
  126997. * Gets camera class name
  126998. * @returns StereoscopicGamepadCamera
  126999. */
  127000. getClassName(): string;
  127001. }
  127002. }
  127003. declare module BABYLON {
  127004. /**
  127005. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  127006. * @see https://doc.babylonjs.com/features/cameras
  127007. */
  127008. export class StereoscopicUniversalCamera extends UniversalCamera {
  127009. /**
  127010. * Creates a new StereoscopicUniversalCamera
  127011. * @param name defines camera name
  127012. * @param position defines initial position
  127013. * @param interaxialDistance defines distance between each color axis
  127014. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  127015. * @param scene defines the hosting scene
  127016. */
  127017. constructor(name: string, position: Vector3, interaxialDistance: number, isStereoscopicSideBySide: boolean, scene: Scene);
  127018. /**
  127019. * Gets camera class name
  127020. * @returns StereoscopicUniversalCamera
  127021. */
  127022. getClassName(): string;
  127023. }
  127024. }
  127025. declare module BABYLON {
  127026. /**
  127027. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  127028. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  127029. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  127030. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  127031. */
  127032. export class VirtualJoysticksCamera extends FreeCamera {
  127033. /**
  127034. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  127035. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  127036. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  127037. * @see https://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  127038. * @param name Define the name of the camera in the scene
  127039. * @param position Define the start position of the camera in the scene
  127040. * @param scene Define the scene the camera belongs to
  127041. */
  127042. constructor(name: string, position: Vector3, scene: Scene);
  127043. /**
  127044. * Gets the current object class name.
  127045. * @return the class name
  127046. */
  127047. getClassName(): string;
  127048. }
  127049. }
  127050. declare module BABYLON {
  127051. /**
  127052. * This represents all the required metrics to create a VR camera.
  127053. * @see https://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  127054. */
  127055. export class VRCameraMetrics {
  127056. /**
  127057. * Define the horizontal resolution off the screen.
  127058. */
  127059. hResolution: number;
  127060. /**
  127061. * Define the vertical resolution off the screen.
  127062. */
  127063. vResolution: number;
  127064. /**
  127065. * Define the horizontal screen size.
  127066. */
  127067. hScreenSize: number;
  127068. /**
  127069. * Define the vertical screen size.
  127070. */
  127071. vScreenSize: number;
  127072. /**
  127073. * Define the vertical screen center position.
  127074. */
  127075. vScreenCenter: number;
  127076. /**
  127077. * Define the distance of the eyes to the screen.
  127078. */
  127079. eyeToScreenDistance: number;
  127080. /**
  127081. * Define the distance between both lenses
  127082. */
  127083. lensSeparationDistance: number;
  127084. /**
  127085. * Define the distance between both viewer's eyes.
  127086. */
  127087. interpupillaryDistance: number;
  127088. /**
  127089. * Define the distortion factor of the VR postprocess.
  127090. * Please, touch with care.
  127091. */
  127092. distortionK: number[];
  127093. /**
  127094. * Define the chromatic aberration correction factors for the VR post process.
  127095. */
  127096. chromaAbCorrection: number[];
  127097. /**
  127098. * Define the scale factor of the post process.
  127099. * The smaller the better but the slower.
  127100. */
  127101. postProcessScaleFactor: number;
  127102. /**
  127103. * Define an offset for the lens center.
  127104. */
  127105. lensCenterOffset: number;
  127106. /**
  127107. * Define if the current vr camera should compensate the distortion of the lense or not.
  127108. */
  127109. compensateDistortion: boolean;
  127110. /**
  127111. * Defines if multiview should be enabled when rendering (Default: false)
  127112. */
  127113. multiviewEnabled: boolean;
  127114. /**
  127115. * Gets the rendering aspect ratio based on the provided resolutions.
  127116. */
  127117. get aspectRatio(): number;
  127118. /**
  127119. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  127120. */
  127121. get aspectRatioFov(): number;
  127122. /**
  127123. * @hidden
  127124. */
  127125. get leftHMatrix(): Matrix;
  127126. /**
  127127. * @hidden
  127128. */
  127129. get rightHMatrix(): Matrix;
  127130. /**
  127131. * @hidden
  127132. */
  127133. get leftPreViewMatrix(): Matrix;
  127134. /**
  127135. * @hidden
  127136. */
  127137. get rightPreViewMatrix(): Matrix;
  127138. /**
  127139. * Get the default VRMetrics based on the most generic setup.
  127140. * @returns the default vr metrics
  127141. */
  127142. static GetDefault(): VRCameraMetrics;
  127143. }
  127144. }
  127145. declare module BABYLON {
  127146. /** @hidden */
  127147. export var vrDistortionCorrectionPixelShader: {
  127148. name: string;
  127149. shader: string;
  127150. };
  127151. }
  127152. declare module BABYLON {
  127153. /**
  127154. * VRDistortionCorrectionPostProcess used for mobile VR
  127155. */
  127156. export class VRDistortionCorrectionPostProcess extends PostProcess {
  127157. private _isRightEye;
  127158. private _distortionFactors;
  127159. private _postProcessScaleFactor;
  127160. private _lensCenterOffset;
  127161. private _scaleIn;
  127162. private _scaleFactor;
  127163. private _lensCenter;
  127164. /**
  127165. * Gets a string identifying the name of the class
  127166. * @returns "VRDistortionCorrectionPostProcess" string
  127167. */
  127168. getClassName(): string;
  127169. /**
  127170. * Initializes the VRDistortionCorrectionPostProcess
  127171. * @param name The name of the effect.
  127172. * @param camera The camera to apply the render pass to.
  127173. * @param isRightEye If this is for the right eye distortion
  127174. * @param vrMetrics All the required metrics for the VR camera
  127175. */
  127176. constructor(name: string, camera: Camera, isRightEye: boolean, vrMetrics: VRCameraMetrics);
  127177. }
  127178. }
  127179. declare module BABYLON {
  127180. /**
  127181. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  127182. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127183. */
  127184. export class VRDeviceOrientationArcRotateCamera extends ArcRotateCamera {
  127185. /**
  127186. * Creates a new VRDeviceOrientationArcRotateCamera
  127187. * @param name defines camera name
  127188. * @param alpha defines the camera rotation along the logitudinal axis
  127189. * @param beta defines the camera rotation along the latitudinal axis
  127190. * @param radius defines the camera distance from its target
  127191. * @param target defines the camera target
  127192. * @param scene defines the scene the camera belongs to
  127193. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127194. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127195. */
  127196. constructor(name: string, alpha: number, beta: number, radius: number, target: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127197. /**
  127198. * Gets camera class name
  127199. * @returns VRDeviceOrientationArcRotateCamera
  127200. */
  127201. getClassName(): string;
  127202. }
  127203. }
  127204. declare module BABYLON {
  127205. /**
  127206. * Camera used to simulate VR rendering (based on FreeCamera)
  127207. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127208. */
  127209. export class VRDeviceOrientationFreeCamera extends DeviceOrientationCamera {
  127210. /**
  127211. * Creates a new VRDeviceOrientationFreeCamera
  127212. * @param name defines camera name
  127213. * @param position defines the start position of the camera
  127214. * @param scene defines the scene the camera belongs to
  127215. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127216. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127217. */
  127218. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127219. /**
  127220. * Gets camera class name
  127221. * @returns VRDeviceOrientationFreeCamera
  127222. */
  127223. getClassName(): string;
  127224. }
  127225. }
  127226. declare module BABYLON {
  127227. /**
  127228. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  127229. * @see https://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  127230. */
  127231. export class VRDeviceOrientationGamepadCamera extends VRDeviceOrientationFreeCamera {
  127232. /**
  127233. * Creates a new VRDeviceOrientationGamepadCamera
  127234. * @param name defines camera name
  127235. * @param position defines the start position of the camera
  127236. * @param scene defines the scene the camera belongs to
  127237. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  127238. * @param vrCameraMetrics defines the vr metrics associated to the camera
  127239. */
  127240. constructor(name: string, position: Vector3, scene: Scene, compensateDistortion?: boolean, vrCameraMetrics?: VRCameraMetrics);
  127241. /**
  127242. * Gets camera class name
  127243. * @returns VRDeviceOrientationGamepadCamera
  127244. */
  127245. getClassName(): string;
  127246. }
  127247. }
  127248. declare module BABYLON {
  127249. /**
  127250. * A class extending Texture allowing drawing on a texture
  127251. * @see https://doc.babylonjs.com/how_to/dynamictexture
  127252. */
  127253. export class DynamicTexture extends Texture {
  127254. private _generateMipMaps;
  127255. private _canvas;
  127256. private _context;
  127257. /**
  127258. * Creates a DynamicTexture
  127259. * @param name defines the name of the texture
  127260. * @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
  127261. * @param scene defines the scene where you want the texture
  127262. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  127263. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  127264. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  127265. * @param invertY defines if the texture needs to be inverted on the y axis during loading
  127266. */
  127267. constructor(name: string, options: any, scene: Scene | null | undefined, generateMipMaps: boolean, samplingMode?: number, format?: number, invertY?: boolean);
  127268. /**
  127269. * Get the current class name of the texture useful for serialization or dynamic coding.
  127270. * @returns "DynamicTexture"
  127271. */
  127272. getClassName(): string;
  127273. /**
  127274. * Gets the current state of canRescale
  127275. */
  127276. get canRescale(): boolean;
  127277. private _recreate;
  127278. /**
  127279. * Scales the texture
  127280. * @param ratio the scale factor to apply to both width and height
  127281. */
  127282. scale(ratio: number): void;
  127283. /**
  127284. * Resizes the texture
  127285. * @param width the new width
  127286. * @param height the new height
  127287. */
  127288. scaleTo(width: number, height: number): void;
  127289. /**
  127290. * Gets the context of the canvas used by the texture
  127291. * @returns the canvas context of the dynamic texture
  127292. */
  127293. getContext(): CanvasRenderingContext2D;
  127294. /**
  127295. * Clears the texture
  127296. */
  127297. clear(): void;
  127298. /**
  127299. * Updates the texture
  127300. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127301. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  127302. */
  127303. update(invertY?: boolean, premulAlpha?: boolean): void;
  127304. /**
  127305. * Draws text onto the texture
  127306. * @param text defines the text to be drawn
  127307. * @param x defines the placement of the text from the left
  127308. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  127309. * @param font defines the font to be used with font-style, font-size, font-name
  127310. * @param color defines the color used for the text
  127311. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  127312. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  127313. * @param update defines whether texture is immediately update (default is true)
  127314. */
  127315. drawText(text: string, x: number | null | undefined, y: number | null | undefined, font: string, color: string | null, clearColor: string, invertY?: boolean, update?: boolean): void;
  127316. /**
  127317. * Clones the texture
  127318. * @returns the clone of the texture.
  127319. */
  127320. clone(): DynamicTexture;
  127321. /**
  127322. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  127323. * @returns a serialized dynamic texture object
  127324. */
  127325. serialize(): any;
  127326. private _IsCanvasElement;
  127327. /** @hidden */
  127328. _rebuild(): void;
  127329. }
  127330. }
  127331. declare module BABYLON {
  127332. /**
  127333. * Class containing static functions to help procedurally build meshes
  127334. */
  127335. export class GroundBuilder {
  127336. /**
  127337. * Creates a ground mesh
  127338. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  127339. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  127340. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  127341. * @param name defines the name of the mesh
  127342. * @param options defines the options used to create the mesh
  127343. * @param scene defines the hosting scene
  127344. * @returns the ground mesh
  127345. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  127346. */
  127347. static CreateGround(name: string, options: {
  127348. width?: number;
  127349. height?: number;
  127350. subdivisions?: number;
  127351. subdivisionsX?: number;
  127352. subdivisionsY?: number;
  127353. updatable?: boolean;
  127354. }, scene: any): Mesh;
  127355. /**
  127356. * Creates a tiled ground mesh
  127357. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  127358. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  127359. * * 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
  127360. * * 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
  127361. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127362. * @param name defines the name of the mesh
  127363. * @param options defines the options used to create the mesh
  127364. * @param scene defines the hosting scene
  127365. * @returns the tiled ground mesh
  127366. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  127367. */
  127368. static CreateTiledGround(name: string, options: {
  127369. xmin: number;
  127370. zmin: number;
  127371. xmax: number;
  127372. zmax: number;
  127373. subdivisions?: {
  127374. w: number;
  127375. h: number;
  127376. };
  127377. precision?: {
  127378. w: number;
  127379. h: number;
  127380. };
  127381. updatable?: boolean;
  127382. }, scene?: Nullable<Scene>): Mesh;
  127383. /**
  127384. * Creates a ground mesh from a height map
  127385. * * The parameter `url` sets the URL of the height map image resource.
  127386. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  127387. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  127388. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  127389. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  127390. * * 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.
  127391. * * 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).
  127392. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  127393. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127394. * @param name defines the name of the mesh
  127395. * @param url defines the url to the height map
  127396. * @param options defines the options used to create the mesh
  127397. * @param scene defines the hosting scene
  127398. * @returns the ground mesh
  127399. * @see https://doc.babylonjs.com/babylon101/height_map
  127400. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  127401. */
  127402. static CreateGroundFromHeightMap(name: string, url: string, options: {
  127403. width?: number;
  127404. height?: number;
  127405. subdivisions?: number;
  127406. minHeight?: number;
  127407. maxHeight?: number;
  127408. colorFilter?: Color3;
  127409. alphaFilter?: number;
  127410. updatable?: boolean;
  127411. onReady?: (mesh: GroundMesh) => void;
  127412. }, scene?: Nullable<Scene>): GroundMesh;
  127413. }
  127414. }
  127415. declare module BABYLON {
  127416. /**
  127417. * Class containing static functions to help procedurally build meshes
  127418. */
  127419. export class TorusBuilder {
  127420. /**
  127421. * Creates a torus mesh
  127422. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  127423. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  127424. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  127425. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127426. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127427. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127428. * @param name defines the name of the mesh
  127429. * @param options defines the options used to create the mesh
  127430. * @param scene defines the hosting scene
  127431. * @returns the torus mesh
  127432. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  127433. */
  127434. static CreateTorus(name: string, options: {
  127435. diameter?: number;
  127436. thickness?: number;
  127437. tessellation?: number;
  127438. updatable?: boolean;
  127439. sideOrientation?: number;
  127440. frontUVs?: Vector4;
  127441. backUVs?: Vector4;
  127442. }, scene: any): Mesh;
  127443. }
  127444. }
  127445. declare module BABYLON {
  127446. /**
  127447. * Class containing static functions to help procedurally build meshes
  127448. */
  127449. export class CylinderBuilder {
  127450. /**
  127451. * Creates a cylinder or a cone mesh
  127452. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  127453. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  127454. * * 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.
  127455. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  127456. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  127457. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  127458. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  127459. * * 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).
  127460. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  127461. * * 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).
  127462. * * 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
  127463. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  127464. * * 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
  127465. * * 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.
  127466. * * If `enclose` is false, a ring surface is one element.
  127467. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  127468. * * 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
  127469. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  127470. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  127471. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  127472. * @param name defines the name of the mesh
  127473. * @param options defines the options used to create the mesh
  127474. * @param scene defines the hosting scene
  127475. * @returns the cylinder mesh
  127476. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  127477. */
  127478. static CreateCylinder(name: string, options: {
  127479. height?: number;
  127480. diameterTop?: number;
  127481. diameterBottom?: number;
  127482. diameter?: number;
  127483. tessellation?: number;
  127484. subdivisions?: number;
  127485. arc?: number;
  127486. faceColors?: Color4[];
  127487. faceUV?: Vector4[];
  127488. updatable?: boolean;
  127489. hasRings?: boolean;
  127490. enclose?: boolean;
  127491. cap?: number;
  127492. sideOrientation?: number;
  127493. frontUVs?: Vector4;
  127494. backUVs?: Vector4;
  127495. }, scene: any): Mesh;
  127496. }
  127497. }
  127498. declare module BABYLON {
  127499. /**
  127500. * States of the webXR experience
  127501. */
  127502. export enum WebXRState {
  127503. /**
  127504. * Transitioning to being in XR mode
  127505. */
  127506. ENTERING_XR = 0,
  127507. /**
  127508. * Transitioning to non XR mode
  127509. */
  127510. EXITING_XR = 1,
  127511. /**
  127512. * In XR mode and presenting
  127513. */
  127514. IN_XR = 2,
  127515. /**
  127516. * Not entered XR mode
  127517. */
  127518. NOT_IN_XR = 3
  127519. }
  127520. /**
  127521. * Abstraction of the XR render target
  127522. */
  127523. export interface WebXRRenderTarget extends IDisposable {
  127524. /**
  127525. * xrpresent context of the canvas which can be used to display/mirror xr content
  127526. */
  127527. canvasContext: WebGLRenderingContext;
  127528. /**
  127529. * xr layer for the canvas
  127530. */
  127531. xrLayer: Nullable<XRWebGLLayer>;
  127532. /**
  127533. * Initializes the xr layer for the session
  127534. * @param xrSession xr session
  127535. * @returns a promise that will resolve once the XR Layer has been created
  127536. */
  127537. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127538. }
  127539. }
  127540. declare module BABYLON {
  127541. /**
  127542. * COnfiguration object for WebXR output canvas
  127543. */
  127544. export class WebXRManagedOutputCanvasOptions {
  127545. /**
  127546. * An optional canvas in case you wish to create it yourself and provide it here.
  127547. * If not provided, a new canvas will be created
  127548. */
  127549. canvasElement?: HTMLCanvasElement;
  127550. /**
  127551. * Options for this XR Layer output
  127552. */
  127553. canvasOptions?: XRWebGLLayerOptions;
  127554. /**
  127555. * CSS styling for a newly created canvas (if not provided)
  127556. */
  127557. newCanvasCssStyle?: string;
  127558. /**
  127559. * Get the default values of the configuration object
  127560. * @param engine defines the engine to use (can be null)
  127561. * @returns default values of this configuration object
  127562. */
  127563. static GetDefaults(engine?: ThinEngine): WebXRManagedOutputCanvasOptions;
  127564. }
  127565. /**
  127566. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  127567. */
  127568. export class WebXRManagedOutputCanvas implements WebXRRenderTarget {
  127569. private _options;
  127570. private _canvas;
  127571. private _engine;
  127572. private _originalCanvasSize;
  127573. /**
  127574. * Rendering context of the canvas which can be used to display/mirror xr content
  127575. */
  127576. canvasContext: WebGLRenderingContext;
  127577. /**
  127578. * xr layer for the canvas
  127579. */
  127580. xrLayer: Nullable<XRWebGLLayer>;
  127581. /**
  127582. * Obseervers registered here will be triggered when the xr layer was initialized
  127583. */
  127584. onXRLayerInitObservable: Observable<XRWebGLLayer>;
  127585. /**
  127586. * Initializes the canvas to be added/removed upon entering/exiting xr
  127587. * @param _xrSessionManager The XR Session manager
  127588. * @param _options optional configuration for this canvas output. defaults will be used if not provided
  127589. */
  127590. constructor(_xrSessionManager: WebXRSessionManager, _options?: WebXRManagedOutputCanvasOptions);
  127591. /**
  127592. * Disposes of the object
  127593. */
  127594. dispose(): void;
  127595. /**
  127596. * Initializes the xr layer for the session
  127597. * @param xrSession xr session
  127598. * @returns a promise that will resolve once the XR Layer has been created
  127599. */
  127600. initializeXRLayerAsync(xrSession: XRSession): Promise<XRWebGLLayer>;
  127601. private _addCanvas;
  127602. private _removeCanvas;
  127603. private _setCanvasSize;
  127604. private _setManagedOutputCanvas;
  127605. }
  127606. }
  127607. declare module BABYLON {
  127608. /**
  127609. * Manages an XRSession to work with Babylon's engine
  127610. * @see https://doc.babylonjs.com/how_to/webxr_session_manager
  127611. */
  127612. export class WebXRSessionManager implements IDisposable {
  127613. /** The scene which the session should be created for */
  127614. scene: Scene;
  127615. private _referenceSpace;
  127616. private _rttProvider;
  127617. private _sessionEnded;
  127618. private _xrNavigator;
  127619. private baseLayer;
  127620. /**
  127621. * The base reference space from which the session started. good if you want to reset your
  127622. * reference space
  127623. */
  127624. baseReferenceSpace: XRReferenceSpace;
  127625. /**
  127626. * Current XR frame
  127627. */
  127628. currentFrame: Nullable<XRFrame>;
  127629. /** WebXR timestamp updated every frame */
  127630. currentTimestamp: number;
  127631. /**
  127632. * Used just in case of a failure to initialize an immersive session.
  127633. * The viewer reference space is compensated using this height, creating a kind of "viewer-floor" reference space
  127634. */
  127635. defaultHeightCompensation: number;
  127636. /**
  127637. * Fires every time a new xrFrame arrives which can be used to update the camera
  127638. */
  127639. onXRFrameObservable: Observable<XRFrame>;
  127640. /**
  127641. * Fires when the reference space changed
  127642. */
  127643. onXRReferenceSpaceChanged: Observable<XRReferenceSpace>;
  127644. /**
  127645. * Fires when the xr session is ended either by the device or manually done
  127646. */
  127647. onXRSessionEnded: Observable<any>;
  127648. /**
  127649. * Fires when the xr session is ended either by the device or manually done
  127650. */
  127651. onXRSessionInit: Observable<XRSession>;
  127652. /**
  127653. * Underlying xr session
  127654. */
  127655. session: XRSession;
  127656. /**
  127657. * The viewer (head position) reference space. This can be used to get the XR world coordinates
  127658. * or get the offset the player is currently at.
  127659. */
  127660. viewerReferenceSpace: XRReferenceSpace;
  127661. /**
  127662. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  127663. * @param scene The scene which the session should be created for
  127664. */
  127665. constructor(
  127666. /** The scene which the session should be created for */
  127667. scene: Scene);
  127668. /**
  127669. * The current reference space used in this session. This reference space can constantly change!
  127670. * It is mainly used to offset the camera's position.
  127671. */
  127672. get referenceSpace(): XRReferenceSpace;
  127673. /**
  127674. * Set a new reference space and triggers the observable
  127675. */
  127676. set referenceSpace(newReferenceSpace: XRReferenceSpace);
  127677. /**
  127678. * Disposes of the session manager
  127679. */
  127680. dispose(): void;
  127681. /**
  127682. * Stops the xrSession and restores the render loop
  127683. * @returns Promise which resolves after it exits XR
  127684. */
  127685. exitXRAsync(): Promise<void>;
  127686. /**
  127687. * Gets the correct render target texture to be rendered this frame for this eye
  127688. * @param eye the eye for which to get the render target
  127689. * @returns the render target for the specified eye
  127690. */
  127691. getRenderTargetTextureForEye(eye: XREye): RenderTargetTexture;
  127692. /**
  127693. * Creates a WebXRRenderTarget object for the XR session
  127694. * @param onStateChangedObservable optional, mechanism for enabling/disabling XR rendering canvas, used only on Web
  127695. * @param options optional options to provide when creating a new render target
  127696. * @returns a WebXR render target to which the session can render
  127697. */
  127698. getWebXRRenderTarget(options?: WebXRManagedOutputCanvasOptions): WebXRRenderTarget;
  127699. /**
  127700. * Initializes the manager
  127701. * After initialization enterXR can be called to start an XR session
  127702. * @returns Promise which resolves after it is initialized
  127703. */
  127704. initializeAsync(): Promise<void>;
  127705. /**
  127706. * Initializes an xr session
  127707. * @param xrSessionMode mode to initialize
  127708. * @param xrSessionInit defines optional and required values to pass to the session builder
  127709. * @returns a promise which will resolve once the session has been initialized
  127710. */
  127711. initializeSessionAsync(xrSessionMode?: XRSessionMode, xrSessionInit?: XRSessionInit): Promise<XRSession>;
  127712. /**
  127713. * Checks if a session would be supported for the creation options specified
  127714. * @param sessionMode session mode to check if supported eg. immersive-vr
  127715. * @returns A Promise that resolves to true if supported and false if not
  127716. */
  127717. isSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127718. /**
  127719. * Resets the reference space to the one started the session
  127720. */
  127721. resetReferenceSpace(): void;
  127722. /**
  127723. * Starts rendering to the xr layer
  127724. */
  127725. runXRRenderLoop(): void;
  127726. /**
  127727. * Sets the reference space on the xr session
  127728. * @param referenceSpaceType space to set
  127729. * @returns a promise that will resolve once the reference space has been set
  127730. */
  127731. setReferenceSpaceTypeAsync(referenceSpaceType?: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  127732. /**
  127733. * Updates the render state of the session
  127734. * @param state state to set
  127735. * @returns a promise that resolves once the render state has been updated
  127736. */
  127737. updateRenderStateAsync(state: XRRenderState): Promise<void>;
  127738. /**
  127739. * Returns a promise that resolves with a boolean indicating if the provided session mode is supported by this browser
  127740. * @param sessionMode defines the session to test
  127741. * @returns a promise with boolean as final value
  127742. */
  127743. static IsSessionSupportedAsync(sessionMode: XRSessionMode): Promise<boolean>;
  127744. private _createRenderTargetTexture;
  127745. }
  127746. }
  127747. declare module BABYLON {
  127748. /**
  127749. * WebXR Camera which holds the views for the xrSession
  127750. * @see https://doc.babylonjs.com/how_to/webxr_camera
  127751. */
  127752. export class WebXRCamera extends FreeCamera {
  127753. private _xrSessionManager;
  127754. private _firstFrame;
  127755. private _referenceQuaternion;
  127756. private _referencedPosition;
  127757. private _xrInvPositionCache;
  127758. private _xrInvQuaternionCache;
  127759. /**
  127760. * Observable raised before camera teleportation
  127761. */
  127762. onBeforeCameraTeleport: Observable<Vector3>;
  127763. /**
  127764. * Observable raised after camera teleportation
  127765. */
  127766. onAfterCameraTeleport: Observable<Vector3>;
  127767. /**
  127768. * Should position compensation execute on first frame.
  127769. * This is used when copying the position from a native (non XR) camera
  127770. */
  127771. compensateOnFirstFrame: boolean;
  127772. /**
  127773. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  127774. * @param name the name of the camera
  127775. * @param scene the scene to add the camera to
  127776. * @param _xrSessionManager a constructed xr session manager
  127777. */
  127778. constructor(name: string, scene: Scene, _xrSessionManager: WebXRSessionManager);
  127779. /**
  127780. * Return the user's height, unrelated to the current ground.
  127781. * This will be the y position of this camera, when ground level is 0.
  127782. */
  127783. get realWorldHeight(): number;
  127784. /** @hidden */
  127785. _updateForDualEyeDebugging(): void;
  127786. /**
  127787. * Sets this camera's transformation based on a non-vr camera
  127788. * @param otherCamera the non-vr camera to copy the transformation from
  127789. * @param resetToBaseReferenceSpace should XR reset to the base reference space
  127790. */
  127791. setTransformationFromNonVRCamera(otherCamera?: Camera, resetToBaseReferenceSpace?: boolean): void;
  127792. /**
  127793. * Gets the current instance class name ("WebXRCamera").
  127794. * @returns the class name
  127795. */
  127796. getClassName(): string;
  127797. private _rotate180;
  127798. private _updateFromXRSession;
  127799. private _updateNumberOfRigCameras;
  127800. private _updateReferenceSpace;
  127801. private _updateReferenceSpaceOffset;
  127802. }
  127803. }
  127804. declare module BABYLON {
  127805. /**
  127806. * Defining the interface required for a (webxr) feature
  127807. */
  127808. export interface IWebXRFeature extends IDisposable {
  127809. /**
  127810. * Is this feature attached
  127811. */
  127812. attached: boolean;
  127813. /**
  127814. * Should auto-attach be disabled?
  127815. */
  127816. disableAutoAttach: boolean;
  127817. /**
  127818. * Attach the feature to the session
  127819. * Will usually be called by the features manager
  127820. *
  127821. * @param force should attachment be forced (even when already attached)
  127822. * @returns true if successful.
  127823. */
  127824. attach(force?: boolean): boolean;
  127825. /**
  127826. * Detach the feature from the session
  127827. * Will usually be called by the features manager
  127828. *
  127829. * @returns true if successful.
  127830. */
  127831. detach(): boolean;
  127832. /**
  127833. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  127834. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  127835. *
  127836. * @returns whether or not the feature is compatible in this environment
  127837. */
  127838. isCompatible(): boolean;
  127839. /**
  127840. * Was this feature disposed;
  127841. */
  127842. isDisposed: boolean;
  127843. /**
  127844. * The name of the native xr feature name, if applicable (like anchor, hit-test, or hand-tracking)
  127845. */
  127846. xrNativeFeatureName?: string;
  127847. /**
  127848. * A list of (Babylon WebXR) features this feature depends on
  127849. */
  127850. dependsOn?: string[];
  127851. }
  127852. /**
  127853. * A list of the currently available features without referencing them
  127854. */
  127855. export class WebXRFeatureName {
  127856. /**
  127857. * The name of the anchor system feature
  127858. */
  127859. static readonly ANCHOR_SYSTEM: string;
  127860. /**
  127861. * The name of the background remover feature
  127862. */
  127863. static readonly BACKGROUND_REMOVER: string;
  127864. /**
  127865. * The name of the hit test feature
  127866. */
  127867. static readonly HIT_TEST: string;
  127868. /**
  127869. * physics impostors for xr controllers feature
  127870. */
  127871. static readonly PHYSICS_CONTROLLERS: string;
  127872. /**
  127873. * The name of the plane detection feature
  127874. */
  127875. static readonly PLANE_DETECTION: string;
  127876. /**
  127877. * The name of the pointer selection feature
  127878. */
  127879. static readonly POINTER_SELECTION: string;
  127880. /**
  127881. * The name of the teleportation feature
  127882. */
  127883. static readonly TELEPORTATION: string;
  127884. /**
  127885. * The name of the feature points feature.
  127886. */
  127887. static readonly FEATURE_POINTS: string;
  127888. /**
  127889. * The name of the hand tracking feature.
  127890. */
  127891. static readonly HAND_TRACKING: string;
  127892. }
  127893. /**
  127894. * Defining the constructor of a feature. Used to register the modules.
  127895. */
  127896. export type WebXRFeatureConstructor = (xrSessionManager: WebXRSessionManager, options?: any) => () => IWebXRFeature;
  127897. /**
  127898. * The WebXR features manager is responsible of enabling or disabling features required for the current XR session.
  127899. * It is mainly used in AR sessions.
  127900. *
  127901. * A feature can have a version that is defined by Babylon (and does not correspond with the webxr version).
  127902. */
  127903. export class WebXRFeaturesManager implements IDisposable {
  127904. private _xrSessionManager;
  127905. private static readonly _AvailableFeatures;
  127906. private _features;
  127907. /**
  127908. * constructs a new features manages.
  127909. *
  127910. * @param _xrSessionManager an instance of WebXRSessionManager
  127911. */
  127912. constructor(_xrSessionManager: WebXRSessionManager);
  127913. /**
  127914. * Used to register a module. After calling this function a developer can use this feature in the scene.
  127915. * Mainly used internally.
  127916. *
  127917. * @param featureName the name of the feature to register
  127918. * @param constructorFunction the function used to construct the module
  127919. * @param version the (babylon) version of the module
  127920. * @param stable is that a stable version of this module
  127921. */
  127922. static AddWebXRFeature(featureName: string, constructorFunction: WebXRFeatureConstructor, version?: number, stable?: boolean): void;
  127923. /**
  127924. * Returns a constructor of a specific feature.
  127925. *
  127926. * @param featureName the name of the feature to construct
  127927. * @param version the version of the feature to load
  127928. * @param xrSessionManager the xrSessionManager. Used to construct the module
  127929. * @param options optional options provided to the module.
  127930. * @returns a function that, when called, will return a new instance of this feature
  127931. */
  127932. static ConstructFeature(featureName: string, version: number | undefined, xrSessionManager: WebXRSessionManager, options?: any): () => IWebXRFeature;
  127933. /**
  127934. * Can be used to return the list of features currently registered
  127935. *
  127936. * @returns an Array of available features
  127937. */
  127938. static GetAvailableFeatures(): string[];
  127939. /**
  127940. * Gets the versions available for a specific feature
  127941. * @param featureName the name of the feature
  127942. * @returns an array with the available versions
  127943. */
  127944. static GetAvailableVersions(featureName: string): string[];
  127945. /**
  127946. * Return the latest unstable version of this feature
  127947. * @param featureName the name of the feature to search
  127948. * @returns the version number. if not found will return -1
  127949. */
  127950. static GetLatestVersionOfFeature(featureName: string): number;
  127951. /**
  127952. * Return the latest stable version of this feature
  127953. * @param featureName the name of the feature to search
  127954. * @returns the version number. if not found will return -1
  127955. */
  127956. static GetStableVersionOfFeature(featureName: string): number;
  127957. /**
  127958. * Attach a feature to the current session. Mainly used when session started to start the feature effect.
  127959. * Can be used during a session to start a feature
  127960. * @param featureName the name of feature to attach
  127961. */
  127962. attachFeature(featureName: string): void;
  127963. /**
  127964. * Can be used inside a session or when the session ends to detach a specific feature
  127965. * @param featureName the name of the feature to detach
  127966. */
  127967. detachFeature(featureName: string): void;
  127968. /**
  127969. * Used to disable an already-enabled feature
  127970. * The feature will be disposed and will be recreated once enabled.
  127971. * @param featureName the feature to disable
  127972. * @returns true if disable was successful
  127973. */
  127974. disableFeature(featureName: string | {
  127975. Name: string;
  127976. }): boolean;
  127977. /**
  127978. * dispose this features manager
  127979. */
  127980. dispose(): void;
  127981. /**
  127982. * 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.
  127983. * 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.
  127984. *
  127985. * @param featureName the name of the feature to load or the class of the feature
  127986. * @param version optional version to load. if not provided the latest version will be enabled
  127987. * @param moduleOptions options provided to the module. Ses the module documentation / constructor
  127988. * @param attachIfPossible if set to true (default) the feature will be automatically attached, if it is currently possible
  127989. * @param required is this feature required to the app. If set to true the session init will fail if the feature is not available.
  127990. * @returns a new constructed feature or throws an error if feature not found.
  127991. */
  127992. enableFeature(featureName: string | {
  127993. Name: string;
  127994. }, version?: number | string, moduleOptions?: any, attachIfPossible?: boolean, required?: boolean): IWebXRFeature;
  127995. /**
  127996. * get the implementation of an enabled feature.
  127997. * @param featureName the name of the feature to load
  127998. * @returns the feature class, if found
  127999. */
  128000. getEnabledFeature(featureName: string): IWebXRFeature;
  128001. /**
  128002. * Get the list of enabled features
  128003. * @returns an array of enabled features
  128004. */
  128005. getEnabledFeatures(): string[];
  128006. /**
  128007. * This function will exten the session creation configuration object with enabled features.
  128008. * If, for example, the anchors feature is enabled, it will be automatically added to the optional or required features list,
  128009. * according to the defined "required" variable, provided during enableFeature call
  128010. * @param xrSessionInit the xr Session init object to extend
  128011. *
  128012. * @returns an extended XRSessionInit object
  128013. */
  128014. extendXRSessionInitObject(xrSessionInit: XRSessionInit): XRSessionInit;
  128015. }
  128016. }
  128017. declare module BABYLON {
  128018. /**
  128019. * Base set of functionality needed to create an XR experience (WebXRSessionManager, Camera, StateManagement, etc.)
  128020. * @see https://doc.babylonjs.com/how_to/webxr_experience_helpers
  128021. */
  128022. export class WebXRExperienceHelper implements IDisposable {
  128023. private scene;
  128024. private _nonVRCamera;
  128025. private _originalSceneAutoClear;
  128026. private _supported;
  128027. /**
  128028. * Camera used to render xr content
  128029. */
  128030. camera: WebXRCamera;
  128031. /** A features manager for this xr session */
  128032. featuresManager: WebXRFeaturesManager;
  128033. /**
  128034. * Observers registered here will be triggered after the camera's initial transformation is set
  128035. * This can be used to set a different ground level or an extra rotation.
  128036. *
  128037. * Note that ground level is considered to be at 0. The height defined by the XR camera will be added
  128038. * to the position set after this observable is done executing.
  128039. */
  128040. onInitialXRPoseSetObservable: Observable<WebXRCamera>;
  128041. /**
  128042. * Fires when the state of the experience helper has changed
  128043. */
  128044. onStateChangedObservable: Observable<WebXRState>;
  128045. /** Session manager used to keep track of xr session */
  128046. sessionManager: WebXRSessionManager;
  128047. /**
  128048. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  128049. */
  128050. state: WebXRState;
  128051. /**
  128052. * Creates a WebXRExperienceHelper
  128053. * @param scene The scene the helper should be created in
  128054. */
  128055. private constructor();
  128056. /**
  128057. * Creates the experience helper
  128058. * @param scene the scene to attach the experience helper to
  128059. * @returns a promise for the experience helper
  128060. */
  128061. static CreateAsync(scene: Scene): Promise<WebXRExperienceHelper>;
  128062. /**
  128063. * Disposes of the experience helper
  128064. */
  128065. dispose(): void;
  128066. /**
  128067. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  128068. * @param sessionMode options for the XR session
  128069. * @param referenceSpaceType frame of reference of the XR session
  128070. * @param renderTarget the output canvas that will be used to enter XR mode
  128071. * @param sessionCreationOptions optional XRSessionInit object to init the session with
  128072. * @returns promise that resolves after xr mode has entered
  128073. */
  128074. enterXRAsync(sessionMode: XRSessionMode, referenceSpaceType: XRReferenceSpaceType, renderTarget?: WebXRRenderTarget, sessionCreationOptions?: XRSessionInit): Promise<WebXRSessionManager>;
  128075. /**
  128076. * Exits XR mode and returns the scene to its original state
  128077. * @returns promise that resolves after xr mode has exited
  128078. */
  128079. exitXRAsync(): Promise<void>;
  128080. private _nonXRToXRCamera;
  128081. private _setState;
  128082. }
  128083. }
  128084. declare module BABYLON {
  128085. /**
  128086. * X-Y values for axes in WebXR
  128087. */
  128088. export interface IWebXRMotionControllerAxesValue {
  128089. /**
  128090. * The value of the x axis
  128091. */
  128092. x: number;
  128093. /**
  128094. * The value of the y-axis
  128095. */
  128096. y: number;
  128097. }
  128098. /**
  128099. * changed / previous values for the values of this component
  128100. */
  128101. export interface IWebXRMotionControllerComponentChangesValues<T> {
  128102. /**
  128103. * current (this frame) value
  128104. */
  128105. current: T;
  128106. /**
  128107. * previous (last change) value
  128108. */
  128109. previous: T;
  128110. }
  128111. /**
  128112. * Represents changes in the component between current frame and last values recorded
  128113. */
  128114. export interface IWebXRMotionControllerComponentChanges {
  128115. /**
  128116. * will be populated with previous and current values if axes changed
  128117. */
  128118. axes?: IWebXRMotionControllerComponentChangesValues<IWebXRMotionControllerAxesValue>;
  128119. /**
  128120. * will be populated with previous and current values if pressed changed
  128121. */
  128122. pressed?: IWebXRMotionControllerComponentChangesValues<boolean>;
  128123. /**
  128124. * will be populated with previous and current values if touched changed
  128125. */
  128126. touched?: IWebXRMotionControllerComponentChangesValues<boolean>;
  128127. /**
  128128. * will be populated with previous and current values if value changed
  128129. */
  128130. value?: IWebXRMotionControllerComponentChangesValues<number>;
  128131. }
  128132. /**
  128133. * This class represents a single component (for example button or thumbstick) of a motion controller
  128134. */
  128135. export class WebXRControllerComponent implements IDisposable {
  128136. /**
  128137. * the id of this component
  128138. */
  128139. id: string;
  128140. /**
  128141. * the type of the component
  128142. */
  128143. type: MotionControllerComponentType;
  128144. private _buttonIndex;
  128145. private _axesIndices;
  128146. private _axes;
  128147. private _changes;
  128148. private _currentValue;
  128149. private _hasChanges;
  128150. private _pressed;
  128151. private _touched;
  128152. /**
  128153. * button component type
  128154. */
  128155. static BUTTON_TYPE: MotionControllerComponentType;
  128156. /**
  128157. * squeeze component type
  128158. */
  128159. static SQUEEZE_TYPE: MotionControllerComponentType;
  128160. /**
  128161. * Thumbstick component type
  128162. */
  128163. static THUMBSTICK_TYPE: MotionControllerComponentType;
  128164. /**
  128165. * Touchpad component type
  128166. */
  128167. static TOUCHPAD_TYPE: MotionControllerComponentType;
  128168. /**
  128169. * trigger component type
  128170. */
  128171. static TRIGGER_TYPE: MotionControllerComponentType;
  128172. /**
  128173. * If axes are available for this component (like a touchpad or thumbstick) the observers will be notified when
  128174. * the axes data changes
  128175. */
  128176. onAxisValueChangedObservable: Observable<{
  128177. x: number;
  128178. y: number;
  128179. }>;
  128180. /**
  128181. * Observers registered here will be triggered when the state of a button changes
  128182. * State change is either pressed / touched / value
  128183. */
  128184. onButtonStateChangedObservable: Observable<WebXRControllerComponent>;
  128185. /**
  128186. * Creates a new component for a motion controller.
  128187. * It is created by the motion controller itself
  128188. *
  128189. * @param id the id of this component
  128190. * @param type the type of the component
  128191. * @param _buttonIndex index in the buttons array of the gamepad
  128192. * @param _axesIndices indices of the values in the axes array of the gamepad
  128193. */
  128194. constructor(
  128195. /**
  128196. * the id of this component
  128197. */
  128198. id: string,
  128199. /**
  128200. * the type of the component
  128201. */
  128202. type: MotionControllerComponentType, _buttonIndex?: number, _axesIndices?: number[]);
  128203. /**
  128204. * The current axes data. If this component has no axes it will still return an object { x: 0, y: 0 }
  128205. */
  128206. get axes(): IWebXRMotionControllerAxesValue;
  128207. /**
  128208. * Get the changes. Elements will be populated only if they changed with their previous and current value
  128209. */
  128210. get changes(): IWebXRMotionControllerComponentChanges;
  128211. /**
  128212. * Return whether or not the component changed the last frame
  128213. */
  128214. get hasChanges(): boolean;
  128215. /**
  128216. * is the button currently pressed
  128217. */
  128218. get pressed(): boolean;
  128219. /**
  128220. * is the button currently touched
  128221. */
  128222. get touched(): boolean;
  128223. /**
  128224. * Get the current value of this component
  128225. */
  128226. get value(): number;
  128227. /**
  128228. * Dispose this component
  128229. */
  128230. dispose(): void;
  128231. /**
  128232. * Are there axes correlating to this component
  128233. * @return true is axes data is available
  128234. */
  128235. isAxes(): boolean;
  128236. /**
  128237. * Is this component a button (hence - pressable)
  128238. * @returns true if can be pressed
  128239. */
  128240. isButton(): boolean;
  128241. /**
  128242. * update this component using the gamepad object it is in. Called on every frame
  128243. * @param nativeController the native gamepad controller object
  128244. */
  128245. update(nativeController: IMinimalMotionControllerObject): void;
  128246. }
  128247. }
  128248. declare module BABYLON {
  128249. /**
  128250. * Interface used to represent data loading progression
  128251. */
  128252. export interface ISceneLoaderProgressEvent {
  128253. /**
  128254. * Defines if data length to load can be evaluated
  128255. */
  128256. readonly lengthComputable: boolean;
  128257. /**
  128258. * Defines the loaded data length
  128259. */
  128260. readonly loaded: number;
  128261. /**
  128262. * Defines the data length to load
  128263. */
  128264. readonly total: number;
  128265. }
  128266. /**
  128267. * Interface used by SceneLoader plugins to define supported file extensions
  128268. */
  128269. export interface ISceneLoaderPluginExtensions {
  128270. /**
  128271. * Defines the list of supported extensions
  128272. */
  128273. [extension: string]: {
  128274. isBinary: boolean;
  128275. };
  128276. }
  128277. /**
  128278. * Interface used by SceneLoader plugin factory
  128279. */
  128280. export interface ISceneLoaderPluginFactory {
  128281. /**
  128282. * Defines the name of the factory
  128283. */
  128284. name: string;
  128285. /**
  128286. * Function called to create a new plugin
  128287. * @return the new plugin
  128288. */
  128289. createPlugin(): ISceneLoaderPlugin | ISceneLoaderPluginAsync;
  128290. /**
  128291. * The callback that returns true if the data can be directly loaded.
  128292. * @param data string containing the file data
  128293. * @returns if the data can be loaded directly
  128294. */
  128295. canDirectLoad?(data: string): boolean;
  128296. }
  128297. /**
  128298. * Interface used to define the base of ISceneLoaderPlugin and ISceneLoaderPluginAsync
  128299. */
  128300. export interface ISceneLoaderPluginBase {
  128301. /**
  128302. * The friendly name of this plugin.
  128303. */
  128304. name: string;
  128305. /**
  128306. * The file extensions supported by this plugin.
  128307. */
  128308. extensions: string | ISceneLoaderPluginExtensions;
  128309. /**
  128310. * The callback called when loading from a url.
  128311. * @param scene scene loading this url
  128312. * @param url url to load
  128313. * @param onSuccess callback called when the file successfully loads
  128314. * @param onProgress callback called while file is loading (if the server supports this mode)
  128315. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  128316. * @param onError callback called when the file fails to load
  128317. * @returns a file request object
  128318. */
  128319. requestFile?(scene: Scene, url: string, onSuccess: (data: any, request?: WebRequest) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => void, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128320. /**
  128321. * The callback called when loading from a file object.
  128322. * @param scene scene loading this file
  128323. * @param file defines the file to load
  128324. * @param onSuccess defines the callback to call when data is loaded
  128325. * @param onProgress defines the callback to call during loading process
  128326. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  128327. * @param onError defines the callback to call when an error occurs
  128328. * @returns a file request object
  128329. */
  128330. readFile?(scene: Scene, file: File, onSuccess: (data: any) => void, onProgress?: (ev: ISceneLoaderProgressEvent) => any, useArrayBuffer?: boolean, onError?: (error: any) => void): IFileRequest;
  128331. /**
  128332. * The callback that returns true if the data can be directly loaded.
  128333. * @param data string containing the file data
  128334. * @returns if the data can be loaded directly
  128335. */
  128336. canDirectLoad?(data: string): boolean;
  128337. /**
  128338. * The callback that returns the data to pass to the plugin if the data can be directly loaded.
  128339. * @param scene scene loading this data
  128340. * @param data string containing the data
  128341. * @returns data to pass to the plugin
  128342. */
  128343. directLoad?(scene: Scene, data: string): any;
  128344. /**
  128345. * The callback that allows custom handling of the root url based on the response url.
  128346. * @param rootUrl the original root url
  128347. * @param responseURL the response url if available
  128348. * @returns the new root url
  128349. */
  128350. rewriteRootURL?(rootUrl: string, responseURL?: string): string;
  128351. }
  128352. /**
  128353. * Interface used to define a SceneLoader plugin
  128354. */
  128355. export interface ISceneLoaderPlugin extends ISceneLoaderPluginBase {
  128356. /**
  128357. * Import meshes into a scene.
  128358. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128359. * @param scene The scene to import into
  128360. * @param data The data to import
  128361. * @param rootUrl The root url for scene and resources
  128362. * @param meshes The meshes array to import into
  128363. * @param particleSystems The particle systems array to import into
  128364. * @param skeletons The skeletons array to import into
  128365. * @param onError The callback when import fails
  128366. * @returns True if successful or false otherwise
  128367. */
  128368. importMesh(meshesNames: any, scene: Scene, data: any, rootUrl: string, meshes: AbstractMesh[], particleSystems: IParticleSystem[], skeletons: Skeleton[], onError?: (message: string, exception?: any) => void): boolean;
  128369. /**
  128370. * Load into a scene.
  128371. * @param scene The scene to load into
  128372. * @param data The data to import
  128373. * @param rootUrl The root url for scene and resources
  128374. * @param onError The callback when import fails
  128375. * @returns True if successful or false otherwise
  128376. */
  128377. load(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): boolean;
  128378. /**
  128379. * Load into an asset container.
  128380. * @param scene The scene to load into
  128381. * @param data The data to import
  128382. * @param rootUrl The root url for scene and resources
  128383. * @param onError The callback when import fails
  128384. * @returns The loaded asset container
  128385. */
  128386. loadAssetContainer(scene: Scene, data: any, rootUrl: string, onError?: (message: string, exception?: any) => void): AssetContainer;
  128387. }
  128388. /**
  128389. * Interface used to define an async SceneLoader plugin
  128390. */
  128391. export interface ISceneLoaderPluginAsync extends ISceneLoaderPluginBase {
  128392. /**
  128393. * Import meshes into a scene.
  128394. * @param meshesNames An array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128395. * @param scene The scene to import into
  128396. * @param data The data to import
  128397. * @param rootUrl The root url for scene and resources
  128398. * @param onProgress The callback when the load progresses
  128399. * @param fileName Defines the name of the file to load
  128400. * @returns The loaded meshes, particle systems, skeletons, and animation groups
  128401. */
  128402. importMeshAsync(meshesNames: any, scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<{
  128403. meshes: AbstractMesh[];
  128404. particleSystems: IParticleSystem[];
  128405. skeletons: Skeleton[];
  128406. animationGroups: AnimationGroup[];
  128407. }>;
  128408. /**
  128409. * Load into a scene.
  128410. * @param scene The scene to load into
  128411. * @param data The data to import
  128412. * @param rootUrl The root url for scene and resources
  128413. * @param onProgress The callback when the load progresses
  128414. * @param fileName Defines the name of the file to load
  128415. * @returns Nothing
  128416. */
  128417. loadAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<void>;
  128418. /**
  128419. * Load into an asset container.
  128420. * @param scene The scene to load into
  128421. * @param data The data to import
  128422. * @param rootUrl The root url for scene and resources
  128423. * @param onProgress The callback when the load progresses
  128424. * @param fileName Defines the name of the file to load
  128425. * @returns The loaded asset container
  128426. */
  128427. loadAssetContainerAsync(scene: Scene, data: any, rootUrl: string, onProgress?: (event: ISceneLoaderProgressEvent) => void, fileName?: string): Promise<AssetContainer>;
  128428. }
  128429. /**
  128430. * Mode that determines how to handle old animation groups before loading new ones.
  128431. */
  128432. export enum SceneLoaderAnimationGroupLoadingMode {
  128433. /**
  128434. * Reset all old animations to initial state then dispose them.
  128435. */
  128436. Clean = 0,
  128437. /**
  128438. * Stop all old animations.
  128439. */
  128440. Stop = 1,
  128441. /**
  128442. * Restart old animations from first frame.
  128443. */
  128444. Sync = 2,
  128445. /**
  128446. * Old animations remains untouched.
  128447. */
  128448. NoSync = 3
  128449. }
  128450. /**
  128451. * Defines a plugin registered by the SceneLoader
  128452. */
  128453. interface IRegisteredPlugin {
  128454. /**
  128455. * Defines the plugin to use
  128456. */
  128457. plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128458. /**
  128459. * Defines if the plugin supports binary data
  128460. */
  128461. isBinary: boolean;
  128462. }
  128463. /**
  128464. * Class used to load scene from various file formats using registered plugins
  128465. * @see https://doc.babylonjs.com/how_to/load_from_any_file_type
  128466. */
  128467. export class SceneLoader {
  128468. /**
  128469. * No logging while loading
  128470. */
  128471. static readonly NO_LOGGING: number;
  128472. /**
  128473. * Minimal logging while loading
  128474. */
  128475. static readonly MINIMAL_LOGGING: number;
  128476. /**
  128477. * Summary logging while loading
  128478. */
  128479. static readonly SUMMARY_LOGGING: number;
  128480. /**
  128481. * Detailled logging while loading
  128482. */
  128483. static readonly DETAILED_LOGGING: number;
  128484. /**
  128485. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  128486. */
  128487. static get ForceFullSceneLoadingForIncremental(): boolean;
  128488. static set ForceFullSceneLoadingForIncremental(value: boolean);
  128489. /**
  128490. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  128491. */
  128492. static get ShowLoadingScreen(): boolean;
  128493. static set ShowLoadingScreen(value: boolean);
  128494. /**
  128495. * Defines the current logging level (while loading the scene)
  128496. * @ignorenaming
  128497. */
  128498. static get loggingLevel(): number;
  128499. static set loggingLevel(value: number);
  128500. /**
  128501. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  128502. */
  128503. static get CleanBoneMatrixWeights(): boolean;
  128504. static set CleanBoneMatrixWeights(value: boolean);
  128505. /**
  128506. * Event raised when a plugin is used to load a scene
  128507. */
  128508. static OnPluginActivatedObservable: Observable<ISceneLoaderPlugin | ISceneLoaderPluginAsync>;
  128509. private static _registeredPlugins;
  128510. private static _showingLoadingScreen;
  128511. /**
  128512. * Gets the default plugin (used to load Babylon files)
  128513. * @returns the .babylon plugin
  128514. */
  128515. static GetDefaultPlugin(): IRegisteredPlugin;
  128516. private static _GetPluginForExtension;
  128517. private static _GetPluginForDirectLoad;
  128518. private static _GetPluginForFilename;
  128519. private static _GetDirectLoad;
  128520. private static _LoadData;
  128521. private static _GetFileInfo;
  128522. /**
  128523. * Gets a plugin that can load the given extension
  128524. * @param extension defines the extension to load
  128525. * @returns a plugin or null if none works
  128526. */
  128527. static GetPluginForExtension(extension: string): ISceneLoaderPlugin | ISceneLoaderPluginAsync | ISceneLoaderPluginFactory;
  128528. /**
  128529. * Gets a boolean indicating that the given extension can be loaded
  128530. * @param extension defines the extension to load
  128531. * @returns true if the extension is supported
  128532. */
  128533. static IsPluginForExtensionAvailable(extension: string): boolean;
  128534. /**
  128535. * Adds a new plugin to the list of registered plugins
  128536. * @param plugin defines the plugin to add
  128537. */
  128538. static RegisterPlugin(plugin: ISceneLoaderPlugin | ISceneLoaderPluginAsync): void;
  128539. /**
  128540. * Import meshes into a scene
  128541. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128542. * @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)
  128543. * @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)
  128544. * @param scene the instance of BABYLON.Scene to append to
  128545. * @param onSuccess a callback with a list of imported meshes, particleSystems, skeletons, and animationGroups when import succeeds
  128546. * @param onProgress a callback with a progress event for each file being loaded
  128547. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128548. * @param pluginExtension the extension used to determine the plugin
  128549. * @returns The loaded plugin
  128550. */
  128551. 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>;
  128552. /**
  128553. * Import meshes into a scene
  128554. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  128555. * @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)
  128556. * @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)
  128557. * @param scene the instance of BABYLON.Scene to append to
  128558. * @param onProgress a callback with a progress event for each file being loaded
  128559. * @param pluginExtension the extension used to determine the plugin
  128560. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  128561. */
  128562. static ImportMeshAsync(meshNames: any, rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<{
  128563. meshes: AbstractMesh[];
  128564. particleSystems: IParticleSystem[];
  128565. skeletons: Skeleton[];
  128566. animationGroups: AnimationGroup[];
  128567. }>;
  128568. /**
  128569. * Load a scene
  128570. * @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)
  128571. * @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)
  128572. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128573. * @param onSuccess a callback with the scene when import succeeds
  128574. * @param onProgress a callback with a progress event for each file being loaded
  128575. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128576. * @param pluginExtension the extension used to determine the plugin
  128577. * @returns The loaded plugin
  128578. */
  128579. 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>;
  128580. /**
  128581. * Load a scene
  128582. * @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)
  128583. * @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)
  128584. * @param engine is the instance of BABYLON.Engine to use to create the scene
  128585. * @param onProgress a callback with a progress event for each file being loaded
  128586. * @param pluginExtension the extension used to determine the plugin
  128587. * @returns The loaded scene
  128588. */
  128589. static LoadAsync(rootUrl: string, sceneFilename?: string | File, engine?: Nullable<Engine>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128590. /**
  128591. * Append a scene
  128592. * @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)
  128593. * @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)
  128594. * @param scene is the instance of BABYLON.Scene to append to
  128595. * @param onSuccess a callback with the scene when import succeeds
  128596. * @param onProgress a callback with a progress event for each file being loaded
  128597. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128598. * @param pluginExtension the extension used to determine the plugin
  128599. * @returns The loaded plugin
  128600. */
  128601. 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>;
  128602. /**
  128603. * Append a scene
  128604. * @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)
  128605. * @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)
  128606. * @param scene is the instance of BABYLON.Scene to append to
  128607. * @param onProgress a callback with a progress event for each file being loaded
  128608. * @param pluginExtension the extension used to determine the plugin
  128609. * @returns The given scene
  128610. */
  128611. static AppendAsync(rootUrl: string, sceneFilename?: string | File, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<Scene>;
  128612. /**
  128613. * Load a scene into an asset container
  128614. * @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)
  128615. * @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)
  128616. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128617. * @param onSuccess a callback with the scene when import succeeds
  128618. * @param onProgress a callback with a progress event for each file being loaded
  128619. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128620. * @param pluginExtension the extension used to determine the plugin
  128621. * @returns The loaded plugin
  128622. */
  128623. 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>;
  128624. /**
  128625. * Load a scene into an asset container
  128626. * @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)
  128627. * @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)
  128628. * @param scene is the instance of Scene to append to
  128629. * @param onProgress a callback with a progress event for each file being loaded
  128630. * @param pluginExtension the extension used to determine the plugin
  128631. * @returns The loaded asset container
  128632. */
  128633. static LoadAssetContainerAsync(rootUrl: string, sceneFilename?: string, scene?: Nullable<Scene>, onProgress?: Nullable<(event: ISceneLoaderProgressEvent) => void>, pluginExtension?: Nullable<string>): Promise<AssetContainer>;
  128634. /**
  128635. * Import animations from a file into a scene
  128636. * @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)
  128637. * @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)
  128638. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128639. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128640. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128641. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128642. * @param onSuccess a callback with the scene when import succeeds
  128643. * @param onProgress a callback with a progress event for each file being loaded
  128644. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128645. * @param pluginExtension the extension used to determine the plugin
  128646. */
  128647. 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;
  128648. /**
  128649. * Import animations from a file into a scene
  128650. * @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)
  128651. * @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)
  128652. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  128653. * @param overwriteAnimations when true, animations are cleaned before importing new ones. Animations are appended otherwise
  128654. * @param animationGroupLoadingMode defines how to handle old animations groups before importing new ones
  128655. * @param targetConverter defines a function used to convert animation targets from loaded scene to current scene (default: search node by name)
  128656. * @param onSuccess a callback with the scene when import succeeds
  128657. * @param onProgress a callback with a progress event for each file being loaded
  128658. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  128659. * @param pluginExtension the extension used to determine the plugin
  128660. * @returns the updated scene with imported animations
  128661. */
  128662. 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>;
  128663. }
  128664. }
  128665. declare module BABYLON {
  128666. /**
  128667. * Handedness type in xrInput profiles. These can be used to define layouts in the Layout Map.
  128668. */
  128669. export type MotionControllerHandedness = "none" | "left" | "right";
  128670. /**
  128671. * The type of components available in motion controllers.
  128672. * This is not the name of the component.
  128673. */
  128674. export type MotionControllerComponentType = "trigger" | "squeeze" | "touchpad" | "thumbstick" | "button";
  128675. /**
  128676. * The state of a controller component
  128677. */
  128678. export type MotionControllerComponentStateType = "default" | "touched" | "pressed";
  128679. /**
  128680. * The schema of motion controller layout.
  128681. * No object will be initialized using this interface
  128682. * This is used just to define the profile.
  128683. */
  128684. export interface IMotionControllerLayout {
  128685. /**
  128686. * Path to load the assets. Usually relative to the base path
  128687. */
  128688. assetPath: string;
  128689. /**
  128690. * Available components (unsorted)
  128691. */
  128692. components: {
  128693. /**
  128694. * A map of component Ids
  128695. */
  128696. [componentId: string]: {
  128697. /**
  128698. * The type of input the component outputs
  128699. */
  128700. type: MotionControllerComponentType;
  128701. /**
  128702. * The indices of this component in the gamepad object
  128703. */
  128704. gamepadIndices: {
  128705. /**
  128706. * Index of button
  128707. */
  128708. button?: number;
  128709. /**
  128710. * If available, index of x-axis
  128711. */
  128712. xAxis?: number;
  128713. /**
  128714. * If available, index of y-axis
  128715. */
  128716. yAxis?: number;
  128717. };
  128718. /**
  128719. * The mesh's root node name
  128720. */
  128721. rootNodeName: string;
  128722. /**
  128723. * Animation definitions for this model
  128724. */
  128725. visualResponses: {
  128726. [stateKey: string]: {
  128727. /**
  128728. * What property will be animated
  128729. */
  128730. componentProperty: "xAxis" | "yAxis" | "button" | "state";
  128731. /**
  128732. * What states influence this visual response
  128733. */
  128734. states: MotionControllerComponentStateType[];
  128735. /**
  128736. * Type of animation - movement or visibility
  128737. */
  128738. valueNodeProperty: "transform" | "visibility";
  128739. /**
  128740. * Base node name to move. Its position will be calculated according to the min and max nodes
  128741. */
  128742. valueNodeName?: string;
  128743. /**
  128744. * Minimum movement node
  128745. */
  128746. minNodeName?: string;
  128747. /**
  128748. * Max movement node
  128749. */
  128750. maxNodeName?: string;
  128751. };
  128752. };
  128753. /**
  128754. * If touch enabled, what is the name of node to display user feedback
  128755. */
  128756. touchPointNodeName?: string;
  128757. };
  128758. };
  128759. /**
  128760. * Is it xr standard mapping or not
  128761. */
  128762. gamepadMapping: "" | "xr-standard";
  128763. /**
  128764. * Base root node of this entire model
  128765. */
  128766. rootNodeName: string;
  128767. /**
  128768. * Defines the main button component id
  128769. */
  128770. selectComponentId: string;
  128771. }
  128772. /**
  128773. * A definition for the layout map in the input profile
  128774. */
  128775. export interface IMotionControllerLayoutMap {
  128776. /**
  128777. * Layouts with handedness type as a key
  128778. */
  128779. [handedness: string]: IMotionControllerLayout;
  128780. }
  128781. /**
  128782. * The XR Input profile schema
  128783. * Profiles can be found here:
  128784. * https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/registry/profiles
  128785. */
  128786. export interface IMotionControllerProfile {
  128787. /**
  128788. * fallback profiles for this profileId
  128789. */
  128790. fallbackProfileIds: string[];
  128791. /**
  128792. * The layout map, with handedness as key
  128793. */
  128794. layouts: IMotionControllerLayoutMap;
  128795. /**
  128796. * The id of this profile
  128797. * correlates to the profile(s) in the xrInput.profiles array
  128798. */
  128799. profileId: string;
  128800. }
  128801. /**
  128802. * A helper-interface for the 3 meshes needed for controller button animation
  128803. * The meshes are provided to the _lerpButtonTransform function to calculate the current position of the value mesh
  128804. */
  128805. export interface IMotionControllerButtonMeshMap {
  128806. /**
  128807. * the mesh that defines the pressed value mesh position.
  128808. * This is used to find the max-position of this button
  128809. */
  128810. pressedMesh: AbstractMesh;
  128811. /**
  128812. * the mesh that defines the unpressed value mesh position.
  128813. * This is used to find the min (or initial) position of this button
  128814. */
  128815. unpressedMesh: AbstractMesh;
  128816. /**
  128817. * The mesh that will be changed when value changes
  128818. */
  128819. valueMesh: AbstractMesh;
  128820. }
  128821. /**
  128822. * A helper-interface for the 3 meshes needed for controller axis animation.
  128823. * This will be expanded when touchpad animations are fully supported
  128824. * The meshes are provided to the _lerpAxisTransform function to calculate the current position of the value mesh
  128825. */
  128826. export interface IMotionControllerMeshMap {
  128827. /**
  128828. * the mesh that defines the maximum value mesh position.
  128829. */
  128830. maxMesh?: AbstractMesh;
  128831. /**
  128832. * the mesh that defines the minimum value mesh position.
  128833. */
  128834. minMesh?: AbstractMesh;
  128835. /**
  128836. * The mesh that will be changed when axis value changes
  128837. */
  128838. valueMesh?: AbstractMesh;
  128839. }
  128840. /**
  128841. * The elements needed for change-detection of the gamepad objects in motion controllers
  128842. */
  128843. export interface IMinimalMotionControllerObject {
  128844. /**
  128845. * Available axes of this controller
  128846. */
  128847. axes: number[];
  128848. /**
  128849. * An array of available buttons
  128850. */
  128851. buttons: Array<{
  128852. /**
  128853. * Value of the button/trigger
  128854. */
  128855. value: number;
  128856. /**
  128857. * If the button/trigger is currently touched
  128858. */
  128859. touched: boolean;
  128860. /**
  128861. * If the button/trigger is currently pressed
  128862. */
  128863. pressed: boolean;
  128864. }>;
  128865. /**
  128866. * EXPERIMENTAL haptic support.
  128867. */
  128868. hapticActuators?: Array<{
  128869. pulse: (value: number, duration: number) => Promise<boolean>;
  128870. }>;
  128871. }
  128872. /**
  128873. * An Abstract Motion controller
  128874. * This class receives an xrInput and a profile layout and uses those to initialize the components
  128875. * Each component has an observable to check for changes in value and state
  128876. */
  128877. export abstract class WebXRAbstractMotionController implements IDisposable {
  128878. protected scene: Scene;
  128879. protected layout: IMotionControllerLayout;
  128880. /**
  128881. * The gamepad object correlating to this controller
  128882. */
  128883. gamepadObject: IMinimalMotionControllerObject;
  128884. /**
  128885. * handedness (left/right/none) of this controller
  128886. */
  128887. handedness: MotionControllerHandedness;
  128888. private _initComponent;
  128889. private _modelReady;
  128890. /**
  128891. * A map of components (WebXRControllerComponent) in this motion controller
  128892. * Components have a ComponentType and can also have both button and axis definitions
  128893. */
  128894. readonly components: {
  128895. [id: string]: WebXRControllerComponent;
  128896. };
  128897. /**
  128898. * Disable the model's animation. Can be set at any time.
  128899. */
  128900. disableAnimation: boolean;
  128901. /**
  128902. * Observers registered here will be triggered when the model of this controller is done loading
  128903. */
  128904. onModelLoadedObservable: Observable<WebXRAbstractMotionController>;
  128905. /**
  128906. * The profile id of this motion controller
  128907. */
  128908. abstract profileId: string;
  128909. /**
  128910. * The root mesh of the model. It is null if the model was not yet initialized
  128911. */
  128912. rootMesh: Nullable<AbstractMesh>;
  128913. /**
  128914. * constructs a new abstract motion controller
  128915. * @param scene the scene to which the model of the controller will be added
  128916. * @param layout The profile layout to load
  128917. * @param gamepadObject The gamepad object correlating to this controller
  128918. * @param handedness handedness (left/right/none) of this controller
  128919. * @param _doNotLoadControllerMesh set this flag to ignore the mesh loading
  128920. */
  128921. constructor(scene: Scene, layout: IMotionControllerLayout,
  128922. /**
  128923. * The gamepad object correlating to this controller
  128924. */
  128925. gamepadObject: IMinimalMotionControllerObject,
  128926. /**
  128927. * handedness (left/right/none) of this controller
  128928. */
  128929. handedness: MotionControllerHandedness, _doNotLoadControllerMesh?: boolean);
  128930. /**
  128931. * Dispose this controller, the model mesh and all its components
  128932. */
  128933. dispose(): void;
  128934. /**
  128935. * Returns all components of specific type
  128936. * @param type the type to search for
  128937. * @return an array of components with this type
  128938. */
  128939. getAllComponentsOfType(type: MotionControllerComponentType): WebXRControllerComponent[];
  128940. /**
  128941. * get a component based an its component id as defined in layout.components
  128942. * @param id the id of the component
  128943. * @returns the component correlates to the id or undefined if not found
  128944. */
  128945. getComponent(id: string): WebXRControllerComponent;
  128946. /**
  128947. * Get the list of components available in this motion controller
  128948. * @returns an array of strings correlating to available components
  128949. */
  128950. getComponentIds(): string[];
  128951. /**
  128952. * Get the first component of specific type
  128953. * @param type type of component to find
  128954. * @return a controller component or null if not found
  128955. */
  128956. getComponentOfType(type: MotionControllerComponentType): Nullable<WebXRControllerComponent>;
  128957. /**
  128958. * Get the main (Select) component of this controller as defined in the layout
  128959. * @returns the main component of this controller
  128960. */
  128961. getMainComponent(): WebXRControllerComponent;
  128962. /**
  128963. * Loads the model correlating to this controller
  128964. * When the mesh is loaded, the onModelLoadedObservable will be triggered
  128965. * @returns A promise fulfilled with the result of the model loading
  128966. */
  128967. loadModel(): Promise<boolean>;
  128968. /**
  128969. * Update this model using the current XRFrame
  128970. * @param xrFrame the current xr frame to use and update the model
  128971. */
  128972. updateFromXRFrame(xrFrame: XRFrame): void;
  128973. /**
  128974. * Backwards compatibility due to a deeply-integrated typo
  128975. */
  128976. get handness(): XREye;
  128977. /**
  128978. * Pulse (vibrate) this controller
  128979. * If the controller does not support pulses, this function will fail silently and return Promise<false> directly after called
  128980. * Consecutive calls to this function will cancel the last pulse call
  128981. *
  128982. * @param value the strength of the pulse in 0.0...1.0 range
  128983. * @param duration Duration of the pulse in milliseconds
  128984. * @param hapticActuatorIndex optional index of actuator (will usually be 0)
  128985. * @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
  128986. */
  128987. pulse(value: number, duration: number, hapticActuatorIndex?: number): Promise<boolean>;
  128988. protected _getChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128989. protected _getImmediateChildByName(node: AbstractMesh, name: string): AbstractMesh | undefined;
  128990. /**
  128991. * Moves the axis on the controller mesh based on its current state
  128992. * @param axis the index of the axis
  128993. * @param axisValue the value of the axis which determines the meshes new position
  128994. * @hidden
  128995. */
  128996. protected _lerpTransform(axisMap: IMotionControllerMeshMap, axisValue: number, fixValueCoordinates?: boolean): void;
  128997. /**
  128998. * Update the model itself with the current frame data
  128999. * @param xrFrame the frame to use for updating the model mesh
  129000. */
  129001. protected updateModel(xrFrame: XRFrame): void;
  129002. /**
  129003. * Get the filename and path for this controller's model
  129004. * @returns a map of filename and path
  129005. */
  129006. protected abstract _getFilenameAndPath(): {
  129007. filename: string;
  129008. path: string;
  129009. };
  129010. /**
  129011. * This function is called before the mesh is loaded. It checks for loading constraints.
  129012. * For example, this function can check if the GLB loader is available
  129013. * If this function returns false, the generic controller will be loaded instead
  129014. * @returns Is the client ready to load the mesh
  129015. */
  129016. protected abstract _getModelLoadingConstraints(): boolean;
  129017. /**
  129018. * This function will be called after the model was successfully loaded and can be used
  129019. * for mesh transformations before it is available for the user
  129020. * @param meshes the loaded meshes
  129021. */
  129022. protected abstract _processLoadedModel(meshes: AbstractMesh[]): void;
  129023. /**
  129024. * Set the root mesh for this controller. Important for the WebXR controller class
  129025. * @param meshes the loaded meshes
  129026. */
  129027. protected abstract _setRootMesh(meshes: AbstractMesh[]): void;
  129028. /**
  129029. * A function executed each frame that updates the mesh (if needed)
  129030. * @param xrFrame the current xrFrame
  129031. */
  129032. protected abstract _updateModel(xrFrame: XRFrame): void;
  129033. private _getGenericFilenameAndPath;
  129034. private _getGenericParentMesh;
  129035. }
  129036. }
  129037. declare module BABYLON {
  129038. /**
  129039. * A generic trigger-only motion controller for WebXR
  129040. */
  129041. export class WebXRGenericTriggerMotionController extends WebXRAbstractMotionController {
  129042. /**
  129043. * Static version of the profile id of this controller
  129044. */
  129045. static ProfileId: string;
  129046. profileId: string;
  129047. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  129048. protected _getFilenameAndPath(): {
  129049. filename: string;
  129050. path: string;
  129051. };
  129052. protected _getModelLoadingConstraints(): boolean;
  129053. protected _processLoadedModel(meshes: AbstractMesh[]): void;
  129054. protected _setRootMesh(meshes: AbstractMesh[]): void;
  129055. protected _updateModel(): void;
  129056. }
  129057. }
  129058. declare module BABYLON {
  129059. /**
  129060. * Class containing static functions to help procedurally build meshes
  129061. */
  129062. export class SphereBuilder {
  129063. /**
  129064. * Creates a sphere mesh
  129065. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  129066. * * 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`)
  129067. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  129068. * * 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
  129069. * * 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)
  129070. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  129071. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  129072. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129073. * @param name defines the name of the mesh
  129074. * @param options defines the options used to create the mesh
  129075. * @param scene defines the hosting scene
  129076. * @returns the sphere mesh
  129077. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  129078. */
  129079. static CreateSphere(name: string, options: {
  129080. segments?: number;
  129081. diameter?: number;
  129082. diameterX?: number;
  129083. diameterY?: number;
  129084. diameterZ?: number;
  129085. arc?: number;
  129086. slice?: number;
  129087. sideOrientation?: number;
  129088. frontUVs?: Vector4;
  129089. backUVs?: Vector4;
  129090. updatable?: boolean;
  129091. }, scene?: Nullable<Scene>): Mesh;
  129092. }
  129093. }
  129094. declare module BABYLON {
  129095. /**
  129096. * A profiled motion controller has its profile loaded from an online repository.
  129097. * The class is responsible of loading the model, mapping the keys and enabling model-animations
  129098. */
  129099. export class WebXRProfiledMotionController extends WebXRAbstractMotionController {
  129100. private _repositoryUrl;
  129101. private _buttonMeshMapping;
  129102. private _touchDots;
  129103. /**
  129104. * The profile ID of this controller. Will be populated when the controller initializes.
  129105. */
  129106. profileId: string;
  129107. constructor(scene: Scene, xrInput: XRInputSource, _profile: IMotionControllerProfile, _repositoryUrl: string);
  129108. dispose(): void;
  129109. protected _getFilenameAndPath(): {
  129110. filename: string;
  129111. path: string;
  129112. };
  129113. protected _getModelLoadingConstraints(): boolean;
  129114. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  129115. protected _setRootMesh(meshes: AbstractMesh[]): void;
  129116. protected _updateModel(_xrFrame: XRFrame): void;
  129117. }
  129118. }
  129119. declare module BABYLON {
  129120. /**
  129121. * A construction function type to create a new controller based on an xrInput object
  129122. */
  129123. export type MotionControllerConstructor = (xrInput: XRInputSource, scene: Scene) => WebXRAbstractMotionController;
  129124. /**
  129125. * The MotionController Manager manages all registered motion controllers and loads the right one when needed.
  129126. *
  129127. * When this repository is complete: https://github.com/immersive-web/webxr-input-profiles/tree/master/packages/assets
  129128. * it should be replaced with auto-loaded controllers.
  129129. *
  129130. * When using a model try to stay as generic as possible. Eventually there will be no need in any of the controller classes
  129131. */
  129132. export class WebXRMotionControllerManager {
  129133. private static _AvailableControllers;
  129134. private static _Fallbacks;
  129135. private static _ProfileLoadingPromises;
  129136. private static _ProfilesList;
  129137. /**
  129138. * The base URL of the online controller repository. Can be changed at any time.
  129139. */
  129140. static BaseRepositoryUrl: string;
  129141. /**
  129142. * Which repository gets priority - local or online
  129143. */
  129144. static PrioritizeOnlineRepository: boolean;
  129145. /**
  129146. * Use the online repository, or use only locally-defined controllers
  129147. */
  129148. static UseOnlineRepository: boolean;
  129149. /**
  129150. * Clear the cache used for profile loading and reload when requested again
  129151. */
  129152. static ClearProfilesCache(): void;
  129153. /**
  129154. * Register the default fallbacks.
  129155. * This function is called automatically when this file is imported.
  129156. */
  129157. static DefaultFallbacks(): void;
  129158. /**
  129159. * Find a fallback profile if the profile was not found. There are a few predefined generic profiles.
  129160. * @param profileId the profile to which a fallback needs to be found
  129161. * @return an array with corresponding fallback profiles
  129162. */
  129163. static FindFallbackWithProfileId(profileId: string): string[];
  129164. /**
  129165. * When acquiring a new xrInput object (usually by the WebXRInput class), match it with the correct profile.
  129166. * The order of search:
  129167. *
  129168. * 1) Iterate the profiles array of the xr input and try finding a corresponding motion controller
  129169. * 2) (If not found) search in the gamepad id and try using it (legacy versions only)
  129170. * 3) search for registered fallbacks (should be redundant, nonetheless it makes sense to check)
  129171. * 4) return the generic trigger controller if none were found
  129172. *
  129173. * @param xrInput the xrInput to which a new controller is initialized
  129174. * @param scene the scene to which the model will be added
  129175. * @param forceProfile force a certain profile for this controller
  129176. * @return A promise that fulfils with the motion controller class for this profile id or the generic standard class if none was found
  129177. */
  129178. static GetMotionControllerWithXRInput(xrInput: XRInputSource, scene: Scene, forceProfile?: string): Promise<WebXRAbstractMotionController>;
  129179. /**
  129180. * Register a new controller based on its profile. This function will be called by the controller classes themselves.
  129181. *
  129182. * If you are missing a profile, make sure it is imported in your source, otherwise it will not register.
  129183. *
  129184. * @param type the profile type to register
  129185. * @param constructFunction the function to be called when loading this profile
  129186. */
  129187. static RegisterController(type: string, constructFunction: MotionControllerConstructor): void;
  129188. /**
  129189. * Register a fallback to a specific profile.
  129190. * @param profileId the profileId that will receive the fallbacks
  129191. * @param fallbacks A list of fallback profiles
  129192. */
  129193. static RegisterFallbacksForProfileId(profileId: string, fallbacks: string[]): void;
  129194. /**
  129195. * Will update the list of profiles available in the repository
  129196. * @return a promise that resolves to a map of profiles available online
  129197. */
  129198. static UpdateProfilesList(): Promise<{
  129199. [profile: string]: string;
  129200. }>;
  129201. private static _LoadProfileFromRepository;
  129202. private static _LoadProfilesFromAvailableControllers;
  129203. }
  129204. }
  129205. declare module BABYLON {
  129206. /**
  129207. * Configuration options for the WebXR controller creation
  129208. */
  129209. export interface IWebXRControllerOptions {
  129210. /**
  129211. * Should the controller mesh be animated when a user interacts with it
  129212. * The pressed buttons / thumbstick and touchpad animations will be disabled
  129213. */
  129214. disableMotionControllerAnimation?: boolean;
  129215. /**
  129216. * Do not load the controller mesh, in case a different mesh needs to be loaded.
  129217. */
  129218. doNotLoadControllerMesh?: boolean;
  129219. /**
  129220. * Force a specific controller type for this controller.
  129221. * This can be used when creating your own profile or when testing different controllers
  129222. */
  129223. forceControllerProfile?: string;
  129224. /**
  129225. * Defines a rendering group ID for meshes that will be loaded.
  129226. * This is for the default controllers only.
  129227. */
  129228. renderingGroupId?: number;
  129229. }
  129230. /**
  129231. * Represents an XR controller
  129232. */
  129233. export class WebXRInputSource {
  129234. private _scene;
  129235. /** The underlying input source for the controller */
  129236. inputSource: XRInputSource;
  129237. private _options;
  129238. private _tmpVector;
  129239. private _uniqueId;
  129240. private _disposed;
  129241. /**
  129242. * 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
  129243. */
  129244. grip?: AbstractMesh;
  129245. /**
  129246. * If available, this is the gamepad object related to this controller.
  129247. * Using this object it is possible to get click events and trackpad changes of the
  129248. * webxr controller that is currently being used.
  129249. */
  129250. motionController?: WebXRAbstractMotionController;
  129251. /**
  129252. * Event that fires when the controller is removed/disposed.
  129253. * The object provided as event data is this controller, after associated assets were disposed.
  129254. * uniqueId is still available.
  129255. */
  129256. onDisposeObservable: Observable<WebXRInputSource>;
  129257. /**
  129258. * Will be triggered when the mesh associated with the motion controller is done loading.
  129259. * It is also possible that this will never trigger (!) if no mesh was loaded, or if the developer decides to load a different mesh
  129260. * A shortened version of controller -> motion controller -> on mesh loaded.
  129261. */
  129262. onMeshLoadedObservable: Observable<AbstractMesh>;
  129263. /**
  129264. * Observers registered here will trigger when a motion controller profile was assigned to this xr controller
  129265. */
  129266. onMotionControllerInitObservable: Observable<WebXRAbstractMotionController>;
  129267. /**
  129268. * Pointer which can be used to select objects or attach a visible laser to
  129269. */
  129270. pointer: AbstractMesh;
  129271. /**
  129272. * Creates the input source object
  129273. * @see https://doc.babylonjs.com/how_to/webxr_controllers_support
  129274. * @param _scene the scene which the controller should be associated to
  129275. * @param inputSource the underlying input source for the controller
  129276. * @param _options options for this controller creation
  129277. */
  129278. constructor(_scene: Scene,
  129279. /** The underlying input source for the controller */
  129280. inputSource: XRInputSource, _options?: IWebXRControllerOptions);
  129281. /**
  129282. * Get this controllers unique id
  129283. */
  129284. get uniqueId(): string;
  129285. /**
  129286. * Disposes of the object
  129287. */
  129288. dispose(): void;
  129289. /**
  129290. * Gets a world space ray coming from the pointer or grip
  129291. * @param result the resulting ray
  129292. * @param gripIfAvailable use the grip mesh instead of the pointer, if available
  129293. */
  129294. getWorldPointerRayToRef(result: Ray, gripIfAvailable?: boolean): void;
  129295. /**
  129296. * Updates the controller pose based on the given XRFrame
  129297. * @param xrFrame xr frame to update the pose with
  129298. * @param referenceSpace reference space to use
  129299. */
  129300. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace): void;
  129301. }
  129302. }
  129303. declare module BABYLON {
  129304. /**
  129305. * The schema for initialization options of the XR Input class
  129306. */
  129307. export interface IWebXRInputOptions {
  129308. /**
  129309. * If set to true no model will be automatically loaded
  129310. */
  129311. doNotLoadControllerMeshes?: boolean;
  129312. /**
  129313. * If set, this profile will be used for all controllers loaded (for example "microsoft-mixed-reality")
  129314. * If not found, the xr input profile data will be used.
  129315. * Profiles are defined here - https://github.com/immersive-web/webxr-input-profiles/
  129316. */
  129317. forceInputProfile?: string;
  129318. /**
  129319. * Do not send a request to the controller repository to load the profile.
  129320. *
  129321. * Instead, use the controllers available in babylon itself.
  129322. */
  129323. disableOnlineControllerRepository?: boolean;
  129324. /**
  129325. * A custom URL for the controllers repository
  129326. */
  129327. customControllersRepositoryURL?: string;
  129328. /**
  129329. * Should the controller model's components not move according to the user input
  129330. */
  129331. disableControllerAnimation?: boolean;
  129332. /**
  129333. * Optional options to pass to the controller. Will be overridden by the Input options where applicable
  129334. */
  129335. controllerOptions?: IWebXRControllerOptions;
  129336. }
  129337. /**
  129338. * XR input used to track XR inputs such as controllers/rays
  129339. */
  129340. export class WebXRInput implements IDisposable {
  129341. /**
  129342. * the xr session manager for this session
  129343. */
  129344. xrSessionManager: WebXRSessionManager;
  129345. /**
  129346. * the WebXR camera for this session. Mainly used for teleportation
  129347. */
  129348. xrCamera: WebXRCamera;
  129349. private readonly options;
  129350. /**
  129351. * XR controllers being tracked
  129352. */
  129353. controllers: Array<WebXRInputSource>;
  129354. private _frameObserver;
  129355. private _sessionEndedObserver;
  129356. private _sessionInitObserver;
  129357. /**
  129358. * Event when a controller has been connected/added
  129359. */
  129360. onControllerAddedObservable: Observable<WebXRInputSource>;
  129361. /**
  129362. * Event when a controller has been removed/disconnected
  129363. */
  129364. onControllerRemovedObservable: Observable<WebXRInputSource>;
  129365. /**
  129366. * Initializes the WebXRInput
  129367. * @param xrSessionManager the xr session manager for this session
  129368. * @param xrCamera the WebXR camera for this session. Mainly used for teleportation
  129369. * @param options = initialization options for this xr input
  129370. */
  129371. constructor(
  129372. /**
  129373. * the xr session manager for this session
  129374. */
  129375. xrSessionManager: WebXRSessionManager,
  129376. /**
  129377. * the WebXR camera for this session. Mainly used for teleportation
  129378. */
  129379. xrCamera: WebXRCamera, options?: IWebXRInputOptions);
  129380. private _onInputSourcesChange;
  129381. private _addAndRemoveControllers;
  129382. /**
  129383. * Disposes of the object
  129384. */
  129385. dispose(): void;
  129386. }
  129387. }
  129388. declare module BABYLON {
  129389. /**
  129390. * This is the base class for all WebXR features.
  129391. * Since most features require almost the same resources and callbacks, this class can be used to simplify the development
  129392. * Note that since the features manager is using the `IWebXRFeature` you are in no way obligated to use this class
  129393. */
  129394. export abstract class WebXRAbstractFeature implements IWebXRFeature {
  129395. protected _xrSessionManager: WebXRSessionManager;
  129396. private _attached;
  129397. private _removeOnDetach;
  129398. /**
  129399. * Is this feature disposed?
  129400. */
  129401. isDisposed: boolean;
  129402. /**
  129403. * Should auto-attach be disabled?
  129404. */
  129405. disableAutoAttach: boolean;
  129406. /**
  129407. * The name of the native xr feature name (like anchor, hit-test, or hand-tracking)
  129408. */
  129409. xrNativeFeatureName: string;
  129410. /**
  129411. * Construct a new (abstract) WebXR feature
  129412. * @param _xrSessionManager the xr session manager for this feature
  129413. */
  129414. constructor(_xrSessionManager: WebXRSessionManager);
  129415. /**
  129416. * Is this feature attached
  129417. */
  129418. get attached(): boolean;
  129419. /**
  129420. * attach this feature
  129421. *
  129422. * @param force should attachment be forced (even when already attached)
  129423. * @returns true if successful, false is failed or already attached
  129424. */
  129425. attach(force?: boolean): boolean;
  129426. /**
  129427. * detach this feature.
  129428. *
  129429. * @returns true if successful, false if failed or already detached
  129430. */
  129431. detach(): boolean;
  129432. /**
  129433. * Dispose this feature and all of the resources attached
  129434. */
  129435. dispose(): void;
  129436. /**
  129437. * This function will be executed during before enabling the feature and can be used to not-allow enabling it.
  129438. * Note that at this point the session has NOT started, so this is purely checking if the browser supports it
  129439. *
  129440. * @returns whether or not the feature is compatible in this environment
  129441. */
  129442. isCompatible(): boolean;
  129443. /**
  129444. * This is used to register callbacks that will automatically be removed when detach is called.
  129445. * @param observable the observable to which the observer will be attached
  129446. * @param callback the callback to register
  129447. */
  129448. protected _addNewAttachObserver<T>(observable: Observable<T>, callback: (eventData: T, eventState: EventState) => void): void;
  129449. /**
  129450. * Code in this function will be executed on each xrFrame received from the browser.
  129451. * This function will not execute after the feature is detached.
  129452. * @param _xrFrame the current frame
  129453. */
  129454. protected abstract _onXRFrame(_xrFrame: XRFrame): void;
  129455. }
  129456. }
  129457. declare module BABYLON {
  129458. /**
  129459. * Renders a layer on top of an existing scene
  129460. */
  129461. export class UtilityLayerRenderer implements IDisposable {
  129462. /** the original scene that will be rendered on top of */
  129463. originalScene: Scene;
  129464. private _pointerCaptures;
  129465. private _lastPointerEvents;
  129466. private static _DefaultUtilityLayer;
  129467. private static _DefaultKeepDepthUtilityLayer;
  129468. private _sharedGizmoLight;
  129469. private _renderCamera;
  129470. /**
  129471. * Gets the camera that is used to render the utility layer (when not set, this will be the last active camera)
  129472. * @param getRigParentIfPossible if the current active camera is a rig camera, should its parent camera be returned
  129473. * @returns the camera that is used when rendering the utility layer
  129474. */
  129475. getRenderCamera(getRigParentIfPossible?: boolean): Camera;
  129476. /**
  129477. * Sets the camera that should be used when rendering the utility layer (If set to null the last active camera will be used)
  129478. * @param cam the camera that should be used when rendering the utility layer
  129479. */
  129480. setRenderCamera(cam: Nullable<Camera>): void;
  129481. /**
  129482. * @hidden
  129483. * Light which used by gizmos to get light shading
  129484. */
  129485. _getSharedGizmoLight(): HemisphericLight;
  129486. /**
  129487. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  129488. */
  129489. pickUtilitySceneFirst: boolean;
  129490. /**
  129491. * 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)
  129492. */
  129493. static get DefaultUtilityLayer(): UtilityLayerRenderer;
  129494. /**
  129495. * 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)
  129496. */
  129497. static get DefaultKeepDepthUtilityLayer(): UtilityLayerRenderer;
  129498. /**
  129499. * The scene that is rendered on top of the original scene
  129500. */
  129501. utilityLayerScene: Scene;
  129502. /**
  129503. * If the utility layer should automatically be rendered on top of existing scene
  129504. */
  129505. shouldRender: boolean;
  129506. /**
  129507. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  129508. */
  129509. onlyCheckPointerDownEvents: boolean;
  129510. /**
  129511. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  129512. */
  129513. processAllEvents: boolean;
  129514. /**
  129515. * Observable raised when the pointer move from the utility layer scene to the main scene
  129516. */
  129517. onPointerOutObservable: Observable<number>;
  129518. /** Gets or sets a predicate that will be used to indicate utility meshes present in the main scene */
  129519. mainSceneTrackerPredicate: (mesh: Nullable<AbstractMesh>) => boolean;
  129520. private _afterRenderObserver;
  129521. private _sceneDisposeObserver;
  129522. private _originalPointerObserver;
  129523. /**
  129524. * Instantiates a UtilityLayerRenderer
  129525. * @param originalScene the original scene that will be rendered on top of
  129526. * @param handleEvents boolean indicating if the utility layer should handle events
  129527. */
  129528. constructor(
  129529. /** the original scene that will be rendered on top of */
  129530. originalScene: Scene, handleEvents?: boolean);
  129531. private _notifyObservers;
  129532. /**
  129533. * Renders the utility layers scene on top of the original scene
  129534. */
  129535. render(): void;
  129536. /**
  129537. * Disposes of the renderer
  129538. */
  129539. dispose(): void;
  129540. private _updateCamera;
  129541. }
  129542. }
  129543. declare module BABYLON {
  129544. /**
  129545. * Options interface for the pointer selection module
  129546. */
  129547. export interface IWebXRControllerPointerSelectionOptions {
  129548. /**
  129549. * if provided, this scene will be used to render meshes.
  129550. */
  129551. customUtilityLayerScene?: Scene;
  129552. /**
  129553. * 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)
  129554. * If not disabled, the last picked point will be used to execute a pointer up event
  129555. * If disabled, pointer up event will be triggered right after the pointer down event.
  129556. * Used in screen and gaze target ray mode only
  129557. */
  129558. disablePointerUpOnTouchOut: boolean;
  129559. /**
  129560. * For gaze mode for tracked-pointer / controllers (time to select instead of button press)
  129561. */
  129562. forceGazeMode: boolean;
  129563. /**
  129564. * 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
  129565. * to start a new countdown to the pointer down event.
  129566. * Defaults to 1.
  129567. */
  129568. gazeModePointerMovedFactor?: number;
  129569. /**
  129570. * Different button type to use instead of the main component
  129571. */
  129572. overrideButtonId?: string;
  129573. /**
  129574. * use this rendering group id for the meshes (optional)
  129575. */
  129576. renderingGroupId?: number;
  129577. /**
  129578. * The amount of time in milliseconds it takes between pick found something to a pointer down event.
  129579. * Used in gaze modes. Tracked pointer uses the trigger, screen uses touch events
  129580. * 3000 means 3 seconds between pointing at something and selecting it
  129581. */
  129582. timeToSelect?: number;
  129583. /**
  129584. * Should meshes created here be added to a utility layer or the main scene
  129585. */
  129586. useUtilityLayer?: boolean;
  129587. /**
  129588. * Optional WebXR camera to be used for gaze selection
  129589. */
  129590. gazeCamera?: WebXRCamera;
  129591. /**
  129592. * the xr input to use with this pointer selection
  129593. */
  129594. xrInput: WebXRInput;
  129595. }
  129596. /**
  129597. * A module that will enable pointer selection for motion controllers of XR Input Sources
  129598. */
  129599. export class WebXRControllerPointerSelection extends WebXRAbstractFeature {
  129600. private readonly _options;
  129601. private static _idCounter;
  129602. private _attachController;
  129603. private _controllers;
  129604. private _scene;
  129605. private _tmpVectorForPickCompare;
  129606. /**
  129607. * The module's name
  129608. */
  129609. static readonly Name: string;
  129610. /**
  129611. * The (Babylon) version of this module.
  129612. * This is an integer representing the implementation version.
  129613. * This number does not correspond to the WebXR specs version
  129614. */
  129615. static readonly Version: number;
  129616. /**
  129617. * Disable lighting on the laser pointer (so it will always be visible)
  129618. */
  129619. disablePointerLighting: boolean;
  129620. /**
  129621. * Disable lighting on the selection mesh (so it will always be visible)
  129622. */
  129623. disableSelectionMeshLighting: boolean;
  129624. /**
  129625. * Should the laser pointer be displayed
  129626. */
  129627. displayLaserPointer: boolean;
  129628. /**
  129629. * Should the selection mesh be displayed (The ring at the end of the laser pointer)
  129630. */
  129631. displaySelectionMesh: boolean;
  129632. /**
  129633. * This color will be set to the laser pointer when selection is triggered
  129634. */
  129635. laserPointerPickedColor: Color3;
  129636. /**
  129637. * Default color of the laser pointer
  129638. */
  129639. laserPointerDefaultColor: Color3;
  129640. /**
  129641. * default color of the selection ring
  129642. */
  129643. selectionMeshDefaultColor: Color3;
  129644. /**
  129645. * This color will be applied to the selection ring when selection is triggered
  129646. */
  129647. selectionMeshPickedColor: Color3;
  129648. /**
  129649. * Optional filter to be used for ray selection. This predicate shares behavior with
  129650. * scene.pointerMovePredicate which takes priority if it is also assigned.
  129651. */
  129652. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  129653. /**
  129654. * constructs a new background remover module
  129655. * @param _xrSessionManager the session manager for this module
  129656. * @param _options read-only options to be used in this module
  129657. */
  129658. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPointerSelectionOptions);
  129659. /**
  129660. * attach this feature
  129661. * Will usually be called by the features manager
  129662. *
  129663. * @returns true if successful.
  129664. */
  129665. attach(): boolean;
  129666. /**
  129667. * detach this feature.
  129668. * Will usually be called by the features manager
  129669. *
  129670. * @returns true if successful.
  129671. */
  129672. detach(): boolean;
  129673. /**
  129674. * Will get the mesh under a specific pointer.
  129675. * `scene.meshUnderPointer` will only return one mesh - either left or right.
  129676. * @param controllerId the controllerId to check
  129677. * @returns The mesh under pointer or null if no mesh is under the pointer
  129678. */
  129679. getMeshUnderPointer(controllerId: string): Nullable<AbstractMesh>;
  129680. /**
  129681. * Get the xr controller that correlates to the pointer id in the pointer event
  129682. *
  129683. * @param id the pointer id to search for
  129684. * @returns the controller that correlates to this id or null if not found
  129685. */
  129686. getXRControllerByPointerId(id: number): Nullable<WebXRInputSource>;
  129687. protected _onXRFrame(_xrFrame: XRFrame): void;
  129688. private _attachGazeMode;
  129689. private _attachScreenRayMode;
  129690. private _attachTrackedPointerRayMode;
  129691. private _convertNormalToDirectionOfRay;
  129692. private _detachController;
  129693. private _generateNewMeshPair;
  129694. private _pickingMoved;
  129695. private _updatePointerDistance;
  129696. /** @hidden */
  129697. get lasterPointerDefaultColor(): Color3;
  129698. }
  129699. }
  129700. declare module BABYLON {
  129701. /**
  129702. * Button which can be used to enter a different mode of XR
  129703. */
  129704. export class WebXREnterExitUIButton {
  129705. /** button element */
  129706. element: HTMLElement;
  129707. /** XR initialization options for the button */
  129708. sessionMode: XRSessionMode;
  129709. /** Reference space type */
  129710. referenceSpaceType: XRReferenceSpaceType;
  129711. /**
  129712. * Creates a WebXREnterExitUIButton
  129713. * @param element button element
  129714. * @param sessionMode XR initialization session mode
  129715. * @param referenceSpaceType the type of reference space to be used
  129716. */
  129717. constructor(
  129718. /** button element */
  129719. element: HTMLElement,
  129720. /** XR initialization options for the button */
  129721. sessionMode: XRSessionMode,
  129722. /** Reference space type */
  129723. referenceSpaceType: XRReferenceSpaceType);
  129724. /**
  129725. * Extendable function which can be used to update the button's visuals when the state changes
  129726. * @param activeButton the current active button in the UI
  129727. */
  129728. update(activeButton: Nullable<WebXREnterExitUIButton>): void;
  129729. }
  129730. /**
  129731. * Options to create the webXR UI
  129732. */
  129733. export class WebXREnterExitUIOptions {
  129734. /**
  129735. * User provided buttons to enable/disable WebXR. The system will provide default if not set
  129736. */
  129737. customButtons?: Array<WebXREnterExitUIButton>;
  129738. /**
  129739. * A reference space type to use when creating the default button.
  129740. * Default is local-floor
  129741. */
  129742. referenceSpaceType?: XRReferenceSpaceType;
  129743. /**
  129744. * Context to enter xr with
  129745. */
  129746. renderTarget?: Nullable<WebXRRenderTarget>;
  129747. /**
  129748. * A session mode to use when creating the default button.
  129749. * Default is immersive-vr
  129750. */
  129751. sessionMode?: XRSessionMode;
  129752. /**
  129753. * A list of optional features to init the session with
  129754. */
  129755. optionalFeatures?: string[];
  129756. /**
  129757. * A list of optional features to init the session with
  129758. */
  129759. requiredFeatures?: string[];
  129760. }
  129761. /**
  129762. * UI to allow the user to enter/exit XR mode
  129763. */
  129764. export class WebXREnterExitUI implements IDisposable {
  129765. private scene;
  129766. /** version of the options passed to this UI */
  129767. options: WebXREnterExitUIOptions;
  129768. private _activeButton;
  129769. private _buttons;
  129770. /**
  129771. * The HTML Div Element to which buttons are added.
  129772. */
  129773. readonly overlay: HTMLDivElement;
  129774. /**
  129775. * Fired every time the active button is changed.
  129776. *
  129777. * When xr is entered via a button that launches xr that button will be the callback parameter
  129778. *
  129779. * When exiting xr the callback parameter will be null)
  129780. */
  129781. activeButtonChangedObservable: Observable<Nullable<WebXREnterExitUIButton>>;
  129782. /**
  129783. *
  129784. * @param scene babylon scene object to use
  129785. * @param options (read-only) version of the options passed to this UI
  129786. */
  129787. private constructor();
  129788. /**
  129789. * Creates UI to allow the user to enter/exit XR mode
  129790. * @param scene the scene to add the ui to
  129791. * @param helper the xr experience helper to enter/exit xr with
  129792. * @param options options to configure the UI
  129793. * @returns the created ui
  129794. */
  129795. static CreateAsync(scene: Scene, helper: WebXRExperienceHelper, options: WebXREnterExitUIOptions): Promise<WebXREnterExitUI>;
  129796. /**
  129797. * Disposes of the XR UI component
  129798. */
  129799. dispose(): void;
  129800. private _updateButtons;
  129801. }
  129802. }
  129803. declare module BABYLON {
  129804. /**
  129805. * Class containing static functions to help procedurally build meshes
  129806. */
  129807. export class LinesBuilder {
  129808. /**
  129809. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  129810. * * 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
  129811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  129812. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  129813. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  129814. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  129815. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129816. * * 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
  129817. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  129818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129819. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  129820. * @param name defines the name of the new line system
  129821. * @param options defines the options used to create the line system
  129822. * @param scene defines the hosting scene
  129823. * @returns a new line system mesh
  129824. */
  129825. static CreateLineSystem(name: string, options: {
  129826. lines: Vector3[][];
  129827. updatable?: boolean;
  129828. instance?: Nullable<LinesMesh>;
  129829. colors?: Nullable<Color4[][]>;
  129830. useVertexAlpha?: boolean;
  129831. }, scene: Nullable<Scene>): LinesMesh;
  129832. /**
  129833. * Creates a line mesh
  129834. * 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
  129835. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129836. * * The parameter `points` is an array successive Vector3
  129837. * * 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
  129838. * * The optional parameter `colors` is an array of successive Color4, one per line point
  129839. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  129840. * * When updating an instance, remember that only point positions can change, not the number of points
  129841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  129843. * @param name defines the name of the new line system
  129844. * @param options defines the options used to create the line system
  129845. * @param scene defines the hosting scene
  129846. * @returns a new line mesh
  129847. */
  129848. static CreateLines(name: string, options: {
  129849. points: Vector3[];
  129850. updatable?: boolean;
  129851. instance?: Nullable<LinesMesh>;
  129852. colors?: Color4[];
  129853. useVertexAlpha?: boolean;
  129854. }, scene?: Nullable<Scene>): LinesMesh;
  129855. /**
  129856. * Creates a dashed line mesh
  129857. * * 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
  129858. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  129859. * * The parameter `points` is an array successive Vector3
  129860. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  129861. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  129862. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  129863. * * 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
  129864. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  129865. * * When updating an instance, remember that only point positions can change, not the number of points
  129866. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  129867. * @param name defines the name of the mesh
  129868. * @param options defines the options used to create the mesh
  129869. * @param scene defines the hosting scene
  129870. * @returns the dashed line mesh
  129871. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  129872. */
  129873. static CreateDashedLines(name: string, options: {
  129874. points: Vector3[];
  129875. dashSize?: number;
  129876. gapSize?: number;
  129877. dashNb?: number;
  129878. updatable?: boolean;
  129879. instance?: LinesMesh;
  129880. useVertexAlpha?: boolean;
  129881. }, scene?: Nullable<Scene>): LinesMesh;
  129882. }
  129883. }
  129884. declare module BABYLON {
  129885. /**
  129886. * Construction options for a timer
  129887. */
  129888. export interface ITimerOptions<T> {
  129889. /**
  129890. * Time-to-end
  129891. */
  129892. timeout: number;
  129893. /**
  129894. * The context observable is used to calculate time deltas and provides the context of the timer's callbacks. Will usually be OnBeforeRenderObservable.
  129895. * Countdown calculation is done ONLY when the observable is notifying its observers, meaning that if
  129896. * you choose an observable that doesn't trigger too often, the wait time might extend further than the requested max time
  129897. */
  129898. contextObservable: Observable<T>;
  129899. /**
  129900. * Optional parameters when adding an observer to the observable
  129901. */
  129902. observableParameters?: {
  129903. mask?: number;
  129904. insertFirst?: boolean;
  129905. scope?: any;
  129906. };
  129907. /**
  129908. * An optional break condition that will stop the times prematurely. In this case onEnded will not be triggered!
  129909. */
  129910. breakCondition?: (data?: ITimerData<T>) => boolean;
  129911. /**
  129912. * Will be triggered when the time condition has met
  129913. */
  129914. onEnded?: (data: ITimerData<any>) => void;
  129915. /**
  129916. * Will be triggered when the break condition has met (prematurely ended)
  129917. */
  129918. onAborted?: (data: ITimerData<any>) => void;
  129919. /**
  129920. * Optional function to execute on each tick (or count)
  129921. */
  129922. onTick?: (data: ITimerData<any>) => void;
  129923. }
  129924. /**
  129925. * An interface defining the data sent by the timer
  129926. */
  129927. export interface ITimerData<T> {
  129928. /**
  129929. * When did it start
  129930. */
  129931. startTime: number;
  129932. /**
  129933. * Time now
  129934. */
  129935. currentTime: number;
  129936. /**
  129937. * Time passed since started
  129938. */
  129939. deltaTime: number;
  129940. /**
  129941. * How much is completed, in [0.0...1.0].
  129942. * Note that this CAN be higher than 1 due to the fact that we don't actually measure time but delta between observable calls
  129943. */
  129944. completeRate: number;
  129945. /**
  129946. * What the registered observable sent in the last count
  129947. */
  129948. payload: T;
  129949. }
  129950. /**
  129951. * The current state of the timer
  129952. */
  129953. export enum TimerState {
  129954. /**
  129955. * Timer initialized, not yet started
  129956. */
  129957. INIT = 0,
  129958. /**
  129959. * Timer started and counting
  129960. */
  129961. STARTED = 1,
  129962. /**
  129963. * Timer ended (whether aborted or time reached)
  129964. */
  129965. ENDED = 2
  129966. }
  129967. /**
  129968. * A simple version of the timer. Will take options and start the timer immediately after calling it
  129969. *
  129970. * @param options options with which to initialize this timer
  129971. */
  129972. export function setAndStartTimer(options: ITimerOptions<any>): Nullable<Observer<any>>;
  129973. /**
  129974. * An advanced implementation of a timer class
  129975. */
  129976. export class AdvancedTimer<T = any> implements IDisposable {
  129977. /**
  129978. * Will notify each time the timer calculates the remaining time
  129979. */
  129980. onEachCountObservable: Observable<ITimerData<T>>;
  129981. /**
  129982. * Will trigger when the timer was aborted due to the break condition
  129983. */
  129984. onTimerAbortedObservable: Observable<ITimerData<T>>;
  129985. /**
  129986. * Will trigger when the timer ended successfully
  129987. */
  129988. onTimerEndedObservable: Observable<ITimerData<T>>;
  129989. /**
  129990. * Will trigger when the timer state has changed
  129991. */
  129992. onStateChangedObservable: Observable<TimerState>;
  129993. private _observer;
  129994. private _contextObservable;
  129995. private _observableParameters;
  129996. private _startTime;
  129997. private _timer;
  129998. private _state;
  129999. private _breakCondition;
  130000. private _timeToEnd;
  130001. private _breakOnNextTick;
  130002. /**
  130003. * Will construct a new advanced timer based on the options provided. Timer will not start until start() is called.
  130004. * @param options construction options for this advanced timer
  130005. */
  130006. constructor(options: ITimerOptions<T>);
  130007. /**
  130008. * set a breaking condition for this timer. Default is to never break during count
  130009. * @param predicate the new break condition. Returns true to break, false otherwise
  130010. */
  130011. set breakCondition(predicate: (data: ITimerData<T>) => boolean);
  130012. /**
  130013. * Reset ALL associated observables in this advanced timer
  130014. */
  130015. clearObservables(): void;
  130016. /**
  130017. * Will start a new iteration of this timer. Only one instance of this timer can run at a time.
  130018. *
  130019. * @param timeToEnd how much time to measure until timer ended
  130020. */
  130021. start(timeToEnd?: number): void;
  130022. /**
  130023. * Will force a stop on the next tick.
  130024. */
  130025. stop(): void;
  130026. /**
  130027. * Dispose this timer, clearing all resources
  130028. */
  130029. dispose(): void;
  130030. private _setState;
  130031. private _tick;
  130032. private _stop;
  130033. }
  130034. }
  130035. declare module BABYLON {
  130036. /**
  130037. * The options container for the teleportation module
  130038. */
  130039. export interface IWebXRTeleportationOptions {
  130040. /**
  130041. * if provided, this scene will be used to render meshes.
  130042. */
  130043. customUtilityLayerScene?: Scene;
  130044. /**
  130045. * Values to configure the default target mesh
  130046. */
  130047. defaultTargetMeshOptions?: {
  130048. /**
  130049. * Fill color of the teleportation area
  130050. */
  130051. teleportationFillColor?: string;
  130052. /**
  130053. * Border color for the teleportation area
  130054. */
  130055. teleportationBorderColor?: string;
  130056. /**
  130057. * Disable the mesh's animation sequence
  130058. */
  130059. disableAnimation?: boolean;
  130060. /**
  130061. * Disable lighting on the material or the ring and arrow
  130062. */
  130063. disableLighting?: boolean;
  130064. /**
  130065. * Override the default material of the torus and arrow
  130066. */
  130067. torusArrowMaterial?: Material;
  130068. };
  130069. /**
  130070. * A list of meshes to use as floor meshes.
  130071. * Meshes can be added and removed after initializing the feature using the
  130072. * addFloorMesh and removeFloorMesh functions
  130073. * If empty, rotation will still work
  130074. */
  130075. floorMeshes?: AbstractMesh[];
  130076. /**
  130077. * use this rendering group id for the meshes (optional)
  130078. */
  130079. renderingGroupId?: number;
  130080. /**
  130081. * Should teleportation move only to snap points
  130082. */
  130083. snapPointsOnly?: boolean;
  130084. /**
  130085. * An array of points to which the teleportation will snap to.
  130086. * If the teleportation ray is in the proximity of one of those points, it will be corrected to this point.
  130087. */
  130088. snapPositions?: Vector3[];
  130089. /**
  130090. * How close should the teleportation ray be in order to snap to position.
  130091. * Default to 0.8 units (meters)
  130092. */
  130093. snapToPositionRadius?: number;
  130094. /**
  130095. * Provide your own teleportation mesh instead of babylon's wonderful doughnut.
  130096. * If you want to support rotation, make sure your mesh has a direction indicator.
  130097. *
  130098. * When left untouched, the default mesh will be initialized.
  130099. */
  130100. teleportationTargetMesh?: AbstractMesh;
  130101. /**
  130102. * If main component is used (no thumbstick), how long should the "long press" take before teleport
  130103. */
  130104. timeToTeleport?: number;
  130105. /**
  130106. * Disable using the thumbstick and use the main component (usually trigger) on long press.
  130107. * This will be automatically true if the controller doesn't have a thumbstick or touchpad.
  130108. */
  130109. useMainComponentOnly?: boolean;
  130110. /**
  130111. * Should meshes created here be added to a utility layer or the main scene
  130112. */
  130113. useUtilityLayer?: boolean;
  130114. /**
  130115. * Babylon XR Input class for controller
  130116. */
  130117. xrInput: WebXRInput;
  130118. /**
  130119. * Meshes that the teleportation ray cannot go through
  130120. */
  130121. pickBlockerMeshes?: AbstractMesh[];
  130122. }
  130123. /**
  130124. * This is a teleportation feature to be used with WebXR-enabled motion controllers.
  130125. * When enabled and attached, the feature will allow a user to move around and rotate in the scene using
  130126. * the input of the attached controllers.
  130127. */
  130128. export class WebXRMotionControllerTeleportation extends WebXRAbstractFeature {
  130129. private _options;
  130130. private _controllers;
  130131. private _currentTeleportationControllerId;
  130132. private _floorMeshes;
  130133. private _quadraticBezierCurve;
  130134. private _selectionFeature;
  130135. private _snapToPositions;
  130136. private _snappedToPoint;
  130137. private _teleportationRingMaterial?;
  130138. private _tmpRay;
  130139. private _tmpVector;
  130140. private _tmpQuaternion;
  130141. /**
  130142. * The module's name
  130143. */
  130144. static readonly Name: string;
  130145. /**
  130146. * The (Babylon) version of this module.
  130147. * This is an integer representing the implementation version.
  130148. * This number does not correspond to the webxr specs version
  130149. */
  130150. static readonly Version: number;
  130151. /**
  130152. * Is movement backwards enabled
  130153. */
  130154. backwardsMovementEnabled: boolean;
  130155. /**
  130156. * Distance to travel when moving backwards
  130157. */
  130158. backwardsTeleportationDistance: number;
  130159. /**
  130160. * The distance from the user to the inspection point in the direction of the controller
  130161. * A higher number will allow the user to move further
  130162. * defaults to 5 (meters, in xr units)
  130163. */
  130164. parabolicCheckRadius: number;
  130165. /**
  130166. * Should the module support parabolic ray on top of direct ray
  130167. * If enabled, the user will be able to point "at the sky" and move according to predefined radius distance
  130168. * Very helpful when moving between floors / different heights
  130169. */
  130170. parabolicRayEnabled: boolean;
  130171. /**
  130172. * How much rotation should be applied when rotating right and left
  130173. */
  130174. rotationAngle: number;
  130175. /**
  130176. * Is rotation enabled when moving forward?
  130177. * Disabling this feature will prevent the user from deciding the direction when teleporting
  130178. */
  130179. rotationEnabled: boolean;
  130180. /**
  130181. * constructs a new anchor system
  130182. * @param _xrSessionManager an instance of WebXRSessionManager
  130183. * @param _options configuration object for this feature
  130184. */
  130185. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRTeleportationOptions);
  130186. /**
  130187. * Get the snapPointsOnly flag
  130188. */
  130189. get snapPointsOnly(): boolean;
  130190. /**
  130191. * Sets the snapPointsOnly flag
  130192. * @param snapToPoints should teleportation be exclusively to snap points
  130193. */
  130194. set snapPointsOnly(snapToPoints: boolean);
  130195. /**
  130196. * Add a new mesh to the floor meshes array
  130197. * @param mesh the mesh to use as floor mesh
  130198. */
  130199. addFloorMesh(mesh: AbstractMesh): void;
  130200. /**
  130201. * Add a new snap-to point to fix teleportation to this position
  130202. * @param newSnapPoint The new Snap-To point
  130203. */
  130204. addSnapPoint(newSnapPoint: Vector3): void;
  130205. attach(): boolean;
  130206. detach(): boolean;
  130207. dispose(): void;
  130208. /**
  130209. * Remove a mesh from the floor meshes array
  130210. * @param mesh the mesh to remove
  130211. */
  130212. removeFloorMesh(mesh: AbstractMesh): void;
  130213. /**
  130214. * Remove a mesh from the floor meshes array using its name
  130215. * @param name the mesh name to remove
  130216. */
  130217. removeFloorMeshByName(name: string): void;
  130218. /**
  130219. * 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
  130220. * @param snapPointToRemove the point (or a clone of it) to be removed from the array
  130221. * @returns was the point found and removed or not
  130222. */
  130223. removeSnapPoint(snapPointToRemove: Vector3): boolean;
  130224. /**
  130225. * This function sets a selection feature that will be disabled when
  130226. * the forward ray is shown and will be reattached when hidden.
  130227. * This is used to remove the selection rays when moving.
  130228. * @param selectionFeature the feature to disable when forward movement is enabled
  130229. */
  130230. setSelectionFeature(selectionFeature: Nullable<IWebXRFeature>): void;
  130231. protected _onXRFrame(_xrFrame: XRFrame): void;
  130232. private _attachController;
  130233. private _createDefaultTargetMesh;
  130234. private _detachController;
  130235. private _findClosestSnapPointWithRadius;
  130236. private _setTargetMeshPosition;
  130237. private _setTargetMeshVisibility;
  130238. private _showParabolicPath;
  130239. private _teleportForward;
  130240. }
  130241. }
  130242. declare module BABYLON {
  130243. /**
  130244. * Options for the default xr helper
  130245. */
  130246. export class WebXRDefaultExperienceOptions {
  130247. /**
  130248. * Enable or disable default UI to enter XR
  130249. */
  130250. disableDefaultUI?: boolean;
  130251. /**
  130252. * Should teleportation not initialize. defaults to false.
  130253. */
  130254. disableTeleportation?: boolean;
  130255. /**
  130256. * Floor meshes that will be used for teleport
  130257. */
  130258. floorMeshes?: Array<AbstractMesh>;
  130259. /**
  130260. * If set to true, the first frame will not be used to reset position
  130261. * The first frame is mainly used when copying transformation from the old camera
  130262. * Mainly used in AR
  130263. */
  130264. ignoreNativeCameraTransformation?: boolean;
  130265. /**
  130266. * Disable the controller mesh-loading. Can be used if you want to load your own meshes
  130267. */
  130268. inputOptions?: IWebXRInputOptions;
  130269. /**
  130270. * optional configuration for the output canvas
  130271. */
  130272. outputCanvasOptions?: WebXRManagedOutputCanvasOptions;
  130273. /**
  130274. * optional UI options. This can be used among other to change session mode and reference space type
  130275. */
  130276. uiOptions?: WebXREnterExitUIOptions;
  130277. /**
  130278. * When loading teleportation and pointer select, use stable versions instead of latest.
  130279. */
  130280. useStablePlugins?: boolean;
  130281. /**
  130282. * An optional rendering group id that will be set globally for teleportation, pointer selection and default controller meshes
  130283. */
  130284. renderingGroupId?: number;
  130285. /**
  130286. * A list of optional features to init the session with
  130287. * If set to true, all features we support will be added
  130288. */
  130289. optionalFeatures?: boolean | string[];
  130290. }
  130291. /**
  130292. * Default experience which provides a similar setup to the previous webVRExperience
  130293. */
  130294. export class WebXRDefaultExperience {
  130295. /**
  130296. * Base experience
  130297. */
  130298. baseExperience: WebXRExperienceHelper;
  130299. /**
  130300. * Enables ui for entering/exiting xr
  130301. */
  130302. enterExitUI: WebXREnterExitUI;
  130303. /**
  130304. * Input experience extension
  130305. */
  130306. input: WebXRInput;
  130307. /**
  130308. * Enables laser pointer and selection
  130309. */
  130310. pointerSelection: WebXRControllerPointerSelection;
  130311. /**
  130312. * Default target xr should render to
  130313. */
  130314. renderTarget: WebXRRenderTarget;
  130315. /**
  130316. * Enables teleportation
  130317. */
  130318. teleportation: WebXRMotionControllerTeleportation;
  130319. private constructor();
  130320. /**
  130321. * Creates the default xr experience
  130322. * @param scene scene
  130323. * @param options options for basic configuration
  130324. * @returns resulting WebXRDefaultExperience
  130325. */
  130326. static CreateAsync(scene: Scene, options?: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  130327. /**
  130328. * DIsposes of the experience helper
  130329. */
  130330. dispose(): void;
  130331. }
  130332. }
  130333. declare module BABYLON {
  130334. /**
  130335. * Options to modify the vr teleportation behavior.
  130336. */
  130337. export interface VRTeleportationOptions {
  130338. /**
  130339. * The name of the mesh which should be used as the teleportation floor. (default: null)
  130340. */
  130341. floorMeshName?: string;
  130342. /**
  130343. * A list of meshes to be used as the teleportation floor. (default: empty)
  130344. */
  130345. floorMeshes?: Mesh[];
  130346. /**
  130347. * The teleportation mode. (default: TELEPORTATIONMODE_CONSTANTTIME)
  130348. */
  130349. teleportationMode?: number;
  130350. /**
  130351. * The duration of the animation in ms, apply when animationMode is TELEPORTATIONMODE_CONSTANTTIME. (default 122ms)
  130352. */
  130353. teleportationTime?: number;
  130354. /**
  130355. * The speed of the animation in distance/sec, apply when animationMode is TELEPORTATIONMODE_CONSTANTSPEED. (default 20 units / sec)
  130356. */
  130357. teleportationSpeed?: number;
  130358. /**
  130359. * The easing function used in the animation or null for Linear. (default CircleEase)
  130360. */
  130361. easingFunction?: EasingFunction;
  130362. }
  130363. /**
  130364. * Options to modify the vr experience helper's behavior.
  130365. */
  130366. export interface VRExperienceHelperOptions extends WebVROptions {
  130367. /**
  130368. * Create a DeviceOrientationCamera to be used as your out of vr camera. (default: true)
  130369. */
  130370. createDeviceOrientationCamera?: boolean;
  130371. /**
  130372. * Create a VRDeviceOrientationFreeCamera to be used for VR when no external HMD is found. (default: true)
  130373. */
  130374. createFallbackVRDeviceOrientationFreeCamera?: boolean;
  130375. /**
  130376. * Uses the main button on the controller to toggle the laser casted. (default: true)
  130377. */
  130378. laserToggle?: boolean;
  130379. /**
  130380. * A list of meshes to be used as the teleportation floor. If specified, teleportation will be enabled (default: undefined)
  130381. */
  130382. floorMeshes?: Mesh[];
  130383. /**
  130384. * Distortion metrics for the fallback vrDeviceOrientationCamera (default: VRCameraMetrics.Default)
  130385. */
  130386. vrDeviceOrientationCameraMetrics?: VRCameraMetrics;
  130387. /**
  130388. * Defines if WebXR should be used instead of WebVR (if available)
  130389. */
  130390. useXR?: boolean;
  130391. }
  130392. /**
  130393. * Event containing information after VR has been entered
  130394. */
  130395. export class OnAfterEnteringVRObservableEvent {
  130396. /**
  130397. * If entering vr was successful
  130398. */
  130399. success: boolean;
  130400. }
  130401. /**
  130402. * Helps to quickly add VR support to an existing scene.
  130403. * See https://doc.babylonjs.com/how_to/webvr_helper
  130404. */
  130405. export class VRExperienceHelper {
  130406. /** Options to modify the vr experience helper's behavior. */
  130407. webVROptions: VRExperienceHelperOptions;
  130408. private _scene;
  130409. private _position;
  130410. private _btnVR;
  130411. private _btnVRDisplayed;
  130412. private _webVRsupported;
  130413. private _webVRready;
  130414. private _webVRrequesting;
  130415. private _webVRpresenting;
  130416. private _hasEnteredVR;
  130417. private _fullscreenVRpresenting;
  130418. private _inputElement;
  130419. private _webVRCamera;
  130420. private _vrDeviceOrientationCamera;
  130421. private _deviceOrientationCamera;
  130422. private _existingCamera;
  130423. private _onKeyDown;
  130424. private _onVrDisplayPresentChange;
  130425. private _onVRDisplayChanged;
  130426. private _onVRRequestPresentStart;
  130427. private _onVRRequestPresentComplete;
  130428. /**
  130429. * 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)
  130430. */
  130431. enableGazeEvenWhenNoPointerLock: boolean;
  130432. /**
  130433. * Gets or sets a boolean indicating that the VREXperienceHelper will exit VR if double tap is detected
  130434. */
  130435. exitVROnDoubleTap: boolean;
  130436. /**
  130437. * Observable raised right before entering VR.
  130438. */
  130439. onEnteringVRObservable: Observable<VRExperienceHelper>;
  130440. /**
  130441. * Observable raised when entering VR has completed.
  130442. */
  130443. onAfterEnteringVRObservable: Observable<OnAfterEnteringVRObservableEvent>;
  130444. /**
  130445. * Observable raised when exiting VR.
  130446. */
  130447. onExitingVRObservable: Observable<VRExperienceHelper>;
  130448. /**
  130449. * Observable raised when controller mesh is loaded.
  130450. */
  130451. onControllerMeshLoadedObservable: Observable<WebVRController>;
  130452. /** Return this.onEnteringVRObservable
  130453. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  130454. */
  130455. get onEnteringVR(): Observable<VRExperienceHelper>;
  130456. /** Return this.onExitingVRObservable
  130457. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  130458. */
  130459. get onExitingVR(): Observable<VRExperienceHelper>;
  130460. /** Return this.onControllerMeshLoadedObservable
  130461. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  130462. */
  130463. get onControllerMeshLoaded(): Observable<WebVRController>;
  130464. private _rayLength;
  130465. private _useCustomVRButton;
  130466. private _teleportationRequested;
  130467. private _teleportActive;
  130468. private _floorMeshName;
  130469. private _floorMeshesCollection;
  130470. private _teleportationMode;
  130471. private _teleportationTime;
  130472. private _teleportationSpeed;
  130473. private _teleportationEasing;
  130474. private _rotationAllowed;
  130475. private _teleportBackwardsVector;
  130476. private _teleportationTarget;
  130477. private _isDefaultTeleportationTarget;
  130478. private _postProcessMove;
  130479. private _teleportationFillColor;
  130480. private _teleportationBorderColor;
  130481. private _rotationAngle;
  130482. private _haloCenter;
  130483. private _cameraGazer;
  130484. private _padSensibilityUp;
  130485. private _padSensibilityDown;
  130486. private _leftController;
  130487. private _rightController;
  130488. private _gazeColor;
  130489. private _laserColor;
  130490. private _pickedLaserColor;
  130491. private _pickedGazeColor;
  130492. /**
  130493. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  130494. */
  130495. onNewMeshSelected: Observable<AbstractMesh>;
  130496. /**
  130497. * Observable raised when a new mesh is selected based on meshSelectionPredicate.
  130498. * This observable will provide the mesh and the controller used to select the mesh
  130499. */
  130500. onMeshSelectedWithController: Observable<{
  130501. mesh: AbstractMesh;
  130502. controller: WebVRController;
  130503. }>;
  130504. /**
  130505. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  130506. */
  130507. onNewMeshPicked: Observable<PickingInfo>;
  130508. private _circleEase;
  130509. /**
  130510. * Observable raised before camera teleportation
  130511. */
  130512. onBeforeCameraTeleport: Observable<Vector3>;
  130513. /**
  130514. * Observable raised after camera teleportation
  130515. */
  130516. onAfterCameraTeleport: Observable<Vector3>;
  130517. /**
  130518. * Observable raised when current selected mesh gets unselected
  130519. */
  130520. onSelectedMeshUnselected: Observable<AbstractMesh>;
  130521. private _raySelectionPredicate;
  130522. /**
  130523. * To be optionaly changed by user to define custom ray selection
  130524. */
  130525. raySelectionPredicate: (mesh: AbstractMesh) => boolean;
  130526. /**
  130527. * To be optionaly changed by user to define custom selection logic (after ray selection)
  130528. */
  130529. meshSelectionPredicate: (mesh: AbstractMesh) => boolean;
  130530. /**
  130531. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  130532. */
  130533. teleportationEnabled: boolean;
  130534. private _defaultHeight;
  130535. private _teleportationInitialized;
  130536. private _interactionsEnabled;
  130537. private _interactionsRequested;
  130538. private _displayGaze;
  130539. private _displayLaserPointer;
  130540. /**
  130541. * The mesh used to display where the user is going to teleport.
  130542. */
  130543. get teleportationTarget(): Mesh;
  130544. /**
  130545. * Sets the mesh to be used to display where the user is going to teleport.
  130546. */
  130547. set teleportationTarget(value: Mesh);
  130548. /**
  130549. * 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
  130550. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  130551. * See https://doc.babylonjs.com/resources/baking_transformations
  130552. */
  130553. get gazeTrackerMesh(): Mesh;
  130554. set gazeTrackerMesh(value: Mesh);
  130555. /**
  130556. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  130557. */
  130558. updateGazeTrackerScale: boolean;
  130559. /**
  130560. * If the gaze trackers color should be updated when selecting meshes
  130561. */
  130562. updateGazeTrackerColor: boolean;
  130563. /**
  130564. * If the controller laser color should be updated when selecting meshes
  130565. */
  130566. updateControllerLaserColor: boolean;
  130567. /**
  130568. * The gaze tracking mesh corresponding to the left controller
  130569. */
  130570. get leftControllerGazeTrackerMesh(): Nullable<Mesh>;
  130571. /**
  130572. * The gaze tracking mesh corresponding to the right controller
  130573. */
  130574. get rightControllerGazeTrackerMesh(): Nullable<Mesh>;
  130575. /**
  130576. * If the ray of the gaze should be displayed.
  130577. */
  130578. get displayGaze(): boolean;
  130579. /**
  130580. * Sets if the ray of the gaze should be displayed.
  130581. */
  130582. set displayGaze(value: boolean);
  130583. /**
  130584. * If the ray of the LaserPointer should be displayed.
  130585. */
  130586. get displayLaserPointer(): boolean;
  130587. /**
  130588. * Sets if the ray of the LaserPointer should be displayed.
  130589. */
  130590. set displayLaserPointer(value: boolean);
  130591. /**
  130592. * The deviceOrientationCamera used as the camera when not in VR.
  130593. */
  130594. get deviceOrientationCamera(): Nullable<DeviceOrientationCamera>;
  130595. /**
  130596. * Based on the current WebVR support, returns the current VR camera used.
  130597. */
  130598. get currentVRCamera(): Nullable<Camera>;
  130599. /**
  130600. * The webVRCamera which is used when in VR.
  130601. */
  130602. get webVRCamera(): WebVRFreeCamera;
  130603. /**
  130604. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  130605. */
  130606. get vrDeviceOrientationCamera(): Nullable<VRDeviceOrientationFreeCamera>;
  130607. /**
  130608. * The html button that is used to trigger entering into VR.
  130609. */
  130610. get vrButton(): Nullable<HTMLButtonElement>;
  130611. private get _teleportationRequestInitiated();
  130612. /**
  130613. * Defines whether or not Pointer lock should be requested when switching to
  130614. * full screen.
  130615. */
  130616. requestPointerLockOnFullScreen: boolean;
  130617. /**
  130618. * If asking to force XR, this will be populated with the default xr experience
  130619. */
  130620. xr: WebXRDefaultExperience;
  130621. /**
  130622. * Was the XR test done already. If this is true AND this.xr exists, xr is initialized.
  130623. * If this is true and no this.xr, xr exists but is not supported, using WebVR.
  130624. */
  130625. xrTestDone: boolean;
  130626. /**
  130627. * Instantiates a VRExperienceHelper.
  130628. * Helps to quickly add VR support to an existing scene.
  130629. * @param scene The scene the VRExperienceHelper belongs to.
  130630. * @param webVROptions Options to modify the vr experience helper's behavior.
  130631. */
  130632. constructor(scene: Scene,
  130633. /** Options to modify the vr experience helper's behavior. */
  130634. webVROptions?: VRExperienceHelperOptions);
  130635. private completeVRInit;
  130636. private _onDefaultMeshLoaded;
  130637. private _onResize;
  130638. private _onFullscreenChange;
  130639. /**
  130640. * Gets a value indicating if we are currently in VR mode.
  130641. */
  130642. get isInVRMode(): boolean;
  130643. private onVrDisplayPresentChange;
  130644. private onVRDisplayChanged;
  130645. private moveButtonToBottomRight;
  130646. private displayVRButton;
  130647. private updateButtonVisibility;
  130648. private _cachedAngularSensibility;
  130649. /**
  130650. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  130651. * Otherwise, will use the fullscreen API.
  130652. */
  130653. enterVR(): void;
  130654. /**
  130655. * Attempt to exit VR, or fullscreen.
  130656. */
  130657. exitVR(): void;
  130658. /**
  130659. * The position of the vr experience helper.
  130660. */
  130661. get position(): Vector3;
  130662. /**
  130663. * Sets the position of the vr experience helper.
  130664. */
  130665. set position(value: Vector3);
  130666. /**
  130667. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  130668. */
  130669. enableInteractions(): void;
  130670. private get _noControllerIsActive();
  130671. private beforeRender;
  130672. private _isTeleportationFloor;
  130673. /**
  130674. * Adds a floor mesh to be used for teleportation.
  130675. * @param floorMesh the mesh to be used for teleportation.
  130676. */
  130677. addFloorMesh(floorMesh: Mesh): void;
  130678. /**
  130679. * Removes a floor mesh from being used for teleportation.
  130680. * @param floorMesh the mesh to be removed.
  130681. */
  130682. removeFloorMesh(floorMesh: Mesh): void;
  130683. /**
  130684. * Enables interactions and teleportation using the VR controllers and gaze.
  130685. * @param vrTeleportationOptions options to modify teleportation behavior.
  130686. */
  130687. enableTeleportation(vrTeleportationOptions?: VRTeleportationOptions): void;
  130688. private _onNewGamepadConnected;
  130689. private _tryEnableInteractionOnController;
  130690. private _onNewGamepadDisconnected;
  130691. private _enableInteractionOnController;
  130692. private _checkTeleportWithRay;
  130693. private _checkRotate;
  130694. private _checkTeleportBackwards;
  130695. private _enableTeleportationOnController;
  130696. private _createTeleportationCircles;
  130697. private _displayTeleportationTarget;
  130698. private _hideTeleportationTarget;
  130699. private _rotateCamera;
  130700. private _moveTeleportationSelectorTo;
  130701. private _workingVector;
  130702. private _workingQuaternion;
  130703. private _workingMatrix;
  130704. /**
  130705. * Time Constant Teleportation Mode
  130706. */
  130707. static readonly TELEPORTATIONMODE_CONSTANTTIME: number;
  130708. /**
  130709. * Speed Constant Teleportation Mode
  130710. */
  130711. static readonly TELEPORTATIONMODE_CONSTANTSPEED: number;
  130712. /**
  130713. * Teleports the users feet to the desired location
  130714. * @param location The location where the user's feet should be placed
  130715. */
  130716. teleportCamera(location: Vector3): void;
  130717. private _convertNormalToDirectionOfRay;
  130718. private _castRayAndSelectObject;
  130719. private _notifySelectedMeshUnselected;
  130720. /**
  130721. * Permanently set new colors for the laser pointer
  130722. * @param color the new laser color
  130723. * @param pickedColor the new laser color when picked mesh detected
  130724. */
  130725. setLaserColor(color: Color3, pickedColor?: Color3): void;
  130726. /**
  130727. * Set lighting enabled / disabled on the laser pointer of both controllers
  130728. * @param enabled should the lighting be enabled on the laser pointer
  130729. */
  130730. setLaserLightingState(enabled?: boolean): void;
  130731. /**
  130732. * Permanently set new colors for the gaze pointer
  130733. * @param color the new gaze color
  130734. * @param pickedColor the new gaze color when picked mesh detected
  130735. */
  130736. setGazeColor(color: Color3, pickedColor?: Color3): void;
  130737. /**
  130738. * Sets the color of the laser ray from the vr controllers.
  130739. * @param color new color for the ray.
  130740. */
  130741. changeLaserColor(color: Color3): void;
  130742. /**
  130743. * Sets the color of the ray from the vr headsets gaze.
  130744. * @param color new color for the ray.
  130745. */
  130746. changeGazeColor(color: Color3): void;
  130747. /**
  130748. * Exits VR and disposes of the vr experience helper
  130749. */
  130750. dispose(): void;
  130751. /**
  130752. * Gets the name of the VRExperienceHelper class
  130753. * @returns "VRExperienceHelper"
  130754. */
  130755. getClassName(): string;
  130756. }
  130757. }
  130758. declare module BABYLON {
  130759. /**
  130760. * Contains an array of blocks representing the octree
  130761. */
  130762. export interface IOctreeContainer<T> {
  130763. /**
  130764. * Blocks within the octree
  130765. */
  130766. blocks: Array<OctreeBlock<T>>;
  130767. }
  130768. /**
  130769. * Class used to store a cell in an octree
  130770. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130771. */
  130772. export class OctreeBlock<T> {
  130773. /**
  130774. * Gets the content of the current block
  130775. */
  130776. entries: T[];
  130777. /**
  130778. * Gets the list of block children
  130779. */
  130780. blocks: Array<OctreeBlock<T>>;
  130781. private _depth;
  130782. private _maxDepth;
  130783. private _capacity;
  130784. private _minPoint;
  130785. private _maxPoint;
  130786. private _boundingVectors;
  130787. private _creationFunc;
  130788. /**
  130789. * Creates a new block
  130790. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  130791. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  130792. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130793. * @param depth defines the current depth of this block in the octree
  130794. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  130795. * @param creationFunc defines a callback to call when an element is added to the block
  130796. */
  130797. constructor(minPoint: Vector3, maxPoint: Vector3, capacity: number, depth: number, maxDepth: number, creationFunc: (entry: T, block: OctreeBlock<T>) => void);
  130798. /**
  130799. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  130800. */
  130801. get capacity(): number;
  130802. /**
  130803. * Gets the minimum vector (in world space) of the block's bounding box
  130804. */
  130805. get minPoint(): Vector3;
  130806. /**
  130807. * Gets the maximum vector (in world space) of the block's bounding box
  130808. */
  130809. get maxPoint(): Vector3;
  130810. /**
  130811. * Add a new element to this block
  130812. * @param entry defines the element to add
  130813. */
  130814. addEntry(entry: T): void;
  130815. /**
  130816. * Remove an element from this block
  130817. * @param entry defines the element to remove
  130818. */
  130819. removeEntry(entry: T): void;
  130820. /**
  130821. * Add an array of elements to this block
  130822. * @param entries defines the array of elements to add
  130823. */
  130824. addEntries(entries: T[]): void;
  130825. /**
  130826. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  130827. * @param frustumPlanes defines the frustum planes to test
  130828. * @param selection defines the array to store current content if selection is positive
  130829. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130830. */
  130831. select(frustumPlanes: Plane[], selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130832. /**
  130833. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  130834. * @param sphereCenter defines the bounding sphere center
  130835. * @param sphereRadius defines the bounding sphere radius
  130836. * @param selection defines the array to store current content if selection is positive
  130837. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130838. */
  130839. intersects(sphereCenter: Vector3, sphereRadius: number, selection: SmartArrayNoDuplicate<T>, allowDuplicate?: boolean): void;
  130840. /**
  130841. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  130842. * @param ray defines the ray to test with
  130843. * @param selection defines the array to store current content if selection is positive
  130844. */
  130845. intersectsRay(ray: Ray, selection: SmartArrayNoDuplicate<T>): void;
  130846. /**
  130847. * Subdivide the content into child blocks (this block will then be empty)
  130848. */
  130849. createInnerBlocks(): void;
  130850. /**
  130851. * @hidden
  130852. */
  130853. 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;
  130854. }
  130855. }
  130856. declare module BABYLON {
  130857. /**
  130858. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  130859. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130860. */
  130861. export class Octree<T> {
  130862. /** 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.) */
  130863. maxDepth: number;
  130864. /**
  130865. * Blocks within the octree containing objects
  130866. */
  130867. blocks: Array<OctreeBlock<T>>;
  130868. /**
  130869. * Content stored in the octree
  130870. */
  130871. dynamicContent: T[];
  130872. private _maxBlockCapacity;
  130873. private _selectionContent;
  130874. private _creationFunc;
  130875. /**
  130876. * Creates a octree
  130877. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130878. * @param creationFunc function to be used to instatiate the octree
  130879. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  130880. * @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.)
  130881. */
  130882. constructor(creationFunc: (entry: T, block: OctreeBlock<T>) => void, maxBlockCapacity?: number,
  130883. /** 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.) */
  130884. maxDepth?: number);
  130885. /**
  130886. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  130887. * @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);
  130888. * @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);
  130889. * @param entries meshes to be added to the octree blocks
  130890. */
  130891. update(worldMin: Vector3, worldMax: Vector3, entries: T[]): void;
  130892. /**
  130893. * Adds a mesh to the octree
  130894. * @param entry Mesh to add to the octree
  130895. */
  130896. addMesh(entry: T): void;
  130897. /**
  130898. * Remove an element from the octree
  130899. * @param entry defines the element to remove
  130900. */
  130901. removeMesh(entry: T): void;
  130902. /**
  130903. * Selects an array of meshes within the frustum
  130904. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  130905. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  130906. * @returns array of meshes within the frustum
  130907. */
  130908. select(frustumPlanes: Plane[], allowDuplicate?: boolean): SmartArray<T>;
  130909. /**
  130910. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  130911. * @param sphereCenter defines the bounding sphere center
  130912. * @param sphereRadius defines the bounding sphere radius
  130913. * @param allowDuplicate defines if the selection array can contains duplicated entries
  130914. * @returns an array of objects that intersect the sphere
  130915. */
  130916. intersects(sphereCenter: Vector3, sphereRadius: number, allowDuplicate?: boolean): SmartArray<T>;
  130917. /**
  130918. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  130919. * @param ray defines the ray to test with
  130920. * @returns array of intersected objects
  130921. */
  130922. intersectsRay(ray: Ray): SmartArray<T>;
  130923. /**
  130924. * Adds a mesh into the octree block if it intersects the block
  130925. */
  130926. static CreationFuncForMeshes: (entry: AbstractMesh, block: OctreeBlock<AbstractMesh>) => void;
  130927. /**
  130928. * Adds a submesh into the octree block if it intersects the block
  130929. */
  130930. static CreationFuncForSubMeshes: (entry: SubMesh, block: OctreeBlock<SubMesh>) => void;
  130931. }
  130932. }
  130933. declare module BABYLON {
  130934. interface Scene {
  130935. /**
  130936. * @hidden
  130937. * Backing Filed
  130938. */
  130939. _selectionOctree: Octree<AbstractMesh>;
  130940. /**
  130941. * Gets the octree used to boost mesh selection (picking)
  130942. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130943. */
  130944. selectionOctree: Octree<AbstractMesh>;
  130945. /**
  130946. * Creates or updates the octree used to boost selection (picking)
  130947. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130948. * @param maxCapacity defines the maximum capacity per leaf
  130949. * @param maxDepth defines the maximum depth of the octree
  130950. * @returns an octree of AbstractMesh
  130951. */
  130952. createOrUpdateSelectionOctree(maxCapacity?: number, maxDepth?: number): Octree<AbstractMesh>;
  130953. }
  130954. interface AbstractMesh {
  130955. /**
  130956. * @hidden
  130957. * Backing Field
  130958. */
  130959. _submeshesOctree: Octree<SubMesh>;
  130960. /**
  130961. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  130962. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  130963. * @param maxCapacity defines the maximum size of each block (64 by default)
  130964. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  130965. * @returns the new octree
  130966. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  130967. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  130968. */
  130969. createOrUpdateSubmeshesOctree(maxCapacity?: number, maxDepth?: number): Octree<SubMesh>;
  130970. }
  130971. /**
  130972. * Defines the octree scene component responsible to manage any octrees
  130973. * in a given scene.
  130974. */
  130975. export class OctreeSceneComponent {
  130976. /**
  130977. * The component name help to identify the component in the list of scene components.
  130978. */
  130979. readonly name: string;
  130980. /**
  130981. * The scene the component belongs to.
  130982. */
  130983. scene: Scene;
  130984. /**
  130985. * Indicates if the meshes have been checked to make sure they are isEnabled()
  130986. */
  130987. readonly checksIsEnabled: boolean;
  130988. /**
  130989. * Creates a new instance of the component for the given scene
  130990. * @param scene Defines the scene to register the component in
  130991. */
  130992. constructor(scene: Scene);
  130993. /**
  130994. * Registers the component in a given scene
  130995. */
  130996. register(): void;
  130997. /**
  130998. * Return the list of active meshes
  130999. * @returns the list of active meshes
  131000. */
  131001. getActiveMeshCandidates(): ISmartArrayLike<AbstractMesh>;
  131002. /**
  131003. * Return the list of active sub meshes
  131004. * @param mesh The mesh to get the candidates sub meshes from
  131005. * @returns the list of active sub meshes
  131006. */
  131007. getActiveSubMeshCandidates(mesh: AbstractMesh): ISmartArrayLike<SubMesh>;
  131008. private _tempRay;
  131009. /**
  131010. * Return the list of sub meshes intersecting with a given local ray
  131011. * @param mesh defines the mesh to find the submesh for
  131012. * @param localRay defines the ray in local space
  131013. * @returns the list of intersecting sub meshes
  131014. */
  131015. getIntersectingSubMeshCandidates(mesh: AbstractMesh, localRay: Ray): ISmartArrayLike<SubMesh>;
  131016. /**
  131017. * Return the list of sub meshes colliding with a collider
  131018. * @param mesh defines the mesh to find the submesh for
  131019. * @param collider defines the collider to evaluate the collision against
  131020. * @returns the list of colliding sub meshes
  131021. */
  131022. getCollidingSubMeshCandidates(mesh: AbstractMesh, collider: Collider): ISmartArrayLike<SubMesh>;
  131023. /**
  131024. * Rebuilds the elements related to this component in case of
  131025. * context lost for instance.
  131026. */
  131027. rebuild(): void;
  131028. /**
  131029. * Disposes the component and the associated ressources.
  131030. */
  131031. dispose(): void;
  131032. }
  131033. }
  131034. declare module BABYLON {
  131035. /**
  131036. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  131037. */
  131038. export class Gizmo implements IDisposable {
  131039. /** The utility layer the gizmo will be added to */
  131040. gizmoLayer: UtilityLayerRenderer;
  131041. /**
  131042. * The root mesh of the gizmo
  131043. */
  131044. _rootMesh: Mesh;
  131045. private _attachedMesh;
  131046. private _attachedNode;
  131047. /**
  131048. * Ratio for the scale of the gizmo (Default: 1)
  131049. */
  131050. protected _scaleRatio: number;
  131051. /**
  131052. * boolean updated by pointermove when a gizmo mesh is hovered
  131053. */
  131054. protected _isHovered: boolean;
  131055. /**
  131056. * Ratio for the scale of the gizmo (Default: 1)
  131057. */
  131058. set scaleRatio(value: number);
  131059. get scaleRatio(): number;
  131060. /**
  131061. * True when the mouse pointer is hovered a gizmo mesh
  131062. */
  131063. get isHovered(): boolean;
  131064. /**
  131065. * If a custom mesh has been set (Default: false)
  131066. */
  131067. protected _customMeshSet: boolean;
  131068. /**
  131069. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  131070. * * When set, interactions will be enabled
  131071. */
  131072. get attachedMesh(): Nullable<AbstractMesh>;
  131073. set attachedMesh(value: Nullable<AbstractMesh>);
  131074. /**
  131075. * Node that the gizmo will be attached to. (eg. on a drag gizmo the mesh, bone or NodeTransform that will be dragged)
  131076. * * When set, interactions will be enabled
  131077. */
  131078. get attachedNode(): Nullable<Node>;
  131079. set attachedNode(value: Nullable<Node>);
  131080. /**
  131081. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  131082. * @param mesh The mesh to replace the default mesh of the gizmo
  131083. */
  131084. setCustomMesh(mesh: Mesh): void;
  131085. protected _updateGizmoRotationToMatchAttachedMesh: boolean;
  131086. /**
  131087. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  131088. */
  131089. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131090. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131091. /**
  131092. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  131093. */
  131094. updateGizmoPositionToMatchAttachedMesh: boolean;
  131095. /**
  131096. * When set, the gizmo will always appear the same size no matter where the camera is (default: true)
  131097. */
  131098. updateScale: boolean;
  131099. protected _interactionsEnabled: boolean;
  131100. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131101. private _beforeRenderObserver;
  131102. private _tempQuaternion;
  131103. private _tempVector;
  131104. private _tempVector2;
  131105. private _tempMatrix1;
  131106. private _tempMatrix2;
  131107. private _rightHandtoLeftHandMatrix;
  131108. /**
  131109. * Creates a gizmo
  131110. * @param gizmoLayer The utility layer the gizmo will be added to
  131111. */
  131112. constructor(
  131113. /** The utility layer the gizmo will be added to */
  131114. gizmoLayer?: UtilityLayerRenderer);
  131115. /**
  131116. * Updates the gizmo to match the attached mesh's position/rotation
  131117. */
  131118. protected _update(): void;
  131119. /**
  131120. * computes the rotation/scaling/position of the transform once the Node world matrix has changed.
  131121. * @param value Node, TransformNode or mesh
  131122. */
  131123. protected _matrixChanged(): void;
  131124. /**
  131125. * Disposes of the gizmo
  131126. */
  131127. dispose(): void;
  131128. }
  131129. }
  131130. declare module BABYLON {
  131131. /**
  131132. * Single plane drag gizmo
  131133. */
  131134. export class PlaneDragGizmo extends Gizmo {
  131135. /**
  131136. * Drag behavior responsible for the gizmos dragging interactions
  131137. */
  131138. dragBehavior: PointerDragBehavior;
  131139. private _pointerObserver;
  131140. /**
  131141. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131142. */
  131143. snapDistance: number;
  131144. /**
  131145. * Event that fires each time the gizmo snaps to a new location.
  131146. * * snapDistance is the the change in distance
  131147. */
  131148. onSnapObservable: Observable<{
  131149. snapDistance: number;
  131150. }>;
  131151. private _plane;
  131152. private _coloredMaterial;
  131153. private _hoverMaterial;
  131154. private _isEnabled;
  131155. private _parent;
  131156. /** @hidden */
  131157. static _CreatePlane(scene: Scene, material: StandardMaterial): TransformNode;
  131158. /** @hidden */
  131159. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131160. /**
  131161. * Creates a PlaneDragGizmo
  131162. * @param gizmoLayer The utility layer the gizmo will be added to
  131163. * @param dragPlaneNormal The axis normal to which the gizmo will be able to drag on
  131164. * @param color The color of the gizmo
  131165. */
  131166. constructor(dragPlaneNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>);
  131167. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131168. /**
  131169. * If the gizmo is enabled
  131170. */
  131171. set isEnabled(value: boolean);
  131172. get isEnabled(): boolean;
  131173. /**
  131174. * Disposes of the gizmo
  131175. */
  131176. dispose(): void;
  131177. }
  131178. }
  131179. declare module BABYLON {
  131180. /**
  131181. * Gizmo that enables dragging a mesh along 3 axis
  131182. */
  131183. export class PositionGizmo extends Gizmo {
  131184. /**
  131185. * Internal gizmo used for interactions on the x axis
  131186. */
  131187. xGizmo: AxisDragGizmo;
  131188. /**
  131189. * Internal gizmo used for interactions on the y axis
  131190. */
  131191. yGizmo: AxisDragGizmo;
  131192. /**
  131193. * Internal gizmo used for interactions on the z axis
  131194. */
  131195. zGizmo: AxisDragGizmo;
  131196. /**
  131197. * Internal gizmo used for interactions on the yz plane
  131198. */
  131199. xPlaneGizmo: PlaneDragGizmo;
  131200. /**
  131201. * Internal gizmo used for interactions on the xz plane
  131202. */
  131203. yPlaneGizmo: PlaneDragGizmo;
  131204. /**
  131205. * Internal gizmo used for interactions on the xy plane
  131206. */
  131207. zPlaneGizmo: PlaneDragGizmo;
  131208. /**
  131209. * private variables
  131210. */
  131211. private _meshAttached;
  131212. private _nodeAttached;
  131213. private _snapDistance;
  131214. /** Fires an event when any of it's sub gizmos are dragged */
  131215. onDragStartObservable: Observable<unknown>;
  131216. /** Fires an event when any of it's sub gizmos are released from dragging */
  131217. onDragEndObservable: Observable<unknown>;
  131218. /**
  131219. * If set to true, planar drag is enabled
  131220. */
  131221. private _planarGizmoEnabled;
  131222. get attachedMesh(): Nullable<AbstractMesh>;
  131223. set attachedMesh(mesh: Nullable<AbstractMesh>);
  131224. get attachedNode(): Nullable<Node>;
  131225. set attachedNode(node: Nullable<Node>);
  131226. /**
  131227. * True when the mouse pointer is hovering a gizmo mesh
  131228. */
  131229. get isHovered(): boolean;
  131230. /**
  131231. * Creates a PositionGizmo
  131232. * @param gizmoLayer The utility layer the gizmo will be added to
  131233. @param thickness display gizmo axis thickness
  131234. */
  131235. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  131236. /**
  131237. * If the planar drag gizmo is enabled
  131238. * setting this will enable/disable XY, XZ and YZ planes regardless of individual gizmo settings.
  131239. */
  131240. set planarGizmoEnabled(value: boolean);
  131241. get planarGizmoEnabled(): boolean;
  131242. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  131243. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  131244. /**
  131245. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131246. */
  131247. set snapDistance(value: number);
  131248. get snapDistance(): number;
  131249. /**
  131250. * Ratio for the scale of the gizmo (Default: 1)
  131251. */
  131252. set scaleRatio(value: number);
  131253. get scaleRatio(): number;
  131254. /**
  131255. * Disposes of the gizmo
  131256. */
  131257. dispose(): void;
  131258. /**
  131259. * CustomMeshes are not supported by this gizmo
  131260. * @param mesh The mesh to replace the default mesh of the gizmo
  131261. */
  131262. setCustomMesh(mesh: Mesh): void;
  131263. }
  131264. }
  131265. declare module BABYLON {
  131266. /**
  131267. * Single axis drag gizmo
  131268. */
  131269. export class AxisDragGizmo extends Gizmo {
  131270. /**
  131271. * Drag behavior responsible for the gizmos dragging interactions
  131272. */
  131273. dragBehavior: PointerDragBehavior;
  131274. private _pointerObserver;
  131275. /**
  131276. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  131277. */
  131278. snapDistance: number;
  131279. /**
  131280. * Event that fires each time the gizmo snaps to a new location.
  131281. * * snapDistance is the the change in distance
  131282. */
  131283. onSnapObservable: Observable<{
  131284. snapDistance: number;
  131285. }>;
  131286. private _isEnabled;
  131287. private _parent;
  131288. private _arrow;
  131289. private _coloredMaterial;
  131290. private _hoverMaterial;
  131291. /** @hidden */
  131292. static _CreateArrow(scene: Scene, material: StandardMaterial, thickness?: number): TransformNode;
  131293. /** @hidden */
  131294. static _CreateArrowInstance(scene: Scene, arrow: TransformNode): TransformNode;
  131295. /**
  131296. * Creates an AxisDragGizmo
  131297. * @param gizmoLayer The utility layer the gizmo will be added to
  131298. * @param dragAxis The axis which the gizmo will be able to drag on
  131299. * @param color The color of the gizmo
  131300. * @param thickness display gizmo axis thickness
  131301. */
  131302. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<PositionGizmo>, thickness?: number);
  131303. protected _attachedNodeChanged(value: Nullable<Node>): void;
  131304. /**
  131305. * If the gizmo is enabled
  131306. */
  131307. set isEnabled(value: boolean);
  131308. get isEnabled(): boolean;
  131309. /**
  131310. * Disposes of the gizmo
  131311. */
  131312. dispose(): void;
  131313. }
  131314. }
  131315. declare module BABYLON.Debug {
  131316. /**
  131317. * The Axes viewer will show 3 axes in a specific point in space
  131318. */
  131319. export class AxesViewer {
  131320. private _xAxis;
  131321. private _yAxis;
  131322. private _zAxis;
  131323. private _scaleLinesFactor;
  131324. private _instanced;
  131325. /**
  131326. * Gets the hosting scene
  131327. */
  131328. scene: Nullable<Scene>;
  131329. /**
  131330. * Gets or sets a number used to scale line length
  131331. */
  131332. scaleLines: number;
  131333. /** Gets the node hierarchy used to render x-axis */
  131334. get xAxis(): TransformNode;
  131335. /** Gets the node hierarchy used to render y-axis */
  131336. get yAxis(): TransformNode;
  131337. /** Gets the node hierarchy used to render z-axis */
  131338. get zAxis(): TransformNode;
  131339. /**
  131340. * Creates a new AxesViewer
  131341. * @param scene defines the hosting scene
  131342. * @param scaleLines defines a number used to scale line length (1 by default)
  131343. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  131344. * @param xAxis defines the node hierarchy used to render the x-axis
  131345. * @param yAxis defines the node hierarchy used to render the y-axis
  131346. * @param zAxis defines the node hierarchy used to render the z-axis
  131347. */
  131348. constructor(scene: Scene, scaleLines?: number, renderingGroupId?: Nullable<number>, xAxis?: TransformNode, yAxis?: TransformNode, zAxis?: TransformNode);
  131349. /**
  131350. * Force the viewer to update
  131351. * @param position defines the position of the viewer
  131352. * @param xaxis defines the x axis of the viewer
  131353. * @param yaxis defines the y axis of the viewer
  131354. * @param zaxis defines the z axis of the viewer
  131355. */
  131356. update(position: Vector3, xaxis: Vector3, yaxis: Vector3, zaxis: Vector3): void;
  131357. /**
  131358. * Creates an instance of this axes viewer.
  131359. * @returns a new axes viewer with instanced meshes
  131360. */
  131361. createInstance(): AxesViewer;
  131362. /** Releases resources */
  131363. dispose(): void;
  131364. private static _SetRenderingGroupId;
  131365. }
  131366. }
  131367. declare module BABYLON.Debug {
  131368. /**
  131369. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  131370. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  131371. */
  131372. export class BoneAxesViewer extends AxesViewer {
  131373. /**
  131374. * Gets or sets the target mesh where to display the axes viewer
  131375. */
  131376. mesh: Nullable<Mesh>;
  131377. /**
  131378. * Gets or sets the target bone where to display the axes viewer
  131379. */
  131380. bone: Nullable<Bone>;
  131381. /** Gets current position */
  131382. pos: Vector3;
  131383. /** Gets direction of X axis */
  131384. xaxis: Vector3;
  131385. /** Gets direction of Y axis */
  131386. yaxis: Vector3;
  131387. /** Gets direction of Z axis */
  131388. zaxis: Vector3;
  131389. /**
  131390. * Creates a new BoneAxesViewer
  131391. * @param scene defines the hosting scene
  131392. * @param bone defines the target bone
  131393. * @param mesh defines the target mesh
  131394. * @param scaleLines defines a scaling factor for line length (1 by default)
  131395. */
  131396. constructor(scene: Scene, bone: Bone, mesh: Mesh, scaleLines?: number);
  131397. /**
  131398. * Force the viewer to update
  131399. */
  131400. update(): void;
  131401. /** Releases resources */
  131402. dispose(): void;
  131403. }
  131404. }
  131405. declare module BABYLON {
  131406. /**
  131407. * Interface used to define scene explorer extensibility option
  131408. */
  131409. export interface IExplorerExtensibilityOption {
  131410. /**
  131411. * Define the option label
  131412. */
  131413. label: string;
  131414. /**
  131415. * Defines the action to execute on click
  131416. */
  131417. action: (entity: any) => void;
  131418. }
  131419. /**
  131420. * Defines a group of actions associated with a predicate to use when extending the Inspector scene explorer
  131421. */
  131422. export interface IExplorerExtensibilityGroup {
  131423. /**
  131424. * Defines a predicate to test if a given type mut be extended
  131425. */
  131426. predicate: (entity: any) => boolean;
  131427. /**
  131428. * Gets the list of options added to a type
  131429. */
  131430. entries: IExplorerExtensibilityOption[];
  131431. }
  131432. /**
  131433. * Interface used to define the options to use to create the Inspector
  131434. */
  131435. export interface IInspectorOptions {
  131436. /**
  131437. * Display in overlay mode (default: false)
  131438. */
  131439. overlay?: boolean;
  131440. /**
  131441. * HTML element to use as root (the parent of the rendering canvas will be used as default value)
  131442. */
  131443. globalRoot?: HTMLElement;
  131444. /**
  131445. * Display the Scene explorer
  131446. */
  131447. showExplorer?: boolean;
  131448. /**
  131449. * Display the property inspector
  131450. */
  131451. showInspector?: boolean;
  131452. /**
  131453. * Display in embed mode (both panes on the right)
  131454. */
  131455. embedMode?: boolean;
  131456. /**
  131457. * let the Inspector handles resize of the canvas when panes are resized (default to true)
  131458. */
  131459. handleResize?: boolean;
  131460. /**
  131461. * Allow the panes to popup (default: true)
  131462. */
  131463. enablePopup?: boolean;
  131464. /**
  131465. * Allow the panes to be closed by users (default: true)
  131466. */
  131467. enableClose?: boolean;
  131468. /**
  131469. * Optional list of extensibility entries
  131470. */
  131471. explorerExtensibility?: IExplorerExtensibilityGroup[];
  131472. /**
  131473. * Optional URL to get the inspector script from (by default it uses the babylonjs CDN).
  131474. */
  131475. inspectorURL?: string;
  131476. /**
  131477. * Optional initial tab (default to DebugLayerTab.Properties)
  131478. */
  131479. initialTab?: DebugLayerTab;
  131480. }
  131481. interface Scene {
  131482. /**
  131483. * @hidden
  131484. * Backing field
  131485. */
  131486. _debugLayer: DebugLayer;
  131487. /**
  131488. * Gets the debug layer (aka Inspector) associated with the scene
  131489. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131490. */
  131491. debugLayer: DebugLayer;
  131492. }
  131493. /**
  131494. * Enum of inspector action tab
  131495. */
  131496. export enum DebugLayerTab {
  131497. /**
  131498. * Properties tag (default)
  131499. */
  131500. Properties = 0,
  131501. /**
  131502. * Debug tab
  131503. */
  131504. Debug = 1,
  131505. /**
  131506. * Statistics tab
  131507. */
  131508. Statistics = 2,
  131509. /**
  131510. * Tools tab
  131511. */
  131512. Tools = 3,
  131513. /**
  131514. * Settings tab
  131515. */
  131516. Settings = 4
  131517. }
  131518. /**
  131519. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131520. * what is happening in your scene
  131521. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131522. */
  131523. export class DebugLayer {
  131524. /**
  131525. * Define the url to get the inspector script from.
  131526. * By default it uses the babylonjs CDN.
  131527. * @ignoreNaming
  131528. */
  131529. static InspectorURL: string;
  131530. private _scene;
  131531. private BJSINSPECTOR;
  131532. private _onPropertyChangedObservable?;
  131533. /**
  131534. * Observable triggered when a property is changed through the inspector.
  131535. */
  131536. get onPropertyChangedObservable(): any;
  131537. /**
  131538. * Instantiates a new debug layer.
  131539. * The debug layer (aka Inspector) is the go to tool in order to better understand
  131540. * what is happening in your scene
  131541. * @see https://doc.babylonjs.com/features/playground_debuglayer
  131542. * @param scene Defines the scene to inspect
  131543. */
  131544. constructor(scene: Scene);
  131545. /** Creates the inspector window. */
  131546. private _createInspector;
  131547. /**
  131548. * Select a specific entity in the scene explorer and highlight a specific block in that entity property grid
  131549. * @param entity defines the entity to select
  131550. * @param lineContainerTitles defines the specific blocks to highlight (could be a string or an array of strings)
  131551. */
  131552. select(entity: any, lineContainerTitles?: string | string[]): void;
  131553. /** Get the inspector from bundle or global */
  131554. private _getGlobalInspector;
  131555. /**
  131556. * Get if the inspector is visible or not.
  131557. * @returns true if visible otherwise, false
  131558. */
  131559. isVisible(): boolean;
  131560. /**
  131561. * Hide the inspector and close its window.
  131562. */
  131563. hide(): void;
  131564. /**
  131565. * Update the scene in the inspector
  131566. */
  131567. setAsActiveScene(): void;
  131568. /**
  131569. * Launch the debugLayer.
  131570. * @param config Define the configuration of the inspector
  131571. * @return a promise fulfilled when the debug layer is visible
  131572. */
  131573. show(config?: IInspectorOptions): Promise<DebugLayer>;
  131574. }
  131575. }
  131576. declare module BABYLON {
  131577. /**
  131578. * Class containing static functions to help procedurally build meshes
  131579. */
  131580. export class BoxBuilder {
  131581. /**
  131582. * Creates a box mesh
  131583. * * The parameter `size` sets the size (float) of each box side (default 1)
  131584. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  131585. * * 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)
  131586. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  131587. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131588. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131589. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131590. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  131591. * @param name defines the name of the mesh
  131592. * @param options defines the options used to create the mesh
  131593. * @param scene defines the hosting scene
  131594. * @returns the box mesh
  131595. */
  131596. static CreateBox(name: string, options: {
  131597. size?: number;
  131598. width?: number;
  131599. height?: number;
  131600. depth?: number;
  131601. faceUV?: Vector4[];
  131602. faceColors?: Color4[];
  131603. sideOrientation?: number;
  131604. frontUVs?: Vector4;
  131605. backUVs?: Vector4;
  131606. wrap?: boolean;
  131607. topBaseAt?: number;
  131608. bottomBaseAt?: number;
  131609. updatable?: boolean;
  131610. }, scene?: Nullable<Scene>): Mesh;
  131611. }
  131612. }
  131613. declare module BABYLON.Debug {
  131614. /**
  131615. * Used to show the physics impostor around the specific mesh
  131616. */
  131617. export class PhysicsViewer {
  131618. /** @hidden */
  131619. protected _impostors: Array<Nullable<PhysicsImpostor>>;
  131620. /** @hidden */
  131621. protected _meshes: Array<Nullable<AbstractMesh>>;
  131622. /** @hidden */
  131623. protected _scene: Nullable<Scene>;
  131624. /** @hidden */
  131625. protected _numMeshes: number;
  131626. /** @hidden */
  131627. protected _physicsEnginePlugin: Nullable<IPhysicsEnginePlugin>;
  131628. private _renderFunction;
  131629. private _utilityLayer;
  131630. private _debugBoxMesh;
  131631. private _debugSphereMesh;
  131632. private _debugCylinderMesh;
  131633. private _debugMaterial;
  131634. private _debugMeshMeshes;
  131635. /**
  131636. * Creates a new PhysicsViewer
  131637. * @param scene defines the hosting scene
  131638. */
  131639. constructor(scene: Scene);
  131640. /** @hidden */
  131641. protected _updateDebugMeshes(): void;
  131642. /**
  131643. * Renders a specified physic impostor
  131644. * @param impostor defines the impostor to render
  131645. * @param targetMesh defines the mesh represented by the impostor
  131646. * @returns the new debug mesh used to render the impostor
  131647. */
  131648. showImpostor(impostor: PhysicsImpostor, targetMesh?: Mesh): Nullable<AbstractMesh>;
  131649. /**
  131650. * Hides a specified physic impostor
  131651. * @param impostor defines the impostor to hide
  131652. */
  131653. hideImpostor(impostor: Nullable<PhysicsImpostor>): void;
  131654. private _getDebugMaterial;
  131655. private _getDebugBoxMesh;
  131656. private _getDebugSphereMesh;
  131657. private _getDebugCylinderMesh;
  131658. private _getDebugMeshMesh;
  131659. private _getDebugMesh;
  131660. /** Releases all resources */
  131661. dispose(): void;
  131662. }
  131663. }
  131664. declare module BABYLON {
  131665. /**
  131666. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131667. * in order to better appreciate the issue one might have.
  131668. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131669. */
  131670. export class RayHelper {
  131671. /**
  131672. * Defines the ray we are currently tryin to visualize.
  131673. */
  131674. ray: Nullable<Ray>;
  131675. private _renderPoints;
  131676. private _renderLine;
  131677. private _renderFunction;
  131678. private _scene;
  131679. private _onAfterRenderObserver;
  131680. private _onAfterStepObserver;
  131681. private _attachedToMesh;
  131682. private _meshSpaceDirection;
  131683. private _meshSpaceOrigin;
  131684. /**
  131685. * Helper function to create a colored helper in a scene in one line.
  131686. * @param ray Defines the ray we are currently tryin to visualize
  131687. * @param scene Defines the scene the ray is used in
  131688. * @param color Defines the color we want to see the ray in
  131689. * @returns The newly created ray helper.
  131690. */
  131691. static CreateAndShow(ray: Ray, scene: Scene, color: Color3): RayHelper;
  131692. /**
  131693. * Instantiate a new ray helper.
  131694. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  131695. * in order to better appreciate the issue one might have.
  131696. * @see https://doc.babylonjs.com/babylon101/raycasts#debugging
  131697. * @param ray Defines the ray we are currently tryin to visualize
  131698. */
  131699. constructor(ray: Ray);
  131700. /**
  131701. * Shows the ray we are willing to debug.
  131702. * @param scene Defines the scene the ray needs to be rendered in
  131703. * @param color Defines the color the ray needs to be rendered in
  131704. */
  131705. show(scene: Scene, color?: Color3): void;
  131706. /**
  131707. * Hides the ray we are debugging.
  131708. */
  131709. hide(): void;
  131710. private _render;
  131711. /**
  131712. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  131713. * @param mesh Defines the mesh we want the helper attached to
  131714. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  131715. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  131716. * @param length Defines the length of the ray
  131717. */
  131718. attachToMesh(mesh: AbstractMesh, meshSpaceDirection?: Vector3, meshSpaceOrigin?: Vector3, length?: number): void;
  131719. /**
  131720. * Detach the ray helper from the mesh it has previously been attached to.
  131721. */
  131722. detachFromMesh(): void;
  131723. private _updateToMesh;
  131724. /**
  131725. * Dispose the helper and release its associated resources.
  131726. */
  131727. dispose(): void;
  131728. }
  131729. }
  131730. declare module BABYLON {
  131731. /**
  131732. * Defines the options associated with the creation of a SkeletonViewer.
  131733. */
  131734. export interface ISkeletonViewerOptions {
  131735. /** Should the system pause animations before building the Viewer? */
  131736. pauseAnimations: boolean;
  131737. /** Should the system return the skeleton to rest before building? */
  131738. returnToRest: boolean;
  131739. /** public Display Mode of the Viewer */
  131740. displayMode: number;
  131741. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131742. displayOptions: ISkeletonViewerDisplayOptions;
  131743. /** Flag to toggle if the Viewer should use the CPU for animations or not? */
  131744. computeBonesUsingShaders: boolean;
  131745. /** Flag ignore non weighted bones */
  131746. useAllBones: boolean;
  131747. }
  131748. /**
  131749. * Defines how to display the various bone meshes for the viewer.
  131750. */
  131751. export interface ISkeletonViewerDisplayOptions {
  131752. /** How far down to start tapering the bone spurs */
  131753. midStep?: number;
  131754. /** How big is the midStep? */
  131755. midStepFactor?: number;
  131756. /** Base for the Sphere Size */
  131757. sphereBaseSize?: number;
  131758. /** The ratio of the sphere to the longest bone in units */
  131759. sphereScaleUnit?: number;
  131760. /** Ratio for the Sphere Size */
  131761. sphereFactor?: number;
  131762. /** Whether a spur should attach its far end to the child bone position */
  131763. spurFollowsChild?: boolean;
  131764. /** Whether to show local axes or not */
  131765. showLocalAxes?: boolean;
  131766. /** Length of each local axis */
  131767. localAxesSize?: number;
  131768. }
  131769. /**
  131770. * Defines the constructor options for the BoneWeight Shader.
  131771. */
  131772. export interface IBoneWeightShaderOptions {
  131773. /** Skeleton to Map */
  131774. skeleton: Skeleton;
  131775. /** Colors for Uninfluenced bones */
  131776. colorBase?: Color3;
  131777. /** Colors for 0.0-0.25 Weight bones */
  131778. colorZero?: Color3;
  131779. /** Color for 0.25-0.5 Weight Influence */
  131780. colorQuarter?: Color3;
  131781. /** Color for 0.5-0.75 Weight Influence */
  131782. colorHalf?: Color3;
  131783. /** Color for 0.75-1 Weight Influence */
  131784. colorFull?: Color3;
  131785. /** Color for Zero Weight Influence */
  131786. targetBoneIndex?: number;
  131787. }
  131788. /**
  131789. * Simple structure of the gradient steps for the Color Map.
  131790. */
  131791. export interface ISkeletonMapShaderColorMapKnot {
  131792. /** Color of the Knot */
  131793. color: Color3;
  131794. /** Location of the Knot */
  131795. location: number;
  131796. }
  131797. /**
  131798. * Defines the constructor options for the SkeletonMap Shader.
  131799. */
  131800. export interface ISkeletonMapShaderOptions {
  131801. /** Skeleton to Map */
  131802. skeleton: Skeleton;
  131803. /** Array of ColorMapKnots that make the gradient must be ordered with knot[i].location < knot[i+1].location*/
  131804. colorMap?: ISkeletonMapShaderColorMapKnot[];
  131805. }
  131806. }
  131807. declare module BABYLON {
  131808. /**
  131809. * Class containing static functions to help procedurally build meshes
  131810. */
  131811. export class RibbonBuilder {
  131812. /**
  131813. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  131814. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  131815. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  131816. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  131817. * * 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
  131818. * * 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
  131819. * * 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
  131820. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131821. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131822. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131823. * * 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
  131824. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  131825. * * 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
  131826. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  131827. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131828. * @param name defines the name of the mesh
  131829. * @param options defines the options used to create the mesh
  131830. * @param scene defines the hosting scene
  131831. * @returns the ribbon mesh
  131832. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  131833. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131834. */
  131835. static CreateRibbon(name: string, options: {
  131836. pathArray: Vector3[][];
  131837. closeArray?: boolean;
  131838. closePath?: boolean;
  131839. offset?: number;
  131840. updatable?: boolean;
  131841. sideOrientation?: number;
  131842. frontUVs?: Vector4;
  131843. backUVs?: Vector4;
  131844. instance?: Mesh;
  131845. invertUV?: boolean;
  131846. uvs?: Vector2[];
  131847. colors?: Color4[];
  131848. }, scene?: Nullable<Scene>): Mesh;
  131849. }
  131850. }
  131851. declare module BABYLON {
  131852. /**
  131853. * Class containing static functions to help procedurally build meshes
  131854. */
  131855. export class ShapeBuilder {
  131856. /**
  131857. * 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.
  131858. * * 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.
  131859. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131860. * * 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.
  131861. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  131862. * * 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
  131863. * * 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
  131864. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  131865. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131866. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131867. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  131868. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  131869. * @param name defines the name of the mesh
  131870. * @param options defines the options used to create the mesh
  131871. * @param scene defines the hosting scene
  131872. * @returns the extruded shape mesh
  131873. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131874. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131875. */
  131876. static ExtrudeShape(name: string, options: {
  131877. shape: Vector3[];
  131878. path: Vector3[];
  131879. scale?: number;
  131880. rotation?: number;
  131881. cap?: number;
  131882. updatable?: boolean;
  131883. sideOrientation?: number;
  131884. frontUVs?: Vector4;
  131885. backUVs?: Vector4;
  131886. instance?: Mesh;
  131887. invertUV?: boolean;
  131888. }, scene?: Nullable<Scene>): Mesh;
  131889. /**
  131890. * Creates an custom extruded shape mesh.
  131891. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  131892. * * 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.
  131893. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  131894. * * 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
  131895. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  131896. * * 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
  131897. * * It must returns a float value that will be the scale value applied to the shape on each path point
  131898. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  131899. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  131900. * * 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
  131901. * * 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
  131902. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  131903. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  131904. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  131905. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  131906. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  131907. * @param name defines the name of the mesh
  131908. * @param options defines the options used to create the mesh
  131909. * @param scene defines the hosting scene
  131910. * @returns the custom extruded shape mesh
  131911. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  131912. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  131913. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  131914. */
  131915. static ExtrudeShapeCustom(name: string, options: {
  131916. shape: Vector3[];
  131917. path: Vector3[];
  131918. scaleFunction?: any;
  131919. rotationFunction?: any;
  131920. ribbonCloseArray?: boolean;
  131921. ribbonClosePath?: boolean;
  131922. cap?: number;
  131923. updatable?: boolean;
  131924. sideOrientation?: number;
  131925. frontUVs?: Vector4;
  131926. backUVs?: Vector4;
  131927. instance?: Mesh;
  131928. invertUV?: boolean;
  131929. }, scene?: Nullable<Scene>): Mesh;
  131930. private static _ExtrudeShapeGeneric;
  131931. }
  131932. }
  131933. declare module BABYLON.Debug {
  131934. /**
  131935. * Class used to render a debug view of a given skeleton
  131936. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  131937. */
  131938. export class SkeletonViewer {
  131939. /** defines the skeleton to render */
  131940. skeleton: Skeleton;
  131941. /** defines the mesh attached to the skeleton */
  131942. mesh: AbstractMesh;
  131943. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  131944. autoUpdateBonesMatrices: boolean;
  131945. /** defines the rendering group id to use with the viewer */
  131946. renderingGroupId: number;
  131947. /** is the options for the viewer */
  131948. options: Partial<ISkeletonViewerOptions>;
  131949. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_LINES */
  131950. static readonly DISPLAY_LINES: number;
  131951. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERES */
  131952. static readonly DISPLAY_SPHERES: number;
  131953. /** public Display constants BABYLON.SkeletonViewer.DISPLAY_SPHERE_AND_SPURS */
  131954. static readonly DISPLAY_SPHERE_AND_SPURS: number;
  131955. /** public static method to create a BoneWeight Shader
  131956. * @param options The constructor options
  131957. * @param scene The scene that the shader is scoped to
  131958. * @returns The created ShaderMaterial
  131959. * @see http://www.babylonjs-playground.com/#1BZJVJ#395
  131960. */
  131961. static CreateBoneWeightShader(options: IBoneWeightShaderOptions, scene: Scene): ShaderMaterial;
  131962. /** public static method to create a BoneWeight Shader
  131963. * @param options The constructor options
  131964. * @param scene The scene that the shader is scoped to
  131965. * @returns The created ShaderMaterial
  131966. */
  131967. static CreateSkeletonMapShader(options: ISkeletonMapShaderOptions, scene: Scene): ShaderMaterial;
  131968. /** private static method to create a BoneWeight Shader
  131969. * @param size The size of the buffer to create (usually the bone count)
  131970. * @param colorMap The gradient data to generate
  131971. * @param scene The scene that the shader is scoped to
  131972. * @returns an Array of floats from the color gradient values
  131973. */
  131974. private static _CreateBoneMapColorBuffer;
  131975. /** If SkeletonViewer scene scope. */
  131976. private _scene;
  131977. /** Gets or sets the color used to render the skeleton */
  131978. color: Color3;
  131979. /** Array of the points of the skeleton fo the line view. */
  131980. private _debugLines;
  131981. /** The SkeletonViewers Mesh. */
  131982. private _debugMesh;
  131983. /** The local axes Meshes. */
  131984. private _localAxes;
  131985. /** If SkeletonViewer is enabled. */
  131986. private _isEnabled;
  131987. /** If SkeletonViewer is ready. */
  131988. private _ready;
  131989. /** SkeletonViewer render observable. */
  131990. private _obs;
  131991. /** The Utility Layer to render the gizmos in. */
  131992. private _utilityLayer;
  131993. private _boneIndices;
  131994. /** Gets the Scene. */
  131995. get scene(): Scene;
  131996. /** Gets the utilityLayer. */
  131997. get utilityLayer(): Nullable<UtilityLayerRenderer>;
  131998. /** Checks Ready Status. */
  131999. get isReady(): Boolean;
  132000. /** Sets Ready Status. */
  132001. set ready(value: boolean);
  132002. /** Gets the debugMesh */
  132003. get debugMesh(): Nullable<AbstractMesh> | Nullable<LinesMesh>;
  132004. /** Sets the debugMesh */
  132005. set debugMesh(value: Nullable<AbstractMesh> | Nullable<LinesMesh>);
  132006. /** Gets the displayMode */
  132007. get displayMode(): number;
  132008. /** Sets the displayMode */
  132009. set displayMode(value: number);
  132010. /**
  132011. * Creates a new SkeletonViewer
  132012. * @param skeleton defines the skeleton to render
  132013. * @param mesh defines the mesh attached to the skeleton
  132014. * @param scene defines the hosting scene
  132015. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  132016. * @param renderingGroupId defines the rendering group id to use with the viewer
  132017. * @param options All of the extra constructor options for the SkeletonViewer
  132018. */
  132019. constructor(
  132020. /** defines the skeleton to render */
  132021. skeleton: Skeleton,
  132022. /** defines the mesh attached to the skeleton */
  132023. mesh: AbstractMesh,
  132024. /** The Scene scope*/
  132025. scene: Scene,
  132026. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  132027. autoUpdateBonesMatrices?: boolean,
  132028. /** defines the rendering group id to use with the viewer */
  132029. renderingGroupId?: number,
  132030. /** is the options for the viewer */
  132031. options?: Partial<ISkeletonViewerOptions>);
  132032. /** The Dynamic bindings for the update functions */
  132033. private _bindObs;
  132034. /** Update the viewer to sync with current skeleton state, only used to manually update. */
  132035. update(): void;
  132036. /** Gets or sets a boolean indicating if the viewer is enabled */
  132037. set isEnabled(value: boolean);
  132038. get isEnabled(): boolean;
  132039. private _getBonePosition;
  132040. private _getLinesForBonesWithLength;
  132041. private _getLinesForBonesNoLength;
  132042. /** function to revert the mesh and scene back to the initial state. */
  132043. private _revert;
  132044. /** function to get the absolute bind pose of a bone by accumulating transformations up the bone hierarchy. */
  132045. private _getAbsoluteBindPoseToRef;
  132046. /** function to build and bind sphere joint points and spur bone representations. */
  132047. private _buildSpheresAndSpurs;
  132048. private _buildLocalAxes;
  132049. /** Update the viewer to sync with current skeleton state, only used for the line display. */
  132050. private _displayLinesUpdate;
  132051. /** Changes the displayMode of the skeleton viewer
  132052. * @param mode The displayMode numerical value
  132053. */
  132054. changeDisplayMode(mode: number): void;
  132055. /** Sets a display option of the skeleton viewer
  132056. *
  132057. * | Option | Type | Default | Description |
  132058. * | ---------------- | ------- | ------- | ----------- |
  132059. * | midStep | float | 0.235 | A percentage between a bone and its child that determines the widest part of a spur. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132060. * | midStepFactor | float | 0.15 | Mid step width expressed as a factor of the length. A value of 0.5 makes the spur width half of the spur length. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132061. * | sphereBaseSize | float | 2 | Sphere base size. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132062. * | sphereScaleUnit | float | 0.865 | Sphere scale factor used to scale spheres in relation to the longest bone. Only used when `displayMode` is set to `DISPLAY_SPHERE_AND_SPURS`. |
  132063. * | spurFollowsChild | boolean | false | Whether a spur should attach its far end to the child bone. |
  132064. * | showLocalAxes | boolean | false | Displays local axes on all bones. |
  132065. * | localAxesSize | float | 0.075 | Determines the length of each local axis. |
  132066. *
  132067. * @param option String of the option name
  132068. * @param value The numerical option value
  132069. */
  132070. changeDisplayOptions(option: string, value: number): void;
  132071. /** Release associated resources */
  132072. dispose(): void;
  132073. }
  132074. }
  132075. declare module BABYLON {
  132076. /**
  132077. * Enum for Device Types
  132078. */
  132079. export enum DeviceType {
  132080. /** Generic */
  132081. Generic = 0,
  132082. /** Keyboard */
  132083. Keyboard = 1,
  132084. /** Mouse */
  132085. Mouse = 2,
  132086. /** Touch Pointers */
  132087. Touch = 3,
  132088. /** PS4 Dual Shock */
  132089. DualShock = 4,
  132090. /** Xbox */
  132091. Xbox = 5,
  132092. /** Switch Controller */
  132093. Switch = 6
  132094. }
  132095. /**
  132096. * Enum for All Pointers (Touch/Mouse)
  132097. */
  132098. export enum PointerInput {
  132099. /** Horizontal Axis */
  132100. Horizontal = 0,
  132101. /** Vertical Axis */
  132102. Vertical = 1,
  132103. /** Left Click or Touch */
  132104. LeftClick = 2,
  132105. /** Middle Click */
  132106. MiddleClick = 3,
  132107. /** Right Click */
  132108. RightClick = 4,
  132109. /** Browser Back */
  132110. BrowserBack = 5,
  132111. /** Browser Forward */
  132112. BrowserForward = 6
  132113. }
  132114. /**
  132115. * Enum for Dual Shock Gamepad
  132116. */
  132117. export enum DualShockInput {
  132118. /** Cross */
  132119. Cross = 0,
  132120. /** Circle */
  132121. Circle = 1,
  132122. /** Square */
  132123. Square = 2,
  132124. /** Triangle */
  132125. Triangle = 3,
  132126. /** L1 */
  132127. L1 = 4,
  132128. /** R1 */
  132129. R1 = 5,
  132130. /** L2 */
  132131. L2 = 6,
  132132. /** R2 */
  132133. R2 = 7,
  132134. /** Share */
  132135. Share = 8,
  132136. /** Options */
  132137. Options = 9,
  132138. /** L3 */
  132139. L3 = 10,
  132140. /** R3 */
  132141. R3 = 11,
  132142. /** DPadUp */
  132143. DPadUp = 12,
  132144. /** DPadDown */
  132145. DPadDown = 13,
  132146. /** DPadLeft */
  132147. DPadLeft = 14,
  132148. /** DRight */
  132149. DPadRight = 15,
  132150. /** Home */
  132151. Home = 16,
  132152. /** TouchPad */
  132153. TouchPad = 17,
  132154. /** LStickXAxis */
  132155. LStickXAxis = 18,
  132156. /** LStickYAxis */
  132157. LStickYAxis = 19,
  132158. /** RStickXAxis */
  132159. RStickXAxis = 20,
  132160. /** RStickYAxis */
  132161. RStickYAxis = 21
  132162. }
  132163. /**
  132164. * Enum for Xbox Gamepad
  132165. */
  132166. export enum XboxInput {
  132167. /** A */
  132168. A = 0,
  132169. /** B */
  132170. B = 1,
  132171. /** X */
  132172. X = 2,
  132173. /** Y */
  132174. Y = 3,
  132175. /** LB */
  132176. LB = 4,
  132177. /** RB */
  132178. RB = 5,
  132179. /** LT */
  132180. LT = 6,
  132181. /** RT */
  132182. RT = 7,
  132183. /** Back */
  132184. Back = 8,
  132185. /** Start */
  132186. Start = 9,
  132187. /** LS */
  132188. LS = 10,
  132189. /** RS */
  132190. RS = 11,
  132191. /** DPadUp */
  132192. DPadUp = 12,
  132193. /** DPadDown */
  132194. DPadDown = 13,
  132195. /** DPadLeft */
  132196. DPadLeft = 14,
  132197. /** DRight */
  132198. DPadRight = 15,
  132199. /** Home */
  132200. Home = 16,
  132201. /** LStickXAxis */
  132202. LStickXAxis = 17,
  132203. /** LStickYAxis */
  132204. LStickYAxis = 18,
  132205. /** RStickXAxis */
  132206. RStickXAxis = 19,
  132207. /** RStickYAxis */
  132208. RStickYAxis = 20
  132209. }
  132210. /**
  132211. * Enum for Switch (Pro/JoyCon L+R) Gamepad
  132212. */
  132213. export enum SwitchInput {
  132214. /** B */
  132215. B = 0,
  132216. /** A */
  132217. A = 1,
  132218. /** Y */
  132219. Y = 2,
  132220. /** X */
  132221. X = 3,
  132222. /** L */
  132223. L = 4,
  132224. /** R */
  132225. R = 5,
  132226. /** ZL */
  132227. ZL = 6,
  132228. /** ZR */
  132229. ZR = 7,
  132230. /** Minus */
  132231. Minus = 8,
  132232. /** Plus */
  132233. Plus = 9,
  132234. /** LS */
  132235. LS = 10,
  132236. /** RS */
  132237. RS = 11,
  132238. /** DPadUp */
  132239. DPadUp = 12,
  132240. /** DPadDown */
  132241. DPadDown = 13,
  132242. /** DPadLeft */
  132243. DPadLeft = 14,
  132244. /** DRight */
  132245. DPadRight = 15,
  132246. /** Home */
  132247. Home = 16,
  132248. /** Capture */
  132249. Capture = 17,
  132250. /** LStickXAxis */
  132251. LStickXAxis = 18,
  132252. /** LStickYAxis */
  132253. LStickYAxis = 19,
  132254. /** RStickXAxis */
  132255. RStickXAxis = 20,
  132256. /** RStickYAxis */
  132257. RStickYAxis = 21
  132258. }
  132259. }
  132260. declare module BABYLON {
  132261. /**
  132262. * This class will take all inputs from Keyboard, Pointer, and
  132263. * any Gamepads and provide a polling system that all devices
  132264. * will use. This class assumes that there will only be one
  132265. * pointer device and one keyboard.
  132266. */
  132267. export class DeviceInputSystem implements IDisposable {
  132268. /**
  132269. * Callback to be triggered when a device is connected
  132270. */
  132271. onDeviceConnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132272. /**
  132273. * Callback to be triggered when a device is disconnected
  132274. */
  132275. onDeviceDisconnected: (deviceType: DeviceType, deviceSlot: number) => void;
  132276. /**
  132277. * Callback to be triggered when event driven input is updated
  132278. */
  132279. onInputChanged: (deviceType: DeviceType, deviceSlot: number, inputIndex: number, previousState: Nullable<number>, currentState: Nullable<number>) => void;
  132280. private _inputs;
  132281. private _gamepads;
  132282. private _keyboardActive;
  132283. private _pointerActive;
  132284. private _elementToAttachTo;
  132285. private _keyboardDownEvent;
  132286. private _keyboardUpEvent;
  132287. private _pointerMoveEvent;
  132288. private _pointerDownEvent;
  132289. private _pointerUpEvent;
  132290. private _gamepadConnectedEvent;
  132291. private _gamepadDisconnectedEvent;
  132292. private static _MAX_KEYCODES;
  132293. private static _MAX_POINTER_INPUTS;
  132294. private constructor();
  132295. /**
  132296. * Creates a new DeviceInputSystem instance
  132297. * @param engine Engine to pull input element from
  132298. * @returns The new instance
  132299. */
  132300. static Create(engine: Engine): DeviceInputSystem;
  132301. /**
  132302. * Checks for current device input value, given an id and input index
  132303. * @param deviceName Id of connected device
  132304. * @param inputIndex Index of device input
  132305. * @returns Current value of input
  132306. */
  132307. /**
  132308. * Checks for current device input value, given an id and input index. Throws exception if requested device not initialized.
  132309. * @param deviceType Enum specifiying device type
  132310. * @param deviceSlot "Slot" or index that device is referenced in
  132311. * @param inputIndex Id of input to be checked
  132312. * @returns Current value of input
  132313. */
  132314. pollInput(deviceType: DeviceType, deviceSlot: number, inputIndex: number): number;
  132315. /**
  132316. * Dispose of all the eventlisteners
  132317. */
  132318. dispose(): void;
  132319. /**
  132320. * Add device and inputs to device array
  132321. * @param deviceType Enum specifiying device type
  132322. * @param deviceSlot "Slot" or index that device is referenced in
  132323. * @param numberOfInputs Number of input entries to create for given device
  132324. */
  132325. private _registerDevice;
  132326. /**
  132327. * Given a specific device name, remove that device from the device map
  132328. * @param deviceType Enum specifiying device type
  132329. * @param deviceSlot "Slot" or index that device is referenced in
  132330. */
  132331. private _unregisterDevice;
  132332. /**
  132333. * Handle all actions that come from keyboard interaction
  132334. */
  132335. private _handleKeyActions;
  132336. /**
  132337. * Handle all actions that come from pointer interaction
  132338. */
  132339. private _handlePointerActions;
  132340. /**
  132341. * Handle all actions that come from gamepad interaction
  132342. */
  132343. private _handleGamepadActions;
  132344. /**
  132345. * Update all non-event based devices with each frame
  132346. * @param deviceType Enum specifiying device type
  132347. * @param deviceSlot "Slot" or index that device is referenced in
  132348. * @param inputIndex Id of input to be checked
  132349. */
  132350. private _updateDevice;
  132351. /**
  132352. * Gets DeviceType from the device name
  132353. * @param deviceName Name of Device from DeviceInputSystem
  132354. * @returns DeviceType enum value
  132355. */
  132356. private _getGamepadDeviceType;
  132357. }
  132358. }
  132359. declare module BABYLON {
  132360. /**
  132361. * Type to handle enforcement of inputs
  132362. */
  132363. 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;
  132364. }
  132365. declare module BABYLON {
  132366. /**
  132367. * Class that handles all input for a specific device
  132368. */
  132369. export class DeviceSource<T extends DeviceType> {
  132370. /** Type of device */
  132371. readonly deviceType: DeviceType;
  132372. /** "Slot" or index that device is referenced in */
  132373. readonly deviceSlot: number;
  132374. /**
  132375. * Observable to handle device input changes per device
  132376. */
  132377. readonly onInputChangedObservable: Observable<{
  132378. inputIndex: DeviceInput<T>;
  132379. previousState: Nullable<number>;
  132380. currentState: Nullable<number>;
  132381. }>;
  132382. private readonly _deviceInputSystem;
  132383. /**
  132384. * Default Constructor
  132385. * @param deviceInputSystem Reference to DeviceInputSystem
  132386. * @param deviceType Type of device
  132387. * @param deviceSlot "Slot" or index that device is referenced in
  132388. */
  132389. constructor(deviceInputSystem: DeviceInputSystem,
  132390. /** Type of device */
  132391. deviceType: DeviceType,
  132392. /** "Slot" or index that device is referenced in */
  132393. deviceSlot?: number);
  132394. /**
  132395. * Get input for specific input
  132396. * @param inputIndex index of specific input on device
  132397. * @returns Input value from DeviceInputSystem
  132398. */
  132399. getInput(inputIndex: DeviceInput<T>): number;
  132400. }
  132401. /**
  132402. * Class to keep track of devices
  132403. */
  132404. export class DeviceSourceManager implements IDisposable {
  132405. /**
  132406. * Observable to be triggered when before a device is connected
  132407. */
  132408. readonly onBeforeDeviceConnectedObservable: Observable<{
  132409. deviceType: DeviceType;
  132410. deviceSlot: number;
  132411. }>;
  132412. /**
  132413. * Observable to be triggered when before a device is disconnected
  132414. */
  132415. readonly onBeforeDeviceDisconnectedObservable: Observable<{
  132416. deviceType: DeviceType;
  132417. deviceSlot: number;
  132418. }>;
  132419. /**
  132420. * Observable to be triggered when after a device is connected
  132421. */
  132422. readonly onAfterDeviceConnectedObservable: Observable<{
  132423. deviceType: DeviceType;
  132424. deviceSlot: number;
  132425. }>;
  132426. /**
  132427. * Observable to be triggered when after a device is disconnected
  132428. */
  132429. readonly onAfterDeviceDisconnectedObservable: Observable<{
  132430. deviceType: DeviceType;
  132431. deviceSlot: number;
  132432. }>;
  132433. private readonly _devices;
  132434. private readonly _firstDevice;
  132435. private readonly _deviceInputSystem;
  132436. /**
  132437. * Default Constructor
  132438. * @param engine engine to pull input element from
  132439. */
  132440. constructor(engine: Engine);
  132441. /**
  132442. * Gets a DeviceSource, given a type and slot
  132443. * @param deviceType Enum specifying device type
  132444. * @param deviceSlot "Slot" or index that device is referenced in
  132445. * @returns DeviceSource object
  132446. */
  132447. getDeviceSource<T extends DeviceType>(deviceType: T, deviceSlot?: number): Nullable<DeviceSource<T>>;
  132448. /**
  132449. * Gets an array of DeviceSource objects for a given device type
  132450. * @param deviceType Enum specifying device type
  132451. * @returns Array of DeviceSource objects
  132452. */
  132453. getDeviceSources<T extends DeviceType>(deviceType: T): ReadonlyArray<DeviceSource<T>>;
  132454. /**
  132455. * Dispose of DeviceInputSystem and other parts
  132456. */
  132457. dispose(): void;
  132458. /**
  132459. * Function to add device name to device list
  132460. * @param deviceType Enum specifying device type
  132461. * @param deviceSlot "Slot" or index that device is referenced in
  132462. */
  132463. private _addDevice;
  132464. /**
  132465. * Function to remove device name to device list
  132466. * @param deviceType Enum specifying device type
  132467. * @param deviceSlot "Slot" or index that device is referenced in
  132468. */
  132469. private _removeDevice;
  132470. /**
  132471. * Updates array storing first connected device of each type
  132472. * @param type Type of Device
  132473. */
  132474. private _updateFirstDevices;
  132475. }
  132476. }
  132477. declare module BABYLON {
  132478. /**
  132479. * Options to create the null engine
  132480. */
  132481. export class NullEngineOptions {
  132482. /**
  132483. * Render width (Default: 512)
  132484. */
  132485. renderWidth: number;
  132486. /**
  132487. * Render height (Default: 256)
  132488. */
  132489. renderHeight: number;
  132490. /**
  132491. * Texture size (Default: 512)
  132492. */
  132493. textureSize: number;
  132494. /**
  132495. * If delta time between frames should be constant
  132496. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132497. */
  132498. deterministicLockstep: boolean;
  132499. /**
  132500. * Maximum about of steps between frames (Default: 4)
  132501. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132502. */
  132503. lockstepMaxSteps: number;
  132504. /**
  132505. * Make the matrix computations to be performed in 64 bits instead of 32 bits. False by default
  132506. */
  132507. useHighPrecisionMatrix?: boolean;
  132508. }
  132509. /**
  132510. * The null engine class provides support for headless version of babylon.js.
  132511. * This can be used in server side scenario or for testing purposes
  132512. */
  132513. export class NullEngine extends Engine {
  132514. private _options;
  132515. /**
  132516. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  132517. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132518. * @returns true if engine is in deterministic lock step mode
  132519. */
  132520. isDeterministicLockStep(): boolean;
  132521. /**
  132522. * Gets the max steps when engine is running in deterministic lock step
  132523. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132524. * @returns the max steps
  132525. */
  132526. getLockstepMaxSteps(): number;
  132527. /**
  132528. * Gets the current hardware scaling level.
  132529. * By default the hardware scaling level is computed from the window device ratio.
  132530. * 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.
  132531. * @returns a number indicating the current hardware scaling level
  132532. */
  132533. getHardwareScalingLevel(): number;
  132534. constructor(options?: NullEngineOptions);
  132535. /**
  132536. * Creates a vertex buffer
  132537. * @param vertices the data for the vertex buffer
  132538. * @returns the new WebGL static buffer
  132539. */
  132540. createVertexBuffer(vertices: FloatArray): DataBuffer;
  132541. /**
  132542. * Creates a new index buffer
  132543. * @param indices defines the content of the index buffer
  132544. * @param updatable defines if the index buffer must be updatable
  132545. * @returns a new webGL buffer
  132546. */
  132547. createIndexBuffer(indices: IndicesArray): DataBuffer;
  132548. /**
  132549. * Clear the current render buffer or the current render target (if any is set up)
  132550. * @param color defines the color to use
  132551. * @param backBuffer defines if the back buffer must be cleared
  132552. * @param depth defines if the depth buffer must be cleared
  132553. * @param stencil defines if the stencil buffer must be cleared
  132554. */
  132555. clear(color: IColor4Like, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  132556. /**
  132557. * Gets the current render width
  132558. * @param useScreen defines if screen size must be used (or the current render target if any)
  132559. * @returns a number defining the current render width
  132560. */
  132561. getRenderWidth(useScreen?: boolean): number;
  132562. /**
  132563. * Gets the current render height
  132564. * @param useScreen defines if screen size must be used (or the current render target if any)
  132565. * @returns a number defining the current render height
  132566. */
  132567. getRenderHeight(useScreen?: boolean): number;
  132568. /**
  132569. * Set the WebGL's viewport
  132570. * @param viewport defines the viewport element to be used
  132571. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  132572. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  132573. */
  132574. setViewport(viewport: IViewportLike, requiredWidth?: number, requiredHeight?: number): void;
  132575. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: string, context?: WebGLRenderingContext): WebGLProgram;
  132576. /**
  132577. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  132578. * @param pipelineContext defines the pipeline context to use
  132579. * @param uniformsNames defines the list of uniform names
  132580. * @returns an array of webGL uniform locations
  132581. */
  132582. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): Nullable<WebGLUniformLocation>[];
  132583. /**
  132584. * Gets the lsit of active attributes for a given webGL program
  132585. * @param pipelineContext defines the pipeline context to use
  132586. * @param attributesNames defines the list of attribute names to get
  132587. * @returns an array of indices indicating the offset of each attribute
  132588. */
  132589. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  132590. /**
  132591. * Binds an effect to the webGL context
  132592. * @param effect defines the effect to bind
  132593. */
  132594. bindSamplers(effect: Effect): void;
  132595. /**
  132596. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  132597. * @param effect defines the effect to activate
  132598. */
  132599. enableEffect(effect: Effect): void;
  132600. /**
  132601. * Set various states to the webGL context
  132602. * @param culling defines backface culling state
  132603. * @param zOffset defines the value to apply to zOffset (0 by default)
  132604. * @param force defines if states must be applied even if cache is up to date
  132605. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  132606. */
  132607. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  132608. /**
  132609. * Set the value of an uniform to an array of int32
  132610. * @param uniform defines the webGL uniform location where to store the value
  132611. * @param array defines the array of int32 to store
  132612. * @returns true if value was set
  132613. */
  132614. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132615. /**
  132616. * Set the value of an uniform to an array of int32 (stored as vec2)
  132617. * @param uniform defines the webGL uniform location where to store the value
  132618. * @param array defines the array of int32 to store
  132619. * @returns true if value was set
  132620. */
  132621. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132622. /**
  132623. * Set the value of an uniform to an array of int32 (stored as vec3)
  132624. * @param uniform defines the webGL uniform location where to store the value
  132625. * @param array defines the array of int32 to store
  132626. * @returns true if value was set
  132627. */
  132628. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132629. /**
  132630. * Set the value of an uniform to an array of int32 (stored as vec4)
  132631. * @param uniform defines the webGL uniform location where to store the value
  132632. * @param array defines the array of int32 to store
  132633. * @returns true if value was set
  132634. */
  132635. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  132636. /**
  132637. * Set the value of an uniform to an array of float32
  132638. * @param uniform defines the webGL uniform location where to store the value
  132639. * @param array defines the array of float32 to store
  132640. * @returns true if value was set
  132641. */
  132642. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132643. /**
  132644. * Set the value of an uniform to an array of float32 (stored as vec2)
  132645. * @param uniform defines the webGL uniform location where to store the value
  132646. * @param array defines the array of float32 to store
  132647. * @returns true if value was set
  132648. */
  132649. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132650. /**
  132651. * Set the value of an uniform to an array of float32 (stored as vec3)
  132652. * @param uniform defines the webGL uniform location where to store the value
  132653. * @param array defines the array of float32 to store
  132654. * @returns true if value was set
  132655. */
  132656. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132657. /**
  132658. * Set the value of an uniform to an array of float32 (stored as vec4)
  132659. * @param uniform defines the webGL uniform location where to store the value
  132660. * @param array defines the array of float32 to store
  132661. * @returns true if value was set
  132662. */
  132663. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  132664. /**
  132665. * Set the value of an uniform to an array of number
  132666. * @param uniform defines the webGL uniform location where to store the value
  132667. * @param array defines the array of number to store
  132668. * @returns true if value was set
  132669. */
  132670. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  132671. /**
  132672. * Set the value of an uniform to an array of number (stored as vec2)
  132673. * @param uniform defines the webGL uniform location where to store the value
  132674. * @param array defines the array of number to store
  132675. * @returns true if value was set
  132676. */
  132677. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  132678. /**
  132679. * Set the value of an uniform to an array of number (stored as vec3)
  132680. * @param uniform defines the webGL uniform location where to store the value
  132681. * @param array defines the array of number to store
  132682. * @returns true if value was set
  132683. */
  132684. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  132685. /**
  132686. * Set the value of an uniform to an array of number (stored as vec4)
  132687. * @param uniform defines the webGL uniform location where to store the value
  132688. * @param array defines the array of number to store
  132689. * @returns true if value was set
  132690. */
  132691. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  132692. /**
  132693. * Set the value of an uniform to an array of float32 (stored as matrices)
  132694. * @param uniform defines the webGL uniform location where to store the value
  132695. * @param matrices defines the array of float32 to store
  132696. * @returns true if value was set
  132697. */
  132698. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  132699. /**
  132700. * Set the value of an uniform to a matrix (3x3)
  132701. * @param uniform defines the webGL uniform location where to store the value
  132702. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  132703. * @returns true if value was set
  132704. */
  132705. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132706. /**
  132707. * Set the value of an uniform to a matrix (2x2)
  132708. * @param uniform defines the webGL uniform location where to store the value
  132709. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  132710. * @returns true if value was set
  132711. */
  132712. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  132713. /**
  132714. * Set the value of an uniform to a number (float)
  132715. * @param uniform defines the webGL uniform location where to store the value
  132716. * @param value defines the float number to store
  132717. * @returns true if value was set
  132718. */
  132719. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  132720. /**
  132721. * Set the value of an uniform to a vec2
  132722. * @param uniform defines the webGL uniform location where to store the value
  132723. * @param x defines the 1st component of the value
  132724. * @param y defines the 2nd component of the value
  132725. * @returns true if value was set
  132726. */
  132727. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  132728. /**
  132729. * Set the value of an uniform to a vec3
  132730. * @param uniform defines the webGL uniform location where to store the value
  132731. * @param x defines the 1st component of the value
  132732. * @param y defines the 2nd component of the value
  132733. * @param z defines the 3rd component of the value
  132734. * @returns true if value was set
  132735. */
  132736. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  132737. /**
  132738. * Set the value of an uniform to a boolean
  132739. * @param uniform defines the webGL uniform location where to store the value
  132740. * @param bool defines the boolean to store
  132741. * @returns true if value was set
  132742. */
  132743. setBool(uniform: WebGLUniformLocation, bool: number): boolean;
  132744. /**
  132745. * Set the value of an uniform to a vec4
  132746. * @param uniform defines the webGL uniform location where to store the value
  132747. * @param x defines the 1st component of the value
  132748. * @param y defines the 2nd component of the value
  132749. * @param z defines the 3rd component of the value
  132750. * @param w defines the 4th component of the value
  132751. * @returns true if value was set
  132752. */
  132753. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  132754. /**
  132755. * Sets the current alpha mode
  132756. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  132757. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  132758. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  132759. */
  132760. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  132761. /**
  132762. * Bind webGl buffers directly to the webGL context
  132763. * @param vertexBuffers defines the vertex buffer to bind
  132764. * @param indexBuffer defines the index buffer to bind
  132765. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  132766. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  132767. * @param effect defines the effect associated with the vertex buffer
  132768. */
  132769. bindBuffers(vertexBuffers: {
  132770. [key: string]: VertexBuffer;
  132771. }, indexBuffer: DataBuffer, effect: Effect): void;
  132772. /**
  132773. * Force the entire cache to be cleared
  132774. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  132775. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  132776. */
  132777. wipeCaches(bruteForce?: boolean): void;
  132778. /**
  132779. * Send a draw order
  132780. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  132781. * @param indexStart defines the starting index
  132782. * @param indexCount defines the number of index to draw
  132783. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132784. */
  132785. draw(useTriangles: boolean, indexStart: number, indexCount: number, instancesCount?: number): void;
  132786. /**
  132787. * Draw a list of indexed primitives
  132788. * @param fillMode defines the primitive to use
  132789. * @param indexStart defines the starting index
  132790. * @param indexCount defines the number of index to draw
  132791. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132792. */
  132793. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  132794. /**
  132795. * Draw a list of unindexed primitives
  132796. * @param fillMode defines the primitive to use
  132797. * @param verticesStart defines the index of first vertex to draw
  132798. * @param verticesCount defines the count of vertices to draw
  132799. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  132800. */
  132801. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  132802. /** @hidden */
  132803. _createTexture(): WebGLTexture;
  132804. /** @hidden */
  132805. _releaseTexture(texture: InternalTexture): void;
  132806. /**
  132807. * Usually called from Texture.ts.
  132808. * Passed information to create a WebGLTexture
  132809. * @param urlArg defines a value which contains one of the following:
  132810. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  132811. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  132812. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  132813. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  132814. * @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)
  132815. * @param scene needed for loading to the correct scene
  132816. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  132817. * @param onLoad optional callback to be called upon successful completion
  132818. * @param onError optional callback to be called upon failure
  132819. * @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
  132820. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  132821. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  132822. * @param forcedExtension defines the extension to use to pick the right loader
  132823. * @param mimeType defines an optional mime type
  132824. * @returns a InternalTexture for assignment back into BABYLON.Texture
  132825. */
  132826. 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;
  132827. /**
  132828. * Creates a new render target texture
  132829. * @param size defines the size of the texture
  132830. * @param options defines the options used to create the texture
  132831. * @returns a new render target texture stored in an InternalTexture
  132832. */
  132833. createRenderTargetTexture(size: any, options: boolean | RenderTargetCreationOptions): InternalTexture;
  132834. /**
  132835. * Update the sampling mode of a given texture
  132836. * @param samplingMode defines the required sampling mode
  132837. * @param texture defines the texture to update
  132838. */
  132839. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  132840. /**
  132841. * Binds the frame buffer to the specified texture.
  132842. * @param texture The texture to render to or null for the default canvas
  132843. * @param faceIndex The face of the texture to render to in case of cube texture
  132844. * @param requiredWidth The width of the target to render to
  132845. * @param requiredHeight The height of the target to render to
  132846. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  132847. * @param lodLevel defines le lod level to bind to the frame buffer
  132848. */
  132849. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  132850. /**
  132851. * Unbind the current render target texture from the webGL context
  132852. * @param texture defines the render target texture to unbind
  132853. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  132854. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  132855. */
  132856. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  132857. /**
  132858. * Creates a dynamic vertex buffer
  132859. * @param vertices the data for the dynamic vertex buffer
  132860. * @returns the new WebGL dynamic buffer
  132861. */
  132862. createDynamicVertexBuffer(vertices: FloatArray): DataBuffer;
  132863. /**
  132864. * Update the content of a dynamic texture
  132865. * @param texture defines the texture to update
  132866. * @param canvas defines the canvas containing the source
  132867. * @param invertY defines if data must be stored with Y axis inverted
  132868. * @param premulAlpha defines if alpha is stored as premultiplied
  132869. * @param format defines the format of the data
  132870. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  132871. */
  132872. updateDynamicTexture(texture: Nullable<InternalTexture>, canvas: HTMLCanvasElement, invertY: boolean, premulAlpha?: boolean, format?: number): void;
  132873. /**
  132874. * Gets a boolean indicating if all created effects are ready
  132875. * @returns true if all effects are ready
  132876. */
  132877. areAllEffectsReady(): boolean;
  132878. /**
  132879. * @hidden
  132880. * Get the current error code of the webGL context
  132881. * @returns the error code
  132882. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  132883. */
  132884. getError(): number;
  132885. /** @hidden */
  132886. _getUnpackAlignement(): number;
  132887. /** @hidden */
  132888. _unpackFlipY(value: boolean): void;
  132889. /**
  132890. * Update a dynamic index buffer
  132891. * @param indexBuffer defines the target index buffer
  132892. * @param indices defines the data to update
  132893. * @param offset defines the offset in the target index buffer where update should start
  132894. */
  132895. updateDynamicIndexBuffer(indexBuffer: WebGLBuffer, indices: IndicesArray, offset?: number): void;
  132896. /**
  132897. * Updates a dynamic vertex buffer.
  132898. * @param vertexBuffer the vertex buffer to update
  132899. * @param vertices the data used to update the vertex buffer
  132900. * @param byteOffset the byte offset of the data (optional)
  132901. * @param byteLength the byte length of the data (optional)
  132902. */
  132903. updateDynamicVertexBuffer(vertexBuffer: WebGLBuffer, vertices: FloatArray, byteOffset?: number, byteLength?: number): void;
  132904. /** @hidden */
  132905. _bindTextureDirectly(target: number, texture: InternalTexture): boolean;
  132906. /** @hidden */
  132907. _bindTexture(channel: number, texture: InternalTexture): void;
  132908. protected _deleteBuffer(buffer: WebGLBuffer): void;
  132909. /**
  132910. * 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
  132911. */
  132912. releaseEffects(): void;
  132913. displayLoadingUI(): void;
  132914. hideLoadingUI(): void;
  132915. /** @hidden */
  132916. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132917. /** @hidden */
  132918. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132919. /** @hidden */
  132920. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  132921. /** @hidden */
  132922. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  132923. }
  132924. }
  132925. declare module BABYLON {
  132926. /**
  132927. * @hidden
  132928. **/
  132929. export class _TimeToken {
  132930. _startTimeQuery: Nullable<WebGLQuery>;
  132931. _endTimeQuery: Nullable<WebGLQuery>;
  132932. _timeElapsedQuery: Nullable<WebGLQuery>;
  132933. _timeElapsedQueryEnded: boolean;
  132934. }
  132935. }
  132936. declare module BABYLON {
  132937. /** @hidden */
  132938. export class _OcclusionDataStorage {
  132939. /** @hidden */
  132940. occlusionInternalRetryCounter: number;
  132941. /** @hidden */
  132942. isOcclusionQueryInProgress: boolean;
  132943. /** @hidden */
  132944. isOccluded: boolean;
  132945. /** @hidden */
  132946. occlusionRetryCount: number;
  132947. /** @hidden */
  132948. occlusionType: number;
  132949. /** @hidden */
  132950. occlusionQueryAlgorithmType: number;
  132951. }
  132952. interface Engine {
  132953. /**
  132954. * Create a new webGL query (you must be sure that queries are supported by checking getCaps() function)
  132955. * @return the new query
  132956. */
  132957. createQuery(): WebGLQuery;
  132958. /**
  132959. * Delete and release a webGL query
  132960. * @param query defines the query to delete
  132961. * @return the current engine
  132962. */
  132963. deleteQuery(query: WebGLQuery): Engine;
  132964. /**
  132965. * Check if a given query has resolved and got its value
  132966. * @param query defines the query to check
  132967. * @returns true if the query got its value
  132968. */
  132969. isQueryResultAvailable(query: WebGLQuery): boolean;
  132970. /**
  132971. * Gets the value of a given query
  132972. * @param query defines the query to check
  132973. * @returns the value of the query
  132974. */
  132975. getQueryResult(query: WebGLQuery): number;
  132976. /**
  132977. * Initiates an occlusion query
  132978. * @param algorithmType defines the algorithm to use
  132979. * @param query defines the query to use
  132980. * @returns the current engine
  132981. * @see https://doc.babylonjs.com/features/occlusionquery
  132982. */
  132983. beginOcclusionQuery(algorithmType: number, query: WebGLQuery): Engine;
  132984. /**
  132985. * Ends an occlusion query
  132986. * @see https://doc.babylonjs.com/features/occlusionquery
  132987. * @param algorithmType defines the algorithm to use
  132988. * @returns the current engine
  132989. */
  132990. endOcclusionQuery(algorithmType: number): Engine;
  132991. /**
  132992. * Starts a time query (used to measure time spent by the GPU on a specific frame)
  132993. * Please note that only one query can be issued at a time
  132994. * @returns a time token used to track the time span
  132995. */
  132996. startTimeQuery(): Nullable<_TimeToken>;
  132997. /**
  132998. * Ends a time query
  132999. * @param token defines the token used to measure the time span
  133000. * @returns the time spent (in ns)
  133001. */
  133002. endTimeQuery(token: _TimeToken): int;
  133003. /** @hidden */
  133004. _currentNonTimestampToken: Nullable<_TimeToken>;
  133005. /** @hidden */
  133006. _createTimeQuery(): WebGLQuery;
  133007. /** @hidden */
  133008. _deleteTimeQuery(query: WebGLQuery): void;
  133009. /** @hidden */
  133010. _getGlAlgorithmType(algorithmType: number): number;
  133011. /** @hidden */
  133012. _getTimeQueryResult(query: WebGLQuery): any;
  133013. /** @hidden */
  133014. _getTimeQueryAvailability(query: WebGLQuery): any;
  133015. }
  133016. interface AbstractMesh {
  133017. /**
  133018. * Backing filed
  133019. * @hidden
  133020. */
  133021. __occlusionDataStorage: _OcclusionDataStorage;
  133022. /**
  133023. * Access property
  133024. * @hidden
  133025. */
  133026. _occlusionDataStorage: _OcclusionDataStorage;
  133027. /**
  133028. * 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.
  133029. * The default value is -1 which means don't break the query and wait till the result
  133030. * @see https://doc.babylonjs.com/features/occlusionquery
  133031. */
  133032. occlusionRetryCount: number;
  133033. /**
  133034. * 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:
  133035. * * OCCLUSION_TYPE_NONE (Default Value): this option means no occlusion query whith the Mesh.
  133036. * * OCCLUSION_TYPE_OPTIMISTIC: this option is means use occlusion query and if occlusionRetryCount is reached and the query is broken show the mesh.
  133037. * * 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.
  133038. * @see https://doc.babylonjs.com/features/occlusionquery
  133039. */
  133040. occlusionType: number;
  133041. /**
  133042. * This property determines the type of occlusion query algorithm to run in WebGl, you can use:
  133043. * * AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE which is mapped to GL_ANY_SAMPLES_PASSED.
  133044. * * 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.
  133045. * @see https://doc.babylonjs.com/features/occlusionquery
  133046. */
  133047. occlusionQueryAlgorithmType: number;
  133048. /**
  133049. * 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
  133050. * @see https://doc.babylonjs.com/features/occlusionquery
  133051. */
  133052. isOccluded: boolean;
  133053. /**
  133054. * Flag to check the progress status of the query
  133055. * @see https://doc.babylonjs.com/features/occlusionquery
  133056. */
  133057. isOcclusionQueryInProgress: boolean;
  133058. }
  133059. }
  133060. declare module BABYLON {
  133061. /** @hidden */
  133062. export var _forceTransformFeedbackToBundle: boolean;
  133063. interface Engine {
  133064. /**
  133065. * Creates a webGL transform feedback object
  133066. * Please makes sure to check webGLVersion property to check if you are running webGL 2+
  133067. * @returns the webGL transform feedback object
  133068. */
  133069. createTransformFeedback(): WebGLTransformFeedback;
  133070. /**
  133071. * Delete a webGL transform feedback object
  133072. * @param value defines the webGL transform feedback object to delete
  133073. */
  133074. deleteTransformFeedback(value: WebGLTransformFeedback): void;
  133075. /**
  133076. * Bind a webGL transform feedback object to the webgl context
  133077. * @param value defines the webGL transform feedback object to bind
  133078. */
  133079. bindTransformFeedback(value: Nullable<WebGLTransformFeedback>): void;
  133080. /**
  133081. * Begins a transform feedback operation
  133082. * @param usePoints defines if points or triangles must be used
  133083. */
  133084. beginTransformFeedback(usePoints: boolean): void;
  133085. /**
  133086. * Ends a transform feedback operation
  133087. */
  133088. endTransformFeedback(): void;
  133089. /**
  133090. * Specify the varyings to use with transform feedback
  133091. * @param program defines the associated webGL program
  133092. * @param value defines the list of strings representing the varying names
  133093. */
  133094. setTranformFeedbackVaryings(program: WebGLProgram, value: string[]): void;
  133095. /**
  133096. * Bind a webGL buffer for a transform feedback operation
  133097. * @param value defines the webGL buffer to bind
  133098. */
  133099. bindTransformFeedbackBuffer(value: Nullable<DataBuffer>): void;
  133100. }
  133101. }
  133102. declare module BABYLON {
  133103. /**
  133104. * Class used to define an additional view for the engine
  133105. * @see https://doc.babylonjs.com/how_to/multi_canvases
  133106. */
  133107. export class EngineView {
  133108. /** Defines the canvas where to render the view */
  133109. target: HTMLCanvasElement;
  133110. /** Defines an optional camera used to render the view (will use active camera else) */
  133111. camera?: Camera;
  133112. }
  133113. interface Engine {
  133114. /**
  133115. * Gets or sets the HTML element to use for attaching events
  133116. */
  133117. inputElement: Nullable<HTMLElement>;
  133118. /**
  133119. * Gets the current engine view
  133120. * @see https://doc.babylonjs.com/how_to/multi_canvases
  133121. */
  133122. activeView: Nullable<EngineView>;
  133123. /** Gets or sets the list of views */
  133124. views: EngineView[];
  133125. /**
  133126. * Register a new child canvas
  133127. * @param canvas defines the canvas to register
  133128. * @param camera defines an optional camera to use with this canvas (it will overwrite the scene.camera for this view)
  133129. * @returns the associated view
  133130. */
  133131. registerView(canvas: HTMLCanvasElement, camera?: Camera): EngineView;
  133132. /**
  133133. * Remove a registered child canvas
  133134. * @param canvas defines the canvas to remove
  133135. * @returns the current engine
  133136. */
  133137. unRegisterView(canvas: HTMLCanvasElement): Engine;
  133138. }
  133139. }
  133140. declare module BABYLON {
  133141. interface Engine {
  133142. /** @hidden */
  133143. _excludedCompressedTextures: string[];
  133144. /** @hidden */
  133145. _textureFormatInUse: string;
  133146. /**
  133147. * Gets the list of texture formats supported
  133148. */
  133149. readonly texturesSupported: Array<string>;
  133150. /**
  133151. * Gets the texture format in use
  133152. */
  133153. readonly textureFormatInUse: Nullable<string>;
  133154. /**
  133155. * Set the compressed texture extensions or file names to skip.
  133156. *
  133157. * @param skippedFiles defines the list of those texture files you want to skip
  133158. * Example: [".dds", ".env", "myfile.png"]
  133159. */
  133160. setCompressedTextureExclusions(skippedFiles: Array<string>): void;
  133161. /**
  133162. * Set the compressed texture format to use, based on the formats you have, and the formats
  133163. * supported by the hardware / browser.
  133164. *
  133165. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  133166. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  133167. * to API arguments needed to compressed textures. This puts the burden on the container
  133168. * generator to house the arcane code for determining these for current & future formats.
  133169. *
  133170. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  133171. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  133172. *
  133173. * Note: The result of this call is not taken into account when a texture is base64.
  133174. *
  133175. * @param formatsAvailable defines the list of those format families you have created
  133176. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  133177. *
  133178. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  133179. * @returns The extension selected.
  133180. */
  133181. setTextureFormatToUse(formatsAvailable: Array<string>): Nullable<string>;
  133182. }
  133183. }
  133184. declare module BABYLON {
  133185. /**
  133186. * CubeMap information grouping all the data for each faces as well as the cubemap size.
  133187. */
  133188. export interface CubeMapInfo {
  133189. /**
  133190. * The pixel array for the front face.
  133191. * This is stored in format, left to right, up to down format.
  133192. */
  133193. front: Nullable<ArrayBufferView>;
  133194. /**
  133195. * The pixel array for the back face.
  133196. * This is stored in format, left to right, up to down format.
  133197. */
  133198. back: Nullable<ArrayBufferView>;
  133199. /**
  133200. * The pixel array for the left face.
  133201. * This is stored in format, left to right, up to down format.
  133202. */
  133203. left: Nullable<ArrayBufferView>;
  133204. /**
  133205. * The pixel array for the right face.
  133206. * This is stored in format, left to right, up to down format.
  133207. */
  133208. right: Nullable<ArrayBufferView>;
  133209. /**
  133210. * The pixel array for the up face.
  133211. * This is stored in format, left to right, up to down format.
  133212. */
  133213. up: Nullable<ArrayBufferView>;
  133214. /**
  133215. * The pixel array for the down face.
  133216. * This is stored in format, left to right, up to down format.
  133217. */
  133218. down: Nullable<ArrayBufferView>;
  133219. /**
  133220. * The size of the cubemap stored.
  133221. *
  133222. * Each faces will be size * size pixels.
  133223. */
  133224. size: number;
  133225. /**
  133226. * The format of the texture.
  133227. *
  133228. * RGBA, RGB.
  133229. */
  133230. format: number;
  133231. /**
  133232. * The type of the texture data.
  133233. *
  133234. * UNSIGNED_INT, FLOAT.
  133235. */
  133236. type: number;
  133237. /**
  133238. * Specifies whether the texture is in gamma space.
  133239. */
  133240. gammaSpace: boolean;
  133241. }
  133242. /**
  133243. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  133244. */
  133245. export class PanoramaToCubeMapTools {
  133246. private static FACE_LEFT;
  133247. private static FACE_RIGHT;
  133248. private static FACE_FRONT;
  133249. private static FACE_BACK;
  133250. private static FACE_DOWN;
  133251. private static FACE_UP;
  133252. /**
  133253. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  133254. *
  133255. * @param float32Array The source data.
  133256. * @param inputWidth The width of the input panorama.
  133257. * @param inputHeight The height of the input panorama.
  133258. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  133259. * @return The cubemap data
  133260. */
  133261. static ConvertPanoramaToCubemap(float32Array: Float32Array, inputWidth: number, inputHeight: number, size: number): CubeMapInfo;
  133262. private static CreateCubemapTexture;
  133263. private static CalcProjectionSpherical;
  133264. }
  133265. }
  133266. declare module BABYLON {
  133267. /**
  133268. * Helper class dealing with the extraction of spherical polynomial dataArray
  133269. * from a cube map.
  133270. */
  133271. export class CubeMapToSphericalPolynomialTools {
  133272. private static FileFaces;
  133273. /**
  133274. * Converts a texture to the according Spherical Polynomial data.
  133275. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133276. *
  133277. * @param texture The texture to extract the information from.
  133278. * @return The Spherical Polynomial data.
  133279. */
  133280. static ConvertCubeMapTextureToSphericalPolynomial(texture: BaseTexture): Nullable<SphericalPolynomial>;
  133281. /**
  133282. * Converts a cubemap to the according Spherical Polynomial data.
  133283. * This extracts the first 3 orders only as they are the only one used in the lighting.
  133284. *
  133285. * @param cubeInfo The Cube map to extract the information from.
  133286. * @return The Spherical Polynomial data.
  133287. */
  133288. static ConvertCubeMapToSphericalPolynomial(cubeInfo: CubeMapInfo): SphericalPolynomial;
  133289. }
  133290. }
  133291. declare module BABYLON {
  133292. interface BaseTexture {
  133293. /**
  133294. * Get the polynomial representation of the texture data.
  133295. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  133296. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  133297. */
  133298. sphericalPolynomial: Nullable<SphericalPolynomial>;
  133299. }
  133300. }
  133301. declare module BABYLON {
  133302. /** @hidden */
  133303. export var rgbdEncodePixelShader: {
  133304. name: string;
  133305. shader: string;
  133306. };
  133307. }
  133308. declare module BABYLON {
  133309. /** @hidden */
  133310. export var rgbdDecodePixelShader: {
  133311. name: string;
  133312. shader: string;
  133313. };
  133314. }
  133315. declare module BABYLON {
  133316. /**
  133317. * Raw texture data and descriptor sufficient for WebGL texture upload
  133318. */
  133319. export interface EnvironmentTextureInfo {
  133320. /**
  133321. * Version of the environment map
  133322. */
  133323. version: number;
  133324. /**
  133325. * Width of image
  133326. */
  133327. width: number;
  133328. /**
  133329. * Irradiance information stored in the file.
  133330. */
  133331. irradiance: any;
  133332. /**
  133333. * Specular information stored in the file.
  133334. */
  133335. specular: any;
  133336. }
  133337. /**
  133338. * Defines One Image in the file. It requires only the position in the file
  133339. * as well as the length.
  133340. */
  133341. interface BufferImageData {
  133342. /**
  133343. * Length of the image data.
  133344. */
  133345. length: number;
  133346. /**
  133347. * Position of the data from the null terminator delimiting the end of the JSON.
  133348. */
  133349. position: number;
  133350. }
  133351. /**
  133352. * Defines the specular data enclosed in the file.
  133353. * This corresponds to the version 1 of the data.
  133354. */
  133355. export interface EnvironmentTextureSpecularInfoV1 {
  133356. /**
  133357. * Defines where the specular Payload is located. It is a runtime value only not stored in the file.
  133358. */
  133359. specularDataPosition?: number;
  133360. /**
  133361. * This contains all the images data needed to reconstruct the cubemap.
  133362. */
  133363. mipmaps: Array<BufferImageData>;
  133364. /**
  133365. * Defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness.
  133366. */
  133367. lodGenerationScale: number;
  133368. }
  133369. /**
  133370. * Sets of helpers addressing the serialization and deserialization of environment texture
  133371. * stored in a BabylonJS env file.
  133372. * Those files are usually stored as .env files.
  133373. */
  133374. export class EnvironmentTextureTools {
  133375. /**
  133376. * Magic number identifying the env file.
  133377. */
  133378. private static _MagicBytes;
  133379. /**
  133380. * Gets the environment info from an env file.
  133381. * @param data The array buffer containing the .env bytes.
  133382. * @returns the environment file info (the json header) if successfully parsed.
  133383. */
  133384. static GetEnvInfo(data: ArrayBufferView): Nullable<EnvironmentTextureInfo>;
  133385. /**
  133386. * Creates an environment texture from a loaded cube texture.
  133387. * @param texture defines the cube texture to convert in env file
  133388. * @return a promise containing the environment data if succesfull.
  133389. */
  133390. static CreateEnvTextureAsync(texture: BaseTexture): Promise<ArrayBuffer>;
  133391. /**
  133392. * Creates a JSON representation of the spherical data.
  133393. * @param texture defines the texture containing the polynomials
  133394. * @return the JSON representation of the spherical info
  133395. */
  133396. private static _CreateEnvTextureIrradiance;
  133397. /**
  133398. * Creates the ArrayBufferViews used for initializing environment texture image data.
  133399. * @param data the image data
  133400. * @param info parameters that determine what views will be created for accessing the underlying buffer
  133401. * @return the views described by info providing access to the underlying buffer
  133402. */
  133403. static CreateImageDataArrayBufferViews(data: ArrayBufferView, info: EnvironmentTextureInfo): Array<Array<ArrayBufferView>>;
  133404. /**
  133405. * Uploads the texture info contained in the env file to the GPU.
  133406. * @param texture defines the internal texture to upload to
  133407. * @param data defines the data to load
  133408. * @param info defines the texture info retrieved through the GetEnvInfo method
  133409. * @returns a promise
  133410. */
  133411. static UploadEnvLevelsAsync(texture: InternalTexture, data: ArrayBufferView, info: EnvironmentTextureInfo): Promise<void>;
  133412. private static _OnImageReadyAsync;
  133413. /**
  133414. * Uploads the levels of image data to the GPU.
  133415. * @param texture defines the internal texture to upload to
  133416. * @param imageData defines the array buffer views of image data [mipmap][face]
  133417. * @returns a promise
  133418. */
  133419. static UploadLevelsAsync(texture: InternalTexture, imageData: ArrayBufferView[][]): Promise<void>;
  133420. /**
  133421. * Uploads spherical polynomials information to the texture.
  133422. * @param texture defines the texture we are trying to upload the information to
  133423. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  133424. */
  133425. static UploadEnvSpherical(texture: InternalTexture, info: EnvironmentTextureInfo): void;
  133426. /** @hidden */
  133427. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  133428. }
  133429. }
  133430. declare module BABYLON {
  133431. /**
  133432. * Class used to inline functions in shader code
  133433. */
  133434. export class ShaderCodeInliner {
  133435. private static readonly _RegexpFindFunctionNameAndType;
  133436. private _sourceCode;
  133437. private _functionDescr;
  133438. private _numMaxIterations;
  133439. /** Gets or sets the token used to mark the functions to inline */
  133440. inlineToken: string;
  133441. /** Gets or sets the debug mode */
  133442. debug: boolean;
  133443. /** Gets the code after the inlining process */
  133444. get code(): string;
  133445. /**
  133446. * Initializes the inliner
  133447. * @param sourceCode shader code source to inline
  133448. * @param numMaxIterations maximum number of iterations (used to detect recursive calls)
  133449. */
  133450. constructor(sourceCode: string, numMaxIterations?: number);
  133451. /**
  133452. * Start the processing of the shader code
  133453. */
  133454. processCode(): void;
  133455. private _collectFunctions;
  133456. private _processInlining;
  133457. private _extractBetweenMarkers;
  133458. private _skipWhitespaces;
  133459. private _removeComments;
  133460. private _replaceFunctionCallsByCode;
  133461. private _findBackward;
  133462. private _escapeRegExp;
  133463. private _replaceNames;
  133464. }
  133465. }
  133466. declare module BABYLON {
  133467. /**
  133468. * Container for accessors for natively-stored mesh data buffers.
  133469. */
  133470. class NativeDataBuffer extends DataBuffer {
  133471. /**
  133472. * Accessor value used to identify/retrieve a natively-stored index buffer.
  133473. */
  133474. nativeIndexBuffer?: any;
  133475. /**
  133476. * Accessor value used to identify/retrieve a natively-stored vertex buffer.
  133477. */
  133478. nativeVertexBuffer?: any;
  133479. }
  133480. /** @hidden */
  133481. class NativeTexture extends InternalTexture {
  133482. getInternalTexture(): InternalTexture;
  133483. getViewCount(): number;
  133484. }
  133485. /** @hidden */
  133486. export class NativeEngine extends Engine {
  133487. private readonly _native;
  133488. /** Defines the invalid handle returned by bgfx when resource creation goes wrong */
  133489. private readonly INVALID_HANDLE;
  133490. private _boundBuffersVertexArray;
  133491. private _currentDepthTest;
  133492. getHardwareScalingLevel(): number;
  133493. constructor();
  133494. dispose(): void;
  133495. /**
  133496. * Can be used to override the current requestAnimationFrame requester.
  133497. * @hidden
  133498. */
  133499. protected _queueNewFrame(bindedRenderFunction: any, requester?: any): number;
  133500. /**
  133501. * Override default engine behavior.
  133502. * @param color
  133503. * @param backBuffer
  133504. * @param depth
  133505. * @param stencil
  133506. */
  133507. _bindUnboundFramebuffer(framebuffer: Nullable<WebGLFramebuffer>): void;
  133508. /**
  133509. * Gets host document
  133510. * @returns the host document object
  133511. */
  133512. getHostDocument(): Nullable<Document>;
  133513. clear(color: Nullable<IColor4Like>, backBuffer: boolean, depth: boolean, stencil?: boolean): void;
  133514. createIndexBuffer(indices: IndicesArray, updateable?: boolean): NativeDataBuffer;
  133515. createVertexBuffer(data: DataArray, updateable?: boolean): NativeDataBuffer;
  133516. protected _recordVertexArrayObject(vertexArray: any, vertexBuffers: {
  133517. [key: string]: VertexBuffer;
  133518. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133519. bindBuffers(vertexBuffers: {
  133520. [key: string]: VertexBuffer;
  133521. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): void;
  133522. recordVertexArrayObject(vertexBuffers: {
  133523. [key: string]: VertexBuffer;
  133524. }, indexBuffer: Nullable<NativeDataBuffer>, effect: Effect): WebGLVertexArrayObject;
  133525. bindVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133526. releaseVertexArrayObject(vertexArray: WebGLVertexArrayObject): void;
  133527. getAttributes(pipelineContext: IPipelineContext, attributesNames: string[]): number[];
  133528. /**
  133529. * Draw a list of indexed primitives
  133530. * @param fillMode defines the primitive to use
  133531. * @param indexStart defines the starting index
  133532. * @param indexCount defines the number of index to draw
  133533. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133534. */
  133535. drawElementsType(fillMode: number, indexStart: number, indexCount: number, instancesCount?: number): void;
  133536. /**
  133537. * Draw a list of unindexed primitives
  133538. * @param fillMode defines the primitive to use
  133539. * @param verticesStart defines the index of first vertex to draw
  133540. * @param verticesCount defines the count of vertices to draw
  133541. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  133542. */
  133543. drawArraysType(fillMode: number, verticesStart: number, verticesCount: number, instancesCount?: number): void;
  133544. createPipelineContext(): IPipelineContext;
  133545. _preparePipelineContext(pipelineContext: IPipelineContext, vertexSourceCode: string, fragmentSourceCode: string, createAsRaw: boolean, rebuildRebind: any, defines: Nullable<string>, transformFeedbackVaryings: Nullable<string[]>): void;
  133546. /** @hidden */
  133547. _isRenderingStateCompiled(pipelineContext: IPipelineContext): boolean;
  133548. /** @hidden */
  133549. _executeWhenRenderingStateIsCompiled(pipelineContext: IPipelineContext, action: () => void): void;
  133550. createRawShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133551. createShaderProgram(pipelineContext: IPipelineContext, vertexCode: string, fragmentCode: string, defines: Nullable<string>, context?: WebGLRenderingContext, transformFeedbackVaryings?: Nullable<string[]>): any;
  133552. protected _setProgram(program: WebGLProgram): void;
  133553. _releaseEffect(effect: Effect): void;
  133554. _deletePipelineContext(pipelineContext: IPipelineContext): void;
  133555. getUniforms(pipelineContext: IPipelineContext, uniformsNames: string[]): WebGLUniformLocation[];
  133556. bindUniformBlock(pipelineContext: IPipelineContext, blockName: string, index: number): void;
  133557. bindSamplers(effect: Effect): void;
  133558. setMatrix(uniform: WebGLUniformLocation, matrix: Matrix): void;
  133559. getRenderWidth(useScreen?: boolean): number;
  133560. getRenderHeight(useScreen?: boolean): number;
  133561. setViewport(viewport: Viewport, requiredWidth?: number, requiredHeight?: number): void;
  133562. setState(culling: boolean, zOffset?: number, force?: boolean, reverseSide?: boolean): void;
  133563. /**
  133564. * Set the z offset to apply to current rendering
  133565. * @param value defines the offset to apply
  133566. */
  133567. setZOffset(value: number): void;
  133568. /**
  133569. * Gets the current value of the zOffset
  133570. * @returns the current zOffset state
  133571. */
  133572. getZOffset(): number;
  133573. /**
  133574. * Enable or disable depth buffering
  133575. * @param enable defines the state to set
  133576. */
  133577. setDepthBuffer(enable: boolean): void;
  133578. /**
  133579. * Gets a boolean indicating if depth writing is enabled
  133580. * @returns the current depth writing state
  133581. */
  133582. getDepthWrite(): boolean;
  133583. setDepthFunctionToGreater(): void;
  133584. setDepthFunctionToGreaterOrEqual(): void;
  133585. setDepthFunctionToLess(): void;
  133586. setDepthFunctionToLessOrEqual(): void;
  133587. /**
  133588. * Enable or disable depth writing
  133589. * @param enable defines the state to set
  133590. */
  133591. setDepthWrite(enable: boolean): void;
  133592. /**
  133593. * Enable or disable color writing
  133594. * @param enable defines the state to set
  133595. */
  133596. setColorWrite(enable: boolean): void;
  133597. /**
  133598. * Gets a boolean indicating if color writing is enabled
  133599. * @returns the current color writing state
  133600. */
  133601. getColorWrite(): boolean;
  133602. /**
  133603. * Sets alpha constants used by some alpha blending modes
  133604. * @param r defines the red component
  133605. * @param g defines the green component
  133606. * @param b defines the blue component
  133607. * @param a defines the alpha component
  133608. */
  133609. setAlphaConstants(r: number, g: number, b: number, a: number): void;
  133610. /**
  133611. * Sets the current alpha mode
  133612. * @param mode defines the mode to use (one of the BABYLON.Constants.ALPHA_XXX)
  133613. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  133614. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133615. */
  133616. setAlphaMode(mode: number, noDepthWriteChange?: boolean): void;
  133617. /**
  133618. * Gets the current alpha mode
  133619. * @see https://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  133620. * @returns the current alpha mode
  133621. */
  133622. getAlphaMode(): number;
  133623. setInt(uniform: WebGLUniformLocation, int: number): boolean;
  133624. setIntArray(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133625. setIntArray2(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133626. setIntArray3(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133627. setIntArray4(uniform: WebGLUniformLocation, array: Int32Array): boolean;
  133628. setFloatArray(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133629. setFloatArray2(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133630. setFloatArray3(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133631. setFloatArray4(uniform: WebGLUniformLocation, array: Float32Array): boolean;
  133632. setArray(uniform: WebGLUniformLocation, array: number[]): boolean;
  133633. setArray2(uniform: WebGLUniformLocation, array: number[]): boolean;
  133634. setArray3(uniform: WebGLUniformLocation, array: number[]): boolean;
  133635. setArray4(uniform: WebGLUniformLocation, array: number[]): boolean;
  133636. setMatrices(uniform: WebGLUniformLocation, matrices: Float32Array): boolean;
  133637. setMatrix3x3(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133638. setMatrix2x2(uniform: WebGLUniformLocation, matrix: Float32Array): boolean;
  133639. setFloat(uniform: WebGLUniformLocation, value: number): boolean;
  133640. setFloat2(uniform: WebGLUniformLocation, x: number, y: number): boolean;
  133641. setFloat3(uniform: WebGLUniformLocation, x: number, y: number, z: number): boolean;
  133642. setFloat4(uniform: WebGLUniformLocation, x: number, y: number, z: number, w: number): boolean;
  133643. setColor3(uniform: WebGLUniformLocation, color3: Color3): boolean;
  133644. setColor4(uniform: WebGLUniformLocation, color3: Color3, alpha: number): boolean;
  133645. wipeCaches(bruteForce?: boolean): void;
  133646. _createTexture(): WebGLTexture;
  133647. protected _deleteTexture(texture: Nullable<WebGLTexture>): void;
  133648. /**
  133649. * Usually called from Texture.ts.
  133650. * Passed information to create a WebGLTexture
  133651. * @param url defines a value which contains one of the following:
  133652. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  133653. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  133654. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  133655. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  133656. * @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)
  133657. * @param scene needed for loading to the correct scene
  133658. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  133659. * @param onLoad optional callback to be called upon successful completion
  133660. * @param onError optional callback to be called upon failure
  133661. * @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
  133662. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  133663. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  133664. * @param forcedExtension defines the extension to use to pick the right loader
  133665. * @param mimeType defines an optional mime type
  133666. * @returns a InternalTexture for assignment back into BABYLON.Texture
  133667. */
  133668. 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;
  133669. /**
  133670. * Creates a cube texture
  133671. * @param rootUrl defines the url where the files to load is located
  133672. * @param scene defines the current scene
  133673. * @param files defines the list of files to load (1 per face)
  133674. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  133675. * @param onLoad defines an optional callback raised when the texture is loaded
  133676. * @param onError defines an optional callback raised if there is an issue to load the texture
  133677. * @param format defines the format of the data
  133678. * @param forcedExtension defines the extension to use to pick the right loader
  133679. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  133680. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  133681. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  133682. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  133683. * @returns the cube texture as an InternalTexture
  133684. */
  133685. 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;
  133686. createRenderTargetTexture(size: number | {
  133687. width: number;
  133688. height: number;
  133689. }, options: boolean | RenderTargetCreationOptions): NativeTexture;
  133690. updateTextureSamplingMode(samplingMode: number, texture: InternalTexture): void;
  133691. bindFramebuffer(texture: InternalTexture, faceIndex?: number, requiredWidth?: number, requiredHeight?: number, forceFullscreenViewport?: boolean): void;
  133692. unBindFramebuffer(texture: InternalTexture, disableGenerateMipMaps?: boolean, onBeforeUnbind?: () => void): void;
  133693. createDynamicVertexBuffer(data: DataArray): DataBuffer;
  133694. updateDynamicIndexBuffer(indexBuffer: DataBuffer, indices: IndicesArray, offset?: number): void;
  133695. /**
  133696. * Updates a dynamic vertex buffer.
  133697. * @param vertexBuffer the vertex buffer to update
  133698. * @param data the data used to update the vertex buffer
  133699. * @param byteOffset the byte offset of the data (optional)
  133700. * @param byteLength the byte length of the data (optional)
  133701. */
  133702. updateDynamicVertexBuffer(vertexBuffer: DataBuffer, data: DataArray, byteOffset?: number, byteLength?: number): void;
  133703. protected _setTexture(channel: number, texture: Nullable<BaseTexture>, isPartOfTextureArray?: boolean, depthStencilTexture?: boolean): boolean;
  133704. private _updateAnisotropicLevel;
  133705. private _getAddressMode;
  133706. /** @hidden */
  133707. _bindTexture(channel: number, texture: InternalTexture): void;
  133708. protected _deleteBuffer(buffer: NativeDataBuffer): void;
  133709. releaseEffects(): void;
  133710. /** @hidden */
  133711. _uploadCompressedDataToTextureDirectly(texture: InternalTexture, internalFormat: number, width: number, height: number, data: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133712. /** @hidden */
  133713. _uploadDataToTextureDirectly(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133714. /** @hidden */
  133715. _uploadArrayBufferViewToTexture(texture: InternalTexture, imageData: ArrayBufferView, faceIndex?: number, lod?: number): void;
  133716. /** @hidden */
  133717. _uploadImageToTexture(texture: InternalTexture, image: HTMLImageElement, faceIndex?: number, lod?: number): void;
  133718. private _getNativeSamplingMode;
  133719. private _getNativeTextureFormat;
  133720. private _getNativeAlphaMode;
  133721. private _getNativeAttribType;
  133722. }
  133723. }
  133724. declare module BABYLON {
  133725. /**
  133726. * Gather the list of clipboard event types as constants.
  133727. */
  133728. export class ClipboardEventTypes {
  133729. /**
  133730. * The clipboard event is fired when a copy command is active (pressed).
  133731. */
  133732. static readonly COPY: number;
  133733. /**
  133734. * The clipboard event is fired when a cut command is active (pressed).
  133735. */
  133736. static readonly CUT: number;
  133737. /**
  133738. * The clipboard event is fired when a paste command is active (pressed).
  133739. */
  133740. static readonly PASTE: number;
  133741. }
  133742. /**
  133743. * This class is used to store clipboard related info for the onClipboardObservable event.
  133744. */
  133745. export class ClipboardInfo {
  133746. /**
  133747. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133748. */
  133749. type: number;
  133750. /**
  133751. * Defines the related dom event
  133752. */
  133753. event: ClipboardEvent;
  133754. /**
  133755. *Creates an instance of ClipboardInfo.
  133756. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  133757. * @param event Defines the related dom event
  133758. */
  133759. constructor(
  133760. /**
  133761. * Defines the type of event (BABYLON.ClipboardEventTypes)
  133762. */
  133763. type: number,
  133764. /**
  133765. * Defines the related dom event
  133766. */
  133767. event: ClipboardEvent);
  133768. /**
  133769. * Get the clipboard event's type from the keycode.
  133770. * @param keyCode Defines the keyCode for the current keyboard event.
  133771. * @return {number}
  133772. */
  133773. static GetTypeFromCharacter(keyCode: number): number;
  133774. }
  133775. }
  133776. declare module BABYLON {
  133777. /**
  133778. * Google Daydream controller
  133779. */
  133780. export class DaydreamController extends WebVRController {
  133781. /**
  133782. * Base Url for the controller model.
  133783. */
  133784. static MODEL_BASE_URL: string;
  133785. /**
  133786. * File name for the controller model.
  133787. */
  133788. static MODEL_FILENAME: string;
  133789. /**
  133790. * Gamepad Id prefix used to identify Daydream Controller.
  133791. */
  133792. static readonly GAMEPAD_ID_PREFIX: string;
  133793. /**
  133794. * Creates a new DaydreamController from a gamepad
  133795. * @param vrGamepad the gamepad that the controller should be created from
  133796. */
  133797. constructor(vrGamepad: any);
  133798. /**
  133799. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133800. * @param scene scene in which to add meshes
  133801. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133802. */
  133803. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133804. /**
  133805. * Called once for each button that changed state since the last frame
  133806. * @param buttonIdx Which button index changed
  133807. * @param state New state of the button
  133808. * @param changes Which properties on the state changed since last frame
  133809. */
  133810. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133811. }
  133812. }
  133813. declare module BABYLON {
  133814. /**
  133815. * Gear VR Controller
  133816. */
  133817. export class GearVRController extends WebVRController {
  133818. /**
  133819. * Base Url for the controller model.
  133820. */
  133821. static MODEL_BASE_URL: string;
  133822. /**
  133823. * File name for the controller model.
  133824. */
  133825. static MODEL_FILENAME: string;
  133826. /**
  133827. * Gamepad Id prefix used to identify this controller.
  133828. */
  133829. static readonly GAMEPAD_ID_PREFIX: string;
  133830. private readonly _buttonIndexToObservableNameMap;
  133831. /**
  133832. * Creates a new GearVRController from a gamepad
  133833. * @param vrGamepad the gamepad that the controller should be created from
  133834. */
  133835. constructor(vrGamepad: any);
  133836. /**
  133837. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133838. * @param scene scene in which to add meshes
  133839. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133840. */
  133841. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133842. /**
  133843. * Called once for each button that changed state since the last frame
  133844. * @param buttonIdx Which button index changed
  133845. * @param state New state of the button
  133846. * @param changes Which properties on the state changed since last frame
  133847. */
  133848. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133849. }
  133850. }
  133851. declare module BABYLON {
  133852. /**
  133853. * Generic Controller
  133854. */
  133855. export class GenericController extends WebVRController {
  133856. /**
  133857. * Base Url for the controller model.
  133858. */
  133859. static readonly MODEL_BASE_URL: string;
  133860. /**
  133861. * File name for the controller model.
  133862. */
  133863. static readonly MODEL_FILENAME: string;
  133864. /**
  133865. * Creates a new GenericController from a gamepad
  133866. * @param vrGamepad the gamepad that the controller should be created from
  133867. */
  133868. constructor(vrGamepad: any);
  133869. /**
  133870. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133871. * @param scene scene in which to add meshes
  133872. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133873. */
  133874. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133875. /**
  133876. * Called once for each button that changed state since the last frame
  133877. * @param buttonIdx Which button index changed
  133878. * @param state New state of the button
  133879. * @param changes Which properties on the state changed since last frame
  133880. */
  133881. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133882. }
  133883. }
  133884. declare module BABYLON {
  133885. /**
  133886. * Oculus Touch Controller
  133887. */
  133888. export class OculusTouchController extends WebVRController {
  133889. /**
  133890. * Base Url for the controller model.
  133891. */
  133892. static MODEL_BASE_URL: string;
  133893. /**
  133894. * File name for the left controller model.
  133895. */
  133896. static MODEL_LEFT_FILENAME: string;
  133897. /**
  133898. * File name for the right controller model.
  133899. */
  133900. static MODEL_RIGHT_FILENAME: string;
  133901. /**
  133902. * Base Url for the Quest controller model.
  133903. */
  133904. static QUEST_MODEL_BASE_URL: string;
  133905. /**
  133906. * @hidden
  133907. * If the controllers are running on a device that needs the updated Quest controller models
  133908. */
  133909. static _IsQuest: boolean;
  133910. /**
  133911. * Fired when the secondary trigger on this controller is modified
  133912. */
  133913. onSecondaryTriggerStateChangedObservable: Observable<ExtendedGamepadButton>;
  133914. /**
  133915. * Fired when the thumb rest on this controller is modified
  133916. */
  133917. onThumbRestChangedObservable: Observable<ExtendedGamepadButton>;
  133918. /**
  133919. * Creates a new OculusTouchController from a gamepad
  133920. * @param vrGamepad the gamepad that the controller should be created from
  133921. */
  133922. constructor(vrGamepad: any);
  133923. /**
  133924. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133925. * @param scene scene in which to add meshes
  133926. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133927. */
  133928. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133929. /**
  133930. * Fired when the A button on this controller is modified
  133931. */
  133932. get onAButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133933. /**
  133934. * Fired when the B button on this controller is modified
  133935. */
  133936. get onBButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133937. /**
  133938. * Fired when the X button on this controller is modified
  133939. */
  133940. get onXButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133941. /**
  133942. * Fired when the Y button on this controller is modified
  133943. */
  133944. get onYButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133945. /**
  133946. * Called once for each button that changed state since the last frame
  133947. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  133948. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  133949. * 2) secondary trigger (same)
  133950. * 3) A (right) X (left), touch, pressed = value
  133951. * 4) B / Y
  133952. * 5) thumb rest
  133953. * @param buttonIdx Which button index changed
  133954. * @param state New state of the button
  133955. * @param changes Which properties on the state changed since last frame
  133956. */
  133957. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  133958. }
  133959. }
  133960. declare module BABYLON {
  133961. /**
  133962. * Vive Controller
  133963. */
  133964. export class ViveController extends WebVRController {
  133965. /**
  133966. * Base Url for the controller model.
  133967. */
  133968. static MODEL_BASE_URL: string;
  133969. /**
  133970. * File name for the controller model.
  133971. */
  133972. static MODEL_FILENAME: string;
  133973. /**
  133974. * Creates a new ViveController from a gamepad
  133975. * @param vrGamepad the gamepad that the controller should be created from
  133976. */
  133977. constructor(vrGamepad: any);
  133978. /**
  133979. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  133980. * @param scene scene in which to add meshes
  133981. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  133982. */
  133983. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void): void;
  133984. /**
  133985. * Fired when the left button on this controller is modified
  133986. */
  133987. get onLeftButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133988. /**
  133989. * Fired when the right button on this controller is modified
  133990. */
  133991. get onRightButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133992. /**
  133993. * Fired when the menu button on this controller is modified
  133994. */
  133995. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  133996. /**
  133997. * Called once for each button that changed state since the last frame
  133998. * Vive mapping:
  133999. * 0: touchpad
  134000. * 1: trigger
  134001. * 2: left AND right buttons
  134002. * 3: menu button
  134003. * @param buttonIdx Which button index changed
  134004. * @param state New state of the button
  134005. * @param changes Which properties on the state changed since last frame
  134006. */
  134007. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134008. }
  134009. }
  134010. declare module BABYLON {
  134011. /**
  134012. * Defines the WindowsMotionController object that the state of the windows motion controller
  134013. */
  134014. export class WindowsMotionController extends WebVRController {
  134015. /**
  134016. * The base url used to load the left and right controller models
  134017. */
  134018. static MODEL_BASE_URL: string;
  134019. /**
  134020. * The name of the left controller model file
  134021. */
  134022. static MODEL_LEFT_FILENAME: string;
  134023. /**
  134024. * The name of the right controller model file
  134025. */
  134026. static MODEL_RIGHT_FILENAME: string;
  134027. /**
  134028. * The controller name prefix for this controller type
  134029. */
  134030. static readonly GAMEPAD_ID_PREFIX: string;
  134031. /**
  134032. * The controller id pattern for this controller type
  134033. */
  134034. private static readonly GAMEPAD_ID_PATTERN;
  134035. private _loadedMeshInfo;
  134036. protected readonly _mapping: {
  134037. buttons: string[];
  134038. buttonMeshNames: {
  134039. trigger: string;
  134040. menu: string;
  134041. grip: string;
  134042. thumbstick: string;
  134043. trackpad: string;
  134044. };
  134045. buttonObservableNames: {
  134046. trigger: string;
  134047. menu: string;
  134048. grip: string;
  134049. thumbstick: string;
  134050. trackpad: string;
  134051. };
  134052. axisMeshNames: string[];
  134053. pointingPoseMeshName: string;
  134054. };
  134055. /**
  134056. * Fired when the trackpad on this controller is clicked
  134057. */
  134058. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  134059. /**
  134060. * Fired when the trackpad on this controller is modified
  134061. */
  134062. onTrackpadValuesChangedObservable: Observable<StickValues>;
  134063. /**
  134064. * The current x and y values of this controller's trackpad
  134065. */
  134066. trackpad: StickValues;
  134067. /**
  134068. * Creates a new WindowsMotionController from a gamepad
  134069. * @param vrGamepad the gamepad that the controller should be created from
  134070. */
  134071. constructor(vrGamepad: any);
  134072. /**
  134073. * Fired when the trigger on this controller is modified
  134074. */
  134075. get onTriggerButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134076. /**
  134077. * Fired when the menu button on this controller is modified
  134078. */
  134079. get onMenuButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134080. /**
  134081. * Fired when the grip button on this controller is modified
  134082. */
  134083. get onGripButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134084. /**
  134085. * Fired when the thumbstick button on this controller is modified
  134086. */
  134087. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134088. /**
  134089. * Fired when the touchpad button on this controller is modified
  134090. */
  134091. get onTouchpadButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134092. /**
  134093. * Fired when the touchpad values on this controller are modified
  134094. */
  134095. get onTouchpadValuesChangedObservable(): Observable<StickValues>;
  134096. protected _updateTrackpad(): void;
  134097. /**
  134098. * Called once per frame by the engine.
  134099. */
  134100. update(): void;
  134101. /**
  134102. * Called once for each button that changed state since the last frame
  134103. * @param buttonIdx Which button index changed
  134104. * @param state New state of the button
  134105. * @param changes Which properties on the state changed since last frame
  134106. */
  134107. protected _handleButtonChange(buttonIdx: number, state: ExtendedGamepadButton, changes: GamepadButtonChanges): void;
  134108. /**
  134109. * Moves the buttons on the controller mesh based on their current state
  134110. * @param buttonName the name of the button to move
  134111. * @param buttonValue the value of the button which determines the buttons new position
  134112. */
  134113. protected _lerpButtonTransform(buttonName: string, buttonValue: number): void;
  134114. /**
  134115. * Moves the axis on the controller mesh based on its current state
  134116. * @param axis the index of the axis
  134117. * @param axisValue the value of the axis which determines the meshes new position
  134118. * @hidden
  134119. */
  134120. protected _lerpAxisTransform(axis: number, axisValue: number): void;
  134121. /**
  134122. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  134123. * @param scene scene in which to add meshes
  134124. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  134125. */
  134126. initControllerMesh(scene: Scene, meshLoaded?: (mesh: AbstractMesh) => void, forceDefault?: boolean): void;
  134127. /**
  134128. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  134129. * can be transformed by button presses and axes values, based on this._mapping.
  134130. *
  134131. * @param scene scene in which the meshes exist
  134132. * @param meshes list of meshes that make up the controller model to process
  134133. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  134134. */
  134135. private processModel;
  134136. private createMeshInfo;
  134137. /**
  134138. * Gets the ray of the controller in the direction the controller is pointing
  134139. * @param length the length the resulting ray should be
  134140. * @returns a ray in the direction the controller is pointing
  134141. */
  134142. getForwardRay(length?: number): Ray;
  134143. /**
  134144. * Disposes of the controller
  134145. */
  134146. dispose(): void;
  134147. }
  134148. /**
  134149. * This class represents a new windows motion controller in XR.
  134150. */
  134151. export class XRWindowsMotionController extends WindowsMotionController {
  134152. /**
  134153. * Changing the original WIndowsMotionController mapping to fir the new mapping
  134154. */
  134155. protected readonly _mapping: {
  134156. buttons: string[];
  134157. buttonMeshNames: {
  134158. trigger: string;
  134159. menu: string;
  134160. grip: string;
  134161. thumbstick: string;
  134162. trackpad: string;
  134163. };
  134164. buttonObservableNames: {
  134165. trigger: string;
  134166. menu: string;
  134167. grip: string;
  134168. thumbstick: string;
  134169. trackpad: string;
  134170. };
  134171. axisMeshNames: string[];
  134172. pointingPoseMeshName: string;
  134173. };
  134174. /**
  134175. * Construct a new XR-Based windows motion controller
  134176. *
  134177. * @param gamepadInfo the gamepad object from the browser
  134178. */
  134179. constructor(gamepadInfo: any);
  134180. /**
  134181. * holds the thumbstick values (X,Y)
  134182. */
  134183. thumbstickValues: StickValues;
  134184. /**
  134185. * Fired when the thumbstick on this controller is clicked
  134186. */
  134187. onThumbstickStateChangedObservable: Observable<ExtendedGamepadButton>;
  134188. /**
  134189. * Fired when the thumbstick on this controller is modified
  134190. */
  134191. onThumbstickValuesChangedObservable: Observable<StickValues>;
  134192. /**
  134193. * Fired when the touchpad button on this controller is modified
  134194. */
  134195. onTrackpadChangedObservable: Observable<ExtendedGamepadButton>;
  134196. /**
  134197. * Fired when the touchpad values on this controller are modified
  134198. */
  134199. onTrackpadValuesChangedObservable: Observable<StickValues>;
  134200. /**
  134201. * Fired when the thumbstick button on this controller is modified
  134202. * here to prevent breaking changes
  134203. */
  134204. get onThumbstickButtonStateChangedObservable(): Observable<ExtendedGamepadButton>;
  134205. /**
  134206. * updating the thumbstick(!) and not the trackpad.
  134207. * This is named this way due to the difference between WebVR and XR and to avoid
  134208. * changing the parent class.
  134209. */
  134210. protected _updateTrackpad(): void;
  134211. /**
  134212. * Disposes the class with joy
  134213. */
  134214. dispose(): void;
  134215. }
  134216. }
  134217. declare module BABYLON {
  134218. /**
  134219. * Class containing static functions to help procedurally build meshes
  134220. */
  134221. export class PolyhedronBuilder {
  134222. /**
  134223. * Creates a polyhedron mesh
  134224. * * 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
  134225. * * The parameter `size` (positive float, default 1) sets the polygon size
  134226. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  134227. * * 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`
  134228. * * 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
  134229. * * 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)`)
  134230. * * 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
  134231. * * 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
  134232. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  134233. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  134234. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  134235. * @param name defines the name of the mesh
  134236. * @param options defines the options used to create the mesh
  134237. * @param scene defines the hosting scene
  134238. * @returns the polyhedron mesh
  134239. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  134240. */
  134241. static CreatePolyhedron(name: string, options: {
  134242. type?: number;
  134243. size?: number;
  134244. sizeX?: number;
  134245. sizeY?: number;
  134246. sizeZ?: number;
  134247. custom?: any;
  134248. faceUV?: Vector4[];
  134249. faceColors?: Color4[];
  134250. flat?: boolean;
  134251. updatable?: boolean;
  134252. sideOrientation?: number;
  134253. frontUVs?: Vector4;
  134254. backUVs?: Vector4;
  134255. }, scene?: Nullable<Scene>): Mesh;
  134256. }
  134257. }
  134258. declare module BABYLON {
  134259. /**
  134260. * Gizmo that enables scaling a mesh along 3 axis
  134261. */
  134262. export class ScaleGizmo extends Gizmo {
  134263. /**
  134264. * Internal gizmo used for interactions on the x axis
  134265. */
  134266. xGizmo: AxisScaleGizmo;
  134267. /**
  134268. * Internal gizmo used for interactions on the y axis
  134269. */
  134270. yGizmo: AxisScaleGizmo;
  134271. /**
  134272. * Internal gizmo used for interactions on the z axis
  134273. */
  134274. zGizmo: AxisScaleGizmo;
  134275. /**
  134276. * Internal gizmo used to scale all axis equally
  134277. */
  134278. uniformScaleGizmo: AxisScaleGizmo;
  134279. private _meshAttached;
  134280. private _nodeAttached;
  134281. private _snapDistance;
  134282. private _uniformScalingMesh;
  134283. private _octahedron;
  134284. private _sensitivity;
  134285. /** Fires an event when any of it's sub gizmos are dragged */
  134286. onDragStartObservable: Observable<unknown>;
  134287. /** Fires an event when any of it's sub gizmos are released from dragging */
  134288. onDragEndObservable: Observable<unknown>;
  134289. get attachedMesh(): Nullable<AbstractMesh>;
  134290. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134291. get attachedNode(): Nullable<Node>;
  134292. set attachedNode(node: Nullable<Node>);
  134293. /**
  134294. * True when the mouse pointer is hovering a gizmo mesh
  134295. */
  134296. get isHovered(): boolean;
  134297. /**
  134298. * Creates a ScaleGizmo
  134299. * @param gizmoLayer The utility layer the gizmo will be added to
  134300. * @param thickness display gizmo axis thickness
  134301. */
  134302. constructor(gizmoLayer?: UtilityLayerRenderer, thickness?: number);
  134303. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134304. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134305. /**
  134306. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134307. */
  134308. set snapDistance(value: number);
  134309. get snapDistance(): number;
  134310. /**
  134311. * Ratio for the scale of the gizmo (Default: 1)
  134312. */
  134313. set scaleRatio(value: number);
  134314. get scaleRatio(): number;
  134315. /**
  134316. * Sensitivity factor for dragging (Default: 1)
  134317. */
  134318. set sensitivity(value: number);
  134319. get sensitivity(): number;
  134320. /**
  134321. * Disposes of the gizmo
  134322. */
  134323. dispose(): void;
  134324. }
  134325. }
  134326. declare module BABYLON {
  134327. /**
  134328. * Single axis scale gizmo
  134329. */
  134330. export class AxisScaleGizmo extends Gizmo {
  134331. /**
  134332. * Drag behavior responsible for the gizmos dragging interactions
  134333. */
  134334. dragBehavior: PointerDragBehavior;
  134335. private _pointerObserver;
  134336. /**
  134337. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134338. */
  134339. snapDistance: number;
  134340. /**
  134341. * Event that fires each time the gizmo snaps to a new location.
  134342. * * snapDistance is the the change in distance
  134343. */
  134344. onSnapObservable: Observable<{
  134345. snapDistance: number;
  134346. }>;
  134347. /**
  134348. * If the scaling operation should be done on all axis (default: false)
  134349. */
  134350. uniformScaling: boolean;
  134351. /**
  134352. * Custom sensitivity value for the drag strength
  134353. */
  134354. sensitivity: number;
  134355. private _isEnabled;
  134356. private _parent;
  134357. private _arrow;
  134358. private _coloredMaterial;
  134359. private _hoverMaterial;
  134360. /**
  134361. * Creates an AxisScaleGizmo
  134362. * @param gizmoLayer The utility layer the gizmo will be added to
  134363. * @param dragAxis The axis which the gizmo will be able to scale on
  134364. * @param color The color of the gizmo
  134365. * @param thickness display gizmo axis thickness
  134366. */
  134367. constructor(dragAxis: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, parent?: Nullable<ScaleGizmo>, thickness?: number);
  134368. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134369. /**
  134370. * If the gizmo is enabled
  134371. */
  134372. set isEnabled(value: boolean);
  134373. get isEnabled(): boolean;
  134374. /**
  134375. * Disposes of the gizmo
  134376. */
  134377. dispose(): void;
  134378. /**
  134379. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  134380. * @param mesh The mesh to replace the default mesh of the gizmo
  134381. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  134382. */
  134383. setCustomMesh(mesh: Mesh, useGizmoMaterial?: boolean): void;
  134384. }
  134385. }
  134386. declare module BABYLON {
  134387. /**
  134388. * Bounding box gizmo
  134389. */
  134390. export class BoundingBoxGizmo extends Gizmo {
  134391. private _lineBoundingBox;
  134392. private _rotateSpheresParent;
  134393. private _scaleBoxesParent;
  134394. private _boundingDimensions;
  134395. private _renderObserver;
  134396. private _pointerObserver;
  134397. private _scaleDragSpeed;
  134398. private _tmpQuaternion;
  134399. private _tmpVector;
  134400. private _tmpRotationMatrix;
  134401. /**
  134402. * 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)
  134403. */
  134404. ignoreChildren: boolean;
  134405. /**
  134406. * 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)
  134407. */
  134408. includeChildPredicate: Nullable<(abstractMesh: AbstractMesh) => boolean>;
  134409. /**
  134410. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  134411. */
  134412. rotationSphereSize: number;
  134413. /**
  134414. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  134415. */
  134416. scaleBoxSize: number;
  134417. /**
  134418. * 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)
  134419. */
  134420. fixedDragMeshScreenSize: boolean;
  134421. /**
  134422. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  134423. */
  134424. fixedDragMeshScreenSizeDistanceFactor: number;
  134425. /**
  134426. * Fired when a rotation sphere or scale box is dragged
  134427. */
  134428. onDragStartObservable: Observable<{}>;
  134429. /**
  134430. * Fired when a scale box is dragged
  134431. */
  134432. onScaleBoxDragObservable: Observable<{}>;
  134433. /**
  134434. * Fired when a scale box drag is ended
  134435. */
  134436. onScaleBoxDragEndObservable: Observable<{}>;
  134437. /**
  134438. * Fired when a rotation sphere is dragged
  134439. */
  134440. onRotationSphereDragObservable: Observable<{}>;
  134441. /**
  134442. * Fired when a rotation sphere drag is ended
  134443. */
  134444. onRotationSphereDragEndObservable: Observable<{}>;
  134445. /**
  134446. * 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)
  134447. */
  134448. scalePivot: Nullable<Vector3>;
  134449. /**
  134450. * Mesh used as a pivot to rotate the attached node
  134451. */
  134452. private _anchorMesh;
  134453. private _existingMeshScale;
  134454. private _dragMesh;
  134455. private pointerDragBehavior;
  134456. private coloredMaterial;
  134457. private hoverColoredMaterial;
  134458. /**
  134459. * Sets the color of the bounding box gizmo
  134460. * @param color the color to set
  134461. */
  134462. setColor(color: Color3): void;
  134463. /**
  134464. * Creates an BoundingBoxGizmo
  134465. * @param gizmoLayer The utility layer the gizmo will be added to
  134466. * @param color The color of the gizmo
  134467. */
  134468. constructor(color?: Color3, gizmoLayer?: UtilityLayerRenderer);
  134469. protected _attachedNodeChanged(value: Nullable<AbstractMesh>): void;
  134470. private _selectNode;
  134471. /**
  134472. * Updates the bounding box information for the Gizmo
  134473. */
  134474. updateBoundingBox(): void;
  134475. private _updateRotationSpheres;
  134476. private _updateScaleBoxes;
  134477. /**
  134478. * Enables rotation on the specified axis and disables rotation on the others
  134479. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  134480. */
  134481. setEnabledRotationAxis(axis: string): void;
  134482. /**
  134483. * Enables/disables scaling
  134484. * @param enable if scaling should be enabled
  134485. * @param homogeneousScaling defines if scaling should only be homogeneous
  134486. */
  134487. setEnabledScaling(enable: boolean, homogeneousScaling?: boolean): void;
  134488. private _updateDummy;
  134489. /**
  134490. * Enables a pointer drag behavior on the bounding box of the gizmo
  134491. */
  134492. enableDragBehavior(): void;
  134493. /**
  134494. * Disposes of the gizmo
  134495. */
  134496. dispose(): void;
  134497. /**
  134498. * 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)
  134499. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  134500. * @returns the bounding box mesh with the passed in mesh as a child
  134501. */
  134502. static MakeNotPickableAndWrapInBoundingBox(mesh: Mesh): Mesh;
  134503. /**
  134504. * CustomMeshes are not supported by this gizmo
  134505. * @param mesh The mesh to replace the default mesh of the gizmo
  134506. */
  134507. setCustomMesh(mesh: Mesh): void;
  134508. }
  134509. }
  134510. declare module BABYLON {
  134511. /**
  134512. * Single plane rotation gizmo
  134513. */
  134514. export class PlaneRotationGizmo extends Gizmo {
  134515. /**
  134516. * Drag behavior responsible for the gizmos dragging interactions
  134517. */
  134518. dragBehavior: PointerDragBehavior;
  134519. private _pointerObserver;
  134520. /**
  134521. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  134522. */
  134523. snapDistance: number;
  134524. /**
  134525. * Event that fires each time the gizmo snaps to a new location.
  134526. * * snapDistance is the the change in distance
  134527. */
  134528. onSnapObservable: Observable<{
  134529. snapDistance: number;
  134530. }>;
  134531. private _isEnabled;
  134532. private _parent;
  134533. /**
  134534. * Creates a PlaneRotationGizmo
  134535. * @param gizmoLayer The utility layer the gizmo will be added to
  134536. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  134537. * @param color The color of the gizmo
  134538. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134539. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134540. * @param thickness display gizmo axis thickness
  134541. */
  134542. constructor(planeNormal: Vector3, color?: Color3, gizmoLayer?: UtilityLayerRenderer, tessellation?: number, parent?: Nullable<RotationGizmo>, useEulerRotation?: boolean, thickness?: number);
  134543. protected _attachedNodeChanged(value: Nullable<Node>): void;
  134544. /**
  134545. * If the gizmo is enabled
  134546. */
  134547. set isEnabled(value: boolean);
  134548. get isEnabled(): boolean;
  134549. /**
  134550. * Disposes of the gizmo
  134551. */
  134552. dispose(): void;
  134553. }
  134554. }
  134555. declare module BABYLON {
  134556. /**
  134557. * Gizmo that enables rotating a mesh along 3 axis
  134558. */
  134559. export class RotationGizmo extends Gizmo {
  134560. /**
  134561. * Internal gizmo used for interactions on the x axis
  134562. */
  134563. xGizmo: PlaneRotationGizmo;
  134564. /**
  134565. * Internal gizmo used for interactions on the y axis
  134566. */
  134567. yGizmo: PlaneRotationGizmo;
  134568. /**
  134569. * Internal gizmo used for interactions on the z axis
  134570. */
  134571. zGizmo: PlaneRotationGizmo;
  134572. /** Fires an event when any of it's sub gizmos are dragged */
  134573. onDragStartObservable: Observable<unknown>;
  134574. /** Fires an event when any of it's sub gizmos are released from dragging */
  134575. onDragEndObservable: Observable<unknown>;
  134576. private _meshAttached;
  134577. private _nodeAttached;
  134578. get attachedMesh(): Nullable<AbstractMesh>;
  134579. set attachedMesh(mesh: Nullable<AbstractMesh>);
  134580. get attachedNode(): Nullable<Node>;
  134581. set attachedNode(node: Nullable<Node>);
  134582. /**
  134583. * True when the mouse pointer is hovering a gizmo mesh
  134584. */
  134585. get isHovered(): boolean;
  134586. /**
  134587. * Creates a RotationGizmo
  134588. * @param gizmoLayer The utility layer the gizmo will be added to
  134589. * @param tessellation Amount of tessellation to be used when creating rotation circles
  134590. * @param useEulerRotation Use and update Euler angle instead of quaternion
  134591. * @param thickness display gizmo axis thickness
  134592. */
  134593. constructor(gizmoLayer?: UtilityLayerRenderer, tessellation?: number, useEulerRotation?: boolean, thickness?: number);
  134594. set updateGizmoRotationToMatchAttachedMesh(value: boolean);
  134595. get updateGizmoRotationToMatchAttachedMesh(): boolean;
  134596. /**
  134597. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  134598. */
  134599. set snapDistance(value: number);
  134600. get snapDistance(): number;
  134601. /**
  134602. * Ratio for the scale of the gizmo (Default: 1)
  134603. */
  134604. set scaleRatio(value: number);
  134605. get scaleRatio(): number;
  134606. /**
  134607. * Disposes of the gizmo
  134608. */
  134609. dispose(): void;
  134610. /**
  134611. * CustomMeshes are not supported by this gizmo
  134612. * @param mesh The mesh to replace the default mesh of the gizmo
  134613. */
  134614. setCustomMesh(mesh: Mesh): void;
  134615. }
  134616. }
  134617. declare module BABYLON {
  134618. /**
  134619. * Helps setup gizmo's in the scene to rotate/scale/position nodes
  134620. */
  134621. export class GizmoManager implements IDisposable {
  134622. private scene;
  134623. /**
  134624. * Gizmo's created by the gizmo manager, gizmo will be null until gizmo has been enabled for the first time
  134625. */
  134626. gizmos: {
  134627. positionGizmo: Nullable<PositionGizmo>;
  134628. rotationGizmo: Nullable<RotationGizmo>;
  134629. scaleGizmo: Nullable<ScaleGizmo>;
  134630. boundingBoxGizmo: Nullable<BoundingBoxGizmo>;
  134631. };
  134632. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  134633. clearGizmoOnEmptyPointerEvent: boolean;
  134634. /** Fires an event when the manager is attached to a mesh */
  134635. onAttachedToMeshObservable: Observable<Nullable<AbstractMesh>>;
  134636. /** Fires an event when the manager is attached to a node */
  134637. onAttachedToNodeObservable: Observable<Nullable<Node>>;
  134638. private _gizmosEnabled;
  134639. private _pointerObserver;
  134640. private _attachedMesh;
  134641. private _attachedNode;
  134642. private _boundingBoxColor;
  134643. private _defaultUtilityLayer;
  134644. private _defaultKeepDepthUtilityLayer;
  134645. private _thickness;
  134646. /**
  134647. * When bounding box gizmo is enabled, this can be used to track drag/end events
  134648. */
  134649. boundingBoxDragBehavior: SixDofDragBehavior;
  134650. /**
  134651. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  134652. */
  134653. attachableMeshes: Nullable<Array<AbstractMesh>>;
  134654. /**
  134655. * Array of nodes which will have the gizmo attached when a pointer selected them. If null, all nodes are attachable. (Default: null)
  134656. */
  134657. attachableNodes: Nullable<Array<Node>>;
  134658. /**
  134659. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh/attachToNode. (Default: true)
  134660. */
  134661. usePointerToAttachGizmos: boolean;
  134662. /**
  134663. * Utility layer that the bounding box gizmo belongs to
  134664. */
  134665. get keepDepthUtilityLayer(): UtilityLayerRenderer;
  134666. /**
  134667. * Utility layer that all gizmos besides bounding box belong to
  134668. */
  134669. get utilityLayer(): UtilityLayerRenderer;
  134670. /**
  134671. * True when the mouse pointer is hovering a gizmo mesh
  134672. */
  134673. get isHovered(): boolean;
  134674. /**
  134675. * Instatiates a gizmo manager
  134676. * @param scene the scene to overlay the gizmos on top of
  134677. * @param thickness display gizmo axis thickness
  134678. */
  134679. constructor(scene: Scene, thickness?: number);
  134680. /**
  134681. * Attaches a set of gizmos to the specified mesh
  134682. * @param mesh The mesh the gizmo's should be attached to
  134683. */
  134684. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  134685. /**
  134686. * Attaches a set of gizmos to the specified node
  134687. * @param node The node the gizmo's should be attached to
  134688. */
  134689. attachToNode(node: Nullable<Node>): void;
  134690. /**
  134691. * If the position gizmo is enabled
  134692. */
  134693. set positionGizmoEnabled(value: boolean);
  134694. get positionGizmoEnabled(): boolean;
  134695. /**
  134696. * If the rotation gizmo is enabled
  134697. */
  134698. set rotationGizmoEnabled(value: boolean);
  134699. get rotationGizmoEnabled(): boolean;
  134700. /**
  134701. * If the scale gizmo is enabled
  134702. */
  134703. set scaleGizmoEnabled(value: boolean);
  134704. get scaleGizmoEnabled(): boolean;
  134705. /**
  134706. * If the boundingBox gizmo is enabled
  134707. */
  134708. set boundingBoxGizmoEnabled(value: boolean);
  134709. get boundingBoxGizmoEnabled(): boolean;
  134710. /**
  134711. * Disposes of the gizmo manager
  134712. */
  134713. dispose(): void;
  134714. }
  134715. }
  134716. declare module BABYLON {
  134717. /**
  134718. * A directional light is defined by a direction (what a surprise!).
  134719. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  134720. * 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.
  134721. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134722. */
  134723. export class DirectionalLight extends ShadowLight {
  134724. private _shadowFrustumSize;
  134725. /**
  134726. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  134727. */
  134728. get shadowFrustumSize(): number;
  134729. /**
  134730. * Specifies a fix frustum size for the shadow generation.
  134731. */
  134732. set shadowFrustumSize(value: number);
  134733. private _shadowOrthoScale;
  134734. /**
  134735. * Gets the shadow projection scale against the optimal computed one.
  134736. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134737. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134738. */
  134739. get shadowOrthoScale(): number;
  134740. /**
  134741. * Sets the shadow projection scale against the optimal computed one.
  134742. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  134743. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  134744. */
  134745. set shadowOrthoScale(value: number);
  134746. /**
  134747. * Automatically compute the projection matrix to best fit (including all the casters)
  134748. * on each frame.
  134749. */
  134750. autoUpdateExtends: boolean;
  134751. /**
  134752. * Automatically compute the shadowMinZ and shadowMaxZ for the projection matrix to best fit (including all the casters)
  134753. * on each frame. autoUpdateExtends must be set to true for this to work
  134754. */
  134755. autoCalcShadowZBounds: boolean;
  134756. private _orthoLeft;
  134757. private _orthoRight;
  134758. private _orthoTop;
  134759. private _orthoBottom;
  134760. /**
  134761. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  134762. * The directional light is emitted from everywhere in the given direction.
  134763. * It can cast shadows.
  134764. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134765. * @param name The friendly name of the light
  134766. * @param direction The direction of the light
  134767. * @param scene The scene the light belongs to
  134768. */
  134769. constructor(name: string, direction: Vector3, scene: Scene);
  134770. /**
  134771. * Returns the string "DirectionalLight".
  134772. * @return The class name
  134773. */
  134774. getClassName(): string;
  134775. /**
  134776. * Returns the integer 1.
  134777. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134778. */
  134779. getTypeID(): number;
  134780. /**
  134781. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  134782. * Returns the DirectionalLight Shadow projection matrix.
  134783. */
  134784. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134785. /**
  134786. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  134787. * Returns the DirectionalLight Shadow projection matrix.
  134788. */
  134789. protected _setDefaultFixedFrustumShadowProjectionMatrix(matrix: Matrix): void;
  134790. /**
  134791. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  134792. * Returns the DirectionalLight Shadow projection matrix.
  134793. */
  134794. protected _setDefaultAutoExtendShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134795. protected _buildUniformLayout(): void;
  134796. /**
  134797. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  134798. * @param effect The effect to update
  134799. * @param lightIndex The index of the light in the effect to update
  134800. * @returns The directional light
  134801. */
  134802. transferToEffect(effect: Effect, lightIndex: string): DirectionalLight;
  134803. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): Light;
  134804. /**
  134805. * Gets the minZ used for shadow according to both the scene and the light.
  134806. *
  134807. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134808. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134809. * @param activeCamera The camera we are returning the min for
  134810. * @returns the depth min z
  134811. */
  134812. getDepthMinZ(activeCamera: Camera): number;
  134813. /**
  134814. * Gets the maxZ used for shadow according to both the scene and the light.
  134815. *
  134816. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  134817. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  134818. * @param activeCamera The camera we are returning the max for
  134819. * @returns the depth max z
  134820. */
  134821. getDepthMaxZ(activeCamera: Camera): number;
  134822. /**
  134823. * Prepares the list of defines specific to the light type.
  134824. * @param defines the list of defines
  134825. * @param lightIndex defines the index of the light for the effect
  134826. */
  134827. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  134828. }
  134829. }
  134830. declare module BABYLON {
  134831. /**
  134832. * Class containing static functions to help procedurally build meshes
  134833. */
  134834. export class HemisphereBuilder {
  134835. /**
  134836. * Creates a hemisphere mesh
  134837. * @param name defines the name of the mesh
  134838. * @param options defines the options used to create the mesh
  134839. * @param scene defines the hosting scene
  134840. * @returns the hemisphere mesh
  134841. */
  134842. static CreateHemisphere(name: string, options: {
  134843. segments?: number;
  134844. diameter?: number;
  134845. sideOrientation?: number;
  134846. }, scene: any): Mesh;
  134847. }
  134848. }
  134849. declare module BABYLON {
  134850. /**
  134851. * A spot light is defined by a position, a direction, an angle, and an exponent.
  134852. * These values define a cone of light starting from the position, emitting toward the direction.
  134853. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  134854. * and the exponent defines the speed of the decay of the light with distance (reach).
  134855. * Documentation: https://doc.babylonjs.com/babylon101/lights
  134856. */
  134857. export class SpotLight extends ShadowLight {
  134858. private _angle;
  134859. private _innerAngle;
  134860. private _cosHalfAngle;
  134861. private _lightAngleScale;
  134862. private _lightAngleOffset;
  134863. /**
  134864. * Gets the cone angle of the spot light in Radians.
  134865. */
  134866. get angle(): number;
  134867. /**
  134868. * Sets the cone angle of the spot light in Radians.
  134869. */
  134870. set angle(value: number);
  134871. /**
  134872. * Only used in gltf falloff mode, this defines the angle where
  134873. * the directional falloff will start before cutting at angle which could be seen
  134874. * as outer angle.
  134875. */
  134876. get innerAngle(): number;
  134877. /**
  134878. * Only used in gltf falloff mode, this defines the angle where
  134879. * the directional falloff will start before cutting at angle which could be seen
  134880. * as outer angle.
  134881. */
  134882. set innerAngle(value: number);
  134883. private _shadowAngleScale;
  134884. /**
  134885. * Allows scaling the angle of the light for shadow generation only.
  134886. */
  134887. get shadowAngleScale(): number;
  134888. /**
  134889. * Allows scaling the angle of the light for shadow generation only.
  134890. */
  134891. set shadowAngleScale(value: number);
  134892. /**
  134893. * The light decay speed with the distance from the emission spot.
  134894. */
  134895. exponent: number;
  134896. private _projectionTextureMatrix;
  134897. /**
  134898. * Allows reading the projecton texture
  134899. */
  134900. get projectionTextureMatrix(): Matrix;
  134901. protected _projectionTextureLightNear: number;
  134902. /**
  134903. * Gets the near clip of the Spotlight for texture projection.
  134904. */
  134905. get projectionTextureLightNear(): number;
  134906. /**
  134907. * Sets the near clip of the Spotlight for texture projection.
  134908. */
  134909. set projectionTextureLightNear(value: number);
  134910. protected _projectionTextureLightFar: number;
  134911. /**
  134912. * Gets the far clip of the Spotlight for texture projection.
  134913. */
  134914. get projectionTextureLightFar(): number;
  134915. /**
  134916. * Sets the far clip of the Spotlight for texture projection.
  134917. */
  134918. set projectionTextureLightFar(value: number);
  134919. protected _projectionTextureUpDirection: Vector3;
  134920. /**
  134921. * Gets the Up vector of the Spotlight for texture projection.
  134922. */
  134923. get projectionTextureUpDirection(): Vector3;
  134924. /**
  134925. * Sets the Up vector of the Spotlight for texture projection.
  134926. */
  134927. set projectionTextureUpDirection(value: Vector3);
  134928. private _projectionTexture;
  134929. /**
  134930. * Gets the projection texture of the light.
  134931. */
  134932. get projectionTexture(): Nullable<BaseTexture>;
  134933. /**
  134934. * Sets the projection texture of the light.
  134935. */
  134936. set projectionTexture(value: Nullable<BaseTexture>);
  134937. private _projectionTextureViewLightDirty;
  134938. private _projectionTextureProjectionLightDirty;
  134939. private _projectionTextureDirty;
  134940. private _projectionTextureViewTargetVector;
  134941. private _projectionTextureViewLightMatrix;
  134942. private _projectionTextureProjectionLightMatrix;
  134943. private _projectionTextureScalingMatrix;
  134944. /**
  134945. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  134946. * It can cast shadows.
  134947. * Documentation : https://doc.babylonjs.com/babylon101/lights
  134948. * @param name The light friendly name
  134949. * @param position The position of the spot light in the scene
  134950. * @param direction The direction of the light in the scene
  134951. * @param angle The cone angle of the light in Radians
  134952. * @param exponent The light decay speed with the distance from the emission spot
  134953. * @param scene The scene the lights belongs to
  134954. */
  134955. constructor(name: string, position: Vector3, direction: Vector3, angle: number, exponent: number, scene: Scene);
  134956. /**
  134957. * Returns the string "SpotLight".
  134958. * @returns the class name
  134959. */
  134960. getClassName(): string;
  134961. /**
  134962. * Returns the integer 2.
  134963. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  134964. */
  134965. getTypeID(): number;
  134966. /**
  134967. * Overrides the direction setter to recompute the projection texture view light Matrix.
  134968. */
  134969. protected _setDirection(value: Vector3): void;
  134970. /**
  134971. * Overrides the position setter to recompute the projection texture view light Matrix.
  134972. */
  134973. protected _setPosition(value: Vector3): void;
  134974. /**
  134975. * 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.
  134976. * Returns the SpotLight.
  134977. */
  134978. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  134979. protected _computeProjectionTextureViewLightMatrix(): void;
  134980. protected _computeProjectionTextureProjectionLightMatrix(): void;
  134981. /**
  134982. * Main function for light texture projection matrix computing.
  134983. */
  134984. protected _computeProjectionTextureMatrix(): void;
  134985. protected _buildUniformLayout(): void;
  134986. private _computeAngleValues;
  134987. /**
  134988. * Sets the passed Effect "effect" with the Light textures.
  134989. * @param effect The effect to update
  134990. * @param lightIndex The index of the light in the effect to update
  134991. * @returns The light
  134992. */
  134993. transferTexturesToEffect(effect: Effect, lightIndex: string): Light;
  134994. /**
  134995. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  134996. * @param effect The effect to update
  134997. * @param lightIndex The index of the light in the effect to update
  134998. * @returns The spot light
  134999. */
  135000. transferToEffect(effect: Effect, lightIndex: string): SpotLight;
  135001. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  135002. /**
  135003. * Disposes the light and the associated resources.
  135004. */
  135005. dispose(): void;
  135006. /**
  135007. * Prepares the list of defines specific to the light type.
  135008. * @param defines the list of defines
  135009. * @param lightIndex defines the index of the light for the effect
  135010. */
  135011. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  135012. }
  135013. }
  135014. declare module BABYLON {
  135015. /**
  135016. * Gizmo that enables viewing a light
  135017. */
  135018. export class LightGizmo extends Gizmo {
  135019. private _lightMesh;
  135020. private _material;
  135021. private _cachedPosition;
  135022. private _cachedForward;
  135023. private _attachedMeshParent;
  135024. private _pointerObserver;
  135025. /**
  135026. * Event that fires each time the gizmo is clicked
  135027. */
  135028. onClickedObservable: Observable<Light>;
  135029. /**
  135030. * Creates a LightGizmo
  135031. * @param gizmoLayer The utility layer the gizmo will be added to
  135032. */
  135033. constructor(gizmoLayer?: UtilityLayerRenderer);
  135034. private _light;
  135035. /**
  135036. * The light that the gizmo is attached to
  135037. */
  135038. set light(light: Nullable<Light>);
  135039. get light(): Nullable<Light>;
  135040. /**
  135041. * Gets the material used to render the light gizmo
  135042. */
  135043. get material(): StandardMaterial;
  135044. /**
  135045. * @hidden
  135046. * Updates the gizmo to match the attached mesh's position/rotation
  135047. */
  135048. protected _update(): void;
  135049. private static _Scale;
  135050. /**
  135051. * Creates the lines for a light mesh
  135052. */
  135053. private static _CreateLightLines;
  135054. /**
  135055. * Disposes of the light gizmo
  135056. */
  135057. dispose(): void;
  135058. private static _CreateHemisphericLightMesh;
  135059. private static _CreatePointLightMesh;
  135060. private static _CreateSpotLightMesh;
  135061. private static _CreateDirectionalLightMesh;
  135062. }
  135063. }
  135064. declare module BABYLON {
  135065. /**
  135066. * Gizmo that enables viewing a camera
  135067. */
  135068. export class CameraGizmo extends Gizmo {
  135069. private _cameraMesh;
  135070. private _cameraLinesMesh;
  135071. private _material;
  135072. private _pointerObserver;
  135073. /**
  135074. * Event that fires each time the gizmo is clicked
  135075. */
  135076. onClickedObservable: Observable<Camera>;
  135077. /**
  135078. * Creates a CameraGizmo
  135079. * @param gizmoLayer The utility layer the gizmo will be added to
  135080. */
  135081. constructor(gizmoLayer?: UtilityLayerRenderer);
  135082. private _camera;
  135083. /** Gets or sets a boolean indicating if frustum lines must be rendered (true by default)) */
  135084. get displayFrustum(): boolean;
  135085. set displayFrustum(value: boolean);
  135086. /**
  135087. * The camera that the gizmo is attached to
  135088. */
  135089. set camera(camera: Nullable<Camera>);
  135090. get camera(): Nullable<Camera>;
  135091. /**
  135092. * Gets the material used to render the camera gizmo
  135093. */
  135094. get material(): StandardMaterial;
  135095. /**
  135096. * @hidden
  135097. * Updates the gizmo to match the attached mesh's position/rotation
  135098. */
  135099. protected _update(): void;
  135100. private static _Scale;
  135101. private _invProjection;
  135102. /**
  135103. * Disposes of the camera gizmo
  135104. */
  135105. dispose(): void;
  135106. private static _CreateCameraMesh;
  135107. private static _CreateCameraFrustum;
  135108. }
  135109. }
  135110. declare module BABYLON {
  135111. /** @hidden */
  135112. export var backgroundFragmentDeclaration: {
  135113. name: string;
  135114. shader: string;
  135115. };
  135116. }
  135117. declare module BABYLON {
  135118. /** @hidden */
  135119. export var backgroundUboDeclaration: {
  135120. name: string;
  135121. shader: string;
  135122. };
  135123. }
  135124. declare module BABYLON {
  135125. /** @hidden */
  135126. export var backgroundPixelShader: {
  135127. name: string;
  135128. shader: string;
  135129. };
  135130. }
  135131. declare module BABYLON {
  135132. /** @hidden */
  135133. export var backgroundVertexDeclaration: {
  135134. name: string;
  135135. shader: string;
  135136. };
  135137. }
  135138. declare module BABYLON {
  135139. /** @hidden */
  135140. export var backgroundVertexShader: {
  135141. name: string;
  135142. shader: string;
  135143. };
  135144. }
  135145. declare module BABYLON {
  135146. /**
  135147. * Background material used to create an efficient environement around your scene.
  135148. */
  135149. export class BackgroundMaterial extends PushMaterial {
  135150. /**
  135151. * Standard reflectance value at parallel view angle.
  135152. */
  135153. static StandardReflectance0: number;
  135154. /**
  135155. * Standard reflectance value at grazing angle.
  135156. */
  135157. static StandardReflectance90: number;
  135158. protected _primaryColor: Color3;
  135159. /**
  135160. * Key light Color (multiply against the environement texture)
  135161. */
  135162. primaryColor: Color3;
  135163. protected __perceptualColor: Nullable<Color3>;
  135164. /**
  135165. * Experimental Internal Use Only.
  135166. *
  135167. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  135168. * This acts as a helper to set the primary color to a more "human friendly" value.
  135169. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  135170. * output color as close as possible from the chosen value.
  135171. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  135172. * part of lighting setup.)
  135173. */
  135174. get _perceptualColor(): Nullable<Color3>;
  135175. set _perceptualColor(value: Nullable<Color3>);
  135176. protected _primaryColorShadowLevel: float;
  135177. /**
  135178. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  135179. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  135180. */
  135181. get primaryColorShadowLevel(): float;
  135182. set primaryColorShadowLevel(value: float);
  135183. protected _primaryColorHighlightLevel: float;
  135184. /**
  135185. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  135186. * The primary color is used at the level chosen to define what the white area would look.
  135187. */
  135188. get primaryColorHighlightLevel(): float;
  135189. set primaryColorHighlightLevel(value: float);
  135190. protected _reflectionTexture: Nullable<BaseTexture>;
  135191. /**
  135192. * Reflection Texture used in the material.
  135193. * Should be author in a specific way for the best result (refer to the documentation).
  135194. */
  135195. reflectionTexture: Nullable<BaseTexture>;
  135196. protected _reflectionBlur: float;
  135197. /**
  135198. * Reflection Texture level of blur.
  135199. *
  135200. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  135201. * texture twice.
  135202. */
  135203. reflectionBlur: float;
  135204. protected _diffuseTexture: Nullable<BaseTexture>;
  135205. /**
  135206. * Diffuse Texture used in the material.
  135207. * Should be author in a specific way for the best result (refer to the documentation).
  135208. */
  135209. diffuseTexture: Nullable<BaseTexture>;
  135210. protected _shadowLights: Nullable<IShadowLight[]>;
  135211. /**
  135212. * Specify the list of lights casting shadow on the material.
  135213. * All scene shadow lights will be included if null.
  135214. */
  135215. shadowLights: Nullable<IShadowLight[]>;
  135216. protected _shadowLevel: float;
  135217. /**
  135218. * Helps adjusting the shadow to a softer level if required.
  135219. * 0 means black shadows and 1 means no shadows.
  135220. */
  135221. shadowLevel: float;
  135222. protected _sceneCenter: Vector3;
  135223. /**
  135224. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  135225. * It is usually zero but might be interesting to modify according to your setup.
  135226. */
  135227. sceneCenter: Vector3;
  135228. protected _opacityFresnel: boolean;
  135229. /**
  135230. * This helps specifying that the material is falling off to the sky box at grazing angle.
  135231. * This helps ensuring a nice transition when the camera goes under the ground.
  135232. */
  135233. opacityFresnel: boolean;
  135234. protected _reflectionFresnel: boolean;
  135235. /**
  135236. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  135237. * This helps adding a mirror texture on the ground.
  135238. */
  135239. reflectionFresnel: boolean;
  135240. protected _reflectionFalloffDistance: number;
  135241. /**
  135242. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  135243. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  135244. */
  135245. reflectionFalloffDistance: number;
  135246. protected _reflectionAmount: number;
  135247. /**
  135248. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  135249. */
  135250. reflectionAmount: number;
  135251. protected _reflectionReflectance0: number;
  135252. /**
  135253. * This specifies the weight of the reflection at grazing angle.
  135254. */
  135255. reflectionReflectance0: number;
  135256. protected _reflectionReflectance90: number;
  135257. /**
  135258. * This specifies the weight of the reflection at a perpendicular point of view.
  135259. */
  135260. reflectionReflectance90: number;
  135261. /**
  135262. * Sets the reflection reflectance fresnel values according to the default standard
  135263. * empirically know to work well :-)
  135264. */
  135265. set reflectionStandardFresnelWeight(value: number);
  135266. protected _useRGBColor: boolean;
  135267. /**
  135268. * Helps to directly use the maps channels instead of their level.
  135269. */
  135270. useRGBColor: boolean;
  135271. protected _enableNoise: boolean;
  135272. /**
  135273. * This helps reducing the banding effect that could occur on the background.
  135274. */
  135275. enableNoise: boolean;
  135276. /**
  135277. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135278. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  135279. * Recommended to be keep at 1.0 except for special cases.
  135280. */
  135281. get fovMultiplier(): number;
  135282. set fovMultiplier(value: number);
  135283. private _fovMultiplier;
  135284. /**
  135285. * Enable the FOV adjustment feature controlled by fovMultiplier.
  135286. */
  135287. useEquirectangularFOV: boolean;
  135288. private _maxSimultaneousLights;
  135289. /**
  135290. * Number of Simultaneous lights allowed on the material.
  135291. */
  135292. maxSimultaneousLights: int;
  135293. private _shadowOnly;
  135294. /**
  135295. * Make the material only render shadows
  135296. */
  135297. shadowOnly: boolean;
  135298. /**
  135299. * Default configuration related to image processing available in the Background Material.
  135300. */
  135301. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  135302. /**
  135303. * Keep track of the image processing observer to allow dispose and replace.
  135304. */
  135305. private _imageProcessingObserver;
  135306. /**
  135307. * Attaches a new image processing configuration to the PBR Material.
  135308. * @param configuration (if null the scene configuration will be use)
  135309. */
  135310. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  135311. /**
  135312. * Gets the image processing configuration used either in this material.
  135313. */
  135314. get imageProcessingConfiguration(): Nullable<ImageProcessingConfiguration>;
  135315. /**
  135316. * Sets the Default image processing configuration used either in the this material.
  135317. *
  135318. * If sets to null, the scene one is in use.
  135319. */
  135320. set imageProcessingConfiguration(value: Nullable<ImageProcessingConfiguration>);
  135321. /**
  135322. * Gets wether the color curves effect is enabled.
  135323. */
  135324. get cameraColorCurvesEnabled(): boolean;
  135325. /**
  135326. * Sets wether the color curves effect is enabled.
  135327. */
  135328. set cameraColorCurvesEnabled(value: boolean);
  135329. /**
  135330. * Gets wether the color grading effect is enabled.
  135331. */
  135332. get cameraColorGradingEnabled(): boolean;
  135333. /**
  135334. * Gets wether the color grading effect is enabled.
  135335. */
  135336. set cameraColorGradingEnabled(value: boolean);
  135337. /**
  135338. * Gets wether tonemapping is enabled or not.
  135339. */
  135340. get cameraToneMappingEnabled(): boolean;
  135341. /**
  135342. * Sets wether tonemapping is enabled or not
  135343. */
  135344. set cameraToneMappingEnabled(value: boolean);
  135345. /**
  135346. * The camera exposure used on this material.
  135347. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135348. * This corresponds to a photographic exposure.
  135349. */
  135350. get cameraExposure(): float;
  135351. /**
  135352. * The camera exposure used on this material.
  135353. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  135354. * This corresponds to a photographic exposure.
  135355. */
  135356. set cameraExposure(value: float);
  135357. /**
  135358. * Gets The camera contrast used on this material.
  135359. */
  135360. get cameraContrast(): float;
  135361. /**
  135362. * Sets The camera contrast used on this material.
  135363. */
  135364. set cameraContrast(value: float);
  135365. /**
  135366. * Gets the Color Grading 2D Lookup Texture.
  135367. */
  135368. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  135369. /**
  135370. * Sets the Color Grading 2D Lookup Texture.
  135371. */
  135372. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  135373. /**
  135374. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135375. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135376. * 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;
  135377. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135378. */
  135379. get cameraColorCurves(): Nullable<ColorCurves>;
  135380. /**
  135381. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  135382. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  135383. * 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;
  135384. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  135385. */
  135386. set cameraColorCurves(value: Nullable<ColorCurves>);
  135387. /**
  135388. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  135389. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  135390. */
  135391. switchToBGR: boolean;
  135392. private _renderTargets;
  135393. private _reflectionControls;
  135394. private _white;
  135395. private _primaryShadowColor;
  135396. private _primaryHighlightColor;
  135397. /**
  135398. * Instantiates a Background Material in the given scene
  135399. * @param name The friendly name of the material
  135400. * @param scene The scene to add the material to
  135401. */
  135402. constructor(name: string, scene: Scene);
  135403. /**
  135404. * Gets a boolean indicating that current material needs to register RTT
  135405. */
  135406. get hasRenderTargetTextures(): boolean;
  135407. /**
  135408. * The entire material has been created in order to prevent overdraw.
  135409. * @returns false
  135410. */
  135411. needAlphaTesting(): boolean;
  135412. /**
  135413. * The entire material has been created in order to prevent overdraw.
  135414. * @returns true if blending is enable
  135415. */
  135416. needAlphaBlending(): boolean;
  135417. /**
  135418. * Checks wether the material is ready to be rendered for a given mesh.
  135419. * @param mesh The mesh to render
  135420. * @param subMesh The submesh to check against
  135421. * @param useInstances Specify wether or not the material is used with instances
  135422. * @returns true if all the dependencies are ready (Textures, Effects...)
  135423. */
  135424. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  135425. /**
  135426. * Compute the primary color according to the chosen perceptual color.
  135427. */
  135428. private _computePrimaryColorFromPerceptualColor;
  135429. /**
  135430. * Compute the highlights and shadow colors according to their chosen levels.
  135431. */
  135432. private _computePrimaryColors;
  135433. /**
  135434. * Build the uniform buffer used in the material.
  135435. */
  135436. buildUniformLayout(): void;
  135437. /**
  135438. * Unbind the material.
  135439. */
  135440. unbind(): void;
  135441. /**
  135442. * Bind only the world matrix to the material.
  135443. * @param world The world matrix to bind.
  135444. */
  135445. bindOnlyWorldMatrix(world: Matrix): void;
  135446. /**
  135447. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  135448. * @param world The world matrix to bind.
  135449. * @param subMesh The submesh to bind for.
  135450. */
  135451. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  135452. /**
  135453. * Checks to see if a texture is used in the material.
  135454. * @param texture - Base texture to use.
  135455. * @returns - Boolean specifying if a texture is used in the material.
  135456. */
  135457. hasTexture(texture: BaseTexture): boolean;
  135458. /**
  135459. * Dispose the material.
  135460. * @param forceDisposeEffect Force disposal of the associated effect.
  135461. * @param forceDisposeTextures Force disposal of the associated textures.
  135462. */
  135463. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  135464. /**
  135465. * Clones the material.
  135466. * @param name The cloned name.
  135467. * @returns The cloned material.
  135468. */
  135469. clone(name: string): BackgroundMaterial;
  135470. /**
  135471. * Serializes the current material to its JSON representation.
  135472. * @returns The JSON representation.
  135473. */
  135474. serialize(): any;
  135475. /**
  135476. * Gets the class name of the material
  135477. * @returns "BackgroundMaterial"
  135478. */
  135479. getClassName(): string;
  135480. /**
  135481. * Parse a JSON input to create back a background material.
  135482. * @param source The JSON data to parse
  135483. * @param scene The scene to create the parsed material in
  135484. * @param rootUrl The root url of the assets the material depends upon
  135485. * @returns the instantiated BackgroundMaterial.
  135486. */
  135487. static Parse(source: any, scene: Scene, rootUrl: string): BackgroundMaterial;
  135488. }
  135489. }
  135490. declare module BABYLON {
  135491. /**
  135492. * Represents the different options available during the creation of
  135493. * a Environment helper.
  135494. *
  135495. * This can control the default ground, skybox and image processing setup of your scene.
  135496. */
  135497. export interface IEnvironmentHelperOptions {
  135498. /**
  135499. * Specifies whether or not to create a ground.
  135500. * True by default.
  135501. */
  135502. createGround: boolean;
  135503. /**
  135504. * Specifies the ground size.
  135505. * 15 by default.
  135506. */
  135507. groundSize: number;
  135508. /**
  135509. * The texture used on the ground for the main color.
  135510. * Comes from the BabylonJS CDN by default.
  135511. *
  135512. * Remarks: Can be either a texture or a url.
  135513. */
  135514. groundTexture: string | BaseTexture;
  135515. /**
  135516. * The color mixed in the ground texture by default.
  135517. * BabylonJS clearColor by default.
  135518. */
  135519. groundColor: Color3;
  135520. /**
  135521. * Specifies the ground opacity.
  135522. * 1 by default.
  135523. */
  135524. groundOpacity: number;
  135525. /**
  135526. * Enables the ground to receive shadows.
  135527. * True by default.
  135528. */
  135529. enableGroundShadow: boolean;
  135530. /**
  135531. * Helps preventing the shadow to be fully black on the ground.
  135532. * 0.5 by default.
  135533. */
  135534. groundShadowLevel: number;
  135535. /**
  135536. * Creates a mirror texture attach to the ground.
  135537. * false by default.
  135538. */
  135539. enableGroundMirror: boolean;
  135540. /**
  135541. * Specifies the ground mirror size ratio.
  135542. * 0.3 by default as the default kernel is 64.
  135543. */
  135544. groundMirrorSizeRatio: number;
  135545. /**
  135546. * Specifies the ground mirror blur kernel size.
  135547. * 64 by default.
  135548. */
  135549. groundMirrorBlurKernel: number;
  135550. /**
  135551. * Specifies the ground mirror visibility amount.
  135552. * 1 by default
  135553. */
  135554. groundMirrorAmount: number;
  135555. /**
  135556. * Specifies the ground mirror reflectance weight.
  135557. * This uses the standard weight of the background material to setup the fresnel effect
  135558. * of the mirror.
  135559. * 1 by default.
  135560. */
  135561. groundMirrorFresnelWeight: number;
  135562. /**
  135563. * Specifies the ground mirror Falloff distance.
  135564. * This can helps reducing the size of the reflection.
  135565. * 0 by Default.
  135566. */
  135567. groundMirrorFallOffDistance: number;
  135568. /**
  135569. * Specifies the ground mirror texture type.
  135570. * Unsigned Int by Default.
  135571. */
  135572. groundMirrorTextureType: number;
  135573. /**
  135574. * Specifies a bias applied to the ground vertical position to prevent z-fighting with
  135575. * the shown objects.
  135576. */
  135577. groundYBias: number;
  135578. /**
  135579. * Specifies whether or not to create a skybox.
  135580. * True by default.
  135581. */
  135582. createSkybox: boolean;
  135583. /**
  135584. * Specifies the skybox size.
  135585. * 20 by default.
  135586. */
  135587. skyboxSize: number;
  135588. /**
  135589. * The texture used on the skybox for the main color.
  135590. * Comes from the BabylonJS CDN by default.
  135591. *
  135592. * Remarks: Can be either a texture or a url.
  135593. */
  135594. skyboxTexture: string | BaseTexture;
  135595. /**
  135596. * The color mixed in the skybox texture by default.
  135597. * BabylonJS clearColor by default.
  135598. */
  135599. skyboxColor: Color3;
  135600. /**
  135601. * The background rotation around the Y axis of the scene.
  135602. * This helps aligning the key lights of your scene with the background.
  135603. * 0 by default.
  135604. */
  135605. backgroundYRotation: number;
  135606. /**
  135607. * Compute automatically the size of the elements to best fit with the scene.
  135608. */
  135609. sizeAuto: boolean;
  135610. /**
  135611. * Default position of the rootMesh if autoSize is not true.
  135612. */
  135613. rootPosition: Vector3;
  135614. /**
  135615. * Sets up the image processing in the scene.
  135616. * true by default.
  135617. */
  135618. setupImageProcessing: boolean;
  135619. /**
  135620. * The texture used as your environment texture in the scene.
  135621. * Comes from the BabylonJS CDN by default and in use if setupImageProcessing is true.
  135622. *
  135623. * Remarks: Can be either a texture or a url.
  135624. */
  135625. environmentTexture: string | BaseTexture;
  135626. /**
  135627. * The value of the exposure to apply to the scene.
  135628. * 0.6 by default if setupImageProcessing is true.
  135629. */
  135630. cameraExposure: number;
  135631. /**
  135632. * The value of the contrast to apply to the scene.
  135633. * 1.6 by default if setupImageProcessing is true.
  135634. */
  135635. cameraContrast: number;
  135636. /**
  135637. * Specifies whether or not tonemapping should be enabled in the scene.
  135638. * true by default if setupImageProcessing is true.
  135639. */
  135640. toneMappingEnabled: boolean;
  135641. }
  135642. /**
  135643. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  135644. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  135645. * It also helps with the default setup of your imageProcessing configuration.
  135646. */
  135647. export class EnvironmentHelper {
  135648. /**
  135649. * Default ground texture URL.
  135650. */
  135651. private static _groundTextureCDNUrl;
  135652. /**
  135653. * Default skybox texture URL.
  135654. */
  135655. private static _skyboxTextureCDNUrl;
  135656. /**
  135657. * Default environment texture URL.
  135658. */
  135659. private static _environmentTextureCDNUrl;
  135660. /**
  135661. * Creates the default options for the helper.
  135662. */
  135663. private static _getDefaultOptions;
  135664. private _rootMesh;
  135665. /**
  135666. * Gets the root mesh created by the helper.
  135667. */
  135668. get rootMesh(): Mesh;
  135669. private _skybox;
  135670. /**
  135671. * Gets the skybox created by the helper.
  135672. */
  135673. get skybox(): Nullable<Mesh>;
  135674. private _skyboxTexture;
  135675. /**
  135676. * Gets the skybox texture created by the helper.
  135677. */
  135678. get skyboxTexture(): Nullable<BaseTexture>;
  135679. private _skyboxMaterial;
  135680. /**
  135681. * Gets the skybox material created by the helper.
  135682. */
  135683. get skyboxMaterial(): Nullable<BackgroundMaterial>;
  135684. private _ground;
  135685. /**
  135686. * Gets the ground mesh created by the helper.
  135687. */
  135688. get ground(): Nullable<Mesh>;
  135689. private _groundTexture;
  135690. /**
  135691. * Gets the ground texture created by the helper.
  135692. */
  135693. get groundTexture(): Nullable<BaseTexture>;
  135694. private _groundMirror;
  135695. /**
  135696. * Gets the ground mirror created by the helper.
  135697. */
  135698. get groundMirror(): Nullable<MirrorTexture>;
  135699. /**
  135700. * Gets the ground mirror render list to helps pushing the meshes
  135701. * you wish in the ground reflection.
  135702. */
  135703. get groundMirrorRenderList(): Nullable<AbstractMesh[]>;
  135704. private _groundMaterial;
  135705. /**
  135706. * Gets the ground material created by the helper.
  135707. */
  135708. get groundMaterial(): Nullable<BackgroundMaterial>;
  135709. /**
  135710. * Stores the creation options.
  135711. */
  135712. private readonly _scene;
  135713. private _options;
  135714. /**
  135715. * This observable will be notified with any error during the creation of the environment,
  135716. * mainly texture creation errors.
  135717. */
  135718. onErrorObservable: Observable<{
  135719. message?: string;
  135720. exception?: any;
  135721. }>;
  135722. /**
  135723. * constructor
  135724. * @param options Defines the options we want to customize the helper
  135725. * @param scene The scene to add the material to
  135726. */
  135727. constructor(options: Partial<IEnvironmentHelperOptions>, scene: Scene);
  135728. /**
  135729. * Updates the background according to the new options
  135730. * @param options
  135731. */
  135732. updateOptions(options: Partial<IEnvironmentHelperOptions>): void;
  135733. /**
  135734. * Sets the primary color of all the available elements.
  135735. * @param color the main color to affect to the ground and the background
  135736. */
  135737. setMainColor(color: Color3): void;
  135738. /**
  135739. * Setup the image processing according to the specified options.
  135740. */
  135741. private _setupImageProcessing;
  135742. /**
  135743. * Setup the environment texture according to the specified options.
  135744. */
  135745. private _setupEnvironmentTexture;
  135746. /**
  135747. * Setup the background according to the specified options.
  135748. */
  135749. private _setupBackground;
  135750. /**
  135751. * Get the scene sizes according to the setup.
  135752. */
  135753. private _getSceneSize;
  135754. /**
  135755. * Setup the ground according to the specified options.
  135756. */
  135757. private _setupGround;
  135758. /**
  135759. * Setup the ground material according to the specified options.
  135760. */
  135761. private _setupGroundMaterial;
  135762. /**
  135763. * Setup the ground diffuse texture according to the specified options.
  135764. */
  135765. private _setupGroundDiffuseTexture;
  135766. /**
  135767. * Setup the ground mirror texture according to the specified options.
  135768. */
  135769. private _setupGroundMirrorTexture;
  135770. /**
  135771. * Setup the ground to receive the mirror texture.
  135772. */
  135773. private _setupMirrorInGroundMaterial;
  135774. /**
  135775. * Setup the skybox according to the specified options.
  135776. */
  135777. private _setupSkybox;
  135778. /**
  135779. * Setup the skybox material according to the specified options.
  135780. */
  135781. private _setupSkyboxMaterial;
  135782. /**
  135783. * Setup the skybox reflection texture according to the specified options.
  135784. */
  135785. private _setupSkyboxReflectionTexture;
  135786. private _errorHandler;
  135787. /**
  135788. * Dispose all the elements created by the Helper.
  135789. */
  135790. dispose(): void;
  135791. }
  135792. }
  135793. declare module BABYLON {
  135794. /**
  135795. * Display a 360/180 degree texture on an approximately spherical surface, useful for VR applications or skyboxes.
  135796. * As a subclass of TransformNode, this allow parenting to the camera or multiple textures with different locations in the scene.
  135797. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135798. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135799. */
  135800. export abstract class TextureDome<T extends Texture> extends TransformNode {
  135801. protected onError: Nullable<(message?: string, exception?: any) => void>;
  135802. /**
  135803. * Define the source as a Monoscopic panoramic 360/180.
  135804. */
  135805. static readonly MODE_MONOSCOPIC: number;
  135806. /**
  135807. * Define the source as a Stereoscopic TopBottom/OverUnder panoramic 360/180.
  135808. */
  135809. static readonly MODE_TOPBOTTOM: number;
  135810. /**
  135811. * Define the source as a Stereoscopic Side by Side panoramic 360/180.
  135812. */
  135813. static readonly MODE_SIDEBYSIDE: number;
  135814. private _halfDome;
  135815. protected _useDirectMapping: boolean;
  135816. /**
  135817. * The texture being displayed on the sphere
  135818. */
  135819. protected _texture: T;
  135820. /**
  135821. * Gets the texture being displayed on the sphere
  135822. */
  135823. get texture(): T;
  135824. /**
  135825. * Sets the texture being displayed on the sphere
  135826. */
  135827. set texture(newTexture: T);
  135828. /**
  135829. * The skybox material
  135830. */
  135831. protected _material: BackgroundMaterial;
  135832. /**
  135833. * The surface used for the dome
  135834. */
  135835. protected _mesh: Mesh;
  135836. /**
  135837. * Gets the mesh used for the dome.
  135838. */
  135839. get mesh(): Mesh;
  135840. /**
  135841. * A mesh that will be used to mask the back of the dome in case it is a 180 degree movie.
  135842. */
  135843. private _halfDomeMask;
  135844. /**
  135845. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  135846. * Also see the options.resolution property.
  135847. */
  135848. get fovMultiplier(): number;
  135849. set fovMultiplier(value: number);
  135850. protected _textureMode: number;
  135851. /**
  135852. * Gets or set the current texture mode for the texture. It can be:
  135853. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135854. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135855. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135856. */
  135857. get textureMode(): number;
  135858. /**
  135859. * Sets the current texture mode for the texture. It can be:
  135860. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135861. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135862. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135863. */
  135864. set textureMode(value: number);
  135865. /**
  135866. * Is it a 180 degrees dome (half dome) or 360 texture (full dome)
  135867. */
  135868. get halfDome(): boolean;
  135869. /**
  135870. * Set the halfDome mode. If set, only the front (180 degrees) will be displayed and the back will be blacked out.
  135871. */
  135872. set halfDome(enabled: boolean);
  135873. /**
  135874. * Oberserver used in Stereoscopic VR Mode.
  135875. */
  135876. private _onBeforeCameraRenderObserver;
  135877. /**
  135878. * Observable raised when an error occured while loading the 360 image
  135879. */
  135880. onLoadErrorObservable: Observable<string>;
  135881. /**
  135882. * Create an instance of this class and pass through the parameters to the relevant classes- Texture, StandardMaterial, and Mesh.
  135883. * @param name Element's name, child elements will append suffixes for their own names.
  135884. * @param textureUrlOrElement defines the url(s) or the (video) HTML element to use
  135885. * @param options An object containing optional or exposed sub element properties
  135886. */
  135887. constructor(name: string, textureUrlOrElement: string | string[] | HTMLVideoElement, options: {
  135888. resolution?: number;
  135889. clickToPlay?: boolean;
  135890. autoPlay?: boolean;
  135891. loop?: boolean;
  135892. size?: number;
  135893. poster?: string;
  135894. faceForward?: boolean;
  135895. useDirectMapping?: boolean;
  135896. halfDomeMode?: boolean;
  135897. }, scene: Scene, onError?: Nullable<(message?: string, exception?: any) => void>);
  135898. protected abstract _initTexture(urlsOrElement: string | string[] | HTMLElement, scene: Scene, options: any): T;
  135899. protected _changeTextureMode(value: number): void;
  135900. /**
  135901. * Releases resources associated with this node.
  135902. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  135903. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  135904. */
  135905. dispose(doNotRecurse?: boolean, disposeMaterialAndTextures?: boolean): void;
  135906. }
  135907. }
  135908. declare module BABYLON {
  135909. /**
  135910. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  135911. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  135912. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  135913. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  135914. */
  135915. export class PhotoDome extends TextureDome<Texture> {
  135916. /**
  135917. * Define the image as a Monoscopic panoramic 360 image.
  135918. */
  135919. static readonly MODE_MONOSCOPIC: number;
  135920. /**
  135921. * Define the image as a Stereoscopic TopBottom/OverUnder panoramic 360 image.
  135922. */
  135923. static readonly MODE_TOPBOTTOM: number;
  135924. /**
  135925. * Define the image as a Stereoscopic Side by Side panoramic 360 image.
  135926. */
  135927. static readonly MODE_SIDEBYSIDE: number;
  135928. /**
  135929. * Gets or sets the texture being displayed on the sphere
  135930. */
  135931. get photoTexture(): Texture;
  135932. /**
  135933. * sets the texture being displayed on the sphere
  135934. */
  135935. set photoTexture(value: Texture);
  135936. /**
  135937. * Gets the current video mode for the video. It can be:
  135938. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135939. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135940. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135941. */
  135942. get imageMode(): number;
  135943. /**
  135944. * Sets the current video mode for the video. It can be:
  135945. * * TextureDome.MODE_MONOSCOPIC : Define the texture source as a Monoscopic panoramic 360.
  135946. * * TextureDome.MODE_TOPBOTTOM : Define the texture source as a Stereoscopic TopBottom/OverUnder panoramic 360.
  135947. * * TextureDome.MODE_SIDEBYSIDE : Define the texture source as a Stereoscopic Side by Side panoramic 360.
  135948. */
  135949. set imageMode(value: number);
  135950. protected _initTexture(urlsOrElement: string, scene: Scene, options: any): Texture;
  135951. }
  135952. }
  135953. declare module BABYLON {
  135954. /**
  135955. * Class used to host RGBD texture specific utilities
  135956. */
  135957. export class RGBDTextureTools {
  135958. /**
  135959. * Expand the RGBD Texture from RGBD to Half Float if possible.
  135960. * @param texture the texture to expand.
  135961. */
  135962. static ExpandRGBDTexture(texture: Texture): void;
  135963. }
  135964. }
  135965. declare module BABYLON {
  135966. /**
  135967. * Class used to host texture specific utilities
  135968. */
  135969. export class BRDFTextureTools {
  135970. /**
  135971. * Prevents texture cache collision
  135972. */
  135973. private static _instanceNumber;
  135974. /**
  135975. * Gets a default environment BRDF for MS-BRDF Height Correlated BRDF
  135976. * @param scene defines the hosting scene
  135977. * @returns the environment BRDF texture
  135978. */
  135979. static GetEnvironmentBRDFTexture(scene: Scene): BaseTexture;
  135980. private static _environmentBRDFBase64Texture;
  135981. }
  135982. }
  135983. declare module BABYLON {
  135984. /**
  135985. * @hidden
  135986. */
  135987. export interface IMaterialClearCoatDefines {
  135988. CLEARCOAT: boolean;
  135989. CLEARCOAT_DEFAULTIOR: boolean;
  135990. CLEARCOAT_TEXTURE: boolean;
  135991. CLEARCOAT_TEXTUREDIRECTUV: number;
  135992. CLEARCOAT_BUMP: boolean;
  135993. CLEARCOAT_BUMPDIRECTUV: number;
  135994. CLEARCOAT_REMAP_F0: boolean;
  135995. CLEARCOAT_TINT: boolean;
  135996. CLEARCOAT_TINT_TEXTURE: boolean;
  135997. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  135998. /** @hidden */
  135999. _areTexturesDirty: boolean;
  136000. }
  136001. /**
  136002. * Define the code related to the clear coat parameters of the pbr material.
  136003. */
  136004. export class PBRClearCoatConfiguration {
  136005. /**
  136006. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  136007. * The default fits with a polyurethane material.
  136008. */
  136009. private static readonly _DefaultIndexOfRefraction;
  136010. private _isEnabled;
  136011. /**
  136012. * Defines if the clear coat is enabled in the material.
  136013. */
  136014. isEnabled: boolean;
  136015. /**
  136016. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  136017. */
  136018. intensity: number;
  136019. /**
  136020. * Defines the clear coat layer roughness.
  136021. */
  136022. roughness: number;
  136023. private _indexOfRefraction;
  136024. /**
  136025. * Defines the index of refraction of the clear coat.
  136026. * This defaults to 1.5 corresponding to a 0.04 f0 or a 4% reflectance at normal incidence
  136027. * The default fits with a polyurethane material.
  136028. * Changing the default value is more performance intensive.
  136029. */
  136030. indexOfRefraction: number;
  136031. private _texture;
  136032. /**
  136033. * Stores the clear coat values in a texture.
  136034. */
  136035. texture: Nullable<BaseTexture>;
  136036. private _remapF0OnInterfaceChange;
  136037. /**
  136038. * Defines if the F0 value should be remapped to account for the interface change in the material.
  136039. */
  136040. remapF0OnInterfaceChange: boolean;
  136041. private _bumpTexture;
  136042. /**
  136043. * Define the clear coat specific bump texture.
  136044. */
  136045. bumpTexture: Nullable<BaseTexture>;
  136046. private _isTintEnabled;
  136047. /**
  136048. * Defines if the clear coat tint is enabled in the material.
  136049. */
  136050. isTintEnabled: boolean;
  136051. /**
  136052. * Defines the clear coat tint of the material.
  136053. * This is only use if tint is enabled
  136054. */
  136055. tintColor: Color3;
  136056. /**
  136057. * Defines the distance at which the tint color should be found in the
  136058. * clear coat media.
  136059. * This is only use if tint is enabled
  136060. */
  136061. tintColorAtDistance: number;
  136062. /**
  136063. * Defines the clear coat layer thickness.
  136064. * This is only use if tint is enabled
  136065. */
  136066. tintThickness: number;
  136067. private _tintTexture;
  136068. /**
  136069. * Stores the clear tint values in a texture.
  136070. * rgb is tint
  136071. * a is a thickness factor
  136072. */
  136073. tintTexture: Nullable<BaseTexture>;
  136074. /** @hidden */
  136075. private _internalMarkAllSubMeshesAsTexturesDirty;
  136076. /** @hidden */
  136077. _markAllSubMeshesAsTexturesDirty(): void;
  136078. /**
  136079. * Instantiate a new istance of clear coat configuration.
  136080. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136081. */
  136082. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136083. /**
  136084. * Gets wehter the submesh is ready to be used or not.
  136085. * @param defines the list of "defines" to update.
  136086. * @param scene defines the scene the material belongs to.
  136087. * @param engine defines the engine the material belongs to.
  136088. * @param disableBumpMap defines wether the material disables bump or not.
  136089. * @returns - boolean indicating that the submesh is ready or not.
  136090. */
  136091. isReadyForSubMesh(defines: IMaterialClearCoatDefines, scene: Scene, engine: Engine, disableBumpMap: boolean): boolean;
  136092. /**
  136093. * Checks to see if a texture is used in the material.
  136094. * @param defines the list of "defines" to update.
  136095. * @param scene defines the scene to the material belongs to.
  136096. */
  136097. prepareDefines(defines: IMaterialClearCoatDefines, scene: Scene): void;
  136098. /**
  136099. * Binds the material data.
  136100. * @param uniformBuffer defines the Uniform buffer to fill in.
  136101. * @param scene defines the scene the material belongs to.
  136102. * @param engine defines the engine the material belongs to.
  136103. * @param disableBumpMap defines wether the material disables bump or not.
  136104. * @param isFrozen defines wether the material is frozen or not.
  136105. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  136106. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  136107. */
  136108. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, disableBumpMap: boolean, isFrozen: boolean, invertNormalMapX: boolean, invertNormalMapY: boolean): void;
  136109. /**
  136110. * Checks to see if a texture is used in the material.
  136111. * @param texture - Base texture to use.
  136112. * @returns - Boolean specifying if a texture is used in the material.
  136113. */
  136114. hasTexture(texture: BaseTexture): boolean;
  136115. /**
  136116. * Returns an array of the actively used textures.
  136117. * @param activeTextures Array of BaseTextures
  136118. */
  136119. getActiveTextures(activeTextures: BaseTexture[]): void;
  136120. /**
  136121. * Returns the animatable textures.
  136122. * @param animatables Array of animatable textures.
  136123. */
  136124. getAnimatables(animatables: IAnimatable[]): void;
  136125. /**
  136126. * Disposes the resources of the material.
  136127. * @param forceDisposeTextures - Forces the disposal of all textures.
  136128. */
  136129. dispose(forceDisposeTextures?: boolean): void;
  136130. /**
  136131. * Get the current class name of the texture useful for serialization or dynamic coding.
  136132. * @returns "PBRClearCoatConfiguration"
  136133. */
  136134. getClassName(): string;
  136135. /**
  136136. * Add fallbacks to the effect fallbacks list.
  136137. * @param defines defines the Base texture to use.
  136138. * @param fallbacks defines the current fallback list.
  136139. * @param currentRank defines the current fallback rank.
  136140. * @returns the new fallback rank.
  136141. */
  136142. static AddFallbacks(defines: IMaterialClearCoatDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136143. /**
  136144. * Add the required uniforms to the current list.
  136145. * @param uniforms defines the current uniform list.
  136146. */
  136147. static AddUniforms(uniforms: string[]): void;
  136148. /**
  136149. * Add the required samplers to the current list.
  136150. * @param samplers defines the current sampler list.
  136151. */
  136152. static AddSamplers(samplers: string[]): void;
  136153. /**
  136154. * Add the required uniforms to the current buffer.
  136155. * @param uniformBuffer defines the current uniform buffer.
  136156. */
  136157. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136158. /**
  136159. * Makes a duplicate of the current configuration into another one.
  136160. * @param clearCoatConfiguration define the config where to copy the info
  136161. */
  136162. copyTo(clearCoatConfiguration: PBRClearCoatConfiguration): void;
  136163. /**
  136164. * Serializes this clear coat configuration.
  136165. * @returns - An object with the serialized config.
  136166. */
  136167. serialize(): any;
  136168. /**
  136169. * Parses a anisotropy Configuration from a serialized object.
  136170. * @param source - Serialized object.
  136171. * @param scene Defines the scene we are parsing for
  136172. * @param rootUrl Defines the rootUrl to load from
  136173. */
  136174. parse(source: any, scene: Scene, rootUrl: string): void;
  136175. }
  136176. }
  136177. declare module BABYLON {
  136178. /**
  136179. * @hidden
  136180. */
  136181. export interface IMaterialAnisotropicDefines {
  136182. ANISOTROPIC: boolean;
  136183. ANISOTROPIC_TEXTURE: boolean;
  136184. ANISOTROPIC_TEXTUREDIRECTUV: number;
  136185. MAINUV1: boolean;
  136186. _areTexturesDirty: boolean;
  136187. _needUVs: boolean;
  136188. }
  136189. /**
  136190. * Define the code related to the anisotropic parameters of the pbr material.
  136191. */
  136192. export class PBRAnisotropicConfiguration {
  136193. private _isEnabled;
  136194. /**
  136195. * Defines if the anisotropy is enabled in the material.
  136196. */
  136197. isEnabled: boolean;
  136198. /**
  136199. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  136200. */
  136201. intensity: number;
  136202. /**
  136203. * Defines if the effect is along the tangents, bitangents or in between.
  136204. * By default, the effect is "strectching" the highlights along the tangents.
  136205. */
  136206. direction: Vector2;
  136207. private _texture;
  136208. /**
  136209. * Stores the anisotropy values in a texture.
  136210. * rg is direction (like normal from -1 to 1)
  136211. * b is a intensity
  136212. */
  136213. texture: Nullable<BaseTexture>;
  136214. /** @hidden */
  136215. private _internalMarkAllSubMeshesAsTexturesDirty;
  136216. /** @hidden */
  136217. _markAllSubMeshesAsTexturesDirty(): void;
  136218. /**
  136219. * Instantiate a new istance of anisotropy configuration.
  136220. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136221. */
  136222. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136223. /**
  136224. * Specifies that the submesh is ready to be used.
  136225. * @param defines the list of "defines" to update.
  136226. * @param scene defines the scene the material belongs to.
  136227. * @returns - boolean indicating that the submesh is ready or not.
  136228. */
  136229. isReadyForSubMesh(defines: IMaterialAnisotropicDefines, scene: Scene): boolean;
  136230. /**
  136231. * Checks to see if a texture is used in the material.
  136232. * @param defines the list of "defines" to update.
  136233. * @param mesh the mesh we are preparing the defines for.
  136234. * @param scene defines the scene the material belongs to.
  136235. */
  136236. prepareDefines(defines: IMaterialAnisotropicDefines, mesh: AbstractMesh, scene: Scene): void;
  136237. /**
  136238. * Binds the material data.
  136239. * @param uniformBuffer defines the Uniform buffer to fill in.
  136240. * @param scene defines the scene the material belongs to.
  136241. * @param isFrozen defines wether the material is frozen or not.
  136242. */
  136243. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136244. /**
  136245. * Checks to see if a texture is used in the material.
  136246. * @param texture - Base texture to use.
  136247. * @returns - Boolean specifying if a texture is used in the material.
  136248. */
  136249. hasTexture(texture: BaseTexture): boolean;
  136250. /**
  136251. * Returns an array of the actively used textures.
  136252. * @param activeTextures Array of BaseTextures
  136253. */
  136254. getActiveTextures(activeTextures: BaseTexture[]): void;
  136255. /**
  136256. * Returns the animatable textures.
  136257. * @param animatables Array of animatable textures.
  136258. */
  136259. getAnimatables(animatables: IAnimatable[]): void;
  136260. /**
  136261. * Disposes the resources of the material.
  136262. * @param forceDisposeTextures - Forces the disposal of all textures.
  136263. */
  136264. dispose(forceDisposeTextures?: boolean): void;
  136265. /**
  136266. * Get the current class name of the texture useful for serialization or dynamic coding.
  136267. * @returns "PBRAnisotropicConfiguration"
  136268. */
  136269. getClassName(): string;
  136270. /**
  136271. * Add fallbacks to the effect fallbacks list.
  136272. * @param defines defines the Base texture to use.
  136273. * @param fallbacks defines the current fallback list.
  136274. * @param currentRank defines the current fallback rank.
  136275. * @returns the new fallback rank.
  136276. */
  136277. static AddFallbacks(defines: IMaterialAnisotropicDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136278. /**
  136279. * Add the required uniforms to the current list.
  136280. * @param uniforms defines the current uniform list.
  136281. */
  136282. static AddUniforms(uniforms: string[]): void;
  136283. /**
  136284. * Add the required uniforms to the current buffer.
  136285. * @param uniformBuffer defines the current uniform buffer.
  136286. */
  136287. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136288. /**
  136289. * Add the required samplers to the current list.
  136290. * @param samplers defines the current sampler list.
  136291. */
  136292. static AddSamplers(samplers: string[]): void;
  136293. /**
  136294. * Makes a duplicate of the current configuration into another one.
  136295. * @param anisotropicConfiguration define the config where to copy the info
  136296. */
  136297. copyTo(anisotropicConfiguration: PBRAnisotropicConfiguration): void;
  136298. /**
  136299. * Serializes this anisotropy configuration.
  136300. * @returns - An object with the serialized config.
  136301. */
  136302. serialize(): any;
  136303. /**
  136304. * Parses a anisotropy Configuration from a serialized object.
  136305. * @param source - Serialized object.
  136306. * @param scene Defines the scene we are parsing for
  136307. * @param rootUrl Defines the rootUrl to load from
  136308. */
  136309. parse(source: any, scene: Scene, rootUrl: string): void;
  136310. }
  136311. }
  136312. declare module BABYLON {
  136313. /**
  136314. * @hidden
  136315. */
  136316. export interface IMaterialBRDFDefines {
  136317. BRDF_V_HEIGHT_CORRELATED: boolean;
  136318. MS_BRDF_ENERGY_CONSERVATION: boolean;
  136319. SPHERICAL_HARMONICS: boolean;
  136320. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  136321. /** @hidden */
  136322. _areMiscDirty: boolean;
  136323. }
  136324. /**
  136325. * Define the code related to the BRDF parameters of the pbr material.
  136326. */
  136327. export class PBRBRDFConfiguration {
  136328. /**
  136329. * Default value used for the energy conservation.
  136330. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136331. */
  136332. static DEFAULT_USE_ENERGY_CONSERVATION: boolean;
  136333. /**
  136334. * Default value used for the Smith Visibility Height Correlated mode.
  136335. * This should only be changed to adapt to the type of texture in scene.environmentBRDFTexture.
  136336. */
  136337. static DEFAULT_USE_SMITH_VISIBILITY_HEIGHT_CORRELATED: boolean;
  136338. /**
  136339. * Default value used for the IBL diffuse part.
  136340. * This can help switching back to the polynomials mode globally which is a tiny bit
  136341. * less GPU intensive at the drawback of a lower quality.
  136342. */
  136343. static DEFAULT_USE_SPHERICAL_HARMONICS: boolean;
  136344. /**
  136345. * Default value used for activating energy conservation for the specular workflow.
  136346. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136347. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136348. */
  136349. static DEFAULT_USE_SPECULAR_GLOSSINESS_INPUT_ENERGY_CONSERVATION: boolean;
  136350. private _useEnergyConservation;
  136351. /**
  136352. * Defines if the material uses energy conservation.
  136353. */
  136354. useEnergyConservation: boolean;
  136355. private _useSmithVisibilityHeightCorrelated;
  136356. /**
  136357. * LEGACY Mode set to false
  136358. * Defines if the material uses height smith correlated visibility term.
  136359. * If you intent to not use our default BRDF, you need to load a separate BRDF Texture for the PBR
  136360. * You can either load https://assets.babylonjs.com/environments/uncorrelatedBRDF.png
  136361. * or https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds to have more precision
  136362. * Not relying on height correlated will also disable energy conservation.
  136363. */
  136364. useSmithVisibilityHeightCorrelated: boolean;
  136365. private _useSphericalHarmonics;
  136366. /**
  136367. * LEGACY Mode set to false
  136368. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  136369. * diffuse part of the IBL.
  136370. * The harmonics despite a tiny bigger cost has been proven to provide closer results
  136371. * to the ground truth.
  136372. */
  136373. useSphericalHarmonics: boolean;
  136374. private _useSpecularGlossinessInputEnergyConservation;
  136375. /**
  136376. * Defines if the material uses energy conservation, when the specular workflow is active.
  136377. * If activated, the albedo color is multiplied with (1. - maxChannel(specular color)).
  136378. * If deactivated, a material is only physically plausible, when (albedo color + specular color) < 1.
  136379. * In the deactivated case, the material author has to ensure energy conservation, for a physically plausible rendering.
  136380. */
  136381. useSpecularGlossinessInputEnergyConservation: boolean;
  136382. /** @hidden */
  136383. private _internalMarkAllSubMeshesAsMiscDirty;
  136384. /** @hidden */
  136385. _markAllSubMeshesAsMiscDirty(): void;
  136386. /**
  136387. * Instantiate a new istance of clear coat configuration.
  136388. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  136389. */
  136390. constructor(markAllSubMeshesAsMiscDirty: () => void);
  136391. /**
  136392. * Checks to see if a texture is used in the material.
  136393. * @param defines the list of "defines" to update.
  136394. */
  136395. prepareDefines(defines: IMaterialBRDFDefines): void;
  136396. /**
  136397. * Get the current class name of the texture useful for serialization or dynamic coding.
  136398. * @returns "PBRClearCoatConfiguration"
  136399. */
  136400. getClassName(): string;
  136401. /**
  136402. * Makes a duplicate of the current configuration into another one.
  136403. * @param brdfConfiguration define the config where to copy the info
  136404. */
  136405. copyTo(brdfConfiguration: PBRBRDFConfiguration): void;
  136406. /**
  136407. * Serializes this BRDF configuration.
  136408. * @returns - An object with the serialized config.
  136409. */
  136410. serialize(): any;
  136411. /**
  136412. * Parses a anisotropy Configuration from a serialized object.
  136413. * @param source - Serialized object.
  136414. * @param scene Defines the scene we are parsing for
  136415. * @param rootUrl Defines the rootUrl to load from
  136416. */
  136417. parse(source: any, scene: Scene, rootUrl: string): void;
  136418. }
  136419. }
  136420. declare module BABYLON {
  136421. /**
  136422. * @hidden
  136423. */
  136424. export interface IMaterialSheenDefines {
  136425. SHEEN: boolean;
  136426. SHEEN_TEXTURE: boolean;
  136427. SHEEN_TEXTUREDIRECTUV: number;
  136428. SHEEN_LINKWITHALBEDO: boolean;
  136429. SHEEN_ROUGHNESS: boolean;
  136430. SHEEN_ALBEDOSCALING: boolean;
  136431. /** @hidden */
  136432. _areTexturesDirty: boolean;
  136433. }
  136434. /**
  136435. * Define the code related to the Sheen parameters of the pbr material.
  136436. */
  136437. export class PBRSheenConfiguration {
  136438. private _isEnabled;
  136439. /**
  136440. * Defines if the material uses sheen.
  136441. */
  136442. isEnabled: boolean;
  136443. private _linkSheenWithAlbedo;
  136444. /**
  136445. * Defines if the sheen is linked to the sheen color.
  136446. */
  136447. linkSheenWithAlbedo: boolean;
  136448. /**
  136449. * Defines the sheen intensity.
  136450. */
  136451. intensity: number;
  136452. /**
  136453. * Defines the sheen color.
  136454. */
  136455. color: Color3;
  136456. private _texture;
  136457. /**
  136458. * Stores the sheen tint values in a texture.
  136459. * rgb is tint
  136460. * a is a intensity or roughness if roughness has been defined
  136461. */
  136462. texture: Nullable<BaseTexture>;
  136463. private _roughness;
  136464. /**
  136465. * Defines the sheen roughness.
  136466. * It is not taken into account if linkSheenWithAlbedo is true.
  136467. * To stay backward compatible, material roughness is used instead if sheen roughness = null
  136468. */
  136469. roughness: Nullable<number>;
  136470. private _albedoScaling;
  136471. /**
  136472. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  136473. * It allows the strength of the sheen effect to not depend on the base color of the material,
  136474. * making it easier to setup and tweak the effect
  136475. */
  136476. albedoScaling: boolean;
  136477. /** @hidden */
  136478. private _internalMarkAllSubMeshesAsTexturesDirty;
  136479. /** @hidden */
  136480. _markAllSubMeshesAsTexturesDirty(): void;
  136481. /**
  136482. * Instantiate a new istance of clear coat configuration.
  136483. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136484. */
  136485. constructor(markAllSubMeshesAsTexturesDirty: () => void);
  136486. /**
  136487. * Specifies that the submesh is ready to be used.
  136488. * @param defines the list of "defines" to update.
  136489. * @param scene defines the scene the material belongs to.
  136490. * @returns - boolean indicating that the submesh is ready or not.
  136491. */
  136492. isReadyForSubMesh(defines: IMaterialSheenDefines, scene: Scene): boolean;
  136493. /**
  136494. * Checks to see if a texture is used in the material.
  136495. * @param defines the list of "defines" to update.
  136496. * @param scene defines the scene the material belongs to.
  136497. */
  136498. prepareDefines(defines: IMaterialSheenDefines, scene: Scene): void;
  136499. /**
  136500. * Binds the material data.
  136501. * @param uniformBuffer defines the Uniform buffer to fill in.
  136502. * @param scene defines the scene the material belongs to.
  136503. * @param isFrozen defines wether the material is frozen or not.
  136504. */
  136505. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, isFrozen: boolean): void;
  136506. /**
  136507. * Checks to see if a texture is used in the material.
  136508. * @param texture - Base texture to use.
  136509. * @returns - Boolean specifying if a texture is used in the material.
  136510. */
  136511. hasTexture(texture: BaseTexture): boolean;
  136512. /**
  136513. * Returns an array of the actively used textures.
  136514. * @param activeTextures Array of BaseTextures
  136515. */
  136516. getActiveTextures(activeTextures: BaseTexture[]): void;
  136517. /**
  136518. * Returns the animatable textures.
  136519. * @param animatables Array of animatable textures.
  136520. */
  136521. getAnimatables(animatables: IAnimatable[]): void;
  136522. /**
  136523. * Disposes the resources of the material.
  136524. * @param forceDisposeTextures - Forces the disposal of all textures.
  136525. */
  136526. dispose(forceDisposeTextures?: boolean): void;
  136527. /**
  136528. * Get the current class name of the texture useful for serialization or dynamic coding.
  136529. * @returns "PBRSheenConfiguration"
  136530. */
  136531. getClassName(): string;
  136532. /**
  136533. * Add fallbacks to the effect fallbacks list.
  136534. * @param defines defines the Base texture to use.
  136535. * @param fallbacks defines the current fallback list.
  136536. * @param currentRank defines the current fallback rank.
  136537. * @returns the new fallback rank.
  136538. */
  136539. static AddFallbacks(defines: IMaterialSheenDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136540. /**
  136541. * Add the required uniforms to the current list.
  136542. * @param uniforms defines the current uniform list.
  136543. */
  136544. static AddUniforms(uniforms: string[]): void;
  136545. /**
  136546. * Add the required uniforms to the current buffer.
  136547. * @param uniformBuffer defines the current uniform buffer.
  136548. */
  136549. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136550. /**
  136551. * Add the required samplers to the current list.
  136552. * @param samplers defines the current sampler list.
  136553. */
  136554. static AddSamplers(samplers: string[]): void;
  136555. /**
  136556. * Makes a duplicate of the current configuration into another one.
  136557. * @param sheenConfiguration define the config where to copy the info
  136558. */
  136559. copyTo(sheenConfiguration: PBRSheenConfiguration): void;
  136560. /**
  136561. * Serializes this BRDF configuration.
  136562. * @returns - An object with the serialized config.
  136563. */
  136564. serialize(): any;
  136565. /**
  136566. * Parses a anisotropy Configuration from a serialized object.
  136567. * @param source - Serialized object.
  136568. * @param scene Defines the scene we are parsing for
  136569. * @param rootUrl Defines the rootUrl to load from
  136570. */
  136571. parse(source: any, scene: Scene, rootUrl: string): void;
  136572. }
  136573. }
  136574. declare module BABYLON {
  136575. /**
  136576. * @hidden
  136577. */
  136578. export interface IMaterialSubSurfaceDefines {
  136579. SUBSURFACE: boolean;
  136580. SS_REFRACTION: boolean;
  136581. SS_TRANSLUCENCY: boolean;
  136582. SS_SCATTERING: boolean;
  136583. SS_THICKNESSANDMASK_TEXTURE: boolean;
  136584. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  136585. SS_REFRACTIONMAP_3D: boolean;
  136586. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  136587. SS_LODINREFRACTIONALPHA: boolean;
  136588. SS_GAMMAREFRACTION: boolean;
  136589. SS_RGBDREFRACTION: boolean;
  136590. SS_LINEARSPECULARREFRACTION: boolean;
  136591. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  136592. SS_ALBEDOFORREFRACTIONTINT: boolean;
  136593. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  136594. /** @hidden */
  136595. _areTexturesDirty: boolean;
  136596. }
  136597. /**
  136598. * Define the code related to the sub surface parameters of the pbr material.
  136599. */
  136600. export class PBRSubSurfaceConfiguration {
  136601. private _isRefractionEnabled;
  136602. /**
  136603. * Defines if the refraction is enabled in the material.
  136604. */
  136605. isRefractionEnabled: boolean;
  136606. private _isTranslucencyEnabled;
  136607. /**
  136608. * Defines if the translucency is enabled in the material.
  136609. */
  136610. isTranslucencyEnabled: boolean;
  136611. private _isScatteringEnabled;
  136612. /**
  136613. * Defines if the sub surface scattering is enabled in the material.
  136614. */
  136615. isScatteringEnabled: boolean;
  136616. private _scatteringDiffusionProfileIndex;
  136617. /**
  136618. * Diffusion profile for subsurface scattering.
  136619. * Useful for better scattering in the skins or foliages.
  136620. */
  136621. get scatteringDiffusionProfile(): Nullable<Color3>;
  136622. set scatteringDiffusionProfile(c: Nullable<Color3>);
  136623. /**
  136624. * Defines the refraction intensity of the material.
  136625. * The refraction when enabled replaces the Diffuse part of the material.
  136626. * The intensity helps transitionning between diffuse and refraction.
  136627. */
  136628. refractionIntensity: number;
  136629. /**
  136630. * Defines the translucency intensity of the material.
  136631. * When translucency has been enabled, this defines how much of the "translucency"
  136632. * is addded to the diffuse part of the material.
  136633. */
  136634. translucencyIntensity: number;
  136635. /**
  136636. * When enabled, transparent surfaces will be tinted with the albedo colour (independent of thickness)
  136637. */
  136638. useAlbedoToTintRefraction: boolean;
  136639. private _thicknessTexture;
  136640. /**
  136641. * Stores the average thickness of a mesh in a texture (The texture is holding the values linearly).
  136642. * The red channel of the texture should contain the thickness remapped between 0 and 1.
  136643. * 0 would mean minimumThickness
  136644. * 1 would mean maximumThickness
  136645. * The other channels might be use as a mask to vary the different effects intensity.
  136646. */
  136647. thicknessTexture: Nullable<BaseTexture>;
  136648. private _refractionTexture;
  136649. /**
  136650. * Defines the texture to use for refraction.
  136651. */
  136652. refractionTexture: Nullable<BaseTexture>;
  136653. private _indexOfRefraction;
  136654. /**
  136655. * Index of refraction of the material base layer.
  136656. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136657. *
  136658. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  136659. *
  136660. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  136661. */
  136662. indexOfRefraction: number;
  136663. private _volumeIndexOfRefraction;
  136664. /**
  136665. * Index of refraction of the material's volume.
  136666. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  136667. *
  136668. * This ONLY impacts refraction. If not provided or given a non-valid value,
  136669. * the volume will use the same IOR as the surface.
  136670. */
  136671. get volumeIndexOfRefraction(): number;
  136672. set volumeIndexOfRefraction(value: number);
  136673. private _invertRefractionY;
  136674. /**
  136675. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  136676. */
  136677. invertRefractionY: boolean;
  136678. private _linkRefractionWithTransparency;
  136679. /**
  136680. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  136681. * Materials half opaque for instance using refraction could benefit from this control.
  136682. */
  136683. linkRefractionWithTransparency: boolean;
  136684. /**
  136685. * Defines the minimum thickness stored in the thickness map.
  136686. * If no thickness map is defined, this value will be used to simulate thickness.
  136687. */
  136688. minimumThickness: number;
  136689. /**
  136690. * Defines the maximum thickness stored in the thickness map.
  136691. */
  136692. maximumThickness: number;
  136693. /**
  136694. * Defines the volume tint of the material.
  136695. * This is used for both translucency and scattering.
  136696. */
  136697. tintColor: Color3;
  136698. /**
  136699. * Defines the distance at which the tint color should be found in the media.
  136700. * This is used for refraction only.
  136701. */
  136702. tintColorAtDistance: number;
  136703. /**
  136704. * Defines how far each channel transmit through the media.
  136705. * It is defined as a color to simplify it selection.
  136706. */
  136707. diffusionDistance: Color3;
  136708. private _useMaskFromThicknessTexture;
  136709. /**
  136710. * Stores the intensity of the different subsurface effects in the thickness texture.
  136711. * * the green channel is the translucency intensity.
  136712. * * the blue channel is the scattering intensity.
  136713. * * the alpha channel is the refraction intensity.
  136714. */
  136715. useMaskFromThicknessTexture: boolean;
  136716. private _scene;
  136717. /** @hidden */
  136718. private _internalMarkAllSubMeshesAsTexturesDirty;
  136719. private _internalMarkScenePrePassDirty;
  136720. /** @hidden */
  136721. _markAllSubMeshesAsTexturesDirty(): void;
  136722. /** @hidden */
  136723. _markScenePrePassDirty(): void;
  136724. /**
  136725. * Instantiate a new istance of sub surface configuration.
  136726. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  136727. * @param markScenePrePassDirty Callback to flag the scene as prepass dirty
  136728. * @param scene The scene
  136729. */
  136730. constructor(markAllSubMeshesAsTexturesDirty: () => void, markScenePrePassDirty: () => void, scene: Scene);
  136731. /**
  136732. * Gets wehter the submesh is ready to be used or not.
  136733. * @param defines the list of "defines" to update.
  136734. * @param scene defines the scene the material belongs to.
  136735. * @returns - boolean indicating that the submesh is ready or not.
  136736. */
  136737. isReadyForSubMesh(defines: IMaterialSubSurfaceDefines, scene: Scene): boolean;
  136738. /**
  136739. * Checks to see if a texture is used in the material.
  136740. * @param defines the list of "defines" to update.
  136741. * @param scene defines the scene to the material belongs to.
  136742. */
  136743. prepareDefines(defines: IMaterialSubSurfaceDefines, scene: Scene): void;
  136744. /**
  136745. * Binds the material data.
  136746. * @param uniformBuffer defines the Uniform buffer to fill in.
  136747. * @param scene defines the scene the material belongs to.
  136748. * @param engine defines the engine the material belongs to.
  136749. * @param isFrozen defines whether the material is frozen or not.
  136750. * @param lodBasedMicrosurface defines whether the material relies on lod based microsurface or not.
  136751. * @param realTimeFiltering defines whether the textures should be filtered on the fly.
  136752. */
  136753. bindForSubMesh(uniformBuffer: UniformBuffer, scene: Scene, engine: Engine, isFrozen: boolean, lodBasedMicrosurface: boolean, realTimeFiltering: boolean): void;
  136754. /**
  136755. * Unbinds the material from the mesh.
  136756. * @param activeEffect defines the effect that should be unbound from.
  136757. * @returns true if unbound, otherwise false
  136758. */
  136759. unbind(activeEffect: Effect): boolean;
  136760. /**
  136761. * Returns the texture used for refraction or null if none is used.
  136762. * @param scene defines the scene the material belongs to.
  136763. * @returns - Refraction texture if present. If no refraction texture and refraction
  136764. * is linked with transparency, returns environment texture. Otherwise, returns null.
  136765. */
  136766. private _getRefractionTexture;
  136767. /**
  136768. * Returns true if alpha blending should be disabled.
  136769. */
  136770. get disableAlphaBlending(): boolean;
  136771. /**
  136772. * Fills the list of render target textures.
  136773. * @param renderTargets the list of render targets to update
  136774. */
  136775. fillRenderTargetTextures(renderTargets: SmartArray<RenderTargetTexture>): void;
  136776. /**
  136777. * Checks to see if a texture is used in the material.
  136778. * @param texture - Base texture to use.
  136779. * @returns - Boolean specifying if a texture is used in the material.
  136780. */
  136781. hasTexture(texture: BaseTexture): boolean;
  136782. /**
  136783. * Gets a boolean indicating that current material needs to register RTT
  136784. * @returns true if this uses a render target otherwise false.
  136785. */
  136786. hasRenderTargetTextures(): boolean;
  136787. /**
  136788. * Returns an array of the actively used textures.
  136789. * @param activeTextures Array of BaseTextures
  136790. */
  136791. getActiveTextures(activeTextures: BaseTexture[]): void;
  136792. /**
  136793. * Returns the animatable textures.
  136794. * @param animatables Array of animatable textures.
  136795. */
  136796. getAnimatables(animatables: IAnimatable[]): void;
  136797. /**
  136798. * Disposes the resources of the material.
  136799. * @param forceDisposeTextures - Forces the disposal of all textures.
  136800. */
  136801. dispose(forceDisposeTextures?: boolean): void;
  136802. /**
  136803. * Get the current class name of the texture useful for serialization or dynamic coding.
  136804. * @returns "PBRSubSurfaceConfiguration"
  136805. */
  136806. getClassName(): string;
  136807. /**
  136808. * Add fallbacks to the effect fallbacks list.
  136809. * @param defines defines the Base texture to use.
  136810. * @param fallbacks defines the current fallback list.
  136811. * @param currentRank defines the current fallback rank.
  136812. * @returns the new fallback rank.
  136813. */
  136814. static AddFallbacks(defines: IMaterialSubSurfaceDefines, fallbacks: EffectFallbacks, currentRank: number): number;
  136815. /**
  136816. * Add the required uniforms to the current list.
  136817. * @param uniforms defines the current uniform list.
  136818. */
  136819. static AddUniforms(uniforms: string[]): void;
  136820. /**
  136821. * Add the required samplers to the current list.
  136822. * @param samplers defines the current sampler list.
  136823. */
  136824. static AddSamplers(samplers: string[]): void;
  136825. /**
  136826. * Add the required uniforms to the current buffer.
  136827. * @param uniformBuffer defines the current uniform buffer.
  136828. */
  136829. static PrepareUniformBuffer(uniformBuffer: UniformBuffer): void;
  136830. /**
  136831. * Makes a duplicate of the current configuration into another one.
  136832. * @param configuration define the config where to copy the info
  136833. */
  136834. copyTo(configuration: PBRSubSurfaceConfiguration): void;
  136835. /**
  136836. * Serializes this Sub Surface configuration.
  136837. * @returns - An object with the serialized config.
  136838. */
  136839. serialize(): any;
  136840. /**
  136841. * Parses a anisotropy Configuration from a serialized object.
  136842. * @param source - Serialized object.
  136843. * @param scene Defines the scene we are parsing for
  136844. * @param rootUrl Defines the rootUrl to load from
  136845. */
  136846. parse(source: any, scene: Scene, rootUrl: string): void;
  136847. }
  136848. }
  136849. declare module BABYLON {
  136850. /** @hidden */
  136851. export var pbrFragmentDeclaration: {
  136852. name: string;
  136853. shader: string;
  136854. };
  136855. }
  136856. declare module BABYLON {
  136857. /** @hidden */
  136858. export var pbrUboDeclaration: {
  136859. name: string;
  136860. shader: string;
  136861. };
  136862. }
  136863. declare module BABYLON {
  136864. /** @hidden */
  136865. export var pbrFragmentExtraDeclaration: {
  136866. name: string;
  136867. shader: string;
  136868. };
  136869. }
  136870. declare module BABYLON {
  136871. /** @hidden */
  136872. export var pbrFragmentSamplersDeclaration: {
  136873. name: string;
  136874. shader: string;
  136875. };
  136876. }
  136877. declare module BABYLON {
  136878. /** @hidden */
  136879. export var subSurfaceScatteringFunctions: {
  136880. name: string;
  136881. shader: string;
  136882. };
  136883. }
  136884. declare module BABYLON {
  136885. /** @hidden */
  136886. export var importanceSampling: {
  136887. name: string;
  136888. shader: string;
  136889. };
  136890. }
  136891. declare module BABYLON {
  136892. /** @hidden */
  136893. export var pbrHelperFunctions: {
  136894. name: string;
  136895. shader: string;
  136896. };
  136897. }
  136898. declare module BABYLON {
  136899. /** @hidden */
  136900. export var harmonicsFunctions: {
  136901. name: string;
  136902. shader: string;
  136903. };
  136904. }
  136905. declare module BABYLON {
  136906. /** @hidden */
  136907. export var pbrDirectLightingSetupFunctions: {
  136908. name: string;
  136909. shader: string;
  136910. };
  136911. }
  136912. declare module BABYLON {
  136913. /** @hidden */
  136914. export var pbrDirectLightingFalloffFunctions: {
  136915. name: string;
  136916. shader: string;
  136917. };
  136918. }
  136919. declare module BABYLON {
  136920. /** @hidden */
  136921. export var pbrBRDFFunctions: {
  136922. name: string;
  136923. shader: string;
  136924. };
  136925. }
  136926. declare module BABYLON {
  136927. /** @hidden */
  136928. export var hdrFilteringFunctions: {
  136929. name: string;
  136930. shader: string;
  136931. };
  136932. }
  136933. declare module BABYLON {
  136934. /** @hidden */
  136935. export var pbrDirectLightingFunctions: {
  136936. name: string;
  136937. shader: string;
  136938. };
  136939. }
  136940. declare module BABYLON {
  136941. /** @hidden */
  136942. export var pbrIBLFunctions: {
  136943. name: string;
  136944. shader: string;
  136945. };
  136946. }
  136947. declare module BABYLON {
  136948. /** @hidden */
  136949. export var pbrBlockAlbedoOpacity: {
  136950. name: string;
  136951. shader: string;
  136952. };
  136953. }
  136954. declare module BABYLON {
  136955. /** @hidden */
  136956. export var pbrBlockReflectivity: {
  136957. name: string;
  136958. shader: string;
  136959. };
  136960. }
  136961. declare module BABYLON {
  136962. /** @hidden */
  136963. export var pbrBlockAmbientOcclusion: {
  136964. name: string;
  136965. shader: string;
  136966. };
  136967. }
  136968. declare module BABYLON {
  136969. /** @hidden */
  136970. export var pbrBlockAlphaFresnel: {
  136971. name: string;
  136972. shader: string;
  136973. };
  136974. }
  136975. declare module BABYLON {
  136976. /** @hidden */
  136977. export var pbrBlockAnisotropic: {
  136978. name: string;
  136979. shader: string;
  136980. };
  136981. }
  136982. declare module BABYLON {
  136983. /** @hidden */
  136984. export var pbrBlockReflection: {
  136985. name: string;
  136986. shader: string;
  136987. };
  136988. }
  136989. declare module BABYLON {
  136990. /** @hidden */
  136991. export var pbrBlockSheen: {
  136992. name: string;
  136993. shader: string;
  136994. };
  136995. }
  136996. declare module BABYLON {
  136997. /** @hidden */
  136998. export var pbrBlockClearcoat: {
  136999. name: string;
  137000. shader: string;
  137001. };
  137002. }
  137003. declare module BABYLON {
  137004. /** @hidden */
  137005. export var pbrBlockSubSurface: {
  137006. name: string;
  137007. shader: string;
  137008. };
  137009. }
  137010. declare module BABYLON {
  137011. /** @hidden */
  137012. export var pbrBlockNormalGeometric: {
  137013. name: string;
  137014. shader: string;
  137015. };
  137016. }
  137017. declare module BABYLON {
  137018. /** @hidden */
  137019. export var pbrBlockNormalFinal: {
  137020. name: string;
  137021. shader: string;
  137022. };
  137023. }
  137024. declare module BABYLON {
  137025. /** @hidden */
  137026. export var pbrBlockLightmapInit: {
  137027. name: string;
  137028. shader: string;
  137029. };
  137030. }
  137031. declare module BABYLON {
  137032. /** @hidden */
  137033. export var pbrBlockGeometryInfo: {
  137034. name: string;
  137035. shader: string;
  137036. };
  137037. }
  137038. declare module BABYLON {
  137039. /** @hidden */
  137040. export var pbrBlockReflectance0: {
  137041. name: string;
  137042. shader: string;
  137043. };
  137044. }
  137045. declare module BABYLON {
  137046. /** @hidden */
  137047. export var pbrBlockReflectance: {
  137048. name: string;
  137049. shader: string;
  137050. };
  137051. }
  137052. declare module BABYLON {
  137053. /** @hidden */
  137054. export var pbrBlockDirectLighting: {
  137055. name: string;
  137056. shader: string;
  137057. };
  137058. }
  137059. declare module BABYLON {
  137060. /** @hidden */
  137061. export var pbrBlockFinalLitComponents: {
  137062. name: string;
  137063. shader: string;
  137064. };
  137065. }
  137066. declare module BABYLON {
  137067. /** @hidden */
  137068. export var pbrBlockFinalUnlitComponents: {
  137069. name: string;
  137070. shader: string;
  137071. };
  137072. }
  137073. declare module BABYLON {
  137074. /** @hidden */
  137075. export var pbrBlockFinalColorComposition: {
  137076. name: string;
  137077. shader: string;
  137078. };
  137079. }
  137080. declare module BABYLON {
  137081. /** @hidden */
  137082. export var pbrBlockImageProcessing: {
  137083. name: string;
  137084. shader: string;
  137085. };
  137086. }
  137087. declare module BABYLON {
  137088. /** @hidden */
  137089. export var pbrDebug: {
  137090. name: string;
  137091. shader: string;
  137092. };
  137093. }
  137094. declare module BABYLON {
  137095. /** @hidden */
  137096. export var pbrPixelShader: {
  137097. name: string;
  137098. shader: string;
  137099. };
  137100. }
  137101. declare module BABYLON {
  137102. /** @hidden */
  137103. export var pbrVertexDeclaration: {
  137104. name: string;
  137105. shader: string;
  137106. };
  137107. }
  137108. declare module BABYLON {
  137109. /** @hidden */
  137110. export var pbrVertexShader: {
  137111. name: string;
  137112. shader: string;
  137113. };
  137114. }
  137115. declare module BABYLON {
  137116. /**
  137117. * Manages the defines for the PBR Material.
  137118. * @hidden
  137119. */
  137120. export class PBRMaterialDefines extends MaterialDefines implements IImageProcessingConfigurationDefines, IMaterialClearCoatDefines, IMaterialAnisotropicDefines, IMaterialBRDFDefines, IMaterialSheenDefines, IMaterialSubSurfaceDefines, IMaterialDetailMapDefines {
  137121. PBR: boolean;
  137122. NUM_SAMPLES: string;
  137123. REALTIME_FILTERING: boolean;
  137124. MAINUV1: boolean;
  137125. MAINUV2: boolean;
  137126. UV1: boolean;
  137127. UV2: boolean;
  137128. ALBEDO: boolean;
  137129. GAMMAALBEDO: boolean;
  137130. ALBEDODIRECTUV: number;
  137131. VERTEXCOLOR: boolean;
  137132. DETAIL: boolean;
  137133. DETAILDIRECTUV: number;
  137134. DETAIL_NORMALBLENDMETHOD: number;
  137135. AMBIENT: boolean;
  137136. AMBIENTDIRECTUV: number;
  137137. AMBIENTINGRAYSCALE: boolean;
  137138. OPACITY: boolean;
  137139. VERTEXALPHA: boolean;
  137140. OPACITYDIRECTUV: number;
  137141. OPACITYRGB: boolean;
  137142. ALPHATEST: boolean;
  137143. DEPTHPREPASS: boolean;
  137144. ALPHABLEND: boolean;
  137145. ALPHAFROMALBEDO: boolean;
  137146. ALPHATESTVALUE: string;
  137147. SPECULAROVERALPHA: boolean;
  137148. RADIANCEOVERALPHA: boolean;
  137149. ALPHAFRESNEL: boolean;
  137150. LINEARALPHAFRESNEL: boolean;
  137151. PREMULTIPLYALPHA: boolean;
  137152. EMISSIVE: boolean;
  137153. EMISSIVEDIRECTUV: number;
  137154. REFLECTIVITY: boolean;
  137155. REFLECTIVITYDIRECTUV: number;
  137156. SPECULARTERM: boolean;
  137157. MICROSURFACEFROMREFLECTIVITYMAP: boolean;
  137158. MICROSURFACEAUTOMATIC: boolean;
  137159. LODBASEDMICROSFURACE: boolean;
  137160. MICROSURFACEMAP: boolean;
  137161. MICROSURFACEMAPDIRECTUV: number;
  137162. METALLICWORKFLOW: boolean;
  137163. ROUGHNESSSTOREINMETALMAPALPHA: boolean;
  137164. ROUGHNESSSTOREINMETALMAPGREEN: boolean;
  137165. METALLNESSSTOREINMETALMAPBLUE: boolean;
  137166. AOSTOREINMETALMAPRED: boolean;
  137167. METALLIC_REFLECTANCE: boolean;
  137168. METALLIC_REFLECTANCEDIRECTUV: number;
  137169. ENVIRONMENTBRDF: boolean;
  137170. ENVIRONMENTBRDF_RGBD: boolean;
  137171. NORMAL: boolean;
  137172. TANGENT: boolean;
  137173. BUMP: boolean;
  137174. BUMPDIRECTUV: number;
  137175. OBJECTSPACE_NORMALMAP: boolean;
  137176. PARALLAX: boolean;
  137177. PARALLAXOCCLUSION: boolean;
  137178. NORMALXYSCALE: boolean;
  137179. LIGHTMAP: boolean;
  137180. LIGHTMAPDIRECTUV: number;
  137181. USELIGHTMAPASSHADOWMAP: boolean;
  137182. GAMMALIGHTMAP: boolean;
  137183. RGBDLIGHTMAP: boolean;
  137184. REFLECTION: boolean;
  137185. REFLECTIONMAP_3D: boolean;
  137186. REFLECTIONMAP_SPHERICAL: boolean;
  137187. REFLECTIONMAP_PLANAR: boolean;
  137188. REFLECTIONMAP_CUBIC: boolean;
  137189. USE_LOCAL_REFLECTIONMAP_CUBIC: boolean;
  137190. REFLECTIONMAP_PROJECTION: boolean;
  137191. REFLECTIONMAP_SKYBOX: boolean;
  137192. REFLECTIONMAP_EXPLICIT: boolean;
  137193. REFLECTIONMAP_EQUIRECTANGULAR: boolean;
  137194. REFLECTIONMAP_EQUIRECTANGULAR_FIXED: boolean;
  137195. REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED: boolean;
  137196. INVERTCUBICMAP: boolean;
  137197. USESPHERICALFROMREFLECTIONMAP: boolean;
  137198. USEIRRADIANCEMAP: boolean;
  137199. SPHERICAL_HARMONICS: boolean;
  137200. USESPHERICALINVERTEX: boolean;
  137201. REFLECTIONMAP_OPPOSITEZ: boolean;
  137202. LODINREFLECTIONALPHA: boolean;
  137203. GAMMAREFLECTION: boolean;
  137204. RGBDREFLECTION: boolean;
  137205. LINEARSPECULARREFLECTION: boolean;
  137206. RADIANCEOCCLUSION: boolean;
  137207. HORIZONOCCLUSION: boolean;
  137208. INSTANCES: boolean;
  137209. THIN_INSTANCES: boolean;
  137210. PREPASS: boolean;
  137211. PREPASS_IRRADIANCE: boolean;
  137212. PREPASS_IRRADIANCE_INDEX: number;
  137213. PREPASS_ALBEDO: boolean;
  137214. PREPASS_ALBEDO_INDEX: number;
  137215. PREPASS_DEPTHNORMAL: boolean;
  137216. PREPASS_DEPTHNORMAL_INDEX: number;
  137217. PREPASS_POSITION: boolean;
  137218. PREPASS_POSITION_INDEX: number;
  137219. PREPASS_VELOCITY: boolean;
  137220. PREPASS_VELOCITY_INDEX: number;
  137221. PREPASS_REFLECTIVITY: boolean;
  137222. PREPASS_REFLECTIVITY_INDEX: number;
  137223. SCENE_MRT_COUNT: number;
  137224. NUM_BONE_INFLUENCERS: number;
  137225. BonesPerMesh: number;
  137226. BONETEXTURE: boolean;
  137227. BONES_VELOCITY_ENABLED: boolean;
  137228. NONUNIFORMSCALING: boolean;
  137229. MORPHTARGETS: boolean;
  137230. MORPHTARGETS_NORMAL: boolean;
  137231. MORPHTARGETS_TANGENT: boolean;
  137232. MORPHTARGETS_UV: boolean;
  137233. NUM_MORPH_INFLUENCERS: number;
  137234. IMAGEPROCESSING: boolean;
  137235. VIGNETTE: boolean;
  137236. VIGNETTEBLENDMODEMULTIPLY: boolean;
  137237. VIGNETTEBLENDMODEOPAQUE: boolean;
  137238. TONEMAPPING: boolean;
  137239. TONEMAPPING_ACES: boolean;
  137240. CONTRAST: boolean;
  137241. COLORCURVES: boolean;
  137242. COLORGRADING: boolean;
  137243. COLORGRADING3D: boolean;
  137244. SAMPLER3DGREENDEPTH: boolean;
  137245. SAMPLER3DBGRMAP: boolean;
  137246. IMAGEPROCESSINGPOSTPROCESS: boolean;
  137247. EXPOSURE: boolean;
  137248. MULTIVIEW: boolean;
  137249. USEPHYSICALLIGHTFALLOFF: boolean;
  137250. USEGLTFLIGHTFALLOFF: boolean;
  137251. TWOSIDEDLIGHTING: boolean;
  137252. SHADOWFLOAT: boolean;
  137253. CLIPPLANE: boolean;
  137254. CLIPPLANE2: boolean;
  137255. CLIPPLANE3: boolean;
  137256. CLIPPLANE4: boolean;
  137257. CLIPPLANE5: boolean;
  137258. CLIPPLANE6: boolean;
  137259. POINTSIZE: boolean;
  137260. FOG: boolean;
  137261. LOGARITHMICDEPTH: boolean;
  137262. FORCENORMALFORWARD: boolean;
  137263. SPECULARAA: boolean;
  137264. CLEARCOAT: boolean;
  137265. CLEARCOAT_DEFAULTIOR: boolean;
  137266. CLEARCOAT_TEXTURE: boolean;
  137267. CLEARCOAT_TEXTUREDIRECTUV: number;
  137268. CLEARCOAT_BUMP: boolean;
  137269. CLEARCOAT_BUMPDIRECTUV: number;
  137270. CLEARCOAT_REMAP_F0: boolean;
  137271. CLEARCOAT_TINT: boolean;
  137272. CLEARCOAT_TINT_TEXTURE: boolean;
  137273. CLEARCOAT_TINT_TEXTUREDIRECTUV: number;
  137274. ANISOTROPIC: boolean;
  137275. ANISOTROPIC_TEXTURE: boolean;
  137276. ANISOTROPIC_TEXTUREDIRECTUV: number;
  137277. BRDF_V_HEIGHT_CORRELATED: boolean;
  137278. MS_BRDF_ENERGY_CONSERVATION: boolean;
  137279. SPECULAR_GLOSSINESS_ENERGY_CONSERVATION: boolean;
  137280. SHEEN: boolean;
  137281. SHEEN_TEXTURE: boolean;
  137282. SHEEN_TEXTUREDIRECTUV: number;
  137283. SHEEN_LINKWITHALBEDO: boolean;
  137284. SHEEN_ROUGHNESS: boolean;
  137285. SHEEN_ALBEDOSCALING: boolean;
  137286. SUBSURFACE: boolean;
  137287. SS_REFRACTION: boolean;
  137288. SS_TRANSLUCENCY: boolean;
  137289. SS_SCATTERING: boolean;
  137290. SS_THICKNESSANDMASK_TEXTURE: boolean;
  137291. SS_THICKNESSANDMASK_TEXTUREDIRECTUV: number;
  137292. SS_REFRACTIONMAP_3D: boolean;
  137293. SS_REFRACTIONMAP_OPPOSITEZ: boolean;
  137294. SS_LODINREFRACTIONALPHA: boolean;
  137295. SS_GAMMAREFRACTION: boolean;
  137296. SS_RGBDREFRACTION: boolean;
  137297. SS_LINEARSPECULARREFRACTION: boolean;
  137298. SS_LINKREFRACTIONTOTRANSPARENCY: boolean;
  137299. SS_ALBEDOFORREFRACTIONTINT: boolean;
  137300. SS_MASK_FROM_THICKNESS_TEXTURE: boolean;
  137301. UNLIT: boolean;
  137302. DEBUGMODE: number;
  137303. /**
  137304. * Initializes the PBR Material defines.
  137305. */
  137306. constructor();
  137307. /**
  137308. * Resets the PBR Material defines.
  137309. */
  137310. reset(): void;
  137311. }
  137312. /**
  137313. * The Physically based material base class of BJS.
  137314. *
  137315. * This offers the main features of a standard PBR material.
  137316. * For more information, please refer to the documentation :
  137317. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137318. */
  137319. export abstract class PBRBaseMaterial extends PushMaterial {
  137320. /**
  137321. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137322. */
  137323. static readonly PBRMATERIAL_OPAQUE: number;
  137324. /**
  137325. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137326. */
  137327. static readonly PBRMATERIAL_ALPHATEST: number;
  137328. /**
  137329. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137330. */
  137331. static readonly PBRMATERIAL_ALPHABLEND: number;
  137332. /**
  137333. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137334. * They are also discarded below the alpha cutoff threshold to improve performances.
  137335. */
  137336. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137337. /**
  137338. * Defines the default value of how much AO map is occluding the analytical lights
  137339. * (point spot...).
  137340. */
  137341. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137342. /**
  137343. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  137344. */
  137345. static readonly LIGHTFALLOFF_PHYSICAL: number;
  137346. /**
  137347. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  137348. * to enhance interoperability with other engines.
  137349. */
  137350. static readonly LIGHTFALLOFF_GLTF: number;
  137351. /**
  137352. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  137353. * to enhance interoperability with other materials.
  137354. */
  137355. static readonly LIGHTFALLOFF_STANDARD: number;
  137356. /**
  137357. * Intensity of the direct lights e.g. the four lights available in your scene.
  137358. * This impacts both the direct diffuse and specular highlights.
  137359. */
  137360. protected _directIntensity: number;
  137361. /**
  137362. * Intensity of the emissive part of the material.
  137363. * This helps controlling the emissive effect without modifying the emissive color.
  137364. */
  137365. protected _emissiveIntensity: number;
  137366. /**
  137367. * Intensity of the environment e.g. how much the environment will light the object
  137368. * either through harmonics for rough material or through the refelction for shiny ones.
  137369. */
  137370. protected _environmentIntensity: number;
  137371. /**
  137372. * This is a special control allowing the reduction of the specular highlights coming from the
  137373. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137374. */
  137375. protected _specularIntensity: number;
  137376. /**
  137377. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  137378. */
  137379. private _lightingInfos;
  137380. /**
  137381. * Debug Control allowing disabling the bump map on this material.
  137382. */
  137383. protected _disableBumpMap: boolean;
  137384. /**
  137385. * AKA Diffuse Texture in standard nomenclature.
  137386. */
  137387. protected _albedoTexture: Nullable<BaseTexture>;
  137388. /**
  137389. * AKA Occlusion Texture in other nomenclature.
  137390. */
  137391. protected _ambientTexture: Nullable<BaseTexture>;
  137392. /**
  137393. * AKA Occlusion Texture Intensity in other nomenclature.
  137394. */
  137395. protected _ambientTextureStrength: number;
  137396. /**
  137397. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137398. * 1 means it completely occludes it
  137399. * 0 mean it has no impact
  137400. */
  137401. protected _ambientTextureImpactOnAnalyticalLights: number;
  137402. /**
  137403. * Stores the alpha values in a texture.
  137404. */
  137405. protected _opacityTexture: Nullable<BaseTexture>;
  137406. /**
  137407. * Stores the reflection values in a texture.
  137408. */
  137409. protected _reflectionTexture: Nullable<BaseTexture>;
  137410. /**
  137411. * Stores the emissive values in a texture.
  137412. */
  137413. protected _emissiveTexture: Nullable<BaseTexture>;
  137414. /**
  137415. * AKA Specular texture in other nomenclature.
  137416. */
  137417. protected _reflectivityTexture: Nullable<BaseTexture>;
  137418. /**
  137419. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137420. */
  137421. protected _metallicTexture: Nullable<BaseTexture>;
  137422. /**
  137423. * Specifies the metallic scalar of the metallic/roughness workflow.
  137424. * Can also be used to scale the metalness values of the metallic texture.
  137425. */
  137426. protected _metallic: Nullable<number>;
  137427. /**
  137428. * Specifies the roughness scalar of the metallic/roughness workflow.
  137429. * Can also be used to scale the roughness values of the metallic texture.
  137430. */
  137431. protected _roughness: Nullable<number>;
  137432. /**
  137433. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137434. * By default the indexOfrefraction is used to compute F0;
  137435. *
  137436. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137437. *
  137438. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137439. * F90 = metallicReflectanceColor;
  137440. */
  137441. protected _metallicF0Factor: number;
  137442. /**
  137443. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137444. * By default the F90 is always 1;
  137445. *
  137446. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137447. *
  137448. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137449. * F90 = metallicReflectanceColor;
  137450. */
  137451. protected _metallicReflectanceColor: Color3;
  137452. /**
  137453. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137454. * This is multiply against the scalar values defined in the material.
  137455. */
  137456. protected _metallicReflectanceTexture: Nullable<BaseTexture>;
  137457. /**
  137458. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137459. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137460. */
  137461. protected _microSurfaceTexture: Nullable<BaseTexture>;
  137462. /**
  137463. * Stores surface normal data used to displace a mesh in a texture.
  137464. */
  137465. protected _bumpTexture: Nullable<BaseTexture>;
  137466. /**
  137467. * Stores the pre-calculated light information of a mesh in a texture.
  137468. */
  137469. protected _lightmapTexture: Nullable<BaseTexture>;
  137470. /**
  137471. * The color of a material in ambient lighting.
  137472. */
  137473. protected _ambientColor: Color3;
  137474. /**
  137475. * AKA Diffuse Color in other nomenclature.
  137476. */
  137477. protected _albedoColor: Color3;
  137478. /**
  137479. * AKA Specular Color in other nomenclature.
  137480. */
  137481. protected _reflectivityColor: Color3;
  137482. /**
  137483. * The color applied when light is reflected from a material.
  137484. */
  137485. protected _reflectionColor: Color3;
  137486. /**
  137487. * The color applied when light is emitted from a material.
  137488. */
  137489. protected _emissiveColor: Color3;
  137490. /**
  137491. * AKA Glossiness in other nomenclature.
  137492. */
  137493. protected _microSurface: number;
  137494. /**
  137495. * Specifies that the material will use the light map as a show map.
  137496. */
  137497. protected _useLightmapAsShadowmap: boolean;
  137498. /**
  137499. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  137500. * makes the reflect vector face the model (under horizon).
  137501. */
  137502. protected _useHorizonOcclusion: boolean;
  137503. /**
  137504. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  137505. * too much the area relying on ambient texture to define their ambient occlusion.
  137506. */
  137507. protected _useRadianceOcclusion: boolean;
  137508. /**
  137509. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  137510. */
  137511. protected _useAlphaFromAlbedoTexture: boolean;
  137512. /**
  137513. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  137514. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  137515. */
  137516. protected _useSpecularOverAlpha: boolean;
  137517. /**
  137518. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  137519. */
  137520. protected _useMicroSurfaceFromReflectivityMapAlpha: boolean;
  137521. /**
  137522. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  137523. */
  137524. protected _useRoughnessFromMetallicTextureAlpha: boolean;
  137525. /**
  137526. * Specifies if the metallic texture contains the roughness information in its green channel.
  137527. */
  137528. protected _useRoughnessFromMetallicTextureGreen: boolean;
  137529. /**
  137530. * Specifies if the metallic texture contains the metallness information in its blue channel.
  137531. */
  137532. protected _useMetallnessFromMetallicTextureBlue: boolean;
  137533. /**
  137534. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  137535. */
  137536. protected _useAmbientOcclusionFromMetallicTextureRed: boolean;
  137537. /**
  137538. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  137539. */
  137540. protected _useAmbientInGrayScale: boolean;
  137541. /**
  137542. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  137543. * The material will try to infer what glossiness each pixel should be.
  137544. */
  137545. protected _useAutoMicroSurfaceFromReflectivityMap: boolean;
  137546. /**
  137547. * Defines the falloff type used in this material.
  137548. * It by default is Physical.
  137549. */
  137550. protected _lightFalloff: number;
  137551. /**
  137552. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  137553. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  137554. */
  137555. protected _useRadianceOverAlpha: boolean;
  137556. /**
  137557. * Allows using an object space normal map (instead of tangent space).
  137558. */
  137559. protected _useObjectSpaceNormalMap: boolean;
  137560. /**
  137561. * Allows using the bump map in parallax mode.
  137562. */
  137563. protected _useParallax: boolean;
  137564. /**
  137565. * Allows using the bump map in parallax occlusion mode.
  137566. */
  137567. protected _useParallaxOcclusion: boolean;
  137568. /**
  137569. * Controls the scale bias of the parallax mode.
  137570. */
  137571. protected _parallaxScaleBias: number;
  137572. /**
  137573. * If sets to true, disables all the lights affecting the material.
  137574. */
  137575. protected _disableLighting: boolean;
  137576. /**
  137577. * Number of Simultaneous lights allowed on the material.
  137578. */
  137579. protected _maxSimultaneousLights: number;
  137580. /**
  137581. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  137582. */
  137583. protected _invertNormalMapX: boolean;
  137584. /**
  137585. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  137586. */
  137587. protected _invertNormalMapY: boolean;
  137588. /**
  137589. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  137590. */
  137591. protected _twoSidedLighting: boolean;
  137592. /**
  137593. * Defines the alpha limits in alpha test mode.
  137594. */
  137595. protected _alphaCutOff: number;
  137596. /**
  137597. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  137598. */
  137599. protected _forceAlphaTest: boolean;
  137600. /**
  137601. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137602. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  137603. */
  137604. protected _useAlphaFresnel: boolean;
  137605. /**
  137606. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  137607. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  137608. */
  137609. protected _useLinearAlphaFresnel: boolean;
  137610. /**
  137611. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  137612. * from cos thetav and roughness:
  137613. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  137614. */
  137615. protected _environmentBRDFTexture: Nullable<BaseTexture>;
  137616. /**
  137617. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  137618. */
  137619. protected _forceIrradianceInFragment: boolean;
  137620. private _realTimeFiltering;
  137621. /**
  137622. * Enables realtime filtering on the texture.
  137623. */
  137624. get realTimeFiltering(): boolean;
  137625. set realTimeFiltering(b: boolean);
  137626. private _realTimeFilteringQuality;
  137627. /**
  137628. * Quality switch for realtime filtering
  137629. */
  137630. get realTimeFilteringQuality(): number;
  137631. set realTimeFilteringQuality(n: number);
  137632. /**
  137633. * Can this material render to several textures at once
  137634. */
  137635. get canRenderToMRT(): boolean;
  137636. /**
  137637. * Force normal to face away from face.
  137638. */
  137639. protected _forceNormalForward: boolean;
  137640. /**
  137641. * Enables specular anti aliasing in the PBR shader.
  137642. * It will both interacts on the Geometry for analytical and IBL lighting.
  137643. * It also prefilter the roughness map based on the bump values.
  137644. */
  137645. protected _enableSpecularAntiAliasing: boolean;
  137646. /**
  137647. * Default configuration related to image processing available in the PBR Material.
  137648. */
  137649. protected _imageProcessingConfiguration: ImageProcessingConfiguration;
  137650. /**
  137651. * Keep track of the image processing observer to allow dispose and replace.
  137652. */
  137653. private _imageProcessingObserver;
  137654. /**
  137655. * Attaches a new image processing configuration to the PBR Material.
  137656. * @param configuration
  137657. */
  137658. protected _attachImageProcessingConfiguration(configuration: Nullable<ImageProcessingConfiguration>): void;
  137659. /**
  137660. * Stores the available render targets.
  137661. */
  137662. private _renderTargets;
  137663. /**
  137664. * Sets the global ambient color for the material used in lighting calculations.
  137665. */
  137666. private _globalAmbientColor;
  137667. /**
  137668. * Enables the use of logarithmic depth buffers, which is good for wide depth buffers.
  137669. */
  137670. private _useLogarithmicDepth;
  137671. /**
  137672. * If set to true, no lighting calculations will be applied.
  137673. */
  137674. private _unlit;
  137675. private _debugMode;
  137676. /**
  137677. * @hidden
  137678. * This is reserved for the inspector.
  137679. * Defines the material debug mode.
  137680. * It helps seeing only some components of the material while troubleshooting.
  137681. */
  137682. debugMode: number;
  137683. /**
  137684. * @hidden
  137685. * This is reserved for the inspector.
  137686. * Specify from where on screen the debug mode should start.
  137687. * The value goes from -1 (full screen) to 1 (not visible)
  137688. * It helps with side by side comparison against the final render
  137689. * This defaults to -1
  137690. */
  137691. private debugLimit;
  137692. /**
  137693. * @hidden
  137694. * This is reserved for the inspector.
  137695. * As the default viewing range might not be enough (if the ambient is really small for instance)
  137696. * You can use the factor to better multiply the final value.
  137697. */
  137698. private debugFactor;
  137699. /**
  137700. * Defines the clear coat layer parameters for the material.
  137701. */
  137702. readonly clearCoat: PBRClearCoatConfiguration;
  137703. /**
  137704. * Defines the anisotropic parameters for the material.
  137705. */
  137706. readonly anisotropy: PBRAnisotropicConfiguration;
  137707. /**
  137708. * Defines the BRDF parameters for the material.
  137709. */
  137710. readonly brdf: PBRBRDFConfiguration;
  137711. /**
  137712. * Defines the Sheen parameters for the material.
  137713. */
  137714. readonly sheen: PBRSheenConfiguration;
  137715. /**
  137716. * Defines the SubSurface parameters for the material.
  137717. */
  137718. readonly subSurface: PBRSubSurfaceConfiguration;
  137719. /**
  137720. * Defines additionnal PrePass parameters for the material.
  137721. */
  137722. readonly prePassConfiguration: PrePassConfiguration;
  137723. /**
  137724. * Defines the detail map parameters for the material.
  137725. */
  137726. readonly detailMap: DetailMapConfiguration;
  137727. protected _rebuildInParallel: boolean;
  137728. /**
  137729. * Instantiates a new PBRMaterial instance.
  137730. *
  137731. * @param name The material name
  137732. * @param scene The scene the material will be use in.
  137733. */
  137734. constructor(name: string, scene: Scene);
  137735. /**
  137736. * Gets a boolean indicating that current material needs to register RTT
  137737. */
  137738. get hasRenderTargetTextures(): boolean;
  137739. /**
  137740. * Gets the name of the material class.
  137741. */
  137742. getClassName(): string;
  137743. /**
  137744. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137745. */
  137746. get useLogarithmicDepth(): boolean;
  137747. /**
  137748. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  137749. */
  137750. set useLogarithmicDepth(value: boolean);
  137751. /**
  137752. * Returns true if alpha blending should be disabled.
  137753. */
  137754. protected get _disableAlphaBlending(): boolean;
  137755. /**
  137756. * Specifies whether or not this material should be rendered in alpha blend mode.
  137757. */
  137758. needAlphaBlending(): boolean;
  137759. /**
  137760. * Specifies whether or not this material should be rendered in alpha test mode.
  137761. */
  137762. needAlphaTesting(): boolean;
  137763. /**
  137764. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  137765. */
  137766. protected _shouldUseAlphaFromAlbedoTexture(): boolean;
  137767. /**
  137768. * Gets the texture used for the alpha test.
  137769. */
  137770. getAlphaTestTexture(): Nullable<BaseTexture>;
  137771. /**
  137772. * Specifies that the submesh is ready to be used.
  137773. * @param mesh - BJS mesh.
  137774. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  137775. * @param useInstances - Specifies that instances should be used.
  137776. * @returns - boolean indicating that the submesh is ready or not.
  137777. */
  137778. isReadyForSubMesh(mesh: AbstractMesh, subMesh: SubMesh, useInstances?: boolean): boolean;
  137779. /**
  137780. * Specifies if the material uses metallic roughness workflow.
  137781. * @returns boolean specifiying if the material uses metallic roughness workflow.
  137782. */
  137783. isMetallicWorkflow(): boolean;
  137784. private _prepareEffect;
  137785. private _prepareDefines;
  137786. /**
  137787. * Force shader compilation
  137788. */
  137789. forceCompilation(mesh: AbstractMesh, onCompiled?: (material: Material) => void, options?: Partial<IMaterialCompilationOptions>): void;
  137790. /**
  137791. * Initializes the uniform buffer layout for the shader.
  137792. */
  137793. buildUniformLayout(): void;
  137794. /**
  137795. * Unbinds the material from the mesh
  137796. */
  137797. unbind(): void;
  137798. /**
  137799. * Binds the submesh data.
  137800. * @param world - The world matrix.
  137801. * @param mesh - The BJS mesh.
  137802. * @param subMesh - A submesh of the BJS mesh.
  137803. */
  137804. bindForSubMesh(world: Matrix, mesh: Mesh, subMesh: SubMesh): void;
  137805. /**
  137806. * Returns the animatable textures.
  137807. * @returns - Array of animatable textures.
  137808. */
  137809. getAnimatables(): IAnimatable[];
  137810. /**
  137811. * Returns the texture used for reflections.
  137812. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  137813. */
  137814. private _getReflectionTexture;
  137815. /**
  137816. * Returns an array of the actively used textures.
  137817. * @returns - Array of BaseTextures
  137818. */
  137819. getActiveTextures(): BaseTexture[];
  137820. /**
  137821. * Checks to see if a texture is used in the material.
  137822. * @param texture - Base texture to use.
  137823. * @returns - Boolean specifying if a texture is used in the material.
  137824. */
  137825. hasTexture(texture: BaseTexture): boolean;
  137826. /**
  137827. * Sets the required values to the prepass renderer.
  137828. * @param prePassRenderer defines the prepass renderer to setup
  137829. */
  137830. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  137831. /**
  137832. * Disposes the resources of the material.
  137833. * @param forceDisposeEffect - Forces the disposal of effects.
  137834. * @param forceDisposeTextures - Forces the disposal of all textures.
  137835. */
  137836. dispose(forceDisposeEffect?: boolean, forceDisposeTextures?: boolean): void;
  137837. }
  137838. }
  137839. declare module BABYLON {
  137840. /**
  137841. * The Physically based material of BJS.
  137842. *
  137843. * This offers the main features of a standard PBR material.
  137844. * For more information, please refer to the documentation :
  137845. * https://doc.babylonjs.com/how_to/physically_based_rendering
  137846. */
  137847. export class PBRMaterial extends PBRBaseMaterial {
  137848. /**
  137849. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  137850. */
  137851. static readonly PBRMATERIAL_OPAQUE: number;
  137852. /**
  137853. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  137854. */
  137855. static readonly PBRMATERIAL_ALPHATEST: number;
  137856. /**
  137857. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137858. */
  137859. static readonly PBRMATERIAL_ALPHABLEND: number;
  137860. /**
  137861. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  137862. * They are also discarded below the alpha cutoff threshold to improve performances.
  137863. */
  137864. static readonly PBRMATERIAL_ALPHATESTANDBLEND: number;
  137865. /**
  137866. * Defines the default value of how much AO map is occluding the analytical lights
  137867. * (point spot...).
  137868. */
  137869. static DEFAULT_AO_ON_ANALYTICAL_LIGHTS: number;
  137870. /**
  137871. * Intensity of the direct lights e.g. the four lights available in your scene.
  137872. * This impacts both the direct diffuse and specular highlights.
  137873. */
  137874. directIntensity: number;
  137875. /**
  137876. * Intensity of the emissive part of the material.
  137877. * This helps controlling the emissive effect without modifying the emissive color.
  137878. */
  137879. emissiveIntensity: number;
  137880. /**
  137881. * Intensity of the environment e.g. how much the environment will light the object
  137882. * either through harmonics for rough material or through the refelction for shiny ones.
  137883. */
  137884. environmentIntensity: number;
  137885. /**
  137886. * This is a special control allowing the reduction of the specular highlights coming from the
  137887. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  137888. */
  137889. specularIntensity: number;
  137890. /**
  137891. * Debug Control allowing disabling the bump map on this material.
  137892. */
  137893. disableBumpMap: boolean;
  137894. /**
  137895. * AKA Diffuse Texture in standard nomenclature.
  137896. */
  137897. albedoTexture: BaseTexture;
  137898. /**
  137899. * AKA Occlusion Texture in other nomenclature.
  137900. */
  137901. ambientTexture: BaseTexture;
  137902. /**
  137903. * AKA Occlusion Texture Intensity in other nomenclature.
  137904. */
  137905. ambientTextureStrength: number;
  137906. /**
  137907. * Defines how much the AO map is occluding the analytical lights (point spot...).
  137908. * 1 means it completely occludes it
  137909. * 0 mean it has no impact
  137910. */
  137911. ambientTextureImpactOnAnalyticalLights: number;
  137912. /**
  137913. * Stores the alpha values in a texture. Use luminance if texture.getAlphaFromRGB is true.
  137914. */
  137915. opacityTexture: BaseTexture;
  137916. /**
  137917. * Stores the reflection values in a texture.
  137918. */
  137919. reflectionTexture: Nullable<BaseTexture>;
  137920. /**
  137921. * Stores the emissive values in a texture.
  137922. */
  137923. emissiveTexture: BaseTexture;
  137924. /**
  137925. * AKA Specular texture in other nomenclature.
  137926. */
  137927. reflectivityTexture: BaseTexture;
  137928. /**
  137929. * Used to switch from specular/glossiness to metallic/roughness workflow.
  137930. */
  137931. metallicTexture: BaseTexture;
  137932. /**
  137933. * Specifies the metallic scalar of the metallic/roughness workflow.
  137934. * Can also be used to scale the metalness values of the metallic texture.
  137935. */
  137936. metallic: Nullable<number>;
  137937. /**
  137938. * Specifies the roughness scalar of the metallic/roughness workflow.
  137939. * Can also be used to scale the roughness values of the metallic texture.
  137940. */
  137941. roughness: Nullable<number>;
  137942. /**
  137943. * In metallic workflow, specifies an F0 factor to help configuring the material F0.
  137944. * By default the indexOfrefraction is used to compute F0;
  137945. *
  137946. * This is used as a factor against the default reflectance at normal incidence to tweak it.
  137947. *
  137948. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor;
  137949. * F90 = metallicReflectanceColor;
  137950. */
  137951. metallicF0Factor: number;
  137952. /**
  137953. * In metallic workflow, specifies an F90 color to help configuring the material F90.
  137954. * By default the F90 is always 1;
  137955. *
  137956. * Please note that this factor is also used as a factor against the default reflectance at normal incidence.
  137957. *
  137958. * F0 = defaultF0 * metallicF0Factor * metallicReflectanceColor
  137959. * F90 = metallicReflectanceColor;
  137960. */
  137961. metallicReflectanceColor: Color3;
  137962. /**
  137963. * Defines to store metallicReflectanceColor in RGB and metallicF0Factor in A
  137964. * This is multiply against the scalar values defined in the material.
  137965. */
  137966. metallicReflectanceTexture: Nullable<BaseTexture>;
  137967. /**
  137968. * Used to enable roughness/glossiness fetch from a separate channel depending on the current mode.
  137969. * Gray Scale represents roughness in metallic mode and glossiness in specular mode.
  137970. */
  137971. microSurfaceTexture: BaseTexture;
  137972. /**
  137973. * Stores surface normal data used to displace a mesh in a texture.
  137974. */
  137975. bumpTexture: BaseTexture;
  137976. /**
  137977. * Stores the pre-calculated light information of a mesh in a texture.
  137978. */
  137979. lightmapTexture: BaseTexture;
  137980. /**
  137981. * Stores the refracted light information in a texture.
  137982. */
  137983. get refractionTexture(): Nullable<BaseTexture>;
  137984. set refractionTexture(value: Nullable<BaseTexture>);
  137985. /**
  137986. * The color of a material in ambient lighting.
  137987. */
  137988. ambientColor: Color3;
  137989. /**
  137990. * AKA Diffuse Color in other nomenclature.
  137991. */
  137992. albedoColor: Color3;
  137993. /**
  137994. * AKA Specular Color in other nomenclature.
  137995. */
  137996. reflectivityColor: Color3;
  137997. /**
  137998. * The color reflected from the material.
  137999. */
  138000. reflectionColor: Color3;
  138001. /**
  138002. * The color emitted from the material.
  138003. */
  138004. emissiveColor: Color3;
  138005. /**
  138006. * AKA Glossiness in other nomenclature.
  138007. */
  138008. microSurface: number;
  138009. /**
  138010. * Index of refraction of the material base layer.
  138011. * https://en.wikipedia.org/wiki/List_of_refractive_indices
  138012. *
  138013. * This does not only impact refraction but also the Base F0 of Dielectric Materials.
  138014. *
  138015. * From dielectric fresnel rules: F0 = square((iorT - iorI) / (iorT + iorI))
  138016. */
  138017. get indexOfRefraction(): number;
  138018. set indexOfRefraction(value: number);
  138019. /**
  138020. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  138021. */
  138022. get invertRefractionY(): boolean;
  138023. set invertRefractionY(value: boolean);
  138024. /**
  138025. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  138026. * Materials half opaque for instance using refraction could benefit from this control.
  138027. */
  138028. get linkRefractionWithTransparency(): boolean;
  138029. set linkRefractionWithTransparency(value: boolean);
  138030. /**
  138031. * If true, the light map contains occlusion information instead of lighting info.
  138032. */
  138033. useLightmapAsShadowmap: boolean;
  138034. /**
  138035. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  138036. */
  138037. useAlphaFromAlbedoTexture: boolean;
  138038. /**
  138039. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  138040. */
  138041. forceAlphaTest: boolean;
  138042. /**
  138043. * Defines the alpha limits in alpha test mode.
  138044. */
  138045. alphaCutOff: number;
  138046. /**
  138047. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  138048. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  138049. */
  138050. useSpecularOverAlpha: boolean;
  138051. /**
  138052. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  138053. */
  138054. useMicroSurfaceFromReflectivityMapAlpha: boolean;
  138055. /**
  138056. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  138057. */
  138058. useRoughnessFromMetallicTextureAlpha: boolean;
  138059. /**
  138060. * Specifies if the metallic texture contains the roughness information in its green channel.
  138061. */
  138062. useRoughnessFromMetallicTextureGreen: boolean;
  138063. /**
  138064. * Specifies if the metallic texture contains the metallness information in its blue channel.
  138065. */
  138066. useMetallnessFromMetallicTextureBlue: boolean;
  138067. /**
  138068. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  138069. */
  138070. useAmbientOcclusionFromMetallicTextureRed: boolean;
  138071. /**
  138072. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  138073. */
  138074. useAmbientInGrayScale: boolean;
  138075. /**
  138076. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  138077. * The material will try to infer what glossiness each pixel should be.
  138078. */
  138079. useAutoMicroSurfaceFromReflectivityMap: boolean;
  138080. /**
  138081. * BJS is using an harcoded light falloff based on a manually sets up range.
  138082. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  138083. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  138084. */
  138085. get usePhysicalLightFalloff(): boolean;
  138086. /**
  138087. * BJS is using an harcoded light falloff based on a manually sets up range.
  138088. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  138089. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  138090. */
  138091. set usePhysicalLightFalloff(value: boolean);
  138092. /**
  138093. * In order to support the falloff compatibility with gltf, a special mode has been added
  138094. * to reproduce the gltf light falloff.
  138095. */
  138096. get useGLTFLightFalloff(): boolean;
  138097. /**
  138098. * In order to support the falloff compatibility with gltf, a special mode has been added
  138099. * to reproduce the gltf light falloff.
  138100. */
  138101. set useGLTFLightFalloff(value: boolean);
  138102. /**
  138103. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  138104. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  138105. */
  138106. useRadianceOverAlpha: boolean;
  138107. /**
  138108. * Allows using an object space normal map (instead of tangent space).
  138109. */
  138110. useObjectSpaceNormalMap: boolean;
  138111. /**
  138112. * Allows using the bump map in parallax mode.
  138113. */
  138114. useParallax: boolean;
  138115. /**
  138116. * Allows using the bump map in parallax occlusion mode.
  138117. */
  138118. useParallaxOcclusion: boolean;
  138119. /**
  138120. * Controls the scale bias of the parallax mode.
  138121. */
  138122. parallaxScaleBias: number;
  138123. /**
  138124. * If sets to true, disables all the lights affecting the material.
  138125. */
  138126. disableLighting: boolean;
  138127. /**
  138128. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  138129. */
  138130. forceIrradianceInFragment: boolean;
  138131. /**
  138132. * Number of Simultaneous lights allowed on the material.
  138133. */
  138134. maxSimultaneousLights: number;
  138135. /**
  138136. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  138137. */
  138138. invertNormalMapX: boolean;
  138139. /**
  138140. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  138141. */
  138142. invertNormalMapY: boolean;
  138143. /**
  138144. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  138145. */
  138146. twoSidedLighting: boolean;
  138147. /**
  138148. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  138149. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  138150. */
  138151. useAlphaFresnel: boolean;
  138152. /**
  138153. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  138154. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  138155. */
  138156. useLinearAlphaFresnel: boolean;
  138157. /**
  138158. * Let user defines the brdf lookup texture used for IBL.
  138159. * A default 8bit version is embedded but you could point at :
  138160. * * Default texture: https://assets.babylonjs.com/environments/correlatedMSBRDF_RGBD.png
  138161. * * Default 16bit pixel depth texture: https://assets.babylonjs.com/environments/correlatedMSBRDF.dds
  138162. * * LEGACY Default None correlated https://assets.babylonjs.com/environments/uncorrelatedBRDF_RGBD.png
  138163. * * LEGACY Default None correlated 16bit pixel depth https://assets.babylonjs.com/environments/uncorrelatedBRDF.dds
  138164. */
  138165. environmentBRDFTexture: Nullable<BaseTexture>;
  138166. /**
  138167. * Force normal to face away from face.
  138168. */
  138169. forceNormalForward: boolean;
  138170. /**
  138171. * Enables specular anti aliasing in the PBR shader.
  138172. * It will both interacts on the Geometry for analytical and IBL lighting.
  138173. * It also prefilter the roughness map based on the bump values.
  138174. */
  138175. enableSpecularAntiAliasing: boolean;
  138176. /**
  138177. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  138178. * makes the reflect vector face the model (under horizon).
  138179. */
  138180. useHorizonOcclusion: boolean;
  138181. /**
  138182. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  138183. * too much the area relying on ambient texture to define their ambient occlusion.
  138184. */
  138185. useRadianceOcclusion: boolean;
  138186. /**
  138187. * If set to true, no lighting calculations will be applied.
  138188. */
  138189. unlit: boolean;
  138190. /**
  138191. * Gets the image processing configuration used either in this material.
  138192. */
  138193. get imageProcessingConfiguration(): ImageProcessingConfiguration;
  138194. /**
  138195. * Sets the Default image processing configuration used either in the this material.
  138196. *
  138197. * If sets to null, the scene one is in use.
  138198. */
  138199. set imageProcessingConfiguration(value: ImageProcessingConfiguration);
  138200. /**
  138201. * Gets wether the color curves effect is enabled.
  138202. */
  138203. get cameraColorCurvesEnabled(): boolean;
  138204. /**
  138205. * Sets wether the color curves effect is enabled.
  138206. */
  138207. set cameraColorCurvesEnabled(value: boolean);
  138208. /**
  138209. * Gets wether the color grading effect is enabled.
  138210. */
  138211. get cameraColorGradingEnabled(): boolean;
  138212. /**
  138213. * Gets wether the color grading effect is enabled.
  138214. */
  138215. set cameraColorGradingEnabled(value: boolean);
  138216. /**
  138217. * Gets wether tonemapping is enabled or not.
  138218. */
  138219. get cameraToneMappingEnabled(): boolean;
  138220. /**
  138221. * Sets wether tonemapping is enabled or not
  138222. */
  138223. set cameraToneMappingEnabled(value: boolean);
  138224. /**
  138225. * The camera exposure used on this material.
  138226. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138227. * This corresponds to a photographic exposure.
  138228. */
  138229. get cameraExposure(): number;
  138230. /**
  138231. * The camera exposure used on this material.
  138232. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  138233. * This corresponds to a photographic exposure.
  138234. */
  138235. set cameraExposure(value: number);
  138236. /**
  138237. * Gets The camera contrast used on this material.
  138238. */
  138239. get cameraContrast(): number;
  138240. /**
  138241. * Sets The camera contrast used on this material.
  138242. */
  138243. set cameraContrast(value: number);
  138244. /**
  138245. * Gets the Color Grading 2D Lookup Texture.
  138246. */
  138247. get cameraColorGradingTexture(): Nullable<BaseTexture>;
  138248. /**
  138249. * Sets the Color Grading 2D Lookup Texture.
  138250. */
  138251. set cameraColorGradingTexture(value: Nullable<BaseTexture>);
  138252. /**
  138253. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138254. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138255. * 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;
  138256. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138257. */
  138258. get cameraColorCurves(): Nullable<ColorCurves>;
  138259. /**
  138260. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  138261. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  138262. * 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;
  138263. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  138264. */
  138265. set cameraColorCurves(value: Nullable<ColorCurves>);
  138266. /**
  138267. * Instantiates a new PBRMaterial instance.
  138268. *
  138269. * @param name The material name
  138270. * @param scene The scene the material will be use in.
  138271. */
  138272. constructor(name: string, scene: Scene);
  138273. /**
  138274. * Returns the name of this material class.
  138275. */
  138276. getClassName(): string;
  138277. /**
  138278. * Makes a duplicate of the current material.
  138279. * @param name - name to use for the new material.
  138280. */
  138281. clone(name: string): PBRMaterial;
  138282. /**
  138283. * Serializes this PBR Material.
  138284. * @returns - An object with the serialized material.
  138285. */
  138286. serialize(): any;
  138287. /**
  138288. * Parses a PBR Material from a serialized object.
  138289. * @param source - Serialized object.
  138290. * @param scene - BJS scene instance.
  138291. * @param rootUrl - url for the scene object
  138292. * @returns - PBRMaterial
  138293. */
  138294. static Parse(source: any, scene: Scene, rootUrl: string): PBRMaterial;
  138295. }
  138296. }
  138297. declare module BABYLON {
  138298. /**
  138299. * Direct draw surface info
  138300. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dx-graphics-dds-pguide
  138301. */
  138302. export interface DDSInfo {
  138303. /**
  138304. * Width of the texture
  138305. */
  138306. width: number;
  138307. /**
  138308. * Width of the texture
  138309. */
  138310. height: number;
  138311. /**
  138312. * Number of Mipmaps for the texture
  138313. * @see https://en.wikipedia.org/wiki/Mipmap
  138314. */
  138315. mipmapCount: number;
  138316. /**
  138317. * If the textures format is a known fourCC format
  138318. * @see https://www.fourcc.org/
  138319. */
  138320. isFourCC: boolean;
  138321. /**
  138322. * If the texture is an RGB format eg. DXGI_FORMAT_B8G8R8X8_UNORM format
  138323. */
  138324. isRGB: boolean;
  138325. /**
  138326. * If the texture is a lumincance format
  138327. */
  138328. isLuminance: boolean;
  138329. /**
  138330. * If this is a cube texture
  138331. * @see https://docs.microsoft.com/en-us/windows/desktop/direct3ddds/dds-file-layout-for-cubic-environment-maps
  138332. */
  138333. isCube: boolean;
  138334. /**
  138335. * If the texture is a compressed format eg. FOURCC_DXT1
  138336. */
  138337. isCompressed: boolean;
  138338. /**
  138339. * The dxgiFormat of the texture
  138340. * @see https://docs.microsoft.com/en-us/windows/desktop/api/dxgiformat/ne-dxgiformat-dxgi_format
  138341. */
  138342. dxgiFormat: number;
  138343. /**
  138344. * Texture type eg. Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT
  138345. */
  138346. textureType: number;
  138347. /**
  138348. * Sphericle polynomial created for the dds texture
  138349. */
  138350. sphericalPolynomial?: SphericalPolynomial;
  138351. }
  138352. /**
  138353. * Class used to provide DDS decompression tools
  138354. */
  138355. export class DDSTools {
  138356. /**
  138357. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  138358. */
  138359. static StoreLODInAlphaChannel: boolean;
  138360. /**
  138361. * Gets DDS information from an array buffer
  138362. * @param data defines the array buffer view to read data from
  138363. * @returns the DDS information
  138364. */
  138365. static GetDDSInfo(data: ArrayBufferView): DDSInfo;
  138366. private static _FloatView;
  138367. private static _Int32View;
  138368. private static _ToHalfFloat;
  138369. private static _FromHalfFloat;
  138370. private static _GetHalfFloatAsFloatRGBAArrayBuffer;
  138371. private static _GetHalfFloatRGBAArrayBuffer;
  138372. private static _GetFloatRGBAArrayBuffer;
  138373. private static _GetFloatAsUIntRGBAArrayBuffer;
  138374. private static _GetHalfFloatAsUIntRGBAArrayBuffer;
  138375. private static _GetRGBAArrayBuffer;
  138376. private static _ExtractLongWordOrder;
  138377. private static _GetRGBArrayBuffer;
  138378. private static _GetLuminanceArrayBuffer;
  138379. /**
  138380. * Uploads DDS Levels to a Babylon Texture
  138381. * @hidden
  138382. */
  138383. static UploadDDSLevels(engine: ThinEngine, texture: InternalTexture, data: ArrayBufferView, info: DDSInfo, loadMipmaps: boolean, faces: number, lodIndex?: number, currentFace?: number): void;
  138384. }
  138385. interface ThinEngine {
  138386. /**
  138387. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  138388. * @param rootUrl defines the url where the file to load is located
  138389. * @param scene defines the current scene
  138390. * @param lodScale defines scale to apply to the mip map selection
  138391. * @param lodOffset defines offset to apply to the mip map selection
  138392. * @param onLoad defines an optional callback raised when the texture is loaded
  138393. * @param onError defines an optional callback raised if there is an issue to load the texture
  138394. * @param format defines the format of the data
  138395. * @param forcedExtension defines the extension to use to pick the right loader
  138396. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  138397. * @returns the cube texture as an InternalTexture
  138398. */
  138399. 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;
  138400. }
  138401. }
  138402. declare module BABYLON {
  138403. /**
  138404. * Implementation of the DDS Texture Loader.
  138405. * @hidden
  138406. */
  138407. export class _DDSTextureLoader implements IInternalTextureLoader {
  138408. /**
  138409. * Defines wether the loader supports cascade loading the different faces.
  138410. */
  138411. readonly supportCascades: boolean;
  138412. /**
  138413. * This returns if the loader support the current file information.
  138414. * @param extension defines the file extension of the file being loaded
  138415. * @returns true if the loader can load the specified file
  138416. */
  138417. canLoad(extension: string): boolean;
  138418. /**
  138419. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138420. * @param data contains the texture data
  138421. * @param texture defines the BabylonJS internal texture
  138422. * @param createPolynomials will be true if polynomials have been requested
  138423. * @param onLoad defines the callback to trigger once the texture is ready
  138424. * @param onError defines the callback to trigger in case of error
  138425. */
  138426. loadCubeData(imgs: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138427. /**
  138428. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138429. * @param data contains the texture data
  138430. * @param texture defines the BabylonJS internal texture
  138431. * @param callback defines the method to call once ready to upload
  138432. */
  138433. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138434. }
  138435. }
  138436. declare module BABYLON {
  138437. /**
  138438. * Implementation of the ENV Texture Loader.
  138439. * @hidden
  138440. */
  138441. export class _ENVTextureLoader implements IInternalTextureLoader {
  138442. /**
  138443. * Defines wether the loader supports cascade loading the different faces.
  138444. */
  138445. readonly supportCascades: boolean;
  138446. /**
  138447. * This returns if the loader support the current file information.
  138448. * @param extension defines the file extension of the file being loaded
  138449. * @returns true if the loader can load the specified file
  138450. */
  138451. canLoad(extension: string): boolean;
  138452. /**
  138453. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138454. * @param data contains the texture data
  138455. * @param texture defines the BabylonJS internal texture
  138456. * @param createPolynomials will be true if polynomials have been requested
  138457. * @param onLoad defines the callback to trigger once the texture is ready
  138458. * @param onError defines the callback to trigger in case of error
  138459. */
  138460. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138461. /**
  138462. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138463. * @param data contains the texture data
  138464. * @param texture defines the BabylonJS internal texture
  138465. * @param callback defines the method to call once ready to upload
  138466. */
  138467. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  138468. }
  138469. }
  138470. declare module BABYLON {
  138471. /**
  138472. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  138473. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  138474. */
  138475. export class KhronosTextureContainer {
  138476. /** contents of the KTX container file */
  138477. data: ArrayBufferView;
  138478. private static HEADER_LEN;
  138479. private static COMPRESSED_2D;
  138480. private static COMPRESSED_3D;
  138481. private static TEX_2D;
  138482. private static TEX_3D;
  138483. /**
  138484. * Gets the openGL type
  138485. */
  138486. glType: number;
  138487. /**
  138488. * Gets the openGL type size
  138489. */
  138490. glTypeSize: number;
  138491. /**
  138492. * Gets the openGL format
  138493. */
  138494. glFormat: number;
  138495. /**
  138496. * Gets the openGL internal format
  138497. */
  138498. glInternalFormat: number;
  138499. /**
  138500. * Gets the base internal format
  138501. */
  138502. glBaseInternalFormat: number;
  138503. /**
  138504. * Gets image width in pixel
  138505. */
  138506. pixelWidth: number;
  138507. /**
  138508. * Gets image height in pixel
  138509. */
  138510. pixelHeight: number;
  138511. /**
  138512. * Gets image depth in pixels
  138513. */
  138514. pixelDepth: number;
  138515. /**
  138516. * Gets the number of array elements
  138517. */
  138518. numberOfArrayElements: number;
  138519. /**
  138520. * Gets the number of faces
  138521. */
  138522. numberOfFaces: number;
  138523. /**
  138524. * Gets the number of mipmap levels
  138525. */
  138526. numberOfMipmapLevels: number;
  138527. /**
  138528. * Gets the bytes of key value data
  138529. */
  138530. bytesOfKeyValueData: number;
  138531. /**
  138532. * Gets the load type
  138533. */
  138534. loadType: number;
  138535. /**
  138536. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  138537. */
  138538. isInvalid: boolean;
  138539. /**
  138540. * Creates a new KhronosTextureContainer
  138541. * @param data contents of the KTX container file
  138542. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  138543. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  138544. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  138545. */
  138546. constructor(
  138547. /** contents of the KTX container file */
  138548. data: ArrayBufferView, facesExpected: number, threeDExpected?: boolean, textureArrayExpected?: boolean);
  138549. /**
  138550. * Uploads KTX content to a Babylon Texture.
  138551. * It is assumed that the texture has already been created & is currently bound
  138552. * @hidden
  138553. */
  138554. uploadLevels(texture: InternalTexture, loadMipmaps: boolean): void;
  138555. private _upload2DCompressedLevels;
  138556. /**
  138557. * Checks if the given data starts with a KTX file identifier.
  138558. * @param data the data to check
  138559. * @returns true if the data is a KTX file or false otherwise
  138560. */
  138561. static IsValid(data: ArrayBufferView): boolean;
  138562. }
  138563. }
  138564. declare module BABYLON {
  138565. /**
  138566. * Helper class to push actions to a pool of workers.
  138567. */
  138568. export class WorkerPool implements IDisposable {
  138569. private _workerInfos;
  138570. private _pendingActions;
  138571. /**
  138572. * Constructor
  138573. * @param workers Array of workers to use for actions
  138574. */
  138575. constructor(workers: Array<Worker>);
  138576. /**
  138577. * Terminates all workers and clears any pending actions.
  138578. */
  138579. dispose(): void;
  138580. /**
  138581. * Pushes an action to the worker pool. If all the workers are active, the action will be
  138582. * pended until a worker has completed its action.
  138583. * @param action The action to perform. Call onComplete when the action is complete.
  138584. */
  138585. push(action: (worker: Worker, onComplete: () => void) => void): void;
  138586. private _execute;
  138587. }
  138588. }
  138589. declare module BABYLON {
  138590. /**
  138591. * Class for loading KTX2 files
  138592. */
  138593. export class KhronosTextureContainer2 {
  138594. private static _WorkerPoolPromise?;
  138595. private static _Initialized;
  138596. private static _Ktx2Decoder;
  138597. /**
  138598. * URLs to use when loading the KTX2 decoder module as well as its dependencies
  138599. * If a url is null, the default url is used (pointing to https://preview.babylonjs.com)
  138600. * Note that jsDecoderModule can't be null and that the other dependencies will only be loaded if necessary
  138601. * Urls you can change:
  138602. * URLConfig.jsDecoderModule
  138603. * URLConfig.wasmUASTCToASTC
  138604. * URLConfig.wasmUASTCToBC7
  138605. * URLConfig.jsMSCTranscoder
  138606. * URLConfig.wasmMSCTranscoder
  138607. * You can see their default values in this PG: https://playground.babylonjs.com/#EIJH8L#9
  138608. */
  138609. static URLConfig: {
  138610. jsDecoderModule: string;
  138611. wasmUASTCToASTC: null;
  138612. wasmUASTCToBC7: null;
  138613. jsMSCTranscoder: null;
  138614. wasmMSCTranscoder: null;
  138615. };
  138616. /**
  138617. * Default number of workers used to handle data decoding
  138618. */
  138619. static DefaultNumWorkers: number;
  138620. private static GetDefaultNumWorkers;
  138621. private _engine;
  138622. private static _CreateWorkerPool;
  138623. /**
  138624. * Constructor
  138625. * @param engine The engine to use
  138626. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  138627. */
  138628. constructor(engine: ThinEngine, numWorkers?: number);
  138629. /** @hidden */
  138630. uploadAsync(data: ArrayBufferView, internalTexture: InternalTexture): Promise<void>;
  138631. /**
  138632. * Stop all async operations and release resources.
  138633. */
  138634. dispose(): void;
  138635. protected _createTexture(data: any, internalTexture: InternalTexture): void;
  138636. /**
  138637. * Checks if the given data starts with a KTX2 file identifier.
  138638. * @param data the data to check
  138639. * @returns true if the data is a KTX2 file or false otherwise
  138640. */
  138641. static IsValid(data: ArrayBufferView): boolean;
  138642. }
  138643. }
  138644. declare module BABYLON {
  138645. /**
  138646. * Implementation of the KTX Texture Loader.
  138647. * @hidden
  138648. */
  138649. export class _KTXTextureLoader implements IInternalTextureLoader {
  138650. /**
  138651. * Defines wether the loader supports cascade loading the different faces.
  138652. */
  138653. readonly supportCascades: boolean;
  138654. /**
  138655. * This returns if the loader support the current file information.
  138656. * @param extension defines the file extension of the file being loaded
  138657. * @param mimeType defines the optional mime type of the file being loaded
  138658. * @returns true if the loader can load the specified file
  138659. */
  138660. canLoad(extension: string, mimeType?: string): boolean;
  138661. /**
  138662. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  138663. * @param data contains the texture data
  138664. * @param texture defines the BabylonJS internal texture
  138665. * @param createPolynomials will be true if polynomials have been requested
  138666. * @param onLoad defines the callback to trigger once the texture is ready
  138667. * @param onError defines the callback to trigger in case of error
  138668. */
  138669. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  138670. /**
  138671. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  138672. * @param data contains the texture data
  138673. * @param texture defines the BabylonJS internal texture
  138674. * @param callback defines the method to call once ready to upload
  138675. */
  138676. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void, loadFailed: boolean) => void): void;
  138677. }
  138678. }
  138679. declare module BABYLON {
  138680. /** @hidden */
  138681. export var _forceSceneHelpersToBundle: boolean;
  138682. interface Scene {
  138683. /**
  138684. * Creates a default light for the scene.
  138685. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-light
  138686. * @param replace has the default false, when true replaces the existing lights in the scene with a hemispheric light
  138687. */
  138688. createDefaultLight(replace?: boolean): void;
  138689. /**
  138690. * Creates a default camera for the scene.
  138691. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-camera
  138692. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138693. * @param replace has default false, when true replaces the active camera in the scene
  138694. * @param attachCameraControls has default false, when true attaches camera controls to the canvas.
  138695. */
  138696. createDefaultCamera(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138697. /**
  138698. * Creates a default camera and a default light.
  138699. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-camera-or-light
  138700. * @param createArcRotateCamera has the default false which creates a free camera, when true creates an arc rotate camera
  138701. * @param replace has the default false, when true replaces the active camera/light in the scene
  138702. * @param attachCameraControls has the default false, when true attaches camera controls to the canvas.
  138703. */
  138704. createDefaultCameraOrLight(createArcRotateCamera?: boolean, replace?: boolean, attachCameraControls?: boolean): void;
  138705. /**
  138706. * Creates a new sky box
  138707. * @see https://doc.babylonjs.com/how_to/Fast_Build#create-default-skybox
  138708. * @param environmentTexture defines the texture to use as environment texture
  138709. * @param pbr has default false which requires the StandardMaterial to be used, when true PBRMaterial must be used
  138710. * @param scale defines the overall scale of the skybox
  138711. * @param blur is only available when pbr is true, default is 0, no blur, maximum value is 1
  138712. * @param setGlobalEnvTexture has default true indicating that scene.environmentTexture must match the current skybox texture
  138713. * @returns a new mesh holding the sky box
  138714. */
  138715. createDefaultSkybox(environmentTexture?: BaseTexture, pbr?: boolean, scale?: number, blur?: number, setGlobalEnvTexture?: boolean): Nullable<Mesh>;
  138716. /**
  138717. * Creates a new environment
  138718. * @see https://doc.babylonjs.com/How_To/Fast_Build#create-default-environment
  138719. * @param options defines the options you can use to configure the environment
  138720. * @returns the new EnvironmentHelper
  138721. */
  138722. createDefaultEnvironment(options?: Partial<IEnvironmentHelperOptions>): Nullable<EnvironmentHelper>;
  138723. /**
  138724. * Creates a new VREXperienceHelper
  138725. * @see https://doc.babylonjs.com/how_to/webvr_helper
  138726. * @param webVROptions defines the options used to create the new VREXperienceHelper
  138727. * @returns a new VREXperienceHelper
  138728. */
  138729. createDefaultVRExperience(webVROptions?: VRExperienceHelperOptions): VRExperienceHelper;
  138730. /**
  138731. * Creates a new WebXRDefaultExperience
  138732. * @see https://doc.babylonjs.com/how_to/introduction_to_webxr
  138733. * @param options experience options
  138734. * @returns a promise for a new WebXRDefaultExperience
  138735. */
  138736. createDefaultXRExperienceAsync(options: WebXRDefaultExperienceOptions): Promise<WebXRDefaultExperience>;
  138737. }
  138738. }
  138739. declare module BABYLON {
  138740. /**
  138741. * Display a 360/180 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  138742. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  138743. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  138744. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  138745. */
  138746. export class VideoDome extends TextureDome<VideoTexture> {
  138747. /**
  138748. * Define the video source as a Monoscopic panoramic 360 video.
  138749. */
  138750. static readonly MODE_MONOSCOPIC: number;
  138751. /**
  138752. * Define the video source as a Stereoscopic TopBottom/OverUnder panoramic 360 video.
  138753. */
  138754. static readonly MODE_TOPBOTTOM: number;
  138755. /**
  138756. * Define the video source as a Stereoscopic Side by Side panoramic 360 video.
  138757. */
  138758. static readonly MODE_SIDEBYSIDE: number;
  138759. /**
  138760. * Get the video texture associated with this video dome
  138761. */
  138762. get videoTexture(): VideoTexture;
  138763. /**
  138764. * Get the video mode of this dome
  138765. */
  138766. get videoMode(): number;
  138767. /**
  138768. * Set the video mode of this dome.
  138769. * @see textureMode
  138770. */
  138771. set videoMode(value: number);
  138772. protected _initTexture(urlsOrElement: string | string[] | HTMLVideoElement, scene: Scene, options: any): VideoTexture;
  138773. }
  138774. }
  138775. declare module BABYLON {
  138776. /**
  138777. * This class can be used to get instrumentation data from a Babylon engine
  138778. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138779. */
  138780. export class EngineInstrumentation implements IDisposable {
  138781. /**
  138782. * Define the instrumented engine.
  138783. */
  138784. engine: Engine;
  138785. private _captureGPUFrameTime;
  138786. private _gpuFrameTimeToken;
  138787. private _gpuFrameTime;
  138788. private _captureShaderCompilationTime;
  138789. private _shaderCompilationTime;
  138790. private _onBeginFrameObserver;
  138791. private _onEndFrameObserver;
  138792. private _onBeforeShaderCompilationObserver;
  138793. private _onAfterShaderCompilationObserver;
  138794. /**
  138795. * Gets the perf counter used for GPU frame time
  138796. */
  138797. get gpuFrameTimeCounter(): PerfCounter;
  138798. /**
  138799. * Gets the GPU frame time capture status
  138800. */
  138801. get captureGPUFrameTime(): boolean;
  138802. /**
  138803. * Enable or disable the GPU frame time capture
  138804. */
  138805. set captureGPUFrameTime(value: boolean);
  138806. /**
  138807. * Gets the perf counter used for shader compilation time
  138808. */
  138809. get shaderCompilationTimeCounter(): PerfCounter;
  138810. /**
  138811. * Gets the shader compilation time capture status
  138812. */
  138813. get captureShaderCompilationTime(): boolean;
  138814. /**
  138815. * Enable or disable the shader compilation time capture
  138816. */
  138817. set captureShaderCompilationTime(value: boolean);
  138818. /**
  138819. * Instantiates a new engine instrumentation.
  138820. * This class can be used to get instrumentation data from a Babylon engine
  138821. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  138822. * @param engine Defines the engine to instrument
  138823. */
  138824. constructor(
  138825. /**
  138826. * Define the instrumented engine.
  138827. */
  138828. engine: Engine);
  138829. /**
  138830. * Dispose and release associated resources.
  138831. */
  138832. dispose(): void;
  138833. }
  138834. }
  138835. declare module BABYLON {
  138836. /**
  138837. * This class can be used to get instrumentation data from a Babylon engine
  138838. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  138839. */
  138840. export class SceneInstrumentation implements IDisposable {
  138841. /**
  138842. * Defines the scene to instrument
  138843. */
  138844. scene: Scene;
  138845. private _captureActiveMeshesEvaluationTime;
  138846. private _activeMeshesEvaluationTime;
  138847. private _captureRenderTargetsRenderTime;
  138848. private _renderTargetsRenderTime;
  138849. private _captureFrameTime;
  138850. private _frameTime;
  138851. private _captureRenderTime;
  138852. private _renderTime;
  138853. private _captureInterFrameTime;
  138854. private _interFrameTime;
  138855. private _captureParticlesRenderTime;
  138856. private _particlesRenderTime;
  138857. private _captureSpritesRenderTime;
  138858. private _spritesRenderTime;
  138859. private _capturePhysicsTime;
  138860. private _physicsTime;
  138861. private _captureAnimationsTime;
  138862. private _animationsTime;
  138863. private _captureCameraRenderTime;
  138864. private _cameraRenderTime;
  138865. private _onBeforeActiveMeshesEvaluationObserver;
  138866. private _onAfterActiveMeshesEvaluationObserver;
  138867. private _onBeforeRenderTargetsRenderObserver;
  138868. private _onAfterRenderTargetsRenderObserver;
  138869. private _onAfterRenderObserver;
  138870. private _onBeforeDrawPhaseObserver;
  138871. private _onAfterDrawPhaseObserver;
  138872. private _onBeforeAnimationsObserver;
  138873. private _onBeforeParticlesRenderingObserver;
  138874. private _onAfterParticlesRenderingObserver;
  138875. private _onBeforeSpritesRenderingObserver;
  138876. private _onAfterSpritesRenderingObserver;
  138877. private _onBeforePhysicsObserver;
  138878. private _onAfterPhysicsObserver;
  138879. private _onAfterAnimationsObserver;
  138880. private _onBeforeCameraRenderObserver;
  138881. private _onAfterCameraRenderObserver;
  138882. /**
  138883. * Gets the perf counter used for active meshes evaluation time
  138884. */
  138885. get activeMeshesEvaluationTimeCounter(): PerfCounter;
  138886. /**
  138887. * Gets the active meshes evaluation time capture status
  138888. */
  138889. get captureActiveMeshesEvaluationTime(): boolean;
  138890. /**
  138891. * Enable or disable the active meshes evaluation time capture
  138892. */
  138893. set captureActiveMeshesEvaluationTime(value: boolean);
  138894. /**
  138895. * Gets the perf counter used for render targets render time
  138896. */
  138897. get renderTargetsRenderTimeCounter(): PerfCounter;
  138898. /**
  138899. * Gets the render targets render time capture status
  138900. */
  138901. get captureRenderTargetsRenderTime(): boolean;
  138902. /**
  138903. * Enable or disable the render targets render time capture
  138904. */
  138905. set captureRenderTargetsRenderTime(value: boolean);
  138906. /**
  138907. * Gets the perf counter used for particles render time
  138908. */
  138909. get particlesRenderTimeCounter(): PerfCounter;
  138910. /**
  138911. * Gets the particles render time capture status
  138912. */
  138913. get captureParticlesRenderTime(): boolean;
  138914. /**
  138915. * Enable or disable the particles render time capture
  138916. */
  138917. set captureParticlesRenderTime(value: boolean);
  138918. /**
  138919. * Gets the perf counter used for sprites render time
  138920. */
  138921. get spritesRenderTimeCounter(): PerfCounter;
  138922. /**
  138923. * Gets the sprites render time capture status
  138924. */
  138925. get captureSpritesRenderTime(): boolean;
  138926. /**
  138927. * Enable or disable the sprites render time capture
  138928. */
  138929. set captureSpritesRenderTime(value: boolean);
  138930. /**
  138931. * Gets the perf counter used for physics time
  138932. */
  138933. get physicsTimeCounter(): PerfCounter;
  138934. /**
  138935. * Gets the physics time capture status
  138936. */
  138937. get capturePhysicsTime(): boolean;
  138938. /**
  138939. * Enable or disable the physics time capture
  138940. */
  138941. set capturePhysicsTime(value: boolean);
  138942. /**
  138943. * Gets the perf counter used for animations time
  138944. */
  138945. get animationsTimeCounter(): PerfCounter;
  138946. /**
  138947. * Gets the animations time capture status
  138948. */
  138949. get captureAnimationsTime(): boolean;
  138950. /**
  138951. * Enable or disable the animations time capture
  138952. */
  138953. set captureAnimationsTime(value: boolean);
  138954. /**
  138955. * Gets the perf counter used for frame time capture
  138956. */
  138957. get frameTimeCounter(): PerfCounter;
  138958. /**
  138959. * Gets the frame time capture status
  138960. */
  138961. get captureFrameTime(): boolean;
  138962. /**
  138963. * Enable or disable the frame time capture
  138964. */
  138965. set captureFrameTime(value: boolean);
  138966. /**
  138967. * Gets the perf counter used for inter-frames time capture
  138968. */
  138969. get interFrameTimeCounter(): PerfCounter;
  138970. /**
  138971. * Gets the inter-frames time capture status
  138972. */
  138973. get captureInterFrameTime(): boolean;
  138974. /**
  138975. * Enable or disable the inter-frames time capture
  138976. */
  138977. set captureInterFrameTime(value: boolean);
  138978. /**
  138979. * Gets the perf counter used for render time capture
  138980. */
  138981. get renderTimeCounter(): PerfCounter;
  138982. /**
  138983. * Gets the render time capture status
  138984. */
  138985. get captureRenderTime(): boolean;
  138986. /**
  138987. * Enable or disable the render time capture
  138988. */
  138989. set captureRenderTime(value: boolean);
  138990. /**
  138991. * Gets the perf counter used for camera render time capture
  138992. */
  138993. get cameraRenderTimeCounter(): PerfCounter;
  138994. /**
  138995. * Gets the camera render time capture status
  138996. */
  138997. get captureCameraRenderTime(): boolean;
  138998. /**
  138999. * Enable or disable the camera render time capture
  139000. */
  139001. set captureCameraRenderTime(value: boolean);
  139002. /**
  139003. * Gets the perf counter used for draw calls
  139004. */
  139005. get drawCallsCounter(): PerfCounter;
  139006. /**
  139007. * Instantiates a new scene instrumentation.
  139008. * This class can be used to get instrumentation data from a Babylon engine
  139009. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  139010. * @param scene Defines the scene to instrument
  139011. */
  139012. constructor(
  139013. /**
  139014. * Defines the scene to instrument
  139015. */
  139016. scene: Scene);
  139017. /**
  139018. * Dispose and release associated resources.
  139019. */
  139020. dispose(): void;
  139021. }
  139022. }
  139023. declare module BABYLON {
  139024. /** @hidden */
  139025. export var glowMapGenerationPixelShader: {
  139026. name: string;
  139027. shader: string;
  139028. };
  139029. }
  139030. declare module BABYLON {
  139031. /** @hidden */
  139032. export var glowMapGenerationVertexShader: {
  139033. name: string;
  139034. shader: string;
  139035. };
  139036. }
  139037. declare module BABYLON {
  139038. /**
  139039. * Effect layer options. This helps customizing the behaviour
  139040. * of the effect layer.
  139041. */
  139042. export interface IEffectLayerOptions {
  139043. /**
  139044. * Multiplication factor apply to the canvas size to compute the render target size
  139045. * used to generated the objects (the smaller the faster).
  139046. */
  139047. mainTextureRatio: number;
  139048. /**
  139049. * Enforces a fixed size texture to ensure effect stability across devices.
  139050. */
  139051. mainTextureFixedSize?: number;
  139052. /**
  139053. * Alpha blending mode used to apply the blur. Default depends of the implementation.
  139054. */
  139055. alphaBlendingMode: number;
  139056. /**
  139057. * The camera attached to the layer.
  139058. */
  139059. camera: Nullable<Camera>;
  139060. /**
  139061. * The rendering group to draw the layer in.
  139062. */
  139063. renderingGroupId: number;
  139064. }
  139065. /**
  139066. * The effect layer Helps adding post process effect blended with the main pass.
  139067. *
  139068. * This can be for instance use to generate glow or higlight effects on the scene.
  139069. *
  139070. * The effect layer class can not be used directly and is intented to inherited from to be
  139071. * customized per effects.
  139072. */
  139073. export abstract class EffectLayer {
  139074. private _vertexBuffers;
  139075. private _indexBuffer;
  139076. private _cachedDefines;
  139077. private _effectLayerMapGenerationEffect;
  139078. private _effectLayerOptions;
  139079. private _mergeEffect;
  139080. protected _scene: Scene;
  139081. protected _engine: Engine;
  139082. protected _maxSize: number;
  139083. protected _mainTextureDesiredSize: ISize;
  139084. protected _mainTexture: RenderTargetTexture;
  139085. protected _shouldRender: boolean;
  139086. protected _postProcesses: PostProcess[];
  139087. protected _textures: BaseTexture[];
  139088. protected _emissiveTextureAndColor: {
  139089. texture: Nullable<BaseTexture>;
  139090. color: Color4;
  139091. };
  139092. /**
  139093. * The name of the layer
  139094. */
  139095. name: string;
  139096. /**
  139097. * The clear color of the texture used to generate the glow map.
  139098. */
  139099. neutralColor: Color4;
  139100. /**
  139101. * Specifies whether the highlight layer is enabled or not.
  139102. */
  139103. isEnabled: boolean;
  139104. /**
  139105. * Gets the camera attached to the layer.
  139106. */
  139107. get camera(): Nullable<Camera>;
  139108. /**
  139109. * Gets the rendering group id the layer should render in.
  139110. */
  139111. get renderingGroupId(): number;
  139112. set renderingGroupId(renderingGroupId: number);
  139113. /**
  139114. * An event triggered when the effect layer has been disposed.
  139115. */
  139116. onDisposeObservable: Observable<EffectLayer>;
  139117. /**
  139118. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  139119. */
  139120. onBeforeRenderMainTextureObservable: Observable<EffectLayer>;
  139121. /**
  139122. * An event triggered when the generated texture is being merged in the scene.
  139123. */
  139124. onBeforeComposeObservable: Observable<EffectLayer>;
  139125. /**
  139126. * An event triggered when the mesh is rendered into the effect render target.
  139127. */
  139128. onBeforeRenderMeshToEffect: Observable<AbstractMesh>;
  139129. /**
  139130. * An event triggered after the mesh has been rendered into the effect render target.
  139131. */
  139132. onAfterRenderMeshToEffect: Observable<AbstractMesh>;
  139133. /**
  139134. * An event triggered when the generated texture has been merged in the scene.
  139135. */
  139136. onAfterComposeObservable: Observable<EffectLayer>;
  139137. /**
  139138. * An event triggered when the efffect layer changes its size.
  139139. */
  139140. onSizeChangedObservable: Observable<EffectLayer>;
  139141. /** @hidden */
  139142. static _SceneComponentInitialization: (scene: Scene) => void;
  139143. /**
  139144. * Instantiates a new effect Layer and references it in the scene.
  139145. * @param name The name of the layer
  139146. * @param scene The scene to use the layer in
  139147. */
  139148. constructor(
  139149. /** The Friendly of the effect in the scene */
  139150. name: string, scene: Scene);
  139151. /**
  139152. * Get the effect name of the layer.
  139153. * @return The effect name
  139154. */
  139155. abstract getEffectName(): string;
  139156. /**
  139157. * Checks for the readiness of the element composing the layer.
  139158. * @param subMesh the mesh to check for
  139159. * @param useInstances specify whether or not to use instances to render the mesh
  139160. * @return true if ready otherwise, false
  139161. */
  139162. abstract isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139163. /**
  139164. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139165. * @returns true if the effect requires stencil during the main canvas render pass.
  139166. */
  139167. abstract needStencil(): boolean;
  139168. /**
  139169. * Create the merge effect. This is the shader use to blit the information back
  139170. * to the main canvas at the end of the scene rendering.
  139171. * @returns The effect containing the shader used to merge the effect on the main canvas
  139172. */
  139173. protected abstract _createMergeEffect(): Effect;
  139174. /**
  139175. * Creates the render target textures and post processes used in the effect layer.
  139176. */
  139177. protected abstract _createTextureAndPostProcesses(): void;
  139178. /**
  139179. * Implementation specific of rendering the generating effect on the main canvas.
  139180. * @param effect The effect used to render through
  139181. */
  139182. protected abstract _internalRender(effect: Effect): void;
  139183. /**
  139184. * Sets the required values for both the emissive texture and and the main color.
  139185. */
  139186. protected abstract _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139187. /**
  139188. * Free any resources and references associated to a mesh.
  139189. * Internal use
  139190. * @param mesh The mesh to free.
  139191. */
  139192. abstract _disposeMesh(mesh: Mesh): void;
  139193. /**
  139194. * Serializes this layer (Glow or Highlight for example)
  139195. * @returns a serialized layer object
  139196. */
  139197. abstract serialize?(): any;
  139198. /**
  139199. * Initializes the effect layer with the required options.
  139200. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  139201. */
  139202. protected _init(options: Partial<IEffectLayerOptions>): void;
  139203. /**
  139204. * Generates the index buffer of the full screen quad blending to the main canvas.
  139205. */
  139206. private _generateIndexBuffer;
  139207. /**
  139208. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  139209. */
  139210. private _generateVertexBuffer;
  139211. /**
  139212. * Sets the main texture desired size which is the closest power of two
  139213. * of the engine canvas size.
  139214. */
  139215. private _setMainTextureSize;
  139216. /**
  139217. * Creates the main texture for the effect layer.
  139218. */
  139219. protected _createMainTexture(): void;
  139220. /**
  139221. * Adds specific effects defines.
  139222. * @param defines The defines to add specifics to.
  139223. */
  139224. protected _addCustomEffectDefines(defines: string[]): void;
  139225. /**
  139226. * Checks for the readiness of the element composing the layer.
  139227. * @param subMesh the mesh to check for
  139228. * @param useInstances specify whether or not to use instances to render the mesh
  139229. * @param emissiveTexture the associated emissive texture used to generate the glow
  139230. * @return true if ready otherwise, false
  139231. */
  139232. protected _isReady(subMesh: SubMesh, useInstances: boolean, emissiveTexture: Nullable<BaseTexture>): boolean;
  139233. /**
  139234. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  139235. */
  139236. render(): void;
  139237. /**
  139238. * Determine if a given mesh will be used in the current effect.
  139239. * @param mesh mesh to test
  139240. * @returns true if the mesh will be used
  139241. */
  139242. hasMesh(mesh: AbstractMesh): boolean;
  139243. /**
  139244. * Returns true if the layer contains information to display, otherwise false.
  139245. * @returns true if the glow layer should be rendered
  139246. */
  139247. shouldRender(): boolean;
  139248. /**
  139249. * Returns true if the mesh should render, otherwise false.
  139250. * @param mesh The mesh to render
  139251. * @returns true if it should render otherwise false
  139252. */
  139253. protected _shouldRenderMesh(mesh: AbstractMesh): boolean;
  139254. /**
  139255. * Returns true if the mesh can be rendered, otherwise false.
  139256. * @param mesh The mesh to render
  139257. * @param material The material used on the mesh
  139258. * @returns true if it can be rendered otherwise false
  139259. */
  139260. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139261. /**
  139262. * Returns true if the mesh should render, otherwise false.
  139263. * @param mesh The mesh to render
  139264. * @returns true if it should render otherwise false
  139265. */
  139266. protected _shouldRenderEmissiveTextureForMesh(): boolean;
  139267. /**
  139268. * Renders the submesh passed in parameter to the generation map.
  139269. */
  139270. protected _renderSubMesh(subMesh: SubMesh, enableAlphaMode?: boolean): void;
  139271. /**
  139272. * Defines whether the current material of the mesh should be use to render the effect.
  139273. * @param mesh defines the current mesh to render
  139274. */
  139275. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139276. /**
  139277. * Rebuild the required buffers.
  139278. * @hidden Internal use only.
  139279. */
  139280. _rebuild(): void;
  139281. /**
  139282. * Dispose only the render target textures and post process.
  139283. */
  139284. private _disposeTextureAndPostProcesses;
  139285. /**
  139286. * Dispose the highlight layer and free resources.
  139287. */
  139288. dispose(): void;
  139289. /**
  139290. * Gets the class name of the effect layer
  139291. * @returns the string with the class name of the effect layer
  139292. */
  139293. getClassName(): string;
  139294. /**
  139295. * Creates an effect layer from parsed effect layer data
  139296. * @param parsedEffectLayer defines effect layer data
  139297. * @param scene defines the current scene
  139298. * @param rootUrl defines the root URL containing the effect layer information
  139299. * @returns a parsed effect Layer
  139300. */
  139301. static Parse(parsedEffectLayer: any, scene: Scene, rootUrl: string): EffectLayer;
  139302. }
  139303. }
  139304. declare module BABYLON {
  139305. interface AbstractScene {
  139306. /**
  139307. * The list of effect layers (highlights/glow) added to the scene
  139308. * @see https://doc.babylonjs.com/how_to/highlight_layer
  139309. * @see https://doc.babylonjs.com/how_to/glow_layer
  139310. */
  139311. effectLayers: Array<EffectLayer>;
  139312. /**
  139313. * Removes the given effect layer from this scene.
  139314. * @param toRemove defines the effect layer to remove
  139315. * @returns the index of the removed effect layer
  139316. */
  139317. removeEffectLayer(toRemove: EffectLayer): number;
  139318. /**
  139319. * Adds the given effect layer to this scene
  139320. * @param newEffectLayer defines the effect layer to add
  139321. */
  139322. addEffectLayer(newEffectLayer: EffectLayer): void;
  139323. }
  139324. /**
  139325. * Defines the layer scene component responsible to manage any effect layers
  139326. * in a given scene.
  139327. */
  139328. export class EffectLayerSceneComponent implements ISceneSerializableComponent {
  139329. /**
  139330. * The component name helpfull to identify the component in the list of scene components.
  139331. */
  139332. readonly name: string;
  139333. /**
  139334. * The scene the component belongs to.
  139335. */
  139336. scene: Scene;
  139337. private _engine;
  139338. private _renderEffects;
  139339. private _needStencil;
  139340. private _previousStencilState;
  139341. /**
  139342. * Creates a new instance of the component for the given scene
  139343. * @param scene Defines the scene to register the component in
  139344. */
  139345. constructor(scene: Scene);
  139346. /**
  139347. * Registers the component in a given scene
  139348. */
  139349. register(): void;
  139350. /**
  139351. * Rebuilds the elements related to this component in case of
  139352. * context lost for instance.
  139353. */
  139354. rebuild(): void;
  139355. /**
  139356. * Serializes the component data to the specified json object
  139357. * @param serializationObject The object to serialize to
  139358. */
  139359. serialize(serializationObject: any): void;
  139360. /**
  139361. * Adds all the elements from the container to the scene
  139362. * @param container the container holding the elements
  139363. */
  139364. addFromContainer(container: AbstractScene): void;
  139365. /**
  139366. * Removes all the elements in the container from the scene
  139367. * @param container contains the elements to remove
  139368. * @param dispose if the removed element should be disposed (default: false)
  139369. */
  139370. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139371. /**
  139372. * Disposes the component and the associated ressources.
  139373. */
  139374. dispose(): void;
  139375. private _isReadyForMesh;
  139376. private _renderMainTexture;
  139377. private _setStencil;
  139378. private _setStencilBack;
  139379. private _draw;
  139380. private _drawCamera;
  139381. private _drawRenderingGroup;
  139382. }
  139383. }
  139384. declare module BABYLON {
  139385. /** @hidden */
  139386. export var glowMapMergePixelShader: {
  139387. name: string;
  139388. shader: string;
  139389. };
  139390. }
  139391. declare module BABYLON {
  139392. /** @hidden */
  139393. export var glowMapMergeVertexShader: {
  139394. name: string;
  139395. shader: string;
  139396. };
  139397. }
  139398. declare module BABYLON {
  139399. interface AbstractScene {
  139400. /**
  139401. * Return a the first highlight layer of the scene with a given name.
  139402. * @param name The name of the highlight layer to look for.
  139403. * @return The highlight layer if found otherwise null.
  139404. */
  139405. getGlowLayerByName(name: string): Nullable<GlowLayer>;
  139406. }
  139407. /**
  139408. * Glow layer options. This helps customizing the behaviour
  139409. * of the glow layer.
  139410. */
  139411. export interface IGlowLayerOptions {
  139412. /**
  139413. * Multiplication factor apply to the canvas size to compute the render target size
  139414. * used to generated the glowing objects (the smaller the faster).
  139415. */
  139416. mainTextureRatio: number;
  139417. /**
  139418. * Enforces a fixed size texture to ensure resize independant blur.
  139419. */
  139420. mainTextureFixedSize?: number;
  139421. /**
  139422. * How big is the kernel of the blur texture.
  139423. */
  139424. blurKernelSize: number;
  139425. /**
  139426. * The camera attached to the layer.
  139427. */
  139428. camera: Nullable<Camera>;
  139429. /**
  139430. * Enable MSAA by chosing the number of samples.
  139431. */
  139432. mainTextureSamples?: number;
  139433. /**
  139434. * The rendering group to draw the layer in.
  139435. */
  139436. renderingGroupId: number;
  139437. }
  139438. /**
  139439. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  139440. *
  139441. * Once instantiated in a scene, by default, all the emissive meshes will glow.
  139442. *
  139443. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  139444. */
  139445. export class GlowLayer extends EffectLayer {
  139446. /**
  139447. * Effect Name of the layer.
  139448. */
  139449. static readonly EffectName: string;
  139450. /**
  139451. * The default blur kernel size used for the glow.
  139452. */
  139453. static DefaultBlurKernelSize: number;
  139454. /**
  139455. * The default texture size ratio used for the glow.
  139456. */
  139457. static DefaultTextureRatio: number;
  139458. /**
  139459. * Sets the kernel size of the blur.
  139460. */
  139461. set blurKernelSize(value: number);
  139462. /**
  139463. * Gets the kernel size of the blur.
  139464. */
  139465. get blurKernelSize(): number;
  139466. /**
  139467. * Sets the glow intensity.
  139468. */
  139469. set intensity(value: number);
  139470. /**
  139471. * Gets the glow intensity.
  139472. */
  139473. get intensity(): number;
  139474. private _options;
  139475. private _intensity;
  139476. private _horizontalBlurPostprocess1;
  139477. private _verticalBlurPostprocess1;
  139478. private _horizontalBlurPostprocess2;
  139479. private _verticalBlurPostprocess2;
  139480. private _blurTexture1;
  139481. private _blurTexture2;
  139482. private _postProcesses1;
  139483. private _postProcesses2;
  139484. private _includedOnlyMeshes;
  139485. private _excludedMeshes;
  139486. private _meshesUsingTheirOwnMaterials;
  139487. /**
  139488. * Callback used to let the user override the color selection on a per mesh basis
  139489. */
  139490. customEmissiveColorSelector: (mesh: Mesh, subMesh: SubMesh, material: Material, result: Color4) => void;
  139491. /**
  139492. * Callback used to let the user override the texture selection on a per mesh basis
  139493. */
  139494. customEmissiveTextureSelector: (mesh: Mesh, subMesh: SubMesh, material: Material) => Texture;
  139495. /**
  139496. * Instantiates a new glow Layer and references it to the scene.
  139497. * @param name The name of the layer
  139498. * @param scene The scene to use the layer in
  139499. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  139500. */
  139501. constructor(name: string, scene: Scene, options?: Partial<IGlowLayerOptions>);
  139502. /**
  139503. * Get the effect name of the layer.
  139504. * @return The effect name
  139505. */
  139506. getEffectName(): string;
  139507. /**
  139508. * Create the merge effect. This is the shader use to blit the information back
  139509. * to the main canvas at the end of the scene rendering.
  139510. */
  139511. protected _createMergeEffect(): Effect;
  139512. /**
  139513. * Creates the render target textures and post processes used in the glow layer.
  139514. */
  139515. protected _createTextureAndPostProcesses(): void;
  139516. /**
  139517. * Checks for the readiness of the element composing the layer.
  139518. * @param subMesh the mesh to check for
  139519. * @param useInstances specify wether or not to use instances to render the mesh
  139520. * @param emissiveTexture the associated emissive texture used to generate the glow
  139521. * @return true if ready otherwise, false
  139522. */
  139523. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139524. /**
  139525. * Returns whether or nood the layer needs stencil enabled during the mesh rendering.
  139526. */
  139527. needStencil(): boolean;
  139528. /**
  139529. * Returns true if the mesh can be rendered, otherwise false.
  139530. * @param mesh The mesh to render
  139531. * @param material The material used on the mesh
  139532. * @returns true if it can be rendered otherwise false
  139533. */
  139534. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139535. /**
  139536. * Implementation specific of rendering the generating effect on the main canvas.
  139537. * @param effect The effect used to render through
  139538. */
  139539. protected _internalRender(effect: Effect): void;
  139540. /**
  139541. * Sets the required values for both the emissive texture and and the main color.
  139542. */
  139543. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139544. /**
  139545. * Returns true if the mesh should render, otherwise false.
  139546. * @param mesh The mesh to render
  139547. * @returns true if it should render otherwise false
  139548. */
  139549. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139550. /**
  139551. * Adds specific effects defines.
  139552. * @param defines The defines to add specifics to.
  139553. */
  139554. protected _addCustomEffectDefines(defines: string[]): void;
  139555. /**
  139556. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  139557. * @param mesh The mesh to exclude from the glow layer
  139558. */
  139559. addExcludedMesh(mesh: Mesh): void;
  139560. /**
  139561. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  139562. * @param mesh The mesh to remove
  139563. */
  139564. removeExcludedMesh(mesh: Mesh): void;
  139565. /**
  139566. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  139567. * @param mesh The mesh to include in the glow layer
  139568. */
  139569. addIncludedOnlyMesh(mesh: Mesh): void;
  139570. /**
  139571. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  139572. * @param mesh The mesh to remove
  139573. */
  139574. removeIncludedOnlyMesh(mesh: Mesh): void;
  139575. /**
  139576. * Determine if a given mesh will be used in the glow layer
  139577. * @param mesh The mesh to test
  139578. * @returns true if the mesh will be highlighted by the current glow layer
  139579. */
  139580. hasMesh(mesh: AbstractMesh): boolean;
  139581. /**
  139582. * Defines whether the current material of the mesh should be use to render the effect.
  139583. * @param mesh defines the current mesh to render
  139584. */
  139585. protected _useMeshMaterial(mesh: AbstractMesh): boolean;
  139586. /**
  139587. * Add a mesh to be rendered through its own material and not with emissive only.
  139588. * @param mesh The mesh for which we need to use its material
  139589. */
  139590. referenceMeshToUseItsOwnMaterial(mesh: AbstractMesh): void;
  139591. /**
  139592. * Remove a mesh from being rendered through its own material and not with emissive only.
  139593. * @param mesh The mesh for which we need to not use its material
  139594. */
  139595. unReferenceMeshFromUsingItsOwnMaterial(mesh: AbstractMesh): void;
  139596. /**
  139597. * Free any resources and references associated to a mesh.
  139598. * Internal use
  139599. * @param mesh The mesh to free.
  139600. * @hidden
  139601. */
  139602. _disposeMesh(mesh: Mesh): void;
  139603. /**
  139604. * Gets the class name of the effect layer
  139605. * @returns the string with the class name of the effect layer
  139606. */
  139607. getClassName(): string;
  139608. /**
  139609. * Serializes this glow layer
  139610. * @returns a serialized glow layer object
  139611. */
  139612. serialize(): any;
  139613. /**
  139614. * Creates a Glow Layer from parsed glow layer data
  139615. * @param parsedGlowLayer defines glow layer data
  139616. * @param scene defines the current scene
  139617. * @param rootUrl defines the root URL containing the glow layer information
  139618. * @returns a parsed Glow Layer
  139619. */
  139620. static Parse(parsedGlowLayer: any, scene: Scene, rootUrl: string): GlowLayer;
  139621. }
  139622. }
  139623. declare module BABYLON {
  139624. /** @hidden */
  139625. export var glowBlurPostProcessPixelShader: {
  139626. name: string;
  139627. shader: string;
  139628. };
  139629. }
  139630. declare module BABYLON {
  139631. interface AbstractScene {
  139632. /**
  139633. * Return a the first highlight layer of the scene with a given name.
  139634. * @param name The name of the highlight layer to look for.
  139635. * @return The highlight layer if found otherwise null.
  139636. */
  139637. getHighlightLayerByName(name: string): Nullable<HighlightLayer>;
  139638. }
  139639. /**
  139640. * Highlight layer options. This helps customizing the behaviour
  139641. * of the highlight layer.
  139642. */
  139643. export interface IHighlightLayerOptions {
  139644. /**
  139645. * Multiplication factor apply to the canvas size to compute the render target size
  139646. * used to generated the glowing objects (the smaller the faster).
  139647. */
  139648. mainTextureRatio: number;
  139649. /**
  139650. * Enforces a fixed size texture to ensure resize independant blur.
  139651. */
  139652. mainTextureFixedSize?: number;
  139653. /**
  139654. * Multiplication factor apply to the main texture size in the first step of the blur to reduce the size
  139655. * of the picture to blur (the smaller the faster).
  139656. */
  139657. blurTextureSizeRatio: number;
  139658. /**
  139659. * How big in texel of the blur texture is the vertical blur.
  139660. */
  139661. blurVerticalSize: number;
  139662. /**
  139663. * How big in texel of the blur texture is the horizontal blur.
  139664. */
  139665. blurHorizontalSize: number;
  139666. /**
  139667. * Alpha blending mode used to apply the blur. Default is combine.
  139668. */
  139669. alphaBlendingMode: number;
  139670. /**
  139671. * The camera attached to the layer.
  139672. */
  139673. camera: Nullable<Camera>;
  139674. /**
  139675. * Should we display highlight as a solid stroke?
  139676. */
  139677. isStroke?: boolean;
  139678. /**
  139679. * The rendering group to draw the layer in.
  139680. */
  139681. renderingGroupId: number;
  139682. }
  139683. /**
  139684. * The highlight layer Helps adding a glow effect around a mesh.
  139685. *
  139686. * Once instantiated in a scene, simply use the addMesh or removeMesh method to add or remove
  139687. * glowy meshes to your scene.
  139688. *
  139689. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  139690. */
  139691. export class HighlightLayer extends EffectLayer {
  139692. name: string;
  139693. /**
  139694. * Effect Name of the highlight layer.
  139695. */
  139696. static readonly EffectName: string;
  139697. /**
  139698. * The neutral color used during the preparation of the glow effect.
  139699. * This is black by default as the blend operation is a blend operation.
  139700. */
  139701. static NeutralColor: Color4;
  139702. /**
  139703. * Stencil value used for glowing meshes.
  139704. */
  139705. static GlowingMeshStencilReference: number;
  139706. /**
  139707. * Stencil value used for the other meshes in the scene.
  139708. */
  139709. static NormalMeshStencilReference: number;
  139710. /**
  139711. * Specifies whether or not the inner glow is ACTIVE in the layer.
  139712. */
  139713. innerGlow: boolean;
  139714. /**
  139715. * Specifies whether or not the outer glow is ACTIVE in the layer.
  139716. */
  139717. outerGlow: boolean;
  139718. /**
  139719. * Specifies the horizontal size of the blur.
  139720. */
  139721. set blurHorizontalSize(value: number);
  139722. /**
  139723. * Specifies the vertical size of the blur.
  139724. */
  139725. set blurVerticalSize(value: number);
  139726. /**
  139727. * Gets the horizontal size of the blur.
  139728. */
  139729. get blurHorizontalSize(): number;
  139730. /**
  139731. * Gets the vertical size of the blur.
  139732. */
  139733. get blurVerticalSize(): number;
  139734. /**
  139735. * An event triggered when the highlight layer is being blurred.
  139736. */
  139737. onBeforeBlurObservable: Observable<HighlightLayer>;
  139738. /**
  139739. * An event triggered when the highlight layer has been blurred.
  139740. */
  139741. onAfterBlurObservable: Observable<HighlightLayer>;
  139742. private _instanceGlowingMeshStencilReference;
  139743. private _options;
  139744. private _downSamplePostprocess;
  139745. private _horizontalBlurPostprocess;
  139746. private _verticalBlurPostprocess;
  139747. private _blurTexture;
  139748. private _meshes;
  139749. private _excludedMeshes;
  139750. /**
  139751. * Instantiates a new highlight Layer and references it to the scene..
  139752. * @param name The name of the layer
  139753. * @param scene The scene to use the layer in
  139754. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  139755. */
  139756. constructor(name: string, scene: Scene, options?: Partial<IHighlightLayerOptions>);
  139757. /**
  139758. * Get the effect name of the layer.
  139759. * @return The effect name
  139760. */
  139761. getEffectName(): string;
  139762. /**
  139763. * Create the merge effect. This is the shader use to blit the information back
  139764. * to the main canvas at the end of the scene rendering.
  139765. */
  139766. protected _createMergeEffect(): Effect;
  139767. /**
  139768. * Creates the render target textures and post processes used in the highlight layer.
  139769. */
  139770. protected _createTextureAndPostProcesses(): void;
  139771. /**
  139772. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  139773. */
  139774. needStencil(): boolean;
  139775. /**
  139776. * Checks for the readiness of the element composing the layer.
  139777. * @param subMesh the mesh to check for
  139778. * @param useInstances specify wether or not to use instances to render the mesh
  139779. * @param emissiveTexture the associated emissive texture used to generate the glow
  139780. * @return true if ready otherwise, false
  139781. */
  139782. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  139783. /**
  139784. * Implementation specific of rendering the generating effect on the main canvas.
  139785. * @param effect The effect used to render through
  139786. */
  139787. protected _internalRender(effect: Effect): void;
  139788. /**
  139789. * Returns true if the layer contains information to display, otherwise false.
  139790. */
  139791. shouldRender(): boolean;
  139792. /**
  139793. * Returns true if the mesh should render, otherwise false.
  139794. * @param mesh The mesh to render
  139795. * @returns true if it should render otherwise false
  139796. */
  139797. protected _shouldRenderMesh(mesh: Mesh): boolean;
  139798. /**
  139799. * Returns true if the mesh can be rendered, otherwise false.
  139800. * @param mesh The mesh to render
  139801. * @param material The material used on the mesh
  139802. * @returns true if it can be rendered otherwise false
  139803. */
  139804. protected _canRenderMesh(mesh: AbstractMesh, material: Material): boolean;
  139805. /**
  139806. * Adds specific effects defines.
  139807. * @param defines The defines to add specifics to.
  139808. */
  139809. protected _addCustomEffectDefines(defines: string[]): void;
  139810. /**
  139811. * Sets the required values for both the emissive texture and and the main color.
  139812. */
  139813. protected _setEmissiveTextureAndColor(mesh: Mesh, subMesh: SubMesh, material: Material): void;
  139814. /**
  139815. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  139816. * @param mesh The mesh to exclude from the highlight layer
  139817. */
  139818. addExcludedMesh(mesh: Mesh): void;
  139819. /**
  139820. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  139821. * @param mesh The mesh to highlight
  139822. */
  139823. removeExcludedMesh(mesh: Mesh): void;
  139824. /**
  139825. * Determine if a given mesh will be highlighted by the current HighlightLayer
  139826. * @param mesh mesh to test
  139827. * @returns true if the mesh will be highlighted by the current HighlightLayer
  139828. */
  139829. hasMesh(mesh: AbstractMesh): boolean;
  139830. /**
  139831. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  139832. * @param mesh The mesh to highlight
  139833. * @param color The color of the highlight
  139834. * @param glowEmissiveOnly Extract the glow from the emissive texture
  139835. */
  139836. addMesh(mesh: Mesh, color: Color3, glowEmissiveOnly?: boolean): void;
  139837. /**
  139838. * Remove a mesh from the highlight layer in order to make it stop glowing.
  139839. * @param mesh The mesh to highlight
  139840. */
  139841. removeMesh(mesh: Mesh): void;
  139842. /**
  139843. * Remove all the meshes currently referenced in the highlight layer
  139844. */
  139845. removeAllMeshes(): void;
  139846. /**
  139847. * Force the stencil to the normal expected value for none glowing parts
  139848. */
  139849. private _defaultStencilReference;
  139850. /**
  139851. * Free any resources and references associated to a mesh.
  139852. * Internal use
  139853. * @param mesh The mesh to free.
  139854. * @hidden
  139855. */
  139856. _disposeMesh(mesh: Mesh): void;
  139857. /**
  139858. * Dispose the highlight layer and free resources.
  139859. */
  139860. dispose(): void;
  139861. /**
  139862. * Gets the class name of the effect layer
  139863. * @returns the string with the class name of the effect layer
  139864. */
  139865. getClassName(): string;
  139866. /**
  139867. * Serializes this Highlight layer
  139868. * @returns a serialized Highlight layer object
  139869. */
  139870. serialize(): any;
  139871. /**
  139872. * Creates a Highlight layer from parsed Highlight layer data
  139873. * @param parsedHightlightLayer defines the Highlight layer data
  139874. * @param scene defines the current scene
  139875. * @param rootUrl defines the root URL containing the Highlight layer information
  139876. * @returns a parsed Highlight layer
  139877. */
  139878. static Parse(parsedHightlightLayer: any, scene: Scene, rootUrl: string): HighlightLayer;
  139879. }
  139880. }
  139881. declare module BABYLON {
  139882. interface AbstractScene {
  139883. /**
  139884. * The list of layers (background and foreground) of the scene
  139885. */
  139886. layers: Array<Layer>;
  139887. }
  139888. /**
  139889. * Defines the layer scene component responsible to manage any layers
  139890. * in a given scene.
  139891. */
  139892. export class LayerSceneComponent implements ISceneComponent {
  139893. /**
  139894. * The component name helpfull to identify the component in the list of scene components.
  139895. */
  139896. readonly name: string;
  139897. /**
  139898. * The scene the component belongs to.
  139899. */
  139900. scene: Scene;
  139901. private _engine;
  139902. /**
  139903. * Creates a new instance of the component for the given scene
  139904. * @param scene Defines the scene to register the component in
  139905. */
  139906. constructor(scene: Scene);
  139907. /**
  139908. * Registers the component in a given scene
  139909. */
  139910. register(): void;
  139911. /**
  139912. * Rebuilds the elements related to this component in case of
  139913. * context lost for instance.
  139914. */
  139915. rebuild(): void;
  139916. /**
  139917. * Disposes the component and the associated ressources.
  139918. */
  139919. dispose(): void;
  139920. private _draw;
  139921. private _drawCameraPredicate;
  139922. private _drawCameraBackground;
  139923. private _drawCameraForeground;
  139924. private _drawRenderTargetPredicate;
  139925. private _drawRenderTargetBackground;
  139926. private _drawRenderTargetForeground;
  139927. /**
  139928. * Adds all the elements from the container to the scene
  139929. * @param container the container holding the elements
  139930. */
  139931. addFromContainer(container: AbstractScene): void;
  139932. /**
  139933. * Removes all the elements in the container from the scene
  139934. * @param container contains the elements to remove
  139935. * @param dispose if the removed element should be disposed (default: false)
  139936. */
  139937. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  139938. }
  139939. }
  139940. declare module BABYLON {
  139941. /** @hidden */
  139942. export var layerPixelShader: {
  139943. name: string;
  139944. shader: string;
  139945. };
  139946. }
  139947. declare module BABYLON {
  139948. /** @hidden */
  139949. export var layerVertexShader: {
  139950. name: string;
  139951. shader: string;
  139952. };
  139953. }
  139954. declare module BABYLON {
  139955. /**
  139956. * This represents a full screen 2d layer.
  139957. * This can be useful to display a picture in the background of your scene for instance.
  139958. * @see https://www.babylonjs-playground.com/#08A2BS#1
  139959. */
  139960. export class Layer {
  139961. /**
  139962. * Define the name of the layer.
  139963. */
  139964. name: string;
  139965. /**
  139966. * Define the texture the layer should display.
  139967. */
  139968. texture: Nullable<Texture>;
  139969. /**
  139970. * Is the layer in background or foreground.
  139971. */
  139972. isBackground: boolean;
  139973. /**
  139974. * Define the color of the layer (instead of texture).
  139975. */
  139976. color: Color4;
  139977. /**
  139978. * Define the scale of the layer in order to zoom in out of the texture.
  139979. */
  139980. scale: Vector2;
  139981. /**
  139982. * Define an offset for the layer in order to shift the texture.
  139983. */
  139984. offset: Vector2;
  139985. /**
  139986. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  139987. */
  139988. alphaBlendingMode: number;
  139989. /**
  139990. * Define if the layer should alpha test or alpha blend with the rest of the scene.
  139991. * Alpha test will not mix with the background color in case of transparency.
  139992. * It will either use the texture color or the background depending on the alpha value of the current pixel.
  139993. */
  139994. alphaTest: boolean;
  139995. /**
  139996. * Define a mask to restrict the layer to only some of the scene cameras.
  139997. */
  139998. layerMask: number;
  139999. /**
  140000. * Define the list of render target the layer is visible into.
  140001. */
  140002. renderTargetTextures: RenderTargetTexture[];
  140003. /**
  140004. * Define if the layer is only used in renderTarget or if it also
  140005. * renders in the main frame buffer of the canvas.
  140006. */
  140007. renderOnlyInRenderTargetTextures: boolean;
  140008. private _scene;
  140009. private _vertexBuffers;
  140010. private _indexBuffer;
  140011. private _effect;
  140012. private _previousDefines;
  140013. /**
  140014. * An event triggered when the layer is disposed.
  140015. */
  140016. onDisposeObservable: Observable<Layer>;
  140017. private _onDisposeObserver;
  140018. /**
  140019. * Back compatibility with callback before the onDisposeObservable existed.
  140020. * The set callback will be triggered when the layer has been disposed.
  140021. */
  140022. set onDispose(callback: () => void);
  140023. /**
  140024. * An event triggered before rendering the scene
  140025. */
  140026. onBeforeRenderObservable: Observable<Layer>;
  140027. private _onBeforeRenderObserver;
  140028. /**
  140029. * Back compatibility with callback before the onBeforeRenderObservable existed.
  140030. * The set callback will be triggered just before rendering the layer.
  140031. */
  140032. set onBeforeRender(callback: () => void);
  140033. /**
  140034. * An event triggered after rendering the scene
  140035. */
  140036. onAfterRenderObservable: Observable<Layer>;
  140037. private _onAfterRenderObserver;
  140038. /**
  140039. * Back compatibility with callback before the onAfterRenderObservable existed.
  140040. * The set callback will be triggered just after rendering the layer.
  140041. */
  140042. set onAfterRender(callback: () => void);
  140043. /**
  140044. * Instantiates a new layer.
  140045. * This represents a full screen 2d layer.
  140046. * This can be useful to display a picture in the background of your scene for instance.
  140047. * @see https://www.babylonjs-playground.com/#08A2BS#1
  140048. * @param name Define the name of the layer in the scene
  140049. * @param imgUrl Define the url of the texture to display in the layer
  140050. * @param scene Define the scene the layer belongs to
  140051. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  140052. * @param color Defines a color for the layer
  140053. */
  140054. constructor(
  140055. /**
  140056. * Define the name of the layer.
  140057. */
  140058. name: string, imgUrl: Nullable<string>, scene: Nullable<Scene>, isBackground?: boolean, color?: Color4);
  140059. private _createIndexBuffer;
  140060. /** @hidden */
  140061. _rebuild(): void;
  140062. /**
  140063. * Renders the layer in the scene.
  140064. */
  140065. render(): void;
  140066. /**
  140067. * Disposes and releases the associated ressources.
  140068. */
  140069. dispose(): void;
  140070. }
  140071. }
  140072. declare module BABYLON {
  140073. /** @hidden */
  140074. export var lensFlarePixelShader: {
  140075. name: string;
  140076. shader: string;
  140077. };
  140078. }
  140079. declare module BABYLON {
  140080. /** @hidden */
  140081. export var lensFlareVertexShader: {
  140082. name: string;
  140083. shader: string;
  140084. };
  140085. }
  140086. declare module BABYLON {
  140087. /**
  140088. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140089. * It is usually composed of several `lensFlare`.
  140090. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140091. */
  140092. export class LensFlareSystem {
  140093. /**
  140094. * Define the name of the lens flare system
  140095. */
  140096. name: string;
  140097. /**
  140098. * List of lens flares used in this system.
  140099. */
  140100. lensFlares: LensFlare[];
  140101. /**
  140102. * Define a limit from the border the lens flare can be visible.
  140103. */
  140104. borderLimit: number;
  140105. /**
  140106. * Define a viewport border we do not want to see the lens flare in.
  140107. */
  140108. viewportBorder: number;
  140109. /**
  140110. * Define a predicate which could limit the list of meshes able to occlude the effect.
  140111. */
  140112. meshesSelectionPredicate: (mesh: AbstractMesh) => boolean;
  140113. /**
  140114. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  140115. */
  140116. layerMask: number;
  140117. /**
  140118. * Define the id of the lens flare system in the scene.
  140119. * (equal to name by default)
  140120. */
  140121. id: string;
  140122. private _scene;
  140123. private _emitter;
  140124. private _vertexBuffers;
  140125. private _indexBuffer;
  140126. private _effect;
  140127. private _positionX;
  140128. private _positionY;
  140129. private _isEnabled;
  140130. /** @hidden */
  140131. static _SceneComponentInitialization: (scene: Scene) => void;
  140132. /**
  140133. * Instantiates a lens flare system.
  140134. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  140135. * It is usually composed of several `lensFlare`.
  140136. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140137. * @param name Define the name of the lens flare system in the scene
  140138. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  140139. * @param scene Define the scene the lens flare system belongs to
  140140. */
  140141. constructor(
  140142. /**
  140143. * Define the name of the lens flare system
  140144. */
  140145. name: string, emitter: any, scene: Scene);
  140146. /**
  140147. * Define if the lens flare system is enabled.
  140148. */
  140149. get isEnabled(): boolean;
  140150. set isEnabled(value: boolean);
  140151. /**
  140152. * Get the scene the effects belongs to.
  140153. * @returns the scene holding the lens flare system
  140154. */
  140155. getScene(): Scene;
  140156. /**
  140157. * Get the emitter of the lens flare system.
  140158. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140159. * @returns the emitter of the lens flare system
  140160. */
  140161. getEmitter(): any;
  140162. /**
  140163. * Set the emitter of the lens flare system.
  140164. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  140165. * @param newEmitter Define the new emitter of the system
  140166. */
  140167. setEmitter(newEmitter: any): void;
  140168. /**
  140169. * Get the lens flare system emitter position.
  140170. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  140171. * @returns the position
  140172. */
  140173. getEmitterPosition(): Vector3;
  140174. /**
  140175. * @hidden
  140176. */
  140177. computeEffectivePosition(globalViewport: Viewport): boolean;
  140178. /** @hidden */
  140179. _isVisible(): boolean;
  140180. /**
  140181. * @hidden
  140182. */
  140183. render(): boolean;
  140184. /**
  140185. * Dispose and release the lens flare with its associated resources.
  140186. */
  140187. dispose(): void;
  140188. /**
  140189. * Parse a lens flare system from a JSON repressentation
  140190. * @param parsedLensFlareSystem Define the JSON to parse
  140191. * @param scene Define the scene the parsed system should be instantiated in
  140192. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  140193. * @returns the parsed system
  140194. */
  140195. static Parse(parsedLensFlareSystem: any, scene: Scene, rootUrl: string): LensFlareSystem;
  140196. /**
  140197. * Serialize the current Lens Flare System into a JSON representation.
  140198. * @returns the serialized JSON
  140199. */
  140200. serialize(): any;
  140201. }
  140202. }
  140203. declare module BABYLON {
  140204. /**
  140205. * This represents one of the lens effect in a `lensFlareSystem`.
  140206. * It controls one of the indiviual texture used in the effect.
  140207. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140208. */
  140209. export class LensFlare {
  140210. /**
  140211. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140212. */
  140213. size: number;
  140214. /**
  140215. * 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.
  140216. */
  140217. position: number;
  140218. /**
  140219. * Define the lens color.
  140220. */
  140221. color: Color3;
  140222. /**
  140223. * Define the lens texture.
  140224. */
  140225. texture: Nullable<Texture>;
  140226. /**
  140227. * Define the alpha mode to render this particular lens.
  140228. */
  140229. alphaMode: number;
  140230. private _system;
  140231. /**
  140232. * Creates a new Lens Flare.
  140233. * This represents one of the lens effect in a `lensFlareSystem`.
  140234. * It controls one of the indiviual texture used in the effect.
  140235. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140236. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  140237. * @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.
  140238. * @param color Define the lens color
  140239. * @param imgUrl Define the lens texture url
  140240. * @param system Define the `lensFlareSystem` this flare is part of
  140241. * @returns The newly created Lens Flare
  140242. */
  140243. static AddFlare(size: number, position: number, color: Color3, imgUrl: string, system: LensFlareSystem): LensFlare;
  140244. /**
  140245. * Instantiates a new Lens Flare.
  140246. * This represents one of the lens effect in a `lensFlareSystem`.
  140247. * It controls one of the indiviual texture used in the effect.
  140248. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140249. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  140250. * @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.
  140251. * @param color Define the lens color
  140252. * @param imgUrl Define the lens texture url
  140253. * @param system Define the `lensFlareSystem` this flare is part of
  140254. */
  140255. constructor(
  140256. /**
  140257. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  140258. */
  140259. size: number,
  140260. /**
  140261. * 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.
  140262. */
  140263. position: number, color: Color3, imgUrl: string, system: LensFlareSystem);
  140264. /**
  140265. * Dispose and release the lens flare with its associated resources.
  140266. */
  140267. dispose(): void;
  140268. }
  140269. }
  140270. declare module BABYLON {
  140271. interface AbstractScene {
  140272. /**
  140273. * The list of lens flare system added to the scene
  140274. * @see https://doc.babylonjs.com/how_to/how_to_use_lens_flares
  140275. */
  140276. lensFlareSystems: Array<LensFlareSystem>;
  140277. /**
  140278. * Removes the given lens flare system from this scene.
  140279. * @param toRemove The lens flare system to remove
  140280. * @returns The index of the removed lens flare system
  140281. */
  140282. removeLensFlareSystem(toRemove: LensFlareSystem): number;
  140283. /**
  140284. * Adds the given lens flare system to this scene
  140285. * @param newLensFlareSystem The lens flare system to add
  140286. */
  140287. addLensFlareSystem(newLensFlareSystem: LensFlareSystem): void;
  140288. /**
  140289. * Gets a lens flare system using its name
  140290. * @param name defines the name to look for
  140291. * @returns the lens flare system or null if not found
  140292. */
  140293. getLensFlareSystemByName(name: string): Nullable<LensFlareSystem>;
  140294. /**
  140295. * Gets a lens flare system using its id
  140296. * @param id defines the id to look for
  140297. * @returns the lens flare system or null if not found
  140298. */
  140299. getLensFlareSystemByID(id: string): Nullable<LensFlareSystem>;
  140300. }
  140301. /**
  140302. * Defines the lens flare scene component responsible to manage any lens flares
  140303. * in a given scene.
  140304. */
  140305. export class LensFlareSystemSceneComponent implements ISceneSerializableComponent {
  140306. /**
  140307. * The component name helpfull to identify the component in the list of scene components.
  140308. */
  140309. readonly name: string;
  140310. /**
  140311. * The scene the component belongs to.
  140312. */
  140313. scene: Scene;
  140314. /**
  140315. * Creates a new instance of the component for the given scene
  140316. * @param scene Defines the scene to register the component in
  140317. */
  140318. constructor(scene: Scene);
  140319. /**
  140320. * Registers the component in a given scene
  140321. */
  140322. register(): void;
  140323. /**
  140324. * Rebuilds the elements related to this component in case of
  140325. * context lost for instance.
  140326. */
  140327. rebuild(): void;
  140328. /**
  140329. * Adds all the elements from the container to the scene
  140330. * @param container the container holding the elements
  140331. */
  140332. addFromContainer(container: AbstractScene): void;
  140333. /**
  140334. * Removes all the elements in the container from the scene
  140335. * @param container contains the elements to remove
  140336. * @param dispose if the removed element should be disposed (default: false)
  140337. */
  140338. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140339. /**
  140340. * Serializes the component data to the specified json object
  140341. * @param serializationObject The object to serialize to
  140342. */
  140343. serialize(serializationObject: any): void;
  140344. /**
  140345. * Disposes the component and the associated ressources.
  140346. */
  140347. dispose(): void;
  140348. private _draw;
  140349. }
  140350. }
  140351. declare module BABYLON {
  140352. /** @hidden */
  140353. export var depthPixelShader: {
  140354. name: string;
  140355. shader: string;
  140356. };
  140357. }
  140358. declare module BABYLON {
  140359. /** @hidden */
  140360. export var depthVertexShader: {
  140361. name: string;
  140362. shader: string;
  140363. };
  140364. }
  140365. declare module BABYLON {
  140366. /**
  140367. * This represents a depth renderer in Babylon.
  140368. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  140369. */
  140370. export class DepthRenderer {
  140371. private _scene;
  140372. private _depthMap;
  140373. private _effect;
  140374. private readonly _storeNonLinearDepth;
  140375. private readonly _clearColor;
  140376. /** Get if the depth renderer is using packed depth or not */
  140377. readonly isPacked: boolean;
  140378. private _cachedDefines;
  140379. private _camera;
  140380. /** Enable or disable the depth renderer. When disabled, the depth texture is not updated */
  140381. enabled: boolean;
  140382. /**
  140383. * Specifiess that the depth renderer will only be used within
  140384. * the camera it is created for.
  140385. * This can help forcing its rendering during the camera processing.
  140386. */
  140387. useOnlyInActiveCamera: boolean;
  140388. /** @hidden */
  140389. static _SceneComponentInitialization: (scene: Scene) => void;
  140390. /**
  140391. * Instantiates a depth renderer
  140392. * @param scene The scene the renderer belongs to
  140393. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  140394. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  140395. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  140396. */
  140397. constructor(scene: Scene, type?: number, camera?: Nullable<Camera>, storeNonLinearDepth?: boolean);
  140398. /**
  140399. * Creates the depth rendering effect and checks if the effect is ready.
  140400. * @param subMesh The submesh to be used to render the depth map of
  140401. * @param useInstances If multiple world instances should be used
  140402. * @returns if the depth renderer is ready to render the depth map
  140403. */
  140404. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  140405. /**
  140406. * Gets the texture which the depth map will be written to.
  140407. * @returns The depth map texture
  140408. */
  140409. getDepthMap(): RenderTargetTexture;
  140410. /**
  140411. * Disposes of the depth renderer.
  140412. */
  140413. dispose(): void;
  140414. }
  140415. }
  140416. declare module BABYLON {
  140417. /** @hidden */
  140418. export var minmaxReduxPixelShader: {
  140419. name: string;
  140420. shader: string;
  140421. };
  140422. }
  140423. declare module BABYLON {
  140424. /**
  140425. * This class computes a min/max reduction from a texture: it means it computes the minimum
  140426. * and maximum values from all values of the texture.
  140427. * It is performed on the GPU for better performances, thanks to a succession of post processes.
  140428. * The source values are read from the red channel of the texture.
  140429. */
  140430. export class MinMaxReducer {
  140431. /**
  140432. * Observable triggered when the computation has been performed
  140433. */
  140434. onAfterReductionPerformed: Observable<{
  140435. min: number;
  140436. max: number;
  140437. }>;
  140438. protected _camera: Camera;
  140439. protected _sourceTexture: Nullable<RenderTargetTexture>;
  140440. protected _reductionSteps: Nullable<Array<PostProcess>>;
  140441. protected _postProcessManager: PostProcessManager;
  140442. protected _onAfterUnbindObserver: Nullable<Observer<RenderTargetTexture>>;
  140443. protected _forceFullscreenViewport: boolean;
  140444. /**
  140445. * Creates a min/max reducer
  140446. * @param camera The camera to use for the post processes
  140447. */
  140448. constructor(camera: Camera);
  140449. /**
  140450. * Gets the texture used to read the values from.
  140451. */
  140452. get sourceTexture(): Nullable<RenderTargetTexture>;
  140453. /**
  140454. * Sets the source texture to read the values from.
  140455. * One must indicate if the texture is a depth texture or not through the depthRedux parameter
  140456. * because in such textures '1' value must not be taken into account to compute the maximum
  140457. * as this value is used to clear the texture.
  140458. * Note that the computation is not activated by calling this function, you must call activate() for that!
  140459. * @param sourceTexture The texture to read the values from. The values should be in the red channel.
  140460. * @param depthRedux Indicates if the texture is a depth texture or not
  140461. * @param type The type of the textures created for the reduction (defaults to TEXTURETYPE_HALF_FLOAT)
  140462. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140463. */
  140464. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140465. /**
  140466. * Defines the refresh rate of the computation.
  140467. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140468. */
  140469. get refreshRate(): number;
  140470. set refreshRate(value: number);
  140471. protected _activated: boolean;
  140472. /**
  140473. * Gets the activation status of the reducer
  140474. */
  140475. get activated(): boolean;
  140476. /**
  140477. * Activates the reduction computation.
  140478. * When activated, the observers registered in onAfterReductionPerformed are
  140479. * called after the compuation is performed
  140480. */
  140481. activate(): void;
  140482. /**
  140483. * Deactivates the reduction computation.
  140484. */
  140485. deactivate(): void;
  140486. /**
  140487. * Disposes the min/max reducer
  140488. * @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.
  140489. */
  140490. dispose(disposeAll?: boolean): void;
  140491. }
  140492. }
  140493. declare module BABYLON {
  140494. /**
  140495. * This class is a small wrapper around the MinMaxReducer class to compute the min/max values of a depth texture
  140496. */
  140497. export class DepthReducer extends MinMaxReducer {
  140498. private _depthRenderer;
  140499. private _depthRendererId;
  140500. /**
  140501. * Gets the depth renderer used for the computation.
  140502. * Note that the result is null if you provide your own renderer when calling setDepthRenderer.
  140503. */
  140504. get depthRenderer(): Nullable<DepthRenderer>;
  140505. /**
  140506. * Creates a depth reducer
  140507. * @param camera The camera used to render the depth texture
  140508. */
  140509. constructor(camera: Camera);
  140510. /**
  140511. * Sets the depth renderer to use to generate the depth map
  140512. * @param depthRenderer The depth renderer to use. If not provided, a new one will be created automatically
  140513. * @param type The texture type of the depth map (default: TEXTURETYPE_HALF_FLOAT)
  140514. * @param forceFullscreenViewport Forces the post processes used for the reduction to be applied without taking into account viewport (defaults to true)
  140515. */
  140516. setDepthRenderer(depthRenderer?: Nullable<DepthRenderer>, type?: number, forceFullscreenViewport?: boolean): void;
  140517. /** @hidden */
  140518. setSourceTexture(sourceTexture: RenderTargetTexture, depthRedux: boolean, type?: number, forceFullscreenViewport?: boolean): void;
  140519. /**
  140520. * Activates the reduction computation.
  140521. * When activated, the observers registered in onAfterReductionPerformed are
  140522. * called after the compuation is performed
  140523. */
  140524. activate(): void;
  140525. /**
  140526. * Deactivates the reduction computation.
  140527. */
  140528. deactivate(): void;
  140529. /**
  140530. * Disposes the depth reducer
  140531. * @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.
  140532. */
  140533. dispose(disposeAll?: boolean): void;
  140534. }
  140535. }
  140536. declare module BABYLON {
  140537. /**
  140538. * A CSM implementation allowing casting shadows on large scenes.
  140539. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140540. * Based on: https://github.com/TheRealMJP/Shadows and https://johanmedestrom.wordpress.com/2016/03/18/opengl-cascaded-shadow-maps/
  140541. */
  140542. export class CascadedShadowGenerator extends ShadowGenerator {
  140543. private static readonly frustumCornersNDCSpace;
  140544. /**
  140545. * Name of the CSM class
  140546. */
  140547. static CLASSNAME: string;
  140548. /**
  140549. * Defines the default number of cascades used by the CSM.
  140550. */
  140551. static readonly DEFAULT_CASCADES_COUNT: number;
  140552. /**
  140553. * Defines the minimum number of cascades used by the CSM.
  140554. */
  140555. static readonly MIN_CASCADES_COUNT: number;
  140556. /**
  140557. * Defines the maximum number of cascades used by the CSM.
  140558. */
  140559. static readonly MAX_CASCADES_COUNT: number;
  140560. protected _validateFilter(filter: number): number;
  140561. /**
  140562. * Gets or sets the actual darkness of the soft shadows while using PCSS filtering (value between 0. and 1.)
  140563. */
  140564. penumbraDarkness: number;
  140565. private _numCascades;
  140566. /**
  140567. * Gets or set the number of cascades used by the CSM.
  140568. */
  140569. get numCascades(): number;
  140570. set numCascades(value: number);
  140571. /**
  140572. * Sets this to true if you want that the edges of the shadows don't "swimm" / "shimmer" when rotating the camera.
  140573. * The trade off is that you lose some precision in the shadow rendering when enabling this setting.
  140574. */
  140575. stabilizeCascades: boolean;
  140576. private _freezeShadowCastersBoundingInfo;
  140577. private _freezeShadowCastersBoundingInfoObservable;
  140578. /**
  140579. * Enables or disables the shadow casters bounding info computation.
  140580. * If your shadow casters don't move, you can disable this feature.
  140581. * If it is enabled, the bounding box computation is done every frame.
  140582. */
  140583. get freezeShadowCastersBoundingInfo(): boolean;
  140584. set freezeShadowCastersBoundingInfo(freeze: boolean);
  140585. private _scbiMin;
  140586. private _scbiMax;
  140587. protected _computeShadowCastersBoundingInfo(): void;
  140588. protected _shadowCastersBoundingInfo: BoundingInfo;
  140589. /**
  140590. * Gets or sets the shadow casters bounding info.
  140591. * If you provide your own shadow casters bounding info, first enable freezeShadowCastersBoundingInfo
  140592. * so that the system won't overwrite the bounds you provide
  140593. */
  140594. get shadowCastersBoundingInfo(): BoundingInfo;
  140595. set shadowCastersBoundingInfo(boundingInfo: BoundingInfo);
  140596. protected _breaksAreDirty: boolean;
  140597. protected _minDistance: number;
  140598. protected _maxDistance: number;
  140599. /**
  140600. * Sets the minimal and maximal distances to use when computing the cascade breaks.
  140601. *
  140602. * The values of min / max are typically the depth zmin and zmax values of your scene, for a given frame.
  140603. * If you don't know these values, simply leave them to their defaults and don't call this function.
  140604. * @param min minimal distance for the breaks (default to 0.)
  140605. * @param max maximal distance for the breaks (default to 1.)
  140606. */
  140607. setMinMaxDistance(min: number, max: number): void;
  140608. /** Gets the minimal distance used in the cascade break computation */
  140609. get minDistance(): number;
  140610. /** Gets the maximal distance used in the cascade break computation */
  140611. get maxDistance(): number;
  140612. /**
  140613. * Gets the class name of that object
  140614. * @returns "CascadedShadowGenerator"
  140615. */
  140616. getClassName(): string;
  140617. private _cascadeMinExtents;
  140618. private _cascadeMaxExtents;
  140619. /**
  140620. * Gets a cascade minimum extents
  140621. * @param cascadeIndex index of the cascade
  140622. * @returns the minimum cascade extents
  140623. */
  140624. getCascadeMinExtents(cascadeIndex: number): Nullable<Vector3>;
  140625. /**
  140626. * Gets a cascade maximum extents
  140627. * @param cascadeIndex index of the cascade
  140628. * @returns the maximum cascade extents
  140629. */
  140630. getCascadeMaxExtents(cascadeIndex: number): Nullable<Vector3>;
  140631. private _cascades;
  140632. private _currentLayer;
  140633. private _viewSpaceFrustumsZ;
  140634. private _viewMatrices;
  140635. private _projectionMatrices;
  140636. private _transformMatrices;
  140637. private _transformMatricesAsArray;
  140638. private _frustumLengths;
  140639. private _lightSizeUVCorrection;
  140640. private _depthCorrection;
  140641. private _frustumCornersWorldSpace;
  140642. private _frustumCenter;
  140643. private _shadowCameraPos;
  140644. private _shadowMaxZ;
  140645. /**
  140646. * Gets the shadow max z distance. It's the limit beyond which shadows are not displayed.
  140647. * It defaults to camera.maxZ
  140648. */
  140649. get shadowMaxZ(): number;
  140650. /**
  140651. * Sets the shadow max z distance.
  140652. */
  140653. set shadowMaxZ(value: number);
  140654. protected _debug: boolean;
  140655. /**
  140656. * Gets or sets the debug flag.
  140657. * When enabled, the cascades are materialized by different colors on the screen.
  140658. */
  140659. get debug(): boolean;
  140660. set debug(dbg: boolean);
  140661. private _depthClamp;
  140662. /**
  140663. * Gets or sets the depth clamping value.
  140664. *
  140665. * When enabled, it improves the shadow quality because the near z plane of the light frustum don't need to be adjusted
  140666. * to account for the shadow casters far away.
  140667. *
  140668. * Note that this property is incompatible with PCSS filtering, so it won't be used in that case.
  140669. */
  140670. get depthClamp(): boolean;
  140671. set depthClamp(value: boolean);
  140672. private _cascadeBlendPercentage;
  140673. /**
  140674. * Gets or sets the percentage of blending between two cascades (value between 0. and 1.).
  140675. * It defaults to 0.1 (10% blending).
  140676. */
  140677. get cascadeBlendPercentage(): number;
  140678. set cascadeBlendPercentage(value: number);
  140679. private _lambda;
  140680. /**
  140681. * Gets or set the lambda parameter.
  140682. * This parameter is used to split the camera frustum and create the cascades.
  140683. * 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.
  140684. * For all values in-between, it's a linear combination of the uniform and logarithm split algorithm.
  140685. */
  140686. get lambda(): number;
  140687. set lambda(value: number);
  140688. /**
  140689. * Gets the view matrix corresponding to a given cascade
  140690. * @param cascadeNum cascade to retrieve the view matrix from
  140691. * @returns the cascade view matrix
  140692. */
  140693. getCascadeViewMatrix(cascadeNum: number): Nullable<Matrix>;
  140694. /**
  140695. * Gets the projection matrix corresponding to a given cascade
  140696. * @param cascadeNum cascade to retrieve the projection matrix from
  140697. * @returns the cascade projection matrix
  140698. */
  140699. getCascadeProjectionMatrix(cascadeNum: number): Nullable<Matrix>;
  140700. /**
  140701. * Gets the transformation matrix corresponding to a given cascade
  140702. * @param cascadeNum cascade to retrieve the transformation matrix from
  140703. * @returns the cascade transformation matrix
  140704. */
  140705. getCascadeTransformMatrix(cascadeNum: number): Nullable<Matrix>;
  140706. private _depthRenderer;
  140707. /**
  140708. * Sets the depth renderer to use when autoCalcDepthBounds is enabled.
  140709. *
  140710. * Note that if no depth renderer is set, a new one will be automatically created internally when necessary.
  140711. *
  140712. * You should call this function if you already have a depth renderer enabled in your scene, to avoid
  140713. * doing multiple depth rendering each frame. If you provide your own depth renderer, make sure it stores linear depth!
  140714. * @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
  140715. */
  140716. setDepthRenderer(depthRenderer: Nullable<DepthRenderer>): void;
  140717. private _depthReducer;
  140718. private _autoCalcDepthBounds;
  140719. /**
  140720. * Gets or sets the autoCalcDepthBounds property.
  140721. *
  140722. * When enabled, a depth rendering pass is first performed (with an internally created depth renderer or with the one
  140723. * you provide by calling setDepthRenderer). Then, a min/max reducing is applied on the depth map to compute the
  140724. * minimal and maximal depth of the map and those values are used as inputs for the setMinMaxDistance() function.
  140725. * It can greatly enhance the shadow quality, at the expense of more GPU works.
  140726. * When using this option, you should increase the value of the lambda parameter, and even set it to 1 for best results.
  140727. */
  140728. get autoCalcDepthBounds(): boolean;
  140729. set autoCalcDepthBounds(value: boolean);
  140730. /**
  140731. * Defines the refresh rate of the min/max computation used when autoCalcDepthBounds is set to true
  140732. * Use 0 to compute just once, 1 to compute on every frame, 2 to compute every two frames and so on...
  140733. * Note that if you provided your own depth renderer through a call to setDepthRenderer, you are responsible
  140734. * for setting the refresh rate on the renderer yourself!
  140735. */
  140736. get autoCalcDepthBoundsRefreshRate(): number;
  140737. set autoCalcDepthBoundsRefreshRate(value: number);
  140738. /**
  140739. * Create the cascade breaks according to the lambda, shadowMaxZ and min/max distance properties, as well as the camera near and far planes.
  140740. * This function is automatically called when updating lambda, shadowMaxZ and min/max distances, however you should call it yourself if
  140741. * you change the camera near/far planes!
  140742. */
  140743. splitFrustum(): void;
  140744. private _splitFrustum;
  140745. private _computeMatrices;
  140746. private _computeFrustumInWorldSpace;
  140747. private _computeCascadeFrustum;
  140748. /**
  140749. * Support test.
  140750. */
  140751. static get IsSupported(): boolean;
  140752. /** @hidden */
  140753. static _SceneComponentInitialization: (scene: Scene) => void;
  140754. /**
  140755. * Creates a Cascaded Shadow Generator object.
  140756. * A ShadowGenerator is the required tool to use the shadows.
  140757. * Each directional light casting shadows needs to use its own ShadowGenerator.
  140758. * Documentation : https://doc.babylonjs.com/babylon101/cascadedShadows
  140759. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  140760. * @param light The directional light object generating the shadows.
  140761. * @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.
  140762. */
  140763. constructor(mapSize: number, light: DirectionalLight, usefulFloatFirst?: boolean);
  140764. protected _initializeGenerator(): void;
  140765. protected _createTargetRenderTexture(): void;
  140766. protected _initializeShadowMap(): void;
  140767. protected _bindCustomEffectForRenderSubMeshForShadowMap(subMesh: SubMesh, effect: Effect, matriceNames: any, mesh: AbstractMesh): void;
  140768. protected _isReadyCustomDefines(defines: any, subMesh: SubMesh, useInstances: boolean): void;
  140769. /**
  140770. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  140771. * @param defines Defines of the material we want to update
  140772. * @param lightIndex Index of the light in the enabled light list of the material
  140773. */
  140774. prepareDefines(defines: any, lightIndex: number): void;
  140775. /**
  140776. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  140777. * defined in the generator but impacting the effect).
  140778. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  140779. * @param effect The effect we are binfing the information for
  140780. */
  140781. bindShadowLight(lightIndex: string, effect: Effect): void;
  140782. /**
  140783. * Gets the transformation matrix of the first cascade used to project the meshes into the map from the light point of view.
  140784. * (eq to view projection * shadow projection matrices)
  140785. * @returns The transform matrix used to create the shadow map
  140786. */
  140787. getTransformMatrix(): Matrix;
  140788. /**
  140789. * Disposes the ShadowGenerator.
  140790. * Returns nothing.
  140791. */
  140792. dispose(): void;
  140793. /**
  140794. * Serializes the shadow generator setup to a json object.
  140795. * @returns The serialized JSON object
  140796. */
  140797. serialize(): any;
  140798. /**
  140799. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  140800. * @param parsedShadowGenerator The JSON object to parse
  140801. * @param scene The scene to create the shadow map for
  140802. * @returns The parsed shadow generator
  140803. */
  140804. static Parse(parsedShadowGenerator: any, scene: Scene): ShadowGenerator;
  140805. }
  140806. }
  140807. declare module BABYLON {
  140808. /**
  140809. * Defines the shadow generator component responsible to manage any shadow generators
  140810. * in a given scene.
  140811. */
  140812. export class ShadowGeneratorSceneComponent implements ISceneSerializableComponent {
  140813. /**
  140814. * The component name helpfull to identify the component in the list of scene components.
  140815. */
  140816. readonly name: string;
  140817. /**
  140818. * The scene the component belongs to.
  140819. */
  140820. scene: Scene;
  140821. /**
  140822. * Creates a new instance of the component for the given scene
  140823. * @param scene Defines the scene to register the component in
  140824. */
  140825. constructor(scene: Scene);
  140826. /**
  140827. * Registers the component in a given scene
  140828. */
  140829. register(): void;
  140830. /**
  140831. * Rebuilds the elements related to this component in case of
  140832. * context lost for instance.
  140833. */
  140834. rebuild(): void;
  140835. /**
  140836. * Serializes the component data to the specified json object
  140837. * @param serializationObject The object to serialize to
  140838. */
  140839. serialize(serializationObject: any): void;
  140840. /**
  140841. * Adds all the elements from the container to the scene
  140842. * @param container the container holding the elements
  140843. */
  140844. addFromContainer(container: AbstractScene): void;
  140845. /**
  140846. * Removes all the elements in the container from the scene
  140847. * @param container contains the elements to remove
  140848. * @param dispose if the removed element should be disposed (default: false)
  140849. */
  140850. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  140851. /**
  140852. * Rebuilds the elements related to this component in case of
  140853. * context lost for instance.
  140854. */
  140855. dispose(): void;
  140856. private _gatherRenderTargets;
  140857. }
  140858. }
  140859. declare module BABYLON {
  140860. /**
  140861. * A point light is a light defined by an unique point in world space.
  140862. * The light is emitted in every direction from this point.
  140863. * A good example of a point light is a standard light bulb.
  140864. * Documentation: https://doc.babylonjs.com/babylon101/lights
  140865. */
  140866. export class PointLight extends ShadowLight {
  140867. private _shadowAngle;
  140868. /**
  140869. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140870. * This specifies what angle the shadow will use to be created.
  140871. *
  140872. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140873. */
  140874. get shadowAngle(): number;
  140875. /**
  140876. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140877. * This specifies what angle the shadow will use to be created.
  140878. *
  140879. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  140880. */
  140881. set shadowAngle(value: number);
  140882. /**
  140883. * Gets the direction if it has been set.
  140884. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140885. */
  140886. get direction(): Vector3;
  140887. /**
  140888. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  140889. */
  140890. set direction(value: Vector3);
  140891. /**
  140892. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  140893. * A PointLight emits the light in every direction.
  140894. * It can cast shadows.
  140895. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  140896. * ```javascript
  140897. * var pointLight = new PointLight("pl", camera.position, scene);
  140898. * ```
  140899. * Documentation : https://doc.babylonjs.com/babylon101/lights
  140900. * @param name The light friendly name
  140901. * @param position The position of the point light in the scene
  140902. * @param scene The scene the lights belongs to
  140903. */
  140904. constructor(name: string, position: Vector3, scene: Scene);
  140905. /**
  140906. * Returns the string "PointLight"
  140907. * @returns the class name
  140908. */
  140909. getClassName(): string;
  140910. /**
  140911. * Returns the integer 0.
  140912. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  140913. */
  140914. getTypeID(): number;
  140915. /**
  140916. * Specifies wether or not the shadowmap should be a cube texture.
  140917. * @returns true if the shadowmap needs to be a cube texture.
  140918. */
  140919. needCube(): boolean;
  140920. /**
  140921. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  140922. * @param faceIndex The index of the face we are computed the direction to generate shadow
  140923. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  140924. */
  140925. getShadowDirection(faceIndex?: number): Vector3;
  140926. /**
  140927. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  140928. * - fov = PI / 2
  140929. * - aspect ratio : 1.0
  140930. * - z-near and far equal to the active camera minZ and maxZ.
  140931. * Returns the PointLight.
  140932. */
  140933. protected _setDefaultShadowProjectionMatrix(matrix: Matrix, viewMatrix: Matrix, renderList: Array<AbstractMesh>): void;
  140934. protected _buildUniformLayout(): void;
  140935. /**
  140936. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  140937. * @param effect The effect to update
  140938. * @param lightIndex The index of the light in the effect to update
  140939. * @returns The point light
  140940. */
  140941. transferToEffect(effect: Effect, lightIndex: string): PointLight;
  140942. transferToNodeMaterialEffect(effect: Effect, lightDataUniformName: string): this;
  140943. /**
  140944. * Prepares the list of defines specific to the light type.
  140945. * @param defines the list of defines
  140946. * @param lightIndex defines the index of the light for the effect
  140947. */
  140948. prepareLightSpecificDefines(defines: any, lightIndex: number): void;
  140949. }
  140950. }
  140951. declare module BABYLON {
  140952. /**
  140953. * Header information of HDR texture files.
  140954. */
  140955. export interface HDRInfo {
  140956. /**
  140957. * The height of the texture in pixels.
  140958. */
  140959. height: number;
  140960. /**
  140961. * The width of the texture in pixels.
  140962. */
  140963. width: number;
  140964. /**
  140965. * The index of the beginning of the data in the binary file.
  140966. */
  140967. dataPosition: number;
  140968. }
  140969. /**
  140970. * This groups tools to convert HDR texture to native colors array.
  140971. */
  140972. export class HDRTools {
  140973. private static Ldexp;
  140974. private static Rgbe2float;
  140975. private static readStringLine;
  140976. /**
  140977. * Reads header information from an RGBE texture stored in a native array.
  140978. * More information on this format are available here:
  140979. * https://en.wikipedia.org/wiki/RGBE_image_format
  140980. *
  140981. * @param uint8array The binary file stored in native array.
  140982. * @return The header information.
  140983. */
  140984. static RGBE_ReadHeader(uint8array: Uint8Array): HDRInfo;
  140985. /**
  140986. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  140987. * This RGBE texture needs to store the information as a panorama.
  140988. *
  140989. * More information on this format are available here:
  140990. * https://en.wikipedia.org/wiki/RGBE_image_format
  140991. *
  140992. * @param buffer The binary file stored in an array buffer.
  140993. * @param size The expected size of the extracted cubemap.
  140994. * @return The Cube Map information.
  140995. */
  140996. static GetCubeMapTextureData(buffer: ArrayBuffer, size: number): CubeMapInfo;
  140997. /**
  140998. * Returns the pixels data extracted from an RGBE texture.
  140999. * This pixels will be stored left to right up to down in the R G B order in one array.
  141000. *
  141001. * More information on this format are available here:
  141002. * https://en.wikipedia.org/wiki/RGBE_image_format
  141003. *
  141004. * @param uint8array The binary file stored in an array buffer.
  141005. * @param hdrInfo The header information of the file.
  141006. * @return The pixels data in RGB right to left up to down order.
  141007. */
  141008. static RGBE_ReadPixels(uint8array: Uint8Array, hdrInfo: HDRInfo): Float32Array;
  141009. private static RGBE_ReadPixels_RLE;
  141010. private static RGBE_ReadPixels_NOT_RLE;
  141011. }
  141012. }
  141013. declare module BABYLON {
  141014. /**
  141015. * Effect Render Options
  141016. */
  141017. export interface IEffectRendererOptions {
  141018. /**
  141019. * Defines the vertices positions.
  141020. */
  141021. positions?: number[];
  141022. /**
  141023. * Defines the indices.
  141024. */
  141025. indices?: number[];
  141026. }
  141027. /**
  141028. * Helper class to render one or more effects.
  141029. * You can access the previous rendering in your shader by declaring a sampler named textureSampler
  141030. */
  141031. export class EffectRenderer {
  141032. private engine;
  141033. private static _DefaultOptions;
  141034. private _vertexBuffers;
  141035. private _indexBuffer;
  141036. private _fullscreenViewport;
  141037. /**
  141038. * Creates an effect renderer
  141039. * @param engine the engine to use for rendering
  141040. * @param options defines the options of the effect renderer
  141041. */
  141042. constructor(engine: ThinEngine, options?: IEffectRendererOptions);
  141043. /**
  141044. * Sets the current viewport in normalized coordinates 0-1
  141045. * @param viewport Defines the viewport to set (defaults to 0 0 1 1)
  141046. */
  141047. setViewport(viewport?: Viewport): void;
  141048. /**
  141049. * Binds the embedded attributes buffer to the effect.
  141050. * @param effect Defines the effect to bind the attributes for
  141051. */
  141052. bindBuffers(effect: Effect): void;
  141053. /**
  141054. * Sets the current effect wrapper to use during draw.
  141055. * The effect needs to be ready before calling this api.
  141056. * This also sets the default full screen position attribute.
  141057. * @param effectWrapper Defines the effect to draw with
  141058. */
  141059. applyEffectWrapper(effectWrapper: EffectWrapper): void;
  141060. /**
  141061. * Restores engine states
  141062. */
  141063. restoreStates(): void;
  141064. /**
  141065. * Draws a full screen quad.
  141066. */
  141067. draw(): void;
  141068. private isRenderTargetTexture;
  141069. /**
  141070. * renders one or more effects to a specified texture
  141071. * @param effectWrapper the effect to renderer
  141072. * @param outputTexture texture to draw to, if null it will render to the screen.
  141073. */
  141074. render(effectWrapper: EffectWrapper, outputTexture?: Nullable<InternalTexture | RenderTargetTexture>): void;
  141075. /**
  141076. * Disposes of the effect renderer
  141077. */
  141078. dispose(): void;
  141079. }
  141080. /**
  141081. * Options to create an EffectWrapper
  141082. */
  141083. interface EffectWrapperCreationOptions {
  141084. /**
  141085. * Engine to use to create the effect
  141086. */
  141087. engine: ThinEngine;
  141088. /**
  141089. * Fragment shader for the effect
  141090. */
  141091. fragmentShader: string;
  141092. /**
  141093. * Use the shader store instead of direct source code
  141094. */
  141095. useShaderStore?: boolean;
  141096. /**
  141097. * Vertex shader for the effect
  141098. */
  141099. vertexShader?: string;
  141100. /**
  141101. * Attributes to use in the shader
  141102. */
  141103. attributeNames?: Array<string>;
  141104. /**
  141105. * Uniforms to use in the shader
  141106. */
  141107. uniformNames?: Array<string>;
  141108. /**
  141109. * Texture sampler names to use in the shader
  141110. */
  141111. samplerNames?: Array<string>;
  141112. /**
  141113. * Defines to use in the shader
  141114. */
  141115. defines?: Array<string>;
  141116. /**
  141117. * Callback when effect is compiled
  141118. */
  141119. onCompiled?: Nullable<(effect: Effect) => void>;
  141120. /**
  141121. * The friendly name of the effect displayed in Spector.
  141122. */
  141123. name?: string;
  141124. }
  141125. /**
  141126. * Wraps an effect to be used for rendering
  141127. */
  141128. export class EffectWrapper {
  141129. /**
  141130. * Event that is fired right before the effect is drawn (should be used to update uniforms)
  141131. */
  141132. onApplyObservable: Observable<{}>;
  141133. /**
  141134. * The underlying effect
  141135. */
  141136. effect: Effect;
  141137. /**
  141138. * Creates an effect to be renderer
  141139. * @param creationOptions options to create the effect
  141140. */
  141141. constructor(creationOptions: EffectWrapperCreationOptions);
  141142. /**
  141143. * Disposes of the effect wrapper
  141144. */
  141145. dispose(): void;
  141146. }
  141147. }
  141148. declare module BABYLON {
  141149. /** @hidden */
  141150. export var hdrFilteringVertexShader: {
  141151. name: string;
  141152. shader: string;
  141153. };
  141154. }
  141155. declare module BABYLON {
  141156. /** @hidden */
  141157. export var hdrFilteringPixelShader: {
  141158. name: string;
  141159. shader: string;
  141160. };
  141161. }
  141162. declare module BABYLON {
  141163. /**
  141164. * Options for texture filtering
  141165. */
  141166. interface IHDRFilteringOptions {
  141167. /**
  141168. * Scales pixel intensity for the input HDR map.
  141169. */
  141170. hdrScale?: number;
  141171. /**
  141172. * Quality of the filter. Should be `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` for prefiltering
  141173. */
  141174. quality?: number;
  141175. }
  141176. /**
  141177. * Filters HDR maps to get correct renderings of PBR reflections
  141178. */
  141179. export class HDRFiltering {
  141180. private _engine;
  141181. private _effectRenderer;
  141182. private _effectWrapper;
  141183. private _lodGenerationOffset;
  141184. private _lodGenerationScale;
  141185. /**
  141186. * Quality switch for prefiltering. Should be set to `Constants.TEXTURE_FILTERING_QUALITY_OFFLINE` unless
  141187. * you care about baking speed.
  141188. */
  141189. quality: number;
  141190. /**
  141191. * Scales pixel intensity for the input HDR map.
  141192. */
  141193. hdrScale: number;
  141194. /**
  141195. * Instantiates HDR filter for reflection maps
  141196. *
  141197. * @param engine Thin engine
  141198. * @param options Options
  141199. */
  141200. constructor(engine: ThinEngine, options?: IHDRFilteringOptions);
  141201. private _createRenderTarget;
  141202. private _prefilterInternal;
  141203. private _createEffect;
  141204. /**
  141205. * Get a value indicating if the filter is ready to be used
  141206. * @param texture Texture to filter
  141207. * @returns true if the filter is ready
  141208. */
  141209. isReady(texture: BaseTexture): boolean;
  141210. /**
  141211. * Prefilters a cube texture to have mipmap levels representing roughness values.
  141212. * Prefiltering will be invoked at the end of next rendering pass.
  141213. * This has to be done once the map is loaded, and has not been prefiltered by a third party software.
  141214. * See http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf for more information
  141215. * @param texture Texture to filter
  141216. * @param onFinished Callback when filtering is done
  141217. * @return Promise called when prefiltering is done
  141218. */
  141219. prefilter(texture: BaseTexture, onFinished?: Nullable<() => void>): Promise<unknown> | undefined;
  141220. }
  141221. }
  141222. declare module BABYLON {
  141223. /**
  141224. * This represents a texture coming from an HDR input.
  141225. *
  141226. * The only supported format is currently panorama picture stored in RGBE format.
  141227. * Example of such files can be found on HDRLib: http://hdrlib.com/
  141228. */
  141229. export class HDRCubeTexture extends BaseTexture {
  141230. private static _facesMapping;
  141231. private _generateHarmonics;
  141232. private _noMipmap;
  141233. private _prefilterOnLoad;
  141234. private _textureMatrix;
  141235. private _size;
  141236. private _onLoad;
  141237. private _onError;
  141238. /**
  141239. * The texture URL.
  141240. */
  141241. url: string;
  141242. protected _isBlocking: boolean;
  141243. /**
  141244. * Sets wether or not the texture is blocking during loading.
  141245. */
  141246. set isBlocking(value: boolean);
  141247. /**
  141248. * Gets wether or not the texture is blocking during loading.
  141249. */
  141250. get isBlocking(): boolean;
  141251. protected _rotationY: number;
  141252. /**
  141253. * Sets texture matrix rotation angle around Y axis in radians.
  141254. */
  141255. set rotationY(value: number);
  141256. /**
  141257. * Gets texture matrix rotation angle around Y axis radians.
  141258. */
  141259. get rotationY(): number;
  141260. /**
  141261. * Gets or sets the center of the bounding box associated with the cube texture
  141262. * It must define where the camera used to render the texture was set
  141263. */
  141264. boundingBoxPosition: Vector3;
  141265. private _boundingBoxSize;
  141266. /**
  141267. * Gets or sets the size of the bounding box associated with the cube texture
  141268. * When defined, the cubemap will switch to local mode
  141269. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  141270. * @example https://www.babylonjs-playground.com/#RNASML
  141271. */
  141272. set boundingBoxSize(value: Vector3);
  141273. get boundingBoxSize(): Vector3;
  141274. /**
  141275. * Instantiates an HDRTexture from the following parameters.
  141276. *
  141277. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  141278. * @param sceneOrEngine The scene or engine the texture will be used in
  141279. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  141280. * @param noMipmap Forces to not generate the mipmap if true
  141281. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  141282. * @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)
  141283. * @param prefilterOnLoad Prefilters HDR texture to allow use of this texture as a PBR reflection texture.
  141284. */
  141285. 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>);
  141286. /**
  141287. * Get the current class name of the texture useful for serialization or dynamic coding.
  141288. * @returns "HDRCubeTexture"
  141289. */
  141290. getClassName(): string;
  141291. /**
  141292. * Occurs when the file is raw .hdr file.
  141293. */
  141294. private loadTexture;
  141295. clone(): HDRCubeTexture;
  141296. delayLoad(): void;
  141297. /**
  141298. * Get the texture reflection matrix used to rotate/transform the reflection.
  141299. * @returns the reflection matrix
  141300. */
  141301. getReflectionTextureMatrix(): Matrix;
  141302. /**
  141303. * Set the texture reflection matrix used to rotate/transform the reflection.
  141304. * @param value Define the reflection matrix to set
  141305. */
  141306. setReflectionTextureMatrix(value: Matrix): void;
  141307. /**
  141308. * Parses a JSON representation of an HDR Texture in order to create the texture
  141309. * @param parsedTexture Define the JSON representation
  141310. * @param scene Define the scene the texture should be created in
  141311. * @param rootUrl Define the root url in case we need to load relative dependencies
  141312. * @returns the newly created texture after parsing
  141313. */
  141314. static Parse(parsedTexture: any, scene: Scene, rootUrl: string): Nullable<HDRCubeTexture>;
  141315. serialize(): any;
  141316. }
  141317. }
  141318. declare module BABYLON {
  141319. /**
  141320. * Class used to control physics engine
  141321. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141322. */
  141323. export class PhysicsEngine implements IPhysicsEngine {
  141324. private _physicsPlugin;
  141325. /**
  141326. * Global value used to control the smallest number supported by the simulation
  141327. */
  141328. static Epsilon: number;
  141329. private _impostors;
  141330. private _joints;
  141331. private _subTimeStep;
  141332. /**
  141333. * Gets the gravity vector used by the simulation
  141334. */
  141335. gravity: Vector3;
  141336. /**
  141337. * Factory used to create the default physics plugin.
  141338. * @returns The default physics plugin
  141339. */
  141340. static DefaultPluginFactory(): IPhysicsEnginePlugin;
  141341. /**
  141342. * Creates a new Physics Engine
  141343. * @param gravity defines the gravity vector used by the simulation
  141344. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  141345. */
  141346. constructor(gravity: Nullable<Vector3>, _physicsPlugin?: IPhysicsEnginePlugin);
  141347. /**
  141348. * Sets the gravity vector used by the simulation
  141349. * @param gravity defines the gravity vector to use
  141350. */
  141351. setGravity(gravity: Vector3): void;
  141352. /**
  141353. * Set the time step of the physics engine.
  141354. * Default is 1/60.
  141355. * To slow it down, enter 1/600 for example.
  141356. * To speed it up, 1/30
  141357. * @param newTimeStep defines the new timestep to apply to this world.
  141358. */
  141359. setTimeStep(newTimeStep?: number): void;
  141360. /**
  141361. * Get the time step of the physics engine.
  141362. * @returns the current time step
  141363. */
  141364. getTimeStep(): number;
  141365. /**
  141366. * Set the sub time step of the physics engine.
  141367. * Default is 0 meaning there is no sub steps
  141368. * To increase physics resolution precision, set a small value (like 1 ms)
  141369. * @param subTimeStep defines the new sub timestep used for physics resolution.
  141370. */
  141371. setSubTimeStep(subTimeStep?: number): void;
  141372. /**
  141373. * Get the sub time step of the physics engine.
  141374. * @returns the current sub time step
  141375. */
  141376. getSubTimeStep(): number;
  141377. /**
  141378. * Release all resources
  141379. */
  141380. dispose(): void;
  141381. /**
  141382. * Gets the name of the current physics plugin
  141383. * @returns the name of the plugin
  141384. */
  141385. getPhysicsPluginName(): string;
  141386. /**
  141387. * Adding a new impostor for the impostor tracking.
  141388. * This will be done by the impostor itself.
  141389. * @param impostor the impostor to add
  141390. */
  141391. addImpostor(impostor: PhysicsImpostor): void;
  141392. /**
  141393. * Remove an impostor from the engine.
  141394. * This impostor and its mesh will not longer be updated by the physics engine.
  141395. * @param impostor the impostor to remove
  141396. */
  141397. removeImpostor(impostor: PhysicsImpostor): void;
  141398. /**
  141399. * Add a joint to the physics engine
  141400. * @param mainImpostor defines the main impostor to which the joint is added.
  141401. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  141402. * @param joint defines the joint that will connect both impostors.
  141403. */
  141404. addJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141405. /**
  141406. * Removes a joint from the simulation
  141407. * @param mainImpostor defines the impostor used with the joint
  141408. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  141409. * @param joint defines the joint to remove
  141410. */
  141411. removeJoint(mainImpostor: PhysicsImpostor, connectedImpostor: PhysicsImpostor, joint: PhysicsJoint): void;
  141412. /**
  141413. * Called by the scene. No need to call it.
  141414. * @param delta defines the timespam between frames
  141415. */
  141416. _step(delta: number): void;
  141417. /**
  141418. * Gets the current plugin used to run the simulation
  141419. * @returns current plugin
  141420. */
  141421. getPhysicsPlugin(): IPhysicsEnginePlugin;
  141422. /**
  141423. * Gets the list of physic impostors
  141424. * @returns an array of PhysicsImpostor
  141425. */
  141426. getImpostors(): Array<PhysicsImpostor>;
  141427. /**
  141428. * Gets the impostor for a physics enabled object
  141429. * @param object defines the object impersonated by the impostor
  141430. * @returns the PhysicsImpostor or null if not found
  141431. */
  141432. getImpostorForPhysicsObject(object: IPhysicsEnabledObject): Nullable<PhysicsImpostor>;
  141433. /**
  141434. * Gets the impostor for a physics body object
  141435. * @param body defines physics body used by the impostor
  141436. * @returns the PhysicsImpostor or null if not found
  141437. */
  141438. getImpostorWithPhysicsBody(body: any): Nullable<PhysicsImpostor>;
  141439. /**
  141440. * Does a raycast in the physics world
  141441. * @param from when should the ray start?
  141442. * @param to when should the ray end?
  141443. * @returns PhysicsRaycastResult
  141444. */
  141445. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141446. }
  141447. }
  141448. declare module BABYLON {
  141449. /** @hidden */
  141450. export class CannonJSPlugin implements IPhysicsEnginePlugin {
  141451. private _useDeltaForWorldStep;
  141452. world: any;
  141453. name: string;
  141454. private _physicsMaterials;
  141455. private _fixedTimeStep;
  141456. private _cannonRaycastResult;
  141457. private _raycastResult;
  141458. private _physicsBodysToRemoveAfterStep;
  141459. private _firstFrame;
  141460. BJSCANNON: any;
  141461. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, cannonInjection?: any);
  141462. setGravity(gravity: Vector3): void;
  141463. setTimeStep(timeStep: number): void;
  141464. getTimeStep(): number;
  141465. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141466. private _removeMarkedPhysicsBodiesFromWorld;
  141467. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141468. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141469. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141470. private _processChildMeshes;
  141471. removePhysicsBody(impostor: PhysicsImpostor): void;
  141472. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141473. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141474. private _addMaterial;
  141475. private _checkWithEpsilon;
  141476. private _createShape;
  141477. private _createHeightmap;
  141478. private _minus90X;
  141479. private _plus90X;
  141480. private _tmpPosition;
  141481. private _tmpDeltaPosition;
  141482. private _tmpUnityRotation;
  141483. private _updatePhysicsBodyTransformation;
  141484. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141485. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141486. isSupported(): boolean;
  141487. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141488. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141489. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141490. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141491. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141492. getBodyMass(impostor: PhysicsImpostor): number;
  141493. getBodyFriction(impostor: PhysicsImpostor): number;
  141494. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141495. getBodyRestitution(impostor: PhysicsImpostor): number;
  141496. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141497. sleepBody(impostor: PhysicsImpostor): void;
  141498. wakeUpBody(impostor: PhysicsImpostor): void;
  141499. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number): void;
  141500. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141501. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141502. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141503. getRadius(impostor: PhysicsImpostor): number;
  141504. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141505. dispose(): void;
  141506. private _extendNamespace;
  141507. /**
  141508. * Does a raycast in the physics world
  141509. * @param from when should the ray start?
  141510. * @param to when should the ray end?
  141511. * @returns PhysicsRaycastResult
  141512. */
  141513. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141514. }
  141515. }
  141516. declare module BABYLON {
  141517. /** @hidden */
  141518. export class OimoJSPlugin implements IPhysicsEnginePlugin {
  141519. private _useDeltaForWorldStep;
  141520. world: any;
  141521. name: string;
  141522. BJSOIMO: any;
  141523. private _raycastResult;
  141524. private _fixedTimeStep;
  141525. constructor(_useDeltaForWorldStep?: boolean, iterations?: number, oimoInjection?: any);
  141526. setGravity(gravity: Vector3): void;
  141527. setTimeStep(timeStep: number): void;
  141528. getTimeStep(): number;
  141529. private _tmpImpostorsArray;
  141530. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141531. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141532. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141533. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141534. private _tmpPositionVector;
  141535. removePhysicsBody(impostor: PhysicsImpostor): void;
  141536. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141537. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141538. isSupported(): boolean;
  141539. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141540. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141541. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141542. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141543. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141544. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141545. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141546. getBodyMass(impostor: PhysicsImpostor): number;
  141547. getBodyFriction(impostor: PhysicsImpostor): number;
  141548. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141549. getBodyRestitution(impostor: PhysicsImpostor): number;
  141550. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141551. sleepBody(impostor: PhysicsImpostor): void;
  141552. wakeUpBody(impostor: PhysicsImpostor): void;
  141553. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141554. setMotor(joint: IMotorEnabledJoint, speed: number, force?: number, motorIndex?: number): void;
  141555. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number, motorIndex?: number): void;
  141556. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141557. getRadius(impostor: PhysicsImpostor): number;
  141558. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141559. dispose(): void;
  141560. /**
  141561. * Does a raycast in the physics world
  141562. * @param from when should the ray start?
  141563. * @param to when should the ray end?
  141564. * @returns PhysicsRaycastResult
  141565. */
  141566. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141567. }
  141568. }
  141569. declare module BABYLON {
  141570. /**
  141571. * AmmoJS Physics plugin
  141572. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  141573. * @see https://github.com/kripken/ammo.js/
  141574. */
  141575. export class AmmoJSPlugin implements IPhysicsEnginePlugin {
  141576. private _useDeltaForWorldStep;
  141577. /**
  141578. * Reference to the Ammo library
  141579. */
  141580. bjsAMMO: any;
  141581. /**
  141582. * Created ammoJS world which physics bodies are added to
  141583. */
  141584. world: any;
  141585. /**
  141586. * Name of the plugin
  141587. */
  141588. name: string;
  141589. private _timeStep;
  141590. private _fixedTimeStep;
  141591. private _maxSteps;
  141592. private _tmpQuaternion;
  141593. private _tmpAmmoTransform;
  141594. private _tmpAmmoQuaternion;
  141595. private _tmpAmmoConcreteContactResultCallback;
  141596. private _collisionConfiguration;
  141597. private _dispatcher;
  141598. private _overlappingPairCache;
  141599. private _solver;
  141600. private _softBodySolver;
  141601. private _tmpAmmoVectorA;
  141602. private _tmpAmmoVectorB;
  141603. private _tmpAmmoVectorC;
  141604. private _tmpAmmoVectorD;
  141605. private _tmpContactCallbackResult;
  141606. private _tmpAmmoVectorRCA;
  141607. private _tmpAmmoVectorRCB;
  141608. private _raycastResult;
  141609. private static readonly DISABLE_COLLISION_FLAG;
  141610. private static readonly KINEMATIC_FLAG;
  141611. private static readonly DISABLE_DEACTIVATION_FLAG;
  141612. /**
  141613. * Initializes the ammoJS plugin
  141614. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  141615. * @param ammoInjection can be used to inject your own ammo reference
  141616. * @param overlappingPairCache can be used to specify your own overlapping pair cache
  141617. */
  141618. constructor(_useDeltaForWorldStep?: boolean, ammoInjection?: any, overlappingPairCache?: any);
  141619. /**
  141620. * Sets the gravity of the physics world (m/(s^2))
  141621. * @param gravity Gravity to set
  141622. */
  141623. setGravity(gravity: Vector3): void;
  141624. /**
  141625. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  141626. * @param timeStep timestep to use in seconds
  141627. */
  141628. setTimeStep(timeStep: number): void;
  141629. /**
  141630. * 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)
  141631. * @param fixedTimeStep fixedTimeStep to use in seconds
  141632. */
  141633. setFixedTimeStep(fixedTimeStep: number): void;
  141634. /**
  141635. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  141636. * @param maxSteps the maximum number of steps by the physics engine per frame
  141637. */
  141638. setMaxSteps(maxSteps: number): void;
  141639. /**
  141640. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  141641. * @returns the current timestep in seconds
  141642. */
  141643. getTimeStep(): number;
  141644. /**
  141645. * The create custom shape handler function to be called when using BABYLON.PhysicsImposter.CustomImpostor
  141646. */
  141647. onCreateCustomShape: (impostor: PhysicsImpostor) => any;
  141648. private _isImpostorInContact;
  141649. private _isImpostorPairInContact;
  141650. private _stepSimulation;
  141651. /**
  141652. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  141653. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  141654. * After the step the babylon meshes are set to the position of the physics imposters
  141655. * @param delta amount of time to step forward
  141656. * @param impostors array of imposters to update before/after the step
  141657. */
  141658. executeStep(delta: number, impostors: Array<PhysicsImpostor>): void;
  141659. /**
  141660. * Update babylon mesh to match physics world object
  141661. * @param impostor imposter to match
  141662. */
  141663. private _afterSoftStep;
  141664. /**
  141665. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141666. * @param impostor imposter to match
  141667. */
  141668. private _ropeStep;
  141669. /**
  141670. * Update babylon mesh vertices vertices to match physics world softbody or cloth
  141671. * @param impostor imposter to match
  141672. */
  141673. private _softbodyOrClothStep;
  141674. private _tmpMatrix;
  141675. /**
  141676. * Applies an impulse on the imposter
  141677. * @param impostor imposter to apply impulse to
  141678. * @param force amount of force to be applied to the imposter
  141679. * @param contactPoint the location to apply the impulse on the imposter
  141680. */
  141681. applyImpulse(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141682. /**
  141683. * Applies a force on the imposter
  141684. * @param impostor imposter to apply force
  141685. * @param force amount of force to be applied to the imposter
  141686. * @param contactPoint the location to apply the force on the imposter
  141687. */
  141688. applyForce(impostor: PhysicsImpostor, force: Vector3, contactPoint: Vector3): void;
  141689. /**
  141690. * Creates a physics body using the plugin
  141691. * @param impostor the imposter to create the physics body on
  141692. */
  141693. generatePhysicsBody(impostor: PhysicsImpostor): void;
  141694. /**
  141695. * Removes the physics body from the imposter and disposes of the body's memory
  141696. * @param impostor imposter to remove the physics body from
  141697. */
  141698. removePhysicsBody(impostor: PhysicsImpostor): void;
  141699. /**
  141700. * Generates a joint
  141701. * @param impostorJoint the imposter joint to create the joint with
  141702. */
  141703. generateJoint(impostorJoint: PhysicsImpostorJoint): void;
  141704. /**
  141705. * Removes a joint
  141706. * @param impostorJoint the imposter joint to remove the joint from
  141707. */
  141708. removeJoint(impostorJoint: PhysicsImpostorJoint): void;
  141709. private _addMeshVerts;
  141710. /**
  141711. * Initialise the soft body vertices to match its object's (mesh) vertices
  141712. * Softbody vertices (nodes) are in world space and to match this
  141713. * The object's position and rotation is set to zero and so its vertices are also then set in world space
  141714. * @param impostor to create the softbody for
  141715. */
  141716. private _softVertexData;
  141717. /**
  141718. * Create an impostor's soft body
  141719. * @param impostor to create the softbody for
  141720. */
  141721. private _createSoftbody;
  141722. /**
  141723. * Create cloth for an impostor
  141724. * @param impostor to create the softbody for
  141725. */
  141726. private _createCloth;
  141727. /**
  141728. * Create rope for an impostor
  141729. * @param impostor to create the softbody for
  141730. */
  141731. private _createRope;
  141732. /**
  141733. * Create a custom physics impostor shape using the plugin's onCreateCustomShape handler
  141734. * @param impostor to create the custom physics shape for
  141735. */
  141736. private _createCustom;
  141737. private _addHullVerts;
  141738. private _createShape;
  141739. /**
  141740. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  141741. * @param impostor imposter containing the physics body and babylon object
  141742. */
  141743. setTransformationFromPhysicsBody(impostor: PhysicsImpostor): void;
  141744. /**
  141745. * Sets the babylon object's position/rotation from the physics body's position/rotation
  141746. * @param impostor imposter containing the physics body and babylon object
  141747. * @param newPosition new position
  141748. * @param newRotation new rotation
  141749. */
  141750. setPhysicsBodyTransformation(impostor: PhysicsImpostor, newPosition: Vector3, newRotation: Quaternion): void;
  141751. /**
  141752. * If this plugin is supported
  141753. * @returns true if its supported
  141754. */
  141755. isSupported(): boolean;
  141756. /**
  141757. * Sets the linear velocity of the physics body
  141758. * @param impostor imposter to set the velocity on
  141759. * @param velocity velocity to set
  141760. */
  141761. setLinearVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141762. /**
  141763. * Sets the angular velocity of the physics body
  141764. * @param impostor imposter to set the velocity on
  141765. * @param velocity velocity to set
  141766. */
  141767. setAngularVelocity(impostor: PhysicsImpostor, velocity: Vector3): void;
  141768. /**
  141769. * gets the linear velocity
  141770. * @param impostor imposter to get linear velocity from
  141771. * @returns linear velocity
  141772. */
  141773. getLinearVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141774. /**
  141775. * gets the angular velocity
  141776. * @param impostor imposter to get angular velocity from
  141777. * @returns angular velocity
  141778. */
  141779. getAngularVelocity(impostor: PhysicsImpostor): Nullable<Vector3>;
  141780. /**
  141781. * Sets the mass of physics body
  141782. * @param impostor imposter to set the mass on
  141783. * @param mass mass to set
  141784. */
  141785. setBodyMass(impostor: PhysicsImpostor, mass: number): void;
  141786. /**
  141787. * Gets the mass of the physics body
  141788. * @param impostor imposter to get the mass from
  141789. * @returns mass
  141790. */
  141791. getBodyMass(impostor: PhysicsImpostor): number;
  141792. /**
  141793. * Gets friction of the impostor
  141794. * @param impostor impostor to get friction from
  141795. * @returns friction value
  141796. */
  141797. getBodyFriction(impostor: PhysicsImpostor): number;
  141798. /**
  141799. * Sets friction of the impostor
  141800. * @param impostor impostor to set friction on
  141801. * @param friction friction value
  141802. */
  141803. setBodyFriction(impostor: PhysicsImpostor, friction: number): void;
  141804. /**
  141805. * Gets restitution of the impostor
  141806. * @param impostor impostor to get restitution from
  141807. * @returns restitution value
  141808. */
  141809. getBodyRestitution(impostor: PhysicsImpostor): number;
  141810. /**
  141811. * Sets resitution of the impostor
  141812. * @param impostor impostor to set resitution on
  141813. * @param restitution resitution value
  141814. */
  141815. setBodyRestitution(impostor: PhysicsImpostor, restitution: number): void;
  141816. /**
  141817. * Gets pressure inside the impostor
  141818. * @param impostor impostor to get pressure from
  141819. * @returns pressure value
  141820. */
  141821. getBodyPressure(impostor: PhysicsImpostor): number;
  141822. /**
  141823. * Sets pressure inside a soft body impostor
  141824. * Cloth and rope must remain 0 pressure
  141825. * @param impostor impostor to set pressure on
  141826. * @param pressure pressure value
  141827. */
  141828. setBodyPressure(impostor: PhysicsImpostor, pressure: number): void;
  141829. /**
  141830. * Gets stiffness of the impostor
  141831. * @param impostor impostor to get stiffness from
  141832. * @returns pressure value
  141833. */
  141834. getBodyStiffness(impostor: PhysicsImpostor): number;
  141835. /**
  141836. * Sets stiffness of the impostor
  141837. * @param impostor impostor to set stiffness on
  141838. * @param stiffness stiffness value from 0 to 1
  141839. */
  141840. setBodyStiffness(impostor: PhysicsImpostor, stiffness: number): void;
  141841. /**
  141842. * Gets velocityIterations of the impostor
  141843. * @param impostor impostor to get velocity iterations from
  141844. * @returns velocityIterations value
  141845. */
  141846. getBodyVelocityIterations(impostor: PhysicsImpostor): number;
  141847. /**
  141848. * Sets velocityIterations of the impostor
  141849. * @param impostor impostor to set velocity iterations on
  141850. * @param velocityIterations velocityIterations value
  141851. */
  141852. setBodyVelocityIterations(impostor: PhysicsImpostor, velocityIterations: number): void;
  141853. /**
  141854. * Gets positionIterations of the impostor
  141855. * @param impostor impostor to get position iterations from
  141856. * @returns positionIterations value
  141857. */
  141858. getBodyPositionIterations(impostor: PhysicsImpostor): number;
  141859. /**
  141860. * Sets positionIterations of the impostor
  141861. * @param impostor impostor to set position on
  141862. * @param positionIterations positionIterations value
  141863. */
  141864. setBodyPositionIterations(impostor: PhysicsImpostor, positionIterations: number): void;
  141865. /**
  141866. * Append an anchor to a cloth object
  141867. * @param impostor is the cloth impostor to add anchor to
  141868. * @param otherImpostor is the rigid impostor to anchor to
  141869. * @param width ratio across width from 0 to 1
  141870. * @param height ratio up height from 0 to 1
  141871. * @param influence the elasticity between cloth impostor and anchor from 0, very stretchy to 1, little strech
  141872. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141873. */
  141874. appendAnchor(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, width: number, height: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141875. /**
  141876. * Append an hook to a rope object
  141877. * @param impostor is the rope impostor to add hook to
  141878. * @param otherImpostor is the rigid impostor to hook to
  141879. * @param length ratio along the rope from 0 to 1
  141880. * @param influence the elasticity between soft impostor and anchor from 0, very stretchy to 1, little strech
  141881. * @param noCollisionBetweenLinkedBodies when true collisions between soft impostor and anchor are ignored; default false
  141882. */
  141883. appendHook(impostor: PhysicsImpostor, otherImpostor: PhysicsImpostor, length: number, influence?: number, noCollisionBetweenLinkedBodies?: boolean): void;
  141884. /**
  141885. * Sleeps the physics body and stops it from being active
  141886. * @param impostor impostor to sleep
  141887. */
  141888. sleepBody(impostor: PhysicsImpostor): void;
  141889. /**
  141890. * Activates the physics body
  141891. * @param impostor impostor to activate
  141892. */
  141893. wakeUpBody(impostor: PhysicsImpostor): void;
  141894. /**
  141895. * Updates the distance parameters of the joint
  141896. * @param joint joint to update
  141897. * @param maxDistance maximum distance of the joint
  141898. * @param minDistance minimum distance of the joint
  141899. */
  141900. updateDistanceJoint(joint: PhysicsJoint, maxDistance: number, minDistance?: number): void;
  141901. /**
  141902. * Sets a motor on the joint
  141903. * @param joint joint to set motor on
  141904. * @param speed speed of the motor
  141905. * @param maxForce maximum force of the motor
  141906. * @param motorIndex index of the motor
  141907. */
  141908. setMotor(joint: IMotorEnabledJoint, speed?: number, maxForce?: number, motorIndex?: number): void;
  141909. /**
  141910. * Sets the motors limit
  141911. * @param joint joint to set limit on
  141912. * @param upperLimit upper limit
  141913. * @param lowerLimit lower limit
  141914. */
  141915. setLimit(joint: IMotorEnabledJoint, upperLimit: number, lowerLimit?: number): void;
  141916. /**
  141917. * Syncs the position and rotation of a mesh with the impostor
  141918. * @param mesh mesh to sync
  141919. * @param impostor impostor to update the mesh with
  141920. */
  141921. syncMeshWithImpostor(mesh: AbstractMesh, impostor: PhysicsImpostor): void;
  141922. /**
  141923. * Gets the radius of the impostor
  141924. * @param impostor impostor to get radius from
  141925. * @returns the radius
  141926. */
  141927. getRadius(impostor: PhysicsImpostor): number;
  141928. /**
  141929. * Gets the box size of the impostor
  141930. * @param impostor impostor to get box size from
  141931. * @param result the resulting box size
  141932. */
  141933. getBoxSizeToRef(impostor: PhysicsImpostor, result: Vector3): void;
  141934. /**
  141935. * Disposes of the impostor
  141936. */
  141937. dispose(): void;
  141938. /**
  141939. * Does a raycast in the physics world
  141940. * @param from when should the ray start?
  141941. * @param to when should the ray end?
  141942. * @returns PhysicsRaycastResult
  141943. */
  141944. raycast(from: Vector3, to: Vector3): PhysicsRaycastResult;
  141945. }
  141946. }
  141947. declare module BABYLON {
  141948. interface AbstractScene {
  141949. /**
  141950. * The list of reflection probes added to the scene
  141951. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141952. */
  141953. reflectionProbes: Array<ReflectionProbe>;
  141954. /**
  141955. * Removes the given reflection probe from this scene.
  141956. * @param toRemove The reflection probe to remove
  141957. * @returns The index of the removed reflection probe
  141958. */
  141959. removeReflectionProbe(toRemove: ReflectionProbe): number;
  141960. /**
  141961. * Adds the given reflection probe to this scene.
  141962. * @param newReflectionProbe The reflection probe to add
  141963. */
  141964. addReflectionProbe(newReflectionProbe: ReflectionProbe): void;
  141965. }
  141966. /**
  141967. * Class used to generate realtime reflection / refraction cube textures
  141968. * @see https://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  141969. */
  141970. export class ReflectionProbe {
  141971. /** defines the name of the probe */
  141972. name: string;
  141973. private _scene;
  141974. private _renderTargetTexture;
  141975. private _projectionMatrix;
  141976. private _viewMatrix;
  141977. private _target;
  141978. private _add;
  141979. private _attachedMesh;
  141980. private _invertYAxis;
  141981. /** Gets or sets probe position (center of the cube map) */
  141982. position: Vector3;
  141983. /**
  141984. * Creates a new reflection probe
  141985. * @param name defines the name of the probe
  141986. * @param size defines the texture resolution (for each face)
  141987. * @param scene defines the hosting scene
  141988. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  141989. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  141990. */
  141991. constructor(
  141992. /** defines the name of the probe */
  141993. name: string, size: number, scene: Scene, generateMipMaps?: boolean, useFloat?: boolean);
  141994. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  141995. get samples(): number;
  141996. set samples(value: number);
  141997. /** Gets or sets the refresh rate to use (on every frame by default) */
  141998. get refreshRate(): number;
  141999. set refreshRate(value: number);
  142000. /**
  142001. * Gets the hosting scene
  142002. * @returns a Scene
  142003. */
  142004. getScene(): Scene;
  142005. /** Gets the internal CubeTexture used to render to */
  142006. get cubeTexture(): RenderTargetTexture;
  142007. /** Gets the list of meshes to render */
  142008. get renderList(): Nullable<AbstractMesh[]>;
  142009. /**
  142010. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  142011. * @param mesh defines the mesh to attach to
  142012. */
  142013. attachToMesh(mesh: Nullable<AbstractMesh>): void;
  142014. /**
  142015. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  142016. * @param renderingGroupId The rendering group id corresponding to its index
  142017. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  142018. */
  142019. setRenderingAutoClearDepthStencil(renderingGroupId: number, autoClearDepthStencil: boolean): void;
  142020. /**
  142021. * Clean all associated resources
  142022. */
  142023. dispose(): void;
  142024. /**
  142025. * Converts the reflection probe information to a readable string for debug purpose.
  142026. * @param fullDetails Supports for multiple levels of logging within scene loading
  142027. * @returns the human readable reflection probe info
  142028. */
  142029. toString(fullDetails?: boolean): string;
  142030. /**
  142031. * Get the class name of the relfection probe.
  142032. * @returns "ReflectionProbe"
  142033. */
  142034. getClassName(): string;
  142035. /**
  142036. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  142037. * @returns The JSON representation of the texture
  142038. */
  142039. serialize(): any;
  142040. /**
  142041. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  142042. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  142043. * @param scene Define the scene the parsed reflection probe should be instantiated in
  142044. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  142045. * @returns The parsed reflection probe if successful
  142046. */
  142047. static Parse(parsedReflectionProbe: any, scene: Scene, rootUrl: string): Nullable<ReflectionProbe>;
  142048. }
  142049. }
  142050. declare module BABYLON {
  142051. /** @hidden */
  142052. export var _BabylonLoaderRegistered: boolean;
  142053. /**
  142054. * Helps setting up some configuration for the babylon file loader.
  142055. */
  142056. export class BabylonFileLoaderConfiguration {
  142057. /**
  142058. * The loader does not allow injecting custom physix engine into the plugins.
  142059. * Unfortunately in ES6, we need to manually inject them into the plugin.
  142060. * So you could set this variable to your engine import to make it work.
  142061. */
  142062. static LoaderInjectedPhysicsEngine: any;
  142063. }
  142064. }
  142065. declare module BABYLON {
  142066. /**
  142067. * The Physically based simple base material of BJS.
  142068. *
  142069. * This enables better naming and convention enforcements on top of the pbrMaterial.
  142070. * It is used as the base class for both the specGloss and metalRough conventions.
  142071. */
  142072. export abstract class PBRBaseSimpleMaterial extends PBRBaseMaterial {
  142073. /**
  142074. * Number of Simultaneous lights allowed on the material.
  142075. */
  142076. maxSimultaneousLights: number;
  142077. /**
  142078. * If sets to true, disables all the lights affecting the material.
  142079. */
  142080. disableLighting: boolean;
  142081. /**
  142082. * Environment Texture used in the material (this is use for both reflection and environment lighting).
  142083. */
  142084. environmentTexture: BaseTexture;
  142085. /**
  142086. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  142087. */
  142088. invertNormalMapX: boolean;
  142089. /**
  142090. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  142091. */
  142092. invertNormalMapY: boolean;
  142093. /**
  142094. * Normal map used in the model.
  142095. */
  142096. normalTexture: BaseTexture;
  142097. /**
  142098. * Emissivie color used to self-illuminate the model.
  142099. */
  142100. emissiveColor: Color3;
  142101. /**
  142102. * Emissivie texture used to self-illuminate the model.
  142103. */
  142104. emissiveTexture: BaseTexture;
  142105. /**
  142106. * Occlusion Channel Strenght.
  142107. */
  142108. occlusionStrength: number;
  142109. /**
  142110. * Occlusion Texture of the material (adding extra occlusion effects).
  142111. */
  142112. occlusionTexture: BaseTexture;
  142113. /**
  142114. * Defines the alpha limits in alpha test mode.
  142115. */
  142116. alphaCutOff: number;
  142117. /**
  142118. * Gets the current double sided mode.
  142119. */
  142120. get doubleSided(): boolean;
  142121. /**
  142122. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  142123. */
  142124. set doubleSided(value: boolean);
  142125. /**
  142126. * Stores the pre-calculated light information of a mesh in a texture.
  142127. */
  142128. lightmapTexture: BaseTexture;
  142129. /**
  142130. * If true, the light map contains occlusion information instead of lighting info.
  142131. */
  142132. useLightmapAsShadowmap: boolean;
  142133. /**
  142134. * Instantiates a new PBRMaterial instance.
  142135. *
  142136. * @param name The material name
  142137. * @param scene The scene the material will be use in.
  142138. */
  142139. constructor(name: string, scene: Scene);
  142140. getClassName(): string;
  142141. }
  142142. }
  142143. declare module BABYLON {
  142144. /**
  142145. * The PBR material of BJS following the metal roughness convention.
  142146. *
  142147. * This fits to the PBR convention in the GLTF definition:
  142148. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  142149. */
  142150. export class PBRMetallicRoughnessMaterial extends PBRBaseSimpleMaterial {
  142151. /**
  142152. * The base color has two different interpretations depending on the value of metalness.
  142153. * When the material is a metal, the base color is the specific measured reflectance value
  142154. * at normal incidence (F0). For a non-metal the base color represents the reflected diffuse color
  142155. * of the material.
  142156. */
  142157. baseColor: Color3;
  142158. /**
  142159. * Base texture of the metallic workflow. It contains both the baseColor information in RGB as
  142160. * well as opacity information in the alpha channel.
  142161. */
  142162. baseTexture: BaseTexture;
  142163. /**
  142164. * Specifies the metallic scalar value of the material.
  142165. * Can also be used to scale the metalness values of the metallic texture.
  142166. */
  142167. metallic: number;
  142168. /**
  142169. * Specifies the roughness scalar value of the material.
  142170. * Can also be used to scale the roughness values of the metallic texture.
  142171. */
  142172. roughness: number;
  142173. /**
  142174. * Texture containing both the metallic value in the B channel and the
  142175. * roughness value in the G channel to keep better precision.
  142176. */
  142177. metallicRoughnessTexture: BaseTexture;
  142178. /**
  142179. * Instantiates a new PBRMetalRoughnessMaterial instance.
  142180. *
  142181. * @param name The material name
  142182. * @param scene The scene the material will be use in.
  142183. */
  142184. constructor(name: string, scene: Scene);
  142185. /**
  142186. * Return the currrent class name of the material.
  142187. */
  142188. getClassName(): string;
  142189. /**
  142190. * Makes a duplicate of the current material.
  142191. * @param name - name to use for the new material.
  142192. */
  142193. clone(name: string): PBRMetallicRoughnessMaterial;
  142194. /**
  142195. * Serialize the material to a parsable JSON object.
  142196. */
  142197. serialize(): any;
  142198. /**
  142199. * Parses a JSON object correponding to the serialize function.
  142200. */
  142201. static Parse(source: any, scene: Scene, rootUrl: string): PBRMetallicRoughnessMaterial;
  142202. }
  142203. }
  142204. declare module BABYLON {
  142205. /**
  142206. * The PBR material of BJS following the specular glossiness convention.
  142207. *
  142208. * This fits to the PBR convention in the GLTF definition:
  142209. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  142210. */
  142211. export class PBRSpecularGlossinessMaterial extends PBRBaseSimpleMaterial {
  142212. /**
  142213. * Specifies the diffuse color of the material.
  142214. */
  142215. diffuseColor: Color3;
  142216. /**
  142217. * Specifies the diffuse texture of the material. This can also contains the opcity value in its alpha
  142218. * channel.
  142219. */
  142220. diffuseTexture: BaseTexture;
  142221. /**
  142222. * Specifies the specular color of the material. This indicates how reflective is the material (none to mirror).
  142223. */
  142224. specularColor: Color3;
  142225. /**
  142226. * Specifies the glossiness of the material. This indicates "how sharp is the reflection".
  142227. */
  142228. glossiness: number;
  142229. /**
  142230. * Specifies both the specular color RGB and the glossiness A of the material per pixels.
  142231. */
  142232. specularGlossinessTexture: BaseTexture;
  142233. /**
  142234. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  142235. *
  142236. * @param name The material name
  142237. * @param scene The scene the material will be use in.
  142238. */
  142239. constructor(name: string, scene: Scene);
  142240. /**
  142241. * Return the currrent class name of the material.
  142242. */
  142243. getClassName(): string;
  142244. /**
  142245. * Makes a duplicate of the current material.
  142246. * @param name - name to use for the new material.
  142247. */
  142248. clone(name: string): PBRSpecularGlossinessMaterial;
  142249. /**
  142250. * Serialize the material to a parsable JSON object.
  142251. */
  142252. serialize(): any;
  142253. /**
  142254. * Parses a JSON object correponding to the serialize function.
  142255. */
  142256. static Parse(source: any, scene: Scene, rootUrl: string): PBRSpecularGlossinessMaterial;
  142257. }
  142258. }
  142259. declare module BABYLON {
  142260. /**
  142261. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  142262. * It can help converting any input color in a desired output one. This can then be used to create effects
  142263. * from sepia, black and white to sixties or futuristic rendering...
  142264. *
  142265. * The only supported format is currently 3dl.
  142266. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  142267. */
  142268. export class ColorGradingTexture extends BaseTexture {
  142269. /**
  142270. * The texture URL.
  142271. */
  142272. url: string;
  142273. /**
  142274. * Empty line regex stored for GC.
  142275. */
  142276. private static _noneEmptyLineRegex;
  142277. private _textureMatrix;
  142278. private _onLoad;
  142279. /**
  142280. * Instantiates a ColorGradingTexture from the following parameters.
  142281. *
  142282. * @param url The location of the color gradind data (currently only supporting 3dl)
  142283. * @param sceneOrEngine The scene or engine the texture will be used in
  142284. * @param onLoad defines a callback triggered when the texture has been loaded
  142285. */
  142286. constructor(url: string, sceneOrEngine: Scene | ThinEngine, onLoad?: Nullable<() => void>);
  142287. /**
  142288. * Fires the onload event from the constructor if requested.
  142289. */
  142290. private _triggerOnLoad;
  142291. /**
  142292. * Returns the texture matrix used in most of the material.
  142293. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  142294. */
  142295. getTextureMatrix(): Matrix;
  142296. /**
  142297. * Occurs when the file being loaded is a .3dl LUT file.
  142298. */
  142299. private load3dlTexture;
  142300. /**
  142301. * Starts the loading process of the texture.
  142302. */
  142303. private loadTexture;
  142304. /**
  142305. * Clones the color gradind texture.
  142306. */
  142307. clone(): ColorGradingTexture;
  142308. /**
  142309. * Called during delayed load for textures.
  142310. */
  142311. delayLoad(): void;
  142312. /**
  142313. * Parses a color grading texture serialized by Babylon.
  142314. * @param parsedTexture The texture information being parsedTexture
  142315. * @param scene The scene to load the texture in
  142316. * @param rootUrl The root url of the data assets to load
  142317. * @return A color gradind texture
  142318. */
  142319. static Parse(parsedTexture: any, scene: Scene): Nullable<ColorGradingTexture>;
  142320. /**
  142321. * Serializes the LUT texture to json format.
  142322. */
  142323. serialize(): any;
  142324. }
  142325. }
  142326. declare module BABYLON {
  142327. /**
  142328. * This represents a texture coming from an equirectangular image supported by the web browser canvas.
  142329. */
  142330. export class EquiRectangularCubeTexture extends BaseTexture {
  142331. /** The six faces of the cube. */
  142332. private static _FacesMapping;
  142333. private _noMipmap;
  142334. private _onLoad;
  142335. private _onError;
  142336. /** The size of the cubemap. */
  142337. private _size;
  142338. /** The buffer of the image. */
  142339. private _buffer;
  142340. /** The width of the input image. */
  142341. private _width;
  142342. /** The height of the input image. */
  142343. private _height;
  142344. /** The URL to the image. */
  142345. url: string;
  142346. /**
  142347. * Instantiates an EquiRectangularCubeTexture from the following parameters.
  142348. * @param url The location of the image
  142349. * @param scene The scene the texture will be used in
  142350. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  142351. * @param noMipmap Forces to not generate the mipmap if true
  142352. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  142353. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  142354. * @param onLoad — defines a callback called when texture is loaded
  142355. * @param onError — defines a callback called if there is an error
  142356. */
  142357. constructor(url: string, scene: Scene, size: number, noMipmap?: boolean, gammaSpace?: boolean, onLoad?: Nullable<() => void>, onError?: Nullable<(message?: string, exception?: any) => void>);
  142358. /**
  142359. * Load the image data, by putting the image on a canvas and extracting its buffer.
  142360. */
  142361. private loadImage;
  142362. /**
  142363. * Convert the image buffer into a cubemap and create a CubeTexture.
  142364. */
  142365. private loadTexture;
  142366. /**
  142367. * Convert the ArrayBuffer into a Float32Array and drop the transparency channel.
  142368. * @param buffer The ArrayBuffer that should be converted.
  142369. * @returns The buffer as Float32Array.
  142370. */
  142371. private getFloat32ArrayFromArrayBuffer;
  142372. /**
  142373. * Get the current class name of the texture useful for serialization or dynamic coding.
  142374. * @returns "EquiRectangularCubeTexture"
  142375. */
  142376. getClassName(): string;
  142377. /**
  142378. * Create a clone of the current EquiRectangularCubeTexture and return it.
  142379. * @returns A clone of the current EquiRectangularCubeTexture.
  142380. */
  142381. clone(): EquiRectangularCubeTexture;
  142382. }
  142383. }
  142384. declare module BABYLON {
  142385. /**
  142386. * Defines the options related to the creation of an HtmlElementTexture
  142387. */
  142388. export interface IHtmlElementTextureOptions {
  142389. /**
  142390. * Defines wether mip maps should be created or not.
  142391. */
  142392. generateMipMaps?: boolean;
  142393. /**
  142394. * Defines the sampling mode of the texture.
  142395. */
  142396. samplingMode?: number;
  142397. /**
  142398. * Defines the engine instance to use the texture with. It is not mandatory if you define a scene.
  142399. */
  142400. engine: Nullable<ThinEngine>;
  142401. /**
  142402. * Defines the scene the texture belongs to. It is not mandatory if you define an engine.
  142403. */
  142404. scene: Nullable<Scene>;
  142405. }
  142406. /**
  142407. * This represents the smallest workload to use an already existing element (Canvas or Video) as a texture.
  142408. * To be as efficient as possible depending on your constraints nothing aside the first upload
  142409. * is automatically managed.
  142410. * It is a cheap VideoTexture or DynamicTexture if you prefer to keep full control of the elements
  142411. * in your application.
  142412. *
  142413. * As the update is not automatic, you need to call them manually.
  142414. */
  142415. export class HtmlElementTexture extends BaseTexture {
  142416. /**
  142417. * The texture URL.
  142418. */
  142419. element: HTMLVideoElement | HTMLCanvasElement;
  142420. private static readonly DefaultOptions;
  142421. private _textureMatrix;
  142422. private _isVideo;
  142423. private _generateMipMaps;
  142424. private _samplingMode;
  142425. /**
  142426. * Instantiates a HtmlElementTexture from the following parameters.
  142427. *
  142428. * @param name Defines the name of the texture
  142429. * @param element Defines the video or canvas the texture is filled with
  142430. * @param options Defines the other none mandatory texture creation options
  142431. */
  142432. constructor(name: string, element: HTMLVideoElement | HTMLCanvasElement, options: IHtmlElementTextureOptions);
  142433. private _createInternalTexture;
  142434. /**
  142435. * Returns the texture matrix used in most of the material.
  142436. */
  142437. getTextureMatrix(): Matrix;
  142438. /**
  142439. * Updates the content of the texture.
  142440. * @param invertY Defines wether the texture should be inverted on Y (false by default on video and true on canvas)
  142441. */
  142442. update(invertY?: Nullable<boolean>): void;
  142443. }
  142444. }
  142445. declare module BABYLON {
  142446. /**
  142447. * Based on jsTGALoader - Javascript loader for TGA file
  142448. * By Vincent Thibault
  142449. * @see http://blog.robrowser.com/javascript-tga-loader.html
  142450. */
  142451. export class TGATools {
  142452. private static _TYPE_INDEXED;
  142453. private static _TYPE_RGB;
  142454. private static _TYPE_GREY;
  142455. private static _TYPE_RLE_INDEXED;
  142456. private static _TYPE_RLE_RGB;
  142457. private static _TYPE_RLE_GREY;
  142458. private static _ORIGIN_MASK;
  142459. private static _ORIGIN_SHIFT;
  142460. private static _ORIGIN_BL;
  142461. private static _ORIGIN_BR;
  142462. private static _ORIGIN_UL;
  142463. private static _ORIGIN_UR;
  142464. /**
  142465. * Gets the header of a TGA file
  142466. * @param data defines the TGA data
  142467. * @returns the header
  142468. */
  142469. static GetTGAHeader(data: Uint8Array): any;
  142470. /**
  142471. * Uploads TGA content to a Babylon Texture
  142472. * @hidden
  142473. */
  142474. static UploadContent(texture: InternalTexture, data: Uint8Array): void;
  142475. /** @hidden */
  142476. 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;
  142477. /** @hidden */
  142478. 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;
  142479. /** @hidden */
  142480. 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;
  142481. /** @hidden */
  142482. 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;
  142483. /** @hidden */
  142484. 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;
  142485. /** @hidden */
  142486. 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;
  142487. }
  142488. }
  142489. declare module BABYLON {
  142490. /**
  142491. * Implementation of the TGA Texture Loader.
  142492. * @hidden
  142493. */
  142494. export class _TGATextureLoader implements IInternalTextureLoader {
  142495. /**
  142496. * Defines wether the loader supports cascade loading the different faces.
  142497. */
  142498. readonly supportCascades: boolean;
  142499. /**
  142500. * This returns if the loader support the current file information.
  142501. * @param extension defines the file extension of the file being loaded
  142502. * @returns true if the loader can load the specified file
  142503. */
  142504. canLoad(extension: string): boolean;
  142505. /**
  142506. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142507. * @param data contains the texture data
  142508. * @param texture defines the BabylonJS internal texture
  142509. * @param createPolynomials will be true if polynomials have been requested
  142510. * @param onLoad defines the callback to trigger once the texture is ready
  142511. * @param onError defines the callback to trigger in case of error
  142512. */
  142513. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142514. /**
  142515. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142516. * @param data contains the texture data
  142517. * @param texture defines the BabylonJS internal texture
  142518. * @param callback defines the method to call once ready to upload
  142519. */
  142520. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142521. }
  142522. }
  142523. declare module BABYLON {
  142524. /**
  142525. * Info about the .basis files
  142526. */
  142527. class BasisFileInfo {
  142528. /**
  142529. * If the file has alpha
  142530. */
  142531. hasAlpha: boolean;
  142532. /**
  142533. * Info about each image of the basis file
  142534. */
  142535. images: Array<{
  142536. levels: Array<{
  142537. width: number;
  142538. height: number;
  142539. transcodedPixels: ArrayBufferView;
  142540. }>;
  142541. }>;
  142542. }
  142543. /**
  142544. * Result of transcoding a basis file
  142545. */
  142546. class TranscodeResult {
  142547. /**
  142548. * Info about the .basis file
  142549. */
  142550. fileInfo: BasisFileInfo;
  142551. /**
  142552. * Format to use when loading the file
  142553. */
  142554. format: number;
  142555. }
  142556. /**
  142557. * Configuration options for the Basis transcoder
  142558. */
  142559. export class BasisTranscodeConfiguration {
  142560. /**
  142561. * Supported compression formats used to determine the supported output format of the transcoder
  142562. */
  142563. supportedCompressionFormats?: {
  142564. /**
  142565. * etc1 compression format
  142566. */
  142567. etc1?: boolean;
  142568. /**
  142569. * s3tc compression format
  142570. */
  142571. s3tc?: boolean;
  142572. /**
  142573. * pvrtc compression format
  142574. */
  142575. pvrtc?: boolean;
  142576. /**
  142577. * etc2 compression format
  142578. */
  142579. etc2?: boolean;
  142580. };
  142581. /**
  142582. * If mipmap levels should be loaded for transcoded images (Default: true)
  142583. */
  142584. loadMipmapLevels?: boolean;
  142585. /**
  142586. * Index of a single image to load (Default: all images)
  142587. */
  142588. loadSingleImage?: number;
  142589. }
  142590. /**
  142591. * Used to load .Basis files
  142592. * See https://github.com/BinomialLLC/basis_universal/tree/master/webgl
  142593. */
  142594. export class BasisTools {
  142595. private static _IgnoreSupportedFormats;
  142596. /**
  142597. * URL to use when loading the basis transcoder
  142598. */
  142599. static JSModuleURL: string;
  142600. /**
  142601. * URL to use when loading the wasm module for the transcoder
  142602. */
  142603. static WasmModuleURL: string;
  142604. /**
  142605. * Get the internal format to be passed to texImage2D corresponding to the .basis format value
  142606. * @param basisFormat format chosen from GetSupportedTranscodeFormat
  142607. * @returns internal format corresponding to the Basis format
  142608. */
  142609. static GetInternalFormatFromBasisFormat(basisFormat: number): number;
  142610. private static _WorkerPromise;
  142611. private static _Worker;
  142612. private static _actionId;
  142613. private static _CreateWorkerAsync;
  142614. /**
  142615. * Transcodes a loaded image file to compressed pixel data
  142616. * @param data image data to transcode
  142617. * @param config configuration options for the transcoding
  142618. * @returns a promise resulting in the transcoded image
  142619. */
  142620. static TranscodeAsync(data: ArrayBuffer | ArrayBufferView, config: BasisTranscodeConfiguration): Promise<TranscodeResult>;
  142621. /**
  142622. * Loads a texture from the transcode result
  142623. * @param texture texture load to
  142624. * @param transcodeResult the result of transcoding the basis file to load from
  142625. */
  142626. static LoadTextureFromTranscodeResult(texture: InternalTexture, transcodeResult: TranscodeResult): void;
  142627. }
  142628. }
  142629. declare module BABYLON {
  142630. /**
  142631. * Loader for .basis file format
  142632. */
  142633. export class _BasisTextureLoader implements IInternalTextureLoader {
  142634. /**
  142635. * Defines whether the loader supports cascade loading the different faces.
  142636. */
  142637. readonly supportCascades: boolean;
  142638. /**
  142639. * This returns if the loader support the current file information.
  142640. * @param extension defines the file extension of the file being loaded
  142641. * @returns true if the loader can load the specified file
  142642. */
  142643. canLoad(extension: string): boolean;
  142644. /**
  142645. * Uploads the cube texture data to the WebGL texture. It has already been bound.
  142646. * @param data contains the texture data
  142647. * @param texture defines the BabylonJS internal texture
  142648. * @param createPolynomials will be true if polynomials have been requested
  142649. * @param onLoad defines the callback to trigger once the texture is ready
  142650. * @param onError defines the callback to trigger in case of error
  142651. */
  142652. loadCubeData(data: ArrayBufferView | ArrayBufferView[], texture: InternalTexture, createPolynomials: boolean, onLoad: Nullable<(data?: any) => void>, onError: Nullable<(message?: string, exception?: any) => void>): void;
  142653. /**
  142654. * Uploads the 2D texture data to the WebGL texture. It has already been bound once in the callback.
  142655. * @param data contains the texture data
  142656. * @param texture defines the BabylonJS internal texture
  142657. * @param callback defines the method to call once ready to upload
  142658. */
  142659. loadData(data: ArrayBufferView, texture: InternalTexture, callback: (width: number, height: number, loadMipmap: boolean, isCompressed: boolean, done: () => void) => void): void;
  142660. }
  142661. }
  142662. declare module BABYLON {
  142663. /**
  142664. * Defines the basic options interface of a TexturePacker Frame
  142665. */
  142666. export interface ITexturePackerFrame {
  142667. /**
  142668. * The frame ID
  142669. */
  142670. id: number;
  142671. /**
  142672. * The frames Scale
  142673. */
  142674. scale: Vector2;
  142675. /**
  142676. * The Frames offset
  142677. */
  142678. offset: Vector2;
  142679. }
  142680. /**
  142681. * This is a support class for frame Data on texture packer sets.
  142682. */
  142683. export class TexturePackerFrame implements ITexturePackerFrame {
  142684. /**
  142685. * The frame ID
  142686. */
  142687. id: number;
  142688. /**
  142689. * The frames Scale
  142690. */
  142691. scale: Vector2;
  142692. /**
  142693. * The Frames offset
  142694. */
  142695. offset: Vector2;
  142696. /**
  142697. * Initializes a texture package frame.
  142698. * @param id The numerical frame identifier
  142699. * @param scale Scalar Vector2 for UV frame
  142700. * @param offset Vector2 for the frame position in UV units.
  142701. * @returns TexturePackerFrame
  142702. */
  142703. constructor(id: number, scale: Vector2, offset: Vector2);
  142704. }
  142705. }
  142706. declare module BABYLON {
  142707. /**
  142708. * Defines the basic options interface of a TexturePacker
  142709. */
  142710. export interface ITexturePackerOptions {
  142711. /**
  142712. * Custom targets for the channels of a texture packer. Default is all the channels of the Standard Material
  142713. */
  142714. map?: string[];
  142715. /**
  142716. * the UV input targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142717. */
  142718. uvsIn?: string;
  142719. /**
  142720. * the UV output targets, as a single value for all meshes. Defaults to VertexBuffer.UVKind
  142721. */
  142722. uvsOut?: string;
  142723. /**
  142724. * number representing the layout style. Defaults to LAYOUT_STRIP
  142725. */
  142726. layout?: number;
  142727. /**
  142728. * number of columns if using custom column count layout(2). This defaults to 4.
  142729. */
  142730. colnum?: number;
  142731. /**
  142732. * flag to update the input meshes to the new packed texture after compilation. Defaults to true.
  142733. */
  142734. updateInputMeshes?: boolean;
  142735. /**
  142736. * boolean flag to dispose all the source textures. Defaults to true.
  142737. */
  142738. disposeSources?: boolean;
  142739. /**
  142740. * Fills the blank cells in a set to the customFillColor. Defaults to true.
  142741. */
  142742. fillBlanks?: boolean;
  142743. /**
  142744. * string value representing the context fill style color. Defaults to 'black'.
  142745. */
  142746. customFillColor?: string;
  142747. /**
  142748. * Width and Height Value of each Frame in the TexturePacker Sets
  142749. */
  142750. frameSize?: number;
  142751. /**
  142752. * Ratio of the value to add padding wise to each cell. Defaults to 0.0115
  142753. */
  142754. paddingRatio?: number;
  142755. /**
  142756. * Number that declares the fill method for the padding gutter.
  142757. */
  142758. paddingMode?: number;
  142759. /**
  142760. * If in SUBUV_COLOR padding mode what color to use.
  142761. */
  142762. paddingColor?: Color3 | Color4;
  142763. }
  142764. /**
  142765. * Defines the basic interface of a TexturePacker JSON File
  142766. */
  142767. export interface ITexturePackerJSON {
  142768. /**
  142769. * The frame ID
  142770. */
  142771. name: string;
  142772. /**
  142773. * The base64 channel data
  142774. */
  142775. sets: any;
  142776. /**
  142777. * The options of the Packer
  142778. */
  142779. options: ITexturePackerOptions;
  142780. /**
  142781. * The frame data of the Packer
  142782. */
  142783. frames: Array<number>;
  142784. }
  142785. /**
  142786. * This is a support class that generates a series of packed texture sets.
  142787. * @see https://doc.babylonjs.com/babylon101/materials
  142788. */
  142789. export class TexturePacker {
  142790. /** Packer Layout Constant 0 */
  142791. static readonly LAYOUT_STRIP: number;
  142792. /** Packer Layout Constant 1 */
  142793. static readonly LAYOUT_POWER2: number;
  142794. /** Packer Layout Constant 2 */
  142795. static readonly LAYOUT_COLNUM: number;
  142796. /** Packer Layout Constant 0 */
  142797. static readonly SUBUV_WRAP: number;
  142798. /** Packer Layout Constant 1 */
  142799. static readonly SUBUV_EXTEND: number;
  142800. /** Packer Layout Constant 2 */
  142801. static readonly SUBUV_COLOR: number;
  142802. /** The Name of the Texture Package */
  142803. name: string;
  142804. /** The scene scope of the TexturePacker */
  142805. scene: Scene;
  142806. /** The Meshes to target */
  142807. meshes: AbstractMesh[];
  142808. /** Arguments passed with the Constructor */
  142809. options: ITexturePackerOptions;
  142810. /** The promise that is started upon initialization */
  142811. promise: Nullable<Promise<TexturePacker | string>>;
  142812. /** The Container object for the channel sets that are generated */
  142813. sets: object;
  142814. /** The Container array for the frames that are generated */
  142815. frames: TexturePackerFrame[];
  142816. /** The expected number of textures the system is parsing. */
  142817. private _expecting;
  142818. /** The padding value from Math.ceil(frameSize * paddingRatio) */
  142819. private _paddingValue;
  142820. /**
  142821. * Initializes a texture package series from an array of meshes or a single mesh.
  142822. * @param name The name of the package
  142823. * @param meshes The target meshes to compose the package from
  142824. * @param options The arguments that texture packer should follow while building.
  142825. * @param scene The scene which the textures are scoped to.
  142826. * @returns TexturePacker
  142827. */
  142828. constructor(name: string, meshes: AbstractMesh[], options: ITexturePackerOptions, scene: Scene);
  142829. /**
  142830. * Starts the package process
  142831. * @param resolve The promises resolution function
  142832. * @returns TexturePacker
  142833. */
  142834. private _createFrames;
  142835. /**
  142836. * Calculates the Size of the Channel Sets
  142837. * @returns Vector2
  142838. */
  142839. private _calculateSize;
  142840. /**
  142841. * Calculates the UV data for the frames.
  142842. * @param baseSize the base frameSize
  142843. * @param padding the base frame padding
  142844. * @param dtSize size of the Dynamic Texture for that channel
  142845. * @param dtUnits is 1/dtSize
  142846. * @param update flag to update the input meshes
  142847. */
  142848. private _calculateMeshUVFrames;
  142849. /**
  142850. * Calculates the frames Offset.
  142851. * @param index of the frame
  142852. * @returns Vector2
  142853. */
  142854. private _getFrameOffset;
  142855. /**
  142856. * Updates a Mesh to the frame data
  142857. * @param mesh that is the target
  142858. * @param frameID or the frame index
  142859. */
  142860. private _updateMeshUV;
  142861. /**
  142862. * Updates a Meshes materials to use the texture packer channels
  142863. * @param m is the mesh to target
  142864. * @param force all channels on the packer to be set.
  142865. */
  142866. private _updateTextureReferences;
  142867. /**
  142868. * Public method to set a Mesh to a frame
  142869. * @param m that is the target
  142870. * @param frameID or the frame index
  142871. * @param updateMaterial trigger for if the Meshes attached Material be updated?
  142872. */
  142873. setMeshToFrame(m: AbstractMesh, frameID: number, updateMaterial?: boolean): void;
  142874. /**
  142875. * Starts the async promise to compile the texture packer.
  142876. * @returns Promise<void>
  142877. */
  142878. processAsync(): Promise<void>;
  142879. /**
  142880. * Disposes all textures associated with this packer
  142881. */
  142882. dispose(): void;
  142883. /**
  142884. * Starts the download process for all the channels converting them to base64 data and embedding it all in a JSON file.
  142885. * @param imageType is the image type to use.
  142886. * @param quality of the image if downloading as jpeg, Ranges from >0 to 1.
  142887. */
  142888. download(imageType?: string, quality?: number): void;
  142889. /**
  142890. * Public method to load a texturePacker JSON file.
  142891. * @param data of the JSON file in string format.
  142892. */
  142893. updateFromJSON(data: string): void;
  142894. }
  142895. }
  142896. declare module BABYLON {
  142897. /**
  142898. * 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.
  142899. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142900. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142901. */
  142902. export class CustomProceduralTexture extends ProceduralTexture {
  142903. private _animate;
  142904. private _time;
  142905. private _config;
  142906. private _texturePath;
  142907. /**
  142908. * Instantiates a new Custom Procedural Texture.
  142909. * 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.
  142910. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  142911. * @see https://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  142912. * @param name Define the name of the texture
  142913. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  142914. * @param size Define the size of the texture to create
  142915. * @param scene Define the scene the texture belongs to
  142916. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  142917. * @param generateMipMaps Define if the texture should creates mip maps or not
  142918. */
  142919. constructor(name: string, texturePath: string, size: number, scene: Scene, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142920. private _loadJson;
  142921. /**
  142922. * Is the texture ready to be used ? (rendered at least once)
  142923. * @returns true if ready, otherwise, false.
  142924. */
  142925. isReady(): boolean;
  142926. /**
  142927. * Render the texture to its associated render target.
  142928. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  142929. */
  142930. render(useCameraPostProcess?: boolean): void;
  142931. /**
  142932. * Update the list of dependant textures samplers in the shader.
  142933. */
  142934. updateTextures(): void;
  142935. /**
  142936. * Update the uniform values of the procedural texture in the shader.
  142937. */
  142938. updateShaderUniforms(): void;
  142939. /**
  142940. * Define if the texture animates or not.
  142941. */
  142942. get animate(): boolean;
  142943. set animate(value: boolean);
  142944. }
  142945. }
  142946. declare module BABYLON {
  142947. /** @hidden */
  142948. export var noisePixelShader: {
  142949. name: string;
  142950. shader: string;
  142951. };
  142952. }
  142953. declare module BABYLON {
  142954. /**
  142955. * Class used to generate noise procedural textures
  142956. */
  142957. export class NoiseProceduralTexture extends ProceduralTexture {
  142958. /** Gets or sets the start time (default is 0) */
  142959. time: number;
  142960. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  142961. brightness: number;
  142962. /** Defines the number of octaves to process */
  142963. octaves: number;
  142964. /** Defines the level of persistence (0.8 by default) */
  142965. persistence: number;
  142966. /** Gets or sets animation speed factor (default is 1) */
  142967. animationSpeedFactor: number;
  142968. /**
  142969. * Creates a new NoiseProceduralTexture
  142970. * @param name defines the name fo the texture
  142971. * @param size defines the size of the texture (default is 256)
  142972. * @param scene defines the hosting scene
  142973. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  142974. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  142975. */
  142976. constructor(name: string, size?: number, scene?: Nullable<Scene>, fallbackTexture?: Texture, generateMipMaps?: boolean);
  142977. private _updateShaderUniforms;
  142978. protected _getDefines(): string;
  142979. /** Generate the current state of the procedural texture */
  142980. render(useCameraPostProcess?: boolean): void;
  142981. /**
  142982. * Serializes this noise procedural texture
  142983. * @returns a serialized noise procedural texture object
  142984. */
  142985. serialize(): any;
  142986. /**
  142987. * Clone the texture.
  142988. * @returns the cloned texture
  142989. */
  142990. clone(): NoiseProceduralTexture;
  142991. /**
  142992. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  142993. * @param parsedTexture defines parsed texture data
  142994. * @param scene defines the current scene
  142995. * @param rootUrl defines the root URL containing noise procedural texture information
  142996. * @returns a parsed NoiseProceduralTexture
  142997. */
  142998. static Parse(parsedTexture: any, scene: Scene): NoiseProceduralTexture;
  142999. }
  143000. }
  143001. declare module BABYLON {
  143002. /**
  143003. * Raw cube texture where the raw buffers are passed in
  143004. */
  143005. export class RawCubeTexture extends CubeTexture {
  143006. /**
  143007. * Creates a cube texture where the raw buffers are passed in.
  143008. * @param scene defines the scene the texture is attached to
  143009. * @param data defines the array of data to use to create each face
  143010. * @param size defines the size of the textures
  143011. * @param format defines the format of the data
  143012. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  143013. * @param generateMipMaps defines if the engine should generate the mip levels
  143014. * @param invertY defines if data must be stored with Y axis inverted
  143015. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  143016. * @param compression defines the compression used (null by default)
  143017. */
  143018. constructor(scene: Scene, data: Nullable<ArrayBufferView[]>, size: number, format?: number, type?: number, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, compression?: Nullable<string>);
  143019. /**
  143020. * Updates the raw cube texture.
  143021. * @param data defines the data to store
  143022. * @param format defines the data format
  143023. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  143024. * @param invertY defines if data must be stored with Y axis inverted
  143025. * @param compression defines the compression used (null by default)
  143026. * @param level defines which level of the texture to update
  143027. */
  143028. update(data: ArrayBufferView[], format: number, type: number, invertY: boolean, compression?: Nullable<string>): void;
  143029. /**
  143030. * Updates a raw cube texture with RGBD encoded data.
  143031. * @param data defines the array of data [mipmap][face] to use to create each face
  143032. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  143033. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  143034. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  143035. * @returns a promsie that resolves when the operation is complete
  143036. */
  143037. updateRGBDAsync(data: ArrayBufferView[][], sphericalPolynomial?: Nullable<SphericalPolynomial>, lodScale?: number, lodOffset?: number): Promise<void>;
  143038. /**
  143039. * Clones the raw cube texture.
  143040. * @return a new cube texture
  143041. */
  143042. clone(): CubeTexture;
  143043. /** @hidden */
  143044. static _UpdateRGBDAsync(internalTexture: InternalTexture, data: ArrayBufferView[][], sphericalPolynomial: Nullable<SphericalPolynomial>, lodScale: number, lodOffset: number): Promise<void>;
  143045. }
  143046. }
  143047. declare module BABYLON {
  143048. /**
  143049. * Class used to store 2D array textures containing user data
  143050. */
  143051. export class RawTexture2DArray extends Texture {
  143052. /** Gets or sets the texture format to use */
  143053. format: number;
  143054. /**
  143055. * Create a new RawTexture2DArray
  143056. * @param data defines the data of the texture
  143057. * @param width defines the width of the texture
  143058. * @param height defines the height of the texture
  143059. * @param depth defines the number of layers of the texture
  143060. * @param format defines the texture format to use
  143061. * @param scene defines the hosting scene
  143062. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143063. * @param invertY defines if texture must be stored with Y axis inverted
  143064. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143065. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143066. */
  143067. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143068. /** Gets or sets the texture format to use */
  143069. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143070. /**
  143071. * Update the texture with new data
  143072. * @param data defines the data to store in the texture
  143073. */
  143074. update(data: ArrayBufferView): void;
  143075. }
  143076. }
  143077. declare module BABYLON {
  143078. /**
  143079. * Class used to store 3D textures containing user data
  143080. */
  143081. export class RawTexture3D extends Texture {
  143082. /** Gets or sets the texture format to use */
  143083. format: number;
  143084. /**
  143085. * Create a new RawTexture3D
  143086. * @param data defines the data of the texture
  143087. * @param width defines the width of the texture
  143088. * @param height defines the height of the texture
  143089. * @param depth defines the depth of the texture
  143090. * @param format defines the texture format to use
  143091. * @param scene defines the hosting scene
  143092. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  143093. * @param invertY defines if texture must be stored with Y axis inverted
  143094. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  143095. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  143096. */
  143097. constructor(data: ArrayBufferView, width: number, height: number, depth: number,
  143098. /** Gets or sets the texture format to use */
  143099. format: number, scene: Scene, generateMipMaps?: boolean, invertY?: boolean, samplingMode?: number, textureType?: number);
  143100. /**
  143101. * Update the texture with new data
  143102. * @param data defines the data to store in the texture
  143103. */
  143104. update(data: ArrayBufferView): void;
  143105. }
  143106. }
  143107. declare module BABYLON {
  143108. /**
  143109. * Creates a refraction texture used by refraction channel of the standard material.
  143110. * It is like a mirror but to see through a material.
  143111. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143112. */
  143113. export class RefractionTexture extends RenderTargetTexture {
  143114. /**
  143115. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  143116. * 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.
  143117. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143118. */
  143119. refractionPlane: Plane;
  143120. /**
  143121. * Define how deep under the surface we should see.
  143122. */
  143123. depth: number;
  143124. /**
  143125. * Creates a refraction texture used by refraction channel of the standard material.
  143126. * It is like a mirror but to see through a material.
  143127. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  143128. * @param name Define the texture name
  143129. * @param size Define the size of the underlying texture
  143130. * @param scene Define the scene the refraction belongs to
  143131. * @param generateMipMaps Define if we need to generate mips level for the refraction
  143132. */
  143133. constructor(name: string, size: number, scene: Scene, generateMipMaps?: boolean);
  143134. /**
  143135. * Clone the refraction texture.
  143136. * @returns the cloned texture
  143137. */
  143138. clone(): RefractionTexture;
  143139. /**
  143140. * Serialize the texture to a JSON representation you could use in Parse later on
  143141. * @returns the serialized JSON representation
  143142. */
  143143. serialize(): any;
  143144. }
  143145. }
  143146. declare module BABYLON {
  143147. /**
  143148. * Block used to add support for vertex skinning (bones)
  143149. */
  143150. export class BonesBlock extends NodeMaterialBlock {
  143151. /**
  143152. * Creates a new BonesBlock
  143153. * @param name defines the block name
  143154. */
  143155. constructor(name: string);
  143156. /**
  143157. * Initialize the block and prepare the context for build
  143158. * @param state defines the state that will be used for the build
  143159. */
  143160. initialize(state: NodeMaterialBuildState): void;
  143161. /**
  143162. * Gets the current class name
  143163. * @returns the class name
  143164. */
  143165. getClassName(): string;
  143166. /**
  143167. * Gets the matrix indices input component
  143168. */
  143169. get matricesIndices(): NodeMaterialConnectionPoint;
  143170. /**
  143171. * Gets the matrix weights input component
  143172. */
  143173. get matricesWeights(): NodeMaterialConnectionPoint;
  143174. /**
  143175. * Gets the extra matrix indices input component
  143176. */
  143177. get matricesIndicesExtra(): NodeMaterialConnectionPoint;
  143178. /**
  143179. * Gets the extra matrix weights input component
  143180. */
  143181. get matricesWeightsExtra(): NodeMaterialConnectionPoint;
  143182. /**
  143183. * Gets the world input component
  143184. */
  143185. get world(): NodeMaterialConnectionPoint;
  143186. /**
  143187. * Gets the output component
  143188. */
  143189. get output(): NodeMaterialConnectionPoint;
  143190. autoConfigure(material: NodeMaterial): void;
  143191. provideFallbacks(mesh: AbstractMesh, fallbacks: EffectFallbacks): void;
  143192. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143193. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143194. protected _buildBlock(state: NodeMaterialBuildState): this;
  143195. }
  143196. }
  143197. declare module BABYLON {
  143198. /**
  143199. * Block used to add support for instances
  143200. * @see https://doc.babylonjs.com/how_to/how_to_use_instances
  143201. */
  143202. export class InstancesBlock extends NodeMaterialBlock {
  143203. /**
  143204. * Creates a new InstancesBlock
  143205. * @param name defines the block name
  143206. */
  143207. constructor(name: string);
  143208. /**
  143209. * Gets the current class name
  143210. * @returns the class name
  143211. */
  143212. getClassName(): string;
  143213. /**
  143214. * Gets the first world row input component
  143215. */
  143216. get world0(): NodeMaterialConnectionPoint;
  143217. /**
  143218. * Gets the second world row input component
  143219. */
  143220. get world1(): NodeMaterialConnectionPoint;
  143221. /**
  143222. * Gets the third world row input component
  143223. */
  143224. get world2(): NodeMaterialConnectionPoint;
  143225. /**
  143226. * Gets the forth world row input component
  143227. */
  143228. get world3(): NodeMaterialConnectionPoint;
  143229. /**
  143230. * Gets the world input component
  143231. */
  143232. get world(): NodeMaterialConnectionPoint;
  143233. /**
  143234. * Gets the output component
  143235. */
  143236. get output(): NodeMaterialConnectionPoint;
  143237. /**
  143238. * Gets the isntanceID component
  143239. */
  143240. get instanceID(): NodeMaterialConnectionPoint;
  143241. autoConfigure(material: NodeMaterial): void;
  143242. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, useInstances?: boolean, subMesh?: SubMesh): void;
  143243. protected _buildBlock(state: NodeMaterialBuildState): this;
  143244. }
  143245. }
  143246. declare module BABYLON {
  143247. /**
  143248. * Block used to add morph targets support to vertex shader
  143249. */
  143250. export class MorphTargetsBlock extends NodeMaterialBlock {
  143251. private _repeatableContentAnchor;
  143252. /**
  143253. * Create a new MorphTargetsBlock
  143254. * @param name defines the block name
  143255. */
  143256. constructor(name: string);
  143257. /**
  143258. * Gets the current class name
  143259. * @returns the class name
  143260. */
  143261. getClassName(): string;
  143262. /**
  143263. * Gets the position input component
  143264. */
  143265. get position(): NodeMaterialConnectionPoint;
  143266. /**
  143267. * Gets the normal input component
  143268. */
  143269. get normal(): NodeMaterialConnectionPoint;
  143270. /**
  143271. * Gets the tangent input component
  143272. */
  143273. get tangent(): NodeMaterialConnectionPoint;
  143274. /**
  143275. * Gets the tangent input component
  143276. */
  143277. get uv(): NodeMaterialConnectionPoint;
  143278. /**
  143279. * Gets the position output component
  143280. */
  143281. get positionOutput(): NodeMaterialConnectionPoint;
  143282. /**
  143283. * Gets the normal output component
  143284. */
  143285. get normalOutput(): NodeMaterialConnectionPoint;
  143286. /**
  143287. * Gets the tangent output component
  143288. */
  143289. get tangentOutput(): NodeMaterialConnectionPoint;
  143290. /**
  143291. * Gets the tangent output component
  143292. */
  143293. get uvOutput(): NodeMaterialConnectionPoint;
  143294. initialize(state: NodeMaterialBuildState): void;
  143295. autoConfigure(material: NodeMaterial): void;
  143296. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143297. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143298. replaceRepeatableContent(vertexShaderState: NodeMaterialBuildState, fragmentShaderState: NodeMaterialBuildState, mesh: AbstractMesh, defines: NodeMaterialDefines): void;
  143299. protected _buildBlock(state: NodeMaterialBuildState): this;
  143300. }
  143301. }
  143302. declare module BABYLON {
  143303. /**
  143304. * Block used to get data information from a light
  143305. */
  143306. export class LightInformationBlock extends NodeMaterialBlock {
  143307. private _lightDataUniformName;
  143308. private _lightColorUniformName;
  143309. private _lightTypeDefineName;
  143310. /**
  143311. * Gets or sets the light associated with this block
  143312. */
  143313. light: Nullable<Light>;
  143314. /**
  143315. * Creates a new LightInformationBlock
  143316. * @param name defines the block name
  143317. */
  143318. constructor(name: string);
  143319. /**
  143320. * Gets the current class name
  143321. * @returns the class name
  143322. */
  143323. getClassName(): string;
  143324. /**
  143325. * Gets the world position input component
  143326. */
  143327. get worldPosition(): NodeMaterialConnectionPoint;
  143328. /**
  143329. * Gets the direction output component
  143330. */
  143331. get direction(): NodeMaterialConnectionPoint;
  143332. /**
  143333. * Gets the direction output component
  143334. */
  143335. get color(): NodeMaterialConnectionPoint;
  143336. /**
  143337. * Gets the direction output component
  143338. */
  143339. get intensity(): NodeMaterialConnectionPoint;
  143340. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143341. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143342. protected _buildBlock(state: NodeMaterialBuildState): this;
  143343. serialize(): any;
  143344. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143345. }
  143346. }
  143347. declare module BABYLON {
  143348. /**
  143349. * Block used to add image processing support to fragment shader
  143350. */
  143351. export class ImageProcessingBlock extends NodeMaterialBlock {
  143352. /**
  143353. * Create a new ImageProcessingBlock
  143354. * @param name defines the block name
  143355. */
  143356. constructor(name: string);
  143357. /**
  143358. * Gets the current class name
  143359. * @returns the class name
  143360. */
  143361. getClassName(): string;
  143362. /**
  143363. * Gets the color input component
  143364. */
  143365. get color(): NodeMaterialConnectionPoint;
  143366. /**
  143367. * Gets the output component
  143368. */
  143369. get output(): NodeMaterialConnectionPoint;
  143370. /**
  143371. * Initialize the block and prepare the context for build
  143372. * @param state defines the state that will be used for the build
  143373. */
  143374. initialize(state: NodeMaterialBuildState): void;
  143375. isReady(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): boolean;
  143376. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143377. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143378. protected _buildBlock(state: NodeMaterialBuildState): this;
  143379. }
  143380. }
  143381. declare module BABYLON {
  143382. /**
  143383. * Block used to pertub normals based on a normal map
  143384. */
  143385. export class PerturbNormalBlock extends NodeMaterialBlock {
  143386. private _tangentSpaceParameterName;
  143387. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  143388. invertX: boolean;
  143389. /** Gets or sets a boolean indicating that normal should be inverted on Y axis */
  143390. invertY: boolean;
  143391. /**
  143392. * Create a new PerturbNormalBlock
  143393. * @param name defines the block name
  143394. */
  143395. constructor(name: string);
  143396. /**
  143397. * Gets the current class name
  143398. * @returns the class name
  143399. */
  143400. getClassName(): string;
  143401. /**
  143402. * Gets the world position input component
  143403. */
  143404. get worldPosition(): NodeMaterialConnectionPoint;
  143405. /**
  143406. * Gets the world normal input component
  143407. */
  143408. get worldNormal(): NodeMaterialConnectionPoint;
  143409. /**
  143410. * Gets the world tangent input component
  143411. */
  143412. get worldTangent(): NodeMaterialConnectionPoint;
  143413. /**
  143414. * Gets the uv input component
  143415. */
  143416. get uv(): NodeMaterialConnectionPoint;
  143417. /**
  143418. * Gets the normal map color input component
  143419. */
  143420. get normalMapColor(): NodeMaterialConnectionPoint;
  143421. /**
  143422. * Gets the strength input component
  143423. */
  143424. get strength(): NodeMaterialConnectionPoint;
  143425. /**
  143426. * Gets the output component
  143427. */
  143428. get output(): NodeMaterialConnectionPoint;
  143429. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143430. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143431. autoConfigure(material: NodeMaterial): void;
  143432. protected _buildBlock(state: NodeMaterialBuildState): this;
  143433. protected _dumpPropertiesCode(): string;
  143434. serialize(): any;
  143435. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143436. }
  143437. }
  143438. declare module BABYLON {
  143439. /**
  143440. * Block used to discard a pixel if a value is smaller than a cutoff
  143441. */
  143442. export class DiscardBlock extends NodeMaterialBlock {
  143443. /**
  143444. * Create a new DiscardBlock
  143445. * @param name defines the block name
  143446. */
  143447. constructor(name: string);
  143448. /**
  143449. * Gets the current class name
  143450. * @returns the class name
  143451. */
  143452. getClassName(): string;
  143453. /**
  143454. * Gets the color input component
  143455. */
  143456. get value(): NodeMaterialConnectionPoint;
  143457. /**
  143458. * Gets the cutoff input component
  143459. */
  143460. get cutoff(): NodeMaterialConnectionPoint;
  143461. protected _buildBlock(state: NodeMaterialBuildState): this;
  143462. }
  143463. }
  143464. declare module BABYLON {
  143465. /**
  143466. * Block used to test if the fragment shader is front facing
  143467. */
  143468. export class FrontFacingBlock extends NodeMaterialBlock {
  143469. /**
  143470. * Creates a new FrontFacingBlock
  143471. * @param name defines the block name
  143472. */
  143473. constructor(name: string);
  143474. /**
  143475. * Gets the current class name
  143476. * @returns the class name
  143477. */
  143478. getClassName(): string;
  143479. /**
  143480. * Gets the output component
  143481. */
  143482. get output(): NodeMaterialConnectionPoint;
  143483. protected _buildBlock(state: NodeMaterialBuildState): this;
  143484. }
  143485. }
  143486. declare module BABYLON {
  143487. /**
  143488. * Block used to get the derivative value on x and y of a given input
  143489. */
  143490. export class DerivativeBlock extends NodeMaterialBlock {
  143491. /**
  143492. * Create a new DerivativeBlock
  143493. * @param name defines the block name
  143494. */
  143495. constructor(name: string);
  143496. /**
  143497. * Gets the current class name
  143498. * @returns the class name
  143499. */
  143500. getClassName(): string;
  143501. /**
  143502. * Gets the input component
  143503. */
  143504. get input(): NodeMaterialConnectionPoint;
  143505. /**
  143506. * Gets the derivative output on x
  143507. */
  143508. get dx(): NodeMaterialConnectionPoint;
  143509. /**
  143510. * Gets the derivative output on y
  143511. */
  143512. get dy(): NodeMaterialConnectionPoint;
  143513. protected _buildBlock(state: NodeMaterialBuildState): this;
  143514. }
  143515. }
  143516. declare module BABYLON {
  143517. /**
  143518. * Block used to make gl_FragCoord available
  143519. */
  143520. export class FragCoordBlock extends NodeMaterialBlock {
  143521. /**
  143522. * Creates a new FragCoordBlock
  143523. * @param name defines the block name
  143524. */
  143525. constructor(name: string);
  143526. /**
  143527. * Gets the current class name
  143528. * @returns the class name
  143529. */
  143530. getClassName(): string;
  143531. /**
  143532. * Gets the xy component
  143533. */
  143534. get xy(): NodeMaterialConnectionPoint;
  143535. /**
  143536. * Gets the xyz component
  143537. */
  143538. get xyz(): NodeMaterialConnectionPoint;
  143539. /**
  143540. * Gets the xyzw component
  143541. */
  143542. get xyzw(): NodeMaterialConnectionPoint;
  143543. /**
  143544. * Gets the x component
  143545. */
  143546. get x(): NodeMaterialConnectionPoint;
  143547. /**
  143548. * Gets the y component
  143549. */
  143550. get y(): NodeMaterialConnectionPoint;
  143551. /**
  143552. * Gets the z component
  143553. */
  143554. get z(): NodeMaterialConnectionPoint;
  143555. /**
  143556. * Gets the w component
  143557. */
  143558. get output(): NodeMaterialConnectionPoint;
  143559. protected writeOutputs(state: NodeMaterialBuildState): string;
  143560. protected _buildBlock(state: NodeMaterialBuildState): this;
  143561. }
  143562. }
  143563. declare module BABYLON {
  143564. /**
  143565. * Block used to get the screen sizes
  143566. */
  143567. export class ScreenSizeBlock extends NodeMaterialBlock {
  143568. private _varName;
  143569. private _scene;
  143570. /**
  143571. * Creates a new ScreenSizeBlock
  143572. * @param name defines the block name
  143573. */
  143574. constructor(name: string);
  143575. /**
  143576. * Gets the current class name
  143577. * @returns the class name
  143578. */
  143579. getClassName(): string;
  143580. /**
  143581. * Gets the xy component
  143582. */
  143583. get xy(): NodeMaterialConnectionPoint;
  143584. /**
  143585. * Gets the x component
  143586. */
  143587. get x(): NodeMaterialConnectionPoint;
  143588. /**
  143589. * Gets the y component
  143590. */
  143591. get y(): NodeMaterialConnectionPoint;
  143592. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143593. protected writeOutputs(state: NodeMaterialBuildState, varName: string): string;
  143594. protected _buildBlock(state: NodeMaterialBuildState): this;
  143595. }
  143596. }
  143597. declare module BABYLON {
  143598. /**
  143599. * Block used to add support for scene fog
  143600. */
  143601. export class FogBlock extends NodeMaterialBlock {
  143602. private _fogDistanceName;
  143603. private _fogParameters;
  143604. /**
  143605. * Create a new FogBlock
  143606. * @param name defines the block name
  143607. */
  143608. constructor(name: string);
  143609. /**
  143610. * Gets the current class name
  143611. * @returns the class name
  143612. */
  143613. getClassName(): string;
  143614. /**
  143615. * Gets the world position input component
  143616. */
  143617. get worldPosition(): NodeMaterialConnectionPoint;
  143618. /**
  143619. * Gets the view input component
  143620. */
  143621. get view(): NodeMaterialConnectionPoint;
  143622. /**
  143623. * Gets the color input component
  143624. */
  143625. get input(): NodeMaterialConnectionPoint;
  143626. /**
  143627. * Gets the fog color input component
  143628. */
  143629. get fogColor(): NodeMaterialConnectionPoint;
  143630. /**
  143631. * Gets the output component
  143632. */
  143633. get output(): NodeMaterialConnectionPoint;
  143634. autoConfigure(material: NodeMaterial): void;
  143635. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143636. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143637. protected _buildBlock(state: NodeMaterialBuildState): this;
  143638. }
  143639. }
  143640. declare module BABYLON {
  143641. /**
  143642. * Block used to add light in the fragment shader
  143643. */
  143644. export class LightBlock extends NodeMaterialBlock {
  143645. private _lightId;
  143646. /**
  143647. * Gets or sets the light associated with this block
  143648. */
  143649. light: Nullable<Light>;
  143650. /**
  143651. * Create a new LightBlock
  143652. * @param name defines the block name
  143653. */
  143654. constructor(name: string);
  143655. /**
  143656. * Gets the current class name
  143657. * @returns the class name
  143658. */
  143659. getClassName(): string;
  143660. /**
  143661. * Gets the world position input component
  143662. */
  143663. get worldPosition(): NodeMaterialConnectionPoint;
  143664. /**
  143665. * Gets the world normal input component
  143666. */
  143667. get worldNormal(): NodeMaterialConnectionPoint;
  143668. /**
  143669. * Gets the camera (or eye) position component
  143670. */
  143671. get cameraPosition(): NodeMaterialConnectionPoint;
  143672. /**
  143673. * Gets the glossiness component
  143674. */
  143675. get glossiness(): NodeMaterialConnectionPoint;
  143676. /**
  143677. * Gets the glossinness power component
  143678. */
  143679. get glossPower(): NodeMaterialConnectionPoint;
  143680. /**
  143681. * Gets the diffuse color component
  143682. */
  143683. get diffuseColor(): NodeMaterialConnectionPoint;
  143684. /**
  143685. * Gets the specular color component
  143686. */
  143687. get specularColor(): NodeMaterialConnectionPoint;
  143688. /**
  143689. * Gets the diffuse output component
  143690. */
  143691. get diffuseOutput(): NodeMaterialConnectionPoint;
  143692. /**
  143693. * Gets the specular output component
  143694. */
  143695. get specularOutput(): NodeMaterialConnectionPoint;
  143696. /**
  143697. * Gets the shadow output component
  143698. */
  143699. get shadow(): NodeMaterialConnectionPoint;
  143700. autoConfigure(material: NodeMaterial): void;
  143701. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  143702. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  143703. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  143704. private _injectVertexCode;
  143705. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  143706. serialize(): any;
  143707. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143708. }
  143709. }
  143710. declare module BABYLON {
  143711. /**
  143712. * Block used to read a reflection texture from a sampler
  143713. */
  143714. export class ReflectionTextureBlock extends ReflectionTextureBaseBlock {
  143715. /**
  143716. * Create a new ReflectionTextureBlock
  143717. * @param name defines the block name
  143718. */
  143719. constructor(name: string);
  143720. /**
  143721. * Gets the current class name
  143722. * @returns the class name
  143723. */
  143724. getClassName(): string;
  143725. /**
  143726. * Gets the world position input component
  143727. */
  143728. get position(): NodeMaterialConnectionPoint;
  143729. /**
  143730. * Gets the world position input component
  143731. */
  143732. get worldPosition(): NodeMaterialConnectionPoint;
  143733. /**
  143734. * Gets the world normal input component
  143735. */
  143736. get worldNormal(): NodeMaterialConnectionPoint;
  143737. /**
  143738. * Gets the world input component
  143739. */
  143740. get world(): NodeMaterialConnectionPoint;
  143741. /**
  143742. * Gets the camera (or eye) position component
  143743. */
  143744. get cameraPosition(): NodeMaterialConnectionPoint;
  143745. /**
  143746. * Gets the view input component
  143747. */
  143748. get view(): NodeMaterialConnectionPoint;
  143749. /**
  143750. * Gets the rgb output component
  143751. */
  143752. get rgb(): NodeMaterialConnectionPoint;
  143753. /**
  143754. * Gets the rgba output component
  143755. */
  143756. get rgba(): NodeMaterialConnectionPoint;
  143757. /**
  143758. * Gets the r output component
  143759. */
  143760. get r(): NodeMaterialConnectionPoint;
  143761. /**
  143762. * Gets the g output component
  143763. */
  143764. get g(): NodeMaterialConnectionPoint;
  143765. /**
  143766. * Gets the b output component
  143767. */
  143768. get b(): NodeMaterialConnectionPoint;
  143769. /**
  143770. * Gets the a output component
  143771. */
  143772. get a(): NodeMaterialConnectionPoint;
  143773. autoConfigure(material: NodeMaterial): void;
  143774. protected _buildBlock(state: NodeMaterialBuildState): this;
  143775. }
  143776. }
  143777. declare module BABYLON {
  143778. /**
  143779. * Block used to add 2 vectors
  143780. */
  143781. export class AddBlock extends NodeMaterialBlock {
  143782. /**
  143783. * Creates a new AddBlock
  143784. * @param name defines the block name
  143785. */
  143786. constructor(name: string);
  143787. /**
  143788. * Gets the current class name
  143789. * @returns the class name
  143790. */
  143791. getClassName(): string;
  143792. /**
  143793. * Gets the left operand input component
  143794. */
  143795. get left(): NodeMaterialConnectionPoint;
  143796. /**
  143797. * Gets the right operand input component
  143798. */
  143799. get right(): NodeMaterialConnectionPoint;
  143800. /**
  143801. * Gets the output component
  143802. */
  143803. get output(): NodeMaterialConnectionPoint;
  143804. protected _buildBlock(state: NodeMaterialBuildState): this;
  143805. }
  143806. }
  143807. declare module BABYLON {
  143808. /**
  143809. * Block used to scale a vector by a float
  143810. */
  143811. export class ScaleBlock extends NodeMaterialBlock {
  143812. /**
  143813. * Creates a new ScaleBlock
  143814. * @param name defines the block name
  143815. */
  143816. constructor(name: string);
  143817. /**
  143818. * Gets the current class name
  143819. * @returns the class name
  143820. */
  143821. getClassName(): string;
  143822. /**
  143823. * Gets the input component
  143824. */
  143825. get input(): NodeMaterialConnectionPoint;
  143826. /**
  143827. * Gets the factor input component
  143828. */
  143829. get factor(): NodeMaterialConnectionPoint;
  143830. /**
  143831. * Gets the output component
  143832. */
  143833. get output(): NodeMaterialConnectionPoint;
  143834. protected _buildBlock(state: NodeMaterialBuildState): this;
  143835. }
  143836. }
  143837. declare module BABYLON {
  143838. /**
  143839. * Block used to clamp a float
  143840. */
  143841. export class ClampBlock extends NodeMaterialBlock {
  143842. /** Gets or sets the minimum range */
  143843. minimum: number;
  143844. /** Gets or sets the maximum range */
  143845. maximum: number;
  143846. /**
  143847. * Creates a new ClampBlock
  143848. * @param name defines the block name
  143849. */
  143850. constructor(name: string);
  143851. /**
  143852. * Gets the current class name
  143853. * @returns the class name
  143854. */
  143855. getClassName(): string;
  143856. /**
  143857. * Gets the value input component
  143858. */
  143859. get value(): NodeMaterialConnectionPoint;
  143860. /**
  143861. * Gets the output component
  143862. */
  143863. get output(): NodeMaterialConnectionPoint;
  143864. protected _buildBlock(state: NodeMaterialBuildState): this;
  143865. protected _dumpPropertiesCode(): string;
  143866. serialize(): any;
  143867. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  143868. }
  143869. }
  143870. declare module BABYLON {
  143871. /**
  143872. * Block used to apply a cross product between 2 vectors
  143873. */
  143874. export class CrossBlock extends NodeMaterialBlock {
  143875. /**
  143876. * Creates a new CrossBlock
  143877. * @param name defines the block name
  143878. */
  143879. constructor(name: string);
  143880. /**
  143881. * Gets the current class name
  143882. * @returns the class name
  143883. */
  143884. getClassName(): string;
  143885. /**
  143886. * Gets the left operand input component
  143887. */
  143888. get left(): NodeMaterialConnectionPoint;
  143889. /**
  143890. * Gets the right operand input component
  143891. */
  143892. get right(): NodeMaterialConnectionPoint;
  143893. /**
  143894. * Gets the output component
  143895. */
  143896. get output(): NodeMaterialConnectionPoint;
  143897. protected _buildBlock(state: NodeMaterialBuildState): this;
  143898. }
  143899. }
  143900. declare module BABYLON {
  143901. /**
  143902. * Block used to apply a dot product between 2 vectors
  143903. */
  143904. export class DotBlock extends NodeMaterialBlock {
  143905. /**
  143906. * Creates a new DotBlock
  143907. * @param name defines the block name
  143908. */
  143909. constructor(name: string);
  143910. /**
  143911. * Gets the current class name
  143912. * @returns the class name
  143913. */
  143914. getClassName(): string;
  143915. /**
  143916. * Gets the left operand input component
  143917. */
  143918. get left(): NodeMaterialConnectionPoint;
  143919. /**
  143920. * Gets the right operand input component
  143921. */
  143922. get right(): NodeMaterialConnectionPoint;
  143923. /**
  143924. * Gets the output component
  143925. */
  143926. get output(): NodeMaterialConnectionPoint;
  143927. protected _buildBlock(state: NodeMaterialBuildState): this;
  143928. }
  143929. }
  143930. declare module BABYLON {
  143931. /**
  143932. * Block used to normalize a vector
  143933. */
  143934. export class NormalizeBlock extends NodeMaterialBlock {
  143935. /**
  143936. * Creates a new NormalizeBlock
  143937. * @param name defines the block name
  143938. */
  143939. constructor(name: string);
  143940. /**
  143941. * Gets the current class name
  143942. * @returns the class name
  143943. */
  143944. getClassName(): string;
  143945. /**
  143946. * Gets the input component
  143947. */
  143948. get input(): NodeMaterialConnectionPoint;
  143949. /**
  143950. * Gets the output component
  143951. */
  143952. get output(): NodeMaterialConnectionPoint;
  143953. protected _buildBlock(state: NodeMaterialBuildState): this;
  143954. }
  143955. }
  143956. declare module BABYLON {
  143957. /**
  143958. * Block used to create a Color3/4 out of individual inputs (one for each component)
  143959. */
  143960. export class ColorMergerBlock extends NodeMaterialBlock {
  143961. /**
  143962. * Create a new ColorMergerBlock
  143963. * @param name defines the block name
  143964. */
  143965. constructor(name: string);
  143966. /**
  143967. * Gets the current class name
  143968. * @returns the class name
  143969. */
  143970. getClassName(): string;
  143971. /**
  143972. * Gets the rgb component (input)
  143973. */
  143974. get rgbIn(): NodeMaterialConnectionPoint;
  143975. /**
  143976. * Gets the r component (input)
  143977. */
  143978. get r(): NodeMaterialConnectionPoint;
  143979. /**
  143980. * Gets the g component (input)
  143981. */
  143982. get g(): NodeMaterialConnectionPoint;
  143983. /**
  143984. * Gets the b component (input)
  143985. */
  143986. get b(): NodeMaterialConnectionPoint;
  143987. /**
  143988. * Gets the a component (input)
  143989. */
  143990. get a(): NodeMaterialConnectionPoint;
  143991. /**
  143992. * Gets the rgba component (output)
  143993. */
  143994. get rgba(): NodeMaterialConnectionPoint;
  143995. /**
  143996. * Gets the rgb component (output)
  143997. */
  143998. get rgbOut(): NodeMaterialConnectionPoint;
  143999. /**
  144000. * Gets the rgb component (output)
  144001. * @deprecated Please use rgbOut instead.
  144002. */
  144003. get rgb(): NodeMaterialConnectionPoint;
  144004. protected _buildBlock(state: NodeMaterialBuildState): this;
  144005. }
  144006. }
  144007. declare module BABYLON {
  144008. /**
  144009. * Block used to expand a Vector3/4 into 4 outputs (one for each component)
  144010. */
  144011. export class VectorSplitterBlock extends NodeMaterialBlock {
  144012. /**
  144013. * Create a new VectorSplitterBlock
  144014. * @param name defines the block name
  144015. */
  144016. constructor(name: string);
  144017. /**
  144018. * Gets the current class name
  144019. * @returns the class name
  144020. */
  144021. getClassName(): string;
  144022. /**
  144023. * Gets the xyzw component (input)
  144024. */
  144025. get xyzw(): NodeMaterialConnectionPoint;
  144026. /**
  144027. * Gets the xyz component (input)
  144028. */
  144029. get xyzIn(): NodeMaterialConnectionPoint;
  144030. /**
  144031. * Gets the xy component (input)
  144032. */
  144033. get xyIn(): NodeMaterialConnectionPoint;
  144034. /**
  144035. * Gets the xyz component (output)
  144036. */
  144037. get xyzOut(): NodeMaterialConnectionPoint;
  144038. /**
  144039. * Gets the xy component (output)
  144040. */
  144041. get xyOut(): NodeMaterialConnectionPoint;
  144042. /**
  144043. * Gets the x component (output)
  144044. */
  144045. get x(): NodeMaterialConnectionPoint;
  144046. /**
  144047. * Gets the y component (output)
  144048. */
  144049. get y(): NodeMaterialConnectionPoint;
  144050. /**
  144051. * Gets the z component (output)
  144052. */
  144053. get z(): NodeMaterialConnectionPoint;
  144054. /**
  144055. * Gets the w component (output)
  144056. */
  144057. get w(): NodeMaterialConnectionPoint;
  144058. protected _inputRename(name: string): string;
  144059. protected _outputRename(name: string): string;
  144060. protected _buildBlock(state: NodeMaterialBuildState): this;
  144061. }
  144062. }
  144063. declare module BABYLON {
  144064. /**
  144065. * Block used to lerp between 2 values
  144066. */
  144067. export class LerpBlock extends NodeMaterialBlock {
  144068. /**
  144069. * Creates a new LerpBlock
  144070. * @param name defines the block name
  144071. */
  144072. constructor(name: string);
  144073. /**
  144074. * Gets the current class name
  144075. * @returns the class name
  144076. */
  144077. getClassName(): string;
  144078. /**
  144079. * Gets the left operand input component
  144080. */
  144081. get left(): NodeMaterialConnectionPoint;
  144082. /**
  144083. * Gets the right operand input component
  144084. */
  144085. get right(): NodeMaterialConnectionPoint;
  144086. /**
  144087. * Gets the gradient operand input component
  144088. */
  144089. get gradient(): NodeMaterialConnectionPoint;
  144090. /**
  144091. * Gets the output component
  144092. */
  144093. get output(): NodeMaterialConnectionPoint;
  144094. protected _buildBlock(state: NodeMaterialBuildState): this;
  144095. }
  144096. }
  144097. declare module BABYLON {
  144098. /**
  144099. * Block used to divide 2 vectors
  144100. */
  144101. export class DivideBlock extends NodeMaterialBlock {
  144102. /**
  144103. * Creates a new DivideBlock
  144104. * @param name defines the block name
  144105. */
  144106. constructor(name: string);
  144107. /**
  144108. * Gets the current class name
  144109. * @returns the class name
  144110. */
  144111. getClassName(): string;
  144112. /**
  144113. * Gets the left operand input component
  144114. */
  144115. get left(): NodeMaterialConnectionPoint;
  144116. /**
  144117. * Gets the right operand input component
  144118. */
  144119. get right(): NodeMaterialConnectionPoint;
  144120. /**
  144121. * Gets the output component
  144122. */
  144123. get output(): NodeMaterialConnectionPoint;
  144124. protected _buildBlock(state: NodeMaterialBuildState): this;
  144125. }
  144126. }
  144127. declare module BABYLON {
  144128. /**
  144129. * Block used to subtract 2 vectors
  144130. */
  144131. export class SubtractBlock extends NodeMaterialBlock {
  144132. /**
  144133. * Creates a new SubtractBlock
  144134. * @param name defines the block name
  144135. */
  144136. constructor(name: string);
  144137. /**
  144138. * Gets the current class name
  144139. * @returns the class name
  144140. */
  144141. getClassName(): string;
  144142. /**
  144143. * Gets the left operand input component
  144144. */
  144145. get left(): NodeMaterialConnectionPoint;
  144146. /**
  144147. * Gets the right operand input component
  144148. */
  144149. get right(): NodeMaterialConnectionPoint;
  144150. /**
  144151. * Gets the output component
  144152. */
  144153. get output(): NodeMaterialConnectionPoint;
  144154. protected _buildBlock(state: NodeMaterialBuildState): this;
  144155. }
  144156. }
  144157. declare module BABYLON {
  144158. /**
  144159. * Block used to step a value
  144160. */
  144161. export class StepBlock extends NodeMaterialBlock {
  144162. /**
  144163. * Creates a new StepBlock
  144164. * @param name defines the block name
  144165. */
  144166. constructor(name: string);
  144167. /**
  144168. * Gets the current class name
  144169. * @returns the class name
  144170. */
  144171. getClassName(): string;
  144172. /**
  144173. * Gets the value operand input component
  144174. */
  144175. get value(): NodeMaterialConnectionPoint;
  144176. /**
  144177. * Gets the edge operand input component
  144178. */
  144179. get edge(): NodeMaterialConnectionPoint;
  144180. /**
  144181. * Gets the output component
  144182. */
  144183. get output(): NodeMaterialConnectionPoint;
  144184. protected _buildBlock(state: NodeMaterialBuildState): this;
  144185. }
  144186. }
  144187. declare module BABYLON {
  144188. /**
  144189. * Block used to get the opposite (1 - x) of a value
  144190. */
  144191. export class OneMinusBlock extends NodeMaterialBlock {
  144192. /**
  144193. * Creates a new OneMinusBlock
  144194. * @param name defines the block name
  144195. */
  144196. constructor(name: string);
  144197. /**
  144198. * Gets the current class name
  144199. * @returns the class name
  144200. */
  144201. getClassName(): string;
  144202. /**
  144203. * Gets the input component
  144204. */
  144205. get input(): NodeMaterialConnectionPoint;
  144206. /**
  144207. * Gets the output component
  144208. */
  144209. get output(): NodeMaterialConnectionPoint;
  144210. protected _buildBlock(state: NodeMaterialBuildState): this;
  144211. }
  144212. }
  144213. declare module BABYLON {
  144214. /**
  144215. * Block used to get the view direction
  144216. */
  144217. export class ViewDirectionBlock extends NodeMaterialBlock {
  144218. /**
  144219. * Creates a new ViewDirectionBlock
  144220. * @param name defines the block name
  144221. */
  144222. constructor(name: string);
  144223. /**
  144224. * Gets the current class name
  144225. * @returns the class name
  144226. */
  144227. getClassName(): string;
  144228. /**
  144229. * Gets the world position component
  144230. */
  144231. get worldPosition(): NodeMaterialConnectionPoint;
  144232. /**
  144233. * Gets the camera position component
  144234. */
  144235. get cameraPosition(): NodeMaterialConnectionPoint;
  144236. /**
  144237. * Gets the output component
  144238. */
  144239. get output(): NodeMaterialConnectionPoint;
  144240. autoConfigure(material: NodeMaterial): void;
  144241. protected _buildBlock(state: NodeMaterialBuildState): this;
  144242. }
  144243. }
  144244. declare module BABYLON {
  144245. /**
  144246. * Block used to compute fresnel value
  144247. */
  144248. export class FresnelBlock extends NodeMaterialBlock {
  144249. /**
  144250. * Create a new FresnelBlock
  144251. * @param name defines the block name
  144252. */
  144253. constructor(name: string);
  144254. /**
  144255. * Gets the current class name
  144256. * @returns the class name
  144257. */
  144258. getClassName(): string;
  144259. /**
  144260. * Gets the world normal input component
  144261. */
  144262. get worldNormal(): NodeMaterialConnectionPoint;
  144263. /**
  144264. * Gets the view direction input component
  144265. */
  144266. get viewDirection(): NodeMaterialConnectionPoint;
  144267. /**
  144268. * Gets the bias input component
  144269. */
  144270. get bias(): NodeMaterialConnectionPoint;
  144271. /**
  144272. * Gets the camera (or eye) position component
  144273. */
  144274. get power(): NodeMaterialConnectionPoint;
  144275. /**
  144276. * Gets the fresnel output component
  144277. */
  144278. get fresnel(): NodeMaterialConnectionPoint;
  144279. autoConfigure(material: NodeMaterial): void;
  144280. protected _buildBlock(state: NodeMaterialBuildState): this;
  144281. }
  144282. }
  144283. declare module BABYLON {
  144284. /**
  144285. * Block used to get the max of 2 values
  144286. */
  144287. export class MaxBlock extends NodeMaterialBlock {
  144288. /**
  144289. * Creates a new MaxBlock
  144290. * @param name defines the block name
  144291. */
  144292. constructor(name: string);
  144293. /**
  144294. * Gets the current class name
  144295. * @returns the class name
  144296. */
  144297. getClassName(): string;
  144298. /**
  144299. * Gets the left operand input component
  144300. */
  144301. get left(): NodeMaterialConnectionPoint;
  144302. /**
  144303. * Gets the right operand input component
  144304. */
  144305. get right(): NodeMaterialConnectionPoint;
  144306. /**
  144307. * Gets the output component
  144308. */
  144309. get output(): NodeMaterialConnectionPoint;
  144310. protected _buildBlock(state: NodeMaterialBuildState): this;
  144311. }
  144312. }
  144313. declare module BABYLON {
  144314. /**
  144315. * Block used to get the min of 2 values
  144316. */
  144317. export class MinBlock extends NodeMaterialBlock {
  144318. /**
  144319. * Creates a new MinBlock
  144320. * @param name defines the block name
  144321. */
  144322. constructor(name: string);
  144323. /**
  144324. * Gets the current class name
  144325. * @returns the class name
  144326. */
  144327. getClassName(): string;
  144328. /**
  144329. * Gets the left operand input component
  144330. */
  144331. get left(): NodeMaterialConnectionPoint;
  144332. /**
  144333. * Gets the right operand input component
  144334. */
  144335. get right(): NodeMaterialConnectionPoint;
  144336. /**
  144337. * Gets the output component
  144338. */
  144339. get output(): NodeMaterialConnectionPoint;
  144340. protected _buildBlock(state: NodeMaterialBuildState): this;
  144341. }
  144342. }
  144343. declare module BABYLON {
  144344. /**
  144345. * Block used to get the distance between 2 values
  144346. */
  144347. export class DistanceBlock extends NodeMaterialBlock {
  144348. /**
  144349. * Creates a new DistanceBlock
  144350. * @param name defines the block name
  144351. */
  144352. constructor(name: string);
  144353. /**
  144354. * Gets the current class name
  144355. * @returns the class name
  144356. */
  144357. getClassName(): string;
  144358. /**
  144359. * Gets the left operand input component
  144360. */
  144361. get left(): NodeMaterialConnectionPoint;
  144362. /**
  144363. * Gets the right operand input component
  144364. */
  144365. get right(): NodeMaterialConnectionPoint;
  144366. /**
  144367. * Gets the output component
  144368. */
  144369. get output(): NodeMaterialConnectionPoint;
  144370. protected _buildBlock(state: NodeMaterialBuildState): this;
  144371. }
  144372. }
  144373. declare module BABYLON {
  144374. /**
  144375. * Block used to get the length of a vector
  144376. */
  144377. export class LengthBlock extends NodeMaterialBlock {
  144378. /**
  144379. * Creates a new LengthBlock
  144380. * @param name defines the block name
  144381. */
  144382. constructor(name: string);
  144383. /**
  144384. * Gets the current class name
  144385. * @returns the class name
  144386. */
  144387. getClassName(): string;
  144388. /**
  144389. * Gets the value input component
  144390. */
  144391. get value(): NodeMaterialConnectionPoint;
  144392. /**
  144393. * Gets the output component
  144394. */
  144395. get output(): NodeMaterialConnectionPoint;
  144396. protected _buildBlock(state: NodeMaterialBuildState): this;
  144397. }
  144398. }
  144399. declare module BABYLON {
  144400. /**
  144401. * Block used to get negative version of a value (i.e. x * -1)
  144402. */
  144403. export class NegateBlock extends NodeMaterialBlock {
  144404. /**
  144405. * Creates a new NegateBlock
  144406. * @param name defines the block name
  144407. */
  144408. constructor(name: string);
  144409. /**
  144410. * Gets the current class name
  144411. * @returns the class name
  144412. */
  144413. getClassName(): string;
  144414. /**
  144415. * Gets the value input component
  144416. */
  144417. get value(): NodeMaterialConnectionPoint;
  144418. /**
  144419. * Gets the output component
  144420. */
  144421. get output(): NodeMaterialConnectionPoint;
  144422. protected _buildBlock(state: NodeMaterialBuildState): this;
  144423. }
  144424. }
  144425. declare module BABYLON {
  144426. /**
  144427. * Block used to get the value of the first parameter raised to the power of the second
  144428. */
  144429. export class PowBlock extends NodeMaterialBlock {
  144430. /**
  144431. * Creates a new PowBlock
  144432. * @param name defines the block name
  144433. */
  144434. constructor(name: string);
  144435. /**
  144436. * Gets the current class name
  144437. * @returns the class name
  144438. */
  144439. getClassName(): string;
  144440. /**
  144441. * Gets the value operand input component
  144442. */
  144443. get value(): NodeMaterialConnectionPoint;
  144444. /**
  144445. * Gets the power operand input component
  144446. */
  144447. get power(): NodeMaterialConnectionPoint;
  144448. /**
  144449. * Gets the output component
  144450. */
  144451. get output(): NodeMaterialConnectionPoint;
  144452. protected _buildBlock(state: NodeMaterialBuildState): this;
  144453. }
  144454. }
  144455. declare module BABYLON {
  144456. /**
  144457. * Block used to get a random number
  144458. */
  144459. export class RandomNumberBlock extends NodeMaterialBlock {
  144460. /**
  144461. * Creates a new RandomNumberBlock
  144462. * @param name defines the block name
  144463. */
  144464. constructor(name: string);
  144465. /**
  144466. * Gets the current class name
  144467. * @returns the class name
  144468. */
  144469. getClassName(): string;
  144470. /**
  144471. * Gets the seed input component
  144472. */
  144473. get seed(): NodeMaterialConnectionPoint;
  144474. /**
  144475. * Gets the output component
  144476. */
  144477. get output(): NodeMaterialConnectionPoint;
  144478. protected _buildBlock(state: NodeMaterialBuildState): this;
  144479. }
  144480. }
  144481. declare module BABYLON {
  144482. /**
  144483. * Block used to compute arc tangent of 2 values
  144484. */
  144485. export class ArcTan2Block extends NodeMaterialBlock {
  144486. /**
  144487. * Creates a new ArcTan2Block
  144488. * @param name defines the block name
  144489. */
  144490. constructor(name: string);
  144491. /**
  144492. * Gets the current class name
  144493. * @returns the class name
  144494. */
  144495. getClassName(): string;
  144496. /**
  144497. * Gets the x operand input component
  144498. */
  144499. get x(): NodeMaterialConnectionPoint;
  144500. /**
  144501. * Gets the y operand input component
  144502. */
  144503. get y(): NodeMaterialConnectionPoint;
  144504. /**
  144505. * Gets the output component
  144506. */
  144507. get output(): NodeMaterialConnectionPoint;
  144508. protected _buildBlock(state: NodeMaterialBuildState): this;
  144509. }
  144510. }
  144511. declare module BABYLON {
  144512. /**
  144513. * Block used to smooth step a value
  144514. */
  144515. export class SmoothStepBlock extends NodeMaterialBlock {
  144516. /**
  144517. * Creates a new SmoothStepBlock
  144518. * @param name defines the block name
  144519. */
  144520. constructor(name: string);
  144521. /**
  144522. * Gets the current class name
  144523. * @returns the class name
  144524. */
  144525. getClassName(): string;
  144526. /**
  144527. * Gets the value operand input component
  144528. */
  144529. get value(): NodeMaterialConnectionPoint;
  144530. /**
  144531. * Gets the first edge operand input component
  144532. */
  144533. get edge0(): NodeMaterialConnectionPoint;
  144534. /**
  144535. * Gets the second edge operand input component
  144536. */
  144537. get edge1(): NodeMaterialConnectionPoint;
  144538. /**
  144539. * Gets the output component
  144540. */
  144541. get output(): NodeMaterialConnectionPoint;
  144542. protected _buildBlock(state: NodeMaterialBuildState): this;
  144543. }
  144544. }
  144545. declare module BABYLON {
  144546. /**
  144547. * Block used to get the reciprocal (1 / x) of a value
  144548. */
  144549. export class ReciprocalBlock extends NodeMaterialBlock {
  144550. /**
  144551. * Creates a new ReciprocalBlock
  144552. * @param name defines the block name
  144553. */
  144554. constructor(name: string);
  144555. /**
  144556. * Gets the current class name
  144557. * @returns the class name
  144558. */
  144559. getClassName(): string;
  144560. /**
  144561. * Gets the input component
  144562. */
  144563. get input(): NodeMaterialConnectionPoint;
  144564. /**
  144565. * Gets the output component
  144566. */
  144567. get output(): NodeMaterialConnectionPoint;
  144568. protected _buildBlock(state: NodeMaterialBuildState): this;
  144569. }
  144570. }
  144571. declare module BABYLON {
  144572. /**
  144573. * Block used to replace a color by another one
  144574. */
  144575. export class ReplaceColorBlock extends NodeMaterialBlock {
  144576. /**
  144577. * Creates a new ReplaceColorBlock
  144578. * @param name defines the block name
  144579. */
  144580. constructor(name: string);
  144581. /**
  144582. * Gets the current class name
  144583. * @returns the class name
  144584. */
  144585. getClassName(): string;
  144586. /**
  144587. * Gets the value input component
  144588. */
  144589. get value(): NodeMaterialConnectionPoint;
  144590. /**
  144591. * Gets the reference input component
  144592. */
  144593. get reference(): NodeMaterialConnectionPoint;
  144594. /**
  144595. * Gets the distance input component
  144596. */
  144597. get distance(): NodeMaterialConnectionPoint;
  144598. /**
  144599. * Gets the replacement input component
  144600. */
  144601. get replacement(): NodeMaterialConnectionPoint;
  144602. /**
  144603. * Gets the output component
  144604. */
  144605. get output(): NodeMaterialConnectionPoint;
  144606. protected _buildBlock(state: NodeMaterialBuildState): this;
  144607. }
  144608. }
  144609. declare module BABYLON {
  144610. /**
  144611. * Block used to posterize a value
  144612. * @see https://en.wikipedia.org/wiki/Posterization
  144613. */
  144614. export class PosterizeBlock extends NodeMaterialBlock {
  144615. /**
  144616. * Creates a new PosterizeBlock
  144617. * @param name defines the block name
  144618. */
  144619. constructor(name: string);
  144620. /**
  144621. * Gets the current class name
  144622. * @returns the class name
  144623. */
  144624. getClassName(): string;
  144625. /**
  144626. * Gets the value input component
  144627. */
  144628. get value(): NodeMaterialConnectionPoint;
  144629. /**
  144630. * Gets the steps input component
  144631. */
  144632. get steps(): NodeMaterialConnectionPoint;
  144633. /**
  144634. * Gets the output component
  144635. */
  144636. get output(): NodeMaterialConnectionPoint;
  144637. protected _buildBlock(state: NodeMaterialBuildState): this;
  144638. }
  144639. }
  144640. declare module BABYLON {
  144641. /**
  144642. * Operations supported by the Wave block
  144643. */
  144644. export enum WaveBlockKind {
  144645. /** SawTooth */
  144646. SawTooth = 0,
  144647. /** Square */
  144648. Square = 1,
  144649. /** Triangle */
  144650. Triangle = 2
  144651. }
  144652. /**
  144653. * Block used to apply wave operation to floats
  144654. */
  144655. export class WaveBlock extends NodeMaterialBlock {
  144656. /**
  144657. * Gets or sets the kibnd of wave to be applied by the block
  144658. */
  144659. kind: WaveBlockKind;
  144660. /**
  144661. * Creates a new WaveBlock
  144662. * @param name defines the block name
  144663. */
  144664. constructor(name: string);
  144665. /**
  144666. * Gets the current class name
  144667. * @returns the class name
  144668. */
  144669. getClassName(): string;
  144670. /**
  144671. * Gets the input component
  144672. */
  144673. get input(): NodeMaterialConnectionPoint;
  144674. /**
  144675. * Gets the output component
  144676. */
  144677. get output(): NodeMaterialConnectionPoint;
  144678. protected _buildBlock(state: NodeMaterialBuildState): this;
  144679. serialize(): any;
  144680. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144681. }
  144682. }
  144683. declare module BABYLON {
  144684. /**
  144685. * Class used to store a color step for the GradientBlock
  144686. */
  144687. export class GradientBlockColorStep {
  144688. private _step;
  144689. /**
  144690. * Gets value indicating which step this color is associated with (between 0 and 1)
  144691. */
  144692. get step(): number;
  144693. /**
  144694. * Sets a value indicating which step this color is associated with (between 0 and 1)
  144695. */
  144696. set step(val: number);
  144697. private _color;
  144698. /**
  144699. * Gets the color associated with this step
  144700. */
  144701. get color(): Color3;
  144702. /**
  144703. * Sets the color associated with this step
  144704. */
  144705. set color(val: Color3);
  144706. /**
  144707. * Creates a new GradientBlockColorStep
  144708. * @param step defines a value indicating which step this color is associated with (between 0 and 1)
  144709. * @param color defines the color associated with this step
  144710. */
  144711. constructor(step: number, color: Color3);
  144712. }
  144713. /**
  144714. * Block used to return a color from a gradient based on an input value between 0 and 1
  144715. */
  144716. export class GradientBlock extends NodeMaterialBlock {
  144717. /**
  144718. * Gets or sets the list of color steps
  144719. */
  144720. colorSteps: GradientBlockColorStep[];
  144721. /** Gets an observable raised when the value is changed */
  144722. onValueChangedObservable: Observable<GradientBlock>;
  144723. /** calls observable when the value is changed*/
  144724. colorStepsUpdated(): void;
  144725. /**
  144726. * Creates a new GradientBlock
  144727. * @param name defines the block name
  144728. */
  144729. constructor(name: string);
  144730. /**
  144731. * Gets the current class name
  144732. * @returns the class name
  144733. */
  144734. getClassName(): string;
  144735. /**
  144736. * Gets the gradient input component
  144737. */
  144738. get gradient(): NodeMaterialConnectionPoint;
  144739. /**
  144740. * Gets the output component
  144741. */
  144742. get output(): NodeMaterialConnectionPoint;
  144743. private _writeColorConstant;
  144744. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144745. serialize(): any;
  144746. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144747. protected _dumpPropertiesCode(): string;
  144748. }
  144749. }
  144750. declare module BABYLON {
  144751. /**
  144752. * Block used to normalize lerp between 2 values
  144753. */
  144754. export class NLerpBlock extends NodeMaterialBlock {
  144755. /**
  144756. * Creates a new NLerpBlock
  144757. * @param name defines the block name
  144758. */
  144759. constructor(name: string);
  144760. /**
  144761. * Gets the current class name
  144762. * @returns the class name
  144763. */
  144764. getClassName(): string;
  144765. /**
  144766. * Gets the left operand input component
  144767. */
  144768. get left(): NodeMaterialConnectionPoint;
  144769. /**
  144770. * Gets the right operand input component
  144771. */
  144772. get right(): NodeMaterialConnectionPoint;
  144773. /**
  144774. * Gets the gradient operand input component
  144775. */
  144776. get gradient(): NodeMaterialConnectionPoint;
  144777. /**
  144778. * Gets the output component
  144779. */
  144780. get output(): NodeMaterialConnectionPoint;
  144781. protected _buildBlock(state: NodeMaterialBuildState): this;
  144782. }
  144783. }
  144784. declare module BABYLON {
  144785. /**
  144786. * block used to Generate a Worley Noise 3D Noise Pattern
  144787. */
  144788. export class WorleyNoise3DBlock extends NodeMaterialBlock {
  144789. /** Gets or sets a boolean indicating that normal should be inverted on X axis */
  144790. manhattanDistance: boolean;
  144791. /**
  144792. * Creates a new WorleyNoise3DBlock
  144793. * @param name defines the block name
  144794. */
  144795. constructor(name: string);
  144796. /**
  144797. * Gets the current class name
  144798. * @returns the class name
  144799. */
  144800. getClassName(): string;
  144801. /**
  144802. * Gets the seed input component
  144803. */
  144804. get seed(): NodeMaterialConnectionPoint;
  144805. /**
  144806. * Gets the jitter input component
  144807. */
  144808. get jitter(): NodeMaterialConnectionPoint;
  144809. /**
  144810. * Gets the output component
  144811. */
  144812. get output(): NodeMaterialConnectionPoint;
  144813. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144814. /**
  144815. * Exposes the properties to the UI?
  144816. */
  144817. protected _dumpPropertiesCode(): string;
  144818. /**
  144819. * Exposes the properties to the Seralize?
  144820. */
  144821. serialize(): any;
  144822. /**
  144823. * Exposes the properties to the deseralize?
  144824. */
  144825. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  144826. }
  144827. }
  144828. declare module BABYLON {
  144829. /**
  144830. * block used to Generate a Simplex Perlin 3d Noise Pattern
  144831. */
  144832. export class SimplexPerlin3DBlock extends NodeMaterialBlock {
  144833. /**
  144834. * Creates a new SimplexPerlin3DBlock
  144835. * @param name defines the block name
  144836. */
  144837. constructor(name: string);
  144838. /**
  144839. * Gets the current class name
  144840. * @returns the class name
  144841. */
  144842. getClassName(): string;
  144843. /**
  144844. * Gets the seed operand input component
  144845. */
  144846. get seed(): NodeMaterialConnectionPoint;
  144847. /**
  144848. * Gets the output component
  144849. */
  144850. get output(): NodeMaterialConnectionPoint;
  144851. protected _buildBlock(state: NodeMaterialBuildState): this | undefined;
  144852. }
  144853. }
  144854. declare module BABYLON {
  144855. /**
  144856. * Block used to blend normals
  144857. */
  144858. export class NormalBlendBlock extends NodeMaterialBlock {
  144859. /**
  144860. * Creates a new NormalBlendBlock
  144861. * @param name defines the block name
  144862. */
  144863. constructor(name: string);
  144864. /**
  144865. * Gets the current class name
  144866. * @returns the class name
  144867. */
  144868. getClassName(): string;
  144869. /**
  144870. * Gets the first input component
  144871. */
  144872. get normalMap0(): NodeMaterialConnectionPoint;
  144873. /**
  144874. * Gets the second input component
  144875. */
  144876. get normalMap1(): NodeMaterialConnectionPoint;
  144877. /**
  144878. * Gets the output component
  144879. */
  144880. get output(): NodeMaterialConnectionPoint;
  144881. protected _buildBlock(state: NodeMaterialBuildState): this;
  144882. }
  144883. }
  144884. declare module BABYLON {
  144885. /**
  144886. * Block used to rotate a 2d vector by a given angle
  144887. */
  144888. export class Rotate2dBlock extends NodeMaterialBlock {
  144889. /**
  144890. * Creates a new Rotate2dBlock
  144891. * @param name defines the block name
  144892. */
  144893. constructor(name: string);
  144894. /**
  144895. * Gets the current class name
  144896. * @returns the class name
  144897. */
  144898. getClassName(): string;
  144899. /**
  144900. * Gets the input vector
  144901. */
  144902. get input(): NodeMaterialConnectionPoint;
  144903. /**
  144904. * Gets the input angle
  144905. */
  144906. get angle(): NodeMaterialConnectionPoint;
  144907. /**
  144908. * Gets the output component
  144909. */
  144910. get output(): NodeMaterialConnectionPoint;
  144911. autoConfigure(material: NodeMaterial): void;
  144912. protected _buildBlock(state: NodeMaterialBuildState): this;
  144913. }
  144914. }
  144915. declare module BABYLON {
  144916. /**
  144917. * Block used to get the reflected vector from a direction and a normal
  144918. */
  144919. export class ReflectBlock extends NodeMaterialBlock {
  144920. /**
  144921. * Creates a new ReflectBlock
  144922. * @param name defines the block name
  144923. */
  144924. constructor(name: string);
  144925. /**
  144926. * Gets the current class name
  144927. * @returns the class name
  144928. */
  144929. getClassName(): string;
  144930. /**
  144931. * Gets the incident component
  144932. */
  144933. get incident(): NodeMaterialConnectionPoint;
  144934. /**
  144935. * Gets the normal component
  144936. */
  144937. get normal(): NodeMaterialConnectionPoint;
  144938. /**
  144939. * Gets the output component
  144940. */
  144941. get output(): NodeMaterialConnectionPoint;
  144942. protected _buildBlock(state: NodeMaterialBuildState): this;
  144943. }
  144944. }
  144945. declare module BABYLON {
  144946. /**
  144947. * Block used to get the refracted vector from a direction and a normal
  144948. */
  144949. export class RefractBlock extends NodeMaterialBlock {
  144950. /**
  144951. * Creates a new RefractBlock
  144952. * @param name defines the block name
  144953. */
  144954. constructor(name: string);
  144955. /**
  144956. * Gets the current class name
  144957. * @returns the class name
  144958. */
  144959. getClassName(): string;
  144960. /**
  144961. * Gets the incident component
  144962. */
  144963. get incident(): NodeMaterialConnectionPoint;
  144964. /**
  144965. * Gets the normal component
  144966. */
  144967. get normal(): NodeMaterialConnectionPoint;
  144968. /**
  144969. * Gets the index of refraction component
  144970. */
  144971. get ior(): NodeMaterialConnectionPoint;
  144972. /**
  144973. * Gets the output component
  144974. */
  144975. get output(): NodeMaterialConnectionPoint;
  144976. protected _buildBlock(state: NodeMaterialBuildState): this;
  144977. }
  144978. }
  144979. declare module BABYLON {
  144980. /**
  144981. * Block used to desaturate a color
  144982. */
  144983. export class DesaturateBlock extends NodeMaterialBlock {
  144984. /**
  144985. * Creates a new DesaturateBlock
  144986. * @param name defines the block name
  144987. */
  144988. constructor(name: string);
  144989. /**
  144990. * Gets the current class name
  144991. * @returns the class name
  144992. */
  144993. getClassName(): string;
  144994. /**
  144995. * Gets the color operand input component
  144996. */
  144997. get color(): NodeMaterialConnectionPoint;
  144998. /**
  144999. * Gets the level operand input component
  145000. */
  145001. get level(): NodeMaterialConnectionPoint;
  145002. /**
  145003. * Gets the output component
  145004. */
  145005. get output(): NodeMaterialConnectionPoint;
  145006. protected _buildBlock(state: NodeMaterialBuildState): this;
  145007. }
  145008. }
  145009. declare module BABYLON {
  145010. /**
  145011. * Block used to implement the ambient occlusion module of the PBR material
  145012. */
  145013. export class AmbientOcclusionBlock extends NodeMaterialBlock {
  145014. /**
  145015. * Create a new AmbientOcclusionBlock
  145016. * @param name defines the block name
  145017. */
  145018. constructor(name: string);
  145019. /**
  145020. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  145021. */
  145022. useAmbientInGrayScale: boolean;
  145023. /**
  145024. * Initialize the block and prepare the context for build
  145025. * @param state defines the state that will be used for the build
  145026. */
  145027. initialize(state: NodeMaterialBuildState): void;
  145028. /**
  145029. * Gets the current class name
  145030. * @returns the class name
  145031. */
  145032. getClassName(): string;
  145033. /**
  145034. * Gets the texture input component
  145035. */
  145036. get texture(): NodeMaterialConnectionPoint;
  145037. /**
  145038. * Gets the texture intensity component
  145039. */
  145040. get intensity(): NodeMaterialConnectionPoint;
  145041. /**
  145042. * Gets the direct light intensity input component
  145043. */
  145044. get directLightIntensity(): NodeMaterialConnectionPoint;
  145045. /**
  145046. * Gets the ambient occlusion object output component
  145047. */
  145048. get ambientOcc(): NodeMaterialConnectionPoint;
  145049. /**
  145050. * Gets the main code of the block (fragment side)
  145051. * @param block instance of an AmbientOcclusionBlock or null if the code must be generated without an active ambient occlusion module
  145052. * @returns the shader code
  145053. */
  145054. static GetCode(block: Nullable<AmbientOcclusionBlock>): string;
  145055. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145056. protected _buildBlock(state: NodeMaterialBuildState): this;
  145057. protected _dumpPropertiesCode(): string;
  145058. serialize(): any;
  145059. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145060. }
  145061. }
  145062. declare module BABYLON {
  145063. /**
  145064. * Block used to implement the reflection module of the PBR material
  145065. */
  145066. export class ReflectionBlock extends ReflectionTextureBaseBlock {
  145067. /** @hidden */
  145068. _defineLODReflectionAlpha: string;
  145069. /** @hidden */
  145070. _defineLinearSpecularReflection: string;
  145071. private _vEnvironmentIrradianceName;
  145072. /** @hidden */
  145073. _vReflectionMicrosurfaceInfosName: string;
  145074. /** @hidden */
  145075. _vReflectionInfosName: string;
  145076. /** @hidden */
  145077. _vReflectionFilteringInfoName: string;
  145078. private _scene;
  145079. /**
  145080. * The three properties below are set by the main PBR block prior to calling methods of this class.
  145081. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145082. * It's less burden on the user side in the editor part.
  145083. */
  145084. /** @hidden */
  145085. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145086. /** @hidden */
  145087. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145088. /** @hidden */
  145089. cameraPositionConnectionPoint: NodeMaterialConnectionPoint;
  145090. /**
  145091. * Defines if the material uses spherical harmonics vs spherical polynomials for the
  145092. * diffuse part of the IBL.
  145093. */
  145094. useSphericalHarmonics: boolean;
  145095. /**
  145096. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  145097. */
  145098. forceIrradianceInFragment: boolean;
  145099. /**
  145100. * Create a new ReflectionBlock
  145101. * @param name defines the block name
  145102. */
  145103. constructor(name: string);
  145104. /**
  145105. * Gets the current class name
  145106. * @returns the class name
  145107. */
  145108. getClassName(): string;
  145109. /**
  145110. * Gets the position input component
  145111. */
  145112. get position(): NodeMaterialConnectionPoint;
  145113. /**
  145114. * Gets the world position input component
  145115. */
  145116. get worldPosition(): NodeMaterialConnectionPoint;
  145117. /**
  145118. * Gets the world normal input component
  145119. */
  145120. get worldNormal(): NodeMaterialConnectionPoint;
  145121. /**
  145122. * Gets the world input component
  145123. */
  145124. get world(): NodeMaterialConnectionPoint;
  145125. /**
  145126. * Gets the camera (or eye) position component
  145127. */
  145128. get cameraPosition(): NodeMaterialConnectionPoint;
  145129. /**
  145130. * Gets the view input component
  145131. */
  145132. get view(): NodeMaterialConnectionPoint;
  145133. /**
  145134. * Gets the color input component
  145135. */
  145136. get color(): NodeMaterialConnectionPoint;
  145137. /**
  145138. * Gets the reflection object output component
  145139. */
  145140. get reflection(): NodeMaterialConnectionPoint;
  145141. /**
  145142. * Returns true if the block has a texture (either its own texture or the environment texture from the scene, if set)
  145143. */
  145144. get hasTexture(): boolean;
  145145. /**
  145146. * Gets the reflection color (either the name of the variable if the color input is connected, else a default value)
  145147. */
  145148. get reflectionColor(): string;
  145149. protected _getTexture(): Nullable<BaseTexture>;
  145150. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145151. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145152. /**
  145153. * Gets the code to inject in the vertex shader
  145154. * @param state current state of the node material building
  145155. * @returns the shader code
  145156. */
  145157. handleVertexSide(state: NodeMaterialBuildState): string;
  145158. /**
  145159. * Gets the main code of the block (fragment side)
  145160. * @param state current state of the node material building
  145161. * @param normalVarName name of the existing variable corresponding to the normal
  145162. * @returns the shader code
  145163. */
  145164. getCode(state: NodeMaterialBuildState, normalVarName: string): string;
  145165. protected _buildBlock(state: NodeMaterialBuildState): this;
  145166. protected _dumpPropertiesCode(): string;
  145167. serialize(): any;
  145168. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145169. }
  145170. }
  145171. declare module BABYLON {
  145172. /**
  145173. * Block used to implement the sheen module of the PBR material
  145174. */
  145175. export class SheenBlock extends NodeMaterialBlock {
  145176. /**
  145177. * Create a new SheenBlock
  145178. * @param name defines the block name
  145179. */
  145180. constructor(name: string);
  145181. /**
  145182. * If true, the sheen effect is layered above the base BRDF with the albedo-scaling technique.
  145183. * It allows the strength of the sheen effect to not depend on the base color of the material,
  145184. * making it easier to setup and tweak the effect
  145185. */
  145186. albedoScaling: boolean;
  145187. /**
  145188. * Defines if the sheen is linked to the sheen color.
  145189. */
  145190. linkSheenWithAlbedo: boolean;
  145191. /**
  145192. * Initialize the block and prepare the context for build
  145193. * @param state defines the state that will be used for the build
  145194. */
  145195. initialize(state: NodeMaterialBuildState): void;
  145196. /**
  145197. * Gets the current class name
  145198. * @returns the class name
  145199. */
  145200. getClassName(): string;
  145201. /**
  145202. * Gets the intensity input component
  145203. */
  145204. get intensity(): NodeMaterialConnectionPoint;
  145205. /**
  145206. * Gets the color input component
  145207. */
  145208. get color(): NodeMaterialConnectionPoint;
  145209. /**
  145210. * Gets the roughness input component
  145211. */
  145212. get roughness(): NodeMaterialConnectionPoint;
  145213. /**
  145214. * Gets the sheen object output component
  145215. */
  145216. get sheen(): NodeMaterialConnectionPoint;
  145217. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145218. /**
  145219. * Gets the main code of the block (fragment side)
  145220. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145221. * @returns the shader code
  145222. */
  145223. getCode(reflectionBlock: Nullable<ReflectionBlock>): string;
  145224. protected _buildBlock(state: NodeMaterialBuildState): this;
  145225. protected _dumpPropertiesCode(): string;
  145226. serialize(): any;
  145227. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145228. }
  145229. }
  145230. declare module BABYLON {
  145231. /**
  145232. * Block used to implement the reflectivity module of the PBR material
  145233. */
  145234. export class ReflectivityBlock extends NodeMaterialBlock {
  145235. private _metallicReflectanceColor;
  145236. private _metallicF0Factor;
  145237. /** @hidden */
  145238. _vMetallicReflectanceFactorsName: string;
  145239. /**
  145240. * The property below is set by the main PBR block prior to calling methods of this class.
  145241. */
  145242. /** @hidden */
  145243. indexOfRefractionConnectionPoint: Nullable<NodeMaterialConnectionPoint>;
  145244. /**
  145245. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  145246. */
  145247. useAmbientOcclusionFromMetallicTextureRed: boolean;
  145248. /**
  145249. * Specifies if the metallic texture contains the metallness information in its blue channel.
  145250. */
  145251. useMetallnessFromMetallicTextureBlue: boolean;
  145252. /**
  145253. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  145254. */
  145255. useRoughnessFromMetallicTextureAlpha: boolean;
  145256. /**
  145257. * Specifies if the metallic texture contains the roughness information in its green channel.
  145258. */
  145259. useRoughnessFromMetallicTextureGreen: boolean;
  145260. /**
  145261. * Create a new ReflectivityBlock
  145262. * @param name defines the block name
  145263. */
  145264. constructor(name: string);
  145265. /**
  145266. * Initialize the block and prepare the context for build
  145267. * @param state defines the state that will be used for the build
  145268. */
  145269. initialize(state: NodeMaterialBuildState): void;
  145270. /**
  145271. * Gets the current class name
  145272. * @returns the class name
  145273. */
  145274. getClassName(): string;
  145275. /**
  145276. * Gets the metallic input component
  145277. */
  145278. get metallic(): NodeMaterialConnectionPoint;
  145279. /**
  145280. * Gets the roughness input component
  145281. */
  145282. get roughness(): NodeMaterialConnectionPoint;
  145283. /**
  145284. * Gets the texture input component
  145285. */
  145286. get texture(): NodeMaterialConnectionPoint;
  145287. /**
  145288. * Gets the reflectivity object output component
  145289. */
  145290. get reflectivity(): NodeMaterialConnectionPoint;
  145291. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145292. /**
  145293. * Gets the main code of the block (fragment side)
  145294. * @param state current state of the node material building
  145295. * @param aoIntensityVarName name of the variable with the ambient occlusion intensity
  145296. * @returns the shader code
  145297. */
  145298. getCode(state: NodeMaterialBuildState, aoIntensityVarName: string): string;
  145299. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145300. protected _buildBlock(state: NodeMaterialBuildState): this;
  145301. protected _dumpPropertiesCode(): string;
  145302. serialize(): any;
  145303. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145304. }
  145305. }
  145306. declare module BABYLON {
  145307. /**
  145308. * Block used to implement the anisotropy module of the PBR material
  145309. */
  145310. export class AnisotropyBlock extends NodeMaterialBlock {
  145311. /**
  145312. * The two properties below are set by the main PBR block prior to calling methods of this class.
  145313. * This is to avoid having to add them as inputs here whereas they are already inputs of the main block, so already known.
  145314. * It's less burden on the user side in the editor part.
  145315. */
  145316. /** @hidden */
  145317. worldPositionConnectionPoint: NodeMaterialConnectionPoint;
  145318. /** @hidden */
  145319. worldNormalConnectionPoint: NodeMaterialConnectionPoint;
  145320. /**
  145321. * Create a new AnisotropyBlock
  145322. * @param name defines the block name
  145323. */
  145324. constructor(name: string);
  145325. /**
  145326. * Initialize the block and prepare the context for build
  145327. * @param state defines the state that will be used for the build
  145328. */
  145329. initialize(state: NodeMaterialBuildState): void;
  145330. /**
  145331. * Gets the current class name
  145332. * @returns the class name
  145333. */
  145334. getClassName(): string;
  145335. /**
  145336. * Gets the intensity input component
  145337. */
  145338. get intensity(): NodeMaterialConnectionPoint;
  145339. /**
  145340. * Gets the direction input component
  145341. */
  145342. get direction(): NodeMaterialConnectionPoint;
  145343. /**
  145344. * Gets the texture input component
  145345. */
  145346. get texture(): NodeMaterialConnectionPoint;
  145347. /**
  145348. * Gets the uv input component
  145349. */
  145350. get uv(): NodeMaterialConnectionPoint;
  145351. /**
  145352. * Gets the worldTangent input component
  145353. */
  145354. get worldTangent(): NodeMaterialConnectionPoint;
  145355. /**
  145356. * Gets the anisotropy object output component
  145357. */
  145358. get anisotropy(): NodeMaterialConnectionPoint;
  145359. private _generateTBNSpace;
  145360. /**
  145361. * Gets the main code of the block (fragment side)
  145362. * @param state current state of the node material building
  145363. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145364. * @returns the shader code
  145365. */
  145366. getCode(state: NodeMaterialBuildState, generateTBNSpace?: boolean): string;
  145367. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145368. protected _buildBlock(state: NodeMaterialBuildState): this;
  145369. }
  145370. }
  145371. declare module BABYLON {
  145372. /**
  145373. * Block used to implement the clear coat module of the PBR material
  145374. */
  145375. export class ClearCoatBlock extends NodeMaterialBlock {
  145376. private _scene;
  145377. /**
  145378. * Create a new ClearCoatBlock
  145379. * @param name defines the block name
  145380. */
  145381. constructor(name: string);
  145382. /**
  145383. * Initialize the block and prepare the context for build
  145384. * @param state defines the state that will be used for the build
  145385. */
  145386. initialize(state: NodeMaterialBuildState): void;
  145387. /**
  145388. * Gets the current class name
  145389. * @returns the class name
  145390. */
  145391. getClassName(): string;
  145392. /**
  145393. * Gets the intensity input component
  145394. */
  145395. get intensity(): NodeMaterialConnectionPoint;
  145396. /**
  145397. * Gets the roughness input component
  145398. */
  145399. get roughness(): NodeMaterialConnectionPoint;
  145400. /**
  145401. * Gets the ior input component
  145402. */
  145403. get ior(): NodeMaterialConnectionPoint;
  145404. /**
  145405. * Gets the texture input component
  145406. */
  145407. get texture(): NodeMaterialConnectionPoint;
  145408. /**
  145409. * Gets the bump texture input component
  145410. */
  145411. get bumpTexture(): NodeMaterialConnectionPoint;
  145412. /**
  145413. * Gets the uv input component
  145414. */
  145415. get uv(): NodeMaterialConnectionPoint;
  145416. /**
  145417. * Gets the tint color input component
  145418. */
  145419. get tintColor(): NodeMaterialConnectionPoint;
  145420. /**
  145421. * Gets the tint "at distance" input component
  145422. */
  145423. get tintAtDistance(): NodeMaterialConnectionPoint;
  145424. /**
  145425. * Gets the tint thickness input component
  145426. */
  145427. get tintThickness(): NodeMaterialConnectionPoint;
  145428. /**
  145429. * Gets the world tangent input component
  145430. */
  145431. get worldTangent(): NodeMaterialConnectionPoint;
  145432. /**
  145433. * Gets the clear coat object output component
  145434. */
  145435. get clearcoat(): NodeMaterialConnectionPoint;
  145436. autoConfigure(material: NodeMaterial): void;
  145437. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145438. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh, subMesh?: SubMesh): void;
  145439. private _generateTBNSpace;
  145440. /**
  145441. * Gets the main code of the block (fragment side)
  145442. * @param state current state of the node material building
  145443. * @param ccBlock instance of a ClearCoatBlock or null if the code must be generated without an active clear coat module
  145444. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145445. * @param worldPosVarName name of the variable holding the world position
  145446. * @param generateTBNSpace if true, the code needed to create the TBN coordinate space is generated
  145447. * @param vTBNAvailable indicate that the vTBN variable is already existing because it has already been generated by another block (PerturbNormal or Anisotropy)
  145448. * @param worldNormalVarName name of the variable holding the world normal
  145449. * @returns the shader code
  145450. */
  145451. static GetCode(state: NodeMaterialBuildState, ccBlock: Nullable<ClearCoatBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string, generateTBNSpace: boolean, vTBNAvailable: boolean, worldNormalVarName: string): string;
  145452. protected _buildBlock(state: NodeMaterialBuildState): this;
  145453. }
  145454. }
  145455. declare module BABYLON {
  145456. /**
  145457. * Block used to implement the sub surface module of the PBR material
  145458. */
  145459. export class SubSurfaceBlock extends NodeMaterialBlock {
  145460. /**
  145461. * Create a new SubSurfaceBlock
  145462. * @param name defines the block name
  145463. */
  145464. constructor(name: string);
  145465. /**
  145466. * Stores the intensity of the different subsurface effects in the thickness texture.
  145467. * * the green channel is the translucency intensity.
  145468. * * the blue channel is the scattering intensity.
  145469. * * the alpha channel is the refraction intensity.
  145470. */
  145471. useMaskFromThicknessTexture: boolean;
  145472. /**
  145473. * Initialize the block and prepare the context for build
  145474. * @param state defines the state that will be used for the build
  145475. */
  145476. initialize(state: NodeMaterialBuildState): void;
  145477. /**
  145478. * Gets the current class name
  145479. * @returns the class name
  145480. */
  145481. getClassName(): string;
  145482. /**
  145483. * Gets the min thickness input component
  145484. */
  145485. get minThickness(): NodeMaterialConnectionPoint;
  145486. /**
  145487. * Gets the max thickness input component
  145488. */
  145489. get maxThickness(): NodeMaterialConnectionPoint;
  145490. /**
  145491. * Gets the thickness texture component
  145492. */
  145493. get thicknessTexture(): NodeMaterialConnectionPoint;
  145494. /**
  145495. * Gets the tint color input component
  145496. */
  145497. get tintColor(): NodeMaterialConnectionPoint;
  145498. /**
  145499. * Gets the translucency intensity input component
  145500. */
  145501. get translucencyIntensity(): NodeMaterialConnectionPoint;
  145502. /**
  145503. * Gets the translucency diffusion distance input component
  145504. */
  145505. get translucencyDiffusionDistance(): NodeMaterialConnectionPoint;
  145506. /**
  145507. * Gets the refraction object parameters
  145508. */
  145509. get refraction(): NodeMaterialConnectionPoint;
  145510. /**
  145511. * Gets the sub surface object output component
  145512. */
  145513. get subsurface(): NodeMaterialConnectionPoint;
  145514. autoConfigure(material: NodeMaterial): void;
  145515. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145516. /**
  145517. * Gets the main code of the block (fragment side)
  145518. * @param state current state of the node material building
  145519. * @param ssBlock instance of a SubSurfaceBlock or null if the code must be generated without an active sub surface module
  145520. * @param reflectionBlock instance of a ReflectionBlock null if the code must be generated without an active reflection module
  145521. * @param worldPosVarName name of the variable holding the world position
  145522. * @returns the shader code
  145523. */
  145524. static GetCode(state: NodeMaterialBuildState, ssBlock: Nullable<SubSurfaceBlock>, reflectionBlock: Nullable<ReflectionBlock>, worldPosVarName: string): string;
  145525. protected _buildBlock(state: NodeMaterialBuildState): this;
  145526. }
  145527. }
  145528. declare module BABYLON {
  145529. /**
  145530. * Block used to implement the PBR metallic/roughness model
  145531. */
  145532. export class PBRMetallicRoughnessBlock extends NodeMaterialBlock {
  145533. /**
  145534. * Gets or sets the light associated with this block
  145535. */
  145536. light: Nullable<Light>;
  145537. private _lightId;
  145538. private _scene;
  145539. private _environmentBRDFTexture;
  145540. private _environmentBrdfSamplerName;
  145541. private _vNormalWName;
  145542. private _invertNormalName;
  145543. /**
  145544. * Create a new ReflectionBlock
  145545. * @param name defines the block name
  145546. */
  145547. constructor(name: string);
  145548. /**
  145549. * Intensity of the direct lights e.g. the four lights available in your scene.
  145550. * This impacts both the direct diffuse and specular highlights.
  145551. */
  145552. directIntensity: number;
  145553. /**
  145554. * Intensity of the environment e.g. how much the environment will light the object
  145555. * either through harmonics for rough material or through the refelction for shiny ones.
  145556. */
  145557. environmentIntensity: number;
  145558. /**
  145559. * This is a special control allowing the reduction of the specular highlights coming from the
  145560. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  145561. */
  145562. specularIntensity: number;
  145563. /**
  145564. * Defines the falloff type used in this material.
  145565. * It by default is Physical.
  145566. */
  145567. lightFalloff: number;
  145568. /**
  145569. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  145570. */
  145571. useAlphaFromAlbedoTexture: boolean;
  145572. /**
  145573. * Specifies that alpha test should be used
  145574. */
  145575. useAlphaTest: boolean;
  145576. /**
  145577. * Defines the alpha limits in alpha test mode.
  145578. */
  145579. alphaTestCutoff: number;
  145580. /**
  145581. * Specifies that alpha blending should be used
  145582. */
  145583. useAlphaBlending: boolean;
  145584. /**
  145585. * Defines if the alpha value should be determined via the rgb values.
  145586. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  145587. */
  145588. opacityRGB: boolean;
  145589. /**
  145590. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most luminous ones).
  145591. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  145592. */
  145593. useRadianceOverAlpha: boolean;
  145594. /**
  145595. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most luminous ones).
  145596. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  145597. */
  145598. useSpecularOverAlpha: boolean;
  145599. /**
  145600. * Enables specular anti aliasing in the PBR shader.
  145601. * It will both interacts on the Geometry for analytical and IBL lighting.
  145602. * It also prefilter the roughness map based on the bump values.
  145603. */
  145604. enableSpecularAntiAliasing: boolean;
  145605. /**
  145606. * Enables realtime filtering on the texture.
  145607. */
  145608. realTimeFiltering: boolean;
  145609. /**
  145610. * Quality switch for realtime filtering
  145611. */
  145612. realTimeFilteringQuality: number;
  145613. /**
  145614. * Defines if the material uses energy conservation.
  145615. */
  145616. useEnergyConservation: boolean;
  145617. /**
  145618. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  145619. * too much the area relying on ambient texture to define their ambient occlusion.
  145620. */
  145621. useRadianceOcclusion: boolean;
  145622. /**
  145623. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  145624. * makes the reflect vector face the model (under horizon).
  145625. */
  145626. useHorizonOcclusion: boolean;
  145627. /**
  145628. * If set to true, no lighting calculations will be applied.
  145629. */
  145630. unlit: boolean;
  145631. /**
  145632. * Force normal to face away from face.
  145633. */
  145634. forceNormalForward: boolean;
  145635. /**
  145636. * Defines the material debug mode.
  145637. * It helps seeing only some components of the material while troubleshooting.
  145638. */
  145639. debugMode: number;
  145640. /**
  145641. * Specify from where on screen the debug mode should start.
  145642. * The value goes from -1 (full screen) to 1 (not visible)
  145643. * It helps with side by side comparison against the final render
  145644. * This defaults to 0
  145645. */
  145646. debugLimit: number;
  145647. /**
  145648. * As the default viewing range might not be enough (if the ambient is really small for instance)
  145649. * You can use the factor to better multiply the final value.
  145650. */
  145651. debugFactor: number;
  145652. /**
  145653. * Initialize the block and prepare the context for build
  145654. * @param state defines the state that will be used for the build
  145655. */
  145656. initialize(state: NodeMaterialBuildState): void;
  145657. /**
  145658. * Gets the current class name
  145659. * @returns the class name
  145660. */
  145661. getClassName(): string;
  145662. /**
  145663. * Gets the world position input component
  145664. */
  145665. get worldPosition(): NodeMaterialConnectionPoint;
  145666. /**
  145667. * Gets the world normal input component
  145668. */
  145669. get worldNormal(): NodeMaterialConnectionPoint;
  145670. /**
  145671. * Gets the perturbed normal input component
  145672. */
  145673. get perturbedNormal(): NodeMaterialConnectionPoint;
  145674. /**
  145675. * Gets the camera position input component
  145676. */
  145677. get cameraPosition(): NodeMaterialConnectionPoint;
  145678. /**
  145679. * Gets the base color input component
  145680. */
  145681. get baseColor(): NodeMaterialConnectionPoint;
  145682. /**
  145683. * Gets the opacity texture input component
  145684. */
  145685. get opacityTexture(): NodeMaterialConnectionPoint;
  145686. /**
  145687. * Gets the ambient color input component
  145688. */
  145689. get ambientColor(): NodeMaterialConnectionPoint;
  145690. /**
  145691. * Gets the reflectivity object parameters
  145692. */
  145693. get reflectivity(): NodeMaterialConnectionPoint;
  145694. /**
  145695. * Gets the ambient occlusion object parameters
  145696. */
  145697. get ambientOcc(): NodeMaterialConnectionPoint;
  145698. /**
  145699. * Gets the reflection object parameters
  145700. */
  145701. get reflection(): NodeMaterialConnectionPoint;
  145702. /**
  145703. * Gets the sheen object parameters
  145704. */
  145705. get sheen(): NodeMaterialConnectionPoint;
  145706. /**
  145707. * Gets the clear coat object parameters
  145708. */
  145709. get clearcoat(): NodeMaterialConnectionPoint;
  145710. /**
  145711. * Gets the sub surface object parameters
  145712. */
  145713. get subsurface(): NodeMaterialConnectionPoint;
  145714. /**
  145715. * Gets the anisotropy object parameters
  145716. */
  145717. get anisotropy(): NodeMaterialConnectionPoint;
  145718. /**
  145719. * Gets the ambient output component
  145720. */
  145721. get ambient(): NodeMaterialConnectionPoint;
  145722. /**
  145723. * Gets the diffuse output component
  145724. */
  145725. get diffuse(): NodeMaterialConnectionPoint;
  145726. /**
  145727. * Gets the specular output component
  145728. */
  145729. get specular(): NodeMaterialConnectionPoint;
  145730. /**
  145731. * Gets the sheen output component
  145732. */
  145733. get sheenDir(): NodeMaterialConnectionPoint;
  145734. /**
  145735. * Gets the clear coat output component
  145736. */
  145737. get clearcoatDir(): NodeMaterialConnectionPoint;
  145738. /**
  145739. * Gets the indirect diffuse output component
  145740. */
  145741. get diffuseIndirect(): NodeMaterialConnectionPoint;
  145742. /**
  145743. * Gets the indirect specular output component
  145744. */
  145745. get specularIndirect(): NodeMaterialConnectionPoint;
  145746. /**
  145747. * Gets the indirect sheen output component
  145748. */
  145749. get sheenIndirect(): NodeMaterialConnectionPoint;
  145750. /**
  145751. * Gets the indirect clear coat output component
  145752. */
  145753. get clearcoatIndirect(): NodeMaterialConnectionPoint;
  145754. /**
  145755. * Gets the refraction output component
  145756. */
  145757. get refraction(): NodeMaterialConnectionPoint;
  145758. /**
  145759. * Gets the global lighting output component
  145760. */
  145761. get lighting(): NodeMaterialConnectionPoint;
  145762. /**
  145763. * Gets the shadow output component
  145764. */
  145765. get shadow(): NodeMaterialConnectionPoint;
  145766. /**
  145767. * Gets the alpha output component
  145768. */
  145769. get alpha(): NodeMaterialConnectionPoint;
  145770. autoConfigure(material: NodeMaterial): void;
  145771. prepareDefines(mesh: AbstractMesh, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines): void;
  145772. updateUniformsAndSamples(state: NodeMaterialBuildState, nodeMaterial: NodeMaterial, defines: NodeMaterialDefines, uniformBuffers: string[]): void;
  145773. bind(effect: Effect, nodeMaterial: NodeMaterial, mesh?: Mesh): void;
  145774. private _injectVertexCode;
  145775. /**
  145776. * Gets the code corresponding to the albedo/opacity module
  145777. * @returns the shader code
  145778. */
  145779. getAlbedoOpacityCode(): string;
  145780. protected _buildBlock(state: NodeMaterialBuildState): this;
  145781. protected _dumpPropertiesCode(): string;
  145782. serialize(): any;
  145783. _deserialize(serializationObject: any, scene: Scene, rootUrl: string): void;
  145784. }
  145785. }
  145786. declare module BABYLON {
  145787. /**
  145788. * Block used to compute value of one parameter modulo another
  145789. */
  145790. export class ModBlock extends NodeMaterialBlock {
  145791. /**
  145792. * Creates a new ModBlock
  145793. * @param name defines the block name
  145794. */
  145795. constructor(name: string);
  145796. /**
  145797. * Gets the current class name
  145798. * @returns the class name
  145799. */
  145800. getClassName(): string;
  145801. /**
  145802. * Gets the left operand input component
  145803. */
  145804. get left(): NodeMaterialConnectionPoint;
  145805. /**
  145806. * Gets the right operand input component
  145807. */
  145808. get right(): NodeMaterialConnectionPoint;
  145809. /**
  145810. * Gets the output component
  145811. */
  145812. get output(): NodeMaterialConnectionPoint;
  145813. protected _buildBlock(state: NodeMaterialBuildState): this;
  145814. }
  145815. }
  145816. declare module BABYLON {
  145817. /**
  145818. * Configuration for Draco compression
  145819. */
  145820. export interface IDracoCompressionConfiguration {
  145821. /**
  145822. * Configuration for the decoder.
  145823. */
  145824. decoder: {
  145825. /**
  145826. * The url to the WebAssembly module.
  145827. */
  145828. wasmUrl?: string;
  145829. /**
  145830. * The url to the WebAssembly binary.
  145831. */
  145832. wasmBinaryUrl?: string;
  145833. /**
  145834. * The url to the fallback JavaScript module.
  145835. */
  145836. fallbackUrl?: string;
  145837. };
  145838. }
  145839. /**
  145840. * Draco compression (https://google.github.io/draco/)
  145841. *
  145842. * This class wraps the Draco module.
  145843. *
  145844. * **Encoder**
  145845. *
  145846. * The encoder is not currently implemented.
  145847. *
  145848. * **Decoder**
  145849. *
  145850. * 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.
  145851. *
  145852. * To update the configuration, use the following code:
  145853. * ```javascript
  145854. * DracoCompression.Configuration = {
  145855. * decoder: {
  145856. * wasmUrl: "<url to the WebAssembly library>",
  145857. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  145858. * fallbackUrl: "<url to the fallback JavaScript library>",
  145859. * }
  145860. * };
  145861. * ```
  145862. *
  145863. * 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.
  145864. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  145865. * Use `DracoCompression.DecoderAvailable` to determine if the decoder configuration is available for the current context.
  145866. *
  145867. * To decode Draco compressed data, get the default DracoCompression object and call decodeMeshAsync:
  145868. * ```javascript
  145869. * var vertexData = await DracoCompression.Default.decodeMeshAsync(data);
  145870. * ```
  145871. *
  145872. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  145873. */
  145874. export class DracoCompression implements IDisposable {
  145875. private _workerPoolPromise?;
  145876. private _decoderModulePromise?;
  145877. /**
  145878. * The configuration. Defaults to the following urls:
  145879. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  145880. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  145881. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  145882. */
  145883. static Configuration: IDracoCompressionConfiguration;
  145884. /**
  145885. * Returns true if the decoder configuration is available.
  145886. */
  145887. static get DecoderAvailable(): boolean;
  145888. /**
  145889. * Default number of workers to create when creating the draco compression object.
  145890. */
  145891. static DefaultNumWorkers: number;
  145892. private static GetDefaultNumWorkers;
  145893. private static _Default;
  145894. /**
  145895. * Default instance for the draco compression object.
  145896. */
  145897. static get Default(): DracoCompression;
  145898. /**
  145899. * Constructor
  145900. * @param numWorkers The number of workers for async operations. Specify `0` to disable web workers and run synchronously in the current context.
  145901. */
  145902. constructor(numWorkers?: number);
  145903. /**
  145904. * Stop all async operations and release resources.
  145905. */
  145906. dispose(): void;
  145907. /**
  145908. * Returns a promise that resolves when ready. Call this manually to ensure draco compression is ready before use.
  145909. * @returns a promise that resolves when ready
  145910. */
  145911. whenReadyAsync(): Promise<void>;
  145912. /**
  145913. * Decode Draco compressed mesh data to vertex data.
  145914. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  145915. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  145916. * @returns A promise that resolves with the decoded vertex data
  145917. */
  145918. decodeMeshAsync(data: ArrayBuffer | ArrayBufferView, attributes?: {
  145919. [kind: string]: number;
  145920. }): Promise<VertexData>;
  145921. }
  145922. }
  145923. declare module BABYLON {
  145924. /**
  145925. * Class for building Constructive Solid Geometry
  145926. */
  145927. export class CSG {
  145928. private polygons;
  145929. /**
  145930. * The world matrix
  145931. */
  145932. matrix: Matrix;
  145933. /**
  145934. * Stores the position
  145935. */
  145936. position: Vector3;
  145937. /**
  145938. * Stores the rotation
  145939. */
  145940. rotation: Vector3;
  145941. /**
  145942. * Stores the rotation quaternion
  145943. */
  145944. rotationQuaternion: Nullable<Quaternion>;
  145945. /**
  145946. * Stores the scaling vector
  145947. */
  145948. scaling: Vector3;
  145949. /**
  145950. * Convert the Mesh to CSG
  145951. * @param mesh The Mesh to convert to CSG
  145952. * @returns A new CSG from the Mesh
  145953. */
  145954. static FromMesh(mesh: Mesh): CSG;
  145955. /**
  145956. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  145957. * @param polygons Polygons used to construct a CSG solid
  145958. */
  145959. private static FromPolygons;
  145960. /**
  145961. * Clones, or makes a deep copy, of the CSG
  145962. * @returns A new CSG
  145963. */
  145964. clone(): CSG;
  145965. /**
  145966. * Unions this CSG with another CSG
  145967. * @param csg The CSG to union against this CSG
  145968. * @returns The unioned CSG
  145969. */
  145970. union(csg: CSG): CSG;
  145971. /**
  145972. * Unions this CSG with another CSG in place
  145973. * @param csg The CSG to union against this CSG
  145974. */
  145975. unionInPlace(csg: CSG): void;
  145976. /**
  145977. * Subtracts this CSG with another CSG
  145978. * @param csg The CSG to subtract against this CSG
  145979. * @returns A new CSG
  145980. */
  145981. subtract(csg: CSG): CSG;
  145982. /**
  145983. * Subtracts this CSG with another CSG in place
  145984. * @param csg The CSG to subtact against this CSG
  145985. */
  145986. subtractInPlace(csg: CSG): void;
  145987. /**
  145988. * Intersect this CSG with another CSG
  145989. * @param csg The CSG to intersect against this CSG
  145990. * @returns A new CSG
  145991. */
  145992. intersect(csg: CSG): CSG;
  145993. /**
  145994. * Intersects this CSG with another CSG in place
  145995. * @param csg The CSG to intersect against this CSG
  145996. */
  145997. intersectInPlace(csg: CSG): void;
  145998. /**
  145999. * Return a new CSG solid with solid and empty space switched. This solid is
  146000. * not modified.
  146001. * @returns A new CSG solid with solid and empty space switched
  146002. */
  146003. inverse(): CSG;
  146004. /**
  146005. * Inverses the CSG in place
  146006. */
  146007. inverseInPlace(): void;
  146008. /**
  146009. * This is used to keep meshes transformations so they can be restored
  146010. * when we build back a Babylon Mesh
  146011. * NB : All CSG operations are performed in world coordinates
  146012. * @param csg The CSG to copy the transform attributes from
  146013. * @returns This CSG
  146014. */
  146015. copyTransformAttributes(csg: CSG): CSG;
  146016. /**
  146017. * Build Raw mesh from CSG
  146018. * Coordinates here are in world space
  146019. * @param name The name of the mesh geometry
  146020. * @param scene The Scene
  146021. * @param keepSubMeshes Specifies if the submeshes should be kept
  146022. * @returns A new Mesh
  146023. */
  146024. buildMeshGeometry(name: string, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146025. /**
  146026. * Build Mesh from CSG taking material and transforms into account
  146027. * @param name The name of the Mesh
  146028. * @param material The material of the Mesh
  146029. * @param scene The Scene
  146030. * @param keepSubMeshes Specifies if submeshes should be kept
  146031. * @returns The new Mesh
  146032. */
  146033. toMesh(name: string, material?: Nullable<Material>, scene?: Scene, keepSubMeshes?: boolean): Mesh;
  146034. }
  146035. }
  146036. declare module BABYLON {
  146037. /**
  146038. * Class used to create a trail following a mesh
  146039. */
  146040. export class TrailMesh extends Mesh {
  146041. private _generator;
  146042. private _autoStart;
  146043. private _running;
  146044. private _diameter;
  146045. private _length;
  146046. private _sectionPolygonPointsCount;
  146047. private _sectionVectors;
  146048. private _sectionNormalVectors;
  146049. private _beforeRenderObserver;
  146050. /**
  146051. * @constructor
  146052. * @param name The value used by scene.getMeshByName() to do a lookup.
  146053. * @param generator The mesh or transform node to generate a trail.
  146054. * @param scene The scene to add this mesh to.
  146055. * @param diameter Diameter of trailing mesh. Default is 1.
  146056. * @param length Length of trailing mesh. Default is 60.
  146057. * @param autoStart Automatically start trailing mesh. Default true.
  146058. */
  146059. constructor(name: string, generator: TransformNode, scene: Scene, diameter?: number, length?: number, autoStart?: boolean);
  146060. /**
  146061. * "TrailMesh"
  146062. * @returns "TrailMesh"
  146063. */
  146064. getClassName(): string;
  146065. private _createMesh;
  146066. /**
  146067. * Start trailing mesh.
  146068. */
  146069. start(): void;
  146070. /**
  146071. * Stop trailing mesh.
  146072. */
  146073. stop(): void;
  146074. /**
  146075. * Update trailing mesh geometry.
  146076. */
  146077. update(): void;
  146078. /**
  146079. * Returns a new TrailMesh object.
  146080. * @param name is a string, the name given to the new mesh
  146081. * @param newGenerator use new generator object for cloned trail mesh
  146082. * @returns a new mesh
  146083. */
  146084. clone(name: string | undefined, newGenerator: TransformNode): TrailMesh;
  146085. /**
  146086. * Serializes this trail mesh
  146087. * @param serializationObject object to write serialization to
  146088. */
  146089. serialize(serializationObject: any): void;
  146090. /**
  146091. * Parses a serialized trail mesh
  146092. * @param parsedMesh the serialized mesh
  146093. * @param scene the scene to create the trail mesh in
  146094. * @returns the created trail mesh
  146095. */
  146096. static Parse(parsedMesh: any, scene: Scene): TrailMesh;
  146097. }
  146098. }
  146099. declare module BABYLON {
  146100. /**
  146101. * Class containing static functions to help procedurally build meshes
  146102. */
  146103. export class TiledBoxBuilder {
  146104. /**
  146105. * Creates a box mesh
  146106. * 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)
  146107. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146108. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146109. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146110. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146111. * @param name defines the name of the mesh
  146112. * @param options defines the options used to create the mesh
  146113. * @param scene defines the hosting scene
  146114. * @returns the box mesh
  146115. */
  146116. static CreateTiledBox(name: string, options: {
  146117. pattern?: number;
  146118. width?: number;
  146119. height?: number;
  146120. depth?: number;
  146121. tileSize?: number;
  146122. tileWidth?: number;
  146123. tileHeight?: number;
  146124. alignHorizontal?: number;
  146125. alignVertical?: number;
  146126. faceUV?: Vector4[];
  146127. faceColors?: Color4[];
  146128. sideOrientation?: number;
  146129. updatable?: boolean;
  146130. }, scene?: Nullable<Scene>): Mesh;
  146131. }
  146132. }
  146133. declare module BABYLON {
  146134. /**
  146135. * Class containing static functions to help procedurally build meshes
  146136. */
  146137. export class TorusKnotBuilder {
  146138. /**
  146139. * Creates a torus knot mesh
  146140. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146141. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146142. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146143. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146144. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146145. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146146. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146147. * @param name defines the name of the mesh
  146148. * @param options defines the options used to create the mesh
  146149. * @param scene defines the hosting scene
  146150. * @returns the torus knot mesh
  146151. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146152. */
  146153. static CreateTorusKnot(name: string, options: {
  146154. radius?: number;
  146155. tube?: number;
  146156. radialSegments?: number;
  146157. tubularSegments?: number;
  146158. p?: number;
  146159. q?: number;
  146160. updatable?: boolean;
  146161. sideOrientation?: number;
  146162. frontUVs?: Vector4;
  146163. backUVs?: Vector4;
  146164. }, scene: any): Mesh;
  146165. }
  146166. }
  146167. declare module BABYLON {
  146168. /**
  146169. * Polygon
  146170. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  146171. */
  146172. export class Polygon {
  146173. /**
  146174. * Creates a rectangle
  146175. * @param xmin bottom X coord
  146176. * @param ymin bottom Y coord
  146177. * @param xmax top X coord
  146178. * @param ymax top Y coord
  146179. * @returns points that make the resulting rectation
  146180. */
  146181. static Rectangle(xmin: number, ymin: number, xmax: number, ymax: number): Vector2[];
  146182. /**
  146183. * Creates a circle
  146184. * @param radius radius of circle
  146185. * @param cx scale in x
  146186. * @param cy scale in y
  146187. * @param numberOfSides number of sides that make up the circle
  146188. * @returns points that make the resulting circle
  146189. */
  146190. static Circle(radius: number, cx?: number, cy?: number, numberOfSides?: number): Vector2[];
  146191. /**
  146192. * Creates a polygon from input string
  146193. * @param input Input polygon data
  146194. * @returns the parsed points
  146195. */
  146196. static Parse(input: string): Vector2[];
  146197. /**
  146198. * Starts building a polygon from x and y coordinates
  146199. * @param x x coordinate
  146200. * @param y y coordinate
  146201. * @returns the started path2
  146202. */
  146203. static StartingAt(x: number, y: number): Path2;
  146204. }
  146205. /**
  146206. * Builds a polygon
  146207. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  146208. */
  146209. export class PolygonMeshBuilder {
  146210. private _points;
  146211. private _outlinepoints;
  146212. private _holes;
  146213. private _name;
  146214. private _scene;
  146215. private _epoints;
  146216. private _eholes;
  146217. private _addToepoint;
  146218. /**
  146219. * Babylon reference to the earcut plugin.
  146220. */
  146221. bjsEarcut: any;
  146222. /**
  146223. * Creates a PolygonMeshBuilder
  146224. * @param name name of the builder
  146225. * @param contours Path of the polygon
  146226. * @param scene scene to add to when creating the mesh
  146227. * @param earcutInjection can be used to inject your own earcut reference
  146228. */
  146229. constructor(name: string, contours: Path2 | Vector2[] | any, scene?: Scene, earcutInjection?: any);
  146230. /**
  146231. * Adds a whole within the polygon
  146232. * @param hole Array of points defining the hole
  146233. * @returns this
  146234. */
  146235. addHole(hole: Vector2[]): PolygonMeshBuilder;
  146236. /**
  146237. * Creates the polygon
  146238. * @param updatable If the mesh should be updatable
  146239. * @param depth The depth of the mesh created
  146240. * @returns the created mesh
  146241. */
  146242. build(updatable?: boolean, depth?: number): Mesh;
  146243. /**
  146244. * Creates the polygon
  146245. * @param depth The depth of the mesh created
  146246. * @returns the created VertexData
  146247. */
  146248. buildVertexData(depth?: number): VertexData;
  146249. /**
  146250. * Adds a side to the polygon
  146251. * @param positions points that make the polygon
  146252. * @param normals normals of the polygon
  146253. * @param uvs uvs of the polygon
  146254. * @param indices indices of the polygon
  146255. * @param bounds bounds of the polygon
  146256. * @param points points of the polygon
  146257. * @param depth depth of the polygon
  146258. * @param flip flip of the polygon
  146259. */
  146260. private addSide;
  146261. }
  146262. }
  146263. declare module BABYLON {
  146264. /**
  146265. * Class containing static functions to help procedurally build meshes
  146266. */
  146267. export class PolygonBuilder {
  146268. /**
  146269. * Creates a polygon mesh
  146270. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  146271. * * 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
  146272. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146273. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146274. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  146275. * * Remember you can only change the shape positions, not their number when updating a polygon
  146276. * @param name defines the name of the mesh
  146277. * @param options defines the options used to create the mesh
  146278. * @param scene defines the hosting scene
  146279. * @param earcutInjection can be used to inject your own earcut reference
  146280. * @returns the polygon mesh
  146281. */
  146282. static CreatePolygon(name: string, options: {
  146283. shape: Vector3[];
  146284. holes?: Vector3[][];
  146285. depth?: number;
  146286. faceUV?: Vector4[];
  146287. faceColors?: Color4[];
  146288. updatable?: boolean;
  146289. sideOrientation?: number;
  146290. frontUVs?: Vector4;
  146291. backUVs?: Vector4;
  146292. wrap?: boolean;
  146293. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146294. /**
  146295. * Creates an extruded polygon mesh, with depth in the Y direction.
  146296. * * 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)
  146297. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146298. * @param name defines the name of the mesh
  146299. * @param options defines the options used to create the mesh
  146300. * @param scene defines the hosting scene
  146301. * @param earcutInjection can be used to inject your own earcut reference
  146302. * @returns the polygon mesh
  146303. */
  146304. static ExtrudePolygon(name: string, options: {
  146305. shape: Vector3[];
  146306. holes?: Vector3[][];
  146307. depth?: number;
  146308. faceUV?: Vector4[];
  146309. faceColors?: Color4[];
  146310. updatable?: boolean;
  146311. sideOrientation?: number;
  146312. frontUVs?: Vector4;
  146313. backUVs?: Vector4;
  146314. wrap?: boolean;
  146315. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  146316. }
  146317. }
  146318. declare module BABYLON {
  146319. /**
  146320. * Class containing static functions to help procedurally build meshes
  146321. */
  146322. export class LatheBuilder {
  146323. /**
  146324. * Creates lathe mesh.
  146325. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146326. * * 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
  146327. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146328. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146329. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146330. * * 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
  146331. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146332. * * 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
  146333. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146334. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146335. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146336. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146337. * @param name defines the name of the mesh
  146338. * @param options defines the options used to create the mesh
  146339. * @param scene defines the hosting scene
  146340. * @returns the lathe mesh
  146341. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146342. */
  146343. static CreateLathe(name: string, options: {
  146344. shape: Vector3[];
  146345. radius?: number;
  146346. tessellation?: number;
  146347. clip?: number;
  146348. arc?: number;
  146349. closed?: boolean;
  146350. updatable?: boolean;
  146351. sideOrientation?: number;
  146352. frontUVs?: Vector4;
  146353. backUVs?: Vector4;
  146354. cap?: number;
  146355. invertUV?: boolean;
  146356. }, scene?: Nullable<Scene>): Mesh;
  146357. }
  146358. }
  146359. declare module BABYLON {
  146360. /**
  146361. * Class containing static functions to help procedurally build meshes
  146362. */
  146363. export class TiledPlaneBuilder {
  146364. /**
  146365. * Creates a tiled plane mesh
  146366. * * The parameter `pattern` will, depending on value, do nothing or
  146367. * * * flip (reflect about central vertical) alternate tiles across and up
  146368. * * * flip every tile on alternate rows
  146369. * * * rotate (180 degs) alternate tiles across and up
  146370. * * * rotate every tile on alternate rows
  146371. * * * flip and rotate alternate tiles across and up
  146372. * * * flip and rotate every tile on alternate rows
  146373. * * The parameter `tileSize` sets the size (float) of each tile side (default 1)
  146374. * * You can set some different tile dimensions by using the parameters `tileWidth` and `tileHeight` (both by default have the same value of `tileSize`)
  146375. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146376. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  146377. * * 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)
  146378. * * 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)
  146379. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146380. * @param name defines the name of the mesh
  146381. * @param options defines the options used to create the mesh
  146382. * @param scene defines the hosting scene
  146383. * @returns the box mesh
  146384. */
  146385. static CreateTiledPlane(name: string, options: {
  146386. pattern?: number;
  146387. tileSize?: number;
  146388. tileWidth?: number;
  146389. tileHeight?: number;
  146390. size?: number;
  146391. width?: number;
  146392. height?: number;
  146393. alignHorizontal?: number;
  146394. alignVertical?: number;
  146395. sideOrientation?: number;
  146396. frontUVs?: Vector4;
  146397. backUVs?: Vector4;
  146398. updatable?: boolean;
  146399. }, scene?: Nullable<Scene>): Mesh;
  146400. }
  146401. }
  146402. declare module BABYLON {
  146403. /**
  146404. * Class containing static functions to help procedurally build meshes
  146405. */
  146406. export class TubeBuilder {
  146407. /**
  146408. * Creates a tube mesh.
  146409. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146410. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  146411. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  146412. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  146413. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  146414. * * 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)
  146415. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  146416. * * 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
  146417. * * 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
  146418. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146419. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146420. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146421. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146422. * @param name defines the name of the mesh
  146423. * @param options defines the options used to create the mesh
  146424. * @param scene defines the hosting scene
  146425. * @returns the tube mesh
  146426. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146427. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  146428. */
  146429. static CreateTube(name: string, options: {
  146430. path: Vector3[];
  146431. radius?: number;
  146432. tessellation?: number;
  146433. radiusFunction?: {
  146434. (i: number, distance: number): number;
  146435. };
  146436. cap?: number;
  146437. arc?: number;
  146438. updatable?: boolean;
  146439. sideOrientation?: number;
  146440. frontUVs?: Vector4;
  146441. backUVs?: Vector4;
  146442. instance?: Mesh;
  146443. invertUV?: boolean;
  146444. }, scene?: Nullable<Scene>): Mesh;
  146445. }
  146446. }
  146447. declare module BABYLON {
  146448. /**
  146449. * Class containing static functions to help procedurally build meshes
  146450. */
  146451. export class IcoSphereBuilder {
  146452. /**
  146453. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146454. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146455. * * 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`)
  146456. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146457. * * 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
  146458. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146459. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146460. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146461. * @param name defines the name of the mesh
  146462. * @param options defines the options used to create the mesh
  146463. * @param scene defines the hosting scene
  146464. * @returns the icosahedron mesh
  146465. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146466. */
  146467. static CreateIcoSphere(name: string, options: {
  146468. radius?: number;
  146469. radiusX?: number;
  146470. radiusY?: number;
  146471. radiusZ?: number;
  146472. flat?: boolean;
  146473. subdivisions?: number;
  146474. sideOrientation?: number;
  146475. frontUVs?: Vector4;
  146476. backUVs?: Vector4;
  146477. updatable?: boolean;
  146478. }, scene?: Nullable<Scene>): Mesh;
  146479. }
  146480. }
  146481. declare module BABYLON {
  146482. /**
  146483. * Class containing static functions to help procedurally build meshes
  146484. */
  146485. export class DecalBuilder {
  146486. /**
  146487. * Creates a decal mesh.
  146488. * 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
  146489. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  146490. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  146491. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  146492. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  146493. * @param name defines the name of the mesh
  146494. * @param sourceMesh defines the mesh where the decal must be applied
  146495. * @param options defines the options used to create the mesh
  146496. * @param scene defines the hosting scene
  146497. * @returns the decal mesh
  146498. * @see https://doc.babylonjs.com/how_to/decals
  146499. */
  146500. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  146501. position?: Vector3;
  146502. normal?: Vector3;
  146503. size?: Vector3;
  146504. angle?: number;
  146505. }): Mesh;
  146506. }
  146507. }
  146508. declare module BABYLON {
  146509. /**
  146510. * Class containing static functions to help procedurally build meshes
  146511. */
  146512. export class MeshBuilder {
  146513. /**
  146514. * Creates a box mesh
  146515. * * The parameter `size` sets the size (float) of each box side (default 1)
  146516. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  146517. * * 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)
  146518. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  146519. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146520. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146521. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146522. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  146523. * @param name defines the name of the mesh
  146524. * @param options defines the options used to create the mesh
  146525. * @param scene defines the hosting scene
  146526. * @returns the box mesh
  146527. */
  146528. static CreateBox(name: string, options: {
  146529. size?: number;
  146530. width?: number;
  146531. height?: number;
  146532. depth?: number;
  146533. faceUV?: Vector4[];
  146534. faceColors?: Color4[];
  146535. sideOrientation?: number;
  146536. frontUVs?: Vector4;
  146537. backUVs?: Vector4;
  146538. wrap?: boolean;
  146539. topBaseAt?: number;
  146540. bottomBaseAt?: number;
  146541. updatable?: boolean;
  146542. }, scene?: Nullable<Scene>): Mesh;
  146543. /**
  146544. * Creates a tiled box mesh
  146545. * * faceTiles sets the pattern, tile size and number of tiles for a face
  146546. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146547. * @param name defines the name of the mesh
  146548. * @param options defines the options used to create the mesh
  146549. * @param scene defines the hosting scene
  146550. * @returns the tiled box mesh
  146551. */
  146552. static CreateTiledBox(name: string, options: {
  146553. pattern?: number;
  146554. size?: number;
  146555. width?: number;
  146556. height?: number;
  146557. depth: number;
  146558. tileSize?: number;
  146559. tileWidth?: number;
  146560. tileHeight?: number;
  146561. faceUV?: Vector4[];
  146562. faceColors?: Color4[];
  146563. alignHorizontal?: number;
  146564. alignVertical?: number;
  146565. sideOrientation?: number;
  146566. updatable?: boolean;
  146567. }, scene?: Nullable<Scene>): Mesh;
  146568. /**
  146569. * Creates a sphere mesh
  146570. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  146571. * * 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`)
  146572. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  146573. * * 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
  146574. * * 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)
  146575. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146576. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146577. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146578. * @param name defines the name of the mesh
  146579. * @param options defines the options used to create the mesh
  146580. * @param scene defines the hosting scene
  146581. * @returns the sphere mesh
  146582. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  146583. */
  146584. static CreateSphere(name: string, options: {
  146585. segments?: number;
  146586. diameter?: number;
  146587. diameterX?: number;
  146588. diameterY?: number;
  146589. diameterZ?: number;
  146590. arc?: number;
  146591. slice?: number;
  146592. sideOrientation?: number;
  146593. frontUVs?: Vector4;
  146594. backUVs?: Vector4;
  146595. updatable?: boolean;
  146596. }, scene?: Nullable<Scene>): Mesh;
  146597. /**
  146598. * Creates a plane polygonal mesh. By default, this is a disc
  146599. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  146600. * * 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
  146601. * * 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
  146602. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146603. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146604. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146605. * @param name defines the name of the mesh
  146606. * @param options defines the options used to create the mesh
  146607. * @param scene defines the hosting scene
  146608. * @returns the plane polygonal mesh
  146609. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  146610. */
  146611. static CreateDisc(name: string, options: {
  146612. radius?: number;
  146613. tessellation?: number;
  146614. arc?: number;
  146615. updatable?: boolean;
  146616. sideOrientation?: number;
  146617. frontUVs?: Vector4;
  146618. backUVs?: Vector4;
  146619. }, scene?: Nullable<Scene>): Mesh;
  146620. /**
  146621. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  146622. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  146623. * * 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`)
  146624. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  146625. * * 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
  146626. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146627. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146628. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146629. * @param name defines the name of the mesh
  146630. * @param options defines the options used to create the mesh
  146631. * @param scene defines the hosting scene
  146632. * @returns the icosahedron mesh
  146633. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  146634. */
  146635. static CreateIcoSphere(name: string, options: {
  146636. radius?: number;
  146637. radiusX?: number;
  146638. radiusY?: number;
  146639. radiusZ?: number;
  146640. flat?: boolean;
  146641. subdivisions?: number;
  146642. sideOrientation?: number;
  146643. frontUVs?: Vector4;
  146644. backUVs?: Vector4;
  146645. updatable?: boolean;
  146646. }, scene?: Nullable<Scene>): Mesh;
  146647. /**
  146648. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  146649. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  146650. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  146651. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  146652. * * 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
  146653. * * 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
  146654. * * 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
  146655. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146656. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146657. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146658. * * 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
  146659. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  146660. * * 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
  146661. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  146662. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146663. * @param name defines the name of the mesh
  146664. * @param options defines the options used to create the mesh
  146665. * @param scene defines the hosting scene
  146666. * @returns the ribbon mesh
  146667. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  146668. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146669. */
  146670. static CreateRibbon(name: string, options: {
  146671. pathArray: Vector3[][];
  146672. closeArray?: boolean;
  146673. closePath?: boolean;
  146674. offset?: number;
  146675. updatable?: boolean;
  146676. sideOrientation?: number;
  146677. frontUVs?: Vector4;
  146678. backUVs?: Vector4;
  146679. instance?: Mesh;
  146680. invertUV?: boolean;
  146681. uvs?: Vector2[];
  146682. colors?: Color4[];
  146683. }, scene?: Nullable<Scene>): Mesh;
  146684. /**
  146685. * Creates a cylinder or a cone mesh
  146686. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  146687. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  146688. * * 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.
  146689. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  146690. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  146691. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  146692. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  146693. * * 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).
  146694. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  146695. * * 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).
  146696. * * 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
  146697. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  146698. * * 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
  146699. * * 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.
  146700. * * If `enclose` is false, a ring surface is one element.
  146701. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  146702. * * 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
  146703. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146704. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146705. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146706. * @param name defines the name of the mesh
  146707. * @param options defines the options used to create the mesh
  146708. * @param scene defines the hosting scene
  146709. * @returns the cylinder mesh
  146710. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  146711. */
  146712. static CreateCylinder(name: string, options: {
  146713. height?: number;
  146714. diameterTop?: number;
  146715. diameterBottom?: number;
  146716. diameter?: number;
  146717. tessellation?: number;
  146718. subdivisions?: number;
  146719. arc?: number;
  146720. faceColors?: Color4[];
  146721. faceUV?: Vector4[];
  146722. updatable?: boolean;
  146723. hasRings?: boolean;
  146724. enclose?: boolean;
  146725. cap?: number;
  146726. sideOrientation?: number;
  146727. frontUVs?: Vector4;
  146728. backUVs?: Vector4;
  146729. }, scene?: Nullable<Scene>): Mesh;
  146730. /**
  146731. * Creates a torus mesh
  146732. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  146733. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  146734. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  146735. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146736. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146737. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146738. * @param name defines the name of the mesh
  146739. * @param options defines the options used to create the mesh
  146740. * @param scene defines the hosting scene
  146741. * @returns the torus mesh
  146742. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  146743. */
  146744. static CreateTorus(name: string, options: {
  146745. diameter?: number;
  146746. thickness?: number;
  146747. tessellation?: number;
  146748. updatable?: boolean;
  146749. sideOrientation?: number;
  146750. frontUVs?: Vector4;
  146751. backUVs?: Vector4;
  146752. }, scene?: Nullable<Scene>): Mesh;
  146753. /**
  146754. * Creates a torus knot mesh
  146755. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  146756. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  146757. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  146758. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  146759. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146760. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146761. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146762. * @param name defines the name of the mesh
  146763. * @param options defines the options used to create the mesh
  146764. * @param scene defines the hosting scene
  146765. * @returns the torus knot mesh
  146766. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  146767. */
  146768. static CreateTorusKnot(name: string, options: {
  146769. radius?: number;
  146770. tube?: number;
  146771. radialSegments?: number;
  146772. tubularSegments?: number;
  146773. p?: number;
  146774. q?: number;
  146775. updatable?: boolean;
  146776. sideOrientation?: number;
  146777. frontUVs?: Vector4;
  146778. backUVs?: Vector4;
  146779. }, scene?: Nullable<Scene>): Mesh;
  146780. /**
  146781. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  146782. * * 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
  146783. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  146784. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  146785. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  146786. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  146787. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  146788. * * 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
  146789. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  146790. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146791. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  146792. * @param name defines the name of the new line system
  146793. * @param options defines the options used to create the line system
  146794. * @param scene defines the hosting scene
  146795. * @returns a new line system mesh
  146796. */
  146797. static CreateLineSystem(name: string, options: {
  146798. lines: Vector3[][];
  146799. updatable?: boolean;
  146800. instance?: Nullable<LinesMesh>;
  146801. colors?: Nullable<Color4[][]>;
  146802. useVertexAlpha?: boolean;
  146803. }, scene: Nullable<Scene>): LinesMesh;
  146804. /**
  146805. * Creates a line mesh
  146806. * 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
  146807. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146808. * * The parameter `points` is an array successive Vector3
  146809. * * 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
  146810. * * The optional parameter `colors` is an array of successive Color4, one per line point
  146811. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  146812. * * When updating an instance, remember that only point positions can change, not the number of points
  146813. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146814. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  146815. * @param name defines the name of the new line system
  146816. * @param options defines the options used to create the line system
  146817. * @param scene defines the hosting scene
  146818. * @returns a new line mesh
  146819. */
  146820. static CreateLines(name: string, options: {
  146821. points: Vector3[];
  146822. updatable?: boolean;
  146823. instance?: Nullable<LinesMesh>;
  146824. colors?: Color4[];
  146825. useVertexAlpha?: boolean;
  146826. }, scene?: Nullable<Scene>): LinesMesh;
  146827. /**
  146828. * Creates a dashed line mesh
  146829. * * 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
  146830. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  146831. * * The parameter `points` is an array successive Vector3
  146832. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  146833. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  146834. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  146835. * * 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
  146836. * * When updating an instance, remember that only point positions can change, not the number of points
  146837. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146838. * @param name defines the name of the mesh
  146839. * @param options defines the options used to create the mesh
  146840. * @param scene defines the hosting scene
  146841. * @returns the dashed line mesh
  146842. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  146843. */
  146844. static CreateDashedLines(name: string, options: {
  146845. points: Vector3[];
  146846. dashSize?: number;
  146847. gapSize?: number;
  146848. dashNb?: number;
  146849. updatable?: boolean;
  146850. instance?: LinesMesh;
  146851. }, scene?: Nullable<Scene>): LinesMesh;
  146852. /**
  146853. * 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.
  146854. * * 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.
  146855. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146856. * * 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.
  146857. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  146858. * * 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
  146859. * * 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
  146860. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  146861. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146862. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146863. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  146864. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  146865. * @param name defines the name of the mesh
  146866. * @param options defines the options used to create the mesh
  146867. * @param scene defines the hosting scene
  146868. * @returns the extruded shape mesh
  146869. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146870. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146871. */
  146872. static ExtrudeShape(name: string, options: {
  146873. shape: Vector3[];
  146874. path: Vector3[];
  146875. scale?: number;
  146876. rotation?: number;
  146877. cap?: number;
  146878. updatable?: boolean;
  146879. sideOrientation?: number;
  146880. frontUVs?: Vector4;
  146881. backUVs?: Vector4;
  146882. instance?: Mesh;
  146883. invertUV?: boolean;
  146884. }, scene?: Nullable<Scene>): Mesh;
  146885. /**
  146886. * Creates an custom extruded shape mesh.
  146887. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  146888. * * 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.
  146889. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  146890. * * 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
  146891. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  146892. * * 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
  146893. * * It must returns a float value that will be the scale value applied to the shape on each path point
  146894. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  146895. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  146896. * * 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
  146897. * * 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
  146898. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  146899. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146900. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146901. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146902. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146903. * @param name defines the name of the mesh
  146904. * @param options defines the options used to create the mesh
  146905. * @param scene defines the hosting scene
  146906. * @returns the custom extruded shape mesh
  146907. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  146908. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  146909. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  146910. */
  146911. static ExtrudeShapeCustom(name: string, options: {
  146912. shape: Vector3[];
  146913. path: Vector3[];
  146914. scaleFunction?: any;
  146915. rotationFunction?: any;
  146916. ribbonCloseArray?: boolean;
  146917. ribbonClosePath?: boolean;
  146918. cap?: number;
  146919. updatable?: boolean;
  146920. sideOrientation?: number;
  146921. frontUVs?: Vector4;
  146922. backUVs?: Vector4;
  146923. instance?: Mesh;
  146924. invertUV?: boolean;
  146925. }, scene?: Nullable<Scene>): Mesh;
  146926. /**
  146927. * Creates lathe mesh.
  146928. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  146929. * * 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
  146930. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  146931. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  146932. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  146933. * * 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
  146934. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  146935. * * 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
  146936. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146937. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146938. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  146939. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146940. * @param name defines the name of the mesh
  146941. * @param options defines the options used to create the mesh
  146942. * @param scene defines the hosting scene
  146943. * @returns the lathe mesh
  146944. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  146945. */
  146946. static CreateLathe(name: string, options: {
  146947. shape: Vector3[];
  146948. radius?: number;
  146949. tessellation?: number;
  146950. clip?: number;
  146951. arc?: number;
  146952. closed?: boolean;
  146953. updatable?: boolean;
  146954. sideOrientation?: number;
  146955. frontUVs?: Vector4;
  146956. backUVs?: Vector4;
  146957. cap?: number;
  146958. invertUV?: boolean;
  146959. }, scene?: Nullable<Scene>): Mesh;
  146960. /**
  146961. * Creates a tiled plane mesh
  146962. * * You can set a limited pattern arrangement with the tiles
  146963. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146964. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146965. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146966. * @param name defines the name of the mesh
  146967. * @param options defines the options used to create the mesh
  146968. * @param scene defines the hosting scene
  146969. * @returns the plane mesh
  146970. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  146971. */
  146972. static CreateTiledPlane(name: string, options: {
  146973. pattern?: number;
  146974. tileSize?: number;
  146975. tileWidth?: number;
  146976. tileHeight?: number;
  146977. size?: number;
  146978. width?: number;
  146979. height?: number;
  146980. alignHorizontal?: number;
  146981. alignVertical?: number;
  146982. sideOrientation?: number;
  146983. frontUVs?: Vector4;
  146984. backUVs?: Vector4;
  146985. updatable?: boolean;
  146986. }, scene?: Nullable<Scene>): Mesh;
  146987. /**
  146988. * Creates a plane mesh
  146989. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  146990. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  146991. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  146992. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  146993. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  146994. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  146995. * @param name defines the name of the mesh
  146996. * @param options defines the options used to create the mesh
  146997. * @param scene defines the hosting scene
  146998. * @returns the plane mesh
  146999. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  147000. */
  147001. static CreatePlane(name: string, options: {
  147002. size?: number;
  147003. width?: number;
  147004. height?: number;
  147005. sideOrientation?: number;
  147006. frontUVs?: Vector4;
  147007. backUVs?: Vector4;
  147008. updatable?: boolean;
  147009. sourcePlane?: Plane;
  147010. }, scene?: Nullable<Scene>): Mesh;
  147011. /**
  147012. * Creates a ground mesh
  147013. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  147014. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  147015. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147016. * @param name defines the name of the mesh
  147017. * @param options defines the options used to create the mesh
  147018. * @param scene defines the hosting scene
  147019. * @returns the ground mesh
  147020. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  147021. */
  147022. static CreateGround(name: string, options: {
  147023. width?: number;
  147024. height?: number;
  147025. subdivisions?: number;
  147026. subdivisionsX?: number;
  147027. subdivisionsY?: number;
  147028. updatable?: boolean;
  147029. }, scene?: Nullable<Scene>): Mesh;
  147030. /**
  147031. * Creates a tiled ground mesh
  147032. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  147033. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  147034. * * 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
  147035. * * 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
  147036. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147037. * @param name defines the name of the mesh
  147038. * @param options defines the options used to create the mesh
  147039. * @param scene defines the hosting scene
  147040. * @returns the tiled ground mesh
  147041. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  147042. */
  147043. static CreateTiledGround(name: string, options: {
  147044. xmin: number;
  147045. zmin: number;
  147046. xmax: number;
  147047. zmax: number;
  147048. subdivisions?: {
  147049. w: number;
  147050. h: number;
  147051. };
  147052. precision?: {
  147053. w: number;
  147054. h: number;
  147055. };
  147056. updatable?: boolean;
  147057. }, scene?: Nullable<Scene>): Mesh;
  147058. /**
  147059. * Creates a ground mesh from a height map
  147060. * * The parameter `url` sets the URL of the height map image resource.
  147061. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  147062. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  147063. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  147064. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  147065. * * 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.
  147066. * * 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).
  147067. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  147068. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  147069. * @param name defines the name of the mesh
  147070. * @param url defines the url to the height map
  147071. * @param options defines the options used to create the mesh
  147072. * @param scene defines the hosting scene
  147073. * @returns the ground mesh
  147074. * @see https://doc.babylonjs.com/babylon101/height_map
  147075. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  147076. */
  147077. static CreateGroundFromHeightMap(name: string, url: string, options: {
  147078. width?: number;
  147079. height?: number;
  147080. subdivisions?: number;
  147081. minHeight?: number;
  147082. maxHeight?: number;
  147083. colorFilter?: Color3;
  147084. alphaFilter?: number;
  147085. updatable?: boolean;
  147086. onReady?: (mesh: GroundMesh) => void;
  147087. }, scene?: Nullable<Scene>): GroundMesh;
  147088. /**
  147089. * Creates a polygon mesh
  147090. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  147091. * * 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
  147092. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  147093. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147094. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4)
  147095. * * Remember you can only change the shape positions, not their number when updating a polygon
  147096. * @param name defines the name of the mesh
  147097. * @param options defines the options used to create the mesh
  147098. * @param scene defines the hosting scene
  147099. * @param earcutInjection can be used to inject your own earcut reference
  147100. * @returns the polygon mesh
  147101. */
  147102. static CreatePolygon(name: string, options: {
  147103. shape: Vector3[];
  147104. holes?: Vector3[][];
  147105. depth?: number;
  147106. faceUV?: Vector4[];
  147107. faceColors?: Color4[];
  147108. updatable?: boolean;
  147109. sideOrientation?: number;
  147110. frontUVs?: Vector4;
  147111. backUVs?: Vector4;
  147112. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147113. /**
  147114. * Creates an extruded polygon mesh, with depth in the Y direction.
  147115. * * 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)
  147116. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  147117. * @param name defines the name of the mesh
  147118. * @param options defines the options used to create the mesh
  147119. * @param scene defines the hosting scene
  147120. * @param earcutInjection can be used to inject your own earcut reference
  147121. * @returns the polygon mesh
  147122. */
  147123. static ExtrudePolygon(name: string, options: {
  147124. shape: Vector3[];
  147125. holes?: Vector3[][];
  147126. depth?: number;
  147127. faceUV?: Vector4[];
  147128. faceColors?: Color4[];
  147129. updatable?: boolean;
  147130. sideOrientation?: number;
  147131. frontUVs?: Vector4;
  147132. backUVs?: Vector4;
  147133. wrap?: boolean;
  147134. }, scene?: Nullable<Scene>, earcutInjection?: any): Mesh;
  147135. /**
  147136. * Creates a tube mesh.
  147137. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  147138. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  147139. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  147140. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  147141. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  147142. * * 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)
  147143. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  147144. * * 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
  147145. * * 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
  147146. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147147. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147148. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  147149. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147150. * @param name defines the name of the mesh
  147151. * @param options defines the options used to create the mesh
  147152. * @param scene defines the hosting scene
  147153. * @returns the tube mesh
  147154. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  147155. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  147156. */
  147157. static CreateTube(name: string, options: {
  147158. path: Vector3[];
  147159. radius?: number;
  147160. tessellation?: number;
  147161. radiusFunction?: {
  147162. (i: number, distance: number): number;
  147163. };
  147164. cap?: number;
  147165. arc?: number;
  147166. updatable?: boolean;
  147167. sideOrientation?: number;
  147168. frontUVs?: Vector4;
  147169. backUVs?: Vector4;
  147170. instance?: Mesh;
  147171. invertUV?: boolean;
  147172. }, scene?: Nullable<Scene>): Mesh;
  147173. /**
  147174. * Creates a polyhedron mesh
  147175. * * 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
  147176. * * The parameter `size` (positive float, default 1) sets the polygon size
  147177. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  147178. * * 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`
  147179. * * 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
  147180. * * 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)`)
  147181. * * 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
  147182. * * 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
  147183. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  147184. * * If you create a double-sided mesh, you can choose what parts of the texture image to crop and stick respectively on the front and the back sides with the parameters `frontUVs` and `backUVs` (Vector4). Detail here : https://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation
  147185. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  147186. * @param name defines the name of the mesh
  147187. * @param options defines the options used to create the mesh
  147188. * @param scene defines the hosting scene
  147189. * @returns the polyhedron mesh
  147190. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  147191. */
  147192. static CreatePolyhedron(name: string, options: {
  147193. type?: number;
  147194. size?: number;
  147195. sizeX?: number;
  147196. sizeY?: number;
  147197. sizeZ?: number;
  147198. custom?: any;
  147199. faceUV?: Vector4[];
  147200. faceColors?: Color4[];
  147201. flat?: boolean;
  147202. updatable?: boolean;
  147203. sideOrientation?: number;
  147204. frontUVs?: Vector4;
  147205. backUVs?: Vector4;
  147206. }, scene?: Nullable<Scene>): Mesh;
  147207. /**
  147208. * Creates a decal mesh.
  147209. * 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
  147210. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  147211. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  147212. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  147213. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  147214. * @param name defines the name of the mesh
  147215. * @param sourceMesh defines the mesh where the decal must be applied
  147216. * @param options defines the options used to create the mesh
  147217. * @param scene defines the hosting scene
  147218. * @returns the decal mesh
  147219. * @see https://doc.babylonjs.com/how_to/decals
  147220. */
  147221. static CreateDecal(name: string, sourceMesh: AbstractMesh, options: {
  147222. position?: Vector3;
  147223. normal?: Vector3;
  147224. size?: Vector3;
  147225. angle?: number;
  147226. }): Mesh;
  147227. /**
  147228. * Creates a Capsule Mesh
  147229. * @param name defines the name of the mesh.
  147230. * @param options the constructors options used to shape the mesh.
  147231. * @param scene defines the scene the mesh is scoped to.
  147232. * @returns the capsule mesh
  147233. * @see https://doc.babylonjs.com/how_to/capsule_shape
  147234. */
  147235. static CreateCapsule(name: string, options?: ICreateCapsuleOptions, scene?: Nullable<Scene>): Mesh;
  147236. }
  147237. }
  147238. declare module BABYLON {
  147239. /**
  147240. * A simplifier interface for future simplification implementations
  147241. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147242. */
  147243. export interface ISimplifier {
  147244. /**
  147245. * Simplification of a given mesh according to the given settings.
  147246. * Since this requires computation, it is assumed that the function runs async.
  147247. * @param settings The settings of the simplification, including quality and distance
  147248. * @param successCallback A callback that will be called after the mesh was simplified.
  147249. * @param errorCallback in case of an error, this callback will be called. optional.
  147250. */
  147251. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMeshes: Mesh) => void, errorCallback?: () => void): void;
  147252. }
  147253. /**
  147254. * Expected simplification settings.
  147255. * Quality should be between 0 and 1 (1 being 100%, 0 being 0%)
  147256. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147257. */
  147258. export interface ISimplificationSettings {
  147259. /**
  147260. * Gets or sets the expected quality
  147261. */
  147262. quality: number;
  147263. /**
  147264. * Gets or sets the distance when this optimized version should be used
  147265. */
  147266. distance: number;
  147267. /**
  147268. * Gets an already optimized mesh
  147269. */
  147270. optimizeMesh?: boolean;
  147271. }
  147272. /**
  147273. * Class used to specify simplification options
  147274. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147275. */
  147276. export class SimplificationSettings implements ISimplificationSettings {
  147277. /** expected quality */
  147278. quality: number;
  147279. /** distance when this optimized version should be used */
  147280. distance: number;
  147281. /** already optimized mesh */
  147282. optimizeMesh?: boolean | undefined;
  147283. /**
  147284. * Creates a SimplificationSettings
  147285. * @param quality expected quality
  147286. * @param distance distance when this optimized version should be used
  147287. * @param optimizeMesh already optimized mesh
  147288. */
  147289. constructor(
  147290. /** expected quality */
  147291. quality: number,
  147292. /** distance when this optimized version should be used */
  147293. distance: number,
  147294. /** already optimized mesh */
  147295. optimizeMesh?: boolean | undefined);
  147296. }
  147297. /**
  147298. * Interface used to define a simplification task
  147299. */
  147300. export interface ISimplificationTask {
  147301. /**
  147302. * Array of settings
  147303. */
  147304. settings: Array<ISimplificationSettings>;
  147305. /**
  147306. * Simplification type
  147307. */
  147308. simplificationType: SimplificationType;
  147309. /**
  147310. * Mesh to simplify
  147311. */
  147312. mesh: Mesh;
  147313. /**
  147314. * Callback called on success
  147315. */
  147316. successCallback?: () => void;
  147317. /**
  147318. * Defines if parallel processing can be used
  147319. */
  147320. parallelProcessing: boolean;
  147321. }
  147322. /**
  147323. * Queue used to order the simplification tasks
  147324. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147325. */
  147326. export class SimplificationQueue {
  147327. private _simplificationArray;
  147328. /**
  147329. * Gets a boolean indicating that the process is still running
  147330. */
  147331. running: boolean;
  147332. /**
  147333. * Creates a new queue
  147334. */
  147335. constructor();
  147336. /**
  147337. * Adds a new simplification task
  147338. * @param task defines a task to add
  147339. */
  147340. addTask(task: ISimplificationTask): void;
  147341. /**
  147342. * Execute next task
  147343. */
  147344. executeNext(): void;
  147345. /**
  147346. * Execute a simplification task
  147347. * @param task defines the task to run
  147348. */
  147349. runSimplification(task: ISimplificationTask): void;
  147350. private getSimplifier;
  147351. }
  147352. /**
  147353. * The implemented types of simplification
  147354. * At the moment only Quadratic Error Decimation is implemented
  147355. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147356. */
  147357. export enum SimplificationType {
  147358. /** Quadratic error decimation */
  147359. QUADRATIC = 0
  147360. }
  147361. /**
  147362. * An implementation of the Quadratic Error simplification algorithm.
  147363. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  147364. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  147365. * @author RaananW
  147366. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147367. */
  147368. export class QuadraticErrorSimplification implements ISimplifier {
  147369. private _mesh;
  147370. private triangles;
  147371. private vertices;
  147372. private references;
  147373. private _reconstructedMesh;
  147374. /** Gets or sets the number pf sync interations */
  147375. syncIterations: number;
  147376. /** Gets or sets the aggressiveness of the simplifier */
  147377. aggressiveness: number;
  147378. /** Gets or sets the number of allowed iterations for decimation */
  147379. decimationIterations: number;
  147380. /** Gets or sets the espilon to use for bounding box computation */
  147381. boundingBoxEpsilon: number;
  147382. /**
  147383. * Creates a new QuadraticErrorSimplification
  147384. * @param _mesh defines the target mesh
  147385. */
  147386. constructor(_mesh: Mesh);
  147387. /**
  147388. * Simplification of a given mesh according to the given settings.
  147389. * Since this requires computation, it is assumed that the function runs async.
  147390. * @param settings The settings of the simplification, including quality and distance
  147391. * @param successCallback A callback that will be called after the mesh was simplified.
  147392. */
  147393. simplify(settings: ISimplificationSettings, successCallback: (simplifiedMesh: Mesh) => void): void;
  147394. private runDecimation;
  147395. private initWithMesh;
  147396. private init;
  147397. private reconstructMesh;
  147398. private initDecimatedMesh;
  147399. private isFlipped;
  147400. private updateTriangles;
  147401. private identifyBorder;
  147402. private updateMesh;
  147403. private vertexError;
  147404. private calculateError;
  147405. }
  147406. }
  147407. declare module BABYLON {
  147408. interface Scene {
  147409. /** @hidden (Backing field) */
  147410. _simplificationQueue: SimplificationQueue;
  147411. /**
  147412. * Gets or sets the simplification queue attached to the scene
  147413. * @see https://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  147414. */
  147415. simplificationQueue: SimplificationQueue;
  147416. }
  147417. interface Mesh {
  147418. /**
  147419. * Simplify the mesh according to the given array of settings.
  147420. * Function will return immediately and will simplify async
  147421. * @param settings a collection of simplification settings
  147422. * @param parallelProcessing should all levels calculate parallel or one after the other
  147423. * @param simplificationType the type of simplification to run
  147424. * @param successCallback optional success callback to be called after the simplification finished processing all settings
  147425. * @returns the current mesh
  147426. */
  147427. simplify(settings: Array<ISimplificationSettings>, parallelProcessing?: boolean, simplificationType?: SimplificationType, successCallback?: (mesh?: Mesh, submeshIndex?: number) => void): Mesh;
  147428. }
  147429. /**
  147430. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  147431. * created in a scene
  147432. */
  147433. export class SimplicationQueueSceneComponent implements ISceneComponent {
  147434. /**
  147435. * The component name helpfull to identify the component in the list of scene components.
  147436. */
  147437. readonly name: string;
  147438. /**
  147439. * The scene the component belongs to.
  147440. */
  147441. scene: Scene;
  147442. /**
  147443. * Creates a new instance of the component for the given scene
  147444. * @param scene Defines the scene to register the component in
  147445. */
  147446. constructor(scene: Scene);
  147447. /**
  147448. * Registers the component in a given scene
  147449. */
  147450. register(): void;
  147451. /**
  147452. * Rebuilds the elements related to this component in case of
  147453. * context lost for instance.
  147454. */
  147455. rebuild(): void;
  147456. /**
  147457. * Disposes the component and the associated ressources
  147458. */
  147459. dispose(): void;
  147460. private _beforeCameraUpdate;
  147461. }
  147462. }
  147463. declare module BABYLON {
  147464. interface Mesh {
  147465. /**
  147466. * Gets or sets a boolean defining if we want picking to pick thin instances as well
  147467. */
  147468. thinInstanceEnablePicking: boolean;
  147469. /**
  147470. * Creates a new thin instance
  147471. * @param matrix the matrix or array of matrices (position, rotation, scale) of the thin instance(s) to create
  147472. * @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
  147473. * @returns the thin instance index number. If you pass an array of matrices, other instance indexes are index+1, index+2, etc
  147474. */
  147475. thinInstanceAdd(matrix: DeepImmutableObject<Matrix> | Array<DeepImmutableObject<Matrix>>, refresh: boolean): number;
  147476. /**
  147477. * Adds the transformation (matrix) of the current mesh as a thin instance
  147478. * @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
  147479. * @returns the thin instance index number
  147480. */
  147481. thinInstanceAddSelf(refresh: boolean): number;
  147482. /**
  147483. * Registers a custom attribute to be used with thin instances
  147484. * @param kind name of the attribute
  147485. * @param stride size in floats of the attribute
  147486. */
  147487. thinInstanceRegisterAttribute(kind: string, stride: number): void;
  147488. /**
  147489. * Sets the matrix of a thin instance
  147490. * @param index index of the thin instance
  147491. * @param matrix matrix to set
  147492. * @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
  147493. */
  147494. thinInstanceSetMatrixAt(index: number, matrix: DeepImmutableObject<Matrix>, refresh: boolean): void;
  147495. /**
  147496. * Sets the value of a custom attribute for a thin instance
  147497. * @param kind name of the attribute
  147498. * @param index index of the thin instance
  147499. * @param value value to set
  147500. * @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
  147501. */
  147502. thinInstanceSetAttributeAt(kind: string, index: number, value: Array<number>, refresh: boolean): void;
  147503. /**
  147504. * 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.
  147505. */
  147506. thinInstanceCount: number;
  147507. /**
  147508. * Sets a buffer to be used with thin instances. This method is a faster way to setup multiple instances than calling thinInstanceAdd repeatedly
  147509. * @param kind name of the attribute. Use "matrix" to setup the buffer of matrices
  147510. * @param buffer buffer to set
  147511. * @param stride size in floats of each value of the buffer
  147512. * @param staticBuffer indicates that the buffer is static, so that you won't change it after it is set (better performances - false by default)
  147513. */
  147514. thinInstanceSetBuffer(kind: string, buffer: Nullable<Float32Array>, stride: number, staticBuffer: boolean): void;
  147515. /**
  147516. * Gets the list of world matrices
  147517. * @return an array containing all the world matrices from the thin instances
  147518. */
  147519. thinInstanceGetWorldMatrices(): Matrix[];
  147520. /**
  147521. * Synchronize the gpu buffers with a thin instance buffer. Call this method if you update later on the buffers passed to thinInstanceSetBuffer
  147522. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147523. */
  147524. thinInstanceBufferUpdated(kind: string): void;
  147525. /**
  147526. * Applies a partial update to a buffer directly on the GPU
  147527. * 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
  147528. * @param kind name of the attribute to update. Use "matrix" to update the buffer of matrices
  147529. * @param data the data to set in the GPU buffer
  147530. * @param offset the offset in the GPU buffer where to update the data
  147531. */
  147532. thinInstancePartialBufferUpdate(kind: string, data: Float32Array, offset: number): void;
  147533. /**
  147534. * Refreshes the bounding info, taking into account all the thin instances defined
  147535. * @param forceRefreshParentInfo true to force recomputing the mesh bounding info and use it to compute the aggregated bounding info
  147536. */
  147537. thinInstanceRefreshBoundingInfo(forceRefreshParentInfo: boolean): void;
  147538. /** @hidden */
  147539. _thinInstanceInitializeUserStorage(): void;
  147540. /** @hidden */
  147541. _thinInstanceUpdateBufferSize(kind: string, numInstances: number): void;
  147542. /** @hidden */
  147543. _userThinInstanceBuffersStorage: {
  147544. data: {
  147545. [key: string]: Float32Array;
  147546. };
  147547. sizes: {
  147548. [key: string]: number;
  147549. };
  147550. vertexBuffers: {
  147551. [key: string]: Nullable<VertexBuffer>;
  147552. };
  147553. strides: {
  147554. [key: string]: number;
  147555. };
  147556. };
  147557. }
  147558. }
  147559. declare module BABYLON {
  147560. /**
  147561. * Navigation plugin interface to add navigation constrained by a navigation mesh
  147562. */
  147563. export interface INavigationEnginePlugin {
  147564. /**
  147565. * plugin name
  147566. */
  147567. name: string;
  147568. /**
  147569. * Creates a navigation mesh
  147570. * @param meshes array of all the geometry used to compute the navigatio mesh
  147571. * @param parameters bunch of parameters used to filter geometry
  147572. */
  147573. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147574. /**
  147575. * Create a navigation mesh debug mesh
  147576. * @param scene is where the mesh will be added
  147577. * @returns debug display mesh
  147578. */
  147579. createDebugNavMesh(scene: Scene): Mesh;
  147580. /**
  147581. * Get a navigation mesh constrained position, closest to the parameter position
  147582. * @param position world position
  147583. * @returns the closest point to position constrained by the navigation mesh
  147584. */
  147585. getClosestPoint(position: Vector3): Vector3;
  147586. /**
  147587. * Get a navigation mesh constrained position, closest to the parameter position
  147588. * @param position world position
  147589. * @param result output the closest point to position constrained by the navigation mesh
  147590. */
  147591. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147592. /**
  147593. * Get a navigation mesh constrained position, within a particular radius
  147594. * @param position world position
  147595. * @param maxRadius the maximum distance to the constrained world position
  147596. * @returns the closest point to position constrained by the navigation mesh
  147597. */
  147598. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147599. /**
  147600. * Get a navigation mesh constrained position, within a particular radius
  147601. * @param position world position
  147602. * @param maxRadius the maximum distance to the constrained world position
  147603. * @param result output the closest point to position constrained by the navigation mesh
  147604. */
  147605. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147606. /**
  147607. * Compute the final position from a segment made of destination-position
  147608. * @param position world position
  147609. * @param destination world position
  147610. * @returns the resulting point along the navmesh
  147611. */
  147612. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147613. /**
  147614. * Compute the final position from a segment made of destination-position
  147615. * @param position world position
  147616. * @param destination world position
  147617. * @param result output the resulting point along the navmesh
  147618. */
  147619. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147620. /**
  147621. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147622. * @param start world position
  147623. * @param end world position
  147624. * @returns array containing world position composing the path
  147625. */
  147626. computePath(start: Vector3, end: Vector3): Vector3[];
  147627. /**
  147628. * If this plugin is supported
  147629. * @returns true if plugin is supported
  147630. */
  147631. isSupported(): boolean;
  147632. /**
  147633. * Create a new Crowd so you can add agents
  147634. * @param maxAgents the maximum agent count in the crowd
  147635. * @param maxAgentRadius the maximum radius an agent can have
  147636. * @param scene to attach the crowd to
  147637. * @returns the crowd you can add agents to
  147638. */
  147639. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147640. /**
  147641. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147642. * The queries will try to find a solution within those bounds
  147643. * default is (1,1,1)
  147644. * @param extent x,y,z value that define the extent around the queries point of reference
  147645. */
  147646. setDefaultQueryExtent(extent: Vector3): void;
  147647. /**
  147648. * Get the Bounding box extent specified by setDefaultQueryExtent
  147649. * @returns the box extent values
  147650. */
  147651. getDefaultQueryExtent(): Vector3;
  147652. /**
  147653. * build the navmesh from a previously saved state using getNavmeshData
  147654. * @param data the Uint8Array returned by getNavmeshData
  147655. */
  147656. buildFromNavmeshData(data: Uint8Array): void;
  147657. /**
  147658. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147659. * @returns data the Uint8Array that can be saved and reused
  147660. */
  147661. getNavmeshData(): Uint8Array;
  147662. /**
  147663. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147664. * @param result output the box extent values
  147665. */
  147666. getDefaultQueryExtentToRef(result: Vector3): void;
  147667. /**
  147668. * Release all resources
  147669. */
  147670. dispose(): void;
  147671. }
  147672. /**
  147673. * Crowd Interface. A Crowd is a collection of moving agents constrained by a navigation mesh
  147674. */
  147675. export interface ICrowd {
  147676. /**
  147677. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  147678. * You can attach anything to that node. The node position is updated in the scene update tick.
  147679. * @param pos world position that will be constrained by the navigation mesh
  147680. * @param parameters agent parameters
  147681. * @param transform hooked to the agent that will be update by the scene
  147682. * @returns agent index
  147683. */
  147684. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  147685. /**
  147686. * Returns the agent position in world space
  147687. * @param index agent index returned by addAgent
  147688. * @returns world space position
  147689. */
  147690. getAgentPosition(index: number): Vector3;
  147691. /**
  147692. * Gets the agent position result in world space
  147693. * @param index agent index returned by addAgent
  147694. * @param result output world space position
  147695. */
  147696. getAgentPositionToRef(index: number, result: Vector3): void;
  147697. /**
  147698. * Gets the agent velocity in world space
  147699. * @param index agent index returned by addAgent
  147700. * @returns world space velocity
  147701. */
  147702. getAgentVelocity(index: number): Vector3;
  147703. /**
  147704. * Gets the agent velocity result in world space
  147705. * @param index agent index returned by addAgent
  147706. * @param result output world space velocity
  147707. */
  147708. getAgentVelocityToRef(index: number, result: Vector3): void;
  147709. /**
  147710. * remove a particular agent previously created
  147711. * @param index agent index returned by addAgent
  147712. */
  147713. removeAgent(index: number): void;
  147714. /**
  147715. * get the list of all agents attached to this crowd
  147716. * @returns list of agent indices
  147717. */
  147718. getAgents(): number[];
  147719. /**
  147720. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  147721. * @param deltaTime in seconds
  147722. */
  147723. update(deltaTime: number): void;
  147724. /**
  147725. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  147726. * @param index agent index returned by addAgent
  147727. * @param destination targeted world position
  147728. */
  147729. agentGoto(index: number, destination: Vector3): void;
  147730. /**
  147731. * Teleport the agent to a new position
  147732. * @param index agent index returned by addAgent
  147733. * @param destination targeted world position
  147734. */
  147735. agentTeleport(index: number, destination: Vector3): void;
  147736. /**
  147737. * Update agent parameters
  147738. * @param index agent index returned by addAgent
  147739. * @param parameters agent parameters
  147740. */
  147741. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  147742. /**
  147743. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147744. * The queries will try to find a solution within those bounds
  147745. * default is (1,1,1)
  147746. * @param extent x,y,z value that define the extent around the queries point of reference
  147747. */
  147748. setDefaultQueryExtent(extent: Vector3): void;
  147749. /**
  147750. * Get the Bounding box extent specified by setDefaultQueryExtent
  147751. * @returns the box extent values
  147752. */
  147753. getDefaultQueryExtent(): Vector3;
  147754. /**
  147755. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147756. * @param result output the box extent values
  147757. */
  147758. getDefaultQueryExtentToRef(result: Vector3): void;
  147759. /**
  147760. * Release all resources
  147761. */
  147762. dispose(): void;
  147763. }
  147764. /**
  147765. * Configures an agent
  147766. */
  147767. export interface IAgentParameters {
  147768. /**
  147769. * Agent radius. [Limit: >= 0]
  147770. */
  147771. radius: number;
  147772. /**
  147773. * Agent height. [Limit: > 0]
  147774. */
  147775. height: number;
  147776. /**
  147777. * Maximum allowed acceleration. [Limit: >= 0]
  147778. */
  147779. maxAcceleration: number;
  147780. /**
  147781. * Maximum allowed speed. [Limit: >= 0]
  147782. */
  147783. maxSpeed: number;
  147784. /**
  147785. * Defines how close a collision element must be before it is considered for steering behaviors. [Limits: > 0]
  147786. */
  147787. collisionQueryRange: number;
  147788. /**
  147789. * The path visibility optimization range. [Limit: > 0]
  147790. */
  147791. pathOptimizationRange: number;
  147792. /**
  147793. * How aggresive the agent manager should be at avoiding collisions with this agent. [Limit: >= 0]
  147794. */
  147795. separationWeight: number;
  147796. }
  147797. /**
  147798. * Configures the navigation mesh creation
  147799. */
  147800. export interface INavMeshParameters {
  147801. /**
  147802. * The xz-plane cell size to use for fields. [Limit: > 0] [Units: wu]
  147803. */
  147804. cs: number;
  147805. /**
  147806. * The y-axis cell size to use for fields. [Limit: > 0] [Units: wu]
  147807. */
  147808. ch: number;
  147809. /**
  147810. * The maximum slope that is considered walkable. [Limits: 0 <= value < 90] [Units: Degrees]
  147811. */
  147812. walkableSlopeAngle: number;
  147813. /**
  147814. * Minimum floor to 'ceiling' height that will still allow the floor area to
  147815. * be considered walkable. [Limit: >= 3] [Units: vx]
  147816. */
  147817. walkableHeight: number;
  147818. /**
  147819. * Maximum ledge height that is considered to still be traversable. [Limit: >=0] [Units: vx]
  147820. */
  147821. walkableClimb: number;
  147822. /**
  147823. * The distance to erode/shrink the walkable area of the heightfield away from
  147824. * obstructions. [Limit: >=0] [Units: vx]
  147825. */
  147826. walkableRadius: number;
  147827. /**
  147828. * The maximum allowed length for contour edges along the border of the mesh. [Limit: >=0] [Units: vx]
  147829. */
  147830. maxEdgeLen: number;
  147831. /**
  147832. * The maximum distance a simplfied contour's border edges should deviate
  147833. * the original raw contour. [Limit: >=0] [Units: vx]
  147834. */
  147835. maxSimplificationError: number;
  147836. /**
  147837. * The minimum number of cells allowed to form isolated island areas. [Limit: >=0] [Units: vx]
  147838. */
  147839. minRegionArea: number;
  147840. /**
  147841. * Any regions with a span count smaller than this value will, if possible,
  147842. * be merged with larger regions. [Limit: >=0] [Units: vx]
  147843. */
  147844. mergeRegionArea: number;
  147845. /**
  147846. * The maximum number of vertices allowed for polygons generated during the
  147847. * contour to polygon conversion process. [Limit: >= 3]
  147848. */
  147849. maxVertsPerPoly: number;
  147850. /**
  147851. * Sets the sampling distance to use when generating the detail mesh.
  147852. * (For height detail only.) [Limits: 0 or >= 0.9] [Units: wu]
  147853. */
  147854. detailSampleDist: number;
  147855. /**
  147856. * The maximum distance the detail mesh surface should deviate from heightfield
  147857. * data. (For height detail only.) [Limit: >=0] [Units: wu]
  147858. */
  147859. detailSampleMaxError: number;
  147860. }
  147861. }
  147862. declare module BABYLON {
  147863. /**
  147864. * RecastJS navigation plugin
  147865. */
  147866. export class RecastJSPlugin implements INavigationEnginePlugin {
  147867. /**
  147868. * Reference to the Recast library
  147869. */
  147870. bjsRECAST: any;
  147871. /**
  147872. * plugin name
  147873. */
  147874. name: string;
  147875. /**
  147876. * the first navmesh created. We might extend this to support multiple navmeshes
  147877. */
  147878. navMesh: any;
  147879. /**
  147880. * Initializes the recastJS plugin
  147881. * @param recastInjection can be used to inject your own recast reference
  147882. */
  147883. constructor(recastInjection?: any);
  147884. /**
  147885. * Creates a navigation mesh
  147886. * @param meshes array of all the geometry used to compute the navigatio mesh
  147887. * @param parameters bunch of parameters used to filter geometry
  147888. */
  147889. createNavMesh(meshes: Array<Mesh>, parameters: INavMeshParameters): void;
  147890. /**
  147891. * Create a navigation mesh debug mesh
  147892. * @param scene is where the mesh will be added
  147893. * @returns debug display mesh
  147894. */
  147895. createDebugNavMesh(scene: Scene): Mesh;
  147896. /**
  147897. * Get a navigation mesh constrained position, closest to the parameter position
  147898. * @param position world position
  147899. * @returns the closest point to position constrained by the navigation mesh
  147900. */
  147901. getClosestPoint(position: Vector3): Vector3;
  147902. /**
  147903. * Get a navigation mesh constrained position, closest to the parameter position
  147904. * @param position world position
  147905. * @param result output the closest point to position constrained by the navigation mesh
  147906. */
  147907. getClosestPointToRef(position: Vector3, result: Vector3): void;
  147908. /**
  147909. * Get a navigation mesh constrained position, within a particular radius
  147910. * @param position world position
  147911. * @param maxRadius the maximum distance to the constrained world position
  147912. * @returns the closest point to position constrained by the navigation mesh
  147913. */
  147914. getRandomPointAround(position: Vector3, maxRadius: number): Vector3;
  147915. /**
  147916. * Get a navigation mesh constrained position, within a particular radius
  147917. * @param position world position
  147918. * @param maxRadius the maximum distance to the constrained world position
  147919. * @param result output the closest point to position constrained by the navigation mesh
  147920. */
  147921. getRandomPointAroundToRef(position: Vector3, maxRadius: number, result: Vector3): void;
  147922. /**
  147923. * Compute the final position from a segment made of destination-position
  147924. * @param position world position
  147925. * @param destination world position
  147926. * @returns the resulting point along the navmesh
  147927. */
  147928. moveAlong(position: Vector3, destination: Vector3): Vector3;
  147929. /**
  147930. * Compute the final position from a segment made of destination-position
  147931. * @param position world position
  147932. * @param destination world position
  147933. * @param result output the resulting point along the navmesh
  147934. */
  147935. moveAlongToRef(position: Vector3, destination: Vector3, result: Vector3): void;
  147936. /**
  147937. * Compute a navigation path from start to end. Returns an empty array if no path can be computed
  147938. * @param start world position
  147939. * @param end world position
  147940. * @returns array containing world position composing the path
  147941. */
  147942. computePath(start: Vector3, end: Vector3): Vector3[];
  147943. /**
  147944. * Create a new Crowd so you can add agents
  147945. * @param maxAgents the maximum agent count in the crowd
  147946. * @param maxAgentRadius the maximum radius an agent can have
  147947. * @param scene to attach the crowd to
  147948. * @returns the crowd you can add agents to
  147949. */
  147950. createCrowd(maxAgents: number, maxAgentRadius: number, scene: Scene): ICrowd;
  147951. /**
  147952. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  147953. * The queries will try to find a solution within those bounds
  147954. * default is (1,1,1)
  147955. * @param extent x,y,z value that define the extent around the queries point of reference
  147956. */
  147957. setDefaultQueryExtent(extent: Vector3): void;
  147958. /**
  147959. * Get the Bounding box extent specified by setDefaultQueryExtent
  147960. * @returns the box extent values
  147961. */
  147962. getDefaultQueryExtent(): Vector3;
  147963. /**
  147964. * build the navmesh from a previously saved state using getNavmeshData
  147965. * @param data the Uint8Array returned by getNavmeshData
  147966. */
  147967. buildFromNavmeshData(data: Uint8Array): void;
  147968. /**
  147969. * returns the navmesh data that can be used later. The navmesh must be built before retrieving the data
  147970. * @returns data the Uint8Array that can be saved and reused
  147971. */
  147972. getNavmeshData(): Uint8Array;
  147973. /**
  147974. * Get the Bounding box extent result specified by setDefaultQueryExtent
  147975. * @param result output the box extent values
  147976. */
  147977. getDefaultQueryExtentToRef(result: Vector3): void;
  147978. /**
  147979. * Disposes
  147980. */
  147981. dispose(): void;
  147982. /**
  147983. * If this plugin is supported
  147984. * @returns true if plugin is supported
  147985. */
  147986. isSupported(): boolean;
  147987. }
  147988. /**
  147989. * Recast detour crowd implementation
  147990. */
  147991. export class RecastJSCrowd implements ICrowd {
  147992. /**
  147993. * Recast/detour plugin
  147994. */
  147995. bjsRECASTPlugin: RecastJSPlugin;
  147996. /**
  147997. * Link to the detour crowd
  147998. */
  147999. recastCrowd: any;
  148000. /**
  148001. * One transform per agent
  148002. */
  148003. transforms: TransformNode[];
  148004. /**
  148005. * All agents created
  148006. */
  148007. agents: number[];
  148008. /**
  148009. * Link to the scene is kept to unregister the crowd from the scene
  148010. */
  148011. private _scene;
  148012. /**
  148013. * Observer for crowd updates
  148014. */
  148015. private _onBeforeAnimationsObserver;
  148016. /**
  148017. * Constructor
  148018. * @param plugin recastJS plugin
  148019. * @param maxAgents the maximum agent count in the crowd
  148020. * @param maxAgentRadius the maximum radius an agent can have
  148021. * @param scene to attach the crowd to
  148022. * @returns the crowd you can add agents to
  148023. */
  148024. constructor(plugin: RecastJSPlugin, maxAgents: number, maxAgentRadius: number, scene: Scene);
  148025. /**
  148026. * Add a new agent to the crowd with the specified parameter a corresponding transformNode.
  148027. * You can attach anything to that node. The node position is updated in the scene update tick.
  148028. * @param pos world position that will be constrained by the navigation mesh
  148029. * @param parameters agent parameters
  148030. * @param transform hooked to the agent that will be update by the scene
  148031. * @returns agent index
  148032. */
  148033. addAgent(pos: Vector3, parameters: IAgentParameters, transform: TransformNode): number;
  148034. /**
  148035. * Returns the agent position in world space
  148036. * @param index agent index returned by addAgent
  148037. * @returns world space position
  148038. */
  148039. getAgentPosition(index: number): Vector3;
  148040. /**
  148041. * Returns the agent position result in world space
  148042. * @param index agent index returned by addAgent
  148043. * @param result output world space position
  148044. */
  148045. getAgentPositionToRef(index: number, result: Vector3): void;
  148046. /**
  148047. * Returns the agent velocity in world space
  148048. * @param index agent index returned by addAgent
  148049. * @returns world space velocity
  148050. */
  148051. getAgentVelocity(index: number): Vector3;
  148052. /**
  148053. * Returns the agent velocity result in world space
  148054. * @param index agent index returned by addAgent
  148055. * @param result output world space velocity
  148056. */
  148057. getAgentVelocityToRef(index: number, result: Vector3): void;
  148058. /**
  148059. * Asks a particular agent to go to a destination. That destination is constrained by the navigation mesh
  148060. * @param index agent index returned by addAgent
  148061. * @param destination targeted world position
  148062. */
  148063. agentGoto(index: number, destination: Vector3): void;
  148064. /**
  148065. * Teleport the agent to a new position
  148066. * @param index agent index returned by addAgent
  148067. * @param destination targeted world position
  148068. */
  148069. agentTeleport(index: number, destination: Vector3): void;
  148070. /**
  148071. * Update agent parameters
  148072. * @param index agent index returned by addAgent
  148073. * @param parameters agent parameters
  148074. */
  148075. updateAgentParameters(index: number, parameters: IAgentParameters): void;
  148076. /**
  148077. * remove a particular agent previously created
  148078. * @param index agent index returned by addAgent
  148079. */
  148080. removeAgent(index: number): void;
  148081. /**
  148082. * get the list of all agents attached to this crowd
  148083. * @returns list of agent indices
  148084. */
  148085. getAgents(): number[];
  148086. /**
  148087. * Tick update done by the Scene. Agent position/velocity/acceleration is updated by this function
  148088. * @param deltaTime in seconds
  148089. */
  148090. update(deltaTime: number): void;
  148091. /**
  148092. * Set the Bounding box extent for doing spatial queries (getClosestPoint, getRandomPointAround, ...)
  148093. * The queries will try to find a solution within those bounds
  148094. * default is (1,1,1)
  148095. * @param extent x,y,z value that define the extent around the queries point of reference
  148096. */
  148097. setDefaultQueryExtent(extent: Vector3): void;
  148098. /**
  148099. * Get the Bounding box extent specified by setDefaultQueryExtent
  148100. * @returns the box extent values
  148101. */
  148102. getDefaultQueryExtent(): Vector3;
  148103. /**
  148104. * Get the Bounding box extent result specified by setDefaultQueryExtent
  148105. * @param result output the box extent values
  148106. */
  148107. getDefaultQueryExtentToRef(result: Vector3): void;
  148108. /**
  148109. * Release all resources
  148110. */
  148111. dispose(): void;
  148112. }
  148113. }
  148114. declare module BABYLON {
  148115. /**
  148116. * Class used to enable access to IndexedDB
  148117. * @see https://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  148118. */
  148119. export class Database implements IOfflineProvider {
  148120. private _callbackManifestChecked;
  148121. private _currentSceneUrl;
  148122. private _db;
  148123. private _enableSceneOffline;
  148124. private _enableTexturesOffline;
  148125. private _manifestVersionFound;
  148126. private _mustUpdateRessources;
  148127. private _hasReachedQuota;
  148128. private _isSupported;
  148129. private _idbFactory;
  148130. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  148131. private static IsUASupportingBlobStorage;
  148132. /**
  148133. * Gets a boolean indicating if Database storate is enabled (off by default)
  148134. */
  148135. static IDBStorageEnabled: boolean;
  148136. /**
  148137. * Gets a boolean indicating if scene must be saved in the database
  148138. */
  148139. get enableSceneOffline(): boolean;
  148140. /**
  148141. * Gets a boolean indicating if textures must be saved in the database
  148142. */
  148143. get enableTexturesOffline(): boolean;
  148144. /**
  148145. * Creates a new Database
  148146. * @param urlToScene defines the url to load the scene
  148147. * @param callbackManifestChecked defines the callback to use when manifest is checked
  148148. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  148149. */
  148150. constructor(urlToScene: string, callbackManifestChecked: (checked: boolean) => any, disableManifestCheck?: boolean);
  148151. private static _ParseURL;
  148152. private static _ReturnFullUrlLocation;
  148153. private _checkManifestFile;
  148154. /**
  148155. * Open the database and make it available
  148156. * @param successCallback defines the callback to call on success
  148157. * @param errorCallback defines the callback to call on error
  148158. */
  148159. open(successCallback: () => void, errorCallback: () => void): void;
  148160. /**
  148161. * Loads an image from the database
  148162. * @param url defines the url to load from
  148163. * @param image defines the target DOM image
  148164. */
  148165. loadImage(url: string, image: HTMLImageElement): void;
  148166. private _loadImageFromDBAsync;
  148167. private _saveImageIntoDBAsync;
  148168. private _checkVersionFromDB;
  148169. private _loadVersionFromDBAsync;
  148170. private _saveVersionIntoDBAsync;
  148171. /**
  148172. * Loads a file from database
  148173. * @param url defines the URL to load from
  148174. * @param sceneLoaded defines a callback to call on success
  148175. * @param progressCallBack defines a callback to call when progress changed
  148176. * @param errorCallback defines a callback to call on error
  148177. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  148178. */
  148179. loadFile(url: string, sceneLoaded: (data: any) => void, progressCallBack?: (data: any) => void, errorCallback?: () => void, useArrayBuffer?: boolean): void;
  148180. private _loadFileAsync;
  148181. private _saveFileAsync;
  148182. /**
  148183. * Validates if xhr data is correct
  148184. * @param xhr defines the request to validate
  148185. * @param dataType defines the expected data type
  148186. * @returns true if data is correct
  148187. */
  148188. private static _ValidateXHRData;
  148189. }
  148190. }
  148191. declare module BABYLON {
  148192. /** @hidden */
  148193. export var gpuUpdateParticlesPixelShader: {
  148194. name: string;
  148195. shader: string;
  148196. };
  148197. }
  148198. declare module BABYLON {
  148199. /** @hidden */
  148200. export var gpuUpdateParticlesVertexShader: {
  148201. name: string;
  148202. shader: string;
  148203. };
  148204. }
  148205. declare module BABYLON {
  148206. /** @hidden */
  148207. export var clipPlaneFragmentDeclaration2: {
  148208. name: string;
  148209. shader: string;
  148210. };
  148211. }
  148212. declare module BABYLON {
  148213. /** @hidden */
  148214. export var gpuRenderParticlesPixelShader: {
  148215. name: string;
  148216. shader: string;
  148217. };
  148218. }
  148219. declare module BABYLON {
  148220. /** @hidden */
  148221. export var clipPlaneVertexDeclaration2: {
  148222. name: string;
  148223. shader: string;
  148224. };
  148225. }
  148226. declare module BABYLON {
  148227. /** @hidden */
  148228. export var gpuRenderParticlesVertexShader: {
  148229. name: string;
  148230. shader: string;
  148231. };
  148232. }
  148233. declare module BABYLON {
  148234. /**
  148235. * This represents a GPU particle system in Babylon
  148236. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  148237. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  148238. */
  148239. export class GPUParticleSystem extends BaseParticleSystem implements IDisposable, IParticleSystem, IAnimatable {
  148240. /**
  148241. * The layer mask we are rendering the particles through.
  148242. */
  148243. layerMask: number;
  148244. private _capacity;
  148245. private _activeCount;
  148246. private _currentActiveCount;
  148247. private _accumulatedCount;
  148248. private _renderEffect;
  148249. private _updateEffect;
  148250. private _buffer0;
  148251. private _buffer1;
  148252. private _spriteBuffer;
  148253. private _updateVAO;
  148254. private _renderVAO;
  148255. private _targetIndex;
  148256. private _sourceBuffer;
  148257. private _targetBuffer;
  148258. private _currentRenderId;
  148259. private _started;
  148260. private _stopped;
  148261. private _timeDelta;
  148262. private _randomTexture;
  148263. private _randomTexture2;
  148264. private _attributesStrideSize;
  148265. private _updateEffectOptions;
  148266. private _randomTextureSize;
  148267. private _actualFrame;
  148268. private _customEffect;
  148269. private readonly _rawTextureWidth;
  148270. /**
  148271. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  148272. */
  148273. static get IsSupported(): boolean;
  148274. /**
  148275. * An event triggered when the system is disposed.
  148276. */
  148277. onDisposeObservable: Observable<IParticleSystem>;
  148278. /**
  148279. * Gets the maximum number of particles active at the same time.
  148280. * @returns The max number of active particles.
  148281. */
  148282. getCapacity(): number;
  148283. /**
  148284. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  148285. * to override the particles.
  148286. */
  148287. forceDepthWrite: boolean;
  148288. /**
  148289. * Gets or set the number of active particles
  148290. */
  148291. get activeParticleCount(): number;
  148292. set activeParticleCount(value: number);
  148293. private _preWarmDone;
  148294. /**
  148295. * Specifies if the particles are updated in emitter local space or world space.
  148296. */
  148297. isLocal: boolean;
  148298. /** Gets or sets a matrix to use to compute projection */
  148299. defaultProjectionMatrix: Matrix;
  148300. /**
  148301. * Is this system ready to be used/rendered
  148302. * @return true if the system is ready
  148303. */
  148304. isReady(): boolean;
  148305. /**
  148306. * Gets if the system has been started. (Note: this will still be true after stop is called)
  148307. * @returns True if it has been started, otherwise false.
  148308. */
  148309. isStarted(): boolean;
  148310. /**
  148311. * Gets if the system has been stopped. (Note: rendering is still happening but the system is frozen)
  148312. * @returns True if it has been stopped, otherwise false.
  148313. */
  148314. isStopped(): boolean;
  148315. /**
  148316. * Gets a boolean indicating that the system is stopping
  148317. * @returns true if the system is currently stopping
  148318. */
  148319. isStopping(): boolean;
  148320. /**
  148321. * Gets the number of particles active at the same time.
  148322. * @returns The number of active particles.
  148323. */
  148324. getActiveCount(): number;
  148325. /**
  148326. * Starts the particle system and begins to emit
  148327. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  148328. */
  148329. start(delay?: number): void;
  148330. /**
  148331. * Stops the particle system.
  148332. */
  148333. stop(): void;
  148334. /**
  148335. * Remove all active particles
  148336. */
  148337. reset(): void;
  148338. /**
  148339. * Returns the string "GPUParticleSystem"
  148340. * @returns a string containing the class name
  148341. */
  148342. getClassName(): string;
  148343. /**
  148344. * Gets the custom effect used to render the particles
  148345. * @param blendMode Blend mode for which the effect should be retrieved
  148346. * @returns The effect
  148347. */
  148348. getCustomEffect(blendMode?: number): Nullable<Effect>;
  148349. /**
  148350. * Sets the custom effect used to render the particles
  148351. * @param effect The effect to set
  148352. * @param blendMode Blend mode for which the effect should be set
  148353. */
  148354. setCustomEffect(effect: Nullable<Effect>, blendMode?: number): void;
  148355. /** @hidden */
  148356. protected _onBeforeDrawParticlesObservable: Nullable<Observable<Nullable<Effect>>>;
  148357. /**
  148358. * Observable that will be called just before the particles are drawn
  148359. */
  148360. get onBeforeDrawParticlesObservable(): Observable<Nullable<Effect>>;
  148361. /**
  148362. * Gets the name of the particle vertex shader
  148363. */
  148364. get vertexShaderName(): string;
  148365. private _colorGradientsTexture;
  148366. protected _removeGradientAndTexture(gradient: number, gradients: Nullable<IValueGradient[]>, texture: RawTexture): BaseParticleSystem;
  148367. /**
  148368. * Adds a new color gradient
  148369. * @param gradient defines the gradient to use (between 0 and 1)
  148370. * @param color1 defines the color to affect to the specified gradient
  148371. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  148372. * @returns the current particle system
  148373. */
  148374. addColorGradient(gradient: number, color1: Color4, color2?: Color4): GPUParticleSystem;
  148375. private _refreshColorGradient;
  148376. /** Force the system to rebuild all gradients that need to be resync */
  148377. forceRefreshGradients(): void;
  148378. /**
  148379. * Remove a specific color gradient
  148380. * @param gradient defines the gradient to remove
  148381. * @returns the current particle system
  148382. */
  148383. removeColorGradient(gradient: number): GPUParticleSystem;
  148384. private _angularSpeedGradientsTexture;
  148385. private _sizeGradientsTexture;
  148386. private _velocityGradientsTexture;
  148387. private _limitVelocityGradientsTexture;
  148388. private _dragGradientsTexture;
  148389. private _addFactorGradient;
  148390. /**
  148391. * Adds a new size gradient
  148392. * @param gradient defines the gradient to use (between 0 and 1)
  148393. * @param factor defines the size factor to affect to the specified gradient
  148394. * @returns the current particle system
  148395. */
  148396. addSizeGradient(gradient: number, factor: number): GPUParticleSystem;
  148397. /**
  148398. * Remove a specific size gradient
  148399. * @param gradient defines the gradient to remove
  148400. * @returns the current particle system
  148401. */
  148402. removeSizeGradient(gradient: number): GPUParticleSystem;
  148403. private _refreshFactorGradient;
  148404. /**
  148405. * Adds a new angular speed gradient
  148406. * @param gradient defines the gradient to use (between 0 and 1)
  148407. * @param factor defines the angular speed to affect to the specified gradient
  148408. * @returns the current particle system
  148409. */
  148410. addAngularSpeedGradient(gradient: number, factor: number): GPUParticleSystem;
  148411. /**
  148412. * Remove a specific angular speed gradient
  148413. * @param gradient defines the gradient to remove
  148414. * @returns the current particle system
  148415. */
  148416. removeAngularSpeedGradient(gradient: number): GPUParticleSystem;
  148417. /**
  148418. * Adds a new velocity gradient
  148419. * @param gradient defines the gradient to use (between 0 and 1)
  148420. * @param factor defines the velocity to affect to the specified gradient
  148421. * @returns the current particle system
  148422. */
  148423. addVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148424. /**
  148425. * Remove a specific velocity gradient
  148426. * @param gradient defines the gradient to remove
  148427. * @returns the current particle system
  148428. */
  148429. removeVelocityGradient(gradient: number): GPUParticleSystem;
  148430. /**
  148431. * Adds a new limit velocity gradient
  148432. * @param gradient defines the gradient to use (between 0 and 1)
  148433. * @param factor defines the limit velocity value to affect to the specified gradient
  148434. * @returns the current particle system
  148435. */
  148436. addLimitVelocityGradient(gradient: number, factor: number): GPUParticleSystem;
  148437. /**
  148438. * Remove a specific limit velocity gradient
  148439. * @param gradient defines the gradient to remove
  148440. * @returns the current particle system
  148441. */
  148442. removeLimitVelocityGradient(gradient: number): GPUParticleSystem;
  148443. /**
  148444. * Adds a new drag gradient
  148445. * @param gradient defines the gradient to use (between 0 and 1)
  148446. * @param factor defines the drag value to affect to the specified gradient
  148447. * @returns the current particle system
  148448. */
  148449. addDragGradient(gradient: number, factor: number): GPUParticleSystem;
  148450. /**
  148451. * Remove a specific drag gradient
  148452. * @param gradient defines the gradient to remove
  148453. * @returns the current particle system
  148454. */
  148455. removeDragGradient(gradient: number): GPUParticleSystem;
  148456. /**
  148457. * Not supported by GPUParticleSystem
  148458. * @param gradient defines the gradient to use (between 0 and 1)
  148459. * @param factor defines the emit rate value to affect to the specified gradient
  148460. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148461. * @returns the current particle system
  148462. */
  148463. addEmitRateGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148464. /**
  148465. * Not supported by GPUParticleSystem
  148466. * @param gradient defines the gradient to remove
  148467. * @returns the current particle system
  148468. */
  148469. removeEmitRateGradient(gradient: number): IParticleSystem;
  148470. /**
  148471. * Not supported by GPUParticleSystem
  148472. * @param gradient defines the gradient to use (between 0 and 1)
  148473. * @param factor defines the start size value to affect to the specified gradient
  148474. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148475. * @returns the current particle system
  148476. */
  148477. addStartSizeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148478. /**
  148479. * Not supported by GPUParticleSystem
  148480. * @param gradient defines the gradient to remove
  148481. * @returns the current particle system
  148482. */
  148483. removeStartSizeGradient(gradient: number): IParticleSystem;
  148484. /**
  148485. * Not supported by GPUParticleSystem
  148486. * @param gradient defines the gradient to use (between 0 and 1)
  148487. * @param min defines the color remap minimal range
  148488. * @param max defines the color remap maximal range
  148489. * @returns the current particle system
  148490. */
  148491. addColorRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148492. /**
  148493. * Not supported by GPUParticleSystem
  148494. * @param gradient defines the gradient to remove
  148495. * @returns the current particle system
  148496. */
  148497. removeColorRemapGradient(): IParticleSystem;
  148498. /**
  148499. * Not supported by GPUParticleSystem
  148500. * @param gradient defines the gradient to use (between 0 and 1)
  148501. * @param min defines the alpha remap minimal range
  148502. * @param max defines the alpha remap maximal range
  148503. * @returns the current particle system
  148504. */
  148505. addAlphaRemapGradient(gradient: number, min: number, max: number): IParticleSystem;
  148506. /**
  148507. * Not supported by GPUParticleSystem
  148508. * @param gradient defines the gradient to remove
  148509. * @returns the current particle system
  148510. */
  148511. removeAlphaRemapGradient(): IParticleSystem;
  148512. /**
  148513. * Not supported by GPUParticleSystem
  148514. * @param gradient defines the gradient to use (between 0 and 1)
  148515. * @param color defines the color to affect to the specified gradient
  148516. * @returns the current particle system
  148517. */
  148518. addRampGradient(gradient: number, color: Color3): IParticleSystem;
  148519. /**
  148520. * Not supported by GPUParticleSystem
  148521. * @param gradient defines the gradient to remove
  148522. * @returns the current particle system
  148523. */
  148524. removeRampGradient(): IParticleSystem;
  148525. /**
  148526. * Not supported by GPUParticleSystem
  148527. * @returns the list of ramp gradients
  148528. */
  148529. getRampGradients(): Nullable<Array<Color3Gradient>>;
  148530. /**
  148531. * Not supported by GPUParticleSystem
  148532. * Gets or sets a boolean indicating that ramp gradients must be used
  148533. * @see https://doc.babylonjs.com/babylon101/particles#ramp-gradients
  148534. */
  148535. get useRampGradients(): boolean;
  148536. set useRampGradients(value: boolean);
  148537. /**
  148538. * Not supported by GPUParticleSystem
  148539. * @param gradient defines the gradient to use (between 0 and 1)
  148540. * @param factor defines the life time factor to affect to the specified gradient
  148541. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  148542. * @returns the current particle system
  148543. */
  148544. addLifeTimeGradient(gradient: number, factor: number, factor2?: number): IParticleSystem;
  148545. /**
  148546. * Not supported by GPUParticleSystem
  148547. * @param gradient defines the gradient to remove
  148548. * @returns the current particle system
  148549. */
  148550. removeLifeTimeGradient(gradient: number): IParticleSystem;
  148551. /**
  148552. * Instantiates a GPU particle system.
  148553. * 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.
  148554. * @param name The name of the particle system
  148555. * @param options The options used to create the system
  148556. * @param sceneOrEngine The scene the particle system belongs to or the engine to use if no scene
  148557. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  148558. * @param customEffect a custom effect used to change the way particles are rendered by default
  148559. */
  148560. constructor(name: string, options: Partial<{
  148561. capacity: number;
  148562. randomTextureSize: number;
  148563. }>, sceneOrEngine: Scene | ThinEngine, isAnimationSheetEnabled?: boolean, customEffect?: Nullable<Effect>);
  148564. protected _reset(): void;
  148565. private _createUpdateVAO;
  148566. private _createRenderVAO;
  148567. private _initialize;
  148568. /** @hidden */
  148569. _recreateUpdateEffect(): void;
  148570. private _getEffect;
  148571. /**
  148572. * Fill the defines array according to the current settings of the particle system
  148573. * @param defines Array to be updated
  148574. * @param blendMode blend mode to take into account when updating the array
  148575. */
  148576. fillDefines(defines: Array<string>, blendMode?: number): void;
  148577. /**
  148578. * Fill the uniforms, attributes and samplers arrays according to the current settings of the particle system
  148579. * @param uniforms Uniforms array to fill
  148580. * @param attributes Attributes array to fill
  148581. * @param samplers Samplers array to fill
  148582. */
  148583. fillUniformsAttributesAndSamplerNames(uniforms: Array<string>, attributes: Array<string>, samplers: Array<string>): void;
  148584. /** @hidden */
  148585. _recreateRenderEffect(): Effect;
  148586. /**
  148587. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  148588. * @param preWarm defines if we are in the pre-warmimg phase
  148589. */
  148590. animate(preWarm?: boolean): void;
  148591. private _createFactorGradientTexture;
  148592. private _createSizeGradientTexture;
  148593. private _createAngularSpeedGradientTexture;
  148594. private _createVelocityGradientTexture;
  148595. private _createLimitVelocityGradientTexture;
  148596. private _createDragGradientTexture;
  148597. private _createColorGradientTexture;
  148598. /**
  148599. * Renders the particle system in its current state
  148600. * @param preWarm defines if the system should only update the particles but not render them
  148601. * @returns the current number of particles
  148602. */
  148603. render(preWarm?: boolean): number;
  148604. /**
  148605. * Rebuilds the particle system
  148606. */
  148607. rebuild(): void;
  148608. private _releaseBuffers;
  148609. private _releaseVAOs;
  148610. /**
  148611. * Disposes the particle system and free the associated resources
  148612. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  148613. */
  148614. dispose(disposeTexture?: boolean): void;
  148615. /**
  148616. * Clones the particle system.
  148617. * @param name The name of the cloned object
  148618. * @param newEmitter The new emitter to use
  148619. * @returns the cloned particle system
  148620. */
  148621. clone(name: string, newEmitter: any): GPUParticleSystem;
  148622. /**
  148623. * Serializes the particle system to a JSON object
  148624. * @param serializeTexture defines if the texture must be serialized as well
  148625. * @returns the JSON object
  148626. */
  148627. serialize(serializeTexture?: boolean): any;
  148628. /**
  148629. * Parses a JSON object to create a GPU particle system.
  148630. * @param parsedParticleSystem The JSON object to parse
  148631. * @param sceneOrEngine The scene or the engine to create the particle system in
  148632. * @param rootUrl The root url to use to load external dependencies like texture
  148633. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  148634. * @returns the parsed GPU particle system
  148635. */
  148636. static Parse(parsedParticleSystem: any, sceneOrEngine: Scene | ThinEngine, rootUrl: string, doNotStart?: boolean): GPUParticleSystem;
  148637. }
  148638. }
  148639. declare module BABYLON {
  148640. /**
  148641. * Represents a set of particle systems working together to create a specific effect
  148642. */
  148643. export class ParticleSystemSet implements IDisposable {
  148644. /**
  148645. * Gets or sets base Assets URL
  148646. */
  148647. static BaseAssetsUrl: string;
  148648. private _emitterCreationOptions;
  148649. private _emitterNode;
  148650. /**
  148651. * Gets the particle system list
  148652. */
  148653. systems: IParticleSystem[];
  148654. /**
  148655. * Gets the emitter node used with this set
  148656. */
  148657. get emitterNode(): Nullable<TransformNode>;
  148658. /**
  148659. * Creates a new emitter mesh as a sphere
  148660. * @param options defines the options used to create the sphere
  148661. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  148662. * @param scene defines the hosting scene
  148663. */
  148664. setEmitterAsSphere(options: {
  148665. diameter: number;
  148666. segments: number;
  148667. color: Color3;
  148668. }, renderingGroupId: number, scene: Scene): void;
  148669. /**
  148670. * Starts all particle systems of the set
  148671. * @param emitter defines an optional mesh to use as emitter for the particle systems
  148672. */
  148673. start(emitter?: AbstractMesh): void;
  148674. /**
  148675. * Release all associated resources
  148676. */
  148677. dispose(): void;
  148678. /**
  148679. * Serialize the set into a JSON compatible object
  148680. * @param serializeTexture defines if the texture must be serialized as well
  148681. * @returns a JSON compatible representation of the set
  148682. */
  148683. serialize(serializeTexture?: boolean): any;
  148684. /**
  148685. * Parse a new ParticleSystemSet from a serialized source
  148686. * @param data defines a JSON compatible representation of the set
  148687. * @param scene defines the hosting scene
  148688. * @param gpu defines if we want GPU particles or CPU particles
  148689. * @returns a new ParticleSystemSet
  148690. */
  148691. static Parse(data: any, scene: Scene, gpu?: boolean): ParticleSystemSet;
  148692. }
  148693. }
  148694. declare module BABYLON {
  148695. /**
  148696. * This class is made for on one-liner static method to help creating particle system set.
  148697. */
  148698. export class ParticleHelper {
  148699. /**
  148700. * Gets or sets base Assets URL
  148701. */
  148702. static BaseAssetsUrl: string;
  148703. /** Define the Url to load snippets */
  148704. static SnippetUrl: string;
  148705. /**
  148706. * Create a default particle system that you can tweak
  148707. * @param emitter defines the emitter to use
  148708. * @param capacity defines the system capacity (default is 500 particles)
  148709. * @param scene defines the hosting scene
  148710. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  148711. * @returns the new Particle system
  148712. */
  148713. static CreateDefault(emitter: Nullable<AbstractMesh | Vector3>, capacity?: number, scene?: Scene, useGPU?: boolean): IParticleSystem;
  148714. /**
  148715. * This is the main static method (one-liner) of this helper to create different particle systems
  148716. * @param type This string represents the type to the particle system to create
  148717. * @param scene The scene where the particle system should live
  148718. * @param gpu If the system will use gpu
  148719. * @returns the ParticleSystemSet created
  148720. */
  148721. static CreateAsync(type: string, scene: Nullable<Scene>, gpu?: boolean): Promise<ParticleSystemSet>;
  148722. /**
  148723. * Static function used to export a particle system to a ParticleSystemSet variable.
  148724. * Please note that the emitter shape is not exported
  148725. * @param systems defines the particle systems to export
  148726. * @returns the created particle system set
  148727. */
  148728. static ExportSet(systems: IParticleSystem[]): ParticleSystemSet;
  148729. /**
  148730. * Creates a particle system from a snippet saved in a remote file
  148731. * @param name defines the name of the particle system to create (can be null or empty to use the one from the json data)
  148732. * @param url defines the url to load from
  148733. * @param scene defines the hosting scene
  148734. * @param gpu If the system will use gpu
  148735. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148736. * @returns a promise that will resolve to the new particle system
  148737. */
  148738. static ParseFromFileAsync(name: Nullable<string>, url: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148739. /**
  148740. * Creates a particle system from a snippet saved by the particle system editor
  148741. * @param snippetId defines the snippet to load (can be set to _BLANK to create a default one)
  148742. * @param scene defines the hosting scene
  148743. * @param gpu If the system will use gpu
  148744. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  148745. * @returns a promise that will resolve to the new particle system
  148746. */
  148747. static CreateFromSnippetAsync(snippetId: string, scene: Scene, gpu?: boolean, rootUrl?: string): Promise<IParticleSystem>;
  148748. }
  148749. }
  148750. declare module BABYLON {
  148751. interface Engine {
  148752. /**
  148753. * Create an effect to use with particle systems.
  148754. * Please note that some parameters like animation sheets or not being billboard are not supported in this configuration, except if you pass
  148755. * the particle system for which you want to create a custom effect in the last parameter
  148756. * @param fragmentName defines the base name of the effect (The name of file without .fragment.fx)
  148757. * @param uniformsNames defines a list of attribute names
  148758. * @param samplers defines an array of string used to represent textures
  148759. * @param defines defines the string containing the defines to use to compile the shaders
  148760. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  148761. * @param onCompiled defines a function to call when the effect creation is successful
  148762. * @param onError defines a function to call when the effect creation has failed
  148763. * @param particleSystem the particle system you want to create the effect for
  148764. * @returns the new Effect
  148765. */
  148766. createEffectForParticles(fragmentName: string, uniformsNames: string[], samplers: string[], defines: string, fallbacks?: EffectFallbacks, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void, particleSystem?: IParticleSystem): Effect;
  148767. }
  148768. interface Mesh {
  148769. /**
  148770. * Returns an array populated with IParticleSystem objects whose the mesh is the emitter
  148771. * @returns an array of IParticleSystem
  148772. */
  148773. getEmittedParticleSystems(): IParticleSystem[];
  148774. /**
  148775. * Returns an array populated with IParticleSystem objects whose the mesh or its children are the emitter
  148776. * @returns an array of IParticleSystem
  148777. */
  148778. getHierarchyEmittedParticleSystems(): IParticleSystem[];
  148779. }
  148780. }
  148781. declare module BABYLON {
  148782. /** Defines the 4 color options */
  148783. export enum PointColor {
  148784. /** color value */
  148785. Color = 2,
  148786. /** uv value */
  148787. UV = 1,
  148788. /** random value */
  148789. Random = 0,
  148790. /** stated value */
  148791. Stated = 3
  148792. }
  148793. /**
  148794. * The PointCloudSystem (PCS) is a single updatable mesh. The points corresponding to the vertices of this big mesh.
  148795. * 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.
  148796. * The PointCloudSytem is also a particle system, with each point being a particle. It provides some methods to manage the particles.
  148797. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  148798. *
  148799. * Full documentation here : TO BE ENTERED
  148800. */
  148801. export class PointsCloudSystem implements IDisposable {
  148802. /**
  148803. * The PCS array of cloud point objects. Just access each particle as with any classic array.
  148804. * Example : var p = SPS.particles[i];
  148805. */
  148806. particles: CloudPoint[];
  148807. /**
  148808. * The PCS total number of particles. Read only. Use PCS.counter instead if you need to set your own value.
  148809. */
  148810. nbParticles: number;
  148811. /**
  148812. * This a counter for your own usage. It's not set by any SPS functions.
  148813. */
  148814. counter: number;
  148815. /**
  148816. * The PCS name. This name is also given to the underlying mesh.
  148817. */
  148818. name: string;
  148819. /**
  148820. * The PCS mesh. It's a standard BJS Mesh, so all the methods from the Mesh class are avalaible.
  148821. */
  148822. mesh: Mesh;
  148823. /**
  148824. * This empty object is intended to store some PCS specific or temporary values in order to lower the Garbage Collector activity.
  148825. * Please read :
  148826. */
  148827. vars: any;
  148828. /**
  148829. * @hidden
  148830. */
  148831. _size: number;
  148832. private _scene;
  148833. private _promises;
  148834. private _positions;
  148835. private _indices;
  148836. private _normals;
  148837. private _colors;
  148838. private _uvs;
  148839. private _indices32;
  148840. private _positions32;
  148841. private _colors32;
  148842. private _uvs32;
  148843. private _updatable;
  148844. private _isVisibilityBoxLocked;
  148845. private _alwaysVisible;
  148846. private _groups;
  148847. private _groupCounter;
  148848. private _computeParticleColor;
  148849. private _computeParticleTexture;
  148850. private _computeParticleRotation;
  148851. private _computeBoundingBox;
  148852. private _isReady;
  148853. /**
  148854. * Creates a PCS (Points Cloud System) object
  148855. * @param name (String) is the PCS name, this will be the underlying mesh name
  148856. * @param pointSize (number) is the size for each point
  148857. * @param scene (Scene) is the scene in which the PCS is added
  148858. * @param options defines the options of the PCS e.g.
  148859. * * updatable (optional boolean, default true) : if the PCS must be updatable or immutable
  148860. */
  148861. constructor(name: string, pointSize: number, scene: Scene, options?: {
  148862. updatable?: boolean;
  148863. });
  148864. /**
  148865. * Builds the PCS underlying mesh. Returns a standard Mesh.
  148866. * If no points were added to the PCS, the returned mesh is just a single point.
  148867. * @returns a promise for the created mesh
  148868. */
  148869. buildMeshAsync(): Promise<Mesh>;
  148870. /**
  148871. * @hidden
  148872. */
  148873. private _buildMesh;
  148874. private _addParticle;
  148875. private _randomUnitVector;
  148876. private _getColorIndicesForCoord;
  148877. private _setPointsColorOrUV;
  148878. private _colorFromTexture;
  148879. private _calculateDensity;
  148880. /**
  148881. * Adds points to the PCS in random positions within a unit sphere
  148882. * @param nb (positive integer) the number of particles to be created from this model
  148883. * @param pointFunction is an optional javascript function to be called for each particle on PCS creation
  148884. * @returns the number of groups in the system
  148885. */
  148886. addPoints(nb: number, pointFunction?: any): number;
  148887. /**
  148888. * Adds points to the PCS from the surface of the model shape
  148889. * @param mesh is any Mesh object that will be used as a surface model for the points
  148890. * @param nb (positive integer) the number of particles to be created from this model
  148891. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148892. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148893. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148894. * @returns the number of groups in the system
  148895. */
  148896. addSurfacePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148897. /**
  148898. * Adds points to the PCS inside the model shape
  148899. * @param mesh is any Mesh object that will be used as a surface model for the points
  148900. * @param nb (positive integer) the number of particles to be created from this model
  148901. * @param colorWith determines whether a point is colored using color (default), uv, random, stated or none (invisible)
  148902. * @param color (color4) to be used when colorWith is stated or color (number) when used to specify texture position
  148903. * @param range (number from 0 to 1) to determine the variation in shape and tone for a stated color
  148904. * @returns the number of groups in the system
  148905. */
  148906. addVolumePoints(mesh: Mesh, nb: number, colorWith?: number, color?: Color4 | number, range?: number): number;
  148907. /**
  148908. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  148909. * This method calls `updateParticle()` for each particle of the SPS.
  148910. * For an animated SPS, it is usually called within the render loop.
  148911. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  148912. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  148913. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  148914. * @returns the PCS.
  148915. */
  148916. setParticles(start?: number, end?: number, update?: boolean): PointsCloudSystem;
  148917. /**
  148918. * Disposes the PCS.
  148919. */
  148920. dispose(): void;
  148921. /**
  148922. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  148923. * doc :
  148924. * @returns the PCS.
  148925. */
  148926. refreshVisibleSize(): PointsCloudSystem;
  148927. /**
  148928. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  148929. * @param size the size (float) of the visibility box
  148930. * note : this doesn't lock the PCS mesh bounding box.
  148931. * doc :
  148932. */
  148933. setVisibilityBox(size: number): void;
  148934. /**
  148935. * Gets whether the PCS is always visible or not
  148936. * doc :
  148937. */
  148938. get isAlwaysVisible(): boolean;
  148939. /**
  148940. * Sets the PCS as always visible or not
  148941. * doc :
  148942. */
  148943. set isAlwaysVisible(val: boolean);
  148944. /**
  148945. * Tells to `setParticles()` to compute the particle rotations or not
  148946. * Default value : false. The PCS is faster when it's set to false
  148947. * Note : particle rotations are only applied to parent particles
  148948. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate
  148949. */
  148950. set computeParticleRotation(val: boolean);
  148951. /**
  148952. * Tells to `setParticles()` to compute the particle colors or not.
  148953. * Default value : true. The PCS is faster when it's set to false.
  148954. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148955. */
  148956. set computeParticleColor(val: boolean);
  148957. set computeParticleTexture(val: boolean);
  148958. /**
  148959. * Gets if `setParticles()` computes the particle colors or not.
  148960. * Default value : false. The PCS is faster when it's set to false.
  148961. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  148962. */
  148963. get computeParticleColor(): boolean;
  148964. /**
  148965. * Gets if `setParticles()` computes the particle textures or not.
  148966. * Default value : false. The PCS is faster when it's set to false.
  148967. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  148968. */
  148969. get computeParticleTexture(): boolean;
  148970. /**
  148971. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  148972. */
  148973. set computeBoundingBox(val: boolean);
  148974. /**
  148975. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  148976. */
  148977. get computeBoundingBox(): boolean;
  148978. /**
  148979. * This function does nothing. It may be overwritten to set all the particle first values.
  148980. * The PCS doesn't call this function, you may have to call it by your own.
  148981. * doc :
  148982. */
  148983. initParticles(): void;
  148984. /**
  148985. * This function does nothing. It may be overwritten to recycle a particle
  148986. * The PCS doesn't call this function, you can to call it
  148987. * doc :
  148988. * @param particle The particle to recycle
  148989. * @returns the recycled particle
  148990. */
  148991. recycleParticle(particle: CloudPoint): CloudPoint;
  148992. /**
  148993. * Updates a particle : this function should be overwritten by the user.
  148994. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  148995. * doc :
  148996. * @example : just set a particle position or velocity and recycle conditions
  148997. * @param particle The particle to update
  148998. * @returns the updated particle
  148999. */
  149000. updateParticle(particle: CloudPoint): CloudPoint;
  149001. /**
  149002. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  149003. * This does nothing and may be overwritten by the user.
  149004. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149005. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149006. * @param update the boolean update value actually passed to setParticles()
  149007. */
  149008. beforeUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149009. /**
  149010. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  149011. * This will be passed three parameters.
  149012. * This does nothing and may be overwritten by the user.
  149013. * @param start the particle index in the particle array where to start to iterate, same than the value passed to setParticle()
  149014. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  149015. * @param update the boolean update value actually passed to setParticles()
  149016. */
  149017. afterUpdateParticles(start?: number, stop?: number, update?: boolean): void;
  149018. }
  149019. }
  149020. declare module BABYLON {
  149021. /**
  149022. * Represents one particle of a points cloud system.
  149023. */
  149024. export class CloudPoint {
  149025. /**
  149026. * particle global index
  149027. */
  149028. idx: number;
  149029. /**
  149030. * The color of the particle
  149031. */
  149032. color: Nullable<Color4>;
  149033. /**
  149034. * The world space position of the particle.
  149035. */
  149036. position: Vector3;
  149037. /**
  149038. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  149039. */
  149040. rotation: Vector3;
  149041. /**
  149042. * The world space rotation quaternion of the particle.
  149043. */
  149044. rotationQuaternion: Nullable<Quaternion>;
  149045. /**
  149046. * The uv of the particle.
  149047. */
  149048. uv: Nullable<Vector2>;
  149049. /**
  149050. * The current speed of the particle.
  149051. */
  149052. velocity: Vector3;
  149053. /**
  149054. * The pivot point in the particle local space.
  149055. */
  149056. pivot: Vector3;
  149057. /**
  149058. * Must the particle be translated from its pivot point in its local space ?
  149059. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  149060. * Default : false
  149061. */
  149062. translateFromPivot: boolean;
  149063. /**
  149064. * Index of this particle in the global "positions" array (Internal use)
  149065. * @hidden
  149066. */
  149067. _pos: number;
  149068. /**
  149069. * @hidden Index of this particle in the global "indices" array (Internal use)
  149070. */
  149071. _ind: number;
  149072. /**
  149073. * Group this particle belongs to
  149074. */
  149075. _group: PointsGroup;
  149076. /**
  149077. * Group id of this particle
  149078. */
  149079. groupId: number;
  149080. /**
  149081. * Index of the particle in its group id (Internal use)
  149082. */
  149083. idxInGroup: number;
  149084. /**
  149085. * @hidden Particle BoundingInfo object (Internal use)
  149086. */
  149087. _boundingInfo: BoundingInfo;
  149088. /**
  149089. * @hidden Reference to the PCS that the particle belongs to (Internal use)
  149090. */
  149091. _pcs: PointsCloudSystem;
  149092. /**
  149093. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  149094. */
  149095. _stillInvisible: boolean;
  149096. /**
  149097. * @hidden Last computed particle rotation matrix
  149098. */
  149099. _rotationMatrix: number[];
  149100. /**
  149101. * Parent particle Id, if any.
  149102. * Default null.
  149103. */
  149104. parentId: Nullable<number>;
  149105. /**
  149106. * @hidden Internal global position in the PCS.
  149107. */
  149108. _globalPosition: Vector3;
  149109. /**
  149110. * Creates a Point Cloud object.
  149111. * Don't create particles manually, use instead the PCS internal tools like _addParticle()
  149112. * @param particleIndex (integer) is the particle index in the PCS pool. It's also the particle identifier.
  149113. * @param group (PointsGroup) is the group the particle belongs to
  149114. * @param groupId (integer) is the group identifier in the PCS.
  149115. * @param idxInGroup (integer) is the index of the particle in the current point group (ex: the 10th point of addPoints(30))
  149116. * @param pcs defines the PCS it is associated to
  149117. */
  149118. constructor(particleIndex: number, group: PointsGroup, groupId: number, idxInGroup: number, pcs: PointsCloudSystem);
  149119. /**
  149120. * get point size
  149121. */
  149122. get size(): Vector3;
  149123. /**
  149124. * Set point size
  149125. */
  149126. set size(scale: Vector3);
  149127. /**
  149128. * Legacy support, changed quaternion to rotationQuaternion
  149129. */
  149130. get quaternion(): Nullable<Quaternion>;
  149131. /**
  149132. * Legacy support, changed quaternion to rotationQuaternion
  149133. */
  149134. set quaternion(q: Nullable<Quaternion>);
  149135. /**
  149136. * Returns a boolean. True if the particle intersects a mesh, else false
  149137. * The intersection is computed on the particle position and Axis Aligned Bounding Box (AABB) or Sphere
  149138. * @param target is the object (point or mesh) what the intersection is computed against
  149139. * @param isSphere is boolean flag when false (default) bounding box of mesh is used, when true the bouding sphere is used
  149140. * @returns true if it intersects
  149141. */
  149142. intersectsMesh(target: Mesh, isSphere: boolean): boolean;
  149143. /**
  149144. * get the rotation matrix of the particle
  149145. * @hidden
  149146. */
  149147. getRotationMatrix(m: Matrix): void;
  149148. }
  149149. /**
  149150. * Represents a group of points in a points cloud system
  149151. * * PCS internal tool, don't use it manually.
  149152. */
  149153. export class PointsGroup {
  149154. /**
  149155. * The group id
  149156. * @hidden
  149157. */
  149158. groupID: number;
  149159. /**
  149160. * image data for group (internal use)
  149161. * @hidden
  149162. */
  149163. _groupImageData: Nullable<ArrayBufferView>;
  149164. /**
  149165. * Image Width (internal use)
  149166. * @hidden
  149167. */
  149168. _groupImgWidth: number;
  149169. /**
  149170. * Image Height (internal use)
  149171. * @hidden
  149172. */
  149173. _groupImgHeight: number;
  149174. /**
  149175. * Custom position function (internal use)
  149176. * @hidden
  149177. */
  149178. _positionFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>;
  149179. /**
  149180. * density per facet for surface points
  149181. * @hidden
  149182. */
  149183. _groupDensity: number[];
  149184. /**
  149185. * Only when points are colored by texture carries pointer to texture list array
  149186. * @hidden
  149187. */
  149188. _textureNb: number;
  149189. /**
  149190. * Creates a points group object. This is an internal reference to produce particles for the PCS.
  149191. * PCS internal tool, don't use it manually.
  149192. * @hidden
  149193. */
  149194. constructor(id: number, posFunction: Nullable<(particle: CloudPoint, i?: number, s?: number) => void>);
  149195. }
  149196. }
  149197. declare module BABYLON {
  149198. interface Scene {
  149199. /** @hidden (Backing field) */
  149200. _physicsEngine: Nullable<IPhysicsEngine>;
  149201. /** @hidden */
  149202. _physicsTimeAccumulator: number;
  149203. /**
  149204. * Gets the current physics engine
  149205. * @returns a IPhysicsEngine or null if none attached
  149206. */
  149207. getPhysicsEngine(): Nullable<IPhysicsEngine>;
  149208. /**
  149209. * Enables physics to the current scene
  149210. * @param gravity defines the scene's gravity for the physics engine
  149211. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  149212. * @return a boolean indicating if the physics engine was initialized
  149213. */
  149214. enablePhysics(gravity: Nullable<Vector3>, plugin?: IPhysicsEnginePlugin): boolean;
  149215. /**
  149216. * Disables and disposes the physics engine associated with the scene
  149217. */
  149218. disablePhysicsEngine(): void;
  149219. /**
  149220. * Gets a boolean indicating if there is an active physics engine
  149221. * @returns a boolean indicating if there is an active physics engine
  149222. */
  149223. isPhysicsEnabled(): boolean;
  149224. /**
  149225. * Deletes a physics compound impostor
  149226. * @param compound defines the compound to delete
  149227. */
  149228. deleteCompoundImpostor(compound: any): void;
  149229. /**
  149230. * An event triggered when physic simulation is about to be run
  149231. */
  149232. onBeforePhysicsObservable: Observable<Scene>;
  149233. /**
  149234. * An event triggered when physic simulation has been done
  149235. */
  149236. onAfterPhysicsObservable: Observable<Scene>;
  149237. }
  149238. interface AbstractMesh {
  149239. /** @hidden */
  149240. _physicsImpostor: Nullable<PhysicsImpostor>;
  149241. /**
  149242. * Gets or sets impostor used for physic simulation
  149243. * @see https://doc.babylonjs.com/features/physics_engine
  149244. */
  149245. physicsImpostor: Nullable<PhysicsImpostor>;
  149246. /**
  149247. * Gets the current physics impostor
  149248. * @see https://doc.babylonjs.com/features/physics_engine
  149249. * @returns a physics impostor or null
  149250. */
  149251. getPhysicsImpostor(): Nullable<PhysicsImpostor>;
  149252. /** Apply a physic impulse to the mesh
  149253. * @param force defines the force to apply
  149254. * @param contactPoint defines where to apply the force
  149255. * @returns the current mesh
  149256. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  149257. */
  149258. applyImpulse(force: Vector3, contactPoint: Vector3): AbstractMesh;
  149259. /**
  149260. * Creates a physic joint between two meshes
  149261. * @param otherMesh defines the other mesh to use
  149262. * @param pivot1 defines the pivot to use on this mesh
  149263. * @param pivot2 defines the pivot to use on the other mesh
  149264. * @param options defines additional options (can be plugin dependent)
  149265. * @returns the current mesh
  149266. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  149267. */
  149268. setPhysicsLinkWith(otherMesh: Mesh, pivot1: Vector3, pivot2: Vector3, options?: any): AbstractMesh;
  149269. /** @hidden */
  149270. _disposePhysicsObserver: Nullable<Observer<Node>>;
  149271. }
  149272. /**
  149273. * Defines the physics engine scene component responsible to manage a physics engine
  149274. */
  149275. export class PhysicsEngineSceneComponent implements ISceneComponent {
  149276. /**
  149277. * The component name helpful to identify the component in the list of scene components.
  149278. */
  149279. readonly name: string;
  149280. /**
  149281. * The scene the component belongs to.
  149282. */
  149283. scene: Scene;
  149284. /**
  149285. * Creates a new instance of the component for the given scene
  149286. * @param scene Defines the scene to register the component in
  149287. */
  149288. constructor(scene: Scene);
  149289. /**
  149290. * Registers the component in a given scene
  149291. */
  149292. register(): void;
  149293. /**
  149294. * Rebuilds the elements related to this component in case of
  149295. * context lost for instance.
  149296. */
  149297. rebuild(): void;
  149298. /**
  149299. * Disposes the component and the associated ressources
  149300. */
  149301. dispose(): void;
  149302. }
  149303. }
  149304. declare module BABYLON {
  149305. /**
  149306. * A helper for physics simulations
  149307. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149308. */
  149309. export class PhysicsHelper {
  149310. private _scene;
  149311. private _physicsEngine;
  149312. /**
  149313. * Initializes the Physics helper
  149314. * @param scene Babylon.js scene
  149315. */
  149316. constructor(scene: Scene);
  149317. /**
  149318. * Applies a radial explosion impulse
  149319. * @param origin the origin of the explosion
  149320. * @param radiusOrEventOptions the radius or the options of radial explosion
  149321. * @param strength the explosion strength
  149322. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149323. * @returns A physics radial explosion event, or null
  149324. */
  149325. applyRadialExplosionImpulse(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149326. /**
  149327. * Applies a radial explosion force
  149328. * @param origin the origin of the explosion
  149329. * @param radiusOrEventOptions the radius or the options of radial explosion
  149330. * @param strength the explosion strength
  149331. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149332. * @returns A physics radial explosion event, or null
  149333. */
  149334. applyRadialExplosionForce(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsRadialExplosionEvent>;
  149335. /**
  149336. * Creates a gravitational field
  149337. * @param origin the origin of the explosion
  149338. * @param radiusOrEventOptions the radius or the options of radial explosion
  149339. * @param strength the explosion strength
  149340. * @param falloff possible options: Constant & Linear. Defaults to Constant
  149341. * @returns A physics gravitational field event, or null
  149342. */
  149343. gravitationalField(origin: Vector3, radiusOrEventOptions: number | PhysicsRadialExplosionEventOptions, strength?: number, falloff?: PhysicsRadialImpulseFalloff): Nullable<PhysicsGravitationalFieldEvent>;
  149344. /**
  149345. * Creates a physics updraft event
  149346. * @param origin the origin of the updraft
  149347. * @param radiusOrEventOptions the radius or the options of the updraft
  149348. * @param strength the strength of the updraft
  149349. * @param height the height of the updraft
  149350. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  149351. * @returns A physics updraft event, or null
  149352. */
  149353. updraft(origin: Vector3, radiusOrEventOptions: number | PhysicsUpdraftEventOptions, strength?: number, height?: number, updraftMode?: PhysicsUpdraftMode): Nullable<PhysicsUpdraftEvent>;
  149354. /**
  149355. * Creates a physics vortex event
  149356. * @param origin the of the vortex
  149357. * @param radiusOrEventOptions the radius or the options of the vortex
  149358. * @param strength the strength of the vortex
  149359. * @param height the height of the vortex
  149360. * @returns a Physics vortex event, or null
  149361. * A physics vortex event or null
  149362. */
  149363. vortex(origin: Vector3, radiusOrEventOptions: number | PhysicsVortexEventOptions, strength?: number, height?: number): Nullable<PhysicsVortexEvent>;
  149364. }
  149365. /**
  149366. * Represents a physics radial explosion event
  149367. */
  149368. class PhysicsRadialExplosionEvent {
  149369. private _scene;
  149370. private _options;
  149371. private _sphere;
  149372. private _dataFetched;
  149373. /**
  149374. * Initializes a radial explosioin event
  149375. * @param _scene BabylonJS scene
  149376. * @param _options The options for the vortex event
  149377. */
  149378. constructor(_scene: Scene, _options: PhysicsRadialExplosionEventOptions);
  149379. /**
  149380. * Returns the data related to the radial explosion event (sphere).
  149381. * @returns The radial explosion event data
  149382. */
  149383. getData(): PhysicsRadialExplosionEventData;
  149384. /**
  149385. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  149386. * @param impostor A physics imposter
  149387. * @param origin the origin of the explosion
  149388. * @returns {Nullable<PhysicsHitData>} A physics force and contact point, or null
  149389. */
  149390. getImpostorHitData(impostor: PhysicsImpostor, origin: Vector3): Nullable<PhysicsHitData>;
  149391. /**
  149392. * Triggers affecterd impostors callbacks
  149393. * @param affectedImpostorsWithData defines the list of affected impostors (including associated data)
  149394. */
  149395. triggerAffectedImpostorsCallback(affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>): void;
  149396. /**
  149397. * Disposes the sphere.
  149398. * @param force Specifies if the sphere should be disposed by force
  149399. */
  149400. dispose(force?: boolean): void;
  149401. /*** Helpers ***/
  149402. private _prepareSphere;
  149403. private _intersectsWithSphere;
  149404. }
  149405. /**
  149406. * Represents a gravitational field event
  149407. */
  149408. class PhysicsGravitationalFieldEvent {
  149409. private _physicsHelper;
  149410. private _scene;
  149411. private _origin;
  149412. private _options;
  149413. private _tickCallback;
  149414. private _sphere;
  149415. private _dataFetched;
  149416. /**
  149417. * Initializes the physics gravitational field event
  149418. * @param _physicsHelper A physics helper
  149419. * @param _scene BabylonJS scene
  149420. * @param _origin The origin position of the gravitational field event
  149421. * @param _options The options for the vortex event
  149422. */
  149423. constructor(_physicsHelper: PhysicsHelper, _scene: Scene, _origin: Vector3, _options: PhysicsRadialExplosionEventOptions);
  149424. /**
  149425. * Returns the data related to the gravitational field event (sphere).
  149426. * @returns A gravitational field event
  149427. */
  149428. getData(): PhysicsGravitationalFieldEventData;
  149429. /**
  149430. * Enables the gravitational field.
  149431. */
  149432. enable(): void;
  149433. /**
  149434. * Disables the gravitational field.
  149435. */
  149436. disable(): void;
  149437. /**
  149438. * Disposes the sphere.
  149439. * @param force The force to dispose from the gravitational field event
  149440. */
  149441. dispose(force?: boolean): void;
  149442. private _tick;
  149443. }
  149444. /**
  149445. * Represents a physics updraft event
  149446. */
  149447. class PhysicsUpdraftEvent {
  149448. private _scene;
  149449. private _origin;
  149450. private _options;
  149451. private _physicsEngine;
  149452. private _originTop;
  149453. private _originDirection;
  149454. private _tickCallback;
  149455. private _cylinder;
  149456. private _cylinderPosition;
  149457. private _dataFetched;
  149458. /**
  149459. * Initializes the physics updraft event
  149460. * @param _scene BabylonJS scene
  149461. * @param _origin The origin position of the updraft
  149462. * @param _options The options for the updraft event
  149463. */
  149464. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsUpdraftEventOptions);
  149465. /**
  149466. * Returns the data related to the updraft event (cylinder).
  149467. * @returns A physics updraft event
  149468. */
  149469. getData(): PhysicsUpdraftEventData;
  149470. /**
  149471. * Enables the updraft.
  149472. */
  149473. enable(): void;
  149474. /**
  149475. * Disables the updraft.
  149476. */
  149477. disable(): void;
  149478. /**
  149479. * Disposes the cylinder.
  149480. * @param force Specifies if the updraft should be disposed by force
  149481. */
  149482. dispose(force?: boolean): void;
  149483. private getImpostorHitData;
  149484. private _tick;
  149485. /*** Helpers ***/
  149486. private _prepareCylinder;
  149487. private _intersectsWithCylinder;
  149488. }
  149489. /**
  149490. * Represents a physics vortex event
  149491. */
  149492. class PhysicsVortexEvent {
  149493. private _scene;
  149494. private _origin;
  149495. private _options;
  149496. private _physicsEngine;
  149497. private _originTop;
  149498. private _tickCallback;
  149499. private _cylinder;
  149500. private _cylinderPosition;
  149501. private _dataFetched;
  149502. /**
  149503. * Initializes the physics vortex event
  149504. * @param _scene The BabylonJS scene
  149505. * @param _origin The origin position of the vortex
  149506. * @param _options The options for the vortex event
  149507. */
  149508. constructor(_scene: Scene, _origin: Vector3, _options: PhysicsVortexEventOptions);
  149509. /**
  149510. * Returns the data related to the vortex event (cylinder).
  149511. * @returns The physics vortex event data
  149512. */
  149513. getData(): PhysicsVortexEventData;
  149514. /**
  149515. * Enables the vortex.
  149516. */
  149517. enable(): void;
  149518. /**
  149519. * Disables the cortex.
  149520. */
  149521. disable(): void;
  149522. /**
  149523. * Disposes the sphere.
  149524. * @param force
  149525. */
  149526. dispose(force?: boolean): void;
  149527. private getImpostorHitData;
  149528. private _tick;
  149529. /*** Helpers ***/
  149530. private _prepareCylinder;
  149531. private _intersectsWithCylinder;
  149532. }
  149533. /**
  149534. * Options fot the radial explosion event
  149535. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149536. */
  149537. export class PhysicsRadialExplosionEventOptions {
  149538. /**
  149539. * The radius of the sphere for the radial explosion.
  149540. */
  149541. radius: number;
  149542. /**
  149543. * The strenth of the explosion.
  149544. */
  149545. strength: number;
  149546. /**
  149547. * The strenght of the force in correspondence to the distance of the affected object
  149548. */
  149549. falloff: PhysicsRadialImpulseFalloff;
  149550. /**
  149551. * Sphere options for the radial explosion.
  149552. */
  149553. sphere: {
  149554. segments: number;
  149555. diameter: number;
  149556. };
  149557. /**
  149558. * Sphere options for the radial explosion.
  149559. */
  149560. affectedImpostorsCallback: (affectedImpostorsWithData: Array<PhysicsAffectedImpostorWithData>) => void;
  149561. }
  149562. /**
  149563. * Options fot the updraft event
  149564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149565. */
  149566. export class PhysicsUpdraftEventOptions {
  149567. /**
  149568. * The radius of the cylinder for the vortex
  149569. */
  149570. radius: number;
  149571. /**
  149572. * The strenth of the updraft.
  149573. */
  149574. strength: number;
  149575. /**
  149576. * The height of the cylinder for the updraft.
  149577. */
  149578. height: number;
  149579. /**
  149580. * The mode for the the updraft.
  149581. */
  149582. updraftMode: PhysicsUpdraftMode;
  149583. }
  149584. /**
  149585. * Options fot the vortex event
  149586. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149587. */
  149588. export class PhysicsVortexEventOptions {
  149589. /**
  149590. * The radius of the cylinder for the vortex
  149591. */
  149592. radius: number;
  149593. /**
  149594. * The strenth of the vortex.
  149595. */
  149596. strength: number;
  149597. /**
  149598. * The height of the cylinder for the vortex.
  149599. */
  149600. height: number;
  149601. /**
  149602. * At which distance, relative to the radius the centripetal forces should kick in? Range: 0-1
  149603. */
  149604. centripetalForceThreshold: number;
  149605. /**
  149606. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when below the treshold.
  149607. */
  149608. centripetalForceMultiplier: number;
  149609. /**
  149610. * This multiplier determines with how much force the objects will be pushed sideways/around the vortex, when above the treshold.
  149611. */
  149612. centrifugalForceMultiplier: number;
  149613. /**
  149614. * This multiplier determines with how much force the objects will be pushed upwards, when in the vortex.
  149615. */
  149616. updraftForceMultiplier: number;
  149617. }
  149618. /**
  149619. * The strenght of the force in correspondence to the distance of the affected object
  149620. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149621. */
  149622. export enum PhysicsRadialImpulseFalloff {
  149623. /** Defines that impulse is constant in strength across it's whole radius */
  149624. Constant = 0,
  149625. /** Defines that impulse gets weaker if it's further from the origin */
  149626. Linear = 1
  149627. }
  149628. /**
  149629. * The strength of the force in correspondence to the distance of the affected object
  149630. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149631. */
  149632. export enum PhysicsUpdraftMode {
  149633. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  149634. Center = 0,
  149635. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  149636. Perpendicular = 1
  149637. }
  149638. /**
  149639. * Interface for a physics hit data
  149640. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149641. */
  149642. export interface PhysicsHitData {
  149643. /**
  149644. * The force applied at the contact point
  149645. */
  149646. force: Vector3;
  149647. /**
  149648. * The contact point
  149649. */
  149650. contactPoint: Vector3;
  149651. /**
  149652. * The distance from the origin to the contact point
  149653. */
  149654. distanceFromOrigin: number;
  149655. }
  149656. /**
  149657. * Interface for radial explosion event data
  149658. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149659. */
  149660. export interface PhysicsRadialExplosionEventData {
  149661. /**
  149662. * A sphere used for the radial explosion event
  149663. */
  149664. sphere: Mesh;
  149665. }
  149666. /**
  149667. * Interface for gravitational field event data
  149668. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149669. */
  149670. export interface PhysicsGravitationalFieldEventData {
  149671. /**
  149672. * A sphere mesh used for the gravitational field event
  149673. */
  149674. sphere: Mesh;
  149675. }
  149676. /**
  149677. * Interface for updraft event data
  149678. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149679. */
  149680. export interface PhysicsUpdraftEventData {
  149681. /**
  149682. * A cylinder used for the updraft event
  149683. */
  149684. cylinder: Mesh;
  149685. }
  149686. /**
  149687. * Interface for vortex event data
  149688. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149689. */
  149690. export interface PhysicsVortexEventData {
  149691. /**
  149692. * A cylinder used for the vortex event
  149693. */
  149694. cylinder: Mesh;
  149695. }
  149696. /**
  149697. * Interface for an affected physics impostor
  149698. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine#further-functionality-of-the-impostor-class
  149699. */
  149700. export interface PhysicsAffectedImpostorWithData {
  149701. /**
  149702. * The impostor affected by the effect
  149703. */
  149704. impostor: PhysicsImpostor;
  149705. /**
  149706. * The data about the hit/horce from the explosion
  149707. */
  149708. hitData: PhysicsHitData;
  149709. }
  149710. }
  149711. declare module BABYLON {
  149712. /** @hidden */
  149713. export var blackAndWhitePixelShader: {
  149714. name: string;
  149715. shader: string;
  149716. };
  149717. }
  149718. declare module BABYLON {
  149719. /**
  149720. * Post process used to render in black and white
  149721. */
  149722. export class BlackAndWhitePostProcess extends PostProcess {
  149723. /**
  149724. * Linear about to convert he result to black and white (default: 1)
  149725. */
  149726. degree: number;
  149727. /**
  149728. * Gets a string identifying the name of the class
  149729. * @returns "BlackAndWhitePostProcess" string
  149730. */
  149731. getClassName(): string;
  149732. /**
  149733. * Creates a black and white post process
  149734. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  149735. * @param name The name of the effect.
  149736. * @param options The required width/height ratio to downsize to before computing the render pass.
  149737. * @param camera The camera to apply the render pass to.
  149738. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149739. * @param engine The engine which the post process will be applied. (default: current engine)
  149740. * @param reusable If the post process can be reused on the same frame. (default: false)
  149741. */
  149742. constructor(name: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  149743. /** @hidden */
  149744. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<BlackAndWhitePostProcess>;
  149745. }
  149746. }
  149747. declare module BABYLON {
  149748. /**
  149749. * This represents a set of one or more post processes in Babylon.
  149750. * A post process can be used to apply a shader to a texture after it is rendered.
  149751. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  149752. */
  149753. export class PostProcessRenderEffect {
  149754. private _postProcesses;
  149755. private _getPostProcesses;
  149756. private _singleInstance;
  149757. private _cameras;
  149758. private _indicesForCamera;
  149759. /**
  149760. * Name of the effect
  149761. * @hidden
  149762. */
  149763. _name: string;
  149764. /**
  149765. * Instantiates a post process render effect.
  149766. * A post process can be used to apply a shader to a texture after it is rendered.
  149767. * @param engine The engine the effect is tied to
  149768. * @param name The name of the effect
  149769. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  149770. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  149771. */
  149772. constructor(engine: Engine, name: string, getPostProcesses: () => Nullable<PostProcess | Array<PostProcess>>, singleInstance?: boolean);
  149773. /**
  149774. * Checks if all the post processes in the effect are supported.
  149775. */
  149776. get isSupported(): boolean;
  149777. /**
  149778. * Updates the current state of the effect
  149779. * @hidden
  149780. */
  149781. _update(): void;
  149782. /**
  149783. * Attaches the effect on cameras
  149784. * @param cameras The camera to attach to.
  149785. * @hidden
  149786. */
  149787. _attachCameras(cameras: Camera): void;
  149788. /**
  149789. * Attaches the effect on cameras
  149790. * @param cameras The camera to attach to.
  149791. * @hidden
  149792. */
  149793. _attachCameras(cameras: Camera[]): void;
  149794. /**
  149795. * Detaches the effect on cameras
  149796. * @param cameras The camera to detatch from.
  149797. * @hidden
  149798. */
  149799. _detachCameras(cameras: Camera): void;
  149800. /**
  149801. * Detatches the effect on cameras
  149802. * @param cameras The camera to detatch from.
  149803. * @hidden
  149804. */
  149805. _detachCameras(cameras: Camera[]): void;
  149806. /**
  149807. * Enables the effect on given cameras
  149808. * @param cameras The camera to enable.
  149809. * @hidden
  149810. */
  149811. _enable(cameras: Camera): void;
  149812. /**
  149813. * Enables the effect on given cameras
  149814. * @param cameras The camera to enable.
  149815. * @hidden
  149816. */
  149817. _enable(cameras: Nullable<Camera[]>): void;
  149818. /**
  149819. * Disables the effect on the given cameras
  149820. * @param cameras The camera to disable.
  149821. * @hidden
  149822. */
  149823. _disable(cameras: Camera): void;
  149824. /**
  149825. * Disables the effect on the given cameras
  149826. * @param cameras The camera to disable.
  149827. * @hidden
  149828. */
  149829. _disable(cameras: Nullable<Camera[]>): void;
  149830. /**
  149831. * Gets a list of the post processes contained in the effect.
  149832. * @param camera The camera to get the post processes on.
  149833. * @returns The list of the post processes in the effect.
  149834. */
  149835. getPostProcesses(camera?: Camera): Nullable<Array<PostProcess>>;
  149836. }
  149837. }
  149838. declare module BABYLON {
  149839. /** @hidden */
  149840. export var extractHighlightsPixelShader: {
  149841. name: string;
  149842. shader: string;
  149843. };
  149844. }
  149845. declare module BABYLON {
  149846. /**
  149847. * 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.
  149848. */
  149849. export class ExtractHighlightsPostProcess extends PostProcess {
  149850. /**
  149851. * The luminance threshold, pixels below this value will be set to black.
  149852. */
  149853. threshold: number;
  149854. /** @hidden */
  149855. _exposure: number;
  149856. /**
  149857. * Post process which has the input texture to be used when performing highlight extraction
  149858. * @hidden
  149859. */
  149860. _inputPostProcess: Nullable<PostProcess>;
  149861. /**
  149862. * Gets a string identifying the name of the class
  149863. * @returns "ExtractHighlightsPostProcess" string
  149864. */
  149865. getClassName(): string;
  149866. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149867. }
  149868. }
  149869. declare module BABYLON {
  149870. /** @hidden */
  149871. export var bloomMergePixelShader: {
  149872. name: string;
  149873. shader: string;
  149874. };
  149875. }
  149876. declare module BABYLON {
  149877. /**
  149878. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  149879. */
  149880. export class BloomMergePostProcess extends PostProcess {
  149881. /** Weight of the bloom to be added to the original input. */
  149882. weight: number;
  149883. /**
  149884. * Gets a string identifying the name of the class
  149885. * @returns "BloomMergePostProcess" string
  149886. */
  149887. getClassName(): string;
  149888. /**
  149889. * Creates a new instance of @see BloomMergePostProcess
  149890. * @param name The name of the effect.
  149891. * @param originalFromInput Post process which's input will be used for the merge.
  149892. * @param blurred Blurred highlights post process which's output will be used.
  149893. * @param weight Weight of the bloom to be added to the original input.
  149894. * @param options The required width/height ratio to downsize to before computing the render pass.
  149895. * @param camera The camera to apply the render pass to.
  149896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  149897. * @param engine The engine which the post process will be applied. (default: current engine)
  149898. * @param reusable If the post process can be reused on the same frame. (default: false)
  149899. * @param textureType Type of textures used when performing the post process. (default: 0)
  149900. * @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)
  149901. */
  149902. constructor(name: string, originalFromInput: PostProcess, blurred: PostProcess,
  149903. /** Weight of the bloom to be added to the original input. */
  149904. weight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  149905. }
  149906. }
  149907. declare module BABYLON {
  149908. /**
  149909. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  149910. */
  149911. export class BloomEffect extends PostProcessRenderEffect {
  149912. private bloomScale;
  149913. /**
  149914. * @hidden Internal
  149915. */
  149916. _effects: Array<PostProcess>;
  149917. /**
  149918. * @hidden Internal
  149919. */
  149920. _downscale: ExtractHighlightsPostProcess;
  149921. private _blurX;
  149922. private _blurY;
  149923. private _merge;
  149924. /**
  149925. * The luminance threshold to find bright areas of the image to bloom.
  149926. */
  149927. get threshold(): number;
  149928. set threshold(value: number);
  149929. /**
  149930. * The strength of the bloom.
  149931. */
  149932. get weight(): number;
  149933. set weight(value: number);
  149934. /**
  149935. * Specifies the size of the bloom blur kernel, relative to the final output size
  149936. */
  149937. get kernel(): number;
  149938. set kernel(value: number);
  149939. /**
  149940. * Creates a new instance of @see BloomEffect
  149941. * @param scene The scene the effect belongs to.
  149942. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  149943. * @param bloomKernel The size of the kernel to be used when applying the blur.
  149944. * @param bloomWeight The the strength of bloom.
  149945. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  149946. * @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)
  149947. */
  149948. constructor(scene: Scene, bloomScale: number, bloomWeight: number, bloomKernel: number, pipelineTextureType?: number, blockCompilation?: boolean);
  149949. /**
  149950. * Disposes each of the internal effects for a given camera.
  149951. * @param camera The camera to dispose the effect on.
  149952. */
  149953. disposeEffects(camera: Camera): void;
  149954. /**
  149955. * @hidden Internal
  149956. */
  149957. _updateEffects(): void;
  149958. /**
  149959. * Internal
  149960. * @returns if all the contained post processes are ready.
  149961. * @hidden
  149962. */
  149963. _isReady(): boolean;
  149964. }
  149965. }
  149966. declare module BABYLON {
  149967. /** @hidden */
  149968. export var chromaticAberrationPixelShader: {
  149969. name: string;
  149970. shader: string;
  149971. };
  149972. }
  149973. declare module BABYLON {
  149974. /**
  149975. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  149976. */
  149977. export class ChromaticAberrationPostProcess extends PostProcess {
  149978. /**
  149979. * The amount of seperation of rgb channels (default: 30)
  149980. */
  149981. aberrationAmount: number;
  149982. /**
  149983. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  149984. */
  149985. radialIntensity: number;
  149986. /**
  149987. * 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))
  149988. */
  149989. direction: Vector2;
  149990. /**
  149991. * 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))
  149992. */
  149993. centerPosition: Vector2;
  149994. /** The width of the screen to apply the effect on */
  149995. screenWidth: number;
  149996. /** The height of the screen to apply the effect on */
  149997. screenHeight: number;
  149998. /**
  149999. * Gets a string identifying the name of the class
  150000. * @returns "ChromaticAberrationPostProcess" string
  150001. */
  150002. getClassName(): string;
  150003. /**
  150004. * Creates a new instance ChromaticAberrationPostProcess
  150005. * @param name The name of the effect.
  150006. * @param screenWidth The width of the screen to apply the effect on.
  150007. * @param screenHeight The height of the screen to apply the effect on.
  150008. * @param options The required width/height ratio to downsize to before computing the render pass.
  150009. * @param camera The camera to apply the render pass to.
  150010. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150011. * @param engine The engine which the post process will be applied. (default: current engine)
  150012. * @param reusable If the post process can be reused on the same frame. (default: false)
  150013. * @param textureType Type of textures used when performing the post process. (default: 0)
  150014. * @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)
  150015. */
  150016. constructor(name: string, screenWidth: number, screenHeight: number, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150017. /** @hidden */
  150018. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ChromaticAberrationPostProcess>;
  150019. }
  150020. }
  150021. declare module BABYLON {
  150022. /** @hidden */
  150023. export var circleOfConfusionPixelShader: {
  150024. name: string;
  150025. shader: string;
  150026. };
  150027. }
  150028. declare module BABYLON {
  150029. /**
  150030. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  150031. */
  150032. export class CircleOfConfusionPostProcess extends PostProcess {
  150033. /**
  150034. * 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.
  150035. */
  150036. lensSize: number;
  150037. /**
  150038. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150039. */
  150040. fStop: number;
  150041. /**
  150042. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150043. */
  150044. focusDistance: number;
  150045. /**
  150046. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  150047. */
  150048. focalLength: number;
  150049. /**
  150050. * Gets a string identifying the name of the class
  150051. * @returns "CircleOfConfusionPostProcess" string
  150052. */
  150053. getClassName(): string;
  150054. private _depthTexture;
  150055. /**
  150056. * Creates a new instance CircleOfConfusionPostProcess
  150057. * @param name The name of the effect.
  150058. * @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.
  150059. * @param options The required width/height ratio to downsize to before computing the render pass.
  150060. * @param camera The camera to apply the render pass to.
  150061. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150062. * @param engine The engine which the post process will be applied. (default: current engine)
  150063. * @param reusable If the post process can be reused on the same frame. (default: false)
  150064. * @param textureType Type of textures used when performing the post process. (default: 0)
  150065. * @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)
  150066. */
  150067. constructor(name: string, depthTexture: Nullable<RenderTargetTexture>, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150068. /**
  150069. * 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.
  150070. */
  150071. set depthTexture(value: RenderTargetTexture);
  150072. }
  150073. }
  150074. declare module BABYLON {
  150075. /** @hidden */
  150076. export var colorCorrectionPixelShader: {
  150077. name: string;
  150078. shader: string;
  150079. };
  150080. }
  150081. declare module BABYLON {
  150082. /**
  150083. *
  150084. * This post-process allows the modification of rendered colors by using
  150085. * a 'look-up table' (LUT). This effect is also called Color Grading.
  150086. *
  150087. * The object needs to be provided an url to a texture containing the color
  150088. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  150089. * Use an image editing software to tweak the LUT to match your needs.
  150090. *
  150091. * For an example of a color LUT, see here:
  150092. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  150093. * For explanations on color grading, see here:
  150094. * @see http://udn.epicgames.com/Three/ColorGrading.html
  150095. *
  150096. */
  150097. export class ColorCorrectionPostProcess extends PostProcess {
  150098. private _colorTableTexture;
  150099. /**
  150100. * Gets the color table url used to create the LUT texture
  150101. */
  150102. colorTableUrl: string;
  150103. /**
  150104. * Gets a string identifying the name of the class
  150105. * @returns "ColorCorrectionPostProcess" string
  150106. */
  150107. getClassName(): string;
  150108. constructor(name: string, colorTableUrl: string, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150109. /** @hidden */
  150110. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ColorCorrectionPostProcess>;
  150111. }
  150112. }
  150113. declare module BABYLON {
  150114. /** @hidden */
  150115. export var convolutionPixelShader: {
  150116. name: string;
  150117. shader: string;
  150118. };
  150119. }
  150120. declare module BABYLON {
  150121. /**
  150122. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  150123. * input texture to perform effects such as edge detection or sharpening
  150124. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150125. */
  150126. export class ConvolutionPostProcess extends PostProcess {
  150127. /** Array of 9 values corresponding to the 3x3 kernel to be applied */
  150128. kernel: number[];
  150129. /**
  150130. * Gets a string identifying the name of the class
  150131. * @returns "ConvolutionPostProcess" string
  150132. */
  150133. getClassName(): string;
  150134. /**
  150135. * Creates a new instance ConvolutionPostProcess
  150136. * @param name The name of the effect.
  150137. * @param kernel Array of 9 values corresponding to the 3x3 kernel to be applied
  150138. * @param options The required width/height ratio to downsize to before computing the render pass.
  150139. * @param camera The camera to apply the render pass to.
  150140. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150141. * @param engine The engine which the post process will be applied. (default: current engine)
  150142. * @param reusable If the post process can be reused on the same frame. (default: false)
  150143. * @param textureType Type of textures used when performing the post process. (default: 0)
  150144. */
  150145. constructor(name: string, kernel: number[], options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150146. /** @hidden */
  150147. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<ConvolutionPostProcess>;
  150148. /**
  150149. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150150. */
  150151. static EdgeDetect0Kernel: number[];
  150152. /**
  150153. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150154. */
  150155. static EdgeDetect1Kernel: number[];
  150156. /**
  150157. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150158. */
  150159. static EdgeDetect2Kernel: number[];
  150160. /**
  150161. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150162. */
  150163. static SharpenKernel: number[];
  150164. /**
  150165. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150166. */
  150167. static EmbossKernel: number[];
  150168. /**
  150169. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  150170. */
  150171. static GaussianKernel: number[];
  150172. }
  150173. }
  150174. declare module BABYLON {
  150175. /**
  150176. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  150177. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  150178. * based on samples that have a large difference in distance than the center pixel.
  150179. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  150180. */
  150181. export class DepthOfFieldBlurPostProcess extends BlurPostProcess {
  150182. /**
  150183. * The direction the blur should be applied
  150184. */
  150185. direction: Vector2;
  150186. /**
  150187. * Gets a string identifying the name of the class
  150188. * @returns "DepthOfFieldBlurPostProcess" string
  150189. */
  150190. getClassName(): string;
  150191. /**
  150192. * Creates a new instance CircleOfConfusionPostProcess
  150193. * @param name The name of the effect.
  150194. * @param scene The scene the effect belongs to.
  150195. * @param direction The direction the blur should be applied.
  150196. * @param kernel The size of the kernel used to blur.
  150197. * @param options The required width/height ratio to downsize to before computing the render pass.
  150198. * @param camera The camera to apply the render pass to.
  150199. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  150200. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  150201. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150202. * @param engine The engine which the post process will be applied. (default: current engine)
  150203. * @param reusable If the post process can be reused on the same frame. (default: false)
  150204. * @param textureType Type of textures used when performing the post process. (default: 0)
  150205. * @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)
  150206. */
  150207. 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);
  150208. }
  150209. }
  150210. declare module BABYLON {
  150211. /** @hidden */
  150212. export var depthOfFieldMergePixelShader: {
  150213. name: string;
  150214. shader: string;
  150215. };
  150216. }
  150217. declare module BABYLON {
  150218. /**
  150219. * Options to be set when merging outputs from the default pipeline.
  150220. */
  150221. export class DepthOfFieldMergePostProcessOptions {
  150222. /**
  150223. * The original image to merge on top of
  150224. */
  150225. originalFromInput: PostProcess;
  150226. /**
  150227. * Parameters to perform the merge of the depth of field effect
  150228. */
  150229. depthOfField?: {
  150230. circleOfConfusion: PostProcess;
  150231. blurSteps: Array<PostProcess>;
  150232. };
  150233. /**
  150234. * Parameters to perform the merge of bloom effect
  150235. */
  150236. bloom?: {
  150237. blurred: PostProcess;
  150238. weight: number;
  150239. };
  150240. }
  150241. /**
  150242. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  150243. */
  150244. export class DepthOfFieldMergePostProcess extends PostProcess {
  150245. private blurSteps;
  150246. /**
  150247. * Gets a string identifying the name of the class
  150248. * @returns "DepthOfFieldMergePostProcess" string
  150249. */
  150250. getClassName(): string;
  150251. /**
  150252. * Creates a new instance of DepthOfFieldMergePostProcess
  150253. * @param name The name of the effect.
  150254. * @param originalFromInput Post process which's input will be used for the merge.
  150255. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  150256. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  150257. * @param options The required width/height ratio to downsize to before computing the render pass.
  150258. * @param camera The camera to apply the render pass to.
  150259. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150260. * @param engine The engine which the post process will be applied. (default: current engine)
  150261. * @param reusable If the post process can be reused on the same frame. (default: false)
  150262. * @param textureType Type of textures used when performing the post process. (default: 0)
  150263. * @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)
  150264. */
  150265. 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);
  150266. /**
  150267. * Updates the effect with the current post process compile time values and recompiles the shader.
  150268. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  150269. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  150270. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  150271. * @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
  150272. * @param onCompiled Called when the shader has been compiled.
  150273. * @param onError Called if there is an error when compiling a shader.
  150274. */
  150275. updateEffect(defines?: Nullable<string>, uniforms?: Nullable<string[]>, samplers?: Nullable<string[]>, indexParameters?: any, onCompiled?: (effect: Effect) => void, onError?: (effect: Effect, errors: string) => void): void;
  150276. }
  150277. }
  150278. declare module BABYLON {
  150279. /**
  150280. * Specifies the level of max blur that should be applied when using the depth of field effect
  150281. */
  150282. export enum DepthOfFieldEffectBlurLevel {
  150283. /**
  150284. * Subtle blur
  150285. */
  150286. Low = 0,
  150287. /**
  150288. * Medium blur
  150289. */
  150290. Medium = 1,
  150291. /**
  150292. * Large blur
  150293. */
  150294. High = 2
  150295. }
  150296. /**
  150297. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  150298. */
  150299. export class DepthOfFieldEffect extends PostProcessRenderEffect {
  150300. private _circleOfConfusion;
  150301. /**
  150302. * @hidden Internal, blurs from high to low
  150303. */
  150304. _depthOfFieldBlurX: Array<DepthOfFieldBlurPostProcess>;
  150305. private _depthOfFieldBlurY;
  150306. private _dofMerge;
  150307. /**
  150308. * @hidden Internal post processes in depth of field effect
  150309. */
  150310. _effects: Array<PostProcess>;
  150311. /**
  150312. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  150313. */
  150314. set focalLength(value: number);
  150315. get focalLength(): number;
  150316. /**
  150317. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  150318. */
  150319. set fStop(value: number);
  150320. get fStop(): number;
  150321. /**
  150322. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  150323. */
  150324. set focusDistance(value: number);
  150325. get focusDistance(): number;
  150326. /**
  150327. * 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.
  150328. */
  150329. set lensSize(value: number);
  150330. get lensSize(): number;
  150331. /**
  150332. * Creates a new instance DepthOfFieldEffect
  150333. * @param scene The scene the effect belongs to.
  150334. * @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.
  150335. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  150336. * @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)
  150337. */
  150338. constructor(scene: Scene, depthTexture: Nullable<RenderTargetTexture>, blurLevel?: DepthOfFieldEffectBlurLevel, pipelineTextureType?: number, blockCompilation?: boolean);
  150339. /**
  150340. * Get the current class name of the current effet
  150341. * @returns "DepthOfFieldEffect"
  150342. */
  150343. getClassName(): string;
  150344. /**
  150345. * 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.
  150346. */
  150347. set depthTexture(value: RenderTargetTexture);
  150348. /**
  150349. * Disposes each of the internal effects for a given camera.
  150350. * @param camera The camera to dispose the effect on.
  150351. */
  150352. disposeEffects(camera: Camera): void;
  150353. /**
  150354. * @hidden Internal
  150355. */
  150356. _updateEffects(): void;
  150357. /**
  150358. * Internal
  150359. * @returns if all the contained post processes are ready.
  150360. * @hidden
  150361. */
  150362. _isReady(): boolean;
  150363. }
  150364. }
  150365. declare module BABYLON {
  150366. /** @hidden */
  150367. export var displayPassPixelShader: {
  150368. name: string;
  150369. shader: string;
  150370. };
  150371. }
  150372. declare module BABYLON {
  150373. /**
  150374. * DisplayPassPostProcess which produces an output the same as it's input
  150375. */
  150376. export class DisplayPassPostProcess extends PostProcess {
  150377. /**
  150378. * Gets a string identifying the name of the class
  150379. * @returns "DisplayPassPostProcess" string
  150380. */
  150381. getClassName(): string;
  150382. /**
  150383. * Creates the DisplayPassPostProcess
  150384. * @param name The name of the effect.
  150385. * @param options The required width/height ratio to downsize to before computing the render pass.
  150386. * @param camera The camera to apply the render pass to.
  150387. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150388. * @param engine The engine which the post process will be applied. (default: current engine)
  150389. * @param reusable If the post process can be reused on the same frame. (default: false)
  150390. */
  150391. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150392. /** @hidden */
  150393. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<DisplayPassPostProcess>;
  150394. }
  150395. }
  150396. declare module BABYLON {
  150397. /** @hidden */
  150398. export var filterPixelShader: {
  150399. name: string;
  150400. shader: string;
  150401. };
  150402. }
  150403. declare module BABYLON {
  150404. /**
  150405. * Applies a kernel filter to the image
  150406. */
  150407. export class FilterPostProcess extends PostProcess {
  150408. /** The matrix to be applied to the image */
  150409. kernelMatrix: Matrix;
  150410. /**
  150411. * Gets a string identifying the name of the class
  150412. * @returns "FilterPostProcess" string
  150413. */
  150414. getClassName(): string;
  150415. /**
  150416. *
  150417. * @param name The name of the effect.
  150418. * @param kernelMatrix The matrix to be applied to the image
  150419. * @param options The required width/height ratio to downsize to before computing the render pass.
  150420. * @param camera The camera to apply the render pass to.
  150421. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150422. * @param engine The engine which the post process will be applied. (default: current engine)
  150423. * @param reusable If the post process can be reused on the same frame. (default: false)
  150424. */
  150425. constructor(name: string, kernelMatrix: Matrix, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150426. /** @hidden */
  150427. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<FilterPostProcess>;
  150428. }
  150429. }
  150430. declare module BABYLON {
  150431. /** @hidden */
  150432. export var fxaaPixelShader: {
  150433. name: string;
  150434. shader: string;
  150435. };
  150436. }
  150437. declare module BABYLON {
  150438. /** @hidden */
  150439. export var fxaaVertexShader: {
  150440. name: string;
  150441. shader: string;
  150442. };
  150443. }
  150444. declare module BABYLON {
  150445. /**
  150446. * Fxaa post process
  150447. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  150448. */
  150449. export class FxaaPostProcess extends PostProcess {
  150450. /**
  150451. * Gets a string identifying the name of the class
  150452. * @returns "FxaaPostProcess" string
  150453. */
  150454. getClassName(): string;
  150455. constructor(name: string, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150456. private _getDefines;
  150457. /** @hidden */
  150458. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): FxaaPostProcess;
  150459. }
  150460. }
  150461. declare module BABYLON {
  150462. /** @hidden */
  150463. export var grainPixelShader: {
  150464. name: string;
  150465. shader: string;
  150466. };
  150467. }
  150468. declare module BABYLON {
  150469. /**
  150470. * The GrainPostProcess adds noise to the image at mid luminance levels
  150471. */
  150472. export class GrainPostProcess extends PostProcess {
  150473. /**
  150474. * The intensity of the grain added (default: 30)
  150475. */
  150476. intensity: number;
  150477. /**
  150478. * If the grain should be randomized on every frame
  150479. */
  150480. animated: boolean;
  150481. /**
  150482. * Gets a string identifying the name of the class
  150483. * @returns "GrainPostProcess" string
  150484. */
  150485. getClassName(): string;
  150486. /**
  150487. * Creates a new instance of @see GrainPostProcess
  150488. * @param name The name of the effect.
  150489. * @param options The required width/height ratio to downsize to before computing the render pass.
  150490. * @param camera The camera to apply the render pass to.
  150491. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150492. * @param engine The engine which the post process will be applied. (default: current engine)
  150493. * @param reusable If the post process can be reused on the same frame. (default: false)
  150494. * @param textureType Type of textures used when performing the post process. (default: 0)
  150495. * @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)
  150496. */
  150497. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150498. /** @hidden */
  150499. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): GrainPostProcess;
  150500. }
  150501. }
  150502. declare module BABYLON {
  150503. /** @hidden */
  150504. export var highlightsPixelShader: {
  150505. name: string;
  150506. shader: string;
  150507. };
  150508. }
  150509. declare module BABYLON {
  150510. /**
  150511. * Extracts highlights from the image
  150512. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150513. */
  150514. export class HighlightsPostProcess extends PostProcess {
  150515. /**
  150516. * Gets a string identifying the name of the class
  150517. * @returns "HighlightsPostProcess" string
  150518. */
  150519. getClassName(): string;
  150520. /**
  150521. * Extracts highlights from the image
  150522. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  150523. * @param name The name of the effect.
  150524. * @param options The required width/height ratio to downsize to before computing the render pass.
  150525. * @param camera The camera to apply the render pass to.
  150526. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150527. * @param engine The engine which the post process will be applied. (default: current engine)
  150528. * @param reusable If the post process can be reused on the same frame. (default: false)
  150529. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  150530. */
  150531. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  150532. }
  150533. }
  150534. declare module BABYLON {
  150535. /** @hidden */
  150536. export var mrtFragmentDeclaration: {
  150537. name: string;
  150538. shader: string;
  150539. };
  150540. }
  150541. declare module BABYLON {
  150542. /** @hidden */
  150543. export var geometryPixelShader: {
  150544. name: string;
  150545. shader: string;
  150546. };
  150547. }
  150548. declare module BABYLON {
  150549. /** @hidden */
  150550. export var geometryVertexShader: {
  150551. name: string;
  150552. shader: string;
  150553. };
  150554. }
  150555. declare module BABYLON {
  150556. /** @hidden */
  150557. interface ISavedTransformationMatrix {
  150558. world: Matrix;
  150559. viewProjection: Matrix;
  150560. }
  150561. /**
  150562. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  150563. */
  150564. export class GeometryBufferRenderer {
  150565. /**
  150566. * Constant used to retrieve the position texture index in the G-Buffer textures array
  150567. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  150568. */
  150569. static readonly POSITION_TEXTURE_TYPE: number;
  150570. /**
  150571. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  150572. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  150573. */
  150574. static readonly VELOCITY_TEXTURE_TYPE: number;
  150575. /**
  150576. * Constant used to retrieve the reflectivity texture index in the G-Buffer textures array
  150577. * using the getIndex(GeometryBufferRenderer.REFLECTIVITY_TEXTURE_TYPE)
  150578. */
  150579. static readonly REFLECTIVITY_TEXTURE_TYPE: number;
  150580. /**
  150581. * Dictionary used to store the previous transformation matrices of each rendered mesh
  150582. * in order to compute objects velocities when enableVelocity is set to "true"
  150583. * @hidden
  150584. */
  150585. _previousTransformationMatrices: {
  150586. [index: number]: ISavedTransformationMatrix;
  150587. };
  150588. /**
  150589. * Dictionary used to store the previous bones transformation matrices of each rendered mesh
  150590. * in order to compute objects velocities when enableVelocity is set to "true"
  150591. * @hidden
  150592. */
  150593. _previousBonesTransformationMatrices: {
  150594. [index: number]: Float32Array;
  150595. };
  150596. /**
  150597. * Array used to store the ignored skinned meshes while computing velocity map (typically used by the motion blur post-process).
  150598. * Avoids computing bones velocities and computes only mesh's velocity itself (position, rotation, scaling).
  150599. */
  150600. excludedSkinnedMeshesFromVelocity: AbstractMesh[];
  150601. /** Gets or sets a boolean indicating if transparent meshes should be rendered */
  150602. renderTransparentMeshes: boolean;
  150603. private _scene;
  150604. private _resizeObserver;
  150605. private _multiRenderTarget;
  150606. private _ratio;
  150607. private _enablePosition;
  150608. private _enableVelocity;
  150609. private _enableReflectivity;
  150610. private _positionIndex;
  150611. private _velocityIndex;
  150612. private _reflectivityIndex;
  150613. protected _effect: Effect;
  150614. protected _cachedDefines: string;
  150615. /**
  150616. * Set the render list (meshes to be rendered) used in the G buffer.
  150617. */
  150618. set renderList(meshes: Mesh[]);
  150619. /**
  150620. * Gets wether or not G buffer are supported by the running hardware.
  150621. * This requires draw buffer supports
  150622. */
  150623. get isSupported(): boolean;
  150624. /**
  150625. * Returns the index of the given texture type in the G-Buffer textures array
  150626. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  150627. * @returns the index of the given texture type in the G-Buffer textures array
  150628. */
  150629. getTextureIndex(textureType: number): number;
  150630. /**
  150631. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  150632. */
  150633. get enablePosition(): boolean;
  150634. /**
  150635. * Sets whether or not objects positions are enabled for the G buffer.
  150636. */
  150637. set enablePosition(enable: boolean);
  150638. /**
  150639. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  150640. */
  150641. get enableVelocity(): boolean;
  150642. /**
  150643. * Sets wether or not objects velocities are enabled for the G buffer.
  150644. */
  150645. set enableVelocity(enable: boolean);
  150646. /**
  150647. * Gets a boolean indicating if objects roughness are enabled in the G buffer.
  150648. */
  150649. get enableReflectivity(): boolean;
  150650. /**
  150651. * Sets wether or not objects roughness are enabled for the G buffer.
  150652. */
  150653. set enableReflectivity(enable: boolean);
  150654. /**
  150655. * Gets the scene associated with the buffer.
  150656. */
  150657. get scene(): Scene;
  150658. /**
  150659. * Gets the ratio used by the buffer during its creation.
  150660. * How big is the buffer related to the main canvas.
  150661. */
  150662. get ratio(): number;
  150663. /** @hidden */
  150664. static _SceneComponentInitialization: (scene: Scene) => void;
  150665. /**
  150666. * Creates a new G Buffer for the scene
  150667. * @param scene The scene the buffer belongs to
  150668. * @param ratio How big is the buffer related to the main canvas.
  150669. */
  150670. constructor(scene: Scene, ratio?: number);
  150671. /**
  150672. * Checks wether everything is ready to render a submesh to the G buffer.
  150673. * @param subMesh the submesh to check readiness for
  150674. * @param useInstances is the mesh drawn using instance or not
  150675. * @returns true if ready otherwise false
  150676. */
  150677. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  150678. /**
  150679. * Gets the current underlying G Buffer.
  150680. * @returns the buffer
  150681. */
  150682. getGBuffer(): MultiRenderTarget;
  150683. /**
  150684. * Gets the number of samples used to render the buffer (anti aliasing).
  150685. */
  150686. get samples(): number;
  150687. /**
  150688. * Sets the number of samples used to render the buffer (anti aliasing).
  150689. */
  150690. set samples(value: number);
  150691. /**
  150692. * Disposes the renderer and frees up associated resources.
  150693. */
  150694. dispose(): void;
  150695. protected _createRenderTargets(): void;
  150696. private _copyBonesTransformationMatrices;
  150697. }
  150698. }
  150699. declare module BABYLON {
  150700. /**
  150701. * Contains all parameters needed for the prepass to perform
  150702. * motion blur
  150703. */
  150704. export class MotionBlurConfiguration implements PrePassEffectConfiguration {
  150705. /**
  150706. * Is motion blur enabled
  150707. */
  150708. enabled: boolean;
  150709. /**
  150710. * Name of the configuration
  150711. */
  150712. name: string;
  150713. /**
  150714. * Textures that should be present in the MRT for this effect to work
  150715. */
  150716. readonly texturesRequired: number[];
  150717. }
  150718. }
  150719. declare module BABYLON {
  150720. interface Scene {
  150721. /** @hidden (Backing field) */
  150722. _geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150723. /**
  150724. * Gets or Sets the current geometry buffer associated to the scene.
  150725. */
  150726. geometryBufferRenderer: Nullable<GeometryBufferRenderer>;
  150727. /**
  150728. * Enables a GeometryBufferRender and associates it with the scene
  150729. * @param ratio defines the scaling ratio to apply to the renderer (1 by default which means same resolution)
  150730. * @returns the GeometryBufferRenderer
  150731. */
  150732. enableGeometryBufferRenderer(ratio?: number): Nullable<GeometryBufferRenderer>;
  150733. /**
  150734. * Disables the GeometryBufferRender associated with the scene
  150735. */
  150736. disableGeometryBufferRenderer(): void;
  150737. }
  150738. /**
  150739. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  150740. * in several rendering techniques.
  150741. */
  150742. export class GeometryBufferRendererSceneComponent implements ISceneComponent {
  150743. /**
  150744. * The component name helpful to identify the component in the list of scene components.
  150745. */
  150746. readonly name: string;
  150747. /**
  150748. * The scene the component belongs to.
  150749. */
  150750. scene: Scene;
  150751. /**
  150752. * Creates a new instance of the component for the given scene
  150753. * @param scene Defines the scene to register the component in
  150754. */
  150755. constructor(scene: Scene);
  150756. /**
  150757. * Registers the component in a given scene
  150758. */
  150759. register(): void;
  150760. /**
  150761. * Rebuilds the elements related to this component in case of
  150762. * context lost for instance.
  150763. */
  150764. rebuild(): void;
  150765. /**
  150766. * Disposes the component and the associated ressources
  150767. */
  150768. dispose(): void;
  150769. private _gatherRenderTargets;
  150770. }
  150771. }
  150772. declare module BABYLON {
  150773. /** @hidden */
  150774. export var motionBlurPixelShader: {
  150775. name: string;
  150776. shader: string;
  150777. };
  150778. }
  150779. declare module BABYLON {
  150780. /**
  150781. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  150782. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  150783. * As an example, all you have to do is to create the post-process:
  150784. * var mb = new BABYLON.MotionBlurPostProcess(
  150785. * 'mb', // The name of the effect.
  150786. * scene, // The scene containing the objects to blur according to their velocity.
  150787. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  150788. * camera // The camera to apply the render pass to.
  150789. * );
  150790. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  150791. */
  150792. export class MotionBlurPostProcess extends PostProcess {
  150793. /**
  150794. * Defines how much the image is blurred by the movement. Default value is equal to 1
  150795. */
  150796. motionStrength: number;
  150797. /**
  150798. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  150799. */
  150800. get motionBlurSamples(): number;
  150801. /**
  150802. * Sets the number of iterations to be used for motion blur quality
  150803. */
  150804. set motionBlurSamples(samples: number);
  150805. private _motionBlurSamples;
  150806. private _forceGeometryBuffer;
  150807. private _geometryBufferRenderer;
  150808. private _prePassRenderer;
  150809. /**
  150810. * Gets a string identifying the name of the class
  150811. * @returns "MotionBlurPostProcess" string
  150812. */
  150813. getClassName(): string;
  150814. /**
  150815. * Creates a new instance MotionBlurPostProcess
  150816. * @param name The name of the effect.
  150817. * @param scene The scene containing the objects to blur according to their velocity.
  150818. * @param options The required width/height ratio to downsize to before computing the render pass.
  150819. * @param camera The camera to apply the render pass to.
  150820. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150821. * @param engine The engine which the post process will be applied. (default: current engine)
  150822. * @param reusable If the post process can be reused on the same frame. (default: false)
  150823. * @param textureType Type of textures used when performing the post process. (default: 0)
  150824. * @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)
  150825. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  150826. */
  150827. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  150828. /**
  150829. * Excludes the given skinned mesh from computing bones velocities.
  150830. * 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.
  150831. * @param skinnedMesh The mesh containing the skeleton to ignore when computing the velocity map.
  150832. */
  150833. excludeSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150834. /**
  150835. * Removes the given skinned mesh from the excluded meshes to integrate bones velocities while rendering the velocity map.
  150836. * @param skinnedMesh The mesh containing the skeleton that has been ignored previously.
  150837. * @see excludeSkinnedMesh to exclude a skinned mesh from bones velocity computation.
  150838. */
  150839. removeExcludedSkinnedMesh(skinnedMesh: AbstractMesh): void;
  150840. /**
  150841. * Disposes the post process.
  150842. * @param camera The camera to dispose the post process on.
  150843. */
  150844. dispose(camera?: Camera): void;
  150845. /** @hidden */
  150846. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): Nullable<MotionBlurPostProcess>;
  150847. }
  150848. }
  150849. declare module BABYLON {
  150850. /** @hidden */
  150851. export var refractionPixelShader: {
  150852. name: string;
  150853. shader: string;
  150854. };
  150855. }
  150856. declare module BABYLON {
  150857. /**
  150858. * Post process which applies a refractin texture
  150859. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150860. */
  150861. export class RefractionPostProcess extends PostProcess {
  150862. private _refTexture;
  150863. private _ownRefractionTexture;
  150864. /** the base color of the refraction (used to taint the rendering) */
  150865. color: Color3;
  150866. /** simulated refraction depth */
  150867. depth: number;
  150868. /** the coefficient of the base color (0 to remove base color tainting) */
  150869. colorLevel: number;
  150870. /** Gets the url used to load the refraction texture */
  150871. refractionTextureUrl: string;
  150872. /**
  150873. * Gets or sets the refraction texture
  150874. * Please note that you are responsible for disposing the texture if you set it manually
  150875. */
  150876. get refractionTexture(): Texture;
  150877. set refractionTexture(value: Texture);
  150878. /**
  150879. * Gets a string identifying the name of the class
  150880. * @returns "RefractionPostProcess" string
  150881. */
  150882. getClassName(): string;
  150883. /**
  150884. * Initializes the RefractionPostProcess
  150885. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  150886. * @param name The name of the effect.
  150887. * @param refractionTextureUrl Url of the refraction texture to use
  150888. * @param color the base color of the refraction (used to taint the rendering)
  150889. * @param depth simulated refraction depth
  150890. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  150891. * @param camera The camera to apply the render pass to.
  150892. * @param options The required width/height ratio to downsize to before computing the render pass.
  150893. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150894. * @param engine The engine which the post process will be applied. (default: current engine)
  150895. * @param reusable If the post process can be reused on the same frame. (default: false)
  150896. */
  150897. constructor(name: string, refractionTextureUrl: string, color: Color3, depth: number, colorLevel: number, options: number | PostProcessOptions, camera: Camera, samplingMode?: number, engine?: Engine, reusable?: boolean);
  150898. /**
  150899. * Disposes of the post process
  150900. * @param camera Camera to dispose post process on
  150901. */
  150902. dispose(camera: Camera): void;
  150903. /** @hidden */
  150904. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): RefractionPostProcess;
  150905. }
  150906. }
  150907. declare module BABYLON {
  150908. /** @hidden */
  150909. export var sharpenPixelShader: {
  150910. name: string;
  150911. shader: string;
  150912. };
  150913. }
  150914. declare module BABYLON {
  150915. /**
  150916. * The SharpenPostProcess applies a sharpen kernel to every pixel
  150917. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  150918. */
  150919. export class SharpenPostProcess extends PostProcess {
  150920. /**
  150921. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  150922. */
  150923. colorAmount: number;
  150924. /**
  150925. * How much sharpness should be applied (default: 0.3)
  150926. */
  150927. edgeAmount: number;
  150928. /**
  150929. * Gets a string identifying the name of the class
  150930. * @returns "SharpenPostProcess" string
  150931. */
  150932. getClassName(): string;
  150933. /**
  150934. * Creates a new instance ConvolutionPostProcess
  150935. * @param name The name of the effect.
  150936. * @param options The required width/height ratio to downsize to before computing the render pass.
  150937. * @param camera The camera to apply the render pass to.
  150938. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  150939. * @param engine The engine which the post process will be applied. (default: current engine)
  150940. * @param reusable If the post process can be reused on the same frame. (default: false)
  150941. * @param textureType Type of textures used when performing the post process. (default: 0)
  150942. * @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)
  150943. */
  150944. constructor(name: string, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  150945. /** @hidden */
  150946. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): SharpenPostProcess;
  150947. }
  150948. }
  150949. declare module BABYLON {
  150950. /**
  150951. * PostProcessRenderPipeline
  150952. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  150953. */
  150954. export class PostProcessRenderPipeline {
  150955. private engine;
  150956. private _renderEffects;
  150957. private _renderEffectsForIsolatedPass;
  150958. /**
  150959. * List of inspectable custom properties (used by the Inspector)
  150960. * @see https://doc.babylonjs.com/how_to/debug_layer#extensibility
  150961. */
  150962. inspectableCustomProperties: IInspectable[];
  150963. /**
  150964. * @hidden
  150965. */
  150966. protected _cameras: Camera[];
  150967. /** @hidden */
  150968. _name: string;
  150969. /**
  150970. * Gets pipeline name
  150971. */
  150972. get name(): string;
  150973. /** Gets the list of attached cameras */
  150974. get cameras(): Camera[];
  150975. /**
  150976. * Initializes a PostProcessRenderPipeline
  150977. * @param engine engine to add the pipeline to
  150978. * @param name name of the pipeline
  150979. */
  150980. constructor(engine: Engine, name: string);
  150981. /**
  150982. * Gets the class name
  150983. * @returns "PostProcessRenderPipeline"
  150984. */
  150985. getClassName(): string;
  150986. /**
  150987. * If all the render effects in the pipeline are supported
  150988. */
  150989. get isSupported(): boolean;
  150990. /**
  150991. * Adds an effect to the pipeline
  150992. * @param renderEffect the effect to add
  150993. */
  150994. addEffect(renderEffect: PostProcessRenderEffect): void;
  150995. /** @hidden */
  150996. _rebuild(): void;
  150997. /** @hidden */
  150998. _enableEffect(renderEffectName: string, cameras: Camera): void;
  150999. /** @hidden */
  151000. _enableEffect(renderEffectName: string, cameras: Camera[]): void;
  151001. /** @hidden */
  151002. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151003. /** @hidden */
  151004. _disableEffect(renderEffectName: string, cameras: Nullable<Camera[]>): void;
  151005. /** @hidden */
  151006. _attachCameras(cameras: Camera, unique: boolean): void;
  151007. /** @hidden */
  151008. _attachCameras(cameras: Camera[], unique: boolean): void;
  151009. /** @hidden */
  151010. _detachCameras(cameras: Camera): void;
  151011. /** @hidden */
  151012. _detachCameras(cameras: Nullable<Camera[]>): void;
  151013. /** @hidden */
  151014. _update(): void;
  151015. /** @hidden */
  151016. _reset(): void;
  151017. protected _enableMSAAOnFirstPostProcess(sampleCount: number): boolean;
  151018. /**
  151019. * Sets the required values to the prepass renderer.
  151020. * @param prePassRenderer defines the prepass renderer to setup.
  151021. * @returns true if the pre pass is needed.
  151022. */
  151023. setPrePassRenderer(prePassRenderer: PrePassRenderer): boolean;
  151024. /**
  151025. * Disposes of the pipeline
  151026. */
  151027. dispose(): void;
  151028. }
  151029. }
  151030. declare module BABYLON {
  151031. /**
  151032. * PostProcessRenderPipelineManager class
  151033. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151034. */
  151035. export class PostProcessRenderPipelineManager {
  151036. private _renderPipelines;
  151037. /**
  151038. * Initializes a PostProcessRenderPipelineManager
  151039. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151040. */
  151041. constructor();
  151042. /**
  151043. * Gets the list of supported render pipelines
  151044. */
  151045. get supportedPipelines(): PostProcessRenderPipeline[];
  151046. /**
  151047. * Adds a pipeline to the manager
  151048. * @param renderPipeline The pipeline to add
  151049. */
  151050. addPipeline(renderPipeline: PostProcessRenderPipeline): void;
  151051. /**
  151052. * Attaches a camera to the pipeline
  151053. * @param renderPipelineName The name of the pipeline to attach to
  151054. * @param cameras the camera to attach
  151055. * @param unique if the camera can be attached multiple times to the pipeline
  151056. */
  151057. attachCamerasToRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera, unique?: boolean): void;
  151058. /**
  151059. * Detaches a camera from the pipeline
  151060. * @param renderPipelineName The name of the pipeline to detach from
  151061. * @param cameras the camera to detach
  151062. */
  151063. detachCamerasFromRenderPipeline(renderPipelineName: string, cameras: any | Camera[] | Camera): void;
  151064. /**
  151065. * Enables an effect by name on a pipeline
  151066. * @param renderPipelineName the name of the pipeline to enable the effect in
  151067. * @param renderEffectName the name of the effect to enable
  151068. * @param cameras the cameras that the effect should be enabled on
  151069. */
  151070. enableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151071. /**
  151072. * Disables an effect by name on a pipeline
  151073. * @param renderPipelineName the name of the pipeline to disable the effect in
  151074. * @param renderEffectName the name of the effect to disable
  151075. * @param cameras the cameras that the effect should be disabled on
  151076. */
  151077. disableEffectInPipeline(renderPipelineName: string, renderEffectName: string, cameras: any | Camera[] | Camera): void;
  151078. /**
  151079. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  151080. */
  151081. update(): void;
  151082. /** @hidden */
  151083. _rebuild(): void;
  151084. /**
  151085. * Disposes of the manager and pipelines
  151086. */
  151087. dispose(): void;
  151088. }
  151089. }
  151090. declare module BABYLON {
  151091. interface Scene {
  151092. /** @hidden (Backing field) */
  151093. _postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151094. /**
  151095. * Gets the postprocess render pipeline manager
  151096. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  151097. * @see https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151098. */
  151099. readonly postProcessRenderPipelineManager: PostProcessRenderPipelineManager;
  151100. }
  151101. /**
  151102. * Defines the Render Pipeline scene component responsible to rendering pipelines
  151103. */
  151104. export class PostProcessRenderPipelineManagerSceneComponent implements ISceneComponent {
  151105. /**
  151106. * The component name helpfull to identify the component in the list of scene components.
  151107. */
  151108. readonly name: string;
  151109. /**
  151110. * The scene the component belongs to.
  151111. */
  151112. scene: Scene;
  151113. /**
  151114. * Creates a new instance of the component for the given scene
  151115. * @param scene Defines the scene to register the component in
  151116. */
  151117. constructor(scene: Scene);
  151118. /**
  151119. * Registers the component in a given scene
  151120. */
  151121. register(): void;
  151122. /**
  151123. * Rebuilds the elements related to this component in case of
  151124. * context lost for instance.
  151125. */
  151126. rebuild(): void;
  151127. /**
  151128. * Disposes the component and the associated ressources
  151129. */
  151130. dispose(): void;
  151131. private _gatherRenderTargets;
  151132. }
  151133. }
  151134. declare module BABYLON {
  151135. /**
  151136. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  151137. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  151138. */
  151139. export class DefaultRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  151140. private _scene;
  151141. private _camerasToBeAttached;
  151142. /**
  151143. * ID of the sharpen post process,
  151144. */
  151145. private readonly SharpenPostProcessId;
  151146. /**
  151147. * @ignore
  151148. * ID of the image processing post process;
  151149. */
  151150. readonly ImageProcessingPostProcessId: string;
  151151. /**
  151152. * @ignore
  151153. * ID of the Fast Approximate Anti-Aliasing post process;
  151154. */
  151155. readonly FxaaPostProcessId: string;
  151156. /**
  151157. * ID of the chromatic aberration post process,
  151158. */
  151159. private readonly ChromaticAberrationPostProcessId;
  151160. /**
  151161. * ID of the grain post process
  151162. */
  151163. private readonly GrainPostProcessId;
  151164. /**
  151165. * Sharpen post process which will apply a sharpen convolution to enhance edges
  151166. */
  151167. sharpen: SharpenPostProcess;
  151168. private _sharpenEffect;
  151169. private bloom;
  151170. /**
  151171. * Depth of field effect, applies a blur based on how far away objects are from the focus distance.
  151172. */
  151173. depthOfField: DepthOfFieldEffect;
  151174. /**
  151175. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  151176. */
  151177. fxaa: FxaaPostProcess;
  151178. /**
  151179. * Image post processing pass used to perform operations such as tone mapping or color grading.
  151180. */
  151181. imageProcessing: ImageProcessingPostProcess;
  151182. /**
  151183. * Chromatic aberration post process which will shift rgb colors in the image
  151184. */
  151185. chromaticAberration: ChromaticAberrationPostProcess;
  151186. private _chromaticAberrationEffect;
  151187. /**
  151188. * Grain post process which add noise to the image
  151189. */
  151190. grain: GrainPostProcess;
  151191. private _grainEffect;
  151192. /**
  151193. * Glow post process which adds a glow to emissive areas of the image
  151194. */
  151195. private _glowLayer;
  151196. /**
  151197. * Animations which can be used to tweak settings over a period of time
  151198. */
  151199. animations: Animation[];
  151200. private _imageProcessingConfigurationObserver;
  151201. private _sharpenEnabled;
  151202. private _bloomEnabled;
  151203. private _depthOfFieldEnabled;
  151204. private _depthOfFieldBlurLevel;
  151205. private _fxaaEnabled;
  151206. private _imageProcessingEnabled;
  151207. private _defaultPipelineTextureType;
  151208. private _bloomScale;
  151209. private _chromaticAberrationEnabled;
  151210. private _grainEnabled;
  151211. private _buildAllowed;
  151212. /**
  151213. * Gets active scene
  151214. */
  151215. get scene(): Scene;
  151216. /**
  151217. * Enable or disable the sharpen process from the pipeline
  151218. */
  151219. set sharpenEnabled(enabled: boolean);
  151220. get sharpenEnabled(): boolean;
  151221. private _resizeObserver;
  151222. private _hardwareScaleLevel;
  151223. private _bloomKernel;
  151224. /**
  151225. * Specifies the size of the bloom blur kernel, relative to the final output size
  151226. */
  151227. get bloomKernel(): number;
  151228. set bloomKernel(value: number);
  151229. /**
  151230. * Specifies the weight of the bloom in the final rendering
  151231. */
  151232. private _bloomWeight;
  151233. /**
  151234. * Specifies the luma threshold for the area that will be blurred by the bloom
  151235. */
  151236. private _bloomThreshold;
  151237. private _hdr;
  151238. /**
  151239. * The strength of the bloom.
  151240. */
  151241. set bloomWeight(value: number);
  151242. get bloomWeight(): number;
  151243. /**
  151244. * The strength of the bloom.
  151245. */
  151246. set bloomThreshold(value: number);
  151247. get bloomThreshold(): number;
  151248. /**
  151249. * The scale of the bloom, lower value will provide better performance.
  151250. */
  151251. set bloomScale(value: number);
  151252. get bloomScale(): number;
  151253. /**
  151254. * Enable or disable the bloom from the pipeline
  151255. */
  151256. set bloomEnabled(enabled: boolean);
  151257. get bloomEnabled(): boolean;
  151258. private _rebuildBloom;
  151259. /**
  151260. * If the depth of field is enabled.
  151261. */
  151262. get depthOfFieldEnabled(): boolean;
  151263. set depthOfFieldEnabled(enabled: boolean);
  151264. /**
  151265. * Blur level of the depth of field effect. (Higher blur will effect performance)
  151266. */
  151267. get depthOfFieldBlurLevel(): DepthOfFieldEffectBlurLevel;
  151268. set depthOfFieldBlurLevel(value: DepthOfFieldEffectBlurLevel);
  151269. /**
  151270. * If the anti aliasing is enabled.
  151271. */
  151272. set fxaaEnabled(enabled: boolean);
  151273. get fxaaEnabled(): boolean;
  151274. private _samples;
  151275. /**
  151276. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  151277. */
  151278. set samples(sampleCount: number);
  151279. get samples(): number;
  151280. /**
  151281. * If image processing is enabled.
  151282. */
  151283. set imageProcessingEnabled(enabled: boolean);
  151284. get imageProcessingEnabled(): boolean;
  151285. /**
  151286. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  151287. */
  151288. set glowLayerEnabled(enabled: boolean);
  151289. get glowLayerEnabled(): boolean;
  151290. /**
  151291. * Gets the glow layer (or null if not defined)
  151292. */
  151293. get glowLayer(): Nullable<GlowLayer>;
  151294. /**
  151295. * Enable or disable the chromaticAberration process from the pipeline
  151296. */
  151297. set chromaticAberrationEnabled(enabled: boolean);
  151298. get chromaticAberrationEnabled(): boolean;
  151299. /**
  151300. * Enable or disable the grain process from the pipeline
  151301. */
  151302. set grainEnabled(enabled: boolean);
  151303. get grainEnabled(): boolean;
  151304. /**
  151305. * @constructor
  151306. * @param name - The rendering pipeline name (default: "")
  151307. * @param hdr - If high dynamic range textures should be used (default: true)
  151308. * @param scene - The scene linked to this pipeline (default: the last created scene)
  151309. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  151310. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  151311. */
  151312. constructor(name?: string, hdr?: boolean, scene?: Scene, cameras?: Camera[], automaticBuild?: boolean);
  151313. /**
  151314. * Get the class name
  151315. * @returns "DefaultRenderingPipeline"
  151316. */
  151317. getClassName(): string;
  151318. /**
  151319. * Force the compilation of the entire pipeline.
  151320. */
  151321. prepare(): void;
  151322. private _hasCleared;
  151323. private _prevPostProcess;
  151324. private _prevPrevPostProcess;
  151325. private _setAutoClearAndTextureSharing;
  151326. private _depthOfFieldSceneObserver;
  151327. private _buildPipeline;
  151328. private _disposePostProcesses;
  151329. /**
  151330. * Adds a camera to the pipeline
  151331. * @param camera the camera to be added
  151332. */
  151333. addCamera(camera: Camera): void;
  151334. /**
  151335. * Removes a camera from the pipeline
  151336. * @param camera the camera to remove
  151337. */
  151338. removeCamera(camera: Camera): void;
  151339. /**
  151340. * Dispose of the pipeline and stop all post processes
  151341. */
  151342. dispose(): void;
  151343. /**
  151344. * Serialize the rendering pipeline (Used when exporting)
  151345. * @returns the serialized object
  151346. */
  151347. serialize(): any;
  151348. /**
  151349. * Parse the serialized pipeline
  151350. * @param source Source pipeline.
  151351. * @param scene The scene to load the pipeline to.
  151352. * @param rootUrl The URL of the serialized pipeline.
  151353. * @returns An instantiated pipeline from the serialized object.
  151354. */
  151355. static Parse(source: any, scene: Scene, rootUrl: string): DefaultRenderingPipeline;
  151356. }
  151357. }
  151358. declare module BABYLON {
  151359. /** @hidden */
  151360. export var lensHighlightsPixelShader: {
  151361. name: string;
  151362. shader: string;
  151363. };
  151364. }
  151365. declare module BABYLON {
  151366. /** @hidden */
  151367. export var depthOfFieldPixelShader: {
  151368. name: string;
  151369. shader: string;
  151370. };
  151371. }
  151372. declare module BABYLON {
  151373. /**
  151374. * BABYLON.JS Chromatic Aberration GLSL Shader
  151375. * Author: Olivier Guyot
  151376. * Separates very slightly R, G and B colors on the edges of the screen
  151377. * Inspired by Francois Tarlier & Martins Upitis
  151378. */
  151379. export class LensRenderingPipeline extends PostProcessRenderPipeline {
  151380. /**
  151381. * @ignore
  151382. * The chromatic aberration PostProcess id in the pipeline
  151383. */
  151384. LensChromaticAberrationEffect: string;
  151385. /**
  151386. * @ignore
  151387. * The highlights enhancing PostProcess id in the pipeline
  151388. */
  151389. HighlightsEnhancingEffect: string;
  151390. /**
  151391. * @ignore
  151392. * The depth-of-field PostProcess id in the pipeline
  151393. */
  151394. LensDepthOfFieldEffect: string;
  151395. private _scene;
  151396. private _depthTexture;
  151397. private _grainTexture;
  151398. private _chromaticAberrationPostProcess;
  151399. private _highlightsPostProcess;
  151400. private _depthOfFieldPostProcess;
  151401. private _edgeBlur;
  151402. private _grainAmount;
  151403. private _chromaticAberration;
  151404. private _distortion;
  151405. private _highlightsGain;
  151406. private _highlightsThreshold;
  151407. private _dofDistance;
  151408. private _dofAperture;
  151409. private _dofDarken;
  151410. private _dofPentagon;
  151411. private _blurNoise;
  151412. /**
  151413. * @constructor
  151414. *
  151415. * Effect parameters are as follow:
  151416. * {
  151417. * chromatic_aberration: number; // from 0 to x (1 for realism)
  151418. * edge_blur: number; // from 0 to x (1 for realism)
  151419. * distortion: number; // from 0 to x (1 for realism)
  151420. * grain_amount: number; // from 0 to 1
  151421. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  151422. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  151423. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  151424. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  151425. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  151426. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  151427. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  151428. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  151429. * }
  151430. * Note: if an effect parameter is unset, effect is disabled
  151431. *
  151432. * @param name The rendering pipeline name
  151433. * @param parameters - An object containing all parameters (see above)
  151434. * @param scene The scene linked to this pipeline
  151435. * @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)
  151436. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151437. */
  151438. constructor(name: string, parameters: any, scene: Scene, ratio?: number, cameras?: Camera[]);
  151439. /**
  151440. * Get the class name
  151441. * @returns "LensRenderingPipeline"
  151442. */
  151443. getClassName(): string;
  151444. /**
  151445. * Gets associated scene
  151446. */
  151447. get scene(): Scene;
  151448. /**
  151449. * Gets or sets the edge blur
  151450. */
  151451. get edgeBlur(): number;
  151452. set edgeBlur(value: number);
  151453. /**
  151454. * Gets or sets the grain amount
  151455. */
  151456. get grainAmount(): number;
  151457. set grainAmount(value: number);
  151458. /**
  151459. * Gets or sets the chromatic aberration amount
  151460. */
  151461. get chromaticAberration(): number;
  151462. set chromaticAberration(value: number);
  151463. /**
  151464. * Gets or sets the depth of field aperture
  151465. */
  151466. get dofAperture(): number;
  151467. set dofAperture(value: number);
  151468. /**
  151469. * Gets or sets the edge distortion
  151470. */
  151471. get edgeDistortion(): number;
  151472. set edgeDistortion(value: number);
  151473. /**
  151474. * Gets or sets the depth of field distortion
  151475. */
  151476. get dofDistortion(): number;
  151477. set dofDistortion(value: number);
  151478. /**
  151479. * Gets or sets the darken out of focus amount
  151480. */
  151481. get darkenOutOfFocus(): number;
  151482. set darkenOutOfFocus(value: number);
  151483. /**
  151484. * Gets or sets a boolean indicating if blur noise is enabled
  151485. */
  151486. get blurNoise(): boolean;
  151487. set blurNoise(value: boolean);
  151488. /**
  151489. * Gets or sets a boolean indicating if pentagon bokeh is enabled
  151490. */
  151491. get pentagonBokeh(): boolean;
  151492. set pentagonBokeh(value: boolean);
  151493. /**
  151494. * Gets or sets the highlight grain amount
  151495. */
  151496. get highlightsGain(): number;
  151497. set highlightsGain(value: number);
  151498. /**
  151499. * Gets or sets the highlight threshold
  151500. */
  151501. get highlightsThreshold(): number;
  151502. set highlightsThreshold(value: number);
  151503. /**
  151504. * Sets the amount of blur at the edges
  151505. * @param amount blur amount
  151506. */
  151507. setEdgeBlur(amount: number): void;
  151508. /**
  151509. * Sets edge blur to 0
  151510. */
  151511. disableEdgeBlur(): void;
  151512. /**
  151513. * Sets the amout of grain
  151514. * @param amount Amount of grain
  151515. */
  151516. setGrainAmount(amount: number): void;
  151517. /**
  151518. * Set grain amount to 0
  151519. */
  151520. disableGrain(): void;
  151521. /**
  151522. * Sets the chromatic aberration amount
  151523. * @param amount amount of chromatic aberration
  151524. */
  151525. setChromaticAberration(amount: number): void;
  151526. /**
  151527. * Sets chromatic aberration amount to 0
  151528. */
  151529. disableChromaticAberration(): void;
  151530. /**
  151531. * Sets the EdgeDistortion amount
  151532. * @param amount amount of EdgeDistortion
  151533. */
  151534. setEdgeDistortion(amount: number): void;
  151535. /**
  151536. * Sets edge distortion to 0
  151537. */
  151538. disableEdgeDistortion(): void;
  151539. /**
  151540. * Sets the FocusDistance amount
  151541. * @param amount amount of FocusDistance
  151542. */
  151543. setFocusDistance(amount: number): void;
  151544. /**
  151545. * Disables depth of field
  151546. */
  151547. disableDepthOfField(): void;
  151548. /**
  151549. * Sets the Aperture amount
  151550. * @param amount amount of Aperture
  151551. */
  151552. setAperture(amount: number): void;
  151553. /**
  151554. * Sets the DarkenOutOfFocus amount
  151555. * @param amount amount of DarkenOutOfFocus
  151556. */
  151557. setDarkenOutOfFocus(amount: number): void;
  151558. private _pentagonBokehIsEnabled;
  151559. /**
  151560. * Creates a pentagon bokeh effect
  151561. */
  151562. enablePentagonBokeh(): void;
  151563. /**
  151564. * Disables the pentagon bokeh effect
  151565. */
  151566. disablePentagonBokeh(): void;
  151567. /**
  151568. * Enables noise blur
  151569. */
  151570. enableNoiseBlur(): void;
  151571. /**
  151572. * Disables noise blur
  151573. */
  151574. disableNoiseBlur(): void;
  151575. /**
  151576. * Sets the HighlightsGain amount
  151577. * @param amount amount of HighlightsGain
  151578. */
  151579. setHighlightsGain(amount: number): void;
  151580. /**
  151581. * Sets the HighlightsThreshold amount
  151582. * @param amount amount of HighlightsThreshold
  151583. */
  151584. setHighlightsThreshold(amount: number): void;
  151585. /**
  151586. * Disables highlights
  151587. */
  151588. disableHighlights(): void;
  151589. /**
  151590. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  151591. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  151592. */
  151593. dispose(disableDepthRender?: boolean): void;
  151594. private _createChromaticAberrationPostProcess;
  151595. private _createHighlightsPostProcess;
  151596. private _createDepthOfFieldPostProcess;
  151597. private _createGrainTexture;
  151598. }
  151599. }
  151600. declare module BABYLON {
  151601. /**
  151602. * Contains all parameters needed for the prepass to perform
  151603. * screen space subsurface scattering
  151604. */
  151605. export class SSAO2Configuration implements PrePassEffectConfiguration {
  151606. /**
  151607. * Is subsurface enabled
  151608. */
  151609. enabled: boolean;
  151610. /**
  151611. * Name of the configuration
  151612. */
  151613. name: string;
  151614. /**
  151615. * Textures that should be present in the MRT for this effect to work
  151616. */
  151617. readonly texturesRequired: number[];
  151618. }
  151619. }
  151620. declare module BABYLON {
  151621. /** @hidden */
  151622. export var ssao2PixelShader: {
  151623. name: string;
  151624. shader: string;
  151625. };
  151626. }
  151627. declare module BABYLON {
  151628. /** @hidden */
  151629. export var ssaoCombinePixelShader: {
  151630. name: string;
  151631. shader: string;
  151632. };
  151633. }
  151634. declare module BABYLON {
  151635. /**
  151636. * Render pipeline to produce ssao effect
  151637. */
  151638. export class SSAO2RenderingPipeline extends PostProcessRenderPipeline {
  151639. /**
  151640. * @ignore
  151641. * The PassPostProcess id in the pipeline that contains the original scene color
  151642. */
  151643. SSAOOriginalSceneColorEffect: string;
  151644. /**
  151645. * @ignore
  151646. * The SSAO PostProcess id in the pipeline
  151647. */
  151648. SSAORenderEffect: string;
  151649. /**
  151650. * @ignore
  151651. * The horizontal blur PostProcess id in the pipeline
  151652. */
  151653. SSAOBlurHRenderEffect: string;
  151654. /**
  151655. * @ignore
  151656. * The vertical blur PostProcess id in the pipeline
  151657. */
  151658. SSAOBlurVRenderEffect: string;
  151659. /**
  151660. * @ignore
  151661. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151662. */
  151663. SSAOCombineRenderEffect: string;
  151664. /**
  151665. * The output strength of the SSAO post-process. Default value is 1.0.
  151666. */
  151667. totalStrength: number;
  151668. /**
  151669. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  151670. */
  151671. maxZ: number;
  151672. /**
  151673. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  151674. */
  151675. minZAspect: number;
  151676. private _samples;
  151677. /**
  151678. * Number of samples used for the SSAO calculations. Default value is 8
  151679. */
  151680. set samples(n: number);
  151681. get samples(): number;
  151682. private _textureSamples;
  151683. /**
  151684. * Number of samples to use for antialiasing
  151685. */
  151686. set textureSamples(n: number);
  151687. get textureSamples(): number;
  151688. /**
  151689. * Force rendering the geometry through geometry buffer
  151690. */
  151691. private _forceGeometryBuffer;
  151692. /**
  151693. * Ratio object used for SSAO ratio and blur ratio
  151694. */
  151695. private _ratio;
  151696. /**
  151697. * Dynamically generated sphere sampler.
  151698. */
  151699. private _sampleSphere;
  151700. /**
  151701. * Blur filter offsets
  151702. */
  151703. private _samplerOffsets;
  151704. private _expensiveBlur;
  151705. /**
  151706. * If bilateral blur should be used
  151707. */
  151708. set expensiveBlur(b: boolean);
  151709. get expensiveBlur(): boolean;
  151710. /**
  151711. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  151712. */
  151713. radius: number;
  151714. /**
  151715. * The base color of the SSAO post-process
  151716. * The final result is "base + ssao" between [0, 1]
  151717. */
  151718. base: number;
  151719. /**
  151720. * Support test.
  151721. */
  151722. static get IsSupported(): boolean;
  151723. private _scene;
  151724. private _randomTexture;
  151725. private _originalColorPostProcess;
  151726. private _ssaoPostProcess;
  151727. private _blurHPostProcess;
  151728. private _blurVPostProcess;
  151729. private _ssaoCombinePostProcess;
  151730. private _prePassRenderer;
  151731. /**
  151732. * Gets active scene
  151733. */
  151734. get scene(): Scene;
  151735. /**
  151736. * @constructor
  151737. * @param name The rendering pipeline name
  151738. * @param scene The scene linked to this pipeline
  151739. * @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 }
  151740. * @param cameras The array of cameras that the rendering pipeline will be attached to
  151741. * @param forceGeometryBuffer Set to true if you want to use the legacy geometry buffer renderer
  151742. */
  151743. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[], forceGeometryBuffer?: boolean);
  151744. /**
  151745. * Get the class name
  151746. * @returns "SSAO2RenderingPipeline"
  151747. */
  151748. getClassName(): string;
  151749. /**
  151750. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151751. */
  151752. dispose(disableGeometryBufferRenderer?: boolean): void;
  151753. private _createBlurPostProcess;
  151754. /** @hidden */
  151755. _rebuild(): void;
  151756. private _bits;
  151757. private _radicalInverse_VdC;
  151758. private _hammersley;
  151759. private _hemisphereSample_uniform;
  151760. private _generateHemisphere;
  151761. private _getDefinesForSSAO;
  151762. private _createSSAOPostProcess;
  151763. private _createSSAOCombinePostProcess;
  151764. private _createRandomTexture;
  151765. /**
  151766. * Serialize the rendering pipeline (Used when exporting)
  151767. * @returns the serialized object
  151768. */
  151769. serialize(): any;
  151770. /**
  151771. * Parse the serialized pipeline
  151772. * @param source Source pipeline.
  151773. * @param scene The scene to load the pipeline to.
  151774. * @param rootUrl The URL of the serialized pipeline.
  151775. * @returns An instantiated pipeline from the serialized object.
  151776. */
  151777. static Parse(source: any, scene: Scene, rootUrl: string): SSAO2RenderingPipeline;
  151778. }
  151779. }
  151780. declare module BABYLON {
  151781. /** @hidden */
  151782. export var ssaoPixelShader: {
  151783. name: string;
  151784. shader: string;
  151785. };
  151786. }
  151787. declare module BABYLON {
  151788. /**
  151789. * Render pipeline to produce ssao effect
  151790. */
  151791. export class SSAORenderingPipeline extends PostProcessRenderPipeline {
  151792. /**
  151793. * @ignore
  151794. * The PassPostProcess id in the pipeline that contains the original scene color
  151795. */
  151796. SSAOOriginalSceneColorEffect: string;
  151797. /**
  151798. * @ignore
  151799. * The SSAO PostProcess id in the pipeline
  151800. */
  151801. SSAORenderEffect: string;
  151802. /**
  151803. * @ignore
  151804. * The horizontal blur PostProcess id in the pipeline
  151805. */
  151806. SSAOBlurHRenderEffect: string;
  151807. /**
  151808. * @ignore
  151809. * The vertical blur PostProcess id in the pipeline
  151810. */
  151811. SSAOBlurVRenderEffect: string;
  151812. /**
  151813. * @ignore
  151814. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  151815. */
  151816. SSAOCombineRenderEffect: string;
  151817. /**
  151818. * The output strength of the SSAO post-process. Default value is 1.0.
  151819. */
  151820. totalStrength: number;
  151821. /**
  151822. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  151823. */
  151824. radius: number;
  151825. /**
  151826. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  151827. * Must not be equal to fallOff and superior to fallOff.
  151828. * Default value is 0.0075
  151829. */
  151830. area: number;
  151831. /**
  151832. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  151833. * Must not be equal to area and inferior to area.
  151834. * Default value is 0.000001
  151835. */
  151836. fallOff: number;
  151837. /**
  151838. * The base color of the SSAO post-process
  151839. * The final result is "base + ssao" between [0, 1]
  151840. */
  151841. base: number;
  151842. private _scene;
  151843. private _depthTexture;
  151844. private _randomTexture;
  151845. private _originalColorPostProcess;
  151846. private _ssaoPostProcess;
  151847. private _blurHPostProcess;
  151848. private _blurVPostProcess;
  151849. private _ssaoCombinePostProcess;
  151850. private _firstUpdate;
  151851. /**
  151852. * Gets active scene
  151853. */
  151854. get scene(): Scene;
  151855. /**
  151856. * @constructor
  151857. * @param name - The rendering pipeline name
  151858. * @param scene - The scene linked to this pipeline
  151859. * @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 }
  151860. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  151861. */
  151862. constructor(name: string, scene: Scene, ratio: any, cameras?: Camera[]);
  151863. /**
  151864. * Get the class name
  151865. * @returns "SSAORenderingPipeline"
  151866. */
  151867. getClassName(): string;
  151868. /**
  151869. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  151870. */
  151871. dispose(disableDepthRender?: boolean): void;
  151872. private _createBlurPostProcess;
  151873. /** @hidden */
  151874. _rebuild(): void;
  151875. private _createSSAOPostProcess;
  151876. private _createSSAOCombinePostProcess;
  151877. private _createRandomTexture;
  151878. }
  151879. }
  151880. declare module BABYLON {
  151881. /**
  151882. * Contains all parameters needed for the prepass to perform
  151883. * screen space reflections
  151884. */
  151885. export class ScreenSpaceReflectionsConfiguration implements PrePassEffectConfiguration {
  151886. /**
  151887. * Is ssr enabled
  151888. */
  151889. enabled: boolean;
  151890. /**
  151891. * Name of the configuration
  151892. */
  151893. name: string;
  151894. /**
  151895. * Textures that should be present in the MRT for this effect to work
  151896. */
  151897. readonly texturesRequired: number[];
  151898. }
  151899. }
  151900. declare module BABYLON {
  151901. /** @hidden */
  151902. export var screenSpaceReflectionPixelShader: {
  151903. name: string;
  151904. shader: string;
  151905. };
  151906. }
  151907. declare module BABYLON {
  151908. /**
  151909. * The ScreenSpaceReflectionPostProcess performs realtime reflections using only and only the available informations on the screen (positions and normals).
  151910. * Basically, the screen space reflection post-process will compute reflections according the material's reflectivity.
  151911. */
  151912. export class ScreenSpaceReflectionPostProcess extends PostProcess {
  151913. /**
  151914. * Gets or sets a reflection threshold mainly used to adjust the reflection's height.
  151915. */
  151916. threshold: number;
  151917. /**
  151918. * Gets or sets the current reflection strength. 1.0 is an ideal value but can be increased/decreased for particular results.
  151919. */
  151920. strength: number;
  151921. /**
  151922. * Gets or sets the falloff exponent used while computing fresnel. More the exponent is high, more the reflections will be discrete.
  151923. */
  151924. reflectionSpecularFalloffExponent: number;
  151925. /**
  151926. * 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]
  151927. */
  151928. step: number;
  151929. /**
  151930. * Gets or sets the factor applied when computing roughness. Default value is 0.2.
  151931. */
  151932. roughnessFactor: number;
  151933. private _forceGeometryBuffer;
  151934. private _geometryBufferRenderer;
  151935. private _prePassRenderer;
  151936. private _enableSmoothReflections;
  151937. private _reflectionSamples;
  151938. private _smoothSteps;
  151939. /**
  151940. * Gets a string identifying the name of the class
  151941. * @returns "ScreenSpaceReflectionPostProcess" string
  151942. */
  151943. getClassName(): string;
  151944. /**
  151945. * Creates a new instance of ScreenSpaceReflectionPostProcess.
  151946. * @param name The name of the effect.
  151947. * @param scene The scene containing the objects to calculate reflections.
  151948. * @param options The required width/height ratio to downsize to before computing the render pass.
  151949. * @param camera The camera to apply the render pass to.
  151950. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  151951. * @param engine The engine which the post process will be applied. (default: current engine)
  151952. * @param reusable If the post process can be reused on the same frame. (default: false)
  151953. * @param textureType Type of textures used when performing the post process. (default: 0)
  151954. * @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)
  151955. * @param forceGeometryBuffer If this post process should use geometry buffer instead of prepass (default: false)
  151956. */
  151957. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean, forceGeometryBuffer?: boolean);
  151958. /**
  151959. * Gets wether or not smoothing reflections is enabled.
  151960. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151961. */
  151962. get enableSmoothReflections(): boolean;
  151963. /**
  151964. * Sets wether or not smoothing reflections is enabled.
  151965. * Enabling smoothing will require more GPU power and can generate a drop in FPS.
  151966. */
  151967. set enableSmoothReflections(enabled: boolean);
  151968. /**
  151969. * Gets the number of samples taken while computing reflections. More samples count is high,
  151970. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151971. */
  151972. get reflectionSamples(): number;
  151973. /**
  151974. * Sets the number of samples taken while computing reflections. More samples count is high,
  151975. * more the post-process wil require GPU power and can generate a drop in FPS. Basically in interval [25, 100].
  151976. */
  151977. set reflectionSamples(samples: number);
  151978. /**
  151979. * Gets the number of samples taken while smoothing reflections. More samples count is high,
  151980. * more the post-process will require GPU power and can generate a drop in FPS.
  151981. * Default value (5.0) work pretty well in all cases but can be adjusted.
  151982. */
  151983. get smoothSteps(): number;
  151984. set smoothSteps(steps: number);
  151985. private _updateEffectDefines;
  151986. /** @hidden */
  151987. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceReflectionPostProcess;
  151988. }
  151989. }
  151990. declare module BABYLON {
  151991. /** @hidden */
  151992. export var standardPixelShader: {
  151993. name: string;
  151994. shader: string;
  151995. };
  151996. }
  151997. declare module BABYLON {
  151998. /**
  151999. * Standard rendering pipeline
  152000. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152001. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  152002. */
  152003. export class StandardRenderingPipeline extends PostProcessRenderPipeline implements IDisposable, IAnimatable {
  152004. /**
  152005. * Public members
  152006. */
  152007. /**
  152008. * Post-process which contains the original scene color before the pipeline applies all the effects
  152009. */
  152010. originalPostProcess: Nullable<PostProcess>;
  152011. /**
  152012. * Post-process used to down scale an image x4
  152013. */
  152014. downSampleX4PostProcess: Nullable<PostProcess>;
  152015. /**
  152016. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  152017. */
  152018. brightPassPostProcess: Nullable<PostProcess>;
  152019. /**
  152020. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  152021. */
  152022. blurHPostProcesses: PostProcess[];
  152023. /**
  152024. * Post-process array storing all the vertical blur post-processes used by the pipeline
  152025. */
  152026. blurVPostProcesses: PostProcess[];
  152027. /**
  152028. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  152029. */
  152030. textureAdderPostProcess: Nullable<PostProcess>;
  152031. /**
  152032. * Post-process used to create volumetric lighting effect
  152033. */
  152034. volumetricLightPostProcess: Nullable<PostProcess>;
  152035. /**
  152036. * Post-process used to smooth the previous volumetric light post-process on the X axis
  152037. */
  152038. volumetricLightSmoothXPostProcess: Nullable<BlurPostProcess>;
  152039. /**
  152040. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  152041. */
  152042. volumetricLightSmoothYPostProcess: Nullable<BlurPostProcess>;
  152043. /**
  152044. * Post-process used to merge the volumetric light effect and the real scene color
  152045. */
  152046. volumetricLightMergePostProces: Nullable<PostProcess>;
  152047. /**
  152048. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  152049. */
  152050. volumetricLightFinalPostProcess: Nullable<PostProcess>;
  152051. /**
  152052. * Base post-process used to calculate the average luminance of the final image for HDR
  152053. */
  152054. luminancePostProcess: Nullable<PostProcess>;
  152055. /**
  152056. * Post-processes used to create down sample post-processes in order to get
  152057. * the average luminance of the final image for HDR
  152058. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  152059. */
  152060. luminanceDownSamplePostProcesses: PostProcess[];
  152061. /**
  152062. * Post-process used to create a HDR effect (light adaptation)
  152063. */
  152064. hdrPostProcess: Nullable<PostProcess>;
  152065. /**
  152066. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  152067. */
  152068. textureAdderFinalPostProcess: Nullable<PostProcess>;
  152069. /**
  152070. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  152071. */
  152072. lensFlareFinalPostProcess: Nullable<PostProcess>;
  152073. /**
  152074. * Post-process used to merge the final HDR post-process and the real scene color
  152075. */
  152076. hdrFinalPostProcess: Nullable<PostProcess>;
  152077. /**
  152078. * Post-process used to create a lens flare effect
  152079. */
  152080. lensFlarePostProcess: Nullable<PostProcess>;
  152081. /**
  152082. * Post-process that merges the result of the lens flare post-process and the real scene color
  152083. */
  152084. lensFlareComposePostProcess: Nullable<PostProcess>;
  152085. /**
  152086. * Post-process used to create a motion blur effect
  152087. */
  152088. motionBlurPostProcess: Nullable<PostProcess>;
  152089. /**
  152090. * Post-process used to create a depth of field effect
  152091. */
  152092. depthOfFieldPostProcess: Nullable<PostProcess>;
  152093. /**
  152094. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  152095. */
  152096. fxaaPostProcess: Nullable<FxaaPostProcess>;
  152097. /**
  152098. * Post-process used to simulate realtime reflections using the screen space and geometry renderer.
  152099. */
  152100. screenSpaceReflectionPostProcess: Nullable<ScreenSpaceReflectionPostProcess>;
  152101. /**
  152102. * Represents the brightness threshold in order to configure the illuminated surfaces
  152103. */
  152104. brightThreshold: number;
  152105. /**
  152106. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  152107. */
  152108. blurWidth: number;
  152109. /**
  152110. * Sets if the blur for highlighted surfaces must be only horizontal
  152111. */
  152112. horizontalBlur: boolean;
  152113. /**
  152114. * Gets the overall exposure used by the pipeline
  152115. */
  152116. get exposure(): number;
  152117. /**
  152118. * Sets the overall exposure used by the pipeline
  152119. */
  152120. set exposure(value: number);
  152121. /**
  152122. * Texture used typically to simulate "dirty" on camera lens
  152123. */
  152124. lensTexture: Nullable<Texture>;
  152125. /**
  152126. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  152127. */
  152128. volumetricLightCoefficient: number;
  152129. /**
  152130. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  152131. */
  152132. volumetricLightPower: number;
  152133. /**
  152134. * Used the set the blur intensity to smooth the volumetric lights
  152135. */
  152136. volumetricLightBlurScale: number;
  152137. /**
  152138. * Light (spot or directional) used to generate the volumetric lights rays
  152139. * The source light must have a shadow generate so the pipeline can get its
  152140. * depth map
  152141. */
  152142. sourceLight: Nullable<SpotLight | DirectionalLight>;
  152143. /**
  152144. * For eye adaptation, represents the minimum luminance the eye can see
  152145. */
  152146. hdrMinimumLuminance: number;
  152147. /**
  152148. * For eye adaptation, represents the decrease luminance speed
  152149. */
  152150. hdrDecreaseRate: number;
  152151. /**
  152152. * For eye adaptation, represents the increase luminance speed
  152153. */
  152154. hdrIncreaseRate: number;
  152155. /**
  152156. * Gets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152157. */
  152158. get hdrAutoExposure(): boolean;
  152159. /**
  152160. * Sets wether or not the exposure of the overall pipeline should be automatically adjusted by the HDR post-process
  152161. */
  152162. set hdrAutoExposure(value: boolean);
  152163. /**
  152164. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  152165. */
  152166. lensColorTexture: Nullable<Texture>;
  152167. /**
  152168. * The overall strengh for the lens flare effect
  152169. */
  152170. lensFlareStrength: number;
  152171. /**
  152172. * Dispersion coefficient for lens flare ghosts
  152173. */
  152174. lensFlareGhostDispersal: number;
  152175. /**
  152176. * Main lens flare halo width
  152177. */
  152178. lensFlareHaloWidth: number;
  152179. /**
  152180. * Based on the lens distortion effect, defines how much the lens flare result
  152181. * is distorted
  152182. */
  152183. lensFlareDistortionStrength: number;
  152184. /**
  152185. * Configures the blur intensity used for for lens flare (halo)
  152186. */
  152187. lensFlareBlurWidth: number;
  152188. /**
  152189. * Lens star texture must be used to simulate rays on the flares and is available
  152190. * in the documentation
  152191. */
  152192. lensStarTexture: Nullable<Texture>;
  152193. /**
  152194. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  152195. * flare effect by taking account of the dirt texture
  152196. */
  152197. lensFlareDirtTexture: Nullable<Texture>;
  152198. /**
  152199. * Represents the focal length for the depth of field effect
  152200. */
  152201. depthOfFieldDistance: number;
  152202. /**
  152203. * Represents the blur intensity for the blurred part of the depth of field effect
  152204. */
  152205. depthOfFieldBlurWidth: number;
  152206. /**
  152207. * Gets how much the image is blurred by the movement while using the motion blur post-process
  152208. */
  152209. get motionStrength(): number;
  152210. /**
  152211. * Sets how much the image is blurred by the movement while using the motion blur post-process
  152212. */
  152213. set motionStrength(strength: number);
  152214. /**
  152215. * Gets wether or not the motion blur post-process is object based or screen based.
  152216. */
  152217. get objectBasedMotionBlur(): boolean;
  152218. /**
  152219. * Sets wether or not the motion blur post-process should be object based or screen based
  152220. */
  152221. set objectBasedMotionBlur(value: boolean);
  152222. /**
  152223. * List of animations for the pipeline (IAnimatable implementation)
  152224. */
  152225. animations: Animation[];
  152226. /**
  152227. * Private members
  152228. */
  152229. private _scene;
  152230. private _currentDepthOfFieldSource;
  152231. private _basePostProcess;
  152232. private _fixedExposure;
  152233. private _currentExposure;
  152234. private _hdrAutoExposure;
  152235. private _hdrCurrentLuminance;
  152236. private _motionStrength;
  152237. private _isObjectBasedMotionBlur;
  152238. private _floatTextureType;
  152239. private _camerasToBeAttached;
  152240. private _ratio;
  152241. private _bloomEnabled;
  152242. private _depthOfFieldEnabled;
  152243. private _vlsEnabled;
  152244. private _lensFlareEnabled;
  152245. private _hdrEnabled;
  152246. private _motionBlurEnabled;
  152247. private _fxaaEnabled;
  152248. private _screenSpaceReflectionsEnabled;
  152249. private _motionBlurSamples;
  152250. private _volumetricLightStepsCount;
  152251. private _samples;
  152252. /**
  152253. * @ignore
  152254. * Specifies if the bloom pipeline is enabled
  152255. */
  152256. get BloomEnabled(): boolean;
  152257. set BloomEnabled(enabled: boolean);
  152258. /**
  152259. * @ignore
  152260. * Specifies if the depth of field pipeline is enabed
  152261. */
  152262. get DepthOfFieldEnabled(): boolean;
  152263. set DepthOfFieldEnabled(enabled: boolean);
  152264. /**
  152265. * @ignore
  152266. * Specifies if the lens flare pipeline is enabed
  152267. */
  152268. get LensFlareEnabled(): boolean;
  152269. set LensFlareEnabled(enabled: boolean);
  152270. /**
  152271. * @ignore
  152272. * Specifies if the HDR pipeline is enabled
  152273. */
  152274. get HDREnabled(): boolean;
  152275. set HDREnabled(enabled: boolean);
  152276. /**
  152277. * @ignore
  152278. * Specifies if the volumetric lights scattering effect is enabled
  152279. */
  152280. get VLSEnabled(): boolean;
  152281. set VLSEnabled(enabled: boolean);
  152282. /**
  152283. * @ignore
  152284. * Specifies if the motion blur effect is enabled
  152285. */
  152286. get MotionBlurEnabled(): boolean;
  152287. set MotionBlurEnabled(enabled: boolean);
  152288. /**
  152289. * Specifies if anti-aliasing is enabled
  152290. */
  152291. get fxaaEnabled(): boolean;
  152292. set fxaaEnabled(enabled: boolean);
  152293. /**
  152294. * Specifies if screen space reflections are enabled.
  152295. */
  152296. get screenSpaceReflectionsEnabled(): boolean;
  152297. set screenSpaceReflectionsEnabled(enabled: boolean);
  152298. /**
  152299. * Specifies the number of steps used to calculate the volumetric lights
  152300. * Typically in interval [50, 200]
  152301. */
  152302. get volumetricLightStepsCount(): number;
  152303. set volumetricLightStepsCount(count: number);
  152304. /**
  152305. * Specifies the number of samples used for the motion blur effect
  152306. * Typically in interval [16, 64]
  152307. */
  152308. get motionBlurSamples(): number;
  152309. set motionBlurSamples(samples: number);
  152310. /**
  152311. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  152312. */
  152313. get samples(): number;
  152314. set samples(sampleCount: number);
  152315. /**
  152316. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  152317. * @constructor
  152318. * @param name The rendering pipeline name
  152319. * @param scene The scene linked to this pipeline
  152320. * @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)
  152321. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  152322. * @param cameras The array of cameras that the rendering pipeline will be attached to
  152323. */
  152324. constructor(name: string, scene: Scene, ratio: number, originalPostProcess?: Nullable<PostProcess>, cameras?: Camera[]);
  152325. private _buildPipeline;
  152326. private _createDownSampleX4PostProcess;
  152327. private _createBrightPassPostProcess;
  152328. private _createBlurPostProcesses;
  152329. private _createTextureAdderPostProcess;
  152330. private _createVolumetricLightPostProcess;
  152331. private _createLuminancePostProcesses;
  152332. private _createHdrPostProcess;
  152333. private _createLensFlarePostProcess;
  152334. private _createDepthOfFieldPostProcess;
  152335. private _createMotionBlurPostProcess;
  152336. private _getDepthTexture;
  152337. private _disposePostProcesses;
  152338. /**
  152339. * Dispose of the pipeline and stop all post processes
  152340. */
  152341. dispose(): void;
  152342. /**
  152343. * Serialize the rendering pipeline (Used when exporting)
  152344. * @returns the serialized object
  152345. */
  152346. serialize(): any;
  152347. /**
  152348. * Parse the serialized pipeline
  152349. * @param source Source pipeline.
  152350. * @param scene The scene to load the pipeline to.
  152351. * @param rootUrl The URL of the serialized pipeline.
  152352. * @returns An instantiated pipeline from the serialized object.
  152353. */
  152354. static Parse(source: any, scene: Scene, rootUrl: string): StandardRenderingPipeline;
  152355. /**
  152356. * Luminance steps
  152357. */
  152358. static LuminanceSteps: number;
  152359. }
  152360. }
  152361. declare module BABYLON {
  152362. /** @hidden */
  152363. export var stereoscopicInterlacePixelShader: {
  152364. name: string;
  152365. shader: string;
  152366. };
  152367. }
  152368. declare module BABYLON {
  152369. /**
  152370. * StereoscopicInterlacePostProcessI used to render stereo views from a rigged camera with support for alternate line interlacing
  152371. */
  152372. export class StereoscopicInterlacePostProcessI extends PostProcess {
  152373. private _stepSize;
  152374. private _passedProcess;
  152375. /**
  152376. * Gets a string identifying the name of the class
  152377. * @returns "StereoscopicInterlacePostProcessI" string
  152378. */
  152379. getClassName(): string;
  152380. /**
  152381. * Initializes a StereoscopicInterlacePostProcessI
  152382. * @param name The name of the effect.
  152383. * @param rigCameras The rig cameras to be appled to the post process
  152384. * @param isStereoscopicHoriz If the rendered results are horizontal or vertical
  152385. * @param isStereoscopicInterlaced If the rendered results are alternate line interlaced
  152386. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152387. * @param engine The engine which the post process will be applied. (default: current engine)
  152388. * @param reusable If the post process can be reused on the same frame. (default: false)
  152389. */
  152390. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, isStereoscopicInterlaced: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152391. }
  152392. /**
  152393. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  152394. */
  152395. export class StereoscopicInterlacePostProcess extends PostProcess {
  152396. private _stepSize;
  152397. private _passedProcess;
  152398. /**
  152399. * Gets a string identifying the name of the class
  152400. * @returns "StereoscopicInterlacePostProcess" string
  152401. */
  152402. getClassName(): string;
  152403. /**
  152404. * Initializes a StereoscopicInterlacePostProcess
  152405. * @param name The name of the effect.
  152406. * @param rigCameras The rig cameras to be appled to the post process
  152407. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  152408. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152409. * @param engine The engine which the post process will be applied. (default: current engine)
  152410. * @param reusable If the post process can be reused on the same frame. (default: false)
  152411. */
  152412. constructor(name: string, rigCameras: Camera[], isStereoscopicHoriz: boolean, samplingMode?: number, engine?: Engine, reusable?: boolean);
  152413. }
  152414. }
  152415. declare module BABYLON {
  152416. /** @hidden */
  152417. export var tonemapPixelShader: {
  152418. name: string;
  152419. shader: string;
  152420. };
  152421. }
  152422. declare module BABYLON {
  152423. /** Defines operator used for tonemapping */
  152424. export enum TonemappingOperator {
  152425. /** Hable */
  152426. Hable = 0,
  152427. /** Reinhard */
  152428. Reinhard = 1,
  152429. /** HejiDawson */
  152430. HejiDawson = 2,
  152431. /** Photographic */
  152432. Photographic = 3
  152433. }
  152434. /**
  152435. * Defines a post process to apply tone mapping
  152436. */
  152437. export class TonemapPostProcess extends PostProcess {
  152438. private _operator;
  152439. /** Defines the required exposure adjustement */
  152440. exposureAdjustment: number;
  152441. /**
  152442. * Gets a string identifying the name of the class
  152443. * @returns "TonemapPostProcess" string
  152444. */
  152445. getClassName(): string;
  152446. /**
  152447. * Creates a new TonemapPostProcess
  152448. * @param name defines the name of the postprocess
  152449. * @param _operator defines the operator to use
  152450. * @param exposureAdjustment defines the required exposure adjustement
  152451. * @param camera defines the camera to use (can be null)
  152452. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  152453. * @param engine defines the hosting engine (can be ignore if camera is set)
  152454. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  152455. */
  152456. constructor(name: string, _operator: TonemappingOperator,
  152457. /** Defines the required exposure adjustement */
  152458. exposureAdjustment: number, camera: Camera, samplingMode?: number, engine?: Engine, textureFormat?: number);
  152459. }
  152460. }
  152461. declare module BABYLON {
  152462. /** @hidden */
  152463. export var volumetricLightScatteringPixelShader: {
  152464. name: string;
  152465. shader: string;
  152466. };
  152467. }
  152468. declare module BABYLON {
  152469. /** @hidden */
  152470. export var volumetricLightScatteringPassVertexShader: {
  152471. name: string;
  152472. shader: string;
  152473. };
  152474. }
  152475. declare module BABYLON {
  152476. /** @hidden */
  152477. export var volumetricLightScatteringPassPixelShader: {
  152478. name: string;
  152479. shader: string;
  152480. };
  152481. }
  152482. declare module BABYLON {
  152483. /**
  152484. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  152485. */
  152486. export class VolumetricLightScatteringPostProcess extends PostProcess {
  152487. private _volumetricLightScatteringPass;
  152488. private _volumetricLightScatteringRTT;
  152489. private _viewPort;
  152490. private _screenCoordinates;
  152491. private _cachedDefines;
  152492. /**
  152493. * If not undefined, the mesh position is computed from the attached node position
  152494. */
  152495. attachedNode: {
  152496. position: Vector3;
  152497. };
  152498. /**
  152499. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  152500. */
  152501. customMeshPosition: Vector3;
  152502. /**
  152503. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  152504. */
  152505. useCustomMeshPosition: boolean;
  152506. /**
  152507. * If the post-process should inverse the light scattering direction
  152508. */
  152509. invert: boolean;
  152510. /**
  152511. * The internal mesh used by the post-process
  152512. */
  152513. mesh: Mesh;
  152514. /**
  152515. * @hidden
  152516. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  152517. */
  152518. get useDiffuseColor(): boolean;
  152519. set useDiffuseColor(useDiffuseColor: boolean);
  152520. /**
  152521. * Array containing the excluded meshes not rendered in the internal pass
  152522. */
  152523. excludedMeshes: AbstractMesh[];
  152524. /**
  152525. * Controls the overall intensity of the post-process
  152526. */
  152527. exposure: number;
  152528. /**
  152529. * Dissipates each sample's contribution in range [0, 1]
  152530. */
  152531. decay: number;
  152532. /**
  152533. * Controls the overall intensity of each sample
  152534. */
  152535. weight: number;
  152536. /**
  152537. * Controls the density of each sample
  152538. */
  152539. density: number;
  152540. /**
  152541. * @constructor
  152542. * @param name The post-process name
  152543. * @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)
  152544. * @param camera The camera that the post-process will be attached to
  152545. * @param mesh The mesh used to create the light scattering
  152546. * @param samples The post-process quality, default 100
  152547. * @param samplingModeThe post-process filtering mode
  152548. * @param engine The babylon engine
  152549. * @param reusable If the post-process is reusable
  152550. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  152551. */
  152552. constructor(name: string, ratio: any, camera: Camera, mesh?: Mesh, samples?: number, samplingMode?: number, engine?: Engine, reusable?: boolean, scene?: Scene);
  152553. /**
  152554. * Returns the string "VolumetricLightScatteringPostProcess"
  152555. * @returns "VolumetricLightScatteringPostProcess"
  152556. */
  152557. getClassName(): string;
  152558. private _isReady;
  152559. /**
  152560. * Sets the new light position for light scattering effect
  152561. * @param position The new custom light position
  152562. */
  152563. setCustomMeshPosition(position: Vector3): void;
  152564. /**
  152565. * Returns the light position for light scattering effect
  152566. * @return Vector3 The custom light position
  152567. */
  152568. getCustomMeshPosition(): Vector3;
  152569. /**
  152570. * Disposes the internal assets and detaches the post-process from the camera
  152571. */
  152572. dispose(camera: Camera): void;
  152573. /**
  152574. * Returns the render target texture used by the post-process
  152575. * @return the render target texture used by the post-process
  152576. */
  152577. getPass(): RenderTargetTexture;
  152578. private _meshExcluded;
  152579. private _createPass;
  152580. private _updateMeshScreenCoordinates;
  152581. /**
  152582. * Creates a default mesh for the Volumeric Light Scattering post-process
  152583. * @param name The mesh name
  152584. * @param scene The scene where to create the mesh
  152585. * @return the default mesh
  152586. */
  152587. static CreateDefaultMesh(name: string, scene: Scene): Mesh;
  152588. }
  152589. }
  152590. declare module BABYLON {
  152591. /** @hidden */
  152592. export var screenSpaceCurvaturePixelShader: {
  152593. name: string;
  152594. shader: string;
  152595. };
  152596. }
  152597. declare module BABYLON {
  152598. /**
  152599. * The Screen Space curvature effect can help highlighting ridge and valley of a model.
  152600. */
  152601. export class ScreenSpaceCurvaturePostProcess extends PostProcess {
  152602. /**
  152603. * Defines how much ridge the curvature effect displays.
  152604. */
  152605. ridge: number;
  152606. /**
  152607. * Defines how much valley the curvature effect displays.
  152608. */
  152609. valley: number;
  152610. private _geometryBufferRenderer;
  152611. /**
  152612. * Gets a string identifying the name of the class
  152613. * @returns "ScreenSpaceCurvaturePostProcess" string
  152614. */
  152615. getClassName(): string;
  152616. /**
  152617. * Creates a new instance ScreenSpaceCurvaturePostProcess
  152618. * @param name The name of the effect.
  152619. * @param scene The scene containing the objects to blur according to their velocity.
  152620. * @param options The required width/height ratio to downsize to before computing the render pass.
  152621. * @param camera The camera to apply the render pass to.
  152622. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  152623. * @param engine The engine which the post process will be applied. (default: current engine)
  152624. * @param reusable If the post process can be reused on the same frame. (default: false)
  152625. * @param textureType Type of textures used when performing the post process. (default: 0)
  152626. * @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)
  152627. */
  152628. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number, blockCompilation?: boolean);
  152629. /**
  152630. * Support test.
  152631. */
  152632. static get IsSupported(): boolean;
  152633. /** @hidden */
  152634. static _Parse(parsedPostProcess: any, targetCamera: Camera, scene: Scene, rootUrl: string): ScreenSpaceCurvaturePostProcess;
  152635. }
  152636. }
  152637. declare module BABYLON {
  152638. interface Scene {
  152639. /** @hidden (Backing field) */
  152640. _boundingBoxRenderer: BoundingBoxRenderer;
  152641. /** @hidden (Backing field) */
  152642. _forceShowBoundingBoxes: boolean;
  152643. /**
  152644. * Gets or sets a boolean indicating if all bounding boxes must be rendered
  152645. */
  152646. forceShowBoundingBoxes: boolean;
  152647. /**
  152648. * Gets the bounding box renderer associated with the scene
  152649. * @returns a BoundingBoxRenderer
  152650. */
  152651. getBoundingBoxRenderer(): BoundingBoxRenderer;
  152652. }
  152653. interface AbstractMesh {
  152654. /** @hidden (Backing field) */
  152655. _showBoundingBox: boolean;
  152656. /**
  152657. * Gets or sets a boolean indicating if the bounding box must be rendered as well (false by default)
  152658. */
  152659. showBoundingBox: boolean;
  152660. }
  152661. /**
  152662. * Component responsible of rendering the bounding box of the meshes in a scene.
  152663. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  152664. */
  152665. export class BoundingBoxRenderer implements ISceneComponent {
  152666. /**
  152667. * The component name helpfull to identify the component in the list of scene components.
  152668. */
  152669. readonly name: string;
  152670. /**
  152671. * The scene the component belongs to.
  152672. */
  152673. scene: Scene;
  152674. /**
  152675. * Color of the bounding box lines placed in front of an object
  152676. */
  152677. frontColor: Color3;
  152678. /**
  152679. * Color of the bounding box lines placed behind an object
  152680. */
  152681. backColor: Color3;
  152682. /**
  152683. * Defines if the renderer should show the back lines or not
  152684. */
  152685. showBackLines: boolean;
  152686. /**
  152687. * Observable raised before rendering a bounding box
  152688. */
  152689. onBeforeBoxRenderingObservable: Observable<BoundingBox>;
  152690. /**
  152691. * Observable raised after rendering a bounding box
  152692. */
  152693. onAfterBoxRenderingObservable: Observable<BoundingBox>;
  152694. /**
  152695. * @hidden
  152696. */
  152697. renderList: SmartArray<BoundingBox>;
  152698. private _colorShader;
  152699. private _vertexBuffers;
  152700. private _indexBuffer;
  152701. private _fillIndexBuffer;
  152702. private _fillIndexData;
  152703. /**
  152704. * Instantiates a new bounding box renderer in a scene.
  152705. * @param scene the scene the renderer renders in
  152706. */
  152707. constructor(scene: Scene);
  152708. /**
  152709. * Registers the component in a given scene
  152710. */
  152711. register(): void;
  152712. private _evaluateSubMesh;
  152713. private _activeMesh;
  152714. private _prepareRessources;
  152715. private _createIndexBuffer;
  152716. /**
  152717. * Rebuilds the elements related to this component in case of
  152718. * context lost for instance.
  152719. */
  152720. rebuild(): void;
  152721. /**
  152722. * @hidden
  152723. */
  152724. reset(): void;
  152725. /**
  152726. * Render the bounding boxes of a specific rendering group
  152727. * @param renderingGroupId defines the rendering group to render
  152728. */
  152729. render(renderingGroupId: number): void;
  152730. /**
  152731. * In case of occlusion queries, we can render the occlusion bounding box through this method
  152732. * @param mesh Define the mesh to render the occlusion bounding box for
  152733. */
  152734. renderOcclusionBoundingBox(mesh: AbstractMesh): void;
  152735. /**
  152736. * Dispose and release the resources attached to this renderer.
  152737. */
  152738. dispose(): void;
  152739. }
  152740. }
  152741. declare module BABYLON {
  152742. interface Scene {
  152743. /** @hidden (Backing field) */
  152744. _depthRenderer: {
  152745. [id: string]: DepthRenderer;
  152746. };
  152747. /**
  152748. * Creates a depth renderer a given camera which contains a depth map which can be used for post processing.
  152749. * @param camera The camera to create the depth renderer on (default: scene's active camera)
  152750. * @param storeNonLinearDepth Defines whether the depth is stored linearly like in Babylon Shadows or directly like glFragCoord.z
  152751. * @param force32bitsFloat Forces 32 bits float when supported (else 16 bits float is prioritized over 32 bits float if supported)
  152752. * @returns the created depth renderer
  152753. */
  152754. enableDepthRenderer(camera?: Nullable<Camera>, storeNonLinearDepth?: boolean, force32bitsFloat?: boolean): DepthRenderer;
  152755. /**
  152756. * Disables a depth renderer for a given camera
  152757. * @param camera The camera to disable the depth renderer on (default: scene's active camera)
  152758. */
  152759. disableDepthRenderer(camera?: Nullable<Camera>): void;
  152760. }
  152761. /**
  152762. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  152763. * in several rendering techniques.
  152764. */
  152765. export class DepthRendererSceneComponent implements ISceneComponent {
  152766. /**
  152767. * The component name helpfull to identify the component in the list of scene components.
  152768. */
  152769. readonly name: string;
  152770. /**
  152771. * The scene the component belongs to.
  152772. */
  152773. scene: Scene;
  152774. /**
  152775. * Creates a new instance of the component for the given scene
  152776. * @param scene Defines the scene to register the component in
  152777. */
  152778. constructor(scene: Scene);
  152779. /**
  152780. * Registers the component in a given scene
  152781. */
  152782. register(): void;
  152783. /**
  152784. * Rebuilds the elements related to this component in case of
  152785. * context lost for instance.
  152786. */
  152787. rebuild(): void;
  152788. /**
  152789. * Disposes the component and the associated ressources
  152790. */
  152791. dispose(): void;
  152792. private _gatherRenderTargets;
  152793. private _gatherActiveCameraRenderTargets;
  152794. }
  152795. }
  152796. declare module BABYLON {
  152797. interface AbstractScene {
  152798. /** @hidden (Backing field) */
  152799. _prePassRenderer: Nullable<PrePassRenderer>;
  152800. /**
  152801. * Gets or Sets the current prepass renderer associated to the scene.
  152802. */
  152803. prePassRenderer: Nullable<PrePassRenderer>;
  152804. /**
  152805. * Enables the prepass and associates it with the scene
  152806. * @returns the PrePassRenderer
  152807. */
  152808. enablePrePassRenderer(): Nullable<PrePassRenderer>;
  152809. /**
  152810. * Disables the prepass associated with the scene
  152811. */
  152812. disablePrePassRenderer(): void;
  152813. }
  152814. /**
  152815. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  152816. * in several rendering techniques.
  152817. */
  152818. export class PrePassRendererSceneComponent implements ISceneComponent {
  152819. /**
  152820. * The component name helpful to identify the component in the list of scene components.
  152821. */
  152822. readonly name: string;
  152823. /**
  152824. * The scene the component belongs to.
  152825. */
  152826. scene: Scene;
  152827. /**
  152828. * Creates a new instance of the component for the given scene
  152829. * @param scene Defines the scene to register the component in
  152830. */
  152831. constructor(scene: Scene);
  152832. /**
  152833. * Registers the component in a given scene
  152834. */
  152835. register(): void;
  152836. private _beforeCameraDraw;
  152837. private _afterCameraDraw;
  152838. private _beforeClearStage;
  152839. /**
  152840. * Rebuilds the elements related to this component in case of
  152841. * context lost for instance.
  152842. */
  152843. rebuild(): void;
  152844. /**
  152845. * Disposes the component and the associated ressources
  152846. */
  152847. dispose(): void;
  152848. }
  152849. }
  152850. declare module BABYLON {
  152851. /** @hidden */
  152852. export var fibonacci: {
  152853. name: string;
  152854. shader: string;
  152855. };
  152856. }
  152857. declare module BABYLON {
  152858. /** @hidden */
  152859. export var diffusionProfile: {
  152860. name: string;
  152861. shader: string;
  152862. };
  152863. }
  152864. declare module BABYLON {
  152865. /** @hidden */
  152866. export var subSurfaceScatteringPixelShader: {
  152867. name: string;
  152868. shader: string;
  152869. };
  152870. }
  152871. declare module BABYLON {
  152872. /**
  152873. * Sub surface scattering post process
  152874. */
  152875. export class SubSurfaceScatteringPostProcess extends PostProcess {
  152876. /**
  152877. * Gets a string identifying the name of the class
  152878. * @returns "SubSurfaceScatteringPostProcess" string
  152879. */
  152880. getClassName(): string;
  152881. constructor(name: string, scene: Scene, options: number | PostProcessOptions, camera?: Nullable<Camera>, samplingMode?: number, engine?: Engine, reusable?: boolean, textureType?: number);
  152882. }
  152883. }
  152884. declare module BABYLON {
  152885. /**
  152886. * Contains all parameters needed for the prepass to perform
  152887. * screen space subsurface scattering
  152888. */
  152889. export class SubSurfaceConfiguration implements PrePassEffectConfiguration {
  152890. /** @hidden */
  152891. static _SceneComponentInitialization: (scene: Scene) => void;
  152892. private _ssDiffusionS;
  152893. private _ssFilterRadii;
  152894. private _ssDiffusionD;
  152895. /**
  152896. * Post process to attach for screen space subsurface scattering
  152897. */
  152898. postProcess: SubSurfaceScatteringPostProcess;
  152899. /**
  152900. * Diffusion profile color for subsurface scattering
  152901. */
  152902. get ssDiffusionS(): number[];
  152903. /**
  152904. * Diffusion profile max color channel value for subsurface scattering
  152905. */
  152906. get ssDiffusionD(): number[];
  152907. /**
  152908. * Diffusion profile filter radius for subsurface scattering
  152909. */
  152910. get ssFilterRadii(): number[];
  152911. /**
  152912. * Is subsurface enabled
  152913. */
  152914. enabled: boolean;
  152915. /**
  152916. * Name of the configuration
  152917. */
  152918. name: string;
  152919. /**
  152920. * Diffusion profile colors for subsurface scattering
  152921. * You can add one diffusion color using `addDiffusionProfile` on `scene.prePassRenderer`
  152922. * See ...
  152923. * Note that you can only store up to 5 of them
  152924. */
  152925. ssDiffusionProfileColors: Color3[];
  152926. /**
  152927. * Defines the ratio real world => scene units.
  152928. * Used for subsurface scattering
  152929. */
  152930. metersPerUnit: number;
  152931. /**
  152932. * Textures that should be present in the MRT for this effect to work
  152933. */
  152934. readonly texturesRequired: number[];
  152935. private _scene;
  152936. /**
  152937. * Builds a subsurface configuration object
  152938. * @param scene The scene
  152939. */
  152940. constructor(scene: Scene);
  152941. /**
  152942. * Adds a new diffusion profile.
  152943. * Useful for more realistic subsurface scattering on diverse materials.
  152944. * @param color The color of the diffusion profile. Should be the average color of the material.
  152945. * @return The index of the diffusion profile for the material subsurface configuration
  152946. */
  152947. addDiffusionProfile(color: Color3): number;
  152948. /**
  152949. * Creates the sss post process
  152950. * @return The created post process
  152951. */
  152952. createPostProcess(): SubSurfaceScatteringPostProcess;
  152953. /**
  152954. * Deletes all diffusion profiles.
  152955. * Note that in order to render subsurface scattering, you should have at least 1 diffusion profile.
  152956. */
  152957. clearAllDiffusionProfiles(): void;
  152958. /**
  152959. * Disposes this object
  152960. */
  152961. dispose(): void;
  152962. /**
  152963. * @hidden
  152964. * https://zero-radiance.github.io/post/sampling-diffusion/
  152965. *
  152966. * Importance sample the normalized diffuse reflectance profile for the computed value of 's'.
  152967. * ------------------------------------------------------------------------------------
  152968. * R[r, phi, s] = s * (Exp[-r * s] + Exp[-r * s / 3]) / (8 * Pi * r)
  152969. * PDF[r, phi, s] = r * R[r, phi, s]
  152970. * CDF[r, s] = 1 - 1/4 * Exp[-r * s] - 3/4 * Exp[-r * s / 3]
  152971. * ------------------------------------------------------------------------------------
  152972. * We importance sample the color channel with the widest scattering distance.
  152973. */
  152974. getDiffusionProfileParameters(color: Color3): number;
  152975. /**
  152976. * Performs sampling of a Normalized Burley diffusion profile in polar coordinates.
  152977. * 'u' is the random number (the value of the CDF): [0, 1).
  152978. * rcp(s) = 1 / ShapeParam = ScatteringDistance.
  152979. * Returns the sampled radial distance, s.t. (u = 0 -> r = 0) and (u = 1 -> r = Inf).
  152980. */
  152981. private _sampleBurleyDiffusionProfile;
  152982. }
  152983. }
  152984. declare module BABYLON {
  152985. interface AbstractScene {
  152986. /** @hidden (Backing field) */
  152987. _subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152988. /**
  152989. * Gets or Sets the current prepass renderer associated to the scene.
  152990. */
  152991. subSurfaceConfiguration: Nullable<SubSurfaceConfiguration>;
  152992. /**
  152993. * Enables the subsurface effect for prepass
  152994. * @returns the SubSurfaceConfiguration
  152995. */
  152996. enableSubSurfaceForPrePass(): Nullable<SubSurfaceConfiguration>;
  152997. /**
  152998. * Disables the subsurface effect for prepass
  152999. */
  153000. disableSubSurfaceForPrePass(): void;
  153001. }
  153002. /**
  153003. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  153004. * in several rendering techniques.
  153005. */
  153006. export class SubSurfaceSceneComponent implements ISceneSerializableComponent {
  153007. /**
  153008. * The component name helpful to identify the component in the list of scene components.
  153009. */
  153010. readonly name: string;
  153011. /**
  153012. * The scene the component belongs to.
  153013. */
  153014. scene: Scene;
  153015. /**
  153016. * Creates a new instance of the component for the given scene
  153017. * @param scene Defines the scene to register the component in
  153018. */
  153019. constructor(scene: Scene);
  153020. /**
  153021. * Registers the component in a given scene
  153022. */
  153023. register(): void;
  153024. /**
  153025. * Serializes the component data to the specified json object
  153026. * @param serializationObject The object to serialize to
  153027. */
  153028. serialize(serializationObject: any): void;
  153029. /**
  153030. * Adds all the elements from the container to the scene
  153031. * @param container the container holding the elements
  153032. */
  153033. addFromContainer(container: AbstractScene): void;
  153034. /**
  153035. * Removes all the elements in the container from the scene
  153036. * @param container contains the elements to remove
  153037. * @param dispose if the removed element should be disposed (default: false)
  153038. */
  153039. removeFromContainer(container: AbstractScene, dispose?: boolean): void;
  153040. /**
  153041. * Rebuilds the elements related to this component in case of
  153042. * context lost for instance.
  153043. */
  153044. rebuild(): void;
  153045. /**
  153046. * Disposes the component and the associated ressources
  153047. */
  153048. dispose(): void;
  153049. }
  153050. }
  153051. declare module BABYLON {
  153052. /** @hidden */
  153053. export var outlinePixelShader: {
  153054. name: string;
  153055. shader: string;
  153056. };
  153057. }
  153058. declare module BABYLON {
  153059. /** @hidden */
  153060. export var outlineVertexShader: {
  153061. name: string;
  153062. shader: string;
  153063. };
  153064. }
  153065. declare module BABYLON {
  153066. interface Scene {
  153067. /** @hidden */
  153068. _outlineRenderer: OutlineRenderer;
  153069. /**
  153070. * Gets the outline renderer associated with the scene
  153071. * @returns a OutlineRenderer
  153072. */
  153073. getOutlineRenderer(): OutlineRenderer;
  153074. }
  153075. interface AbstractMesh {
  153076. /** @hidden (Backing field) */
  153077. _renderOutline: boolean;
  153078. /**
  153079. * Gets or sets a boolean indicating if the outline must be rendered as well
  153080. * @see https://www.babylonjs-playground.com/#10WJ5S#3
  153081. */
  153082. renderOutline: boolean;
  153083. /** @hidden (Backing field) */
  153084. _renderOverlay: boolean;
  153085. /**
  153086. * Gets or sets a boolean indicating if the overlay must be rendered as well
  153087. * @see https://www.babylonjs-playground.com/#10WJ5S#2
  153088. */
  153089. renderOverlay: boolean;
  153090. }
  153091. /**
  153092. * This class is responsible to draw bothe outline/overlay of meshes.
  153093. * It should not be used directly but through the available method on mesh.
  153094. */
  153095. export class OutlineRenderer implements ISceneComponent {
  153096. /**
  153097. * Stencil value used to avoid outline being seen within the mesh when the mesh is transparent
  153098. */
  153099. private static _StencilReference;
  153100. /**
  153101. * The name of the component. Each component must have a unique name.
  153102. */
  153103. name: string;
  153104. /**
  153105. * The scene the component belongs to.
  153106. */
  153107. scene: Scene;
  153108. /**
  153109. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  153110. */
  153111. zOffset: number;
  153112. private _engine;
  153113. private _effect;
  153114. private _cachedDefines;
  153115. private _savedDepthWrite;
  153116. /**
  153117. * Instantiates a new outline renderer. (There could be only one per scene).
  153118. * @param scene Defines the scene it belongs to
  153119. */
  153120. constructor(scene: Scene);
  153121. /**
  153122. * Register the component to one instance of a scene.
  153123. */
  153124. register(): void;
  153125. /**
  153126. * Rebuilds the elements related to this component in case of
  153127. * context lost for instance.
  153128. */
  153129. rebuild(): void;
  153130. /**
  153131. * Disposes the component and the associated ressources.
  153132. */
  153133. dispose(): void;
  153134. /**
  153135. * Renders the outline in the canvas.
  153136. * @param subMesh Defines the sumesh to render
  153137. * @param batch Defines the batch of meshes in case of instances
  153138. * @param useOverlay Defines if the rendering is for the overlay or the outline
  153139. */
  153140. render(subMesh: SubMesh, batch: _InstancesBatch, useOverlay?: boolean): void;
  153141. /**
  153142. * Returns whether or not the outline renderer is ready for a given submesh.
  153143. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  153144. * @param subMesh Defines the submesh to check readyness for
  153145. * @param useInstances Defines wheter wee are trying to render instances or not
  153146. * @returns true if ready otherwise false
  153147. */
  153148. isReady(subMesh: SubMesh, useInstances: boolean): boolean;
  153149. private _beforeRenderingMesh;
  153150. private _afterRenderingMesh;
  153151. }
  153152. }
  153153. declare module BABYLON {
  153154. /**
  153155. * Defines the basic options interface of a Sprite Frame Source Size.
  153156. */
  153157. export interface ISpriteJSONSpriteSourceSize {
  153158. /**
  153159. * number of the original width of the Frame
  153160. */
  153161. w: number;
  153162. /**
  153163. * number of the original height of the Frame
  153164. */
  153165. h: number;
  153166. }
  153167. /**
  153168. * Defines the basic options interface of a Sprite Frame Data.
  153169. */
  153170. export interface ISpriteJSONSpriteFrameData {
  153171. /**
  153172. * number of the x offset of the Frame
  153173. */
  153174. x: number;
  153175. /**
  153176. * number of the y offset of the Frame
  153177. */
  153178. y: number;
  153179. /**
  153180. * number of the width of the Frame
  153181. */
  153182. w: number;
  153183. /**
  153184. * number of the height of the Frame
  153185. */
  153186. h: number;
  153187. }
  153188. /**
  153189. * Defines the basic options interface of a JSON Sprite.
  153190. */
  153191. export interface ISpriteJSONSprite {
  153192. /**
  153193. * string name of the Frame
  153194. */
  153195. filename: string;
  153196. /**
  153197. * ISpriteJSONSpriteFrame basic object of the frame data
  153198. */
  153199. frame: ISpriteJSONSpriteFrameData;
  153200. /**
  153201. * boolean to flag is the frame was rotated.
  153202. */
  153203. rotated: boolean;
  153204. /**
  153205. * boolean to flag is the frame was trimmed.
  153206. */
  153207. trimmed: boolean;
  153208. /**
  153209. * ISpriteJSONSpriteFrame basic object of the source data
  153210. */
  153211. spriteSourceSize: ISpriteJSONSpriteFrameData;
  153212. /**
  153213. * ISpriteJSONSpriteFrame basic object of the source data
  153214. */
  153215. sourceSize: ISpriteJSONSpriteSourceSize;
  153216. }
  153217. /**
  153218. * Defines the basic options interface of a JSON atlas.
  153219. */
  153220. export interface ISpriteJSONAtlas {
  153221. /**
  153222. * Array of objects that contain the frame data.
  153223. */
  153224. frames: Array<ISpriteJSONSprite>;
  153225. /**
  153226. * object basic object containing the sprite meta data.
  153227. */
  153228. meta?: object;
  153229. }
  153230. }
  153231. declare module BABYLON {
  153232. /** @hidden */
  153233. export var spriteMapPixelShader: {
  153234. name: string;
  153235. shader: string;
  153236. };
  153237. }
  153238. declare module BABYLON {
  153239. /** @hidden */
  153240. export var spriteMapVertexShader: {
  153241. name: string;
  153242. shader: string;
  153243. };
  153244. }
  153245. declare module BABYLON {
  153246. /**
  153247. * Defines the basic options interface of a SpriteMap
  153248. */
  153249. export interface ISpriteMapOptions {
  153250. /**
  153251. * Vector2 of the number of cells in the grid.
  153252. */
  153253. stageSize?: Vector2;
  153254. /**
  153255. * Vector2 of the size of the output plane in World Units.
  153256. */
  153257. outputSize?: Vector2;
  153258. /**
  153259. * Vector3 of the position of the output plane in World Units.
  153260. */
  153261. outputPosition?: Vector3;
  153262. /**
  153263. * Vector3 of the rotation of the output plane.
  153264. */
  153265. outputRotation?: Vector3;
  153266. /**
  153267. * number of layers that the system will reserve in resources.
  153268. */
  153269. layerCount?: number;
  153270. /**
  153271. * number of max animation frames a single cell will reserve in resources.
  153272. */
  153273. maxAnimationFrames?: number;
  153274. /**
  153275. * number cell index of the base tile when the system compiles.
  153276. */
  153277. baseTile?: number;
  153278. /**
  153279. * boolean flip the sprite after its been repositioned by the framing data.
  153280. */
  153281. flipU?: boolean;
  153282. /**
  153283. * Vector3 scalar of the global RGB values of the SpriteMap.
  153284. */
  153285. colorMultiply?: Vector3;
  153286. }
  153287. /**
  153288. * Defines the IDisposable interface in order to be cleanable from resources.
  153289. */
  153290. export interface ISpriteMap extends IDisposable {
  153291. /**
  153292. * String name of the SpriteMap.
  153293. */
  153294. name: string;
  153295. /**
  153296. * The JSON Array file from a https://www.codeandweb.com/texturepacker export. Or similar structure.
  153297. */
  153298. atlasJSON: ISpriteJSONAtlas;
  153299. /**
  153300. * Texture of the SpriteMap.
  153301. */
  153302. spriteSheet: Texture;
  153303. /**
  153304. * The parameters to initialize the SpriteMap with.
  153305. */
  153306. options: ISpriteMapOptions;
  153307. }
  153308. /**
  153309. * Class used to manage a grid restricted sprite deployment on an Output plane.
  153310. */
  153311. export class SpriteMap implements ISpriteMap {
  153312. /** The Name of the spriteMap */
  153313. name: string;
  153314. /** The JSON file with the frame and meta data */
  153315. atlasJSON: ISpriteJSONAtlas;
  153316. /** The systems Sprite Sheet Texture */
  153317. spriteSheet: Texture;
  153318. /** Arguments passed with the Constructor */
  153319. options: ISpriteMapOptions;
  153320. /** Public Sprite Storage array, parsed from atlasJSON */
  153321. sprites: Array<ISpriteJSONSprite>;
  153322. /** Returns the Number of Sprites in the System */
  153323. get spriteCount(): number;
  153324. /** Returns the Position of Output Plane*/
  153325. get position(): Vector3;
  153326. /** Returns the Position of Output Plane*/
  153327. set position(v: Vector3);
  153328. /** Returns the Rotation of Output Plane*/
  153329. get rotation(): Vector3;
  153330. /** Returns the Rotation of Output Plane*/
  153331. set rotation(v: Vector3);
  153332. /** Sets the AnimationMap*/
  153333. get animationMap(): RawTexture;
  153334. /** Sets the AnimationMap*/
  153335. set animationMap(v: RawTexture);
  153336. /** Scene that the SpriteMap was created in */
  153337. private _scene;
  153338. /** Texture Buffer of Float32 that holds tile frame data*/
  153339. private _frameMap;
  153340. /** Texture Buffers of Float32 that holds tileMap data*/
  153341. private _tileMaps;
  153342. /** Texture Buffer of Float32 that holds Animation Data*/
  153343. private _animationMap;
  153344. /** Custom ShaderMaterial Central to the System*/
  153345. private _material;
  153346. /** Custom ShaderMaterial Central to the System*/
  153347. private _output;
  153348. /** Systems Time Ticker*/
  153349. private _time;
  153350. /**
  153351. * Creates a new SpriteMap
  153352. * @param name defines the SpriteMaps Name
  153353. * @param atlasJSON is the JSON file that controls the Sprites Frames and Meta
  153354. * @param spriteSheet is the Texture that the Sprites are on.
  153355. * @param options a basic deployment configuration
  153356. * @param scene The Scene that the map is deployed on
  153357. */
  153358. constructor(name: string, atlasJSON: ISpriteJSONAtlas, spriteSheet: Texture, options: ISpriteMapOptions, scene: Scene);
  153359. /**
  153360. * Returns tileID location
  153361. * @returns Vector2 the cell position ID
  153362. */
  153363. getTileID(): Vector2;
  153364. /**
  153365. * Gets the UV location of the mouse over the SpriteMap.
  153366. * @returns Vector2 the UV position of the mouse interaction
  153367. */
  153368. getMousePosition(): Vector2;
  153369. /**
  153370. * Creates the "frame" texture Buffer
  153371. * -------------------------------------
  153372. * Structure of frames
  153373. * "filename": "Falling-Water-2.png",
  153374. * "frame": {"x":69,"y":103,"w":24,"h":32},
  153375. * "rotated": true,
  153376. * "trimmed": true,
  153377. * "spriteSourceSize": {"x":4,"y":0,"w":24,"h":32},
  153378. * "sourceSize": {"w":32,"h":32}
  153379. * @returns RawTexture of the frameMap
  153380. */
  153381. private _createFrameBuffer;
  153382. /**
  153383. * Creates the tileMap texture Buffer
  153384. * @param buffer normally and array of numbers, or a false to generate from scratch
  153385. * @param _layer indicates what layer for a logic trigger dealing with the baseTile. The system uses this
  153386. * @returns RawTexture of the tileMap
  153387. */
  153388. private _createTileBuffer;
  153389. /**
  153390. * Modifies the data of the tileMaps
  153391. * @param _layer is the ID of the layer you want to edit on the SpriteMap
  153392. * @param pos is the iVector2 Coordinates of the Tile
  153393. * @param tile The SpriteIndex of the new Tile
  153394. */
  153395. changeTiles(_layer: number | undefined, pos: Vector2 | Vector2[], tile?: number): void;
  153396. /**
  153397. * Creates the animationMap texture Buffer
  153398. * @param buffer normally and array of numbers, or a false to generate from scratch
  153399. * @returns RawTexture of the animationMap
  153400. */
  153401. private _createTileAnimationBuffer;
  153402. /**
  153403. * Modifies the data of the animationMap
  153404. * @param cellID is the Index of the Sprite
  153405. * @param _frame is the target Animation frame
  153406. * @param toCell is the Target Index of the next frame of the animation
  153407. * @param time is a value between 0-1 that is the trigger for when the frame should change tiles
  153408. * @param speed is a global scalar of the time variable on the map.
  153409. */
  153410. addAnimationToTile(cellID?: number, _frame?: number, toCell?: number, time?: number, speed?: number): void;
  153411. /**
  153412. * Exports the .tilemaps file
  153413. */
  153414. saveTileMaps(): void;
  153415. /**
  153416. * Imports the .tilemaps file
  153417. * @param url of the .tilemaps file
  153418. */
  153419. loadTileMaps(url: string): void;
  153420. /**
  153421. * Release associated resources
  153422. */
  153423. dispose(): void;
  153424. }
  153425. }
  153426. declare module BABYLON {
  153427. /**
  153428. * Class used to manage multiple sprites of different sizes on the same spritesheet
  153429. * @see https://doc.babylonjs.com/babylon101/sprites
  153430. */
  153431. export class SpritePackedManager extends SpriteManager {
  153432. /** defines the packed manager's name */
  153433. name: string;
  153434. /**
  153435. * Creates a new sprite manager from a packed sprite sheet
  153436. * @param name defines the manager's name
  153437. * @param imgUrl defines the sprite sheet url
  153438. * @param capacity defines the maximum allowed number of sprites
  153439. * @param scene defines the hosting scene
  153440. * @param spriteJSON null otherwise a JSON object defining sprite sheet data
  153441. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  153442. * @param samplingMode defines the smapling mode to use with spritesheet
  153443. * @param fromPacked set to true; do not alter
  153444. */
  153445. constructor(
  153446. /** defines the packed manager's name */
  153447. name: string, imgUrl: string, capacity: number, scene: Scene, spriteJSON?: string | null, epsilon?: number, samplingMode?: number);
  153448. }
  153449. }
  153450. declare module BABYLON {
  153451. /**
  153452. * Defines the list of states available for a task inside a AssetsManager
  153453. */
  153454. export enum AssetTaskState {
  153455. /**
  153456. * Initialization
  153457. */
  153458. INIT = 0,
  153459. /**
  153460. * Running
  153461. */
  153462. RUNNING = 1,
  153463. /**
  153464. * Done
  153465. */
  153466. DONE = 2,
  153467. /**
  153468. * Error
  153469. */
  153470. ERROR = 3
  153471. }
  153472. /**
  153473. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  153474. */
  153475. export abstract class AbstractAssetTask {
  153476. /**
  153477. * Task name
  153478. */ name: string;
  153479. /**
  153480. * Callback called when the task is successful
  153481. */
  153482. onSuccess: (task: any) => void;
  153483. /**
  153484. * Callback called when the task is not successful
  153485. */
  153486. onError: (task: any, message?: string, exception?: any) => void;
  153487. /**
  153488. * Creates a new AssetsManager
  153489. * @param name defines the name of the task
  153490. */
  153491. constructor(
  153492. /**
  153493. * Task name
  153494. */ name: string);
  153495. private _isCompleted;
  153496. private _taskState;
  153497. private _errorObject;
  153498. /**
  153499. * Get if the task is completed
  153500. */
  153501. get isCompleted(): boolean;
  153502. /**
  153503. * Gets the current state of the task
  153504. */
  153505. get taskState(): AssetTaskState;
  153506. /**
  153507. * Gets the current error object (if task is in error)
  153508. */
  153509. get errorObject(): {
  153510. message?: string;
  153511. exception?: any;
  153512. };
  153513. /**
  153514. * Internal only
  153515. * @hidden
  153516. */
  153517. _setErrorObject(message?: string, exception?: any): void;
  153518. /**
  153519. * Execute the current task
  153520. * @param scene defines the scene where you want your assets to be loaded
  153521. * @param onSuccess is a callback called when the task is successfully executed
  153522. * @param onError is a callback called if an error occurs
  153523. */
  153524. run(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153525. /**
  153526. * Execute the current task
  153527. * @param scene defines the scene where you want your assets to be loaded
  153528. * @param onSuccess is a callback called when the task is successfully executed
  153529. * @param onError is a callback called if an error occurs
  153530. */
  153531. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153532. /**
  153533. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  153534. * This can be used with failed tasks that have the reason for failure fixed.
  153535. */
  153536. reset(): void;
  153537. private onErrorCallback;
  153538. private onDoneCallback;
  153539. }
  153540. /**
  153541. * Define the interface used by progress events raised during assets loading
  153542. */
  153543. export interface IAssetsProgressEvent {
  153544. /**
  153545. * Defines the number of remaining tasks to process
  153546. */
  153547. remainingCount: number;
  153548. /**
  153549. * Defines the total number of tasks
  153550. */
  153551. totalCount: number;
  153552. /**
  153553. * Defines the task that was just processed
  153554. */
  153555. task: AbstractAssetTask;
  153556. }
  153557. /**
  153558. * Class used to share progress information about assets loading
  153559. */
  153560. export class AssetsProgressEvent implements IAssetsProgressEvent {
  153561. /**
  153562. * Defines the number of remaining tasks to process
  153563. */
  153564. remainingCount: number;
  153565. /**
  153566. * Defines the total number of tasks
  153567. */
  153568. totalCount: number;
  153569. /**
  153570. * Defines the task that was just processed
  153571. */
  153572. task: AbstractAssetTask;
  153573. /**
  153574. * Creates a AssetsProgressEvent
  153575. * @param remainingCount defines the number of remaining tasks to process
  153576. * @param totalCount defines the total number of tasks
  153577. * @param task defines the task that was just processed
  153578. */
  153579. constructor(remainingCount: number, totalCount: number, task: AbstractAssetTask);
  153580. }
  153581. /**
  153582. * Define a task used by AssetsManager to load assets into a container
  153583. */
  153584. export class ContainerAssetTask extends AbstractAssetTask {
  153585. /**
  153586. * Defines the name of the task
  153587. */
  153588. name: string;
  153589. /**
  153590. * Defines the list of mesh's names you want to load
  153591. */
  153592. meshesNames: any;
  153593. /**
  153594. * Defines the root url to use as a base to load your meshes and associated resources
  153595. */
  153596. rootUrl: string;
  153597. /**
  153598. * Defines the filename or File of the scene to load from
  153599. */
  153600. sceneFilename: string | File;
  153601. /**
  153602. * Get the loaded asset container
  153603. */
  153604. loadedContainer: AssetContainer;
  153605. /**
  153606. * Gets the list of loaded meshes
  153607. */
  153608. loadedMeshes: Array<AbstractMesh>;
  153609. /**
  153610. * Gets the list of loaded particle systems
  153611. */
  153612. loadedParticleSystems: Array<IParticleSystem>;
  153613. /**
  153614. * Gets the list of loaded skeletons
  153615. */
  153616. loadedSkeletons: Array<Skeleton>;
  153617. /**
  153618. * Gets the list of loaded animation groups
  153619. */
  153620. loadedAnimationGroups: Array<AnimationGroup>;
  153621. /**
  153622. * Callback called when the task is successful
  153623. */
  153624. onSuccess: (task: ContainerAssetTask) => void;
  153625. /**
  153626. * Callback called when the task is successful
  153627. */
  153628. onError: (task: ContainerAssetTask, message?: string, exception?: any) => void;
  153629. /**
  153630. * Creates a new ContainerAssetTask
  153631. * @param name defines the name of the task
  153632. * @param meshesNames defines the list of mesh's names you want to load
  153633. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153634. * @param sceneFilename defines the filename or File of the scene to load from
  153635. */
  153636. constructor(
  153637. /**
  153638. * Defines the name of the task
  153639. */
  153640. name: string,
  153641. /**
  153642. * Defines the list of mesh's names you want to load
  153643. */
  153644. meshesNames: any,
  153645. /**
  153646. * Defines the root url to use as a base to load your meshes and associated resources
  153647. */
  153648. rootUrl: string,
  153649. /**
  153650. * Defines the filename or File of the scene to load from
  153651. */
  153652. sceneFilename: string | File);
  153653. /**
  153654. * Execute the current task
  153655. * @param scene defines the scene where you want your assets to be loaded
  153656. * @param onSuccess is a callback called when the task is successfully executed
  153657. * @param onError is a callback called if an error occurs
  153658. */
  153659. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153660. }
  153661. /**
  153662. * Define a task used by AssetsManager to load meshes
  153663. */
  153664. export class MeshAssetTask extends AbstractAssetTask {
  153665. /**
  153666. * Defines the name of the task
  153667. */
  153668. name: string;
  153669. /**
  153670. * Defines the list of mesh's names you want to load
  153671. */
  153672. meshesNames: any;
  153673. /**
  153674. * Defines the root url to use as a base to load your meshes and associated resources
  153675. */
  153676. rootUrl: string;
  153677. /**
  153678. * Defines the filename or File of the scene to load from
  153679. */
  153680. sceneFilename: string | File;
  153681. /**
  153682. * Gets the list of loaded meshes
  153683. */
  153684. loadedMeshes: Array<AbstractMesh>;
  153685. /**
  153686. * Gets the list of loaded particle systems
  153687. */
  153688. loadedParticleSystems: Array<IParticleSystem>;
  153689. /**
  153690. * Gets the list of loaded skeletons
  153691. */
  153692. loadedSkeletons: Array<Skeleton>;
  153693. /**
  153694. * Gets the list of loaded animation groups
  153695. */
  153696. loadedAnimationGroups: Array<AnimationGroup>;
  153697. /**
  153698. * Callback called when the task is successful
  153699. */
  153700. onSuccess: (task: MeshAssetTask) => void;
  153701. /**
  153702. * Callback called when the task is successful
  153703. */
  153704. onError: (task: MeshAssetTask, message?: string, exception?: any) => void;
  153705. /**
  153706. * Creates a new MeshAssetTask
  153707. * @param name defines the name of the task
  153708. * @param meshesNames defines the list of mesh's names you want to load
  153709. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  153710. * @param sceneFilename defines the filename or File of the scene to load from
  153711. */
  153712. constructor(
  153713. /**
  153714. * Defines the name of the task
  153715. */
  153716. name: string,
  153717. /**
  153718. * Defines the list of mesh's names you want to load
  153719. */
  153720. meshesNames: any,
  153721. /**
  153722. * Defines the root url to use as a base to load your meshes and associated resources
  153723. */
  153724. rootUrl: string,
  153725. /**
  153726. * Defines the filename or File of the scene to load from
  153727. */
  153728. sceneFilename: string | File);
  153729. /**
  153730. * Execute the current task
  153731. * @param scene defines the scene where you want your assets to be loaded
  153732. * @param onSuccess is a callback called when the task is successfully executed
  153733. * @param onError is a callback called if an error occurs
  153734. */
  153735. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153736. }
  153737. /**
  153738. * Define a task used by AssetsManager to load text content
  153739. */
  153740. export class TextFileAssetTask extends AbstractAssetTask {
  153741. /**
  153742. * Defines the name of the task
  153743. */
  153744. name: string;
  153745. /**
  153746. * Defines the location of the file to load
  153747. */
  153748. url: string;
  153749. /**
  153750. * Gets the loaded text string
  153751. */
  153752. text: string;
  153753. /**
  153754. * Callback called when the task is successful
  153755. */
  153756. onSuccess: (task: TextFileAssetTask) => void;
  153757. /**
  153758. * Callback called when the task is successful
  153759. */
  153760. onError: (task: TextFileAssetTask, message?: string, exception?: any) => void;
  153761. /**
  153762. * Creates a new TextFileAssetTask object
  153763. * @param name defines the name of the task
  153764. * @param url defines the location of the file to load
  153765. */
  153766. constructor(
  153767. /**
  153768. * Defines the name of the task
  153769. */
  153770. name: string,
  153771. /**
  153772. * Defines the location of the file to load
  153773. */
  153774. url: string);
  153775. /**
  153776. * Execute the current task
  153777. * @param scene defines the scene where you want your assets to be loaded
  153778. * @param onSuccess is a callback called when the task is successfully executed
  153779. * @param onError is a callback called if an error occurs
  153780. */
  153781. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153782. }
  153783. /**
  153784. * Define a task used by AssetsManager to load binary data
  153785. */
  153786. export class BinaryFileAssetTask extends AbstractAssetTask {
  153787. /**
  153788. * Defines the name of the task
  153789. */
  153790. name: string;
  153791. /**
  153792. * Defines the location of the file to load
  153793. */
  153794. url: string;
  153795. /**
  153796. * Gets the lodaded data (as an array buffer)
  153797. */
  153798. data: ArrayBuffer;
  153799. /**
  153800. * Callback called when the task is successful
  153801. */
  153802. onSuccess: (task: BinaryFileAssetTask) => void;
  153803. /**
  153804. * Callback called when the task is successful
  153805. */
  153806. onError: (task: BinaryFileAssetTask, message?: string, exception?: any) => void;
  153807. /**
  153808. * Creates a new BinaryFileAssetTask object
  153809. * @param name defines the name of the new task
  153810. * @param url defines the location of the file to load
  153811. */
  153812. constructor(
  153813. /**
  153814. * Defines the name of the task
  153815. */
  153816. name: string,
  153817. /**
  153818. * Defines the location of the file to load
  153819. */
  153820. url: string);
  153821. /**
  153822. * Execute the current task
  153823. * @param scene defines the scene where you want your assets to be loaded
  153824. * @param onSuccess is a callback called when the task is successfully executed
  153825. * @param onError is a callback called if an error occurs
  153826. */
  153827. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153828. }
  153829. /**
  153830. * Define a task used by AssetsManager to load images
  153831. */
  153832. export class ImageAssetTask extends AbstractAssetTask {
  153833. /**
  153834. * Defines the name of the task
  153835. */
  153836. name: string;
  153837. /**
  153838. * Defines the location of the image to load
  153839. */
  153840. url: string;
  153841. /**
  153842. * Gets the loaded images
  153843. */
  153844. image: HTMLImageElement;
  153845. /**
  153846. * Callback called when the task is successful
  153847. */
  153848. onSuccess: (task: ImageAssetTask) => void;
  153849. /**
  153850. * Callback called when the task is successful
  153851. */
  153852. onError: (task: ImageAssetTask, message?: string, exception?: any) => void;
  153853. /**
  153854. * Creates a new ImageAssetTask
  153855. * @param name defines the name of the task
  153856. * @param url defines the location of the image to load
  153857. */
  153858. constructor(
  153859. /**
  153860. * Defines the name of the task
  153861. */
  153862. name: string,
  153863. /**
  153864. * Defines the location of the image to load
  153865. */
  153866. url: string);
  153867. /**
  153868. * Execute the current task
  153869. * @param scene defines the scene where you want your assets to be loaded
  153870. * @param onSuccess is a callback called when the task is successfully executed
  153871. * @param onError is a callback called if an error occurs
  153872. */
  153873. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153874. }
  153875. /**
  153876. * Defines the interface used by texture loading tasks
  153877. */
  153878. export interface ITextureAssetTask<TEX extends BaseTexture> {
  153879. /**
  153880. * Gets the loaded texture
  153881. */
  153882. texture: TEX;
  153883. }
  153884. /**
  153885. * Define a task used by AssetsManager to load 2D textures
  153886. */
  153887. export class TextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<Texture> {
  153888. /**
  153889. * Defines the name of the task
  153890. */
  153891. name: string;
  153892. /**
  153893. * Defines the location of the file to load
  153894. */
  153895. url: string;
  153896. /**
  153897. * Defines if mipmap should not be generated (default is false)
  153898. */
  153899. noMipmap?: boolean | undefined;
  153900. /**
  153901. * Defines if texture must be inverted on Y axis (default is true)
  153902. */
  153903. invertY: boolean;
  153904. /**
  153905. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153906. */
  153907. samplingMode: number;
  153908. /**
  153909. * Gets the loaded texture
  153910. */
  153911. texture: Texture;
  153912. /**
  153913. * Callback called when the task is successful
  153914. */
  153915. onSuccess: (task: TextureAssetTask) => void;
  153916. /**
  153917. * Callback called when the task is successful
  153918. */
  153919. onError: (task: TextureAssetTask, message?: string, exception?: any) => void;
  153920. /**
  153921. * Creates a new TextureAssetTask object
  153922. * @param name defines the name of the task
  153923. * @param url defines the location of the file to load
  153924. * @param noMipmap defines if mipmap should not be generated (default is false)
  153925. * @param invertY defines if texture must be inverted on Y axis (default is true)
  153926. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153927. */
  153928. constructor(
  153929. /**
  153930. * Defines the name of the task
  153931. */
  153932. name: string,
  153933. /**
  153934. * Defines the location of the file to load
  153935. */
  153936. url: string,
  153937. /**
  153938. * Defines if mipmap should not be generated (default is false)
  153939. */
  153940. noMipmap?: boolean | undefined,
  153941. /**
  153942. * Defines if texture must be inverted on Y axis (default is true)
  153943. */
  153944. invertY?: boolean,
  153945. /**
  153946. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  153947. */
  153948. samplingMode?: number);
  153949. /**
  153950. * Execute the current task
  153951. * @param scene defines the scene where you want your assets to be loaded
  153952. * @param onSuccess is a callback called when the task is successfully executed
  153953. * @param onError is a callback called if an error occurs
  153954. */
  153955. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  153956. }
  153957. /**
  153958. * Define a task used by AssetsManager to load cube textures
  153959. */
  153960. export class CubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<CubeTexture> {
  153961. /**
  153962. * Defines the name of the task
  153963. */
  153964. name: string;
  153965. /**
  153966. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153967. */
  153968. url: string;
  153969. /**
  153970. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153971. */
  153972. extensions?: string[] | undefined;
  153973. /**
  153974. * Defines if mipmaps should not be generated (default is false)
  153975. */
  153976. noMipmap?: boolean | undefined;
  153977. /**
  153978. * Defines the explicit list of files (undefined by default)
  153979. */
  153980. files?: string[] | undefined;
  153981. /**
  153982. * Gets the loaded texture
  153983. */
  153984. texture: CubeTexture;
  153985. /**
  153986. * Callback called when the task is successful
  153987. */
  153988. onSuccess: (task: CubeTextureAssetTask) => void;
  153989. /**
  153990. * Callback called when the task is successful
  153991. */
  153992. onError: (task: CubeTextureAssetTask, message?: string, exception?: any) => void;
  153993. /**
  153994. * Creates a new CubeTextureAssetTask
  153995. * @param name defines the name of the task
  153996. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  153997. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  153998. * @param noMipmap defines if mipmaps should not be generated (default is false)
  153999. * @param files defines the explicit list of files (undefined by default)
  154000. */
  154001. constructor(
  154002. /**
  154003. * Defines the name of the task
  154004. */
  154005. name: string,
  154006. /**
  154007. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  154008. */
  154009. url: string,
  154010. /**
  154011. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  154012. */
  154013. extensions?: string[] | undefined,
  154014. /**
  154015. * Defines if mipmaps should not be generated (default is false)
  154016. */
  154017. noMipmap?: boolean | undefined,
  154018. /**
  154019. * Defines the explicit list of files (undefined by default)
  154020. */
  154021. files?: string[] | undefined);
  154022. /**
  154023. * Execute the current task
  154024. * @param scene defines the scene where you want your assets to be loaded
  154025. * @param onSuccess is a callback called when the task is successfully executed
  154026. * @param onError is a callback called if an error occurs
  154027. */
  154028. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154029. }
  154030. /**
  154031. * Define a task used by AssetsManager to load HDR cube textures
  154032. */
  154033. export class HDRCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<HDRCubeTexture> {
  154034. /**
  154035. * Defines the name of the task
  154036. */
  154037. name: string;
  154038. /**
  154039. * Defines the location of the file to load
  154040. */
  154041. url: string;
  154042. /**
  154043. * Defines the desired size (the more it increases the longer the generation will be)
  154044. */
  154045. size: number;
  154046. /**
  154047. * Defines if mipmaps should not be generated (default is false)
  154048. */
  154049. noMipmap: boolean;
  154050. /**
  154051. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154052. */
  154053. generateHarmonics: boolean;
  154054. /**
  154055. * 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)
  154056. */
  154057. gammaSpace: boolean;
  154058. /**
  154059. * Internal Use Only
  154060. */
  154061. reserved: boolean;
  154062. /**
  154063. * Gets the loaded texture
  154064. */
  154065. texture: HDRCubeTexture;
  154066. /**
  154067. * Callback called when the task is successful
  154068. */
  154069. onSuccess: (task: HDRCubeTextureAssetTask) => void;
  154070. /**
  154071. * Callback called when the task is successful
  154072. */
  154073. onError: (task: HDRCubeTextureAssetTask, message?: string, exception?: any) => void;
  154074. /**
  154075. * Creates a new HDRCubeTextureAssetTask object
  154076. * @param name defines the name of the task
  154077. * @param url defines the location of the file to load
  154078. * @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.
  154079. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154080. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154081. * @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)
  154082. * @param reserved Internal use only
  154083. */
  154084. constructor(
  154085. /**
  154086. * Defines the name of the task
  154087. */
  154088. name: string,
  154089. /**
  154090. * Defines the location of the file to load
  154091. */
  154092. url: string,
  154093. /**
  154094. * Defines the desired size (the more it increases the longer the generation will be)
  154095. */
  154096. size: number,
  154097. /**
  154098. * Defines if mipmaps should not be generated (default is false)
  154099. */
  154100. noMipmap?: boolean,
  154101. /**
  154102. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  154103. */
  154104. generateHarmonics?: boolean,
  154105. /**
  154106. * 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)
  154107. */
  154108. gammaSpace?: boolean,
  154109. /**
  154110. * Internal Use Only
  154111. */
  154112. reserved?: boolean);
  154113. /**
  154114. * Execute the current task
  154115. * @param scene defines the scene where you want your assets to be loaded
  154116. * @param onSuccess is a callback called when the task is successfully executed
  154117. * @param onError is a callback called if an error occurs
  154118. */
  154119. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154120. }
  154121. /**
  154122. * Define a task used by AssetsManager to load Equirectangular cube textures
  154123. */
  154124. export class EquiRectangularCubeTextureAssetTask extends AbstractAssetTask implements ITextureAssetTask<EquiRectangularCubeTexture> {
  154125. /**
  154126. * Defines the name of the task
  154127. */
  154128. name: string;
  154129. /**
  154130. * Defines the location of the file to load
  154131. */
  154132. url: string;
  154133. /**
  154134. * Defines the desired size (the more it increases the longer the generation will be)
  154135. */
  154136. size: number;
  154137. /**
  154138. * Defines if mipmaps should not be generated (default is false)
  154139. */
  154140. noMipmap: boolean;
  154141. /**
  154142. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154143. * but the standard material would require them in Gamma space) (default is true)
  154144. */
  154145. gammaSpace: boolean;
  154146. /**
  154147. * Gets the loaded texture
  154148. */
  154149. texture: EquiRectangularCubeTexture;
  154150. /**
  154151. * Callback called when the task is successful
  154152. */
  154153. onSuccess: (task: EquiRectangularCubeTextureAssetTask) => void;
  154154. /**
  154155. * Callback called when the task is successful
  154156. */
  154157. onError: (task: EquiRectangularCubeTextureAssetTask, message?: string, exception?: any) => void;
  154158. /**
  154159. * Creates a new EquiRectangularCubeTextureAssetTask object
  154160. * @param name defines the name of the task
  154161. * @param url defines the location of the file to load
  154162. * @param size defines the desired size (the more it increases the longer the generation will be)
  154163. * If the size is omitted this implies you are using a preprocessed cubemap.
  154164. * @param noMipmap defines if mipmaps should not be generated (default is false)
  154165. * @param gammaSpace specifies if the texture will be used in gamma or linear space
  154166. * (the PBR material requires those texture in linear space, but the standard material would require them in Gamma space)
  154167. * (default is true)
  154168. */
  154169. constructor(
  154170. /**
  154171. * Defines the name of the task
  154172. */
  154173. name: string,
  154174. /**
  154175. * Defines the location of the file to load
  154176. */
  154177. url: string,
  154178. /**
  154179. * Defines the desired size (the more it increases the longer the generation will be)
  154180. */
  154181. size: number,
  154182. /**
  154183. * Defines if mipmaps should not be generated (default is false)
  154184. */
  154185. noMipmap?: boolean,
  154186. /**
  154187. * Specifies if the texture will be use in gamma or linear space (the PBR material requires those texture in linear space,
  154188. * but the standard material would require them in Gamma space) (default is true)
  154189. */
  154190. gammaSpace?: boolean);
  154191. /**
  154192. * Execute the current task
  154193. * @param scene defines the scene where you want your assets to be loaded
  154194. * @param onSuccess is a callback called when the task is successfully executed
  154195. * @param onError is a callback called if an error occurs
  154196. */
  154197. runTask(scene: Scene, onSuccess: () => void, onError: (message?: string, exception?: any) => void): void;
  154198. }
  154199. /**
  154200. * This class can be used to easily import assets into a scene
  154201. * @see https://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  154202. */
  154203. export class AssetsManager {
  154204. private _scene;
  154205. private _isLoading;
  154206. protected _tasks: AbstractAssetTask[];
  154207. protected _waitingTasksCount: number;
  154208. protected _totalTasksCount: number;
  154209. /**
  154210. * Callback called when all tasks are processed
  154211. */
  154212. onFinish: (tasks: AbstractAssetTask[]) => void;
  154213. /**
  154214. * Callback called when a task is successful
  154215. */
  154216. onTaskSuccess: (task: AbstractAssetTask) => void;
  154217. /**
  154218. * Callback called when a task had an error
  154219. */
  154220. onTaskError: (task: AbstractAssetTask) => void;
  154221. /**
  154222. * Callback called when a task is done (whatever the result is)
  154223. */
  154224. onProgress: (remainingCount: number, totalCount: number, task: AbstractAssetTask) => void;
  154225. /**
  154226. * Observable called when all tasks are processed
  154227. */
  154228. onTaskSuccessObservable: Observable<AbstractAssetTask>;
  154229. /**
  154230. * Observable called when a task had an error
  154231. */
  154232. onTaskErrorObservable: Observable<AbstractAssetTask>;
  154233. /**
  154234. * Observable called when all tasks were executed
  154235. */
  154236. onTasksDoneObservable: Observable<AbstractAssetTask[]>;
  154237. /**
  154238. * Observable called when a task is done (whatever the result is)
  154239. */
  154240. onProgressObservable: Observable<IAssetsProgressEvent>;
  154241. /**
  154242. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  154243. * @see https://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  154244. */
  154245. useDefaultLoadingScreen: boolean;
  154246. /**
  154247. * Gets or sets a boolean defining if the AssetsManager should automatically hide the loading screen
  154248. * when all assets have been downloaded.
  154249. * If set to false, you need to manually call in hideLoadingUI() once your scene is ready.
  154250. */
  154251. autoHideLoadingUI: boolean;
  154252. /**
  154253. * Creates a new AssetsManager
  154254. * @param scene defines the scene to work on
  154255. */
  154256. constructor(scene: Scene);
  154257. /**
  154258. * Add a ContainerAssetTask to the list of active tasks
  154259. * @param taskName defines the name of the new task
  154260. * @param meshesNames defines the name of meshes to load
  154261. * @param rootUrl defines the root url to use to locate files
  154262. * @param sceneFilename defines the filename of the scene file
  154263. * @returns a new ContainerAssetTask object
  154264. */
  154265. addContainerTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): ContainerAssetTask;
  154266. /**
  154267. * Add a MeshAssetTask to the list of active tasks
  154268. * @param taskName defines the name of the new task
  154269. * @param meshesNames defines the name of meshes to load
  154270. * @param rootUrl defines the root url to use to locate files
  154271. * @param sceneFilename defines the filename of the scene file
  154272. * @returns a new MeshAssetTask object
  154273. */
  154274. addMeshTask(taskName: string, meshesNames: any, rootUrl: string, sceneFilename: string): MeshAssetTask;
  154275. /**
  154276. * Add a TextFileAssetTask to the list of active tasks
  154277. * @param taskName defines the name of the new task
  154278. * @param url defines the url of the file to load
  154279. * @returns a new TextFileAssetTask object
  154280. */
  154281. addTextFileTask(taskName: string, url: string): TextFileAssetTask;
  154282. /**
  154283. * Add a BinaryFileAssetTask to the list of active tasks
  154284. * @param taskName defines the name of the new task
  154285. * @param url defines the url of the file to load
  154286. * @returns a new BinaryFileAssetTask object
  154287. */
  154288. addBinaryFileTask(taskName: string, url: string): BinaryFileAssetTask;
  154289. /**
  154290. * Add a ImageAssetTask to the list of active tasks
  154291. * @param taskName defines the name of the new task
  154292. * @param url defines the url of the file to load
  154293. * @returns a new ImageAssetTask object
  154294. */
  154295. addImageTask(taskName: string, url: string): ImageAssetTask;
  154296. /**
  154297. * Add a TextureAssetTask to the list of active tasks
  154298. * @param taskName defines the name of the new task
  154299. * @param url defines the url of the file to load
  154300. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154301. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  154302. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  154303. * @returns a new TextureAssetTask object
  154304. */
  154305. addTextureTask(taskName: string, url: string, noMipmap?: boolean, invertY?: boolean, samplingMode?: number): TextureAssetTask;
  154306. /**
  154307. * Add a CubeTextureAssetTask to the list of active tasks
  154308. * @param taskName defines the name of the new task
  154309. * @param url defines the url of the file to load
  154310. * @param extensions defines the extension to use to load the cube map (can be null)
  154311. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154312. * @param files defines the list of files to load (can be null)
  154313. * @returns a new CubeTextureAssetTask object
  154314. */
  154315. addCubeTextureTask(taskName: string, url: string, extensions?: string[], noMipmap?: boolean, files?: string[]): CubeTextureAssetTask;
  154316. /**
  154317. *
  154318. * Add a HDRCubeTextureAssetTask to the list of active tasks
  154319. * @param taskName defines the name of the new task
  154320. * @param url defines the url of the file to load
  154321. * @param size defines the size you want for the cubemap (can be null)
  154322. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154323. * @param generateHarmonics defines if you want to automatically generate (true by default)
  154324. * @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)
  154325. * @param reserved Internal use only
  154326. * @returns a new HDRCubeTextureAssetTask object
  154327. */
  154328. addHDRCubeTextureTask(taskName: string, url: string, size: number, noMipmap?: boolean, generateHarmonics?: boolean, gammaSpace?: boolean, reserved?: boolean): HDRCubeTextureAssetTask;
  154329. /**
  154330. *
  154331. * Add a EquiRectangularCubeTextureAssetTask to the list of active tasks
  154332. * @param taskName defines the name of the new task
  154333. * @param url defines the url of the file to load
  154334. * @param size defines the size you want for the cubemap (can be null)
  154335. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  154336. * @param gammaSpace Specifies if the texture will be used in gamma or linear space
  154337. * (the PBR material requires those textures in linear space, but the standard material would require them in Gamma space)
  154338. * @returns a new EquiRectangularCubeTextureAssetTask object
  154339. */
  154340. addEquiRectangularCubeTextureAssetTask(taskName: string, url: string, size: number, noMipmap?: boolean, gammaSpace?: boolean): EquiRectangularCubeTextureAssetTask;
  154341. /**
  154342. * Remove a task from the assets manager.
  154343. * @param task the task to remove
  154344. */
  154345. removeTask(task: AbstractAssetTask): void;
  154346. private _decreaseWaitingTasksCount;
  154347. private _runTask;
  154348. /**
  154349. * Reset the AssetsManager and remove all tasks
  154350. * @return the current instance of the AssetsManager
  154351. */
  154352. reset(): AssetsManager;
  154353. /**
  154354. * Start the loading process
  154355. * @return the current instance of the AssetsManager
  154356. */
  154357. load(): AssetsManager;
  154358. /**
  154359. * Start the loading process as an async operation
  154360. * @return a promise returning the list of failed tasks
  154361. */
  154362. loadAsync(): Promise<void>;
  154363. }
  154364. }
  154365. declare module BABYLON {
  154366. /**
  154367. * Wrapper class for promise with external resolve and reject.
  154368. */
  154369. export class Deferred<T> {
  154370. /**
  154371. * The promise associated with this deferred object.
  154372. */
  154373. readonly promise: Promise<T>;
  154374. private _resolve;
  154375. private _reject;
  154376. /**
  154377. * The resolve method of the promise associated with this deferred object.
  154378. */
  154379. get resolve(): (value?: T | PromiseLike<T> | undefined) => void;
  154380. /**
  154381. * The reject method of the promise associated with this deferred object.
  154382. */
  154383. get reject(): (reason?: any) => void;
  154384. /**
  154385. * Constructor for this deferred object.
  154386. */
  154387. constructor();
  154388. }
  154389. }
  154390. declare module BABYLON {
  154391. /**
  154392. * Class used to explode meshes (ie. to have a center and move them away from that center to better see the overall organization)
  154393. */
  154394. export class MeshExploder {
  154395. private _centerMesh;
  154396. private _meshes;
  154397. private _meshesOrigins;
  154398. private _toCenterVectors;
  154399. private _scaledDirection;
  154400. private _newPosition;
  154401. private _centerPosition;
  154402. /**
  154403. * Explodes meshes from a center mesh.
  154404. * @param meshes The meshes to explode.
  154405. * @param centerMesh The mesh to be center of explosion.
  154406. */
  154407. constructor(meshes: Array<Mesh>, centerMesh?: Mesh);
  154408. private _setCenterMesh;
  154409. /**
  154410. * Get class name
  154411. * @returns "MeshExploder"
  154412. */
  154413. getClassName(): string;
  154414. /**
  154415. * "Exploded meshes"
  154416. * @returns Array of meshes with the centerMesh at index 0.
  154417. */
  154418. getMeshes(): Array<Mesh>;
  154419. /**
  154420. * Explodes meshes giving a specific direction
  154421. * @param direction Number to multiply distance of each mesh's origin from center. Use a negative number to implode, or zero to reset.
  154422. */
  154423. explode(direction?: number): void;
  154424. }
  154425. }
  154426. declare module BABYLON {
  154427. /**
  154428. * Class used to help managing file picking and drag'n'drop
  154429. */
  154430. export class FilesInput {
  154431. /**
  154432. * List of files ready to be loaded
  154433. */
  154434. static get FilesToLoad(): {
  154435. [key: string]: File;
  154436. };
  154437. /**
  154438. * Callback called when a file is processed
  154439. */
  154440. onProcessFileCallback: (file: File, name: string, extension: string) => boolean;
  154441. private _engine;
  154442. private _currentScene;
  154443. private _sceneLoadedCallback;
  154444. private _progressCallback;
  154445. private _additionalRenderLoopLogicCallback;
  154446. private _textureLoadingCallback;
  154447. private _startingProcessingFilesCallback;
  154448. private _onReloadCallback;
  154449. private _errorCallback;
  154450. private _elementToMonitor;
  154451. private _sceneFileToLoad;
  154452. private _filesToLoad;
  154453. /**
  154454. * Creates a new FilesInput
  154455. * @param engine defines the rendering engine
  154456. * @param scene defines the hosting scene
  154457. * @param sceneLoadedCallback callback called when scene is loaded
  154458. * @param progressCallback callback called to track progress
  154459. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  154460. * @param textureLoadingCallback callback called when a texture is loading
  154461. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  154462. * @param onReloadCallback callback called when a reload is requested
  154463. * @param errorCallback callback call if an error occurs
  154464. */
  154465. 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>);
  154466. private _dragEnterHandler;
  154467. private _dragOverHandler;
  154468. private _dropHandler;
  154469. /**
  154470. * Calls this function to listen to drag'n'drop events on a specific DOM element
  154471. * @param elementToMonitor defines the DOM element to track
  154472. */
  154473. monitorElementForDragNDrop(elementToMonitor: HTMLElement): void;
  154474. /** Gets the current list of files to load */
  154475. get filesToLoad(): File[];
  154476. /**
  154477. * Release all associated resources
  154478. */
  154479. dispose(): void;
  154480. private renderFunction;
  154481. private drag;
  154482. private drop;
  154483. private _traverseFolder;
  154484. private _processFiles;
  154485. /**
  154486. * Load files from a drop event
  154487. * @param event defines the drop event to use as source
  154488. */
  154489. loadFiles(event: any): void;
  154490. private _processReload;
  154491. /**
  154492. * Reload the current scene from the loaded files
  154493. */
  154494. reload(): void;
  154495. }
  154496. }
  154497. declare module BABYLON {
  154498. /**
  154499. * Defines the root class used to create scene optimization to use with SceneOptimizer
  154500. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154501. */
  154502. export class SceneOptimization {
  154503. /**
  154504. * Defines the priority of this optimization (0 by default which means first in the list)
  154505. */
  154506. priority: number;
  154507. /**
  154508. * Gets a string describing the action executed by the current optimization
  154509. * @returns description string
  154510. */
  154511. getDescription(): string;
  154512. /**
  154513. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154514. * @param scene defines the current scene where to apply this optimization
  154515. * @param optimizer defines the current optimizer
  154516. * @returns true if everything that can be done was applied
  154517. */
  154518. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154519. /**
  154520. * Creates the SceneOptimization object
  154521. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154522. * @param desc defines the description associated with the optimization
  154523. */
  154524. constructor(
  154525. /**
  154526. * Defines the priority of this optimization (0 by default which means first in the list)
  154527. */
  154528. priority?: number);
  154529. }
  154530. /**
  154531. * Defines an optimization used to reduce the size of render target textures
  154532. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154533. */
  154534. export class TextureOptimization extends SceneOptimization {
  154535. /**
  154536. * Defines the priority of this optimization (0 by default which means first in the list)
  154537. */
  154538. priority: number;
  154539. /**
  154540. * 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
  154541. */
  154542. maximumSize: number;
  154543. /**
  154544. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154545. */
  154546. step: number;
  154547. /**
  154548. * Gets a string describing the action executed by the current optimization
  154549. * @returns description string
  154550. */
  154551. getDescription(): string;
  154552. /**
  154553. * Creates the TextureOptimization object
  154554. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154555. * @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
  154556. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154557. */
  154558. constructor(
  154559. /**
  154560. * Defines the priority of this optimization (0 by default which means first in the list)
  154561. */
  154562. priority?: number,
  154563. /**
  154564. * 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
  154565. */
  154566. maximumSize?: number,
  154567. /**
  154568. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  154569. */
  154570. step?: number);
  154571. /**
  154572. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154573. * @param scene defines the current scene where to apply this optimization
  154574. * @param optimizer defines the current optimizer
  154575. * @returns true if everything that can be done was applied
  154576. */
  154577. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154578. }
  154579. /**
  154580. * Defines an optimization used to increase or decrease the rendering resolution
  154581. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154582. */
  154583. export class HardwareScalingOptimization extends SceneOptimization {
  154584. /**
  154585. * Defines the priority of this optimization (0 by default which means first in the list)
  154586. */
  154587. priority: number;
  154588. /**
  154589. * Defines the maximum scale to use (2 by default)
  154590. */
  154591. maximumScale: number;
  154592. /**
  154593. * Defines the step to use between two passes (0.5 by default)
  154594. */
  154595. step: number;
  154596. private _currentScale;
  154597. private _directionOffset;
  154598. /**
  154599. * Gets a string describing the action executed by the current optimization
  154600. * @return description string
  154601. */
  154602. getDescription(): string;
  154603. /**
  154604. * Creates the HardwareScalingOptimization object
  154605. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154606. * @param maximumScale defines the maximum scale to use (2 by default)
  154607. * @param step defines the step to use between two passes (0.5 by default)
  154608. */
  154609. constructor(
  154610. /**
  154611. * Defines the priority of this optimization (0 by default which means first in the list)
  154612. */
  154613. priority?: number,
  154614. /**
  154615. * Defines the maximum scale to use (2 by default)
  154616. */
  154617. maximumScale?: number,
  154618. /**
  154619. * Defines the step to use between two passes (0.5 by default)
  154620. */
  154621. step?: number);
  154622. /**
  154623. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154624. * @param scene defines the current scene where to apply this optimization
  154625. * @param optimizer defines the current optimizer
  154626. * @returns true if everything that can be done was applied
  154627. */
  154628. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154629. }
  154630. /**
  154631. * Defines an optimization used to remove shadows
  154632. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154633. */
  154634. export class ShadowsOptimization extends SceneOptimization {
  154635. /**
  154636. * Gets a string describing the action executed by the current optimization
  154637. * @return description string
  154638. */
  154639. getDescription(): string;
  154640. /**
  154641. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154642. * @param scene defines the current scene where to apply this optimization
  154643. * @param optimizer defines the current optimizer
  154644. * @returns true if everything that can be done was applied
  154645. */
  154646. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154647. }
  154648. /**
  154649. * Defines an optimization used to turn post-processes off
  154650. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154651. */
  154652. export class PostProcessesOptimization extends SceneOptimization {
  154653. /**
  154654. * Gets a string describing the action executed by the current optimization
  154655. * @return description string
  154656. */
  154657. getDescription(): string;
  154658. /**
  154659. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154660. * @param scene defines the current scene where to apply this optimization
  154661. * @param optimizer defines the current optimizer
  154662. * @returns true if everything that can be done was applied
  154663. */
  154664. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154665. }
  154666. /**
  154667. * Defines an optimization used to turn lens flares off
  154668. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154669. */
  154670. export class LensFlaresOptimization extends SceneOptimization {
  154671. /**
  154672. * Gets a string describing the action executed by the current optimization
  154673. * @return description string
  154674. */
  154675. getDescription(): string;
  154676. /**
  154677. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154678. * @param scene defines the current scene where to apply this optimization
  154679. * @param optimizer defines the current optimizer
  154680. * @returns true if everything that can be done was applied
  154681. */
  154682. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154683. }
  154684. /**
  154685. * Defines an optimization based on user defined callback.
  154686. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154687. */
  154688. export class CustomOptimization extends SceneOptimization {
  154689. /**
  154690. * Callback called to apply the custom optimization.
  154691. */
  154692. onApply: (scene: Scene, optimizer: SceneOptimizer) => boolean;
  154693. /**
  154694. * Callback called to get custom description
  154695. */
  154696. onGetDescription: () => string;
  154697. /**
  154698. * Gets a string describing the action executed by the current optimization
  154699. * @returns description string
  154700. */
  154701. getDescription(): string;
  154702. /**
  154703. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154704. * @param scene defines the current scene where to apply this optimization
  154705. * @param optimizer defines the current optimizer
  154706. * @returns true if everything that can be done was applied
  154707. */
  154708. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154709. }
  154710. /**
  154711. * Defines an optimization used to turn particles off
  154712. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154713. */
  154714. export class ParticlesOptimization extends SceneOptimization {
  154715. /**
  154716. * Gets a string describing the action executed by the current optimization
  154717. * @return description string
  154718. */
  154719. getDescription(): string;
  154720. /**
  154721. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154722. * @param scene defines the current scene where to apply this optimization
  154723. * @param optimizer defines the current optimizer
  154724. * @returns true if everything that can be done was applied
  154725. */
  154726. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154727. }
  154728. /**
  154729. * Defines an optimization used to turn render targets off
  154730. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154731. */
  154732. export class RenderTargetsOptimization extends SceneOptimization {
  154733. /**
  154734. * Gets a string describing the action executed by the current optimization
  154735. * @return description string
  154736. */
  154737. getDescription(): string;
  154738. /**
  154739. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154740. * @param scene defines the current scene where to apply this optimization
  154741. * @param optimizer defines the current optimizer
  154742. * @returns true if everything that can be done was applied
  154743. */
  154744. apply(scene: Scene, optimizer: SceneOptimizer): boolean;
  154745. }
  154746. /**
  154747. * Defines an optimization used to merge meshes with compatible materials
  154748. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154749. */
  154750. export class MergeMeshesOptimization extends SceneOptimization {
  154751. private static _UpdateSelectionTree;
  154752. /**
  154753. * Gets or sets a boolean which defines if optimization octree has to be updated
  154754. */
  154755. static get UpdateSelectionTree(): boolean;
  154756. /**
  154757. * Gets or sets a boolean which defines if optimization octree has to be updated
  154758. */
  154759. static set UpdateSelectionTree(value: boolean);
  154760. /**
  154761. * Gets a string describing the action executed by the current optimization
  154762. * @return description string
  154763. */
  154764. getDescription(): string;
  154765. private _canBeMerged;
  154766. /**
  154767. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  154768. * @param scene defines the current scene where to apply this optimization
  154769. * @param optimizer defines the current optimizer
  154770. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  154771. * @returns true if everything that can be done was applied
  154772. */
  154773. apply(scene: Scene, optimizer: SceneOptimizer, updateSelectionTree?: boolean): boolean;
  154774. }
  154775. /**
  154776. * Defines a list of options used by SceneOptimizer
  154777. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154778. */
  154779. export class SceneOptimizerOptions {
  154780. /**
  154781. * Defines the target frame rate to reach (60 by default)
  154782. */
  154783. targetFrameRate: number;
  154784. /**
  154785. * Defines the interval between two checkes (2000ms by default)
  154786. */
  154787. trackerDuration: number;
  154788. /**
  154789. * Gets the list of optimizations to apply
  154790. */
  154791. optimizations: SceneOptimization[];
  154792. /**
  154793. * Creates a new list of options used by SceneOptimizer
  154794. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  154795. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  154796. */
  154797. constructor(
  154798. /**
  154799. * Defines the target frame rate to reach (60 by default)
  154800. */
  154801. targetFrameRate?: number,
  154802. /**
  154803. * Defines the interval between two checkes (2000ms by default)
  154804. */
  154805. trackerDuration?: number);
  154806. /**
  154807. * Add a new optimization
  154808. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  154809. * @returns the current SceneOptimizerOptions
  154810. */
  154811. addOptimization(optimization: SceneOptimization): SceneOptimizerOptions;
  154812. /**
  154813. * Add a new custom optimization
  154814. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  154815. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  154816. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  154817. * @returns the current SceneOptimizerOptions
  154818. */
  154819. addCustomOptimization(onApply: (scene: Scene) => boolean, onGetDescription: () => string, priority?: number): SceneOptimizerOptions;
  154820. /**
  154821. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  154822. * @param targetFrameRate defines the target frame rate (60 by default)
  154823. * @returns a SceneOptimizerOptions object
  154824. */
  154825. static LowDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154826. /**
  154827. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  154828. * @param targetFrameRate defines the target frame rate (60 by default)
  154829. * @returns a SceneOptimizerOptions object
  154830. */
  154831. static ModerateDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154832. /**
  154833. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  154834. * @param targetFrameRate defines the target frame rate (60 by default)
  154835. * @returns a SceneOptimizerOptions object
  154836. */
  154837. static HighDegradationAllowed(targetFrameRate?: number): SceneOptimizerOptions;
  154838. }
  154839. /**
  154840. * Class used to run optimizations in order to reach a target frame rate
  154841. * @description More details at https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  154842. */
  154843. export class SceneOptimizer implements IDisposable {
  154844. private _isRunning;
  154845. private _options;
  154846. private _scene;
  154847. private _currentPriorityLevel;
  154848. private _targetFrameRate;
  154849. private _trackerDuration;
  154850. private _currentFrameRate;
  154851. private _sceneDisposeObserver;
  154852. private _improvementMode;
  154853. /**
  154854. * Defines an observable called when the optimizer reaches the target frame rate
  154855. */
  154856. onSuccessObservable: Observable<SceneOptimizer>;
  154857. /**
  154858. * Defines an observable called when the optimizer enables an optimization
  154859. */
  154860. onNewOptimizationAppliedObservable: Observable<SceneOptimization>;
  154861. /**
  154862. * Defines an observable called when the optimizer is not able to reach the target frame rate
  154863. */
  154864. onFailureObservable: Observable<SceneOptimizer>;
  154865. /**
  154866. * Gets a boolean indicating if the optimizer is in improvement mode
  154867. */
  154868. get isInImprovementMode(): boolean;
  154869. /**
  154870. * Gets the current priority level (0 at start)
  154871. */
  154872. get currentPriorityLevel(): number;
  154873. /**
  154874. * Gets the current frame rate checked by the SceneOptimizer
  154875. */
  154876. get currentFrameRate(): number;
  154877. /**
  154878. * Gets or sets the current target frame rate (60 by default)
  154879. */
  154880. get targetFrameRate(): number;
  154881. /**
  154882. * Gets or sets the current target frame rate (60 by default)
  154883. */
  154884. set targetFrameRate(value: number);
  154885. /**
  154886. * Gets or sets the current interval between two checks (every 2000ms by default)
  154887. */
  154888. get trackerDuration(): number;
  154889. /**
  154890. * Gets or sets the current interval between two checks (every 2000ms by default)
  154891. */
  154892. set trackerDuration(value: number);
  154893. /**
  154894. * Gets the list of active optimizations
  154895. */
  154896. get optimizations(): SceneOptimization[];
  154897. /**
  154898. * Creates a new SceneOptimizer
  154899. * @param scene defines the scene to work on
  154900. * @param options defines the options to use with the SceneOptimizer
  154901. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  154902. * @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)
  154903. */
  154904. constructor(scene: Scene, options?: SceneOptimizerOptions, autoGeneratePriorities?: boolean, improvementMode?: boolean);
  154905. /**
  154906. * Stops the current optimizer
  154907. */
  154908. stop(): void;
  154909. /**
  154910. * Reset the optimizer to initial step (current priority level = 0)
  154911. */
  154912. reset(): void;
  154913. /**
  154914. * Start the optimizer. By default it will try to reach a specific framerate
  154915. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  154916. */
  154917. start(): void;
  154918. private _checkCurrentState;
  154919. /**
  154920. * Release all resources
  154921. */
  154922. dispose(): void;
  154923. /**
  154924. * Helper function to create a SceneOptimizer with one single line of code
  154925. * @param scene defines the scene to work on
  154926. * @param options defines the options to use with the SceneOptimizer
  154927. * @param onSuccess defines a callback to call on success
  154928. * @param onFailure defines a callback to call on failure
  154929. * @returns the new SceneOptimizer object
  154930. */
  154931. static OptimizeAsync(scene: Scene, options?: SceneOptimizerOptions, onSuccess?: () => void, onFailure?: () => void): SceneOptimizer;
  154932. }
  154933. }
  154934. declare module BABYLON {
  154935. /**
  154936. * Class used to serialize a scene into a string
  154937. */
  154938. export class SceneSerializer {
  154939. /**
  154940. * Clear cache used by a previous serialization
  154941. */
  154942. static ClearCache(): void;
  154943. /**
  154944. * Serialize a scene into a JSON compatible object
  154945. * @param scene defines the scene to serialize
  154946. * @returns a JSON compatible object
  154947. */
  154948. static Serialize(scene: Scene): any;
  154949. /**
  154950. * Serialize a mesh into a JSON compatible object
  154951. * @param toSerialize defines the mesh to serialize
  154952. * @param withParents defines if parents must be serialized as well
  154953. * @param withChildren defines if children must be serialized as well
  154954. * @returns a JSON compatible object
  154955. */
  154956. static SerializeMesh(toSerialize: any, withParents?: boolean, withChildren?: boolean): any;
  154957. }
  154958. }
  154959. declare module BABYLON {
  154960. /**
  154961. * Class used to host texture specific utilities
  154962. */
  154963. export class TextureTools {
  154964. /**
  154965. * Uses the GPU to create a copy texture rescaled at a given size
  154966. * @param texture Texture to copy from
  154967. * @param width defines the desired width
  154968. * @param height defines the desired height
  154969. * @param useBilinearMode defines if bilinear mode has to be used
  154970. * @return the generated texture
  154971. */
  154972. static CreateResizedCopy(texture: Texture, width: number, height: number, useBilinearMode?: boolean): Texture;
  154973. }
  154974. }
  154975. declare module BABYLON {
  154976. /**
  154977. * This represents the different options available for the video capture.
  154978. */
  154979. export interface VideoRecorderOptions {
  154980. /** Defines the mime type of the video. */
  154981. mimeType: string;
  154982. /** Defines the FPS the video should be recorded at. */
  154983. fps: number;
  154984. /** Defines the chunk size for the recording data. */
  154985. recordChunckSize: number;
  154986. /** The audio tracks to attach to the recording. */
  154987. audioTracks?: MediaStreamTrack[];
  154988. }
  154989. /**
  154990. * This can help with recording videos from BabylonJS.
  154991. * This is based on the available WebRTC functionalities of the browser.
  154992. *
  154993. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_video
  154994. */
  154995. export class VideoRecorder {
  154996. private static readonly _defaultOptions;
  154997. /**
  154998. * Returns whether or not the VideoRecorder is available in your browser.
  154999. * @param engine Defines the Babylon Engine.
  155000. * @returns true if supported otherwise false.
  155001. */
  155002. static IsSupported(engine: Engine): boolean;
  155003. private readonly _options;
  155004. private _canvas;
  155005. private _mediaRecorder;
  155006. private _recordedChunks;
  155007. private _fileName;
  155008. private _resolve;
  155009. private _reject;
  155010. /**
  155011. * True when a recording is already in progress.
  155012. */
  155013. get isRecording(): boolean;
  155014. /**
  155015. * Create a new VideoCapture object which can help converting what you see in Babylon to a video file.
  155016. * @param engine Defines the BabylonJS Engine you wish to record.
  155017. * @param options Defines options that can be used to customize the capture.
  155018. */
  155019. constructor(engine: Engine, options?: Nullable<VideoRecorderOptions>);
  155020. /**
  155021. * Stops the current recording before the default capture timeout passed in the startRecording function.
  155022. */
  155023. stopRecording(): void;
  155024. /**
  155025. * Starts recording the canvas for a max duration specified in parameters.
  155026. * @param fileName Defines the name of the file to be downloaded when the recording stop.
  155027. * If null no automatic download will start and you can rely on the promise to get the data back.
  155028. * @param maxDuration Defines the maximum recording time in seconds.
  155029. * It defaults to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  155030. * @return A promise callback at the end of the recording with the video data in Blob.
  155031. */
  155032. startRecording(fileName?: Nullable<string>, maxDuration?: number): Promise<Blob>;
  155033. /**
  155034. * Releases internal resources used during the recording.
  155035. */
  155036. dispose(): void;
  155037. private _handleDataAvailable;
  155038. private _handleError;
  155039. private _handleStop;
  155040. }
  155041. }
  155042. declare module BABYLON {
  155043. /**
  155044. * Class containing a set of static utilities functions for screenshots
  155045. */
  155046. export class ScreenshotTools {
  155047. /**
  155048. * Captures a screenshot of the current rendering
  155049. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155050. * @param engine defines the rendering engine
  155051. * @param camera defines the source camera
  155052. * @param size This parameter can be set to a single number or to an object with the
  155053. * following (optional) properties: precision, width, height. If a single number is passed,
  155054. * it will be used for both width and height. If an object is passed, the screenshot size
  155055. * will be derived from the parameters. The precision property is a multiplier allowing
  155056. * rendering at a higher or lower resolution
  155057. * @param successCallback defines the callback receives a single parameter which contains the
  155058. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155059. * src parameter of an <img> to display it
  155060. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155061. * Check your browser for supported MIME types
  155062. */
  155063. static CreateScreenshot(engine: Engine, camera: Camera, size: IScreenshotSize | number, successCallback?: (data: string) => void, mimeType?: string): void;
  155064. /**
  155065. * Captures a screenshot of the current rendering
  155066. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155067. * @param engine defines the rendering engine
  155068. * @param camera defines the source camera
  155069. * @param size This parameter can be set to a single number or to an object with the
  155070. * following (optional) properties: precision, width, height. If a single number is passed,
  155071. * it will be used for both width and height. If an object is passed, the screenshot size
  155072. * will be derived from the parameters. The precision property is a multiplier allowing
  155073. * rendering at a higher or lower resolution
  155074. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  155075. * Check your browser for supported MIME types
  155076. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155077. * to the src parameter of an <img> to display it
  155078. */
  155079. static CreateScreenshotAsync(engine: Engine, camera: Camera, size: any, mimeType?: string): Promise<string>;
  155080. /**
  155081. * Generates an image screenshot from the specified camera.
  155082. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155083. * @param engine The engine to use for rendering
  155084. * @param camera The camera to use for rendering
  155085. * @param size This parameter can be set to a single number or to an object with the
  155086. * following (optional) properties: precision, width, height. If a single number is passed,
  155087. * it will be used for both width and height. If an object is passed, the screenshot size
  155088. * will be derived from the parameters. The precision property is a multiplier allowing
  155089. * rendering at a higher or lower resolution
  155090. * @param successCallback The callback receives a single parameter which contains the
  155091. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  155092. * src parameter of an <img> to display it
  155093. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155094. * Check your browser for supported MIME types
  155095. * @param samples Texture samples (default: 1)
  155096. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155097. * @param fileName A name for for the downloaded file.
  155098. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155099. * @param enableStencilBuffer Whether the stencil buffer should be enabled or not (default: false)
  155100. */
  155101. 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;
  155102. /**
  155103. * Generates an image screenshot from the specified camera.
  155104. * @see https://doc.babylonjs.com/how_to/render_scene_on_a_png
  155105. * @param engine The engine to use for rendering
  155106. * @param camera The camera to use for rendering
  155107. * @param size This parameter can be set to a single number or to an object with the
  155108. * following (optional) properties: precision, width, height. If a single number is passed,
  155109. * it will be used for both width and height. If an object is passed, the screenshot size
  155110. * will be derived from the parameters. The precision property is a multiplier allowing
  155111. * rendering at a higher or lower resolution
  155112. * @param mimeType The MIME type of the screenshot image (default: image/png).
  155113. * Check your browser for supported MIME types
  155114. * @param samples Texture samples (default: 1)
  155115. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  155116. * @param fileName A name for for the downloaded file.
  155117. * @param renderSprites Whether the sprites should be rendered or not (default: false)
  155118. * @returns screenshot as a string of base64-encoded characters. This string can be assigned
  155119. * to the src parameter of an <img> to display it
  155120. */
  155121. static CreateScreenshotUsingRenderTargetAsync(engine: Engine, camera: Camera, size: any, mimeType?: string, samples?: number, antialiasing?: boolean, fileName?: string, renderSprites?: boolean): Promise<string>;
  155122. /**
  155123. * Gets height and width for screenshot size
  155124. * @private
  155125. */
  155126. private static _getScreenshotSize;
  155127. }
  155128. }
  155129. declare module BABYLON {
  155130. /**
  155131. * Interface for a data buffer
  155132. */
  155133. export interface IDataBuffer {
  155134. /**
  155135. * Reads bytes from the data buffer.
  155136. * @param byteOffset The byte offset to read
  155137. * @param byteLength The byte length to read
  155138. * @returns A promise that resolves when the bytes are read
  155139. */
  155140. readAsync(byteOffset: number, byteLength: number): Promise<ArrayBufferView>;
  155141. /**
  155142. * The byte length of the buffer.
  155143. */
  155144. readonly byteLength: number;
  155145. }
  155146. /**
  155147. * Utility class for reading from a data buffer
  155148. */
  155149. export class DataReader {
  155150. /**
  155151. * The data buffer associated with this data reader.
  155152. */
  155153. readonly buffer: IDataBuffer;
  155154. /**
  155155. * The current byte offset from the beginning of the data buffer.
  155156. */
  155157. byteOffset: number;
  155158. private _dataView;
  155159. private _dataByteOffset;
  155160. /**
  155161. * Constructor
  155162. * @param buffer The buffer to read
  155163. */
  155164. constructor(buffer: IDataBuffer);
  155165. /**
  155166. * Loads the given byte length.
  155167. * @param byteLength The byte length to load
  155168. * @returns A promise that resolves when the load is complete
  155169. */
  155170. loadAsync(byteLength: number): Promise<void>;
  155171. /**
  155172. * Read a unsigned 32-bit integer from the currently loaded data range.
  155173. * @returns The 32-bit integer read
  155174. */
  155175. readUint32(): number;
  155176. /**
  155177. * Read a byte array from the currently loaded data range.
  155178. * @param byteLength The byte length to read
  155179. * @returns The byte array read
  155180. */
  155181. readUint8Array(byteLength: number): Uint8Array;
  155182. /**
  155183. * Read a string from the currently loaded data range.
  155184. * @param byteLength The byte length to read
  155185. * @returns The string read
  155186. */
  155187. readString(byteLength: number): string;
  155188. /**
  155189. * Skips the given byte length the currently loaded data range.
  155190. * @param byteLength The byte length to skip
  155191. */
  155192. skipBytes(byteLength: number): void;
  155193. }
  155194. }
  155195. declare module BABYLON {
  155196. /**
  155197. * Class for storing data to local storage if available or in-memory storage otherwise
  155198. */
  155199. export class DataStorage {
  155200. private static _Storage;
  155201. private static _GetStorage;
  155202. /**
  155203. * Reads a string from the data storage
  155204. * @param key The key to read
  155205. * @param defaultValue The value if the key doesn't exist
  155206. * @returns The string value
  155207. */
  155208. static ReadString(key: string, defaultValue: string): string;
  155209. /**
  155210. * Writes a string to the data storage
  155211. * @param key The key to write
  155212. * @param value The value to write
  155213. */
  155214. static WriteString(key: string, value: string): void;
  155215. /**
  155216. * Reads a boolean from the data storage
  155217. * @param key The key to read
  155218. * @param defaultValue The value if the key doesn't exist
  155219. * @returns The boolean value
  155220. */
  155221. static ReadBoolean(key: string, defaultValue: boolean): boolean;
  155222. /**
  155223. * Writes a boolean to the data storage
  155224. * @param key The key to write
  155225. * @param value The value to write
  155226. */
  155227. static WriteBoolean(key: string, value: boolean): void;
  155228. /**
  155229. * Reads a number from the data storage
  155230. * @param key The key to read
  155231. * @param defaultValue The value if the key doesn't exist
  155232. * @returns The number value
  155233. */
  155234. static ReadNumber(key: string, defaultValue: number): number;
  155235. /**
  155236. * Writes a number to the data storage
  155237. * @param key The key to write
  155238. * @param value The value to write
  155239. */
  155240. static WriteNumber(key: string, value: number): void;
  155241. }
  155242. }
  155243. declare module BABYLON {
  155244. /**
  155245. * Class used to record delta files between 2 scene states
  155246. */
  155247. export class SceneRecorder {
  155248. private _trackedScene;
  155249. private _savedJSON;
  155250. /**
  155251. * Track a given scene. This means the current scene state will be considered the original state
  155252. * @param scene defines the scene to track
  155253. */
  155254. track(scene: Scene): void;
  155255. /**
  155256. * Get the delta between current state and original state
  155257. * @returns a string containing the delta
  155258. */
  155259. getDelta(): any;
  155260. private _compareArray;
  155261. private _compareObjects;
  155262. private _compareCollections;
  155263. private static GetShadowGeneratorById;
  155264. /**
  155265. * Apply a given delta to a given scene
  155266. * @param deltaJSON defines the JSON containing the delta
  155267. * @param scene defines the scene to apply the delta to
  155268. */
  155269. static ApplyDelta(deltaJSON: any | string, scene: Scene): void;
  155270. private static _ApplyPropertiesToEntity;
  155271. private static _ApplyDeltaForEntity;
  155272. }
  155273. }
  155274. declare module BABYLON {
  155275. /**
  155276. * A 3D trajectory consisting of an order list of vectors describing a
  155277. * path of motion through 3D space.
  155278. */
  155279. export class Trajectory {
  155280. private _points;
  155281. private readonly _segmentLength;
  155282. /**
  155283. * Serialize to JSON.
  155284. * @returns serialized JSON string
  155285. */
  155286. serialize(): string;
  155287. /**
  155288. * Deserialize from JSON.
  155289. * @param json serialized JSON string
  155290. * @returns deserialized Trajectory
  155291. */
  155292. static Deserialize(json: string): Trajectory;
  155293. /**
  155294. * Create a new empty Trajectory.
  155295. * @param segmentLength radius of discretization for Trajectory points
  155296. */
  155297. constructor(segmentLength?: number);
  155298. /**
  155299. * Get the length of the Trajectory.
  155300. * @returns length of the Trajectory
  155301. */
  155302. getLength(): number;
  155303. /**
  155304. * Append a new point to the Trajectory.
  155305. * NOTE: This implementation has many allocations.
  155306. * @param point point to append to the Trajectory
  155307. */
  155308. add(point: DeepImmutable<Vector3>): void;
  155309. /**
  155310. * Create a new Trajectory with a segment length chosen to make it
  155311. * probable that the new Trajectory will have a specified number of
  155312. * segments. This operation is imprecise.
  155313. * @param targetResolution number of segments desired
  155314. * @returns new Trajectory with approximately the requested number of segments
  155315. */
  155316. resampleAtTargetResolution(targetResolution: number): Trajectory;
  155317. /**
  155318. * Convert Trajectory segments into tokenized representation. This
  155319. * representation is an array of numbers where each nth number is the
  155320. * index of the token which is most similar to the nth segment of the
  155321. * Trajectory.
  155322. * @param tokens list of vectors which serve as discrete tokens
  155323. * @returns list of indices of most similar token per segment
  155324. */
  155325. tokenize(tokens: DeepImmutable<Vector3[]>): number[];
  155326. private static _forwardDir;
  155327. private static _inverseFromVec;
  155328. private static _upDir;
  155329. private static _fromToVec;
  155330. private static _lookMatrix;
  155331. /**
  155332. * Transform the rotation (i.e., direction) of a segment to isolate
  155333. * the relative transformation represented by the segment. This operation
  155334. * may or may not succeed due to singularities in the equations that define
  155335. * motion relativity in this context.
  155336. * @param priorVec the origin of the prior segment
  155337. * @param fromVec the origin of the current segment
  155338. * @param toVec the destination of the current segment
  155339. * @param result reference to output variable
  155340. * @returns whether or not transformation was successful
  155341. */
  155342. private static _transformSegmentDirToRef;
  155343. private static _bestMatch;
  155344. private static _score;
  155345. private static _bestScore;
  155346. /**
  155347. * Determine which token vector is most similar to the
  155348. * segment vector.
  155349. * @param segment segment vector
  155350. * @param tokens token vector list
  155351. * @returns index of the most similar token to the segment
  155352. */
  155353. private static _tokenizeSegment;
  155354. }
  155355. /**
  155356. * Class representing a set of known, named trajectories to which Trajectories can be
  155357. * added and using which Trajectories can be recognized.
  155358. */
  155359. export class TrajectoryClassifier {
  155360. private _maximumAllowableMatchCost;
  155361. private _vector3Alphabet;
  155362. private _levenshteinAlphabet;
  155363. private _nameToDescribedTrajectory;
  155364. /**
  155365. * Serialize to JSON.
  155366. * @returns JSON serialization
  155367. */
  155368. serialize(): string;
  155369. /**
  155370. * Deserialize from JSON.
  155371. * @param json JSON serialization
  155372. * @returns deserialized TrajectorySet
  155373. */
  155374. static Deserialize(json: string): TrajectoryClassifier;
  155375. /**
  155376. * Initialize a new empty TrajectorySet with auto-generated Alphabets.
  155377. * VERY naive, need to be generating these things from known
  155378. * sets. Better version later, probably eliminating this one.
  155379. * @returns auto-generated TrajectorySet
  155380. */
  155381. static Generate(): TrajectoryClassifier;
  155382. private constructor();
  155383. /**
  155384. * Add a new Trajectory to the set with a given name.
  155385. * @param trajectory new Trajectory to be added
  155386. * @param classification name to which to add the Trajectory
  155387. */
  155388. addTrajectoryToClassification(trajectory: Trajectory, classification: string): void;
  155389. /**
  155390. * Remove a known named trajectory and all Trajectories associated with it.
  155391. * @param classification name to remove
  155392. * @returns whether anything was removed
  155393. */
  155394. deleteClassification(classification: string): boolean;
  155395. /**
  155396. * Attempt to recognize a Trajectory from among all the classifications
  155397. * already known to the classifier.
  155398. * @param trajectory Trajectory to be recognized
  155399. * @returns classification of Trajectory if recognized, null otherwise
  155400. */
  155401. classifyTrajectory(trajectory: Trajectory): Nullable<string>;
  155402. }
  155403. }
  155404. declare module BABYLON {
  155405. /**
  155406. * An interface for all Hit test features
  155407. */
  155408. export interface IWebXRHitTestFeature<T extends IWebXRLegacyHitResult> extends IWebXRFeature {
  155409. /**
  155410. * Triggered when new babylon (transformed) hit test results are available
  155411. */
  155412. onHitTestResultObservable: Observable<T[]>;
  155413. }
  155414. /**
  155415. * Options used for hit testing
  155416. */
  155417. export interface IWebXRLegacyHitTestOptions {
  155418. /**
  155419. * Only test when user interacted with the scene. Default - hit test every frame
  155420. */
  155421. testOnPointerDownOnly?: boolean;
  155422. /**
  155423. * The node to use to transform the local results to world coordinates
  155424. */
  155425. worldParentNode?: TransformNode;
  155426. }
  155427. /**
  155428. * Interface defining the babylon result of raycasting/hit-test
  155429. */
  155430. export interface IWebXRLegacyHitResult {
  155431. /**
  155432. * Transformation matrix that can be applied to a node that will put it in the hit point location
  155433. */
  155434. transformationMatrix: Matrix;
  155435. /**
  155436. * The native hit test result
  155437. */
  155438. xrHitResult: XRHitResult | XRHitTestResult;
  155439. }
  155440. /**
  155441. * The currently-working hit-test module.
  155442. * Hit test (or Ray-casting) is used to interact with the real world.
  155443. * For further information read here - https://github.com/immersive-web/hit-test
  155444. */
  155445. export class WebXRHitTestLegacy extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRLegacyHitResult> {
  155446. /**
  155447. * options to use when constructing this feature
  155448. */
  155449. readonly options: IWebXRLegacyHitTestOptions;
  155450. private _direction;
  155451. private _mat;
  155452. private _onSelectEnabled;
  155453. private _origin;
  155454. /**
  155455. * The module's name
  155456. */
  155457. static readonly Name: string;
  155458. /**
  155459. * The (Babylon) version of this module.
  155460. * This is an integer representing the implementation version.
  155461. * This number does not correspond to the WebXR specs version
  155462. */
  155463. static readonly Version: number;
  155464. /**
  155465. * Populated with the last native XR Hit Results
  155466. */
  155467. lastNativeXRHitResults: XRHitResult[];
  155468. /**
  155469. * Triggered when new babylon (transformed) hit test results are available
  155470. */
  155471. onHitTestResultObservable: Observable<IWebXRLegacyHitResult[]>;
  155472. /**
  155473. * Creates a new instance of the (legacy version) hit test feature
  155474. * @param _xrSessionManager an instance of WebXRSessionManager
  155475. * @param options options to use when constructing this feature
  155476. */
  155477. constructor(_xrSessionManager: WebXRSessionManager,
  155478. /**
  155479. * options to use when constructing this feature
  155480. */
  155481. options?: IWebXRLegacyHitTestOptions);
  155482. /**
  155483. * execute a hit test with an XR Ray
  155484. *
  155485. * @param xrSession a native xrSession that will execute this hit test
  155486. * @param xrRay the ray (position and direction) to use for ray-casting
  155487. * @param referenceSpace native XR reference space to use for the hit-test
  155488. * @param filter filter function that will filter the results
  155489. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155490. */
  155491. static XRHitTestWithRay(xrSession: XRSession, xrRay: XRRay, referenceSpace: XRReferenceSpace, filter?: (result: XRHitResult) => boolean): Promise<XRHitResult[]>;
  155492. /**
  155493. * Execute a hit test on the current running session using a select event returned from a transient input (such as touch)
  155494. * @param event the (select) event to use to select with
  155495. * @param referenceSpace the reference space to use for this hit test
  155496. * @returns a promise that resolves with an array of native XR hit result in xr coordinates system
  155497. */
  155498. static XRHitTestWithSelectEvent(event: XRInputSourceEvent, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  155499. /**
  155500. * attach this feature
  155501. * Will usually be called by the features manager
  155502. *
  155503. * @returns true if successful.
  155504. */
  155505. attach(): boolean;
  155506. /**
  155507. * detach this feature.
  155508. * Will usually be called by the features manager
  155509. *
  155510. * @returns true if successful.
  155511. */
  155512. detach(): boolean;
  155513. /**
  155514. * Dispose this feature and all of the resources attached
  155515. */
  155516. dispose(): void;
  155517. protected _onXRFrame(frame: XRFrame): void;
  155518. private _onHitTestResults;
  155519. private _onSelect;
  155520. }
  155521. }
  155522. declare module BABYLON {
  155523. /**
  155524. * Options used for hit testing (version 2)
  155525. */
  155526. export interface IWebXRHitTestOptions extends IWebXRLegacyHitTestOptions {
  155527. /**
  155528. * Do not create a permanent hit test. Will usually be used when only
  155529. * transient inputs are needed.
  155530. */
  155531. disablePermanentHitTest?: boolean;
  155532. /**
  155533. * Enable transient (for example touch-based) hit test inspections
  155534. */
  155535. enableTransientHitTest?: boolean;
  155536. /**
  155537. * Offset ray for the permanent hit test
  155538. */
  155539. offsetRay?: Vector3;
  155540. /**
  155541. * Offset ray for the transient hit test
  155542. */
  155543. transientOffsetRay?: Vector3;
  155544. /**
  155545. * Instead of using viewer space for hit tests, use the reference space defined in the session manager
  155546. */
  155547. useReferenceSpace?: boolean;
  155548. /**
  155549. * Override the default entity type(s) of the hit-test result
  155550. */
  155551. entityTypes?: XRHitTestTrackableType[];
  155552. }
  155553. /**
  155554. * Interface defining the babylon result of hit-test
  155555. */
  155556. export interface IWebXRHitResult extends IWebXRLegacyHitResult {
  155557. /**
  155558. * The input source that generated this hit test (if transient)
  155559. */
  155560. inputSource?: XRInputSource;
  155561. /**
  155562. * Is this a transient hit test
  155563. */
  155564. isTransient?: boolean;
  155565. /**
  155566. * Position of the hit test result
  155567. */
  155568. position: Vector3;
  155569. /**
  155570. * Rotation of the hit test result
  155571. */
  155572. rotationQuaternion: Quaternion;
  155573. /**
  155574. * The native hit test result
  155575. */
  155576. xrHitResult: XRHitTestResult;
  155577. }
  155578. /**
  155579. * The currently-working hit-test module.
  155580. * Hit test (or Ray-casting) is used to interact with the real world.
  155581. * For further information read here - https://github.com/immersive-web/hit-test
  155582. *
  155583. * Tested on chrome (mobile) 80.
  155584. */
  155585. export class WebXRHitTest extends WebXRAbstractFeature implements IWebXRHitTestFeature<IWebXRHitResult> {
  155586. /**
  155587. * options to use when constructing this feature
  155588. */
  155589. readonly options: IWebXRHitTestOptions;
  155590. private _tmpMat;
  155591. private _tmpPos;
  155592. private _tmpQuat;
  155593. private _transientXrHitTestSource;
  155594. private _xrHitTestSource;
  155595. private initHitTestSource;
  155596. /**
  155597. * The module's name
  155598. */
  155599. static readonly Name: string;
  155600. /**
  155601. * The (Babylon) version of this module.
  155602. * This is an integer representing the implementation version.
  155603. * This number does not correspond to the WebXR specs version
  155604. */
  155605. static readonly Version: number;
  155606. /**
  155607. * When set to true, each hit test will have its own position/rotation objects
  155608. * When set to false, position and rotation objects will be reused for each hit test. It is expected that
  155609. * the developers will clone them or copy them as they see fit.
  155610. */
  155611. autoCloneTransformation: boolean;
  155612. /**
  155613. * Triggered when new babylon (transformed) hit test results are available
  155614. * Note - this will be called when results come back from the device. It can be an empty array!!
  155615. */
  155616. onHitTestResultObservable: Observable<IWebXRHitResult[]>;
  155617. /**
  155618. * Use this to temporarily pause hit test checks.
  155619. */
  155620. paused: boolean;
  155621. /**
  155622. * Creates a new instance of the hit test feature
  155623. * @param _xrSessionManager an instance of WebXRSessionManager
  155624. * @param options options to use when constructing this feature
  155625. */
  155626. constructor(_xrSessionManager: WebXRSessionManager,
  155627. /**
  155628. * options to use when constructing this feature
  155629. */
  155630. options?: IWebXRHitTestOptions);
  155631. /**
  155632. * attach this feature
  155633. * Will usually be called by the features manager
  155634. *
  155635. * @returns true if successful.
  155636. */
  155637. attach(): boolean;
  155638. /**
  155639. * detach this feature.
  155640. * Will usually be called by the features manager
  155641. *
  155642. * @returns true if successful.
  155643. */
  155644. detach(): boolean;
  155645. /**
  155646. * Dispose this feature and all of the resources attached
  155647. */
  155648. dispose(): void;
  155649. protected _onXRFrame(frame: XRFrame): void;
  155650. private _processWebXRHitTestResult;
  155651. }
  155652. }
  155653. declare module BABYLON {
  155654. /**
  155655. * Configuration options of the anchor system
  155656. */
  155657. export interface IWebXRAnchorSystemOptions {
  155658. /**
  155659. * a node that will be used to convert local to world coordinates
  155660. */
  155661. worldParentNode?: TransformNode;
  155662. /**
  155663. * If set to true a reference of the created anchors will be kept until the next session starts
  155664. * If not defined, anchors will be removed from the array when the feature is detached or the session ended.
  155665. */
  155666. doNotRemoveAnchorsOnSessionEnded?: boolean;
  155667. }
  155668. /**
  155669. * A babylon container for an XR Anchor
  155670. */
  155671. export interface IWebXRAnchor {
  155672. /**
  155673. * A babylon-assigned ID for this anchor
  155674. */
  155675. id: number;
  155676. /**
  155677. * Transformation matrix to apply to an object attached to this anchor
  155678. */
  155679. transformationMatrix: Matrix;
  155680. /**
  155681. * The native anchor object
  155682. */
  155683. xrAnchor: XRAnchor;
  155684. /**
  155685. * if defined, this object will be constantly updated by the anchor's position and rotation
  155686. */
  155687. attachedNode?: TransformNode;
  155688. }
  155689. /**
  155690. * An implementation of the anchor system for WebXR.
  155691. * For further information see https://github.com/immersive-web/anchors/
  155692. */
  155693. export class WebXRAnchorSystem extends WebXRAbstractFeature {
  155694. private _options;
  155695. private _lastFrameDetected;
  155696. private _trackedAnchors;
  155697. private _referenceSpaceForFrameAnchors;
  155698. private _futureAnchors;
  155699. /**
  155700. * The module's name
  155701. */
  155702. static readonly Name: string;
  155703. /**
  155704. * The (Babylon) version of this module.
  155705. * This is an integer representing the implementation version.
  155706. * This number does not correspond to the WebXR specs version
  155707. */
  155708. static readonly Version: number;
  155709. /**
  155710. * Observers registered here will be executed when a new anchor was added to the session
  155711. */
  155712. onAnchorAddedObservable: Observable<IWebXRAnchor>;
  155713. /**
  155714. * Observers registered here will be executed when an anchor was removed from the session
  155715. */
  155716. onAnchorRemovedObservable: Observable<IWebXRAnchor>;
  155717. /**
  155718. * Observers registered here will be executed when an existing anchor updates
  155719. * This can execute N times every frame
  155720. */
  155721. onAnchorUpdatedObservable: Observable<IWebXRAnchor>;
  155722. /**
  155723. * Set the reference space to use for anchor creation, when not using a hit test.
  155724. * Will default to the session's reference space if not defined
  155725. */
  155726. set referenceSpaceForFrameAnchors(referenceSpace: XRReferenceSpace);
  155727. /**
  155728. * constructs a new anchor system
  155729. * @param _xrSessionManager an instance of WebXRSessionManager
  155730. * @param _options configuration object for this feature
  155731. */
  155732. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRAnchorSystemOptions);
  155733. private _tmpVector;
  155734. private _tmpQuaternion;
  155735. private _populateTmpTransformation;
  155736. /**
  155737. * Create a new anchor point using a hit test result at a specific point in the scene
  155738. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155739. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155740. *
  155741. * @param hitTestResult The hit test result to use for this anchor creation
  155742. * @param position an optional position offset for this anchor
  155743. * @param rotationQuaternion an optional rotation offset for this anchor
  155744. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155745. */
  155746. addAnchorPointUsingHitTestResultAsync(hitTestResult: IWebXRHitResult, position?: Vector3, rotationQuaternion?: Quaternion): Promise<XRAnchor>;
  155747. /**
  155748. * Add a new anchor at a specific position and rotation
  155749. * This function will add a new anchor per default in the next available frame. Unless forced, the createAnchor function
  155750. * will be called in the next xrFrame loop to make sure that the anchor can be created correctly.
  155751. * An anchor is tracked only after it is added to the trackerAnchors in xrFrame. The promise returned here does not yet guaranty that.
  155752. * Use onAnchorAddedObservable to get newly added anchors if you require tracking guaranty.
  155753. *
  155754. * @param position the position in which to add an anchor
  155755. * @param rotationQuaternion an optional rotation for the anchor transformation
  155756. * @param forceCreateInCurrentFrame force the creation of this anchor in the current frame. Must be called inside xrFrame loop!
  155757. * @returns A promise that fulfills when the XR anchor was registered in the system (but not necessarily added to the tracked anchors)
  155758. */
  155759. addAnchorAtPositionAndRotationAsync(position: Vector3, rotationQuaternion?: Quaternion, forceCreateInCurrentFrame?: boolean): Promise<XRAnchor>;
  155760. /**
  155761. * detach this feature.
  155762. * Will usually be called by the features manager
  155763. *
  155764. * @returns true if successful.
  155765. */
  155766. detach(): boolean;
  155767. /**
  155768. * Dispose this feature and all of the resources attached
  155769. */
  155770. dispose(): void;
  155771. protected _onXRFrame(frame: XRFrame): void;
  155772. /**
  155773. * avoiding using Array.find for global support.
  155774. * @param xrAnchor the plane to find in the array
  155775. */
  155776. private _findIndexInAnchorArray;
  155777. private _updateAnchorWithXRFrame;
  155778. private _createAnchorAtTransformation;
  155779. }
  155780. }
  155781. declare module BABYLON {
  155782. /**
  155783. * Options used in the plane detector module
  155784. */
  155785. export interface IWebXRPlaneDetectorOptions {
  155786. /**
  155787. * The node to use to transform the local results to world coordinates
  155788. */
  155789. worldParentNode?: TransformNode;
  155790. /**
  155791. * If set to true a reference of the created planes will be kept until the next session starts
  155792. * If not defined, planes will be removed from the array when the feature is detached or the session ended.
  155793. */
  155794. doNotRemovePlanesOnSessionEnded?: boolean;
  155795. }
  155796. /**
  155797. * A babylon interface for a WebXR plane.
  155798. * A Plane is actually a polygon, built from N points in space
  155799. *
  155800. * Supported in chrome 79, not supported in canary 81 ATM
  155801. */
  155802. export interface IWebXRPlane {
  155803. /**
  155804. * a babylon-assigned ID for this polygon
  155805. */
  155806. id: number;
  155807. /**
  155808. * an array of vector3 points in babylon space. right/left hand system is taken into account.
  155809. */
  155810. polygonDefinition: Array<Vector3>;
  155811. /**
  155812. * A transformation matrix to apply on the mesh that will be built using the polygonDefinition
  155813. * Local vs. World are decided if worldParentNode was provided or not in the options when constructing the module
  155814. */
  155815. transformationMatrix: Matrix;
  155816. /**
  155817. * the native xr-plane object
  155818. */
  155819. xrPlane: XRPlane;
  155820. }
  155821. /**
  155822. * The plane detector is used to detect planes in the real world when in AR
  155823. * For more information see https://github.com/immersive-web/real-world-geometry/
  155824. */
  155825. export class WebXRPlaneDetector extends WebXRAbstractFeature {
  155826. private _options;
  155827. private _detectedPlanes;
  155828. private _enabled;
  155829. private _lastFrameDetected;
  155830. /**
  155831. * The module's name
  155832. */
  155833. static readonly Name: string;
  155834. /**
  155835. * The (Babylon) version of this module.
  155836. * This is an integer representing the implementation version.
  155837. * This number does not correspond to the WebXR specs version
  155838. */
  155839. static readonly Version: number;
  155840. /**
  155841. * Observers registered here will be executed when a new plane was added to the session
  155842. */
  155843. onPlaneAddedObservable: Observable<IWebXRPlane>;
  155844. /**
  155845. * Observers registered here will be executed when a plane is no longer detected in the session
  155846. */
  155847. onPlaneRemovedObservable: Observable<IWebXRPlane>;
  155848. /**
  155849. * Observers registered here will be executed when an existing plane updates (for example - expanded)
  155850. * This can execute N times every frame
  155851. */
  155852. onPlaneUpdatedObservable: Observable<IWebXRPlane>;
  155853. /**
  155854. * construct a new Plane Detector
  155855. * @param _xrSessionManager an instance of xr Session manager
  155856. * @param _options configuration to use when constructing this feature
  155857. */
  155858. constructor(_xrSessionManager: WebXRSessionManager, _options?: IWebXRPlaneDetectorOptions);
  155859. /**
  155860. * detach this feature.
  155861. * Will usually be called by the features manager
  155862. *
  155863. * @returns true if successful.
  155864. */
  155865. detach(): boolean;
  155866. /**
  155867. * Dispose this feature and all of the resources attached
  155868. */
  155869. dispose(): void;
  155870. protected _onXRFrame(frame: XRFrame): void;
  155871. private _init;
  155872. private _updatePlaneWithXRPlane;
  155873. /**
  155874. * avoiding using Array.find for global support.
  155875. * @param xrPlane the plane to find in the array
  155876. */
  155877. private findIndexInPlaneArray;
  155878. }
  155879. }
  155880. declare module BABYLON {
  155881. /**
  155882. * Options interface for the background remover plugin
  155883. */
  155884. export interface IWebXRBackgroundRemoverOptions {
  155885. /**
  155886. * Further background meshes to disable when entering AR
  155887. */
  155888. backgroundMeshes?: AbstractMesh[];
  155889. /**
  155890. * flags to configure the removal of the environment helper.
  155891. * If not set, the entire background will be removed. If set, flags should be set as well.
  155892. */
  155893. environmentHelperRemovalFlags?: {
  155894. /**
  155895. * Should the skybox be removed (default false)
  155896. */
  155897. skyBox?: boolean;
  155898. /**
  155899. * Should the ground be removed (default false)
  155900. */
  155901. ground?: boolean;
  155902. };
  155903. /**
  155904. * don't disable the environment helper
  155905. */
  155906. ignoreEnvironmentHelper?: boolean;
  155907. }
  155908. /**
  155909. * A module that will automatically disable background meshes when entering AR and will enable them when leaving AR.
  155910. */
  155911. export class WebXRBackgroundRemover extends WebXRAbstractFeature {
  155912. /**
  155913. * read-only options to be used in this module
  155914. */
  155915. readonly options: IWebXRBackgroundRemoverOptions;
  155916. /**
  155917. * The module's name
  155918. */
  155919. static readonly Name: string;
  155920. /**
  155921. * The (Babylon) version of this module.
  155922. * This is an integer representing the implementation version.
  155923. * This number does not correspond to the WebXR specs version
  155924. */
  155925. static readonly Version: number;
  155926. /**
  155927. * registered observers will be triggered when the background state changes
  155928. */
  155929. onBackgroundStateChangedObservable: Observable<boolean>;
  155930. /**
  155931. * constructs a new background remover module
  155932. * @param _xrSessionManager the session manager for this module
  155933. * @param options read-only options to be used in this module
  155934. */
  155935. constructor(_xrSessionManager: WebXRSessionManager,
  155936. /**
  155937. * read-only options to be used in this module
  155938. */
  155939. options?: IWebXRBackgroundRemoverOptions);
  155940. /**
  155941. * attach this feature
  155942. * Will usually be called by the features manager
  155943. *
  155944. * @returns true if successful.
  155945. */
  155946. attach(): boolean;
  155947. /**
  155948. * detach this feature.
  155949. * Will usually be called by the features manager
  155950. *
  155951. * @returns true if successful.
  155952. */
  155953. detach(): boolean;
  155954. /**
  155955. * Dispose this feature and all of the resources attached
  155956. */
  155957. dispose(): void;
  155958. protected _onXRFrame(_xrFrame: XRFrame): void;
  155959. private _setBackgroundState;
  155960. }
  155961. }
  155962. declare module BABYLON {
  155963. /**
  155964. * Options for the controller physics feature
  155965. */
  155966. export class IWebXRControllerPhysicsOptions {
  155967. /**
  155968. * Should the headset get its own impostor
  155969. */
  155970. enableHeadsetImpostor?: boolean;
  155971. /**
  155972. * Optional parameters for the headset impostor
  155973. */
  155974. headsetImpostorParams?: {
  155975. /**
  155976. * The type of impostor to create. Default is sphere
  155977. */
  155978. impostorType: number;
  155979. /**
  155980. * the size of the impostor. Defaults to 10cm
  155981. */
  155982. impostorSize?: number | {
  155983. width: number;
  155984. height: number;
  155985. depth: number;
  155986. };
  155987. /**
  155988. * Friction definitions
  155989. */
  155990. friction?: number;
  155991. /**
  155992. * Restitution
  155993. */
  155994. restitution?: number;
  155995. };
  155996. /**
  155997. * The physics properties of the future impostors
  155998. */
  155999. physicsProperties?: {
  156000. /**
  156001. * If set to true, a mesh impostor will be created when the controller mesh was loaded
  156002. * Note that this requires a physics engine that supports mesh impostors!
  156003. */
  156004. useControllerMesh?: boolean;
  156005. /**
  156006. * The type of impostor to create. Default is sphere
  156007. */
  156008. impostorType?: number;
  156009. /**
  156010. * the size of the impostor. Defaults to 10cm
  156011. */
  156012. impostorSize?: number | {
  156013. width: number;
  156014. height: number;
  156015. depth: number;
  156016. };
  156017. /**
  156018. * Friction definitions
  156019. */
  156020. friction?: number;
  156021. /**
  156022. * Restitution
  156023. */
  156024. restitution?: number;
  156025. };
  156026. /**
  156027. * the xr input to use with this pointer selection
  156028. */
  156029. xrInput: WebXRInput;
  156030. }
  156031. /**
  156032. * Add physics impostor to your webxr controllers,
  156033. * including naive calculation of their linear and angular velocity
  156034. */
  156035. export class WebXRControllerPhysics extends WebXRAbstractFeature {
  156036. private readonly _options;
  156037. private _attachController;
  156038. private _controllers;
  156039. private _debugMode;
  156040. private _delta;
  156041. private _headsetImpostor?;
  156042. private _headsetMesh?;
  156043. private _lastTimestamp;
  156044. private _tmpQuaternion;
  156045. private _tmpVector;
  156046. /**
  156047. * The module's name
  156048. */
  156049. static readonly Name: string;
  156050. /**
  156051. * The (Babylon) version of this module.
  156052. * This is an integer representing the implementation version.
  156053. * This number does not correspond to the webxr specs version
  156054. */
  156055. static readonly Version: number;
  156056. /**
  156057. * Construct a new Controller Physics Feature
  156058. * @param _xrSessionManager the corresponding xr session manager
  156059. * @param _options options to create this feature with
  156060. */
  156061. constructor(_xrSessionManager: WebXRSessionManager, _options: IWebXRControllerPhysicsOptions);
  156062. /**
  156063. * @hidden
  156064. * enable debugging - will show console outputs and the impostor mesh
  156065. */
  156066. _enablePhysicsDebug(): void;
  156067. /**
  156068. * Manually add a controller (if no xrInput was provided or physics engine was not enabled)
  156069. * @param xrController the controller to add
  156070. */
  156071. addController(xrController: WebXRInputSource): void;
  156072. /**
  156073. * attach this feature
  156074. * Will usually be called by the features manager
  156075. *
  156076. * @returns true if successful.
  156077. */
  156078. attach(): boolean;
  156079. /**
  156080. * detach this feature.
  156081. * Will usually be called by the features manager
  156082. *
  156083. * @returns true if successful.
  156084. */
  156085. detach(): boolean;
  156086. /**
  156087. * Get the headset impostor, if enabled
  156088. * @returns the impostor
  156089. */
  156090. getHeadsetImpostor(): PhysicsImpostor | undefined;
  156091. /**
  156092. * Get the physics impostor of a specific controller.
  156093. * The impostor is not attached to a mesh because a mesh for each controller is not obligatory
  156094. * @param controller the controller or the controller id of which to get the impostor
  156095. * @returns the impostor or null
  156096. */
  156097. getImpostorForController(controller: WebXRInputSource | string): Nullable<PhysicsImpostor>;
  156098. /**
  156099. * Update the physics properties provided in the constructor
  156100. * @param newProperties the new properties object
  156101. */
  156102. setPhysicsProperties(newProperties: {
  156103. impostorType?: number;
  156104. impostorSize?: number | {
  156105. width: number;
  156106. height: number;
  156107. depth: number;
  156108. };
  156109. friction?: number;
  156110. restitution?: number;
  156111. }): void;
  156112. protected _onXRFrame(_xrFrame: any): void;
  156113. private _detachController;
  156114. }
  156115. }
  156116. declare module BABYLON {
  156117. /**
  156118. * A babylon interface for a "WebXR" feature point.
  156119. * Represents the position and confidence value of a given feature point.
  156120. */
  156121. export interface IWebXRFeaturePoint {
  156122. /**
  156123. * Represents the position of the feature point in world space.
  156124. */
  156125. position: Vector3;
  156126. /**
  156127. * Represents the confidence value of the feature point in world space. 0 being least confident, and 1 being most confident.
  156128. */
  156129. confidenceValue: number;
  156130. }
  156131. /**
  156132. * The feature point system is used to detect feature points from real world geometry.
  156133. * This feature is currently experimental and only supported on BabylonNative, and should not be used in the browser.
  156134. * The newly introduced API can be seen in webxr.nativeextensions.d.ts and described in FeaturePoints.md.
  156135. */
  156136. export class WebXRFeaturePointSystem extends WebXRAbstractFeature {
  156137. private _enabled;
  156138. private _featurePointCloud;
  156139. /**
  156140. * The module's name
  156141. */
  156142. static readonly Name: string;
  156143. /**
  156144. * The (Babylon) version of this module.
  156145. * This is an integer representing the implementation version.
  156146. * This number does not correspond to the WebXR specs version
  156147. */
  156148. static readonly Version: number;
  156149. /**
  156150. * Observers registered here will be executed whenever new feature points are added (on XRFrame while the session is tracking).
  156151. * Will notify the observers about which feature points have been added.
  156152. */
  156153. readonly onFeaturePointsAddedObservable: Observable<number[]>;
  156154. /**
  156155. * Observers registered here will be executed whenever a feature point has been updated (on XRFrame while the session is tracking).
  156156. * Will notify the observers about which feature points have been updated.
  156157. */
  156158. readonly onFeaturePointsUpdatedObservable: Observable<number[]>;
  156159. /**
  156160. * The current feature point cloud maintained across frames.
  156161. */
  156162. get featurePointCloud(): Array<IWebXRFeaturePoint>;
  156163. /**
  156164. * construct the feature point system
  156165. * @param _xrSessionManager an instance of xr Session manager
  156166. */
  156167. constructor(_xrSessionManager: WebXRSessionManager);
  156168. /**
  156169. * Detach this feature.
  156170. * Will usually be called by the features manager
  156171. *
  156172. * @returns true if successful.
  156173. */
  156174. detach(): boolean;
  156175. /**
  156176. * Dispose this feature and all of the resources attached
  156177. */
  156178. dispose(): void;
  156179. /**
  156180. * On receiving a new XR frame if this feature is attached notify observers new feature point data is available.
  156181. */
  156182. protected _onXRFrame(frame: XRFrame): void;
  156183. /**
  156184. * Initializes the feature. If the feature point feature is not available for this environment do not mark the feature as enabled.
  156185. */
  156186. private _init;
  156187. }
  156188. }
  156189. declare module BABYLON {
  156190. /**
  156191. * Configuration interface for the hand tracking feature
  156192. */
  156193. export interface IWebXRHandTrackingOptions {
  156194. /**
  156195. * The xrInput that will be used as source for new hands
  156196. */
  156197. xrInput: WebXRInput;
  156198. /**
  156199. * Configuration object for the joint meshes
  156200. */
  156201. jointMeshes?: {
  156202. /**
  156203. * Should the meshes created be invisible (defaults to false)
  156204. */
  156205. invisible?: boolean;
  156206. /**
  156207. * A source mesh to be used to create instances. Defaults to a sphere.
  156208. * This mesh will be the source for all other (25) meshes.
  156209. * It should have the general size of a single unit, as the instances will be scaled according to the provided radius
  156210. */
  156211. sourceMesh?: Mesh;
  156212. /**
  156213. * Should the source mesh stay visible. Defaults to false
  156214. */
  156215. keepOriginalVisible?: boolean;
  156216. /**
  156217. * Scale factor for all instances (defaults to 2)
  156218. */
  156219. scaleFactor?: number;
  156220. /**
  156221. * Should each instance have its own physics impostor
  156222. */
  156223. enablePhysics?: boolean;
  156224. /**
  156225. * If enabled, override default physics properties
  156226. */
  156227. physicsProps?: {
  156228. friction?: number;
  156229. restitution?: number;
  156230. impostorType?: number;
  156231. };
  156232. /**
  156233. * For future use - a single hand-mesh that will be updated according to the XRHand data provided
  156234. */
  156235. handMesh?: AbstractMesh;
  156236. };
  156237. }
  156238. /**
  156239. * Parts of the hands divided to writs and finger names
  156240. */
  156241. export const enum HandPart {
  156242. /**
  156243. * HandPart - Wrist
  156244. */
  156245. WRIST = "wrist",
  156246. /**
  156247. * HandPart - The THumb
  156248. */
  156249. THUMB = "thumb",
  156250. /**
  156251. * HandPart - Index finger
  156252. */
  156253. INDEX = "index",
  156254. /**
  156255. * HandPart - Middle finger
  156256. */
  156257. MIDDLE = "middle",
  156258. /**
  156259. * HandPart - Ring finger
  156260. */
  156261. RING = "ring",
  156262. /**
  156263. * HandPart - Little finger
  156264. */
  156265. LITTLE = "little"
  156266. }
  156267. /**
  156268. * Representing a single hand (with its corresponding native XRHand object)
  156269. */
  156270. export class WebXRHand implements IDisposable {
  156271. /** the controller to which the hand correlates */
  156272. readonly xrController: WebXRInputSource;
  156273. /** the meshes to be used to track the hand joints */
  156274. readonly trackedMeshes: AbstractMesh[];
  156275. /**
  156276. * Hand-parts definition (key is HandPart)
  156277. */
  156278. handPartsDefinition: {
  156279. [key: string]: number[];
  156280. };
  156281. /**
  156282. * Populate the HandPartsDefinition object.
  156283. * This is called as a side effect since certain browsers don't have XRHand defined.
  156284. */
  156285. private generateHandPartsDefinition;
  156286. /**
  156287. * Construct a new hand object
  156288. * @param xrController the controller to which the hand correlates
  156289. * @param trackedMeshes the meshes to be used to track the hand joints
  156290. */
  156291. constructor(
  156292. /** the controller to which the hand correlates */
  156293. xrController: WebXRInputSource,
  156294. /** the meshes to be used to track the hand joints */
  156295. trackedMeshes: AbstractMesh[]);
  156296. /**
  156297. * Update this hand from the latest xr frame
  156298. * @param xrFrame xrFrame to update from
  156299. * @param referenceSpace The current viewer reference space
  156300. * @param scaleFactor optional scale factor for the meshes
  156301. */
  156302. updateFromXRFrame(xrFrame: XRFrame, referenceSpace: XRReferenceSpace, scaleFactor?: number): void;
  156303. /**
  156304. * Get meshes of part of the hand
  156305. * @param part the part of hand to get
  156306. * @returns An array of meshes that correlate to the hand part requested
  156307. */
  156308. getHandPartMeshes(part: HandPart): AbstractMesh[];
  156309. /**
  156310. * Dispose this Hand object
  156311. */
  156312. dispose(): void;
  156313. }
  156314. /**
  156315. * WebXR Hand Joint tracking feature, available for selected browsers and devices
  156316. */
  156317. export class WebXRHandTracking extends WebXRAbstractFeature {
  156318. /**
  156319. * options to use when constructing this feature
  156320. */
  156321. readonly options: IWebXRHandTrackingOptions;
  156322. private static _idCounter;
  156323. /**
  156324. * The module's name
  156325. */
  156326. static readonly Name: string;
  156327. /**
  156328. * The (Babylon) version of this module.
  156329. * This is an integer representing the implementation version.
  156330. * This number does not correspond to the WebXR specs version
  156331. */
  156332. static readonly Version: number;
  156333. /**
  156334. * This observable will notify registered observers when a new hand object was added and initialized
  156335. */
  156336. onHandAddedObservable: Observable<WebXRHand>;
  156337. /**
  156338. * This observable will notify its observers right before the hand object is disposed
  156339. */
  156340. onHandRemovedObservable: Observable<WebXRHand>;
  156341. private _hands;
  156342. /**
  156343. * Creates a new instance of the hit test feature
  156344. * @param _xrSessionManager an instance of WebXRSessionManager
  156345. * @param options options to use when constructing this feature
  156346. */
  156347. constructor(_xrSessionManager: WebXRSessionManager,
  156348. /**
  156349. * options to use when constructing this feature
  156350. */
  156351. options: IWebXRHandTrackingOptions);
  156352. /**
  156353. * Check if the needed objects are defined.
  156354. * This does not mean that the feature is enabled, but that the objects needed are well defined.
  156355. */
  156356. isCompatible(): boolean;
  156357. /**
  156358. * attach this feature
  156359. * Will usually be called by the features manager
  156360. *
  156361. * @returns true if successful.
  156362. */
  156363. attach(): boolean;
  156364. /**
  156365. * detach this feature.
  156366. * Will usually be called by the features manager
  156367. *
  156368. * @returns true if successful.
  156369. */
  156370. detach(): boolean;
  156371. /**
  156372. * Dispose this feature and all of the resources attached
  156373. */
  156374. dispose(): void;
  156375. /**
  156376. * Get the hand object according to the controller id
  156377. * @param controllerId the controller id to which we want to get the hand
  156378. * @returns null if not found or the WebXRHand object if found
  156379. */
  156380. getHandByControllerId(controllerId: string): Nullable<WebXRHand>;
  156381. /**
  156382. * Get a hand object according to the requested handedness
  156383. * @param handedness the handedness to request
  156384. * @returns null if not found or the WebXRHand object if found
  156385. */
  156386. getHandByHandedness(handedness: XRHandedness): Nullable<WebXRHand>;
  156387. protected _onXRFrame(_xrFrame: XRFrame): void;
  156388. private _attachHand;
  156389. private _detachHand;
  156390. }
  156391. }
  156392. declare module BABYLON {
  156393. /**
  156394. * The motion controller class for all microsoft mixed reality controllers
  156395. */
  156396. export class WebXRMicrosoftMixedRealityController extends WebXRAbstractMotionController {
  156397. protected readonly _mapping: {
  156398. defaultButton: {
  156399. valueNodeName: string;
  156400. unpressedNodeName: string;
  156401. pressedNodeName: string;
  156402. };
  156403. defaultAxis: {
  156404. valueNodeName: string;
  156405. minNodeName: string;
  156406. maxNodeName: string;
  156407. };
  156408. buttons: {
  156409. "xr-standard-trigger": {
  156410. rootNodeName: string;
  156411. componentProperty: string;
  156412. states: string[];
  156413. };
  156414. "xr-standard-squeeze": {
  156415. rootNodeName: string;
  156416. componentProperty: string;
  156417. states: string[];
  156418. };
  156419. "xr-standard-touchpad": {
  156420. rootNodeName: string;
  156421. labelAnchorNodeName: string;
  156422. touchPointNodeName: string;
  156423. };
  156424. "xr-standard-thumbstick": {
  156425. rootNodeName: string;
  156426. componentProperty: string;
  156427. states: string[];
  156428. };
  156429. };
  156430. axes: {
  156431. "xr-standard-touchpad": {
  156432. "x-axis": {
  156433. rootNodeName: string;
  156434. };
  156435. "y-axis": {
  156436. rootNodeName: string;
  156437. };
  156438. };
  156439. "xr-standard-thumbstick": {
  156440. "x-axis": {
  156441. rootNodeName: string;
  156442. };
  156443. "y-axis": {
  156444. rootNodeName: string;
  156445. };
  156446. };
  156447. };
  156448. };
  156449. /**
  156450. * The base url used to load the left and right controller models
  156451. */
  156452. static MODEL_BASE_URL: string;
  156453. /**
  156454. * The name of the left controller model file
  156455. */
  156456. static MODEL_LEFT_FILENAME: string;
  156457. /**
  156458. * The name of the right controller model file
  156459. */
  156460. static MODEL_RIGHT_FILENAME: string;
  156461. profileId: string;
  156462. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156463. protected _getFilenameAndPath(): {
  156464. filename: string;
  156465. path: string;
  156466. };
  156467. protected _getModelLoadingConstraints(): boolean;
  156468. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156469. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156470. protected _updateModel(): void;
  156471. }
  156472. }
  156473. declare module BABYLON {
  156474. /**
  156475. * The motion controller class for oculus touch (quest, rift).
  156476. * This class supports legacy mapping as well the standard xr mapping
  156477. */
  156478. export class WebXROculusTouchMotionController extends WebXRAbstractMotionController {
  156479. private _forceLegacyControllers;
  156480. private _modelRootNode;
  156481. /**
  156482. * The base url used to load the left and right controller models
  156483. */
  156484. static MODEL_BASE_URL: string;
  156485. /**
  156486. * The name of the left controller model file
  156487. */
  156488. static MODEL_LEFT_FILENAME: string;
  156489. /**
  156490. * The name of the right controller model file
  156491. */
  156492. static MODEL_RIGHT_FILENAME: string;
  156493. /**
  156494. * Base Url for the Quest controller model.
  156495. */
  156496. static QUEST_MODEL_BASE_URL: string;
  156497. profileId: string;
  156498. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness, legacyMapping?: boolean, _forceLegacyControllers?: boolean);
  156499. protected _getFilenameAndPath(): {
  156500. filename: string;
  156501. path: string;
  156502. };
  156503. protected _getModelLoadingConstraints(): boolean;
  156504. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156505. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156506. protected _updateModel(): void;
  156507. /**
  156508. * Is this the new type of oculus touch. At the moment both have the same profile and it is impossible to differentiate
  156509. * between the touch and touch 2.
  156510. */
  156511. private _isQuest;
  156512. }
  156513. }
  156514. declare module BABYLON {
  156515. /**
  156516. * The motion controller class for the standard HTC-Vive controllers
  156517. */
  156518. export class WebXRHTCViveMotionController extends WebXRAbstractMotionController {
  156519. private _modelRootNode;
  156520. /**
  156521. * The base url used to load the left and right controller models
  156522. */
  156523. static MODEL_BASE_URL: string;
  156524. /**
  156525. * File name for the controller model.
  156526. */
  156527. static MODEL_FILENAME: string;
  156528. profileId: string;
  156529. /**
  156530. * Create a new Vive motion controller object
  156531. * @param scene the scene to use to create this controller
  156532. * @param gamepadObject the corresponding gamepad object
  156533. * @param handedness the handedness of the controller
  156534. */
  156535. constructor(scene: Scene, gamepadObject: IMinimalMotionControllerObject, handedness: MotionControllerHandedness);
  156536. protected _getFilenameAndPath(): {
  156537. filename: string;
  156538. path: string;
  156539. };
  156540. protected _getModelLoadingConstraints(): boolean;
  156541. protected _processLoadedModel(_meshes: AbstractMesh[]): void;
  156542. protected _setRootMesh(meshes: AbstractMesh[]): void;
  156543. protected _updateModel(): void;
  156544. }
  156545. }
  156546. declare module BABYLON {
  156547. /**
  156548. * A cursor which tracks a point on a path
  156549. */
  156550. export class PathCursor {
  156551. private path;
  156552. /**
  156553. * Stores path cursor callbacks for when an onchange event is triggered
  156554. */
  156555. private _onchange;
  156556. /**
  156557. * The value of the path cursor
  156558. */
  156559. value: number;
  156560. /**
  156561. * The animation array of the path cursor
  156562. */
  156563. animations: Animation[];
  156564. /**
  156565. * Initializes the path cursor
  156566. * @param path The path to track
  156567. */
  156568. constructor(path: Path2);
  156569. /**
  156570. * Gets the cursor point on the path
  156571. * @returns A point on the path cursor at the cursor location
  156572. */
  156573. getPoint(): Vector3;
  156574. /**
  156575. * Moves the cursor ahead by the step amount
  156576. * @param step The amount to move the cursor forward
  156577. * @returns This path cursor
  156578. */
  156579. moveAhead(step?: number): PathCursor;
  156580. /**
  156581. * Moves the cursor behind by the step amount
  156582. * @param step The amount to move the cursor back
  156583. * @returns This path cursor
  156584. */
  156585. moveBack(step?: number): PathCursor;
  156586. /**
  156587. * Moves the cursor by the step amount
  156588. * If the step amount is greater than one, an exception is thrown
  156589. * @param step The amount to move the cursor
  156590. * @returns This path cursor
  156591. */
  156592. move(step: number): PathCursor;
  156593. /**
  156594. * Ensures that the value is limited between zero and one
  156595. * @returns This path cursor
  156596. */
  156597. private ensureLimits;
  156598. /**
  156599. * Runs onchange callbacks on change (used by the animation engine)
  156600. * @returns This path cursor
  156601. */
  156602. private raiseOnChange;
  156603. /**
  156604. * Executes a function on change
  156605. * @param f A path cursor onchange callback
  156606. * @returns This path cursor
  156607. */
  156608. onchange(f: (cursor: PathCursor) => void): PathCursor;
  156609. }
  156610. }
  156611. declare module BABYLON {
  156612. /** @hidden */
  156613. export var blurPixelShader: {
  156614. name: string;
  156615. shader: string;
  156616. };
  156617. }
  156618. declare module BABYLON {
  156619. /** @hidden */
  156620. export var pointCloudVertexDeclaration: {
  156621. name: string;
  156622. shader: string;
  156623. };
  156624. }
  156625. // Mixins
  156626. interface Window {
  156627. mozIndexedDB: IDBFactory;
  156628. webkitIndexedDB: IDBFactory;
  156629. msIndexedDB: IDBFactory;
  156630. webkitURL: typeof URL;
  156631. mozRequestAnimationFrame(callback: FrameRequestCallback): number;
  156632. oRequestAnimationFrame(callback: FrameRequestCallback): number;
  156633. WebGLRenderingContext: WebGLRenderingContext;
  156634. MSGesture: MSGesture;
  156635. CANNON: any;
  156636. AudioContext: AudioContext;
  156637. webkitAudioContext: AudioContext;
  156638. PointerEvent: any;
  156639. Math: Math;
  156640. Uint8Array: Uint8ArrayConstructor;
  156641. Float32Array: Float32ArrayConstructor;
  156642. mozURL: typeof URL;
  156643. msURL: typeof URL;
  156644. VRFrameData: any; // WebVR, from specs 1.1
  156645. DracoDecoderModule: any;
  156646. setImmediate(handler: (...args: any[]) => void): number;
  156647. }
  156648. interface HTMLCanvasElement {
  156649. requestPointerLock(): void;
  156650. msRequestPointerLock?(): void;
  156651. mozRequestPointerLock?(): void;
  156652. webkitRequestPointerLock?(): void;
  156653. /** Track wether a record is in progress */
  156654. isRecording: boolean;
  156655. /** Capture Stream method defined by some browsers */
  156656. captureStream(fps?: number): MediaStream;
  156657. }
  156658. interface CanvasRenderingContext2D {
  156659. msImageSmoothingEnabled: boolean;
  156660. }
  156661. interface MouseEvent {
  156662. mozMovementX: number;
  156663. mozMovementY: number;
  156664. webkitMovementX: number;
  156665. webkitMovementY: number;
  156666. msMovementX: number;
  156667. msMovementY: number;
  156668. }
  156669. interface Navigator {
  156670. mozGetVRDevices: (any: any) => any;
  156671. webkitGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156672. mozGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156673. msGetUserMedia(constraints: MediaStreamConstraints, successCallback: NavigatorUserMediaSuccessCallback, errorCallback: NavigatorUserMediaErrorCallback): void;
  156674. webkitGetGamepads(): Gamepad[];
  156675. msGetGamepads(): Gamepad[];
  156676. webkitGamepads(): Gamepad[];
  156677. }
  156678. interface HTMLVideoElement {
  156679. mozSrcObject: any;
  156680. }
  156681. interface Math {
  156682. fround(x: number): number;
  156683. imul(a: number, b: number): number;
  156684. }
  156685. interface WebGLRenderingContext {
  156686. drawArraysInstanced(mode: number, first: number, count: number, primcount: number): void;
  156687. drawElementsInstanced(mode: number, count: number, type: number, offset: number, primcount: number): void;
  156688. vertexAttribDivisor(index: number, divisor: number): void;
  156689. createVertexArray(): any;
  156690. bindVertexArray(vao?: WebGLVertexArrayObject | null): void;
  156691. deleteVertexArray(vao: WebGLVertexArrayObject): void;
  156692. blitFramebuffer(srcX0: number, srcY0: number, srcX1: number, srcY1: number, dstX0: number, dstY0: number, dstX1: number, dstY1: number, mask: number, filter: number): void;
  156693. renderbufferStorageMultisample?(target: number, samples: number, internalformat: number, width: number, height: number): void;
  156694. bindBufferBase(target: number, index: number, buffer: WebGLBuffer | null): void;
  156695. getUniformBlockIndex(program: WebGLProgram, uniformBlockName: string): number;
  156696. uniformBlockBinding(program: WebGLProgram, uniformBlockIndex: number, uniformBlockBinding: number): void;
  156697. // Queries
  156698. createQuery(): WebGLQuery;
  156699. deleteQuery(query: WebGLQuery): void;
  156700. beginQuery(target: number, query: WebGLQuery): void;
  156701. endQuery(target: number): void;
  156702. getQueryParameter(query: WebGLQuery, pname: number): any;
  156703. getQuery(target: number, pname: number): any;
  156704. MAX_SAMPLES: number;
  156705. RGBA8: number;
  156706. READ_FRAMEBUFFER: number;
  156707. DRAW_FRAMEBUFFER: number;
  156708. UNIFORM_BUFFER: number;
  156709. HALF_FLOAT_OES: number;
  156710. RGBA16F: number;
  156711. RGBA32F: number;
  156712. R32F: number;
  156713. RG32F: number;
  156714. RGB32F: number;
  156715. R16F: number;
  156716. RG16F: number;
  156717. RGB16F: number;
  156718. RED: number;
  156719. RG: number;
  156720. R8: number;
  156721. RG8: number;
  156722. UNSIGNED_INT_24_8: number;
  156723. DEPTH24_STENCIL8: number;
  156724. MIN: number;
  156725. MAX: number;
  156726. /* Multiple Render Targets */
  156727. drawBuffers(buffers: number[]): void;
  156728. readBuffer(src: number): void;
  156729. readonly COLOR_ATTACHMENT0: number; // 0x8CE1
  156730. readonly COLOR_ATTACHMENT1: number; // 0x8CE2
  156731. readonly COLOR_ATTACHMENT2: number; // 0x8CE3
  156732. readonly COLOR_ATTACHMENT3: number; // 0x8CE4
  156733. // Occlusion Query
  156734. ANY_SAMPLES_PASSED_CONSERVATIVE: number;
  156735. ANY_SAMPLES_PASSED: number;
  156736. QUERY_RESULT_AVAILABLE: number;
  156737. QUERY_RESULT: number;
  156738. }
  156739. interface WebGLProgram {
  156740. __SPECTOR_rebuildProgram?: ((vertexSourceCode: string, fragmentSourceCode: string, onCompiled: (program: WebGLProgram) => void, onError: (message: string) => void) => void) | null;
  156741. }
  156742. interface EXT_disjoint_timer_query {
  156743. QUERY_COUNTER_BITS_EXT: number;
  156744. TIME_ELAPSED_EXT: number;
  156745. TIMESTAMP_EXT: number;
  156746. GPU_DISJOINT_EXT: number;
  156747. QUERY_RESULT_EXT: number;
  156748. QUERY_RESULT_AVAILABLE_EXT: number;
  156749. queryCounterEXT(query: WebGLQuery, target: number): void;
  156750. createQueryEXT(): WebGLQuery;
  156751. beginQueryEXT(target: number, query: WebGLQuery): void;
  156752. endQueryEXT(target: number): void;
  156753. getQueryObjectEXT(query: WebGLQuery, target: number): any;
  156754. deleteQueryEXT(query: WebGLQuery): void;
  156755. }
  156756. interface WebGLUniformLocation {
  156757. _currentState: any;
  156758. }
  156759. // Type definitions for WebGL 2, Editor's Draft Fri Feb 24 16:10:18 2017 -0800
  156760. // Project: https://www.khronos.org/registry/webgl/specs/latest/2.0/
  156761. // Definitions by: Nico Kemnitz <https://github.com/nkemnitz/>
  156762. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156763. interface WebGLRenderingContext {
  156764. readonly RASTERIZER_DISCARD: number;
  156765. readonly DEPTH_COMPONENT24: number;
  156766. readonly TEXTURE_3D: number;
  156767. readonly TEXTURE_2D_ARRAY: number;
  156768. readonly TEXTURE_COMPARE_FUNC: number;
  156769. readonly TEXTURE_COMPARE_MODE: number;
  156770. readonly COMPARE_REF_TO_TEXTURE: number;
  156771. readonly TEXTURE_WRAP_R: number;
  156772. readonly HALF_FLOAT: number;
  156773. readonly RGB8: number;
  156774. readonly RED_INTEGER: number;
  156775. readonly RG_INTEGER: number;
  156776. readonly RGB_INTEGER: number;
  156777. readonly RGBA_INTEGER: number;
  156778. readonly R8_SNORM: number;
  156779. readonly RG8_SNORM: number;
  156780. readonly RGB8_SNORM: number;
  156781. readonly RGBA8_SNORM: number;
  156782. readonly R8I: number;
  156783. readonly RG8I: number;
  156784. readonly RGB8I: number;
  156785. readonly RGBA8I: number;
  156786. readonly R8UI: number;
  156787. readonly RG8UI: number;
  156788. readonly RGB8UI: number;
  156789. readonly RGBA8UI: number;
  156790. readonly R16I: number;
  156791. readonly RG16I: number;
  156792. readonly RGB16I: number;
  156793. readonly RGBA16I: number;
  156794. readonly R16UI: number;
  156795. readonly RG16UI: number;
  156796. readonly RGB16UI: number;
  156797. readonly RGBA16UI: number;
  156798. readonly R32I: number;
  156799. readonly RG32I: number;
  156800. readonly RGB32I: number;
  156801. readonly RGBA32I: number;
  156802. readonly R32UI: number;
  156803. readonly RG32UI: number;
  156804. readonly RGB32UI: number;
  156805. readonly RGBA32UI: number;
  156806. readonly RGB10_A2UI: number;
  156807. readonly R11F_G11F_B10F: number;
  156808. readonly RGB9_E5: number;
  156809. readonly RGB10_A2: number;
  156810. readonly UNSIGNED_INT_2_10_10_10_REV: number;
  156811. readonly UNSIGNED_INT_10F_11F_11F_REV: number;
  156812. readonly UNSIGNED_INT_5_9_9_9_REV: number;
  156813. readonly FLOAT_32_UNSIGNED_INT_24_8_REV: number;
  156814. readonly DEPTH_COMPONENT32F: number;
  156815. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView | null): void;
  156816. texImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, format: number, type: number, pixels: ArrayBufferView, offset: number): void;
  156817. 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;
  156818. framebufferTextureLayer(target: number, attachment: number, texture: WebGLTexture | null, level: number, layer: number): void;
  156819. compressedTexImage3D(target: number, level: number, internalformat: number, width: number, height: number, depth: number, border: number, data: ArrayBufferView, offset?: number, length?: number): void;
  156820. readonly TRANSFORM_FEEDBACK: number;
  156821. readonly INTERLEAVED_ATTRIBS: number;
  156822. readonly TRANSFORM_FEEDBACK_BUFFER: number;
  156823. createTransformFeedback(): WebGLTransformFeedback;
  156824. deleteTransformFeedback(transformFeedbac: WebGLTransformFeedback): void;
  156825. bindTransformFeedback(target: number, transformFeedback: WebGLTransformFeedback | null): void;
  156826. beginTransformFeedback(primitiveMode: number): void;
  156827. endTransformFeedback(): void;
  156828. transformFeedbackVaryings(program: WebGLProgram, varyings: string[], bufferMode: number): void;
  156829. clearBufferfv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156830. clearBufferiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156831. clearBufferuiv(buffer: number, drawbuffer: number, values: ArrayBufferView, srcOffset: number | null): void;
  156832. clearBufferfi(buffer: number, drawbuffer: number, depth: number, stencil: number): void;
  156833. }
  156834. interface ImageBitmap {
  156835. readonly width: number;
  156836. readonly height: number;
  156837. close(): void;
  156838. }
  156839. interface WebGLQuery extends WebGLObject {
  156840. }
  156841. declare var WebGLQuery: {
  156842. prototype: WebGLQuery;
  156843. new(): WebGLQuery;
  156844. };
  156845. interface WebGLSampler extends WebGLObject {
  156846. }
  156847. declare var WebGLSampler: {
  156848. prototype: WebGLSampler;
  156849. new(): WebGLSampler;
  156850. };
  156851. interface WebGLSync extends WebGLObject {
  156852. }
  156853. declare var WebGLSync: {
  156854. prototype: WebGLSync;
  156855. new(): WebGLSync;
  156856. };
  156857. interface WebGLTransformFeedback extends WebGLObject {
  156858. }
  156859. declare var WebGLTransformFeedback: {
  156860. prototype: WebGLTransformFeedback;
  156861. new(): WebGLTransformFeedback;
  156862. };
  156863. interface WebGLVertexArrayObject extends WebGLObject {
  156864. }
  156865. declare var WebGLVertexArrayObject: {
  156866. prototype: WebGLVertexArrayObject;
  156867. new(): WebGLVertexArrayObject;
  156868. };
  156869. // Type definitions for WebVR API
  156870. // Project: https://w3c.github.io/webvr/
  156871. // Definitions by: six a <https://github.com/lostfictions>
  156872. // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
  156873. interface VRDisplay extends EventTarget {
  156874. /**
  156875. * Dictionary of capabilities describing the VRDisplay.
  156876. */
  156877. readonly capabilities: VRDisplayCapabilities;
  156878. /**
  156879. * z-depth defining the far plane of the eye view frustum
  156880. * enables mapping of values in the render target depth
  156881. * attachment to scene coordinates. Initially set to 10000.0.
  156882. */
  156883. depthFar: number;
  156884. /**
  156885. * z-depth defining the near plane of the eye view frustum
  156886. * enables mapping of values in the render target depth
  156887. * attachment to scene coordinates. Initially set to 0.01.
  156888. */
  156889. depthNear: number;
  156890. /**
  156891. * An identifier for this distinct VRDisplay. Used as an
  156892. * association point in the Gamepad API.
  156893. */
  156894. readonly displayId: number;
  156895. /**
  156896. * A display name, a user-readable name identifying it.
  156897. */
  156898. readonly displayName: string;
  156899. readonly isConnected: boolean;
  156900. readonly isPresenting: boolean;
  156901. /**
  156902. * If this VRDisplay supports room-scale experiences, the optional
  156903. * stage attribute contains details on the room-scale parameters.
  156904. */
  156905. readonly stageParameters: VRStageParameters | null;
  156906. /**
  156907. * Passing the value returned by `requestAnimationFrame` to
  156908. * `cancelAnimationFrame` will unregister the callback.
  156909. * @param handle Define the hanle of the request to cancel
  156910. */
  156911. cancelAnimationFrame(handle: number): void;
  156912. /**
  156913. * Stops presenting to the VRDisplay.
  156914. * @returns a promise to know when it stopped
  156915. */
  156916. exitPresent(): Promise<void>;
  156917. /**
  156918. * Return the current VREyeParameters for the given eye.
  156919. * @param whichEye Define the eye we want the parameter for
  156920. * @returns the eye parameters
  156921. */
  156922. getEyeParameters(whichEye: string): VREyeParameters;
  156923. /**
  156924. * Populates the passed VRFrameData with the information required to render
  156925. * the current frame.
  156926. * @param frameData Define the data structure to populate
  156927. * @returns true if ok otherwise false
  156928. */
  156929. getFrameData(frameData: VRFrameData): boolean;
  156930. /**
  156931. * Get the layers currently being presented.
  156932. * @returns the list of VR layers
  156933. */
  156934. getLayers(): VRLayer[];
  156935. /**
  156936. * Return a VRPose containing the future predicted pose of the VRDisplay
  156937. * when the current frame will be presented. The value returned will not
  156938. * change until JavaScript has returned control to the browser.
  156939. *
  156940. * The VRPose will contain the position, orientation, velocity,
  156941. * and acceleration of each of these properties.
  156942. * @returns the pose object
  156943. */
  156944. getPose(): VRPose;
  156945. /**
  156946. * Return the current instantaneous pose of the VRDisplay, with no
  156947. * prediction applied.
  156948. * @returns the current instantaneous pose
  156949. */
  156950. getImmediatePose(): VRPose;
  156951. /**
  156952. * The callback passed to `requestAnimationFrame` will be called
  156953. * any time a new frame should be rendered. When the VRDisplay is
  156954. * presenting the callback will be called at the native refresh
  156955. * rate of the HMD. When not presenting this function acts
  156956. * identically to how window.requestAnimationFrame acts. Content should
  156957. * make no assumptions of frame rate or vsync behavior as the HMD runs
  156958. * asynchronously from other displays and at differing refresh rates.
  156959. * @param callback Define the eaction to run next frame
  156960. * @returns the request handle it
  156961. */
  156962. requestAnimationFrame(callback: FrameRequestCallback): number;
  156963. /**
  156964. * Begin presenting to the VRDisplay. Must be called in response to a user gesture.
  156965. * Repeat calls while already presenting will update the VRLayers being displayed.
  156966. * @param layers Define the list of layer to present
  156967. * @returns a promise to know when the request has been fulfilled
  156968. */
  156969. requestPresent(layers: VRLayer[]): Promise<void>;
  156970. /**
  156971. * Reset the pose for this display, treating its current position and
  156972. * orientation as the "origin/zero" values. VRPose.position,
  156973. * VRPose.orientation, and VRStageParameters.sittingToStandingTransform may be
  156974. * updated when calling resetPose(). This should be called in only
  156975. * sitting-space experiences.
  156976. */
  156977. resetPose(): void;
  156978. /**
  156979. * The VRLayer provided to the VRDisplay will be captured and presented
  156980. * in the HMD. Calling this function has the same effect on the source
  156981. * canvas as any other operation that uses its source image, and canvases
  156982. * created without preserveDrawingBuffer set to true will be cleared.
  156983. * @param pose Define the pose to submit
  156984. */
  156985. submitFrame(pose?: VRPose): void;
  156986. }
  156987. declare var VRDisplay: {
  156988. prototype: VRDisplay;
  156989. new(): VRDisplay;
  156990. };
  156991. interface VRLayer {
  156992. leftBounds?: number[] | Float32Array | null;
  156993. rightBounds?: number[] | Float32Array | null;
  156994. source?: HTMLCanvasElement | null;
  156995. }
  156996. interface VRDisplayCapabilities {
  156997. readonly canPresent: boolean;
  156998. readonly hasExternalDisplay: boolean;
  156999. readonly hasOrientation: boolean;
  157000. readonly hasPosition: boolean;
  157001. readonly maxLayers: number;
  157002. }
  157003. interface VREyeParameters {
  157004. /** @deprecated */
  157005. readonly fieldOfView: VRFieldOfView;
  157006. readonly offset: Float32Array;
  157007. readonly renderHeight: number;
  157008. readonly renderWidth: number;
  157009. }
  157010. interface VRFieldOfView {
  157011. readonly downDegrees: number;
  157012. readonly leftDegrees: number;
  157013. readonly rightDegrees: number;
  157014. readonly upDegrees: number;
  157015. }
  157016. interface VRFrameData {
  157017. readonly leftProjectionMatrix: Float32Array;
  157018. readonly leftViewMatrix: Float32Array;
  157019. readonly pose: VRPose;
  157020. readonly rightProjectionMatrix: Float32Array;
  157021. readonly rightViewMatrix: Float32Array;
  157022. readonly timestamp: number;
  157023. }
  157024. interface VRPose {
  157025. readonly angularAcceleration: Float32Array | null;
  157026. readonly angularVelocity: Float32Array | null;
  157027. readonly linearAcceleration: Float32Array | null;
  157028. readonly linearVelocity: Float32Array | null;
  157029. readonly orientation: Float32Array | null;
  157030. readonly position: Float32Array | null;
  157031. readonly timestamp: number;
  157032. }
  157033. interface VRStageParameters {
  157034. sittingToStandingTransform?: Float32Array;
  157035. sizeX?: number;
  157036. sizeY?: number;
  157037. }
  157038. interface Navigator {
  157039. getVRDisplays(): Promise<VRDisplay[]>;
  157040. readonly activeVRDisplays: ReadonlyArray<VRDisplay>;
  157041. }
  157042. interface Window {
  157043. onvrdisplayconnected: ((this: Window, ev: Event) => any) | null;
  157044. onvrdisplaydisconnected: ((this: Window, ev: Event) => any) | null;
  157045. onvrdisplaypresentchange: ((this: Window, ev: Event) => any) | null;
  157046. addEventListener(type: "vrdisplayconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157047. addEventListener(type: "vrdisplaydisconnected", listener: (ev: Event) => any, useCapture?: boolean): void;
  157048. addEventListener(type: "vrdisplaypresentchange", listener: (ev: Event) => any, useCapture?: boolean): void;
  157049. }
  157050. interface Gamepad {
  157051. readonly displayId: number;
  157052. }
  157053. type XRSessionMode = "inline" | "immersive-vr" | "immersive-ar";
  157054. type XRReferenceSpaceType = "viewer" | "local" | "local-floor" | "bounded-floor" | "unbounded";
  157055. type XREnvironmentBlendMode = "opaque" | "additive" | "alpha-blend";
  157056. type XRVisibilityState = "visible" | "visible-blurred" | "hidden";
  157057. type XRHandedness = "none" | "left" | "right";
  157058. type XRTargetRayMode = "gaze" | "tracked-pointer" | "screen";
  157059. type XREye = "none" | "left" | "right";
  157060. type XREventType = "devicechange" | "visibilitychange" | "end" | "inputsourceschange" | "select" | "selectstart" | "selectend" | "squeeze" | "squeezestart" | "squeezeend" | "reset";
  157061. interface XRSpace extends EventTarget {}
  157062. interface XRRenderState {
  157063. depthNear?: number;
  157064. depthFar?: number;
  157065. inlineVerticalFieldOfView?: number;
  157066. baseLayer?: XRWebGLLayer;
  157067. }
  157068. interface XRInputSource {
  157069. handedness: XRHandedness;
  157070. targetRayMode: XRTargetRayMode;
  157071. targetRaySpace: XRSpace;
  157072. gripSpace: XRSpace | undefined;
  157073. gamepad: Gamepad | undefined;
  157074. profiles: Array<string>;
  157075. hand: XRHand | undefined;
  157076. }
  157077. interface XRSessionInit {
  157078. optionalFeatures?: string[];
  157079. requiredFeatures?: string[];
  157080. }
  157081. interface XRSession {
  157082. addEventListener: Function;
  157083. removeEventListener: Function;
  157084. requestReferenceSpace(type: XRReferenceSpaceType): Promise<XRReferenceSpace>;
  157085. updateRenderState(XRRenderStateInit: XRRenderState): Promise<void>;
  157086. requestAnimationFrame: Function;
  157087. end(): Promise<void>;
  157088. renderState: XRRenderState;
  157089. inputSources: Array<XRInputSource>;
  157090. // hit test
  157091. requestHitTestSource(options: XRHitTestOptionsInit): Promise<XRHitTestSource>;
  157092. requestHitTestSourceForTransientInput(options: XRTransientInputHitTestOptionsInit): Promise<XRTransientInputHitTestSource>;
  157093. // legacy AR hit test
  157094. requestHitTest(ray: XRRay, referenceSpace: XRReferenceSpace): Promise<XRHitResult[]>;
  157095. // legacy plane detection
  157096. updateWorldTrackingState(options: { planeDetectionState?: { enabled: boolean } }): void;
  157097. }
  157098. interface XRReferenceSpace extends XRSpace {
  157099. getOffsetReferenceSpace(originOffset: XRRigidTransform): XRReferenceSpace;
  157100. onreset: any;
  157101. }
  157102. type XRPlaneSet = Set<XRPlane>;
  157103. type XRAnchorSet = Set<XRAnchor>;
  157104. interface XRFrame {
  157105. session: XRSession;
  157106. getViewerPose(referenceSpace: XRReferenceSpace): XRViewerPose | undefined;
  157107. getPose(space: XRSpace, baseSpace: XRSpace): XRPose | undefined;
  157108. // AR
  157109. getHitTestResults(hitTestSource: XRHitTestSource): Array<XRHitTestResult>;
  157110. getHitTestResultsForTransientInput(hitTestSource: XRTransientInputHitTestSource): Array<XRTransientInputHitTestResult>;
  157111. // Anchors
  157112. trackedAnchors?: XRAnchorSet;
  157113. createAnchor(pose: XRRigidTransform, space: XRSpace): Promise<XRAnchor>;
  157114. // Planes
  157115. worldInformation: {
  157116. detectedPlanes?: XRPlaneSet;
  157117. };
  157118. // Hand tracking
  157119. getJointPose(joint: XRJointSpace, baseSpace: XRSpace): XRJointPose;
  157120. }
  157121. interface XRViewerPose extends XRPose {
  157122. views: Array<XRView>;
  157123. }
  157124. interface XRPose {
  157125. transform: XRRigidTransform;
  157126. emulatedPosition: boolean;
  157127. }
  157128. interface XRWebGLLayerOptions {
  157129. antialias?: boolean;
  157130. depth?: boolean;
  157131. stencil?: boolean;
  157132. alpha?: boolean;
  157133. multiview?: boolean;
  157134. framebufferScaleFactor?: number;
  157135. }
  157136. declare var XRWebGLLayer: {
  157137. prototype: XRWebGLLayer;
  157138. new (session: XRSession, context: WebGLRenderingContext | undefined, options?: XRWebGLLayerOptions): XRWebGLLayer;
  157139. };
  157140. interface XRWebGLLayer {
  157141. framebuffer: WebGLFramebuffer;
  157142. framebufferWidth: number;
  157143. framebufferHeight: number;
  157144. getViewport: Function;
  157145. }
  157146. declare class XRRigidTransform {
  157147. constructor(matrix: Float32Array | DOMPointInit, direction?: DOMPointInit);
  157148. position: DOMPointReadOnly;
  157149. orientation: DOMPointReadOnly;
  157150. matrix: Float32Array;
  157151. inverse: XRRigidTransform;
  157152. }
  157153. interface XRView {
  157154. eye: XREye;
  157155. projectionMatrix: Float32Array;
  157156. transform: XRRigidTransform;
  157157. }
  157158. interface XRInputSourceChangeEvent {
  157159. session: XRSession;
  157160. removed: Array<XRInputSource>;
  157161. added: Array<XRInputSource>;
  157162. }
  157163. interface XRInputSourceEvent extends Event {
  157164. readonly frame: XRFrame;
  157165. readonly inputSource: XRInputSource;
  157166. }
  157167. // Experimental(er) features
  157168. declare class XRRay {
  157169. constructor(transformOrOrigin: XRRigidTransform | DOMPointInit, direction?: DOMPointInit);
  157170. origin: DOMPointReadOnly;
  157171. direction: DOMPointReadOnly;
  157172. matrix: Float32Array;
  157173. }
  157174. declare enum XRHitTestTrackableType {
  157175. "point",
  157176. "plane",
  157177. "mesh",
  157178. }
  157179. interface XRHitResult {
  157180. hitMatrix: Float32Array;
  157181. }
  157182. interface XRTransientInputHitTestResult {
  157183. readonly inputSource: XRInputSource;
  157184. readonly results: Array<XRHitTestResult>;
  157185. }
  157186. interface XRHitTestResult {
  157187. getPose(baseSpace: XRSpace): XRPose | undefined;
  157188. // When anchor system is enabled
  157189. createAnchor?(pose: XRRigidTransform): Promise<XRAnchor>;
  157190. }
  157191. interface XRHitTestSource {
  157192. cancel(): void;
  157193. }
  157194. interface XRTransientInputHitTestSource {
  157195. cancel(): void;
  157196. }
  157197. interface XRHitTestOptionsInit {
  157198. space: XRSpace;
  157199. entityTypes?: Array<XRHitTestTrackableType>;
  157200. offsetRay?: XRRay;
  157201. }
  157202. interface XRTransientInputHitTestOptionsInit {
  157203. profile: string;
  157204. entityTypes?: Array<XRHitTestTrackableType>;
  157205. offsetRay?: XRRay;
  157206. }
  157207. interface XRAnchor {
  157208. anchorSpace: XRSpace;
  157209. delete(): void;
  157210. }
  157211. interface XRPlane {
  157212. orientation: "Horizontal" | "Vertical";
  157213. planeSpace: XRSpace;
  157214. polygon: Array<DOMPointReadOnly>;
  157215. lastChangedTime: number;
  157216. }
  157217. interface XRJointSpace extends XRSpace {}
  157218. interface XRJointPose extends XRPose {
  157219. radius: number | undefined;
  157220. }
  157221. interface XRHand /*extends Iterablele<XRJointSpace>*/ {
  157222. readonly length: number;
  157223. [index: number]: XRJointSpace;
  157224. // Specs have the function 'joint(idx: number)', but chrome doesn't support it yet.
  157225. readonly WRIST: number;
  157226. readonly THUMB_METACARPAL: number;
  157227. readonly THUMB_PHALANX_PROXIMAL: number;
  157228. readonly THUMB_PHALANX_DISTAL: number;
  157229. readonly THUMB_PHALANX_TIP: number;
  157230. readonly INDEX_METACARPAL: number;
  157231. readonly INDEX_PHALANX_PROXIMAL: number;
  157232. readonly INDEX_PHALANX_INTERMEDIATE: number;
  157233. readonly INDEX_PHALANX_DISTAL: number;
  157234. readonly INDEX_PHALANX_TIP: number;
  157235. readonly MIDDLE_METACARPAL: number;
  157236. readonly MIDDLE_PHALANX_PROXIMAL: number;
  157237. readonly MIDDLE_PHALANX_INTERMEDIATE: number;
  157238. readonly MIDDLE_PHALANX_DISTAL: number;
  157239. readonly MIDDLE_PHALANX_TIP: number;
  157240. readonly RING_METACARPAL: number;
  157241. readonly RING_PHALANX_PROXIMAL: number;
  157242. readonly RING_PHALANX_INTERMEDIATE: number;
  157243. readonly RING_PHALANX_DISTAL: number;
  157244. readonly RING_PHALANX_TIP: number;
  157245. readonly LITTLE_METACARPAL: number;
  157246. readonly LITTLE_PHALANX_PROXIMAL: number;
  157247. readonly LITTLE_PHALANX_INTERMEDIATE: number;
  157248. readonly LITTLE_PHALANX_DISTAL: number;
  157249. readonly LITTLE_PHALANX_TIP: number;
  157250. }
  157251. // This file contains native only extensions for WebXR These APIs are not supported in the browser yet.
  157252. // They are intended for use with either Babylon Native https://github.com/BabylonJS/BabylonNative or
  157253. // Babylon React Native: https://github.com/BabylonJS/BabylonReactNative
  157254. interface XRSession {
  157255. trySetFeaturePointCloudEnabled(enabled: boolean): boolean;
  157256. }
  157257. interface XRFrame {
  157258. featurePointCloud? : Array<number>;
  157259. }